]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix all the bugs brought on by the guys who made me add t38 no-media passthru
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 26 Jan 2008 03:56:40 +0000 (03:56 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 26 Jan 2008 03:56:40 +0000 (03:56 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7366 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index d603146d7eda4d54349e4877b3f5261d4c727135..81d5968015875c9ebf90892d2af789ba37f56987 100644 (file)
@@ -333,7 +333,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
                                                                                                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 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                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 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                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 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                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);
                                
index b2655568c9afb5e1bb099c9d124e5f0ab08cdc12..35ab30b211b4dba23cb345ba8d3d7310a3f6548e 100644 (file)
@@ -164,7 +164,8 @@ typedef enum {
        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 {
index bc13043fc3a08f08bc1e756de2015543edf2ae87..d42d208cf2e4742c6377239e74027be48ff5222f 100644 (file)
@@ -1308,12 +1308,17 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                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 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                                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);
                        }