pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/33312 )
Change subject: mgw: Allow auditing speciall 'null' endpoint ......................................................................
mgw: Allow auditing speciall 'null' endpoint
This is a special endpoint which can always be audited. This is useful for clients who wish to submit requests to osmo-mgw periodically to find out whether the MGW is still reachable. This endpoint will be used by libomso-mgcp-client as default target endpoint to implement such feature. This "null" Endpoint is osmo-mgw specific, not described in MGCP specs.
Related: SYS#6481 Change-Id: Ia409b16e9211e6261e2e0f21288544289d6f3733 --- M doc/manuals/chapters/mgcp_endpoints.adoc M src/libosmo-mgcp/mgcp_endp.c M src/libosmo-mgcp/mgcp_protocol.c 3 files changed, 49 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/12/33312/1
diff --git a/doc/manuals/chapters/mgcp_endpoints.adoc b/doc/manuals/chapters/mgcp_endpoints.adoc index 797fdea..2fb6e16 100644 --- a/doc/manuals/chapters/mgcp_endpoints.adoc +++ b/doc/manuals/chapters/mgcp_endpoints.adoc @@ -91,4 +91,10 @@ not yet useable.
NOTE: the VTY command "show mgcp" can be used to get a list of all available -endpoints (including identifiers) \ No newline at end of file +endpoints (including identifiers) + +=== The `null` endpoint + +OsmoMGW offers a special `null@<domain>` endpoint which can be audited at all times. +This is useful for MGCP clients who wish to submit requests to OsmoMGW +periodically to find out whether it is still reachable and in a working state. \ No newline at end of file diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c index 2bf15e0..7182fdd 100644 --- a/src/libosmo-mgcp/mgcp_endp.c +++ b/src/libosmo-mgcp/mgcp_endp.c @@ -229,6 +229,17 @@ return false; }
+/*! Check if the given epname refers to a "null" endpoint. + * \param[in] epname endpoint name to check + * \returns true if epname refers to "null"" endpoint, else false. */ +bool mgcp_endp_is_null(const char *epname) +{ + if (strstr(epname, "null")) + return true; + + return false; +} + /*! Find an endpoint by its name on a specified trunk. * \param[out] cause pointer to store cause code, can be NULL. * \param[in] epname endpoint name to lookup. diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 1fa345b..ce9b85e 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -86,6 +86,9 @@ /* set to true when the request has been classified as wildcarded */ bool wildcarded;
+ /* Set to true when the request is targeted at the "null" endpoint */ + bool null_endp; + /* contains cause code in case of problems during endp/trunk resolution */ int mgcp_cause; }; @@ -390,7 +393,10 @@ /* Locate endpoint and trunk, if no endpoint can be located try at least to identify the trunk. */ rq.pdata = &pdata; rq.wildcarded = mgcp_endp_is_wildcarded(pdata.epname); - rq.endp = mgcp_endp_by_name(&rc, pdata.epname, pdata.cfg); + 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.mgcp_cause = rc; if (!rq.endp) { rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_FAIL_NO_ENDPOINT)); @@ -407,14 +413,14 @@ rq.name, pdata.epname); return create_err_response(cfg, NULL, -rq.mgcp_cause, rq.name, pdata.trans); } - } else { + } else if (!rq.null_endp) { /* If the endpoint name suggests that the request refers to a specific endpoint, then the * request cannot be handled and we must stop early. */ LOGP(DLMGCP, LOGL_NOTICE, "%s: cannot find endpoint "%s", cause=%d -- abort\n", rq.name, pdata.epname, -rq.mgcp_cause); return create_err_response(cfg, NULL, -rq.mgcp_cause, rq.name, pdata.trans); - } + } /* else: Handle special "null" endpoint below (with rq.endp=NULL, rq.trunk=NULL) */ } else { osmo_strlcpy(debug_last_endpoint_name, rq.endp->name, sizeof(debug_last_endpoint_name)); rq.trunk = rq.endp->trunk; @@ -460,6 +466,11 @@ static struct msgb *handle_audit_endpoint(struct mgcp_request_data *rq) { LOGPENDP(rq->endp, DLMGCP, LOGL_NOTICE, "AUEP: auditing endpoint ...\n"); + + /* 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); + if (!rq->endp || !mgcp_endp_avail(rq->endp)) { LOGPENDP(rq->endp, DLMGCP, LOGL_ERROR, "AUEP: selected endpoint not available!\n"); return create_err_response(rq->trunk, NULL, 501, "AUEP", rq->pdata->trans);