]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add reason
authorBrian West <brian@freeswitch.org>
Sat, 2 Feb 2008 00:26:22 +0000 (00:26 +0000)
committerBrian West <brian@freeswitch.org>
Sat, 2 Feb 2008 00:26:22 +0000 (00:26 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7488 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index 0537aa9445d194d139414e9a09ab61db05d8b1ff..96e786909c604179205894483f06d0d71e19ca0d 100644 (file)
@@ -279,8 +279,10 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
 
        if (tech_pvt->nh  && !switch_test_flag(tech_pvt, TFLAG_BYE)) {
                if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
+            char reason[128] = "";
+            switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
-                       nua_bye(tech_pvt->nh, TAG_END());
+                       nua_bye(tech_pvt->nh, SIPTAG_REASON_STR(reason), TAG_END());
                } else {
                        if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
                                switch_call_cause_t causecode = switch_channel_get_cause(channel);
index a54b61f7fb8be0f17f633ff0afe212c3b29d41fa..1b00f1cfc0cf6e6d67a1ddf1887b7585489f736c 100644 (file)
@@ -1783,9 +1783,17 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                if (switch_test_flag(tech_pvt, TFLAG_NOHUP)) {
                                        switch_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
                                } else {
+                    int cause;
+                    if (sip->sip_reason && sip->sip_reason->re_protocol && !strcasecmp(sip->sip_reason->re_protocol, "Q.850") && sip->sip_reason->re_cause) {
+                        cause = atoi(sip->sip_reason->re_cause);
+                    } else {
+                        cause = sofia_glue_sip_cause_to_freeswitch(status);
+                    }
                                        switch_snprintf(st, sizeof(st), "%d", status);
                                        switch_channel_set_variable(channel, "sip_term_status", st);
-                                       switch_channel_hangup(channel, sofia_glue_sip_cause_to_freeswitch(status));
+                                       switch_snprintf(st, sizeof(st), "%d", cause);
+                                       switch_channel_set_variable(channel, "sip_term_cause", st);
+                                       switch_channel_hangup(channel, cause);
                                }
                        }