pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/33311 )
Change subject: mgcp-client: Move some static functions further above ......................................................................
mgcp-client: Move some static functions further above
This is a preparation commit for follow-up one, where some of these functions need to be used in other static functions.
Related: SYS#6481 Change-Id: I3a00d8c47ec773390d9626364c4c75ca579f1508 --- M src/libosmo-mgcp-client/mgcp_client.c 1 file changed, 47 insertions(+), 34 deletions(-)
Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c index f0f320c..f74255c 100644 --- a/src/libosmo-mgcp-client/mgcp_client.c +++ b/src/libosmo-mgcp-client/mgcp_client.c @@ -773,6 +773,40 @@ return ret; }
+static const char *_mgcp_client_name_append_domain(const struct mgcp_client *mgcp, const char *name) +{ + static char endpoint[MGCP_ENDPOINT_MAXLEN]; + int rc; + + rc = snprintf(endpoint, sizeof(endpoint), "%s@%s", name, mgcp_client_endpoint_domain(mgcp)); + if (rc > sizeof(endpoint) - 1) { + LOGPMGW(mgcp, LOGL_ERROR, "MGCP endpoint exceeds maximum length of %zu: '%s@%s'\n", + sizeof(endpoint) - 1, name, mgcp_client_endpoint_domain(mgcp)); + return NULL; + } + if (rc < 1) { + LOGPMGW(mgcp, LOGL_ERROR, "Cannot compose MGCP endpoint name\n"); + return NULL; + } + return endpoint; +} + +/* Safely ignore the MGCP response to the DLCX sent via _mgcp_client_send_dlcx() */ +static void _ignore_mgcp_response(struct mgcp_response *response, void *priv) { } + +/* Format DLCX message (fire and forget) and send it off to the MGW */ +static void _mgcp_client_send_dlcx(struct mgcp_client *mgcp, const char *epname) +{ + struct msgb *msgb_dlcx; + struct mgcp_msg mgcp_msg_dlcx = { + .verb = MGCP_VERB_DLCX, + .presence = MGCP_MSG_PRESENCE_ENDPOINT, + }; + osmo_strlcpy(mgcp_msg_dlcx.endpoint, epname, sizeof(mgcp_msg_dlcx.endpoint)); + msgb_dlcx = mgcp_msg_gen(mgcp, &mgcp_msg_dlcx); + mgcp_client_tx(mgcp, msgb_dlcx, &_ignore_mgcp_response, NULL); +} + struct mgcp_client *mgcp_client_init(void *ctx, struct mgcp_client_conf *conf) { @@ -820,40 +854,6 @@ return mgcp; }
-/* Safely ignore the MGCP response to the DLCX sent via _mgcp_client_send_dlcx() */ -static void _ignore_mgcp_response(struct mgcp_response *response, void *priv) { } - -/* Format DLCX message (fire and forget) and send it off to the MGW */ -static void _mgcp_client_send_dlcx(struct mgcp_client *mgcp, const char *epname) -{ - struct msgb *msgb_dlcx; - struct mgcp_msg mgcp_msg_dlcx = { - .verb = MGCP_VERB_DLCX, - .presence = MGCP_MSG_PRESENCE_ENDPOINT, - }; - osmo_strlcpy(mgcp_msg_dlcx.endpoint, epname, sizeof(mgcp_msg_dlcx.endpoint)); - msgb_dlcx = mgcp_msg_gen(mgcp, &mgcp_msg_dlcx); - mgcp_client_tx(mgcp, msgb_dlcx, &_ignore_mgcp_response, NULL); -} - -static const char *_mgcp_client_name_append_domain(const struct mgcp_client *mgcp, const char *name) -{ - static char endpoint[MGCP_ENDPOINT_MAXLEN]; - int rc; - - rc = snprintf(endpoint, sizeof(endpoint), "%s@%s", name, mgcp_client_endpoint_domain(mgcp)); - if (rc > sizeof(endpoint) - 1) { - LOGPMGW(mgcp, LOGL_ERROR, "MGCP endpoint exceeds maximum length of %zu: '%s@%s'\n", - sizeof(endpoint) - 1, name, mgcp_client_endpoint_domain(mgcp)); - return NULL; - } - if (rc < 1) { - LOGPMGW(mgcp, LOGL_ERROR, "Cannot compose MGCP endpoint name\n"); - return NULL; - } - return endpoint; -} - /*! Initialize client connection (opens socket) * \param[in,out] mgcp MGCP client descriptor. * \returns 0 on success, -EINVAL on error. */