mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-04 01:37:14 +00:00
Rename sofia_glue_get_user_host to switch_split_user_domain
and move to switch_utils. To allow use by other modules.
This commit is contained in:
parent
a291af5768
commit
3f7cafd709
src
@ -640,6 +640,16 @@ SWITCH_DECLARE(int) switch_inet_pton(int af, const char *src, void *dst);
|
|||||||
|
|
||||||
SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val);
|
SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Split a user@domain string as user and domain
|
||||||
|
\param in the input string
|
||||||
|
\param user the string to put the user into
|
||||||
|
\param domain the string to put the domain into
|
||||||
|
\return 1 if successfull
|
||||||
|
\note Extended formats protocol:user@domain:port (Example: sip:toto@example.org)
|
||||||
|
*/
|
||||||
|
int switch_split_user_domain(char *in, char **user, char **domain);
|
||||||
|
|
||||||
/* malloc or DIE macros */
|
/* malloc or DIE macros */
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%s", __FILE__, __LINE__),abort(), 0), ptr )
|
#define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%s", __FILE__, __LINE__),abort(), 0), ptr )
|
||||||
|
@ -3750,7 +3750,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||||||
switch_channel_set_variable_printf(nchannel, "sip_local_network_addr", "%s", profile->extsipip ? profile->extsipip : profile->sipip);
|
switch_channel_set_variable_printf(nchannel, "sip_local_network_addr", "%s", profile->extsipip ? profile->extsipip : profile->sipip);
|
||||||
switch_channel_set_variable(nchannel, "sip_profile_name", profile_name);
|
switch_channel_set_variable(nchannel, "sip_profile_name", profile_name);
|
||||||
|
|
||||||
sofia_glue_get_user_host(switch_core_session_strdup(nsession, tech_pvt->dest), NULL, &tech_pvt->remote_ip);
|
switch_split_user_domain(switch_core_session_strdup(nsession, tech_pvt->dest), NULL, &tech_pvt->remote_ip);
|
||||||
|
|
||||||
if (dest_to) {
|
if (dest_to) {
|
||||||
if (strchr(dest_to, '@')) {
|
if (strchr(dest_to, '@')) {
|
||||||
|
@ -824,7 +824,6 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_
|
|||||||
const char *sourceip, switch_memory_pool_t *pool);
|
const char *sourceip, switch_memory_pool_t *pool);
|
||||||
|
|
||||||
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp);
|
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp);
|
||||||
int sofia_glue_get_user_host(char *in, char **user, char **host);
|
|
||||||
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
|
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
|
||||||
void sofia_glue_do_xfer_invite(switch_core_session_t *session);
|
void sofia_glue_do_xfer_invite(switch_core_session_t *session);
|
||||||
uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
|
uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
|
||||||
|
@ -1038,7 +1038,7 @@ void event_handler(switch_event_t *event)
|
|||||||
if ((mwi_account = switch_event_get_header_nil(event, "orig-mwi-account"))) {
|
if ((mwi_account = switch_event_get_header_nil(event, "orig-mwi-account"))) {
|
||||||
dup_mwi_account = strdup(mwi_account);
|
dup_mwi_account = strdup(mwi_account);
|
||||||
switch_assert(dup_mwi_account != NULL);
|
switch_assert(dup_mwi_account != NULL);
|
||||||
sofia_glue_get_user_host(dup_mwi_account, &mwi_user, &mwi_host);
|
switch_split_user_domain(dup_mwi_account, &mwi_user, &mwi_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mwi_user) {
|
if (!mwi_user) {
|
||||||
|
@ -5252,49 +5252,6 @@ char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sofia_glue_get_user_host(char *in, char **user, char **host)
|
|
||||||
{
|
|
||||||
char *p = NULL, *h = NULL, *u = in;
|
|
||||||
|
|
||||||
if (!in) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First isolate the host part from the user part */
|
|
||||||
if ((h = strchr(u, '@'))) {
|
|
||||||
*h++ = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean out the user part of its protocol prefix (if any) */
|
|
||||||
if ((p = strchr(u, ':'))) {
|
|
||||||
*p++ = '\0';
|
|
||||||
u = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean out the host part of any suffix */
|
|
||||||
if (h) {
|
|
||||||
if ((p = strchr(h, ':'))) {
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((p = strchr(h, ';'))) {
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((p = strchr(h, ' '))) {
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (user) {
|
|
||||||
*user = u;
|
|
||||||
}
|
|
||||||
if (host) {
|
|
||||||
*host = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *sofia_glue_strip_proto(const char *uri)
|
const char *sofia_glue_strip_proto(const char *uri)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -304,7 +304,7 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
|
|||||||
|
|
||||||
dup_account = strdup(account);
|
dup_account = strdup(account);
|
||||||
switch_assert(dup_account != NULL);
|
switch_assert(dup_account != NULL);
|
||||||
sofia_glue_get_user_host(dup_account, &user, &host);
|
switch_split_user_domain(dup_account, &user, &host);
|
||||||
|
|
||||||
|
|
||||||
if ((pname = switch_event_get_header(event, "sofia-profile"))) {
|
if ((pname = switch_event_get_header(event, "sofia-profile"))) {
|
||||||
|
@ -1071,7 +1071,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
|||||||
if (v_event && *v_event && (mwi_account = switch_event_get_header(*v_event, "mwi-account"))) {
|
if (v_event && *v_event && (mwi_account = switch_event_get_header(*v_event, "mwi-account"))) {
|
||||||
dup_mwi_account = strdup(mwi_account);
|
dup_mwi_account = strdup(mwi_account);
|
||||||
switch_assert(dup_mwi_account != NULL);
|
switch_assert(dup_mwi_account != NULL);
|
||||||
sofia_glue_get_user_host(dup_mwi_account, &mwi_user, &mwi_host);
|
switch_split_user_domain(dup_mwi_account, &mwi_user, &mwi_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mwi_user) {
|
if (!mwi_user) {
|
||||||
|
@ -2349,6 +2349,49 @@ SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int switch_split_user_domain(char *in, char **user, char **domain)
|
||||||
|
{
|
||||||
|
char *p = NULL, *h = NULL, *u = in;
|
||||||
|
|
||||||
|
if (!in) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* First isolate the host part from the user part */
|
||||||
|
if ((h = strchr(u, '@'))) {
|
||||||
|
*h++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean out the user part of its protocol prefix (if any) */
|
||||||
|
if ((p = strchr(u, ':'))) {
|
||||||
|
*p++ = '\0';
|
||||||
|
u = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean out the host part of any suffix */
|
||||||
|
if (h) {
|
||||||
|
if ((p = strchr(h, ':'))) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((p = strchr(h, ';'))) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((p = strchr(h, ' '))) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (user) {
|
||||||
|
*user = u;
|
||||||
|
}
|
||||||
|
if (domain) {
|
||||||
|
*domain = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user