[MERGED] osmo-mgw[master]: mgcp: add prefix to virtual trunk

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Jan 26 00:31:59 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: mgcp: add prefix to virtual trunk
......................................................................


mgcp: add prefix to virtual trunk

the virtual trunk is addressed without a prefix (just *@domain).

- reorganize find_endpoint() so that it accepts a prefix when
  addressing the virtual trunk.

- do no longer accept wildcarded CRCX requests without prefix
  (will not break anything, the feature of wildcarded CRCX is
  not in use yet)

- keep the old prefix-less method but print a warning that it is
  depreacted.

Change-Id: I2aac3ba0f1f3122dfbb3bf36f74198ecb2b21de5
---
M include/osmocom/mgcp/mgcp_common.h
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_protocol.c
3 files changed, 30 insertions(+), 6 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/mgcp/mgcp_common.h b/include/osmocom/mgcp/mgcp_common.h
index 7684936..7aa5d3f 100644
--- a/include/osmocom/mgcp/mgcp_common.h
+++ b/include/osmocom/mgcp/mgcp_common.h
@@ -76,4 +76,7 @@
 /  (see also RFC3435 section 3.2.1.3) */
 #define MGCP_ENDPOINT_MAXLEN (255*2+1+1)
 
+/* A prefix to denote the virtual trunk (RTP on both ends) */
+#define MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK "rtpbridge/"
+
 #endif
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 9bb2805..3aa93b7 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -228,20 +228,38 @@
 {
 	char *endptr = NULL;
 	unsigned int gw = INT_MAX;
+	const char *endpoint_number_str;
 
+	/* Check if the domainname in the request is correct */
 	if (check_domain_name(cfg, mgcp)) {
 		LOGP(DLMGCP, LOGL_ERROR, "Wrong domain name '%s'\n", mgcp);
 		return NULL;
 	}
 
+	/* Check if the E1 trunk is requested */
 	if (strncmp(mgcp, "ds/e1", 5) == 0)
 		return find_e1_endpoint(cfg, mgcp);
 
-	if (strncmp(mgcp, "*", 1) == 0) {
-		return find_free_endpoint(cfg->trunk.endpoints,
-					  cfg->trunk.number_endpoints);
+	/* Check if the virtual trunk is addressed (new, correct way with prefix) */
+	if (strncmp
+	    (mgcp, MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK,
+	     strlen(MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK)) == 0) {
+		endpoint_number_str =
+		    mgcp + strlen(MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK);
+		if (endpoint_number_str[0] == '*') {
+			return find_free_endpoint(cfg->trunk.endpoints,
+						  cfg->trunk.number_endpoints);
+		}
+
+		gw = strtoul(endpoint_number_str, &endptr, 16);
+		if (gw < cfg->trunk.number_endpoints && endptr[0] == '@')
+			return &cfg->trunk.endpoints[gw];
 	}
 
+	/* Deprecated method without prefix */
+	LOGP(DLMGCP, LOGL_NOTICE,
+	     "Addressing virtual trunk without prefix (deprecated), please use %s: '%s'\n",
+	     MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK, mgcp);
 	gw = strtoul(mgcp, &endptr, 16);
 	if (gw < cfg->trunk.number_endpoints && endptr[0] == '@')
 		return &cfg->trunk.endpoints[gw];
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 16e9cb8..daedc8d 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -198,9 +198,12 @@
 {
 	int rc;
 
-	if (endp->wildcarded_crcx) {
-		rc = msgb_printf(msg, "Z: %u@%s\n", ENDPOINT_NUMBER(endp),
-				 endp->cfg->domain);
+	/* NOTE: Only in the virtual trunk we allow dynamic endpoint names */
+	if (endp->wildcarded_crcx
+	    && endp->tcfg->trunk_type == MGCP_TRUNK_VIRTUAL) {
+		rc = msgb_printf(msg, "Z: %s%u@%s\n",
+				 MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK,
+				 ENDPOINT_NUMBER(endp), endp->cfg->domain);
 		if (rc < 0)
 			return -EINVAL;
 	}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2aac3ba0f1f3122dfbb3bf36f74198ecb2b21de5
Gerrit-PatchSet: 6
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list