[Freeswitch-svn] [commit] r13578 - freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia

FreeSWITCH SVN brian at freeswitch.org
Wed Jun 3 10:52:05 PDT 2009


Author: brian
Date: Wed Jun  3 12:52:05 2009
New Revision: 13578

Log:
 cleanup by mike and bkw 

Modified:
   freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c

Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	(original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	Wed Jun  3 12:52:05 2009
@@ -1417,9 +1417,6 @@
 		}
 	}
 
-	id = switch_mprintf("sip:%s@%s", sub_to_user, (profile->local_network && switch_check_network_list_ip(network_ip, profile->local_network))
-						? sub_to_host : profile->extsipip);
-
 	contact = sofia_glue_get_url_from_contact(o_contact, 1);
 
 	if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && profile->local_network &&
@@ -1432,20 +1429,26 @@
 		if ((ptr = sofia_glue_find_parameter(o_contact, "transport="))) {
 			sofia_transport_t transport = sofia_glue_str2transport(ptr);
 			transport_str = sofia_glue_transport2str(transport);
+
+			switch (transport) {
+			case SOFIA_TRANSPORT_TCP:
+				contact_str = profile->tcp_public_contact;
+				break;
+			case SOFIA_TRANSPORT_TCP_TLS:
+				contact_str = profile->tls_public_contact;
+				break;
+			default:
+				contact_str = profile->public_url;
+				break;
+			}
+
 			user_via = switch_mprintf("SIP/2.0/%s %s;rport", transport_str, profile->extsipip);
+
 		} else {
 			user_via = switch_mprintf("SIP/2.0/UDP %s;rport", profile->extsipip);
-		}
-		
-		if (switch_stristr("udp", transport_str)) {
-			contact_str = profile->public_url;
-		} else if (switch_stristr("tcp", transport_str)) {
-			contact_str = profile->tcp_public_contact;
-		} else if (switch_stristr("tls", transport_str)) {
-			contact_str = profile->tls_public_contact;
-		} else {
 			contact_str = profile->public_url;
 		}
+		
 	} else {
 		contact_str = profile->url;
 		id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
@@ -1496,7 +1499,7 @@
 	nua_notify(nh,
 			   NUTAG_NEWSUB(1),
 			   TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
-			   TAG_IF(!switch_strlen_zero(user_via), SIPTAG_VIA_STR(user_via)),
+			   TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
 			   SIPTAG_EVENT_STR(event),
 			   SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
 			   SIPTAG_PAYLOAD_STR(body), TAG_END());
@@ -1505,6 +1508,7 @@
 	switch_safe_free(id);
 	switch_safe_free(route);
 	switch_safe_free(user_via);
+
 	if (ext_profile) {
 		sofia_glue_release_profile(ext_profile);
 	}
@@ -1558,7 +1562,8 @@
 		get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr, my_addrinfo->ai_addrlen);
 		network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
 
-		if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(network_ip, profile->local_network)) {
+		if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && profile->local_network &&
+			!switch_check_network_list_ip(network_ip, profile->local_network)) {
 			is_auto_nat = 1;
 		}	
 
@@ -1663,8 +1668,6 @@
 			}
 		}
 
-
-
 		if (to) {
 			to_str = switch_mprintf("sip:%s@%s", to->a_url->url_user, to->a_url->url_host);
 		}

Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	(original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	Wed Jun  3 12:52:05 2009
@@ -425,26 +425,34 @@
 			*p = '\0';
 		}
 
-		if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(network_ip, profile->local_network)) {
+		if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && profile->local_network &&
+			!switch_check_network_list_ip(network_ip, profile->local_network)) {
 			char *ptr = NULL;
 			const char *transport_str = NULL;
+			
 			if ((ptr = sofia_glue_find_parameter(contact_url, "transport="))) {
 				sofia_transport_t transport = sofia_glue_str2transport(ptr);
 				transport_str = sofia_glue_transport2str(transport);
-				user_via = switch_mprintf("SIP/2.0/%s %s;rport",  transport_str, profile->extsipip);
+				
+				switch (transport) {
+				case SOFIA_TRANSPORT_TCP:
+					contact_str = profile->tcp_public_contact;
+					break;
+				case SOFIA_TRANSPORT_TCP_TLS:
+					contact_str = profile->tls_public_contact;
+					break;
+				default:
+					contact_str = profile->public_url;
+					break;
+				}
+				
+				user_via = switch_mprintf("SIP/2.0/%s %s;rport", transport_str, profile->extsipip);
+				
 			} else {
 				user_via = switch_mprintf("SIP/2.0/UDP %s;rport", profile->extsipip);
-			}
-
-			if (switch_stristr("udp", transport_str)) {
-				contact_str = profile->public_url;
-			} else if (switch_stristr("tcp", transport_str)) {
-				contact_str = profile->tcp_public_contact;
-			} else if (switch_stristr("tls", transport_str)) {
-				contact_str = profile->tls_public_contact;
-			} else {
 				contact_str = profile->public_url;
 			}
+		
 		} else {
 			contact_str = profile->url;
 		}
@@ -459,7 +467,7 @@
 		nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
 		nua_notify(nh,
 				   NUTAG_NEWSUB(1),
-				   TAG_IF(!switch_strlen_zero(user_via), SIPTAG_VIA_STR(user_via)),
+				   TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
 				   SIPTAG_EVENT_STR(event), 
 				   SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
 				   SIPTAG_PAYLOAD_STR(""),



More information about the Freeswitch-svn mailing list