Change in osmo-mgw[master]: mgcp_protocol: rafctor function create_response_with_sdp

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
Tue Jul 20 15:23:53 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/24972 )


Change subject: mgcp_protocol: rafctor function create_response_with_sdp
......................................................................

mgcp_protocol: rafctor function create_response_with_sdp

The function create_response_calls add_params, which is rather short.
The code in there can also be put in create_response_with_sdp. The
decision whether the endpoint name (Z) should be added or not, should be
made by the caller.

Change-Id: I7e29c513f4386832646e96194ed6c2397405ed3b
Related: SYS#5535
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 17 insertions(+), 27 deletions(-)



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

diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index ef82cfd..5ff94af 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -237,33 +237,13 @@
 	return create_resp(endp, code, " FAIL", msg, trans, NULL, NULL);
 }
 
-/* Add MGCP parameters to a message buffer */
-static int add_params(struct msgb *msg, const struct mgcp_endpoint *endp,
-		      const struct mgcp_conn_rtp *conn)
-{
-	int rc;
-
-	/* NOTE: Only in the virtual trunk we allow dynamic endpoint names */
-	if (endp->wildcarded_req
-	    && endp->trunk->trunk_type == MGCP_TRUNK_VIRTUAL) {
-		rc = msgb_printf(msg, "Z: %s\r\n", endp->name);
-		if (rc < 0)
-			return -EINVAL;
-	}
-
-	rc = msgb_printf(msg, "I: %s\r\n", conn->conn->id);
-	if (rc < 0)
-		return -EINVAL;
-
-	return 0;
-}
-
 /* Format MGCP response string (with SDP attached) */
 static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
 					     struct mgcp_conn_rtp *conn,
 					     const char *msg,
 					     const char *trans_id,
-					     bool add_conn_params)
+					     bool add_epname,
+					     bool add_conn_id)
 {
 	/* cfg->local_ip allows overwritting the announced IP address with
 	 * regards to the one we actually bind to. Useful in behind-NAT
@@ -281,9 +261,16 @@
 	if (!sdp)
 		return NULL;
 
-	/* Attach optional connection parameters */
-	if (add_conn_params) {
-		rc = add_params(sdp, endp, conn);
+	/* Attach optional endpoint name */
+	if (add_epname) {
+		rc = msgb_printf(sdp, "Z: %s\r\n", endp->name);
+		if (rc < 0)
+			goto error;
+	}
+
+	/* Attach optional connection id */
+	if (add_conn_id) {
+		rc = msgb_printf(sdp, "I: %s\r\n", conn->conn->id);
 		if (rc < 0)
 			goto error;
 	}
@@ -1091,7 +1078,10 @@
 		 "CRCX: connection successfully created\n");
 	rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_SUCCESS));
 	mgcp_endp_update(endp);
-	return create_response_with_sdp(endp, conn, "CRCX", pdata->trans, true);
+
+	/* NOTE: Only in the virtual trunk we allow dynamic endpoint names */
+	bool add_epname = rq->wildcarded && endp->trunk->trunk_type == MGCP_TRUNK_VIRTUAL;
+	return create_response_with_sdp(endp, conn, "CRCX", pdata->trans, add_epname, true);
 error2:
 	mgcp_endp_release(endp);
 	LOGPENDP(endp, DLMGCP, LOGL_NOTICE,
@@ -1339,7 +1329,7 @@
 	LOGPCONN(conn->conn, DLMGCP, LOGL_NOTICE,
 		 "MDCX: connection successfully modified\n");
 	mgcp_endp_update(endp);
-	return create_response_with_sdp(endp, conn, "MDCX", pdata->trans, false);
+	return create_response_with_sdp(endp, conn, "MDCX", pdata->trans, false, false);
 error3:
 	return create_err_response(endp, error_code, "MDCX", pdata->trans);
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/24972
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I7e29c513f4386832646e96194ed6c2397405ed3b
Gerrit-Change-Number: 24972
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210720/52ced19a/attachment.htm>


More information about the gerrit-log mailing list