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.orgdexter has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/24972 ) Change subject: mgcp_protocol: refactor function create_response_with_sdp ...................................................................... mgcp_protocol: refactor function create_response_with_sdp The function create_response_with_sdp 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(-) Approvals: Jenkins Builder: Verified daniel: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index ef82cfd..3af87d0 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 && 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: 3 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann at sysmocom.de> Gerrit-Reviewer: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210721/b06bd6eb/attachment.htm>