]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4353 --resolve this may also fix FS-4079
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Jun 2012 14:32:54 +0000 (09:32 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Jun 2012 14:33:01 +0000 (09:33 -0500)
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h

index 12cab2cf669f5ed9a75ef66fc0e9876fd092b6c8..016bbae2fabe134cb2b6d8c0b5895699ba1e6524 100755 (executable)
@@ -1239,6 +1239,7 @@ SWITCH_STANDARD_APP(respond_function)
        msg.from = __FILE__;
        msg.string_arg = data;
        msg.message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
+       msg.numeric_arg = -1;
        switch_core_session_receive_message(session, &msg);
 }
 
index 35ad2e821f052835d46d1fad895418ee9ad21c9f..594266d885784d8e2aa46a13e32d0c453f1cccd7 100644 (file)
@@ -534,6 +534,18 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
                                }
                        } else {
                                char *resp_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
+                               const char *phrase;
+                               if (tech_pvt->respond_code) {
+                                       sip_cause = tech_pvt->respond_code;
+                               }
+
+                               if (tech_pvt->respond_phrase) {
+                                       phrase = su_strdup(nua_handle_home(tech_pvt->nh), tech_pvt->respond_phrase);
+                               } else {
+                                       phrase = sip_status_phrase(sip_cause);
+                               }
+                               
+
 
                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause);
                                if (!tech_pvt->got_bye) {
@@ -548,7 +560,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
                                                switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL);
                                        }
 
-                                       nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause),
+                                       nua_respond(tech_pvt->nh, sip_cause, phrase,
                                                                TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)),
                                                                TAG_IF(cid, SIPTAG_HEADER_STR(cid)), 
                                                                TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), 
@@ -2356,7 +2368,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                int code = msg->numeric_arg;
                                const char *reason = NULL;
 
-                               if (code) {
+                               if (code > 0) {
                                        reason = msg->string_arg;
                                } else {
                                        if (!zstr(msg->string_arg)) {
@@ -2490,8 +2502,19 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                                                switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER);
                                                        }
                                                } else {
-                                                       nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
-                                                                               TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
+                                                       if (msg->numeric_arg) {
+                                                               if (code > 399) {
+                                                                       tech_pvt->respond_code = code;
+                                                                       tech_pvt->respond_phrase = switch_core_session_strdup(tech_pvt->session, reason);
+                                                                       switch_channel_hangup(tech_pvt->channel, sofia_glue_sip_cause_to_freeswitch(code));
+                                                               } else {
+                                                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot respond.\n");
+                                                               }
+                                                       } else {
+                                                               nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
+                                                                                       TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
+                                                       }
+
                                                }
                                                switch_safe_free(extra_headers);
                                        }
index cc4b08c8224645bbf1bd2c656b4c90d39407131d..79e0bc4285517d4d9f9810e94787f5f2b286da3b 100644 (file)
@@ -836,6 +836,8 @@ struct private_object {
        char *local_sdp_video_zrtp_hash;
        char *remote_sdp_audio_zrtp_hash;
        char *remote_sdp_video_zrtp_hash;
+       char *respond_phrase;
+       int respond_code;
 };
 
 struct callback_t {