blob: e264a3c8be0373658aabcd26b374f63cc8188f59 [file] [log] [blame]
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001/* osmo-bsc API to manage all sides of an MGW endpoint */
2#pragma once
3
4#include <osmocom/mgcp_client/mgcp_client_fsm.h>
5
6#include <osmocom/bsc/debug.h>
7
8/* This macro automatically includes a final \n, if omitted. */
9#define LOG_MGWEP(mgwep, level, fmt, args...) do { \
10 LOGPFSML(mgwep->fi, level, "(%s) " fmt, \
11 mgw_endpoint_name(mgwep), ## args); \
12 } while(0)
13
14enum mgwep_fsm_state {
15 MGWEP_ST_UNUSED,
16 MGWEP_ST_WAIT_MGW_RESPONSE,
17 MGWEP_ST_IN_USE,
18};
19
20enum mgwep_fsm_event {
21 _MGWEP_EV_LAST,
22 /* and MGW response events are allocated dynamically */
23};
24
25struct mgw_endpoint;
26struct mgwep_ci;
27struct T_def;
28
29void mgw_endpoint_fsm_init(struct T_def *T_defs);
30
31struct mgw_endpoint *mgw_endpoint_alloc(struct osmo_fsm_inst *parent, uint32_t parent_term_event,
32 struct mgcp_client *mgcp_client,
33 const char *fsm_id,
34 const char *endpoint_str_fmt, ...);
35
36struct mgwep_ci *mgw_endpoint_ci_add(struct mgw_endpoint *mgwep,
37 const char *label_fmt, ...);
38const struct mgcp_conn_peer *mgwep_ci_get_rtp_info(const struct mgwep_ci *ci);
39bool mgwep_ci_get_crcx_info_to_sockaddr(const struct mgwep_ci *ci, struct sockaddr_storage *dest);
40
41void mgw_endpoint_ci_request(struct mgwep_ci *ci,
42 enum mgcp_verb verb, const struct mgcp_conn_peer *verb_info,
43 struct osmo_fsm_inst *notify,
44 uint32_t event_success, uint32_t event_failure,
45 void *notify_data);
46
47static inline void mgw_endpoint_ci_dlcx(struct mgwep_ci *ci)
48{
49 mgw_endpoint_ci_request(ci, MGCP_VERB_DLCX, NULL, NULL, 0, 0, NULL);
50}
51
52void mgw_endpoint_clear(struct mgw_endpoint *mgwep);
53
54const char *mgw_endpoint_name(const struct mgw_endpoint *mgwep);
55const char *mgwep_ci_name(const struct mgwep_ci *ci);
56const char *mgcp_conn_peer_name(const struct mgcp_conn_peer *info);
57
58enum mgcp_codecs chan_mode_to_mgcp_codec(enum gsm48_chan_mode chan_mode, bool full_rate);
Philipp Maierc80cce62018-08-01 11:25:06 +020059void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side);