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);
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);
}
}