hangup unauth calls with rejected cause

This commit is contained in:
Anthony Minessale 2012-09-14 11:19:36 -05:00
parent dc599db683
commit 6721cd918a
1 changed files with 15 additions and 12 deletions

View File

@ -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++;
}