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

dexter gerrit-no-reply at lists.osmocom.org
Fri Feb 2 14:39:51 UTC 2018


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

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(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/59/6259/1

diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index c0fd9ff..a486dcd 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -89,7 +89,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 581c12c..fa2dd28 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -52,5 +52,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 05aefc1..337aa9b 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: newchange
Gerrit-Change-Id: Ia5063ec65f5bc3a8a0943d1fd823aaeee20b8637
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>


More information about the gerrit-log mailing list