[MERGED] osmo-mgw[master]: protocol: fix tagging of wildcarded requests

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
Mon Feb 5 11:14:54 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: protocol: fix tagging of wildcarded requests
......................................................................


protocol: fix tagging of wildcarded requests

When a wildcarded CRCX is done flag "wildcarded_crcx" is set in the
endpoint struct. The flag tells other part of the code whether the
request was wildcarded or not since in some cases the behaviour
might be different for wildcarded requests. The implementation of
this mechanism is not entirely correct. The flag is set on wildcarded
requests but on non wildcarded requests it is not reset. Also the
name is misleading.

- rename wildcarded_crcx to wildcarded_req

- ensure the flag is refreshed with every new request

Change-Id: Ia5063ec65f5bc3a8a0943d1fd823aaeee20b8637
---
M include/osmocom/mgcp/mgcp_endp.h
M src/libosmo-mgcp/mgcp_endp.c
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_protocol.c
4 files changed, 18 insertions(+), 9 deletions(-)

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



diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index ad5e28d..0225879 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -79,7 +79,7 @@
 
 	/*!< Memorize if this endpoint was choosen by the MGW (wildcarded, true)
 	 *   or if the user has choosen the particular endpoint explicitly. */
-	bool wildcarded_crcx;
+	bool wildcarded_req;
 };
 
 /*! Extract endpoint number for a given endpoint */
diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c
index 77310c6..6d3a6d4 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -51,5 +51,5 @@
 	endp->local_options.string = NULL;
 	talloc_free(endp->local_options.codec);
 	endp->local_options.codec = NULL;
-	endp->wildcarded_crcx = false;
+	endp->wildcarded_req = false;
 }
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 89046c0..8d22cc5 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -143,6 +143,7 @@
 	char *rest = NULL;
 	struct mgcp_trunk_config *tcfg;
 	int trunk, endp;
+	struct mgcp_endpoint *endp_ptr;
 
 	trunk = strtoul(mgcp + 6, &rest, 10);
 	if (rest == NULL || rest[0] != '/' || trunk < 1) {
@@ -179,7 +180,9 @@
 		return NULL;
 	}
 
-	return &tcfg->endpoints[endp];
+	endp_ptr = &tcfg->endpoints[endp];
+	endp_ptr->wildcarded_req = false;
+	return endp_ptr;
 }
 
 /* Find an endpoint that is not in use. Do this by going through the endpoint
@@ -197,7 +200,7 @@
 			LOGP(DLMGCP, LOGL_DEBUG,
 			     "endpoint:0x%x found free endpoint\n",
 			     ENDPOINT_NUMBER(endp));
-			endp->wildcarded_crcx = true;
+			endp->wildcarded_req = true;
 			return endp;
 		}
 	}
@@ -263,8 +266,11 @@
 			return endp;
 		}
 		gw = strtoul(endpoint_number_str, &endptr, 16);
-		if (gw < cfg->trunk.number_endpoints && endptr[0] == '@')
-			return &cfg->trunk.endpoints[gw];
+		if (gw < cfg->trunk.number_endpoints && endptr[0] == '@') {
+			endp = &cfg->trunk.endpoints[gw];
+			endp->wildcarded_req = false;
+			return endp;
+		}
 	}
 
 	/* Deprecated method without prefix */
@@ -272,8 +278,11 @@
 	     "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];
+	if (gw < cfg->trunk.number_endpoints && endptr[0] == '@') {
+		endp = &cfg->trunk.endpoints[gw];
+		endp->wildcarded_req = false;
+		return endp;
+	}
 
 	LOGP(DLMGCP, LOGL_ERROR, "Not able to find the endpoint: '%s'\n", mgcp);
 	*cause = -500;
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index bfb8768..62487d1 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -199,7 +199,7 @@
 	int rc;
 
 	/* NOTE: Only in the virtual trunk we allow dynamic endpoint names */
-	if (endp->wildcarded_crcx
+	if (endp->wildcarded_req
 	    && endp->tcfg->trunk_type == MGCP_TRUNK_VIRTUAL) {
 		rc = msgb_printf(msg, "Z: %s%x@%s\r\n",
 				 MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia5063ec65f5bc3a8a0943d1fd823aaeee20b8637
Gerrit-PatchSet: 3
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