mgcp_endp: make wildcarded detection separate

osmo-mgw currently does only a very simple detection method for
wildcarded requests, but it makes sense to split this detection
off into a separate function so that it can be used from different code
locations and we still have it at one place only.

Change-Id: I27018c01afb8acabfcf5d435c996cc9806e52d6b
Related: SYS#5535
This commit is contained in:
Philipp Maier 2021-07-14 11:53:49 +02:00
parent d02716d6c2
commit d64c041cdb
2 changed files with 14 additions and 1 deletions

View File

@ -134,6 +134,7 @@ struct mgcp_endpoint *mgcp_endp_alloc(struct mgcp_trunk *trunk, unsigned int ind
void mgcp_endp_release(struct mgcp_endpoint *endp);
int mgcp_endp_claim(struct mgcp_endpoint *endp, const char *callid);
void mgcp_endp_update(struct mgcp_endpoint *endp);
bool mgcp_endp_is_wildcarded(const char *epname);
struct mgcp_endpoint *mgcp_endp_by_name_trunk(int *cause, const char *epname,
const struct mgcp_trunk *trunk);
struct mgcp_endpoint *mgcp_endp_by_name(int *cause, const char *epname,

View File

@ -237,6 +237,18 @@ static struct mgcp_endpoint *find_specific_endpoint(const char *epname,
return NULL;
}
/*! Check if the given epname refers to a wildcarded request or to a specific
* endpoint.
* \param[in] epname endpoint name to check
* \returns true if epname refers to wildcarded request, else false. */
bool mgcp_endp_is_wildcarded(const char *epname)
{
if (strstr(epname, "*"))
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.
@ -253,7 +265,7 @@ struct mgcp_endpoint *mgcp_endp_by_name_trunk(int *cause, const char *epname,
/* At the moment we only support a primitive ('*'-only) method of
* wildcarded endpoint searches that picks the next free endpoint on
* a trunk. */
if (strstr(epname, "*")) {
if (mgcp_endp_is_wildcarded(epname)) {
endp = find_free_endpoint(trunk);
if (endp) {
LOGPENDP(endp, DLMGCP, LOGL_DEBUG,