pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/34510?usp=email )
Change subject: mgcp-client: Introduce API osmo_mgcpc_ep_local_name() ...................................................................... mgcp-client: Introduce API osmo_mgcpc_ep_local_name() Change-Id: I18d7bdf650c0ec87ae16ed4944aed9f495400137 --- M include/osmocom/mgcp_client/mgcp_client_endpoint_fsm.h M src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c 2 files changed, 33 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/10/34510/1 diff --git a/include/osmocom/mgcp_client/mgcp_client_endpoint_fsm.h b/include/osmocom/mgcp_client/mgcp_client_endpoint_fsm.h index f21f40e..3daa09d 100644 --- a/include/osmocom/mgcp_client/mgcp_client_endpoint_fsm.h +++ b/include/osmocom/mgcp_client/mgcp_client_endpoint_fsm.h @@ -45,6 +45,7 @@ void osmo_mgcpc_ep_clear(struct osmo_mgcpc_ep *ep); const char *osmo_mgcpc_ep_name(const struct osmo_mgcpc_ep *ep); +const char *osmo_mgcpc_ep_local_name(const struct osmo_mgcpc_ep *ep); const char *osmo_mgcpc_ep_ci_name(const struct osmo_mgcpc_ep_ci *ci); const char *osmo_mgcpc_ep_ci_id(const struct osmo_mgcpc_ep_ci *ci); struct mgcp_client *osmo_mgcpc_ep_client(const struct osmo_mgcpc_ep *ep); diff --git a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c index a01bbdc..25e776e 100644 --- a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c +++ b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c @@ -173,6 +173,29 @@ return osmo_fsm_inst_name(ep->fi); } +/*! Get "local endpoint name" part of the endpoint name: (local-endpoint-name@domain-name) + * + * \param ep The MGCP Endpoint + * \returns the local endpoint name if found, NULL on error. + */ +const char *osmo_mgcpc_ep_local_name(const struct osmo_mgcpc_ep *ep) +{ + static char buf[1024]; + const char *sep; + OSMO_ASSERT(ep); + sep = strchr(ep->endpoint, '@'); + if (!sep) { + OSMO_STRLCPY_ARRAY(buf, ep->endpoint); + return buf; + } + if (sep - ep->endpoint >= sizeof(buf)) + return NULL; + + memcpy(buf, ep->endpoint, sep - ep->endpoint); + buf[sep - ep->endpoint] = '\0'; + return buf; +} + const char *mgcp_conn_peer_name(const struct mgcp_conn_peer *info) { /* I'd be fine with a smaller buffer and accept truncation, but gcc possibly refuses to build if -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/34510?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I18d7bdf650c0ec87ae16ed4944aed9f495400137 Gerrit-Change-Number: 34510 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-MessageType: newchange