pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39240?usp=email )
(
7 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: mgw: DLCX: Split mgcp header pars parsing into a previous step
......................................................................
mgw: DLCX: Split mgcp header pars parsing into a previous step
Do most of the initial parsing and verification in a prior step, filling
in a "parsed" struct which simplifies logic coming after for different
message types.
Change-Id: I557a3a257ddefedc479a4aff974a74c4e4e2c85d
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 38 insertions(+), 49 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
daniel: Looks good to me, approved
neels: 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 00e72f3..a33cf3d 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -1224,13 +1224,12 @@
struct mgcp_parse_data *pdata = rq->pdata;
struct mgcp_trunk *trunk = rq->trunk;
struct mgcp_endpoint *endp = rq->endp;
+ struct mgcp_parse_hdr_pars *hpars = &pdata->hpars;
struct rate_ctr_group *rate_ctrs;
- int error_code = 400;
- char *line;
char stats[1048];
- const char *conn_id = NULL;
struct mgcp_conn *conn = NULL;
unsigned int i;
+ int rc;
/* NOTE: In this handler we can not take it for granted that the endp
* pointer will be populated, however a trunk is always guaranteed (except for 'null' endp).
@@ -1272,49 +1271,42 @@
return create_ok_response(trunk, NULL, 200, "DLCX", pdata->trans);
}
- for_each_line(line, pdata->save) {
- if (!mgcp_check_param(line))
- continue;
+ rc = mgcp_parse_hdr_pars(pdata);
+ switch (rc) {
+ case 0:
+ break; /* all good, continue below */
+ case -539:
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_UNHANDLED_PARAM));
+ return create_err_response(rq->trunk, NULL, -rc, "DLCX", pdata->trans);
+ default:
+ return create_err_response(rq->trunk, NULL, -rc, "DLCX", pdata->trans);
+ }
- switch (toupper(line[0])) {
- case 'C':
- /* If we have no endpoint, but a call id in the request,
- then this request cannot be handled */
- if (!endp) {
- LOGPTRUNK(trunk, DLMGCP, LOGL_NOTICE,
- "cannot handle requests with call-id (C) without endpoint -- abort!");
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_UNHANDLED_PARAM));
- return create_err_response(rq->trunk, NULL, 539, "DLCX", pdata->trans);
- }
-
- if (mgcp_verify_call_id(endp, line + 3) != 0) {
- error_code = 516;
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_INVALID_CALLID));
- goto error3;
- }
- break;
- case 'I':
- /* If we have no endpoint, but a connection id in the request,
- then this request cannot be handled */
- if (!endp) {
- LOGPTRUNK(trunk, DLMGCP, LOGL_NOTICE,
- "cannot handle requests with conn-id (I) without endpoint -- abort!");
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_UNHANDLED_PARAM));
- return create_err_response(rq->trunk, NULL, 539, "DLCX", pdata->trans);
- }
-
- conn_id = (const char *)line + 3;
- if ((error_code = mgcp_verify_ci(endp, conn_id))) {
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_INVALID_CONNID));
- goto error3;
- }
- break;
- default:
- LOGPEPTR(endp, trunk, DLMGCP, LOGL_NOTICE, "DLCX: Unhandled MGCP option: '%c'/%d\n",
- line[0], line[0]);
+ if (hpars->callid) {
+ /* If we have no endpoint, but a call id in the request, then this request cannot be handled */
+ if (!endp) {
+ LOGPTRUNK(trunk, DLMGCP, LOGL_NOTICE,
+ "cannot handle requests with call-id (C) without endpoint -- abort!");
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_UNHANDLED_PARAM));
return create_err_response(rq->trunk, NULL, 539, "DLCX", pdata->trans);
- break;
+ }
+ if (mgcp_verify_call_id(endp, hpars->callid) != 0) {
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_INVALID_CALLID));
+ return create_err_response(endp, endp, 516, "DLCX", pdata->trans);
+ }
+ }
+
+ if (hpars->connid) {
+ /* If we have no endpoint, but a connection id in the request, then this request cannot be handled */
+ if (!endp) {
+ LOGPTRUNK(trunk, DLMGCP, LOGL_NOTICE,
+ "cannot handle requests with conn-id (I) without endpoint -- abort!");
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_UNHANDLED_PARAM));
+ return create_err_response(rq->trunk, NULL, 539, "DLCX", pdata->trans);
+ }
+ if ((rc = mgcp_verify_ci(endp, hpars->connid)) != 0) {
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_INVALID_CONNID));
+ return create_err_response(endp, endp, rc, "DLCX", pdata->trans);
}
}
@@ -1326,7 +1318,7 @@
* wildcarded DLCX that refers to the selected endpoint. This means
* that we drop all connections on that specific endpoint at once.
* (See also RFC3435 Section F.7) */
- if (!conn_id) {
+ if (!hpars->connid) {
int num_conns = mgcp_endp_num_conns(endp);
LOGPENDP(endp, DLMGCP, LOGL_NOTICE,
"DLCX: missing ci (connectionIdentifier), will remove all connections (%d total) at once\n",
@@ -1344,10 +1336,10 @@
}
/* Find the connection */
- conn = mgcp_endp_get_conn(endp, conn_id);
+ conn = mgcp_endp_get_conn(endp, hpars->connid);
if (!conn) {
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_INVALID_CONNID));
- goto error3;
+ return create_err_response(endp, endp, 400, "DLCX", pdata->trans);
}
/* save the statistics of the current connection */
mgcp_format_stats(stats, sizeof(stats), conn);
@@ -1368,9 +1360,6 @@
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_SUCCESS));
return create_ok_resp_with_param(endp, endp, 250, "DLCX", pdata->trans, stats);
-
-error3:
- return create_err_response(endp, endp, error_code, "DLCX", pdata->trans);
}
/* RSIP command handler, processes the received command */
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39240?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I557a3a257ddefedc479a4aff974a74c4e4e2c85d
Gerrit-Change-Number: 39240
Gerrit-PatchSet: 8
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39249?usp=email )
(
2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: mgw: Remove wrong TODO comment
......................................................................
mgw: Remove wrong TODO comment
The TODO was written because the author had in mind the ptr where the
codec was stored was a MGCP endpoint object, but it is actually an
rtp_end which is an object under conn_rtp, so that's fine already with
current code.
Change-Id: I99d2211e81443883c45cc3fdda10e39a8c152063
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 0 insertions(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
daniel: Looks good to me, approved
neels: Looks good to me, but someone else must approve
laforge: Looks good to me, but someone else must approve
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 8dcb686..7095058 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -1185,7 +1185,6 @@
goto error3;
}
/* Upgrade the conn type RTP_DEFAULT->RTP_IUUP if needed based on requested codec: */
- /* TODO: "codec" probably needs to be moved from endp to conn */
if (conn_rtp->type == MGCP_RTP_DEFAULT &&
strcmp(conn_rtp->end.cset.codec->subtype_name, "VND.3GPP.IUFP") == 0)
rc = mgcp_conn_iuup_init(conn_rtp);
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39249?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I99d2211e81443883c45cc3fdda10e39a8c152063
Gerrit-Change-Number: 39249
Gerrit-PatchSet: 7
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
neels has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39352?usp=email )
Change subject: mgcp_msg: Improve logging checking MGCP line param
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS1:
> > this patch might be a misunderstanding from CR on the CRCX parsing patch? […]
i hadn't realized the pdata->epname arg, sorry for the noise
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39352?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I18fd316a2d830b9418a806e32f27558d980259d6
Gerrit-Change-Number: 39352
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-CC: neels <nhofmeyr(a)sysmocom.de>
Gerrit-CC: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 21 Jan 2025 15:51:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: osmith <osmith(a)sysmocom.de>
Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>