[Freeswitch-svn] [commit] r7366 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Fri Jan 25 22:56:41 EST 2008


Author: anthm
Date: Fri Jan 25 22:56:40 2008
New Revision: 7366

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c

Log:
fix all the bugs brought on by the guys who made me add t38 no-media passthru

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Fri Jan 25 22:56:40 2008
@@ -333,7 +333,7 @@
 												SIPTAG_REASON_STR("SIP;cause=200;text=\"Call completed elsewhere\"")), TAG_END());
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause);
-				nua_respond(tech_pvt->nh, sip_cause, NULL, TAG_END());
+				nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), TAG_END());
 			}
 		}
 		switch_set_flag(tech_pvt, TFLAG_BYE);
@@ -984,9 +984,10 @@
 				reason = msg->string_arg;
 			} else {
 				if (!switch_strlen_zero(msg->string_arg)){
-					code = atoi(msg->string_arg);
-					if ((reason = strchr(msg->string_arg, ' '))) {
-						reason++;
+					if ((code = atoi(msg->string_arg))) {
+						if ((reason = strchr(msg->string_arg, ' '))) {
+							reason++;
+						}
 					}
 				}
 			}
@@ -999,7 +1000,14 @@
 				code = 488;
 			}
 
-			if (code == 407) {
+			if (!reason) {
+				reason = sip_status_phrase(code);
+				if (switch_strlen_zero(reason)) {
+					reason = "Because";
+				}
+			}
+			
+			if (code == 407 && !msg->numeric_arg) {
 				const char *to_uri = switch_channel_get_variable(channel, "sip_to_uri");
 				const char *to_host = reason;
 					
@@ -1009,7 +1017,7 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Challenging call %s\n", to_uri);
 				sofia_reg_auth_challange(NULL, tech_pvt->profile, tech_pvt->nh, REG_INVITE, to_host, 0); 
 				switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE);
-			} else if (code == 484) {
+			} else if (code == 484 && msg->numeric_arg) {
 				const char *to = switch_channel_get_variable(channel, "sip_to_uri");
 				const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
 				

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Fri Jan 25 22:56:40 2008
@@ -164,7 +164,8 @@
 	TFLAG_LATE_NEGOTIATION = (1 << 24),
 	TFLAG_SDP = (1 << 25),
 	TFLAG_VIDEO = (1 << 26),
-	TFLAG_TPORT_LOG = (1 << 27)
+	TFLAG_TPORT_LOG = (1 << 27),
+	TFLAG_SENT_UPDATE = (1 << 28)
 } TFLAGS;
 
 struct mod_sofia_globals {

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Fri Jan 25 22:56:40 2008
@@ -1308,12 +1308,17 @@
 		switch_channel_t *channel = switch_core_session_get_channel(session);
 		const char *uuid;
 		switch_core_session_t *other_session;
-		
+
 		if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
-			if (status == 200 && !switch_channel_test_flag(channel, CF_ANSWERED) && !switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
+			private_object_t *tech_pvt = switch_core_session_get_private(session);
+			switch_assert(tech_pvt != NULL);
+
+			if (!switch_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
 				return;
 			}
 
+			switch_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
+
 			if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
 				switch_core_session_message_t msg = { 0 };
 				
@@ -1322,7 +1327,7 @@
 				msg.message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
 				msg.from = __FILE__;
 				msg.numeric_arg = status;
-				msg.string_arg = phrase;
+				msg.string_arg = switch_core_session_strdup(other_session, phrase);
 				switch_core_session_receive_message(other_session, &msg);
 				switch_core_session_rwunlock(other_session);
 			}



More information about the Freeswitch-svn mailing list