[PATCH] osmo-msc[master]: mcgp: let the MGW allocate the MGCP endpoint

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Thu Feb 22 11:10:54 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/6319

to look at the new patch set (#2).

mcgp: let the MGW allocate the MGCP endpoint

osmo-msc still uses endpoints that are allocated locally by the
MGCP-Client. Since osmo-mgw now supports the more comfortable,
dynamic variant we should make use of it.

- Replace the endpoint numer allocation by the client with a
  wildcarded CRCX. Use the endpoint that is assigned by the
  MGW.

Related: OS#2710
Change-Id: Iee3e446b6689626516f01c521abe3d4603cd3e13
---
M include/osmocom/msc/msc_mgcp.h
M src/libmsc/msc_mgcp.c
2 files changed, 35 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/19/6319/2

diff --git a/include/osmocom/msc/msc_mgcp.h b/include/osmocom/msc/msc_mgcp.h
index ac3283c..3c4bc62 100644
--- a/include/osmocom/msc/msc_mgcp.h
+++ b/include/osmocom/msc/msc_mgcp.h
@@ -31,10 +31,15 @@
 	/* FSM instance, which handles the connection switching procedure */
 	struct osmo_fsm_inst *fsm;
 
-	/* RTP endpoint number. This number identifies the endpoint
+	/* RTP endpoint string. This string identifies the endpoint
 	 * on the MGW on which the RAN and CN connection is created. This
-	 * endpoint number is assigned and released automatically. */
-	uint16_t rtp_endpoint;
+	 * endpoint number is assigned by the MGW. */
+	char rtp_endpoint[MGCP_ENDPOINT_MAXLEN];
+
+	/* Call id of the current call. Will be derived from the callref
+	 * of the transaction that is valid during the first CRCX. (The
+	 * callref may change throughout the call) */
+	unsigned int call_id;
 
 	/* Set to true, when the context information is no longer needed */
 	bool free_ctx;
diff --git a/src/libmsc/msc_mgcp.c b/src/libmsc/msc_mgcp.c
index 2bc186e..f5e40d2 100644
--- a/src/libmsc/msc_mgcp.c
+++ b/src/libmsc/msc_mgcp.c
@@ -51,7 +51,7 @@
 #define MGCP_ASS_TIMEOUT 10	/* in seconds */
 #define MGCP_ASS_TIMEOUT_TIMER_NR 4
 
-#define MGCP_ENDPOINT_FORMAT "%x at mgw"
+#define ENDPOINT_ID "rtpbridge/*@mgw"
 
 /* Some internal cause codes to indicate fault condition inside the FSM */
 enum msc_mgcp_cause_code {
@@ -187,9 +187,6 @@
 		 * there is no meaningful action we can take now other than
 		 * giving up. */
 
-		/* At least release the occupied endpoint ID */
-		mgcp_client_release_endpoint(mgcp_ctx->rtp_endpoint, mgcp);
-
 		/* Cancel the transaction that timed out */
 		mgcp_client_cancel(mgcp, mgcp_ctx->mgw_pending_trans);
 
@@ -241,8 +238,6 @@
 	mgcp = mgcp_ctx->mgcp;
 	OSMO_ASSERT(mgcp);
 
-	mgcp_ctx->rtp_endpoint = mgcp_client_next_endpoint(mgcp);
-
 	LOGPFSML(fi, LOGL_DEBUG,
 		 "CRCX/RAN: creating connection for the RAN side on MGW endpoint:0x%x...\n", mgcp_ctx->rtp_endpoint);
 
@@ -250,14 +245,15 @@
 	mgcp_msg = (struct mgcp_msg) {
 		.verb = MGCP_VERB_CRCX,
 		.presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID | MGCP_MSG_PRESENCE_CONN_MODE),
-		.call_id = mgcp_ctx->rtp_endpoint,
+		.call_id = mgcp_ctx->call_id,
 		.conn_mode = MGCP_CONN_LOOPBACK
 	};
-	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
+	if (osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, sizeof(mgcp_msg.endpoint)) >=
 	    MGCP_ENDPOINT_MAXLEN) {
 		handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
 		return;
 	}
+
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
 	OSMO_ASSERT(msg);
 
@@ -293,9 +289,11 @@
 		return;
 	}
 
-	/* memorize connection identifier */
+	/* memorize connection identifier and specific endpoint id */
 	osmo_strlcpy(mgcp_ctx->conn_id_ran, r->head.conn_id, sizeof(mgcp_ctx->conn_id_ran));
 	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "CRCX/RAN: MGW responded with CI: %s\n", mgcp_ctx->conn_id_ran);
+	osmo_strlcpy(mgcp_ctx->rtp_endpoint, r->head.endpoint, sizeof(mgcp_ctx->rtp_endpoint));
+	LOGPFSML(mgcp_ctx->fsm, LOGL_DEBUG, "CRCX/RAN: MGW assigned endpoint: %s\n", mgcp_ctx->rtp_endpoint);
 
 	rc = mgcp_response_parse_params(r);
 	if (rc) {
@@ -343,14 +341,15 @@
 	mgcp_msg = (struct mgcp_msg) {
 		.verb = MGCP_VERB_CRCX,
 		.presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID | MGCP_MSG_PRESENCE_CONN_MODE),
-		.call_id = mgcp_ctx->rtp_endpoint,
+		.call_id = mgcp_ctx->call_id,
 		.conn_mode = MGCP_CONN_LOOPBACK
 	};
-	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
+	if (osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, sizeof(mgcp_msg.endpoint)) >=
 	    MGCP_ENDPOINT_MAXLEN) {
 		handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
 		return;
 	}
+
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
 	OSMO_ASSERT(msg);
 
@@ -503,17 +502,18 @@
 		.presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID | MGCP_MSG_PRESENCE_CONN_ID |
 			     MGCP_MSG_PRESENCE_CONN_MODE | MGCP_MSG_PRESENCE_AUDIO_IP |
 			     MGCP_MSG_PRESENCE_AUDIO_PORT),
-		.call_id = mgcp_ctx->rtp_endpoint,
+		.call_id = mgcp_ctx->call_id,
 		.conn_id = mgcp_ctx->conn_id_cn,
 		.conn_mode = MGCP_CONN_RECV_SEND,
 		.audio_ip = conn->rtp.remote_addr_cn,
 		.audio_port = conn->rtp.remote_port_cn
 	};
-	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
+	if (osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, sizeof(mgcp_msg.endpoint)) >=
 	    MGCP_ENDPOINT_MAXLEN) {
 		handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
 		return;
 	}
+
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
 	OSMO_ASSERT(msg);
 
@@ -619,17 +619,18 @@
 		.presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID | MGCP_MSG_PRESENCE_CONN_ID |
 			     MGCP_MSG_PRESENCE_CONN_MODE | MGCP_MSG_PRESENCE_AUDIO_IP |
 			     MGCP_MSG_PRESENCE_AUDIO_PORT),
-		.call_id = mgcp_ctx->rtp_endpoint,
+		.call_id = mgcp_ctx->call_id,
 		.conn_id = mgcp_ctx->conn_id_ran,
 		.conn_mode = MGCP_CONN_RECV_SEND,
 		.audio_ip = conn->rtp.remote_addr_ran,
 		.audio_port = conn->rtp.remote_port_ran
 	};
-	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
+	if (osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, sizeof(mgcp_msg.endpoint)) >=
 	    MGCP_ENDPOINT_MAXLEN) {
 		handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
 		return;
 	}
+
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
 	OSMO_ASSERT(msg);
 
@@ -699,21 +700,18 @@
 	LOGPFSML(fi, LOGL_DEBUG,
 		 "DLCX: removing connection for the RAN and CN side on MGW endpoint:0x%x...\n", mgcp_ctx->rtp_endpoint);
 
-	/* We now relase the endpoint back to the pool in order to allow
-	 * other connections to use this endpoint */
-	mgcp_client_release_endpoint(mgcp_ctx->rtp_endpoint, mgcp);
-
 	/* Generate MGCP message string */
 	mgcp_msg = (struct mgcp_msg) {
 		.verb = MGCP_VERB_DLCX,
 		.presence = (MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_CALL_ID),
-		.call_id = mgcp_ctx->rtp_endpoint
+		.call_id = mgcp_ctx->call_id
 	};
-	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
+	if (osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, sizeof(mgcp_msg.endpoint)) >=
 	    MGCP_ENDPOINT_MAXLEN) {
 		handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
 		return;
 	}
+
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
 	OSMO_ASSERT(msg);
 
@@ -912,12 +910,19 @@
 	/* Allocate and configure a new fsm instance */
 	mgcp_ctx = talloc_zero(NULL, struct mgcp_ctx);
 	OSMO_ASSERT(mgcp_ctx);
-
+	if (osmo_strlcpy(mgcp_ctx->rtp_endpoint, ENDPOINT_ID, sizeof(mgcp_ctx->rtp_endpoint)) >=
+	    MGCP_ENDPOINT_MAXLEN) {
+		talloc_free(mgcp_ctx);
+		LOGP(DMGCP, LOGL_ERROR, "(subscriber:%s) endpoint identifier (%s) exceeds maximum length...\n",
+		     vlr_subscr_name(trans->vsub), ENDPOINT_ID);
+		return -EINVAL;
+	}
 	mgcp_ctx->fsm = osmo_fsm_inst_alloc(&fsm_msc_mgcp, NULL, NULL, LOGL_DEBUG, name);
 	OSMO_ASSERT(mgcp_ctx->fsm);
 	mgcp_ctx->fsm->priv = mgcp_ctx;
 	mgcp_ctx->mgcp = mgcp;
 	mgcp_ctx->trans = trans;
+	mgcp_ctx->call_id = trans->callref;
 
 	/* start state machine */
 	OSMO_ASSERT(mgcp_ctx->fsm->state == ST_CRCX_RAN);

-- 
To view, visit https://gerrit.osmocom.org/6319
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iee3e446b6689626516f01c521abe3d4603cd3e13
Gerrit-PatchSet: 2
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list