blob: 58d9095d0e6e4cc8c7edabcbc00facf4c32d00bd [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);
Philipp Maier87bd9be2017-08-22 16:35:41 +020017int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn,
Pau Espin Pedrol15e7e4f2022-09-09 16:52:41 +020018 const struct osmo_sockaddr *addr);
Pau Espin Pedrol85978da2019-05-17 14:38:19 +020019void conn_osmux_disable(struct mgcp_conn_rtp *conn);
Pau Espin Pedrol21779192022-09-23 16:46:33 +020020int conn_osmux_allocate_local_cid(struct mgcp_conn_rtp *conn);
21void conn_osmux_release_local_cid(struct mgcp_conn_rtp *conn);
Philipp Maier87bd9be2017-08-22 16:35:41 +020022int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn);
23int osmux_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn);
Pau Espin Pedrol8de58e72019-04-24 13:33:46 +020024
25void osmux_cid_pool_get(uint8_t osmux_cid);
26int osmux_cid_pool_get_next(void);
27void osmux_cid_pool_put(uint8_t osmux_cid);
28bool osmux_cid_pool_allocated(uint8_t osmux_cid);
29int osmux_cid_pool_count_used(void);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020030
31enum osmux_state {
Pau Espin Pedrol407b1f12018-10-16 16:40:11 +020032 OSMUX_STATE_DISABLED = 0, /* Osmux not being currently used by endp */
Pau Espin Pedrol407b1f12018-10-16 16:40:11 +020033 OSMUX_STATE_ACTIVATING, /* Osmux was accepted in MGCP CRCX ACK. It can now be enabled by \ref osmux_enable_endpoint. */
34 OSMUX_STATE_ENABLED, /* Osmux was initialized by \ref osmux_enable_endpoint and can process frames */
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020035};
36
Pau Espin Pedrolea7aaf22022-09-22 21:07:54 +020037extern const struct value_string osmux_state_strs[];
38static inline const char *osmux_state_str(enum osmux_state val)
39{ return get_value_string(osmux_state_strs, val); }
40
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020041enum osmux_usage {
42 OSMUX_USAGE_OFF = 0,
43 OSMUX_USAGE_ON = 1,
44 OSMUX_USAGE_ONLY = 2,
45};