pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39719?usp=email )
Change subject: mgw: Move cfg pointer from pdata to rq ...................................................................... mgw: Move cfg pointer from pdata to rq The externa object context is held in rq object, not in pdata object, which holds parsed msg state only. Change-Id: Ie64fb6250cc84f1e7737b5c1cf5cca314c7020ed --- M include/osmocom/mgcp/mgcp_protocol.h M src/libosmo-mgcp/mgcp_protocol.c 2 files changed, 17 insertions(+), 15 deletions(-) Approvals: daniel: Looks good to me, approved osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/mgcp/mgcp_protocol.h b/include/osmocom/mgcp/mgcp_protocol.h index dda0fb3..e61669c 100644 --- a/include/osmocom/mgcp/mgcp_protocol.h +++ b/include/osmocom/mgcp/mgcp_protocol.h @@ -72,7 +72,6 @@ /* Internal structure while parsing a request */ struct mgcp_parse_data { - struct mgcp_config *cfg; char *save; /* MGCP Header: */ char *epname; @@ -88,6 +87,9 @@ /* Verb string (e.g. "MDCX") */ char name[4+1]; + /* Global MGW config */ + struct mgcp_config *cfg; + /* parsing results from the MGCP header (trans id, endpoint name ...) */ struct mgcp_parse_data *pdata; diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 74ed14e..1215b95 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -329,9 +329,9 @@ } /* Initialize parsing data. */ - memset(&pdata, 0, sizeof(pdata)); memset(&rq, 0, sizeof(rq)); - pdata.cfg = cfg; + rq.cfg = cfg; + memset(&pdata, 0, sizeof(pdata)); /* Parse command name: */ memcpy(rq.name, (const char *)&msg->l2h[0], sizeof(rq.name)-1); @@ -360,7 +360,7 @@ if (!rq.wildcarded) rq.null_endp = mgcp_endp_is_null(pdata.epname); if (!rq.null_endp) - rq.endp = mgcp_endp_by_name(&rc, pdata.epname, pdata.cfg); + rq.endp = mgcp_endp_by_name(&rc, pdata.epname, rq.cfg); rq.mgcp_cause = rc; if (!rq.endp) { rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_FAIL_NO_ENDPOINT)); @@ -371,7 +371,7 @@ LOGP(DLMGCP, LOGL_NOTICE, "%s: cannot find endpoint \"%s\", cause=%d -- trying to identify trunk...\n", rq.name, pdata.epname, -rq.mgcp_cause); - rq.trunk = mgcp_trunk_by_name(pdata.cfg, pdata.epname); + rq.trunk = mgcp_trunk_by_name(rq.cfg, pdata.epname); if (!rq.trunk) { LOGP(DLMGCP, LOGL_ERROR, "%s: failed to identify trunk for endpoint \"%s\" -- abort\n", rq.name, pdata.epname); @@ -438,7 +438,7 @@ /* Auditing "null" endpoint is allowed for keepalive purposes. There's no rq->endp nor rq->trunk in this case. */ if (rq->null_endp) - return create_ok_response(rq->pdata->cfg, NULL, 200, "AUEP", rq->pdata->trans); + return create_ok_response(rq->cfg, NULL, 200, "AUEP", rq->pdata->trans); if (!rq->endp || !mgcp_endp_avail(rq->endp)) { LOGPENDP(rq->endp, DLMGCP, LOGL_ERROR, "AUEP: selected endpoint not available!\n"); @@ -772,7 +772,7 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "CRCX: Not allowed in 'null' endpoint!\n"); - return create_err_response(pdata->cfg, NULL, 502, "CRCX", pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "CRCX", pdata->trans); } rate_ctrs = trunk->ratectr.mgcp_crcx_ctr_group; @@ -1042,7 +1042,7 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "MDCX: Not allowed in 'null' endpoint!\n"); - return create_err_response(pdata->cfg, NULL, 502, "MDCX", pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "MDCX", pdata->trans); } rate_ctrs = trunk->ratectr.mgcp_mdcx_ctr_group; @@ -1238,7 +1238,7 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "DLCX: Not allowed in 'null' endpoint!\n"); - return create_err_response(pdata->cfg, NULL, 502, "DLCX", pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "DLCX", pdata->trans); } rate_ctrs = trunk->ratectr.mgcp_dlcx_ctr_group; @@ -1377,11 +1377,11 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "RSIP: Not allowed in 'null' endpoint!\n"); - return create_err_response(rq->pdata->cfg, NULL, 502, "RSIP", rq->pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "RSIP", rq->pdata->trans); } - if (rq->pdata->cfg->reset_cb) - rq->pdata->cfg->reset_cb(rq->endp->trunk); + if (rq->cfg->reset_cb) + rq->cfg->reset_cb(rq->endp->trunk); return NULL; } @@ -1408,7 +1408,7 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "RQNT: Not allowed in 'null' endpoint!\n"); - return create_err_response(rq->pdata->cfg, NULL, 502, "RQNT", rq->pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "RQNT", rq->pdata->trans); } for_each_line(line, rq->pdata->save) { @@ -1423,8 +1423,8 @@ if (tone == CHAR_MAX) return create_ok_response(rq->endp, rq->endp, 200, "RQNT", rq->pdata->trans); - if (rq->pdata->cfg->rqnt_cb) - res = rq->pdata->cfg->rqnt_cb(rq->endp, tone); + if (rq->cfg->rqnt_cb) + res = rq->cfg->rqnt_cb(rq->endp, tone); return res == 0 ? create_ok_response(rq->endp, rq->endp, 200, "RQNT", rq->pdata->trans) : create_err_response(rq->endp, rq->endp, res, "RQNT", rq->pdata->trans); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39719?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: Ie64fb6250cc84f1e7737b5c1cf5cca314c7020ed Gerrit-Change-Number: 39719 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillm...@sysmocom.de> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-Reviewer: pespin <pes...@sysmocom.de>