[Freeswitch-svn] [commit] r9190 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN mikej at freeswitch.org
Mon Jul 28 13:09:51 EDT 2008


Author: mikej
Date: Mon Jul 28 13:09:51 2008
New Revision: 9190

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c

Log:
add channel variable "sip_contact_user" to set user portion of contact on an outbound invite (MODENDP-120)

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Mon Jul 28 13:09:51 2008
@@ -1131,10 +1131,24 @@
 		}
 
 		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;
+				}
 			}
 		}
 



More information about the Freeswitch-svn mailing list