blob: 423c00e662e9f10803c5ef30d63c5374f8b852b2 [file] [log] [blame]
Neels Hofmeyre9920f22017-07-10 15:07:22 +02001#pragma once
2
Neels Hofmeyrd95ab1e2017-09-22 00:52:54 +02003#include <osmocom/core/write_queue.h>
Pau Espin Pedrol563386e2023-06-14 12:20:49 +02004#include <osmocom/core/timer.h>
Neels Hofmeyrd95ab1e2017-09-22 00:52:54 +02005
Neels Hofmeyre9920f22017-07-10 15:07:22 +02006#define MSGB_CB_MGCP_TRANS_ID 0
7
Philipp Maier3f2c15f2021-07-22 11:53:07 +02008/* Struct that holds one endpoint name */
9struct reset_ep {
10 struct llist_head list;
11 char name[MGCP_ENDPOINT_MAXLEN];
12};
13
Neels Hofmeyr3a8e7232017-09-04 01:02:56 +020014struct mgcp_client {
15 struct mgcp_client_conf actual;
Neels Hofmeyre9920f22017-07-10 15:07:22 +020016 struct osmo_wqueue wq;
17 mgcp_trans_id_t next_trans_id;
18 struct llist_head responses_pending;
Pau Espin Pedrol35bd2522022-10-13 17:26:33 +020019 struct mgcp_client_pool_member *pool_member;
Pau Espin Pedrol563386e2023-06-14 12:20:49 +020020 struct osmo_timer_list keepalive_tx_timer;
21 struct osmo_timer_list keepalive_rx_timer;
22 bool conn_up;
Neels Hofmeyre9920f22017-07-10 15:07:22 +020023};
24
Neels Hofmeyr18717f52023-12-07 02:32:00 +010025struct mgcp_response_head {
26 int response_code;
27 mgcp_trans_id_t trans_id;
28 char comment[MGCP_COMMENT_MAXLEN];
29 char conn_id[MGCP_CONN_ID_MAXLEN];
30 char endpoint[MGCP_ENDPOINT_MAXLEN];
31 bool x_osmo_osmux_use;
32 uint8_t x_osmo_osmux_cid;
33};
34
35struct mgcp_response {
36 char *body;
37 struct mgcp_response_head head;
38 uint16_t audio_port;
39 char audio_ip[INET6_ADDRSTRLEN];
40 unsigned int ptime;
Neels Hofmeyr18717f52023-12-07 02:32:00 +010041 struct ptmap ptmap[MGCP_MAX_CODECS];
42 unsigned int ptmap_len;
43};
44
45/* Invoked when an MGCP response is received or sending failed. When the
46 * response is passed as NULL, this indicates failure during transmission. */
47typedef void (*mgcp_response_cb_t)(struct mgcp_response *response, void *priv);
48
Neels Hofmeyre9920f22017-07-10 15:07:22 +020049struct mgcp_response_pending {
50 struct llist_head entry;
51
52 mgcp_trans_id_t trans_id;
53 mgcp_response_cb_t response_cb;
54 void *priv;
55};
56
Neels Hofmeyr3a8e7232017-09-04 01:02:56 +020057int mgcp_client_rx(struct mgcp_client *mgcp, struct msgb *msg);
Neels Hofmeyre9920f22017-07-10 15:07:22 +020058
Neels Hofmeyr3a8e7232017-09-04 01:02:56 +020059struct mgcp_response_pending * mgcp_client_pending_add(
60 struct mgcp_client *mgcp,
Neels Hofmeyre9920f22017-07-10 15:07:22 +020061 mgcp_trans_id_t trans_id,
62 mgcp_response_cb_t response_cb,
63 void *priv);
Neels Hofmeyr18717f52023-12-07 02:32:00 +010064
65#define MGCP_MSG_PRESENCE_ENDPOINT 0x0001
66#define MGCP_MSG_PRESENCE_CALL_ID 0x0002
67#define MGCP_MSG_PRESENCE_CONN_ID 0x0004
68#define MGCP_MSG_PRESENCE_AUDIO_IP 0x0008
69#define MGCP_MSG_PRESENCE_AUDIO_PORT 0x0010
70#define MGCP_MSG_PRESENCE_CONN_MODE 0x0020
71#define MGCP_MSG_PRESENCE_X_OSMO_OSMUX_CID 0x4000
72#define MGCP_MSG_PRESENCE_X_OSMO_IGN 0x8000
73
74struct mgcp_msg {
75 enum mgcp_verb verb;
76 /* See MGCP_MSG_PRESENCE_* constants */
77 uint32_t presence;
78 char endpoint[MGCP_ENDPOINT_MAXLEN];
79 unsigned int call_id;
80 char *conn_id;
81 uint16_t audio_port;
82 char *audio_ip;
83 enum mgcp_connection_mode conn_mode;
84 unsigned int ptime;
Neels Hofmeyr18717f52023-12-07 02:32:00 +010085 struct ptmap ptmap[MGCP_MAX_CODECS];
86 unsigned int ptmap_len;
87 uint32_t x_osmo_ign;
88 bool x_osmo_osmux_use;
89 int x_osmo_osmux_cid; /* -1 is wildcard */
90 bool param_present;
91 struct mgcp_codec_param param;
92};
93
94int mgcp_response_parse_params(struct mgcp_response *r);
95
96int mgcp_client_tx(struct mgcp_client *mgcp, struct msgb *msg,
97 mgcp_response_cb_t response_cb, void *priv);
98int mgcp_client_cancel(struct mgcp_client *mgcp, mgcp_trans_id_t trans_id);
99
100struct msgb *mgcp_msg_gen(struct mgcp_client *mgcp, struct mgcp_msg *mgcp_msg);
101mgcp_trans_id_t mgcp_msg_trans_id(struct msgb *msg);