Revision
16473
Author
brian
Date
2010-01-22 17:37:50 -0600 (Fri, 22 Jan 2010)

Log Message

 fix rpid and from correctly when auto-nat is enabled so polycom won't display the flipping URI and freak some poor souls out :P  

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (16472 => 16473)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2010-01-22 22:17:17 UTC (rev 16472)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2010-01-22 23:37:50 UTC (rev 16473)
@@ -1468,7 +1468,7 @@
 	sofia_set_flag_locked(tech_pvt, TFLAG_READY);
 
 	if (!tech_pvt->nh) {
-		char *d_url = NULL, *url = NULL, *dest_host = NULL, *url_str = NULL;
+		char *d_url = NULL, *url = NULL, *url_str = NULL;
 		sofia_private_t *sofia_private;
 		char *invite_contact = NULL, *to_str, *use_from_str, *from_str;
 		const char *t_var;
@@ -1497,11 +1497,6 @@
 	
 		url_str = url;
 
-		if ((dest_host = strchr(url_str, '@'))) {
-			dest_host++;
-		}
-
-
 		if (!tech_pvt->from_str) {
 			const char* sipip;
 			const char* format;
@@ -1509,7 +1504,7 @@
 			
 			sipip = tech_pvt->profile->sipip;
 			
-			if (sofia_glue_check_nat(tech_pvt->profile, dest_host)) {
+			if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
 				sipip = tech_pvt->profile->extsipip;
 			}
 			
@@ -1527,7 +1522,6 @@
 											!zstr(cid_num) ? "@" : "",
 											sipip);
 		}
-
 		
 		if (from_var) {
 			if (strncasecmp(from_var, "sip:", 4) || strncasecmp(from_var, "sips:", 5)) {
@@ -1559,6 +1553,14 @@
 			rpid_domain = "cluecon.com";
 		}
 
+		if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTO_NAT)) {
+			if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
+				rpid_domain = tech_pvt->profile->extsipip;
+			} else {
+				rpid_domain = tech_pvt->profile->sipip;
+			}
+		}
+
 		/*
 		 * Ignore transport chanvar and uri parameter for gateway connections
 		 * since all of them have been already taken care of in mod_sofia.c:sofia_outgoing_channel()
@@ -1592,7 +1594,7 @@
 			if ((contact = switch_channel_get_variable(channel, "sip_contact_user"))) {
 				char *ip_addr;
 				char *ipv6;
-				
+
 				if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) { 
 					ip_addr = (switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) 
 						? tech_pvt->profile->sipip : tech_pvt->profile->extsipip;
@@ -1628,7 +1630,6 @@
 		from_str = sofia_overcome_sip_uri_weakness(session, use_from_str, 0, SWITCH_TRUE, invite_from_params);
 		to_str = sofia_overcome_sip_uri_weakness(session, invite_to_uri ? invite_to_uri : tech_pvt->dest_to, 0, SWITCH_FALSE, invite_to_params);
 
-
 		/*
 		   Does the "genius" who wanted SIP to be "text-based" so it was "easier to read" even use it now,
 		   or did he just suggest it to make our lives miserable?
@@ -1646,7 +1647,7 @@
 				call_id = switch_core_session_get_uuid(session);
 			}
 		}
-		
+
 		tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
 								  NUTAG_URL(url_str),
 								  TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),