From b743d2b6edb419b144c55a280558a4e874707db5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 2 Feb 2008 00:49:25 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7489 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 7 ++++++- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 13 +++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 96e786909c..132207f4cc 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -280,7 +280,12 @@ 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)); + if (cause < 128) { + switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause)); + } else { + switch_snprintf(reason, sizeof(reason), "FreeSWITCH;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, SIPTAG_REASON_STR(reason), TAG_END()); } else { diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 35ab30b211..7fc55b9d65 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -396,6 +396,7 @@ struct private_object { char *video_fmtp_out; uint32_t video_count; sofia_dtmf_t dtmf_type; + int q850_cause; }; struct callback_t { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 1b00f1cfc0..b698f5c73c 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -136,6 +136,15 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, if (!session) return; channel = switch_core_session_get_channel(session); + + + if (sip->sip_reason && sip->sip_reason->re_protocol && + (!strcasecmp(sip->sip_reason->re_protocol, "Q.850") || !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH")) && + sip->sip_reason->re_cause) { + private_object_t *tech_pvt = switch_core_session_get_private(session); + tech_pvt->q850_cause = atoi(sip->sip_reason->re_cause); + } + if (sip->sip_user_agent && !switch_strlen_zero(sip->sip_user_agent->g_string)){ switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string); } @@ -1784,8 +1793,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, 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); + if (tech_pvt->q850_cause) { + cause = tech_pvt->q850_cause; } else { cause = sofia_glue_sip_cause_to_freeswitch(status); }