Neels Hofmeyr | 3a8e723 | 2017-09-04 01:02:56 +0200 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | |
| 5 | #define MGCP_CLIENT_LOCAL_ADDR_DEFAULT "0.0.0.0" |
| 6 | #define MGCP_CLIENT_LOCAL_PORT_DEFAULT 0 |
| 7 | #define MGCP_CLIENT_REMOTE_ADDR_DEFAULT "127.0.0.1" |
| 8 | #define MGCP_CLIENT_REMOTE_PORT_DEFAULT 2427 |
| 9 | |
| 10 | struct msgb; |
| 11 | struct vty; |
| 12 | struct mgcp_client; |
| 13 | |
| 14 | struct mgcp_client_conf { |
| 15 | const char *local_addr; |
| 16 | int local_port; |
| 17 | const char *remote_addr; |
| 18 | int remote_port; |
| 19 | uint16_t first_endpoint; |
| 20 | uint16_t last_endpoint; |
| 21 | uint16_t bts_base; |
| 22 | }; |
| 23 | |
| 24 | typedef unsigned int mgcp_trans_id_t; |
| 25 | |
| 26 | struct mgcp_response_head { |
| 27 | int response_code; |
| 28 | mgcp_trans_id_t trans_id; |
| 29 | const char *comment; |
| 30 | }; |
| 31 | |
| 32 | struct mgcp_response { |
| 33 | char *body; |
| 34 | struct mgcp_response_head head; |
| 35 | uint16_t audio_port; |
| 36 | }; |
| 37 | |
| 38 | void mgcp_client_conf_init(struct mgcp_client_conf *conf); |
| 39 | void mgcp_client_vty_init(void *talloc_ctx, int node, struct mgcp_client_conf *conf); |
| 40 | int mgcp_client_config_write(struct vty *vty, const char *indent); |
| 41 | struct mgcp_client_conf *mgcp_client_conf_actual(struct mgcp_client *mgcp); |
| 42 | |
| 43 | struct mgcp_client *mgcp_client_init(void *ctx, |
| 44 | struct mgcp_client_conf *conf); |
| 45 | int mgcp_client_connect(struct mgcp_client *mgcp); |
| 46 | |
| 47 | const char *mgcp_client_remote_addr_str(struct mgcp_client *mgcp); |
| 48 | uint16_t mgcp_client_remote_port(struct mgcp_client *mgcp); |
| 49 | uint32_t mgcp_client_remote_addr_n(struct mgcp_client *mgcp); |
| 50 | |
| 51 | int mgcp_client_next_endpoint(struct mgcp_client *client); |
| 52 | void mgcp_client_release_endpoint(uint16_t id, struct mgcp_client *client); |
| 53 | |
| 54 | /* Invoked when an MGCP response is received or sending failed. When the |
| 55 | * response is passed as NULL, this indicates failure during transmission. */ |
| 56 | typedef void (* mgcp_response_cb_t )(struct mgcp_response *response, void *priv); |
| 57 | int mgcp_response_parse_params(struct mgcp_response *r); |
| 58 | |
| 59 | int mgcp_client_tx(struct mgcp_client *mgcp, struct msgb *msg, |
| 60 | mgcp_response_cb_t response_cb, void *priv); |
| 61 | |
| 62 | enum mgcp_connection_mode; |
| 63 | |
| 64 | struct msgb *mgcp_msg_crcx(struct mgcp_client *mgcp, |
| 65 | uint16_t rtp_endpoint, unsigned int call_id, |
| 66 | enum mgcp_connection_mode mode); |
| 67 | |
| 68 | struct msgb *mgcp_msg_mdcx(struct mgcp_client *mgcp, |
| 69 | uint16_t rtp_endpoint, const char *rtp_conn_addr, |
| 70 | uint16_t rtp_port, enum mgcp_connection_mode mode); |
| 71 | |
| 72 | struct msgb *mgcp_msg_dlcx(struct mgcp_client *mgcp, uint16_t rtp_endpoint, |
| 73 | unsigned int call_id); |