mgcp-client: Introduce API osmo_mgcpc_ep_local_name()
Change-Id: I18d7bdf650c0ec87ae16ed4944aed9f495400137
This commit is contained in:
parent
c415ed5113
commit
6225b5cecb
|
@ -45,6 +45,7 @@ static inline void osmo_mgcpc_ep_ci_dlcx(struct osmo_mgcpc_ep_ci *ci)
|
|||
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);
|
||||
|
|
|
@ -173,6 +173,30 @@ const char *osmo_mgcpc_ep_name(const struct osmo_mgcpc_ep *ep)
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue