blob: 9ae20395a7640b6c54b13db2ee6f69777cd697eb [file] [log] [blame]
Neels Hofmeyr538d2c52019-01-28 03:51:35 +01001/* FSM to manage multiple connections of an MGW endpoint */
2#pragma once
3
4#include <osmocom/mgcp_client/mgcp_client_fsm.h>
5
6#define LOG_MGCPC_EP(ep, level, fmt, args...) do { \
7 LOGPFSML(ep->fi, level, "%s " fmt, \
8 osmo_mgcpc_ep_name(ep), ## args); \
9 } while(0)
10
11struct osmo_mgcpc_ep;
12struct osmo_mgcpc_ep_ci;
13struct osmo_tdef;
14
15struct osmo_mgcpc_ep *osmo_mgcpc_ep_alloc(struct osmo_fsm_inst *parent, uint32_t parent_term_event,
16 struct mgcp_client *mgcp_client,
17 const struct osmo_tdef *T_defs,
18 const char *fsm_id,
19 const char *endpoint_str_fmt, ...);
20
21struct osmo_mgcpc_ep_ci *osmo_mgcpc_ep_ci_add(struct osmo_mgcpc_ep *ep, const char *label_fmt, ...);
22const struct mgcp_conn_peer *osmo_mgcpc_ep_ci_get_rtp_info(const struct osmo_mgcpc_ep_ci *ci);
23bool osmo_mgcpc_ep_ci_get_crcx_info_to_sockaddr(const struct osmo_mgcpc_ep_ci *ci, struct sockaddr_storage *dest);
Pau Espin Pedrol30907dc2019-05-06 11:54:17 +020024bool osmo_mgcpc_ep_ci_get_crcx_info_to_osmux_cid(const struct osmo_mgcpc_ep_ci *ci, uint8_t* cid);
Neels Hofmeyr538d2c52019-01-28 03:51:35 +010025
26void osmo_mgcpc_ep_ci_request(struct osmo_mgcpc_ep_ci *ci,
27 enum mgcp_verb verb, const struct mgcp_conn_peer *verb_info,
28 struct osmo_fsm_inst *notify,
29 uint32_t event_success, uint32_t event_failure,
30 void *notify_data);
31
Neels Hofmeyrf2bf8dc2019-10-29 17:39:56 +010032void osmo_mgcpc_ep_cancel_notify(struct osmo_mgcpc_ep *ep, struct osmo_fsm_inst *notify);
33
Neels Hofmeyr538d2c52019-01-28 03:51:35 +010034/*! Dispatch a DLCX for the given connection.
35 * \param ci Connection identifier as obtained from osmo_mgcpc_ep_ci_add().
36 */
37static inline void osmo_mgcpc_ep_ci_dlcx(struct osmo_mgcpc_ep_ci *ci)
38{
39 osmo_mgcpc_ep_ci_request(ci, MGCP_VERB_DLCX, NULL, NULL, 0, 0, NULL);
40}
41
42void osmo_mgcpc_ep_clear(struct osmo_mgcpc_ep *ep);
43
44const char *osmo_mgcpc_ep_name(const struct osmo_mgcpc_ep *ep);
45const char *osmo_mgcpc_ep_ci_name(const struct osmo_mgcpc_ep_ci *ci);
46const char *osmo_mgcpc_ep_ci_id(const struct osmo_mgcpc_ep_ci *ci);
47
48extern const struct value_string osmo_mgcp_verb_names[];
49static inline const char *osmo_mgcp_verb_name(enum mgcp_verb val)
50{ return get_value_string(osmo_mgcp_verb_names, val); }