]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add channel variable "sip_contact_user" to set user portion of contact on an outbound...
authorMichael Jerris <mike@jerris.com>
Mon, 28 Jul 2008 17:09:51 +0000 (17:09 +0000)
committerMichael Jerris <mike@jerris.com>
Mon, 28 Jul 2008 17:09:51 +0000 (17:09 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9190 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia_glue.c

index 216e54a6a7b84bc50fa2511b414c724db18a46b6..e0bf13c7d15f25d511415151e37ce047558b3ee7 100644 (file)
@@ -1131,10 +1131,24 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                }
 
                if (switch_strlen_zero(tech_pvt->invite_contact)) {
-                       if (sofia_glue_transport_has_tls(tech_pvt->transport)) {
-                               tech_pvt->invite_contact = tech_pvt->profile->tls_url;
+                       const char * contact;
+                       if ((contact = switch_channel_get_variable(channel, "sip_contact_user"))) {
+                               char *ip_addr = (tech_pvt->profile->extsipip) ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip;
+                               char *ipv6 = strchr(ip_addr, ':');
+                               if (sofia_glue_transport_has_tls(tech_pvt->transport)) {
+                                       tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s%s%s:%d", contact, 
+                                                                                                                                                  ipv6 ? "[" : "", ip_addr, ipv6 ? "]" : "", 
+                                                                                                                                                  tech_pvt->profile->tls_sip_port);
+                               } else {
+                                       tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s%s%s", contact, 
+                                                                                                                                                  ipv6 ? "[" : "", ip_addr, ipv6 ? "]" : "");
+                               }
                        } else {
-                               tech_pvt->invite_contact = tech_pvt->profile->url;
+                               if (sofia_glue_transport_has_tls(tech_pvt->transport)) {
+                                       tech_pvt->invite_contact = tech_pvt->profile->tls_url;
+                               } else {
+                                       tech_pvt->invite_contact = tech_pvt->profile->url;
+                               }
                        }
                }