blob: 3daa09d5fe20d78a7c3cdfa843cff5542e09ab9a [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
Neels Hofmeyr59e7cf42021-05-01 02:31:01 +000026const struct mgcp_conn_peer *osmo_mgcpc_ep_ci_get_remote_rtp_info(const struct osmo_mgcpc_ep_ci *ci);
27
Neels Hofmeyr538d2c52019-01-28 03:51:35 +010028void osmo_mgcpc_ep_ci_request(struct osmo_mgcpc_ep_ci *ci,
29 enum mgcp_verb verb, const struct mgcp_conn_peer *verb_info,
30 struct osmo_fsm_inst *notify,
31 uint32_t event_success, uint32_t event_failure,
32 void *notify_data);
33
Neels Hofmeyrf2bf8dc2019-10-29 17:39:56 +010034void osmo_mgcpc_ep_cancel_notify(struct osmo_mgcpc_ep *ep, struct osmo_fsm_inst *notify);
Neels Hofmeyr923d60b2019-10-29 17:40:08 +010035struct osmo_mgcpc_ep *osmo_mgcpc_ep_ci_ep(struct osmo_mgcpc_ep_ci *ci);
Neels Hofmeyrf2bf8dc2019-10-29 17:39:56 +010036
Neels Hofmeyr538d2c52019-01-28 03:51:35 +010037/*! Dispatch a DLCX for the given connection.
38 * \param ci Connection identifier as obtained from osmo_mgcpc_ep_ci_add().
39 */
40static inline void osmo_mgcpc_ep_ci_dlcx(struct osmo_mgcpc_ep_ci *ci)
41{
42 osmo_mgcpc_ep_ci_request(ci, MGCP_VERB_DLCX, NULL, NULL, 0, 0, NULL);
43}
44
45void osmo_mgcpc_ep_clear(struct osmo_mgcpc_ep *ep);
46
47const char *osmo_mgcpc_ep_name(const struct osmo_mgcpc_ep *ep);
Pau Espin Pedrol6225b5c2023-09-22 20:00:18 +020048const char *osmo_mgcpc_ep_local_name(const struct osmo_mgcpc_ep *ep);
Neels Hofmeyr538d2c52019-01-28 03:51:35 +010049const char *osmo_mgcpc_ep_ci_name(const struct osmo_mgcpc_ep_ci *ci);
50const char *osmo_mgcpc_ep_ci_id(const struct osmo_mgcpc_ep_ci *ci);
Philipp Maier3f4a4cb2021-07-26 13:20:05 +020051struct mgcp_client *osmo_mgcpc_ep_client(const struct osmo_mgcpc_ep *ep);
Neels Hofmeyr538d2c52019-01-28 03:51:35 +010052
53extern const struct value_string osmo_mgcp_verb_names[];
54static inline const char *osmo_mgcp_verb_name(enum mgcp_verb val)
55{ return get_value_string(osmo_mgcp_verb_names, val); }