blob: 1da7c8b135e7ac324c060ea1e34b9e753351a480 [file] [log] [blame]
Philipp Maier87bd9be2017-08-22 16:35:41 +02001#pragma once
2
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +02003#include <osmocom/core/socket.h>
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02004
5#include <osmocom/netif/osmux.h>
Philipp Maier87bd9be2017-08-22 16:35:41 +02006struct mgcp_conn_rtp;
Neels Hofmeyrf83ec562017-09-07 19:18:40 +02007enum {
8 OSMUX_ROLE_BSC = 0,
9 OSMUX_ROLE_BSC_NAT,
10};
11
Pau Espin Pedrol928a20b2022-09-23 15:38:24 +020012struct mgcp_trunk;
13struct mgcp_endpoint;
14struct mgcp_conn_rtp;
15
Pau Espin Pedrol21bcf6a2022-09-22 18:23:04 +020016int osmux_init(int role, struct mgcp_trunk *trunk);
Pau Espin Pedrold48a8112022-09-27 12:37:53 +020017int osmux_init_conn(struct mgcp_conn_rtp *conn);
Philipp Maier87bd9be2017-08-22 16:35:41 +020018int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn,
Pau Espin Pedrol15e7e4f2022-09-09 16:52:41 +020019 const struct osmo_sockaddr *addr);
Pau Espin Pedrol85978da2019-05-17 14:38:19 +020020void conn_osmux_disable(struct mgcp_conn_rtp *conn);
Pau Espin Pedrol21779192022-09-23 16:46:33 +020021int conn_osmux_allocate_local_cid(struct mgcp_conn_rtp *conn);
22void conn_osmux_release_local_cid(struct mgcp_conn_rtp *conn);
Philipp Maier87bd9be2017-08-22 16:35:41 +020023int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn);
24int osmux_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn);
Pau Espin Pedrol8de58e72019-04-24 13:33:46 +020025
26void osmux_cid_pool_get(uint8_t osmux_cid);
27int osmux_cid_pool_get_next(void);
28void osmux_cid_pool_put(uint8_t osmux_cid);
29bool osmux_cid_pool_allocated(uint8_t osmux_cid);
30int osmux_cid_pool_count_used(void);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020031
32enum osmux_state {
Pau Espin Pedrol407b1f12018-10-16 16:40:11 +020033 OSMUX_STATE_DISABLED = 0, /* Osmux not being currently used by endp */
Pau Espin Pedrol407b1f12018-10-16 16:40:11 +020034 OSMUX_STATE_ACTIVATING, /* Osmux was accepted in MGCP CRCX ACK. It can now be enabled by \ref osmux_enable_endpoint. */
35 OSMUX_STATE_ENABLED, /* Osmux was initialized by \ref osmux_enable_endpoint and can process frames */
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020036};
37
Pau Espin Pedrolea7aaf22022-09-22 21:07:54 +020038extern const struct value_string osmux_state_strs[];
39static inline const char *osmux_state_str(enum osmux_state val)
40{ return get_value_string(osmux_state_strs, val); }
41
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020042enum osmux_usage {
43 OSMUX_USAGE_OFF = 0,
44 OSMUX_USAGE_ON = 1,
45 OSMUX_USAGE_ONLY = 2,
46};