[Freeswitch-branches] [commit] r6691 - freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN stkn at freeswitch.org
Tue Dec 11 21:01:26 EST 2007


Author: stkn
Date: Tue Dec 11 21:01:25 2007
New Revision: 6691

Modified:
   freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c

Log:
Still getting a "no route to host" message on the remote box, but stuff is starting to work now... somehow

Modified: freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Tue Dec 11 21:01:25 2007
@@ -544,3 +544,5 @@
 
 const char *sofia_glue_transport2str(const sofia_transport_t tp);
 const char *sofia_glue_transport2scheme(const sofia_transport_t tp);
+
+int sofia_glue_transport_has_tls(const sofia_transport_t tp);

Modified: freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/sofia.c	Tue Dec 11 21:01:25 2007
@@ -1065,7 +1065,7 @@
 						profile->tls_url = switch_core_sprintf(profile->pool, "sips:mod_sofia@%s:%d", profile->extsipip, profile->tls_sip_port);
 						profile->tls_bindurl = switch_core_sprintf(profile->pool, "sips:mod_sofia@%s:%d;maddr=%s", profile->extsipip, profile->tls_sip_port, profile->sipip);
 					} else {
-						profile->tls_url = switch_core_sprintf(profile->pool, "sips:mod_sofia@%s:%d", profile->extsipip, profile->tls_sip_port);
+						profile->tls_url = switch_core_sprintf(profile->pool, "sips:mod_sofia@%s:%d", profile->sipip, profile->tls_sip_port);
 						profile->tls_bindurl = switch_core_sprintf(profile->pool, "sips:mod_sofia@%s:%d", profile->sipip, profile->tls_sip_port);
 					}
 
@@ -2010,13 +2010,27 @@
 	}
 
 	if (sip->sip_to && sip->sip_to->a_url) {
-		const char *val;
+		const char *host, *user;
+		int port;
 		sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
 
 		url_set_chanvars(session, sip->sip_to->a_url, sip_to);
-		if ((val = switch_channel_get_variable(channel, "sip_to_uri"))) {
+		if (switch_channel_get_variable(channel, "sip_to_uri")) {
+
+			host = switch_channel_get_variable(channel, "sip_to_host");
+			user = switch_channel_get_variable(channel, "sip_to_user");
+
+			if (sip->sip_contact->m_url->url_port) {
+				port = atoi(sip->sip_contact->m_url->url_port);
+			} else {
+				port = sofia_glue_transport_has_tls(transport) ? profile->tls_sip_port : profile->sip_port;
+			}
+
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Components: \"%s\" \"%s\" \"%d\"\n", host, user, port);
+
+			tech_pvt->to_uri = switch_core_session_sprintf(session, "%s:%s@%s:%d;transport=%s",
+						 sofia_glue_transport2scheme(transport), host, user, port, sofia_glue_transport2str(transport));
 
-			tech_pvt->to_uri = switch_core_session_sprintf(session, "%s:%s;transport=%s", sofia_glue_transport2scheme(transport), val, sofia_glue_transport2str(transport));
 			if (profile->ndlb & PFLAG_NDLB_TO_IN_200_CONTACT) {
 				if (strchr(tech_pvt->to_uri, '>')) {
 					tech_pvt->reply_contact = tech_pvt->to_uri;
@@ -2024,17 +2038,21 @@
 					tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s>", tech_pvt->to_uri);
 				}
 			} else {
-				if (strchr(profile->url, '>')) {
-					tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", profile->url, sofia_glue_transport2str(transport));
+				const char *url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url;
+
+				if (strchr(url, '>')) {
+					tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url, sofia_glue_transport2str(transport));
 				} else {
-					tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", profile->url, sofia_glue_transport2str(transport));
+					tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", url, sofia_glue_transport2str(transport));
 				}
 			}
 		} else {
-			if (strchr(profile->url, '>')) {
-				tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", profile->url, sofia_glue_transport2str(transport));
+			const char *url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url;
+
+			if (strchr(url, '>')) {
+				tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url, sofia_glue_transport2str(transport));
 			} else {
-				tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", profile->url, sofia_glue_transport2str(transport));
+				tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", url, sofia_glue_transport2str(transport));
 			}
 		}
 

Modified: freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/branches/stkn/sofia-exp/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Tue Dec 11 21:01:25 2007
@@ -613,7 +613,7 @@
 	}
 }
 
-static int sofia_glue_transport_has_tls(const sofia_transport_t tp)
+int sofia_glue_transport_has_tls(const sofia_transport_t tp)
 {
 	switch(tp) {
 	case SOFIA_TRANSPORT_TCP_TLS:



More information about the Freeswitch-branches mailing list