Revision
15230
Author
anthm
Date
2009-10-26 13:16:38 -0500 (Mon, 26 Oct 2009)

Log Message

add pass-callee-id (defaults to true) disable by setting it to false if you encounter something too stupid to ignore X headers

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (15229 => 15230)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-26 18:06:39 UTC (rev 15229)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-26 18:16:38 UTC (rev 15230)
@@ -179,6 +179,7 @@
 {
 	private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	const char *callee_name = NULL, *callee_number = NULL;
+	const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
 	char *pai = NULL;
 
 	if (!(callee_name = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_name"))) {
@@ -195,9 +196,19 @@
 		callee_name = callee_number;
 	}
 
+	if (ua && !zstr(callee_number) && !switch_stristr("polycom", ua)) {
+		callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, tech_pvt->profile->sipip);
+	}
+	
+
 	if (!zstr(callee_name) && !zstr(callee_number)) {
-		pai = switch_core_session_sprintf(tech_pvt->session, "P-Asserted-Identity: \"%s\" <%s>\nX-FS-Display-Name: %s\nX-FS-Display-Number: %s\n", 
-										  callee_name, callee_number, callee_name, callee_number);
+		if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) {
+			pai = switch_core_session_sprintf(tech_pvt->session, "P-Asserted-Identity: \"%s\" <%s>\nX-FS-Display-Name: %s\nX-FS-Display-Number: %s\n", 
+											  callee_name, callee_number, callee_name, callee_number);
+		} else {
+			pai = switch_core_session_sprintf(tech_pvt->session, "P-Asserted-Identity: \"%s\" <%s>\n", 
+											  callee_name, callee_number, callee_name, callee_number);
+		}
 	}
 	return pai;
 }
@@ -496,7 +507,8 @@
 							SOATAG_REUSE_REJECTED(1),
 							SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), 
 							TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-							SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
+							TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), 
+								   SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
 							TAG_END());
 
 				switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 200 OK, waiting for ACK\n");
@@ -586,7 +598,8 @@
 					SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 					SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), 
 					TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-					SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
+					TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), 
+						   SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
 					TAG_END());
 		switch_safe_free(extra_headers);
 		sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
@@ -1568,7 +1581,8 @@
 						SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 						SIPTAG_HEADER_STR(generate_pai_str(session)), 
 						TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
-						SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
+						TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), 
+							   SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
 						TAG_END());
 			switch_safe_free(extra_header);
 			switch_channel_mark_ring_ready(channel);
@@ -1665,7 +1679,8 @@
 								SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip),
 								SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), 
 								TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
-								SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
+								TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote), 
+									   SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
 								TAG_END());
 					switch_safe_free(extra_header);
 				}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (15229 => 15230)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2009-10-26 18:06:39 UTC (rev 15229)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2009-10-26 18:16:38 UTC (rev 15230)
@@ -199,6 +199,7 @@
 	PFLAG_AUTO_NAT,
 	PFLAG_SIPCOMPACT,
 	PFLAG_SQL_IN_TRANS,
+	PFLAG_PASS_CALLEE_ID,
 	/* No new flags below this line */
 	PFLAG_MAX
 } PFLAGS;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (15229 => 15230)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-10-26 18:06:39 UTC (rev 15229)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-10-26 18:16:38 UTC (rev 15230)
@@ -1830,6 +1830,7 @@
 			profile->reg_acl_count = 0;
 			profile->proxy_acl_count = 0;
 			sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
+			sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
 			profile->ib_calls = 0;
 			profile->ob_calls = 0;
 			profile->ib_failed_calls = 0;
@@ -1847,6 +1848,12 @@
 						profile->debug = atoi(val);
 					} else if (!strcasecmp(var, "tracelevel")) {
 						mod_sofia_globals.tracelevel = switch_log_str2level(val);
+					} else if (!strcasecmp(var, "pass-callee-id")) {
+						if (switch_true(val)) {
+							sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
+						} else {
+							sofia_clear_pflag(profile, PFLAG_PASS_CALLEE_ID);
+						}
 					} else if (!strcasecmp(var, "sip-trace")) {
 						if (switch_true(val)) {
 							sofia_set_flag(profile, TFLAG_TPORT_LOG);
@@ -2386,6 +2393,7 @@
 				sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER);
 				sofia_set_pflag(profile, PFLAG_RTP_AUTOFLUSH_DURING_BRIDGE);
 				profile->contact_user = SOFIA_DEFAULT_CONTACT_USER;
+				sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
 
 				for (param = switch_xml_child(settings, "param"); param; param = param->next) {
 					char *var = (char *) switch_xml_attr_soft(param, "name");
@@ -2773,6 +2781,12 @@
 						if (switch_true(val)) {
 							sofia_set_pflag(profile, PFLAG_SIPCOMPACT);
 						}
+					} else if (!strcasecmp(var, "pass-callee-id")) {
+						if (switch_true(val)) {
+							sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
+						} else {
+							sofia_clear_pflag(profile, PFLAG_PASS_CALLEE_ID);
+						}
 					} else if (!strcasecmp(var, "sql-in-transactions")) {
 						if (switch_true(val)) {
 							sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);

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


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-10-26 18:06:39 UTC (rev 15229)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-10-26 18:16:38 UTC (rev 15230)
@@ -1773,7 +1773,7 @@
 			   TAG_IF(!zstr(tech_pvt->privacy), SIPTAG_PRIVACY_STR(tech_pvt->privacy)),
 			   TAG_IF(!zstr(alert_info), SIPTAG_HEADER_STR(alert_info)),
 			   TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-			   SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
+			   TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
 			   TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
 			   TAG_IF(!zstr(route_uri), NUTAG_PROXY(route_uri)),
 			   TAG_IF(!zstr(route), SIPTAG_ROUTE_STR(route)),