From 6721cd918a65540b4c3f224be76edaafb44c1906 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 14 Sep 2012 11:19:36 -0500 Subject: [PATCH] hangup unauth calls with rejected cause --- src/mod/endpoints/mod_sofia/sofia.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index f475882e65..40b1a9778b 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1712,7 +1712,7 @@ void sofia_event_callback(nua_event_t event, switch(event) { case nua_i_terminated: - if ((status == 401 || status == 407) && sofia_private && sofia_private->uuid) { + if ((status == 401 || status == 407 || status == 403) && sofia_private && sofia_private->uuid) { switch_core_session_t *session; if ((session = switch_core_session_locate(sofia_private->uuid))) { @@ -1722,19 +1722,22 @@ void sofia_event_callback(nua_event_t event, if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND && !switch_channel_test_flag(channel, CF_ANSWERED)) { private_object_t *tech_pvt = switch_core_session_get_private(session); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "detaching session %s\n", sofia_private->uuid); - - if (!zstr(tech_pvt->call_id)) { - tech_pvt->sofia_private = NULL; - tech_pvt->nh = NULL; - sofia_set_flag(tech_pvt, TFLAG_BYE); - switch_mutex_lock(profile->flag_mutex); - switch_core_hash_insert(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session))); - switch_mutex_unlock(profile->flag_mutex); + if (status == 403) { + switch_channel_hangup(channel, SWITCH_CAUSE_CALL_REJECTED); } else { - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "detaching session %s\n", sofia_private->uuid); + + if (!zstr(tech_pvt->call_id)) { + tech_pvt->sofia_private = NULL; + tech_pvt->nh = NULL; + sofia_set_flag(tech_pvt, TFLAG_BYE); + switch_mutex_lock(profile->flag_mutex); + switch_core_hash_insert(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session))); + switch_mutex_unlock(profile->flag_mutex); + } else { + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + } } - end++; }