pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39740?usp=email )
Change subject: mgw: Split DLCX read-only validations into its own function
......................................................................
mgw: Split DLCX read-only validations into its own function
Similar to what's already done in CRCX and MDXC.
Change-Id: I3d86f0cbeacc7c0cd69809f898714a76d3b86ed0
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 50 insertions(+), 28 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
osmith: 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 6a731a3..237f2bf 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -1073,6 +1073,49 @@
return create_err_response(endp, endp, error_code, "MDCX", pdata->trans);
}
+/* Read-only checks for parsed DLCX request, applied to existing found conn.
+ * Returns negative MGCP error code on failure, 0 on scucess.
+ * NOTE: rq->endp may be NULL here! */
+static int validate_parsed_dlcx(struct mgcp_request_data *rq)
+{
+ struct mgcp_parse_data *pdata = rq->pdata;
+ struct mgcp_parse_hdr_pars *hpars = &pdata->hpars;
+ struct rate_ctr_group *rate_ctrs = rq->trunk->ratectr.mgcp_dlcx_ctr_group;
+ int rc;
+
+ if (hpars->callid) {
+ /* If we have no endpoint, but a call id in the request, then this request cannot be handled */
+ if (!rq->endp) {
+ LOGPTRUNK(rq->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 -539;
+ }
+ if (!(rq->endp->x_osmo_ign & MGCP_X_OSMO_IGN_CALLID) &&
+ mgcp_verify_call_id(rq->endp, hpars->callid) != 0) {
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_INVALID_CALLID));
+ return -516;
+ }
+ }
+
+ if (hpars->connid) {
+ /* If we have no endpoint, but a connection id in the request, then this request cannot be handled */
+ if (!rq->endp) {
+ LOGPTRUNK(rq->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 -539;
+ }
+ if ((rc = mgcp_verify_ci(rq->endp, hpars->connid)) != 0) {
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_FAIL_INVALID_CONNID));
+ return -rc;
+ }
+ }
+
+ /* Everything fine, continue */
+ return 0;
+}
+
/* DLCX command handler, processes the received command */
static struct msgb *handle_delete_con(struct mgcp_request_data *rq)
{
@@ -1130,39 +1173,18 @@
if (rc < 0)
return create_err_response(rq->trunk, NULL, -rc, "DLCX", pdata->trans);
- 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);
- }
- if (!(endp->x_osmo_ign & MGCP_X_OSMO_IGN_CALLID) &&
- 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);
- }
- }
+ rc = validate_parsed_dlcx(rq);
+ if (rc < 0)
+ return create_err_response(rq->trunk, NULL, -rc, "DLCX", pdata->trans);
/* The logic does not permit to go past this point without having the
* the endp pointer populated. */
OSMO_ASSERT(endp);
+ /*****************************************************************************
+ * From here on below we start, delete conn and potentially release endpoint.
+ *****************************************************************************/
+
/* When no connection id is supplied, we will interpret this as a
* wildcarded DLCX that refers to the selected endpoint. This means
* that we drop all connections on that specific endpoint at once.
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39740?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: I3d86f0cbeacc7c0cd69809f898714a76d3b86ed0
Gerrit-Change-Number: 39740
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39754?usp=email )
Change subject: mgw: CRCX: Handle codec information before initializing osmux
......................................................................
mgw: CRCX: Handle codec information before initializing osmux
Same order as done during MDCX. This way we can also eg. check
configured codec is AMR before successfully entering configuring osmux.
Change-Id: If291db0c048196e6e0eee2c38e648e5a25438078
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 10 insertions(+), 8 deletions(-)
Approvals:
osmith: Looks good to me, but someone else must approve
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 237f2bf..ef82796 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -768,6 +768,15 @@
conn_rtp = mgcp_conn_get_conn_rtp(conn);
OSMO_ASSERT(conn_rtp);
+ /* Handle codec information and decide for a suitable codec */
+ rc = handle_codec_info(conn_rtp, rq);
+ mgcp_codecset_summary(&conn_rtp->end.cset, mgcp_conn_dump(conn));
+ if (rc) {
+ error_code = rc;
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_CODEC_NEGOTIATION));
+ goto error2;
+ }
+
/* If X-Osmux (remote CID) was received, alloc next avail CID as local CID */
if (hpars->remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) {
/* Make sure osmux is setup: */
@@ -785,14 +794,6 @@
} /* else: -1 (wildcard) */
}
- /* Handle codec information and decide for a suitable codec */
- rc = handle_codec_info(conn_rtp, rq);
- mgcp_codecset_summary(&conn_rtp->end.cset, mgcp_conn_dump(conn));
- if (rc) {
- error_code = rc;
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_CODEC_NEGOTIATION));
- goto error2;
- }
/* Upgrade the conn type RTP_DEFAULT->RTP_IUUP if needed based on requested codec: */
if (conn_rtp->type == MGCP_RTP_DEFAULT &&
strcmp(conn_rtp->end.cset.codec->subtype_name, "VND.3GPP.IUFP") == 0) {
@@ -1017,6 +1018,7 @@
error_code = rc;
goto error3;
}
+
/* Upgrade the conn type RTP_DEFAULT->RTP_IUUP if needed based on requested codec: */
if (conn_rtp->type == MGCP_RTP_DEFAULT &&
strcmp(conn_rtp->end.cset.codec->subtype_name, "VND.3GPP.IUFP") == 0)
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39754?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: If291db0c048196e6e0eee2c38e648e5a25438078
Gerrit-Change-Number: 39754
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39737?usp=email )
Change subject: mgw: Increment rate_ctr MGCP_*_FAIL_UNHANDLED_PARAM during parsing
......................................................................
mgw: Increment rate_ctr MGCP_*_FAIL_UNHANDLED_PARAM during parsing
We could not do it before because we had no easy access to the command
verb being parsed. Now that we have access to it, bettter increase it
where we have exact path where stuff happens.
Change-Id: I3ea45fc1d25284b253ac9b7f0c0a925c10c994ca
---
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_protocol.c
2 files changed, 19 insertions(+), 24 deletions(-)
Approvals:
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index afeadd5..f7cba70 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -422,6 +422,22 @@
goto mgcp_header_done;
default:
LOG_MGCP_PDATA(pdata, LOGL_NOTICE, "unhandled option: '%c'/%d\n", *line, *line);
+ switch (pdata->rq->verb) {
+ case MGCP_VERB_CRCX:
+ rate_ctr_inc(rate_ctr_group_get_ctr(pdata->rq->trunk->ratectr.mgcp_crcx_ctr_group,
+ MGCP_CRCX_FAIL_UNHANDLED_PARAM));
+ break;
+ case MGCP_VERB_MDCX:
+ rate_ctr_inc(rate_ctr_group_get_ctr(pdata->rq->trunk->ratectr.mgcp_mdcx_ctr_group,
+ MGCP_MDCX_FAIL_UNHANDLED_PARAM));
+ break;
+ case MGCP_VERB_DLCX:
+ rate_ctr_inc(rate_ctr_group_get_ctr(pdata->rq->trunk->ratectr.mgcp_dlcx_ctr_group,
+ MGCP_DLCX_FAIL_UNHANDLED_PARAM));
+ break;
+ default:
+ break;
+ }
return -539;
}
}
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 0e0f9dd..ef0aad4 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -689,15 +689,8 @@
/* parse CallID C: and LocalParameters L: */
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_CRCX_FAIL_UNHANDLED_PARAM));
+ if (rc < 0)
return create_err_response(rq->trunk, NULL, -rc, "CRCX", pdata->trans);
- default:
- return create_err_response(rq->trunk, NULL, -rc, "CRCX", pdata->trans);
- }
/* Parse SDP if found: */
if (hpars->have_sdp) {
@@ -901,15 +894,8 @@
}
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_MDCX_FAIL_UNHANDLED_PARAM));
+ if (rc < 0)
return create_err_response(rq->trunk, NULL, -rc, "MDCX", pdata->trans);
- default:
- return create_err_response(rq->trunk, NULL, -rc, "MDCX", pdata->trans);
- }
/* If a CallID is provided during MDCX, validate (unless endp was explicitly configured to ignore it
* through "X-Osmo-IGN: C") that it matches the one previously set. */
@@ -1094,15 +1080,8 @@
}
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));
+ if (rc < 0)
return create_err_response(rq->trunk, NULL, -rc, "DLCX", pdata->trans);
- default:
- return create_err_response(rq->trunk, NULL, -rc, "DLCX", pdata->trans);
- }
if (hpars->callid) {
/* If we have no endpoint, but a call id in the request, then this request cannot be handled */
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39737?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: I3ea45fc1d25284b253ac9b7f0c0a925c10c994ca
Gerrit-Change-Number: 39737
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39736?usp=email )
Change subject: mgw: Split CRCX read-only validations into its own function
......................................................................
mgw: Split CRCX read-only validations into its own function
The SDP parsing is moved to a step beforehand, so that validation of
full message can be done in a subsequent step. That validation step is
moved into a function to give some air to handle_create_con() and easily
spot the logic.
The logic based on force_realloc is split so that code modifying the
object is moved to the later update step.
Change-Id: I639ad0a25a0af4a4637045ca8bf61e436a789426
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 108 insertions(+), 80 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
Jenkins Builder: Verified
osmith: 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 49a4e83..0e0f9dd 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -567,6 +567,87 @@
return 534;
}
+/* Read-only checks for parsed CRCX request.
+ * Returns negative MGCP error code on failure, 0 on scucess. */
+static int validate_parsed_crcx(struct mgcp_request_data *rq)
+{
+ 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 = trunk->ratectr.mgcp_crcx_ctr_group;
+
+ /* Check parameters */
+ if (!hpars->callid) {
+ LOGPENDP(endp, DLMGCP, LOGL_ERROR,
+ "CRCX: insufficient parameters, missing callid\n");
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_MISSING_CALLID));
+ return -516;
+ }
+
+ if (hpars->mode == MGCP_CONN_NONE) {
+ LOGPENDP(endp, DLMGCP, LOGL_ERROR,
+ "CRCX: insufficient parameters, invalid mode\n");
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_INVALID_MODE));
+ return -517;
+ }
+
+ /* It is illegal to send a connection identifier
+ * together with a CRCX, the MGW will assign the
+ * connection identifier by itself on CRCX */
+ if (hpars->connid) {
+ LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: 'I: %s' not expected!\n", hpars->connid);
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_BAD_ACTION));
+ return -523;
+ }
+
+ /* Reject osmux if disabled by config */
+ if (trunk->cfg->osmux.usage == OSMUX_USAGE_OFF &&
+ hpars->remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) {
+ LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: Request with Osmux but it is disabled by config!\n");
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX));
+ return -511;
+ }
+ /* Reject non-osmux if required by config */
+ if (trunk->cfg->osmux.usage == OSMUX_USAGE_ONLY &&
+ hpars->remote_osmux_cid == MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) {
+ LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: Request without Osmux but it is required by config!\n");
+ return -517;
+ }
+
+ /* Read-only checks here, force_realloc case done out of there afterwards.*/
+ if (!trunk->force_realloc) {
+ /* Check if we are able to accept the creation of another connection */
+ if (mgcp_endp_is_full(endp)) {
+ /* There is no more room for a connection, leave
+ * everything as it is and return with an error */
+ LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: endpoint full, max. %d connections allowed!\n",
+ endp->type->max_conns);
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_LIMIT_EXCEEDED));
+ return -540;
+ }
+
+ /* Check if this endpoint already serves a call, if so, check if the
+ * callids match up so that we are sure that this is our call.
+ * Do check only if endpoint was (or is by current CRCX) configured
+ * to explicitly ignore it ("X-Osmo-IGN: C").
+ */
+ if (endp->callid &&
+ !((endp->x_osmo_ign | hpars->x_osmo_ign) & MGCP_X_OSMO_IGN_CALLID) &&
+ mgcp_verify_call_id(endp, hpars->callid)) {
+ /* This is not our call, leave everything as it is and
+ * return with an error. */
+ LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: already seized by other call (%s)\n",
+ endp->callid);
+ rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_UNKNOWN_CALLID));
+ return -400;
+ }
+ }
+
+ /* Everything fine, continue */
+ return 0;
+}
+
/* CRCX command handler, processes the received command */
static struct msgb *handle_create_con(struct mgcp_request_data *rq)
{
@@ -589,6 +670,7 @@
return create_err_response(rq->cfg, NULL, 502, "CRCX", pdata->trans);
}
+ /* rq->trunk is available (non-null) from here on. */
rate_ctrs = trunk->ratectr.mgcp_crcx_ctr_group;
/* we must have a free ep */
@@ -617,30 +699,6 @@
return create_err_response(rq->trunk, NULL, -rc, "CRCX", pdata->trans);
}
- /* Check parameters */
- if (!hpars->callid) {
- LOGPENDP(endp, DLMGCP, LOGL_ERROR,
- "CRCX: insufficient parameters, missing callid\n");
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_MISSING_CALLID));
- return create_err_response(endp, endp, 516, "CRCX", pdata->trans);
- }
-
- if (hpars->mode == MGCP_CONN_NONE) {
- LOGPENDP(endp, DLMGCP, LOGL_ERROR,
- "CRCX: insufficient parameters, invalid mode\n");
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_INVALID_MODE));
- return create_err_response(endp, endp, 517, "CRCX", pdata->trans);
- }
-
- /* It is illegal to send a connection identifier
- * together with a CRCX, the MGW will assign the
- * connection identifier by itself on CRCX */
- if (hpars->connid) {
- LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: 'I: %s' not expected!\n", hpars->connid);
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_BAD_ACTION));
- return create_err_response(endp, endp, 523, "CRCX", pdata->trans);
- }
-
/* Parse SDP if found: */
if (hpars->have_sdp) {
rc = mgcp_parse_sdp_data(pdata);
@@ -650,67 +708,37 @@
}
}
- /* Reject osmux if disabled by config */
- if (trunk->cfg->osmux.usage == OSMUX_USAGE_OFF &&
- hpars->remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) {
- LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: Request with Osmux but it is disabled by config!\n");
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX));
- return create_err_response(endp, endp, 511, "CRCX", pdata->trans);
- }
- /* Reject non-osmux if required by config */
- if (trunk->cfg->osmux.usage == OSMUX_USAGE_ONLY &&
- hpars->remote_osmux_cid == MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) {
- LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: Request without Osmux but it is required by config!\n");
- return create_err_response(endp, endp, 517, "CRCX", pdata->trans);
- }
-
- /* Check if we are able to accept the creation of another connection */
- if (mgcp_endp_is_full(endp)) {
- LOGPENDP(endp, DLMGCP, LOGL_ERROR,
- "CRCX: endpoint full, max. %i connections allowed!\n",
- endp->type->max_conns);
- if (trunk->force_realloc) {
- /* There is no more room for a connection, make some
- * room by blindly tossing the oldest of the two two
- * connections */
- mgcp_endp_free_conn_oldest(endp);
- OSMO_ASSERT(!mgcp_endp_is_full(endp));
- } else {
- /* There is no more room for a connection, leave
- * everything as it is and return with an error */
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_LIMIT_EXCEEDED));
- return create_err_response(endp, endp, 540, "CRCX", pdata->trans);
- }
- }
-
- /* Check if this endpoint already serves a call, if so, check if the
- * callids match up so that we are sure that this is our call.
- * Do check only if endpoint was (or is by current CRCX) configured
- * to explicitly ignore it ("X-Osmo-IGN: C").
- */
- if (endp->callid &&
- !((endp->x_osmo_ign | hpars->x_osmo_ign) & MGCP_X_OSMO_IGN_CALLID) &&
- mgcp_verify_call_id(endp, hpars->callid)) {
- LOGPENDP(endp, DLMGCP, LOGL_ERROR,
- "CRCX: already seized by other call (%s)\n",
- endp->callid);
- if (trunk->force_realloc)
- /* This is not our call, toss everything by releasing
- * the entire endpoint. (rude!) */
- mgcp_endp_release(endp);
- else {
- /* This is not our call, leave everything as it is and
- * return with an error. */
- rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_UNKNOWN_CALLID));
- return create_err_response(endp, endp, 400, "CRCX", pdata->trans);
- }
- }
+ rc = validate_parsed_crcx(rq);
+ if (rc < 0)
+ return create_err_response(endp, endp, -rc, "CRCX", pdata->trans);
/*******************************************************************
* Allocate and update endpoint and conn.
- * From here on below we start updating endpoing and creating conn:
+ * From here on below we start updating endpoint and creating conn:
*******************************************************************/
+ if (trunk->force_realloc) {
+ /* Check if we are able to accept the creation of another connection */
+ if (mgcp_endp_is_full(endp)) {
+ /* There is no more room for a connection, make some
+ * room by blindly tossing the oldest of the two two
+ * connections */
+ LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: endpoint full, max. %d connections allowed!\n",
+ endp->type->max_conns);
+ mgcp_endp_free_conn_oldest(endp);
+ OSMO_ASSERT(!mgcp_endp_is_full(endp));
+ }
+
+ /* Check if this endpoint already serves a call and then check if the callids match up */
+ if (endp->callid &&
+ !((endp->x_osmo_ign | hpars->x_osmo_ign) & MGCP_X_OSMO_IGN_CALLID) &&
+ mgcp_verify_call_id(endp, hpars->callid)) {
+ /* This is not our call, toss everything by releasing
+ * the entire endpoint. (rude!) */
+ mgcp_endp_release(endp);
+ }
+ }
+
/* Update endp->x_osmo_ign: */
endp->x_osmo_ign |= hpars->x_osmo_ign;
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39736?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: I639ad0a25a0af4a4637045ca8bf61e436a789426
Gerrit-Change-Number: 39736
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39756?usp=email )
Change subject: mgw: Rearrange last steps of CRCX and MDCX
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39756?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: I42acda16cb2d59a9b7aae06b7584d4dfc1e91f9e
Gerrit-Change-Number: 39756
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 11 Mar 2025 11:08:35 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes