Revision
15334
Author
anthm
Date
2009-11-03 15:32:18 -0600 (Tue, 03 Nov 2009)

Log Message

add distinct-to=true|false to be used with from-domain when you don't want to change the to

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (15333 => 15334)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2009-11-03 21:07:59 UTC (rev 15333)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2009-11-03 21:32:18 UTC (rev 15334)
@@ -206,7 +206,8 @@
 typedef enum {
 	PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 0),
 	PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1),
-	PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2)
+	PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2),
+	PFLAG_NDLB_ALLOW_BAD_IANANAME = (1 << 3)
 } sofia_NDLB_t;
 
 typedef enum {
@@ -387,6 +388,7 @@
 	int failures;
 	struct sofia_gateway *next;
 	sofia_gateway_subscription_t *subscriptions;
+	int distinct_to;
 };
 
 typedef enum {
@@ -733,7 +735,7 @@
  * \param codec_string The profile's codec string or NULL if inexistant
  * \param sdp The parsed SDP content
  */
-void sofia_glue_set_r_sdp_codec_string(switch_channel_t *channel,const char *codec_string, sdp_session_t *sdp);
+void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp);
 switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, const char *r_sdp);
 char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const char *host, char *val, switch_size_t len);
 void event_handler(switch_event_t *event);

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


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-11-03 21:07:59 UTC (rev 15333)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-11-03 21:32:18 UTC (rev 15334)
@@ -1437,7 +1437,7 @@
 		if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) {
 			const char *sipip, *format;
 			switch_uuid_t uuid;
-			uint32_t ping_freq = 0, extension_in_contact = 0;
+			uint32_t ping_freq = 0, extension_in_contact = 0, distinct_to = 0;
 			char *register_str = "true", *scheme = "Digest",
 				*realm = NULL,
 				*username = NULL,
@@ -1559,6 +1559,8 @@
 					register_proxy = val;
 				} else if (!strcmp(var, "outbound-proxy")) {
 					outbound_proxy = val;
+				} else if (!strcmp(var, "distinct-to")) {
+					distinct_to = switch_true(val);
 				} else if (!strcmp(var, "contact-params")) {
 					contact_params = val;
 				} else if (!strcmp(var, "register-transport")) {
@@ -1655,6 +1657,7 @@
 			gateway->register_username = switch_core_strdup(gateway->pool, username);
 			gateway->auth_username = switch_core_strdup(gateway->pool, auth_username);
 			gateway->register_password = switch_core_strdup(gateway->pool, password);
+			gateway->distinct_to = distinct_to;
 
 			if (switch_true(caller_id_in_from)) {
 				sofia_set_flag(gateway, REG_FLAG_CALLERID);
@@ -1930,6 +1933,12 @@
 						} else {
 							sofia_clear_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT);
 						}
+					} else if (!strcasecmp(var, "NDLB-allow-bad-iananame")) {
+						if (switch_true(val)) {
+							sofia_set_pflag(profile, PFLAG_NDLB_ALLOW_BAD_IANANAME);
+						} else {
+							sofia_clear_pflag(profile, PFLAG_NDLB_ALLOW_BAD_IANANAME);
+						}
 					} else if (!strcasecmp(var, "aggressive-nat-detection")) {
 						if (switch_true(val)) { 
 							sofia_set_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
@@ -2673,6 +2682,12 @@
 						} else {
 							profile->ndlb &= ~PFLAG_NDLB_SENDRECV_IN_SESSION;
 						}
+					} else if (!strcasecmp(var, "NDLB-allow-bad-iananame")) {
+						if (switch_true(val)) {
+							sofia_set_pflag(profile, PFLAG_NDLB_ALLOW_BAD_IANANAME);
+						} else {
+							sofia_clear_pflag(profile, PFLAG_NDLB_ALLOW_BAD_IANANAME);
+						}
 					} else if (!strcasecmp(var, "pass-rfc2833")) {
 						if (switch_true(val)) {
 							sofia_set_pflag(profile, PFLAG_PASS_RFC2833);
@@ -3604,7 +3619,7 @@
 
 				if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && (parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
 					if ((sdp = sdp_session(parser))) {
-						sofia_glue_set_r_sdp_codec_string(channel, (tech_pvt->profile?tech_pvt->profile->codec_string:NULL), sdp);
+						sofia_glue_set_r_sdp_codec_string(session, (tech_pvt->profile?tech_pvt->profile->codec_string:NULL), sdp);
 					}
 					sdp_parser_free(parser);
 				}

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


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-11-03 21:07:59 UTC (rev 15333)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-11-03 21:32:18 UTC (rev 15334)
@@ -2591,7 +2591,7 @@
 
 }
 
-void sofia_glue_set_r_sdp_codec_string(switch_channel_t *channel,const char *codec_string, sdp_session_t *sdp)
+void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp)
 {
 	char buf[1024] = {0};
 	sdp_media_t *m;
@@ -2605,6 +2605,8 @@
 	int num_codecs = 0;
 	char *codec_order[SWITCH_MAX_CODECS];
 	const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS] = { 0 };
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	private_object_t *tech_pvt = switch_core_session_get_private(session);
 
 	if (!zstr(codec_string)) {
 		char *tmp_codec_string;
@@ -2666,7 +2668,7 @@
 						continue;
 					}
 
-					if (map->rm_pt < 96) {
+					if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
 						match = (map->rm_pt == imp->ianacode) ? 1 : 0;
 					} else {
 						if (map->rm_encoding) {
@@ -2707,7 +2709,7 @@
 						continue;
 					}
 
-					if (map->rm_pt < 96) {
+					if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
 						match = (map->rm_pt == imp->ianacode) ? 1 : 0;
 					} else {
 						if(map->rm_encoding) {
@@ -3075,7 +3077,7 @@
 				}
 				
 				for (map = m->m_rtpmaps; map; map = map->rm_next) {
-					if (zstr(map->rm_encoding) && map->rm_pt < 96) {
+					if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
 						match = (map->rm_pt == tech_pvt->pt) ? 1 : 0;
 					} else {
 						match = strcasecmp(switch_str_nil(map->rm_encoding), tech_pvt->iananame) ? 0 : 1;
@@ -3160,7 +3162,7 @@
 					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d]/[%s:%d:%u:%d]\n",
 									  rm_encoding, map->rm_pt, (int) map->rm_rate, ptime,
 									  imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000);
-					if (zstr(map->rm_encoding) && map->rm_pt < 96) {
+					if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
 						match = (map->rm_pt == imp->ianacode) ? 1 : 0;
 					} else {
 						match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
@@ -3294,7 +3296,7 @@
 
 					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Compare [%s:%d]/[%s:%d]\n",
 									  rm_encoding, map->rm_pt, imp->iananame, imp->ianacode);
-					if (map->rm_pt < 96) {
+					if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
 						vmatch = (map->rm_pt == imp->ianacode) ? 1 : 0;
 					} else {
 						vmatch = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (15333 => 15334)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	2009-11-03 21:07:59 UTC (rev 15333)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	2009-11-03 21:32:18 UTC (rev 15334)
@@ -337,7 +337,7 @@
 							 NUTAG_URL(gateway_ptr->register_url),
 							 TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)),
 							 TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
-							 SIPTAG_TO_STR(gateway_ptr->register_from),
+							 SIPTAG_TO_STR(gateway_ptr->distinct_to ? gateway_ptr->register_from : gateway_ptr->register_to),
 							 SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
 							 SIPTAG_FROM_STR(gateway_ptr->register_from),					 
 							 SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
@@ -349,7 +349,7 @@
 							   NUTAG_URL(gateway_ptr->register_url),
 							   TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
 							   SIPTAG_FROM_STR(gateway_ptr->register_from),
-							   SIPTAG_TO_STR(gateway_ptr->register_from),
+							   SIPTAG_TO_STR(gateway_ptr->distinct_to ? gateway_ptr->register_from : gateway_ptr->register_to),
 							   SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
 							   NUTAG_REGISTRAR(gateway_ptr->register_proxy),
 							   NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());