blob: df73811d718ce79b56b84d7d93c27e4565e39263 [file] [log] [blame]
Neels Hofmeyr3a8e7232017-09-04 01:02:56 +02001#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
10struct msgb;
11struct vty;
12struct mgcp_client;
13
14struct 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
24typedef unsigned int mgcp_trans_id_t;
25
26struct mgcp_response_head {
27 int response_code;
28 mgcp_trans_id_t trans_id;
29 const char *comment;
30};
31
32struct mgcp_response {
33 char *body;
34 struct mgcp_response_head head;
35 uint16_t audio_port;
36};
37
38void mgcp_client_conf_init(struct mgcp_client_conf *conf);
39void mgcp_client_vty_init(void *talloc_ctx, int node, struct mgcp_client_conf *conf);
40int mgcp_client_config_write(struct vty *vty, const char *indent);
41struct mgcp_client_conf *mgcp_client_conf_actual(struct mgcp_client *mgcp);
42
43struct mgcp_client *mgcp_client_init(void *ctx,
44 struct mgcp_client_conf *conf);
45int mgcp_client_connect(struct mgcp_client *mgcp);
46
47const char *mgcp_client_remote_addr_str(struct mgcp_client *mgcp);
48uint16_t mgcp_client_remote_port(struct mgcp_client *mgcp);
49uint32_t mgcp_client_remote_addr_n(struct mgcp_client *mgcp);
50
51int mgcp_client_next_endpoint(struct mgcp_client *client);
52void 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. */
56typedef void (* mgcp_response_cb_t )(struct mgcp_response *response, void *priv);
57int mgcp_response_parse_params(struct mgcp_response *r);
58
59int mgcp_client_tx(struct mgcp_client *mgcp, struct msgb *msg,
60 mgcp_response_cb_t response_cb, void *priv);
61
62enum mgcp_connection_mode;
63
64struct msgb *mgcp_msg_crcx(struct mgcp_client *mgcp,
65 uint16_t rtp_endpoint, unsigned int call_id,
66 enum mgcp_connection_mode mode);
67
68struct 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
72struct msgb *mgcp_msg_dlcx(struct mgcp_client *mgcp, uint16_t rtp_endpoint,
73 unsigned int call_id);