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