move mgw endpoint FSM to osmo-mgw.git

osmo-mgw.git also includes fixes of the MGW endpoint FSM, for example
I92a9944acc96398acd6649f9c3c5badec5dd6dcc.

Depends: I9a3effd38e72841529df6c135c077116981dea36 (osmo-mgw)
Change-Id: I03e6b48d9b0a5370310d5f56809259ff7909cf9d
diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am
index 21e53d7..89323c0 100644
--- a/include/osmocom/bsc/Makefile.am
+++ b/include/osmocom/bsc/Makefile.am
@@ -33,7 +33,6 @@
 	meas_feed.h \
 	meas_rep.h \
 	misdn.h \
-	mgw_endpoint_fsm.h \
 	neighbor_ident.h \
 	network_listen.h \
 	openbscdefines.h \
diff --git a/include/osmocom/bsc/bsc_subscr_conn_fsm.h b/include/osmocom/bsc/bsc_subscr_conn_fsm.h
index f5ed7bd..5475272 100644
--- a/include/osmocom/bsc/bsc_subscr_conn_fsm.h
+++ b/include/osmocom/bsc/bsc_subscr_conn_fsm.h
@@ -43,7 +43,7 @@
 struct gsm_subscriber_connection;
 struct gsm_network;
 struct msgb;
-struct mgwep_ci;
+struct osmo_mgcpc_ep_ci;
 struct assignment_request;
 struct gsm_lchan;
 
@@ -57,15 +57,15 @@
 			   struct msgb *msg, int link_id, int allow_sacch);
 int gscon_sigtran_send(struct gsm_subscriber_connection *conn, struct msgb *msg);
 
-struct mgw_endpoint *gscon_ensure_mgw_endpoint(struct gsm_subscriber_connection *conn,
-					       uint16_t msc_assigned_cic);
+struct osmo_mgcpc_ep *gscon_ensure_mgw_endpoint(struct gsm_subscriber_connection *conn,
+						uint16_t msc_assigned_cic);
 bool gscon_connect_mgw_to_msc(struct gsm_subscriber_connection *conn,
 			      struct gsm_lchan *for_lchan,
 			      const char *addr, uint16_t port,
 			      struct osmo_fsm_inst *notify,
 			      uint32_t event_success, uint32_t event_failure,
 			      void *notify_data,
-			      struct mgwep_ci **created_ci);
+			      struct osmo_mgcpc_ep_ci **created_ci);
 
 void gscon_start_assignment(struct gsm_subscriber_connection *conn,
 			    struct assignment_request *req);
@@ -76,7 +76,7 @@
 void gscon_lchan_releasing(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
 void gscon_forget_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
 
-void gscon_forget_mgw_endpoint_ci(struct gsm_subscriber_connection *conn, struct mgwep_ci *ci);
+void gscon_forget_mgw_endpoint_ci(struct gsm_subscriber_connection *conn, struct osmo_mgcpc_ep_ci *ci);
 
 bool gscon_is_aoip(struct gsm_subscriber_connection *conn);
 bool gscon_is_sccplite(struct gsm_subscriber_connection *conn);
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 7b813a6..dacc63b 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -39,7 +39,7 @@
 struct mgcp_client_conf;
 struct mgcp_client;
 struct gsm0808_cell_id;
-struct mgw_endpoint;
+struct osmo_mgcpc_ep;
 
 /** annotations for msgb ownership */
 #define __uses
@@ -136,7 +136,7 @@
 	/* Whether this assignment triggered creation of the MGW endpoint: if the assignment
 	 * fails, we will release that again as soon as possible. (If false, the endpoint already
 	 * existed before or isn't needed at all.)*/
-	struct mgwep_ci *created_ci_for_msc;
+	struct osmo_mgcpc_ep_ci *created_ci_for_msc;
 
 	enum gsm0808_cause failure_cause;
 	enum gsm48_rr_cause rr_cause;
@@ -205,7 +205,7 @@
 	struct gsm_lchan *new_lchan;
 	bool async;
 	struct handover_in_req inter_bsc_in;
-	struct mgwep_ci *created_ci_for_msc;
+	struct osmo_mgcpc_ep_ci *created_ci_for_msc;
 };
 
 /* active radio connection of a mobile subscriber */
@@ -287,11 +287,11 @@
 
 		/* The endpoint at the MGW used to join both BTS and MSC side connections, e.g.
 		 * "rtpbridge/23@mgw". */
-		struct mgw_endpoint *mgw_endpoint;
+		struct osmo_mgcpc_ep *mgw_endpoint;
 
-		/* The connection identifier of the mgw_endpoint used to transceive RTP towards the MSC.
+		/* The connection identifier of the osmo_mgcpc_ep used to transceive RTP towards the MSC.
 		 * (The BTS side CI is handled by struct gsm_lchan and the lchan_fsm.) */
-		struct mgwep_ci *mgw_endpoint_ci_msc;
+		struct osmo_mgcpc_ep_ci *mgw_endpoint_ci_msc;
 	} user_plane;
 
 	/* LCLS (local call, local switch) related state */
@@ -554,7 +554,7 @@
 
 	struct osmo_fsm_inst *fi;
 	struct osmo_fsm_inst *fi_rtp;
-	struct mgwep_ci *mgw_endpoint_ci_bts;
+	struct osmo_mgcpc_ep_ci *mgw_endpoint_ci_bts;
 
 	struct {
 		struct lchan_activate_info info;
@@ -1535,6 +1535,7 @@
 	struct {
 		struct mgcp_client_conf *conf;
 		struct mgcp_client *client;
+		struct osmo_tdef *tdefs;
 	} mgw;
 
 	/* Remote BSS Cell Identifier Lists */
diff --git a/include/osmocom/bsc/lchan_rtp_fsm.h b/include/osmocom/bsc/lchan_rtp_fsm.h
index fa0e746..6ff8fe3 100644
--- a/include/osmocom/bsc/lchan_rtp_fsm.h
+++ b/include/osmocom/bsc/lchan_rtp_fsm.h
@@ -10,6 +10,7 @@
 	} while(0)
 
 struct gsm_lchan;
+struct mgcp_conn_peer;
 
 enum lchan_rtp_fsm_state {
 	LCHAN_RTP_ST_WAIT_MGW_ENDPOINT_AVAILABLE,
@@ -40,6 +41,8 @@
 };
 
 void lchan_rtp_fsm_start(struct gsm_lchan *lchan);
-struct mgwep_ci *lchan_use_mgw_endpoint_ci_bts(struct gsm_lchan *lchan);
+struct osmo_mgcpc_ep_ci *lchan_use_mgw_endpoint_ci_bts(struct gsm_lchan *lchan);
 bool lchan_rtp_established(struct gsm_lchan *lchan);
 void lchan_forget_mgw_endpoint(struct gsm_lchan *lchan);
+
+void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side);
diff --git a/include/osmocom/bsc/mgw_endpoint_fsm.h b/include/osmocom/bsc/mgw_endpoint_fsm.h
deleted file mode 100644
index f86a7cd..0000000
--- a/include/osmocom/bsc/mgw_endpoint_fsm.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* osmo-bsc API to manage all sides of an MGW endpoint */
-#pragma once
-
-#include <osmocom/mgcp_client/mgcp_client_fsm.h>
-
-#include <osmocom/bsc/debug.h>
-
-/* This macro automatically includes a final \n, if omitted. */
-#define LOG_MGWEP(mgwep, level, fmt, args...) do { \
-	LOGPFSML(mgwep->fi, level, "(%s) " fmt, \
-		 mgw_endpoint_name(mgwep), ## args); \
-	} while(0)
-
-enum mgwep_fsm_state {
-	MGWEP_ST_UNUSED,
-	MGWEP_ST_WAIT_MGW_RESPONSE,
-	MGWEP_ST_IN_USE,
-};
-
-enum mgwep_fsm_event {
-	_MGWEP_EV_LAST,
-	/* and MGW response events are allocated dynamically */
-};
-
-struct mgw_endpoint;
-struct mgwep_ci;
-struct osmo_tdef;
-
-void mgw_endpoint_fsm_init(struct osmo_tdef *T_defs);
-
-struct mgw_endpoint *mgw_endpoint_alloc(struct osmo_fsm_inst *parent, uint32_t parent_term_event,
-					struct mgcp_client *mgcp_client,
-					const char *fsm_id,
-					const char *endpoint_str_fmt, ...);
-
-struct mgwep_ci *mgw_endpoint_ci_add(struct mgw_endpoint *mgwep,
-				     const char *label_fmt, ...);
-const struct mgcp_conn_peer *mgwep_ci_get_rtp_info(const struct mgwep_ci *ci);
-bool mgwep_ci_get_crcx_info_to_sockaddr(const struct mgwep_ci *ci, struct sockaddr_storage *dest);
-
-void mgw_endpoint_ci_request(struct mgwep_ci *ci,
-			     enum mgcp_verb verb, const struct mgcp_conn_peer *verb_info,
-			     struct osmo_fsm_inst *notify,
-			     uint32_t event_success, uint32_t event_failure,
-			     void *notify_data);
-
-static inline void mgw_endpoint_ci_dlcx(struct mgwep_ci *ci)
-{
-	mgw_endpoint_ci_request(ci, MGCP_VERB_DLCX, NULL, NULL, 0, 0, NULL);
-}
-
-void mgw_endpoint_clear(struct mgw_endpoint *mgwep);
-
-const char *mgw_endpoint_name(const struct mgw_endpoint *mgwep);
-const char *mgwep_ci_name(const struct mgwep_ci *ci);
-const char *mgcp_conn_peer_name(const struct mgcp_conn_peer *info);
-
-enum mgcp_codecs chan_mode_to_mgcp_codec(enum gsm48_chan_mode chan_mode, bool full_rate);
-void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side);