Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1 | /* 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 | |
| 14 | enum mgwep_fsm_state { |
| 15 | MGWEP_ST_UNUSED, |
| 16 | MGWEP_ST_WAIT_MGW_RESPONSE, |
| 17 | MGWEP_ST_IN_USE, |
| 18 | }; |
| 19 | |
| 20 | enum mgwep_fsm_event { |
| 21 | _MGWEP_EV_LAST, |
| 22 | /* and MGW response events are allocated dynamically */ |
| 23 | }; |
| 24 | |
| 25 | struct mgw_endpoint; |
| 26 | struct mgwep_ci; |
| 27 | struct T_def; |
| 28 | |
| 29 | void mgw_endpoint_fsm_init(struct T_def *T_defs); |
| 30 | |
| 31 | struct 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 | |
| 36 | struct mgwep_ci *mgw_endpoint_ci_add(struct mgw_endpoint *mgwep, |
| 37 | const char *label_fmt, ...); |
| 38 | const struct mgcp_conn_peer *mgwep_ci_get_rtp_info(const struct mgwep_ci *ci); |
| 39 | bool mgwep_ci_get_crcx_info_to_sockaddr(const struct mgwep_ci *ci, struct sockaddr_storage *dest); |
| 40 | |
| 41 | void 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 | |
| 47 | static 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 | |
| 52 | void mgw_endpoint_clear(struct mgw_endpoint *mgwep); |
| 53 | |
| 54 | const char *mgw_endpoint_name(const struct mgw_endpoint *mgwep); |
| 55 | const char *mgwep_ci_name(const struct mgwep_ci *ci); |
| 56 | const char *mgcp_conn_peer_name(const struct mgcp_conn_peer *info); |
| 57 | |
| 58 | enum mgcp_codecs chan_mode_to_mgcp_codec(enum gsm48_chan_mode chan_mode, bool full_rate); |
Philipp Maier | c80cce6 | 2018-08-01 11:25:06 +0200 | [diff] [blame] | 59 | void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side); |