Review at  https://gerrit.osmocom.org/6319

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, 23 insertions(+), 44 deletions(-)


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

diff --git a/include/osmocom/msc/msc_mgcp.h b/include/osmocom/msc/msc_mgcp.h
index ac3283c..05f2fd9 100644
--- a/include/osmocom/msc/msc_mgcp.h
+++ b/include/osmocom/msc/msc_mgcp.h
@@ -31,10 +31,10 @@
        /* 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];
 
        /* 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 bd60c13..85e9d2e 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@mgw"
+#define ENDPOINT_ID "rtpbridge/*@mgw"
 
 /* Some internal cause codes to indicate fault condition inside the FSM */
 enum msc_mgcp_cause_code {
@@ -176,9 +176,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);
 
@@ -230,8 +227,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);
 
@@ -239,14 +234,11 @@
        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 = 12345,
                .conn_mode = MGCP_CONN_LOOPBACK
        };
-       if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, 
MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
-           MGCP_ENDPOINT_MAXLEN) {
-               handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
-               return;
-       }
+       osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
+
        msg = mgcp_msg_gen(mgcp, &mgcp_msg);
        OSMO_ASSERT(msg);
 
@@ -282,9 +274,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) {
@@ -332,14 +326,11 @@
        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 = 12345,
                .conn_mode = MGCP_CONN_LOOPBACK
        };
-       if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, 
MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
-           MGCP_ENDPOINT_MAXLEN) {
-               handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
-               return;
-       }
+       osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
+
        msg = mgcp_msg_gen(mgcp, &mgcp_msg);
        OSMO_ASSERT(msg);
 
@@ -493,17 +484,14 @@
                .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 = 12345,
                .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) >=
-           MGCP_ENDPOINT_MAXLEN) {
-               handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
-               return;
-       }
+       osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
+
        msg = mgcp_msg_gen(mgcp, &mgcp_msg);
        OSMO_ASSERT(msg);
 
@@ -609,17 +597,14 @@
                .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 = 12345,
                .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) >=
-           MGCP_ENDPOINT_MAXLEN) {
-               handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
-               return;
-       }
+       osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
+
        msg = mgcp_msg_gen(mgcp, &mgcp_msg);
        OSMO_ASSERT(msg);
 
@@ -689,21 +674,14 @@
        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 = 12345
        };
-       if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, 
MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
-           MGCP_ENDPOINT_MAXLEN) {
-               handle_error(mgcp_ctx, MGCP_ERR_NOMEM);
-               return;
-       }
+       osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
+
        msg = mgcp_msg_gen(mgcp, &mgcp_msg);
        OSMO_ASSERT(msg);
 
@@ -907,6 +885,7 @@
        mgcp_ctx->fsm->priv = mgcp_ctx;
        mgcp_ctx->mgcp = mgcp;
        mgcp_ctx->trans = trans;
+       osmo_strlcpy(mgcp_ctx->rtp_endpoint, ENDPOINT_ID, 
sizeof(mgcp_ctx->rtp_endpoint));
 
        /* 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: newchange
Gerrit-Change-Id: Iee3e446b6689626516f01c521abe3d4603cd3e13
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: dexter <pma...@sysmocom.de>

Reply via email to