Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1 | #ifndef _OSMO_IPA_H_ |
| 2 | #define _OSMO_IPA_H_ |
| 3 | |
Pablo Neira Ayuso | 9b3a33c | 2011-06-21 13:52:41 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 5 | #include <osmocom/core/linuxlist.h> |
| 6 | #include <osmocom/core/timer.h> |
| 7 | |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame^] | 8 | struct ipa_server_link { |
| 9 | struct e1inp_line *line; |
| 10 | struct osmo_fd ofd; |
| 11 | struct llist_head tx_queue; |
| 12 | const char *addr; |
| 13 | uint16_t port; |
| 14 | int (*accept_cb)(struct ipa_server_link *link, int fd); |
| 15 | }; |
| 16 | |
| 17 | struct ipa_server_link *ipa_server_link_create(void *ctx, struct e1inp_line *line, const char *addr, uint16_t port, int (*accept_cb)(struct ipa_server_link *link, int fd)); |
| 18 | void ipa_server_link_destroy(struct ipa_server_link *link); |
| 19 | |
| 20 | int ipa_server_link_open(struct ipa_server_link *link); |
| 21 | void ipa_server_link_close(struct ipa_server_link *link); |
| 22 | |
Pablo Neira Ayuso | c07a8e7 | 2011-06-21 19:50:04 +0200 | [diff] [blame] | 23 | enum ipa_client_link_state { |
| 24 | IPA_CLIENT_LINK_STATE_NONE = 0, |
| 25 | IPA_CLIENT_LINK_STATE_CONNECTING = 1, |
| 26 | IPA_CLIENT_LINK_STATE_CONNECTED = 2, |
| 27 | IPA_CLIENT_LINK_STATE_MAX |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 28 | }; |
| 29 | |
Pablo Neira Ayuso | c07a8e7 | 2011-06-21 19:50:04 +0200 | [diff] [blame] | 30 | struct ipa_client_link { |
| 31 | struct e1inp_line *line; |
| 32 | struct osmo_fd ofd; |
| 33 | struct llist_head tx_queue; |
| 34 | struct osmo_timer_list timer; |
| 35 | enum ipa_client_link_state state; |
| 36 | const char *addr; |
| 37 | uint16_t port; |
| 38 | int (*cb)(struct ipa_client_link *link, struct msgb *msg); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 39 | }; |
| 40 | |
Pablo Neira Ayuso | c07a8e7 | 2011-06-21 19:50:04 +0200 | [diff] [blame] | 41 | struct ipa_client_link *ipa_client_link_create(void *ctx, struct e1inp_line *line, const char *addr, uint16_t port, int (*cb)(struct ipa_client_link *link, struct msgb *msgb)); |
| 42 | void ipa_client_link_destroy(struct ipa_client_link *link); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 43 | |
Pablo Neira Ayuso | c07a8e7 | 2011-06-21 19:50:04 +0200 | [diff] [blame] | 44 | int ipa_client_link_open(struct ipa_client_link *link); |
| 45 | void ipa_client_link_close(struct ipa_client_link *link); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 46 | |
| 47 | int ipa_msg_recv(int fd, struct msgb **rmsg); |
| 48 | |
| 49 | #endif |