blob: d77371a562015071d659540b330315b0c54dfdbc [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
32/*! Dispatch a DLCX for the given connection.
33 * \param ci Connection identifier as obtained from osmo_mgcpc_ep_ci_add().
34 */
35static inline void osmo_mgcpc_ep_ci_dlcx(struct osmo_mgcpc_ep_ci *ci)
36{
37 osmo_mgcpc_ep_ci_request(ci, MGCP_VERB_DLCX, NULL, NULL, 0, 0, NULL);
38}
39
40void osmo_mgcpc_ep_clear(struct osmo_mgcpc_ep *ep);
41
42const char *osmo_mgcpc_ep_name(const struct osmo_mgcpc_ep *ep);
43const char *osmo_mgcpc_ep_ci_name(const struct osmo_mgcpc_ep_ci *ci);
44const char *osmo_mgcpc_ep_ci_id(const struct osmo_mgcpc_ep_ci *ci);
45
46extern const struct value_string osmo_mgcp_verb_names[];
47static inline const char *osmo_mgcp_verb_name(enum mgcp_verb val)
48{ return get_value_string(osmo_mgcp_verb_names, val); }