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
diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c
index 9ebdd8e..ddfd6cf 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -237,6 +237,18 @@
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 @@
/* 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,