blob: 99b44d1a9f30c67d00291e57340f178a30d56853 [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 +02007
8#define OSMUX_PORT 1984
9
10enum {
11 OSMUX_ROLE_BSC = 0,
12 OSMUX_ROLE_BSC_NAT,
13};
14
15int osmux_init(int role, struct mgcp_config *cfg);
Philipp Maier87bd9be2017-08-22 16:35:41 +020016int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn,
Pau Espin Pedrola790f0c2020-08-31 13:29:11 +020017 struct osmo_sockaddr *addr, uint16_t port);
Pau Espin Pedrol85978da2019-05-17 14:38:19 +020018void conn_osmux_disable(struct mgcp_conn_rtp *conn);
Pau Espin Pedrol8de58e72019-04-24 13:33:46 +020019int conn_osmux_allocate_cid(struct mgcp_conn_rtp *conn, int osmux_cid);
20void conn_osmux_release_cid(struct mgcp_conn_rtp *conn);
Philipp Maier87bd9be2017-08-22 16:35:41 +020021int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn);
22int osmux_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn);
Pau Espin Pedrol8de58e72019-04-24 13:33:46 +020023
24void osmux_cid_pool_get(uint8_t osmux_cid);
25int osmux_cid_pool_get_next(void);
26void osmux_cid_pool_put(uint8_t osmux_cid);
27bool osmux_cid_pool_allocated(uint8_t osmux_cid);
28int osmux_cid_pool_count_used(void);
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020029
30enum osmux_state {
Pau Espin Pedrol407b1f12018-10-16 16:40:11 +020031 OSMUX_STATE_DISABLED = 0, /* Osmux not being currently used by endp */
Pau Espin Pedrol407b1f12018-10-16 16:40:11 +020032 OSMUX_STATE_ACTIVATING, /* Osmux was accepted in MGCP CRCX ACK. It can now be enabled by \ref osmux_enable_endpoint. */
33 OSMUX_STATE_ENABLED, /* Osmux was initialized by \ref osmux_enable_endpoint and can process frames */
Neels Hofmeyrf83ec562017-09-07 19:18:40 +020034};
35
36enum osmux_usage {
37 OSMUX_USAGE_OFF = 0,
38 OSMUX_USAGE_ON = 1,
39 OSMUX_USAGE_ONLY = 2,
40};