From c23c32f013954a04bb83f64f4e374c0041ead56f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 5 Oct 2006 15:07:45 +0000 Subject: [PATCH] sofia again git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2981 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index acc0b96c06..18c146fd79 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2413,6 +2413,7 @@ static void sip_i_invite(nua_t *nua, char *displayname; char *username, *to_username; char *url_user = (char *) from->a_url->url_user; + char *to_user, *to_host; if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); @@ -2424,6 +2425,25 @@ static void sip_i_invite(nua_t *nua, tech_pvt->key = switch_core_session_strdup(session, key); } + to_user = (char *) to->a_url->url_user; + to_host = (char *) to->a_url->url_host; + + if (switch_strlen_zero(to_user)) { /* if sofia doesnt parse the To: right, we'll have to do it */ + if ((to_user = sip_header_as_string(tech_pvt->home, (sip_header_t *) to))) { + char *p; + if (*to_user == '<') { + to_user++; + } + if ((p = strchr((to_user += 4), '@'))) { + *p++ = '\0'; + to_host = p; + if ((p = strchr(to_host, '>'))) { + *p = '\0'; + } + } + } + } + if (switch_strlen_zero(url_user)) { url_user = "service"; } @@ -2446,7 +2466,7 @@ static void sip_i_invite(nua_t *nua, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); return; } - if (!(to_username = switch_core_db_mprintf("%s@%s", (char *) to->a_url->url_user, (char *) to->a_url->url_host))) { + if (!(to_username = switch_core_db_mprintf("%s@%s", (char *) to_user, (char *) to_host))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); switch_core_db_free(username); return; @@ -2470,7 +2490,7 @@ static void sip_i_invite(nua_t *nua, (profile->context && !strcasecmp(profile->context, "_domain_")) ? (char *) from->a_url->url_host : profile->context, (profile->pflags & PFLAG_FULL_ID) ? - to_username : (char *) to->a_url->url_user + to_username : (char *) to_user )) != 0) { switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); switch_core_db_free(username);