From 1eb4d491a5d088755b09ad2ce2c783825690d412 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 22 Apr 2006 03:05:25 +0000 Subject: [PATCH] causes part 2 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1226 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_channel.h | 4 ++- .../mod_bridgecall/mod_bridgecall.c | 2 +- .../applications/mod_commands/mod_commands.c | 2 +- .../applications/mod_ivrtest/mod_ivrtest.c | 6 ++-- .../applications/mod_playback/mod_playback.c | 4 +-- .../mod_dialplan_demo/mod_dialplan_demo.c | 4 +-- .../mod_dialplan_directory.c | 2 +- src/mod/dialplans/mod_pcre/mod_pcre.c | 6 ++-- .../endpoints/mod_dingaling/mod_dingaling.c | 24 +++++++------- src/mod/endpoints/mod_exosip/mod_exosip.c | 32 +++++++++---------- src/mod/endpoints/mod_iax/mod_iax.c | 4 +-- src/mod/endpoints/mod_opal/mod_opal.c | 2 +- .../endpoints/mod_portaudio/mod_portaudio.c | 6 ++-- src/mod/endpoints/mod_wanpipe/mod_wanpipe.c | 8 ++--- src/mod/endpoints/mod_woomera/mod_woomera.c | 8 ++--- src/mod/languages/mod_perl/switch_swig.c | 2 +- .../mod_spidermonkey/mod_spidermonkey.c | 4 +-- src/switch_channel.c | 3 +- src/switch_ivr.c | 8 ++--- 19 files changed, 67 insertions(+), 64 deletions(-) diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 23bb912749..e1cd0a85f4 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -273,9 +273,11 @@ SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel *channel); /*! \brief Hangup a channel flagging it's state machine to end \param channel channel to hangup + \param hangup_cause the appropriate hangup cause \return the resulting channel state. */ -SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel); +SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel, switch_call_cause_t hangup_cause); + /*! \brief Test for presence of DTMF on a given channel diff --git a/src/mod/applications/mod_bridgecall/mod_bridgecall.c b/src/mod/applications/mod_bridgecall/mod_bridgecall.c index 7f0ccde07f..0bddb79ea9 100644 --- a/src/mod/applications/mod_bridgecall/mod_bridgecall.c +++ b/src/mod/applications/mod_bridgecall/mod_bridgecall.c @@ -71,7 +71,7 @@ static void audio_bridge_function(switch_core_session *session, char *data) if (switch_core_session_outgoing_channel(session, chan_type, caller_profile, &peer_session, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n"); - switch_channel_hangup(caller_channel); + switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL); return; } else { switch_ivr_multi_threaded_bridge(session, peer_session, timelimit, NULL, NULL, NULL); diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index e35de19a51..3c32bc9e16 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -48,7 +48,7 @@ static switch_status kill_function(char *dest, char *out, size_t outlen) if ((session = switch_core_session_locate(dest))) { switch_channel *channel = switch_core_session_get_channel(session); switch_core_session_kill_channel(session, SWITCH_SIG_KILL); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); snprintf(out, outlen, "OK\n"); } else { snprintf(out, outlen, "No Such Channel!\n"); diff --git a/src/mod/applications/mod_ivrtest/mod_ivrtest.c b/src/mod/applications/mod_ivrtest/mod_ivrtest.c index d1ac8bf14c..9884724c51 100644 --- a/src/mod/applications/mod_ivrtest/mod_ivrtest.c +++ b/src/mod/applications/mod_ivrtest/mod_ivrtest.c @@ -77,7 +77,7 @@ static void dirtest_function(switch_core_session *session, char *data) } switch_core_directory_close(&dh); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); } @@ -152,13 +152,13 @@ static void ivrtest_function(switch_core_session *session, char *data) status = switch_ivr_play_file(session, NULL, data, NULL, on_dtmf, buf, sizeof(buf)); if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); break; } } if (switch_ivr_collect_digits_count(session, buf, sizeof(buf), 10, "#*", &term, 10000, 1) != SWITCH_STATUS_SUCCESS) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); break; } diff --git a/src/mod/applications/mod_playback/mod_playback.c b/src/mod/applications/mod_playback/mod_playback.c index c668b607d6..6a7f3fe028 100644 --- a/src/mod/applications/mod_playback/mod_playback.c +++ b/src/mod/applications/mod_playback/mod_playback.c @@ -67,7 +67,7 @@ static void playback_function(switch_core_session *session, char *data) switch_channel_answer(channel); if (switch_ivr_play_file(session, NULL, file_name, timer_name, on_dtmf, NULL, 0) != SWITCH_STATUS_SUCCESS) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); } } @@ -80,7 +80,7 @@ static void record_function(switch_core_session *session, char *data) assert(channel != NULL); if (switch_ivr_record_file(session, NULL, data, on_dtmf, NULL, 0) != SWITCH_STATUS_SUCCESS) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); } } diff --git a/src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c b/src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c index a891d53cc4..b34bfe516a 100644 --- a/src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c +++ b/src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c @@ -57,7 +57,7 @@ static switch_caller_extension *demo_dialplan_hunt(switch_core_session *session) if (!switch_config_open_file(&cfg, cf)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return NULL; } @@ -95,7 +95,7 @@ static switch_caller_extension *demo_dialplan_hunt(switch_core_session *session) if (extension) { switch_channel_set_state(channel, CS_EXECUTE); } else { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST); } return extension; diff --git a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c index d141f7fbc8..ce2a8a47b1 100644 --- a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c +++ b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c @@ -146,7 +146,7 @@ static switch_caller_extension *directory_dialplan_hunt(switch_core_session *ses if (extension) { switch_channel_set_state(channel, CS_EXECUTE); } else { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST); } return extension; diff --git a/src/mod/dialplans/mod_pcre/mod_pcre.c b/src/mod/dialplans/mod_pcre/mod_pcre.c index a66985d865..c760c51edc 100644 --- a/src/mod/dialplans/mod_pcre/mod_pcre.c +++ b/src/mod/dialplans/mod_pcre/mod_pcre.c @@ -66,7 +66,7 @@ static switch_caller_extension *dialplan_hunt(switch_core_session *session) if (!switch_config_open_file(&cfg, cf)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return NULL; } @@ -107,7 +107,7 @@ static switch_caller_extension *dialplan_hunt(switch_core_session *session) if (error) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "COMPILE ERROR: %d [%s]\n", erroffset, error); cleanre(); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return NULL; } @@ -184,7 +184,7 @@ static switch_caller_extension *dialplan_hunt(switch_core_session *session) if (extension) { switch_channel_set_state(channel, CS_EXECUTE); } else { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST); } cleanre(); diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 341b8b899b..074f7dabeb 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -247,8 +247,8 @@ static int activate_rtp(struct private_object *tech_pvt) SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't load codec?\n"); - switch_channel_hangup(channel); - return 1; + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return -1; } tech_pvt->read_frame.rate = tech_pvt->read_codec.implementation->samples_per_second; tech_pvt->read_frame.codec = &tech_pvt->read_codec; @@ -263,7 +263,7 @@ static int activate_rtp(struct private_object *tech_pvt) SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't load codec?\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return -1; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Write Codec to %s\n", tech_pvt->codec_name); @@ -285,7 +285,7 @@ static int activate_rtp(struct private_object *tech_pvt) NULL, &err, switch_core_session_get_pool(tech_pvt->session)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return -1; } else { uint8_t vad_in = switch_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0; @@ -342,7 +342,7 @@ static int do_candidates(struct private_object *tech_pvt, int force) } else { if (!stun_ip) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER!\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return -1; } @@ -355,7 +355,7 @@ static int do_candidates(struct private_object *tech_pvt, int force) &err, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, err); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return -1; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand[0].address, cand[0].port); @@ -410,7 +410,7 @@ static int do_describe(struct private_object *tech_pvt, int force) if (!tech_pvt->num_codecs) { get_codecs(tech_pvt); if (!tech_pvt->num_codecs) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); switch_set_flag(tech_pvt, TFLAG_BYE); switch_clear_flag(tech_pvt, TFLAG_IO); return -1; @@ -493,7 +493,7 @@ static void *SWITCH_THREAD_FUNC negotiate_thread_run(switch_thread *thread, void } } if (elapsed > 60000) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); switch_set_flag(tech_pvt, TFLAG_BYE); switch_clear_flag(tech_pvt, TFLAG_IO); return NULL; @@ -643,7 +643,7 @@ static switch_status channel_kill_channel(switch_core_session *session, int sig) switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_VOICE); switch_set_flag(tech_pvt, TFLAG_BYE); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); if (tech_pvt->dlsession) { ldl_session_terminate(tech_pvt->dlsession); } @@ -791,7 +791,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra switch_clear_flag(tech_pvt, TFLAG_READING); if (switch_test_flag(tech_pvt, TFLAG_BYE)) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); return SWITCH_STATUS_FALSE; } @@ -824,7 +824,7 @@ static switch_status channel_write_frame(switch_core_session *session, switch_fr if (switch_test_flag(tech_pvt, TFLAG_BYE)) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); return SWITCH_STATUS_FALSE; } @@ -1491,7 +1491,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hungup %s %u %d\n", switch_channel_get_name(channel), state, CS_INIT); switch_set_flag(tech_pvt, TFLAG_BYE); switch_clear_flag(tech_pvt, TFLAG_IO); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); if (state <= CS_INIT && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy unused Session\n"); diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.c b/src/mod/endpoints/mod_exosip/mod_exosip.c index 501ead7ac7..966cc19124 100644 --- a/src/mod/endpoints/mod_exosip/mod_exosip.c +++ b/src/mod/endpoints/mod_exosip/mod_exosip.c @@ -268,7 +268,7 @@ static switch_status exosip_on_init(switch_core_session *session) if (!stun_ip) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } if (switch_stun_lookup(&ip, @@ -278,7 +278,7 @@ static switch_status exosip_on_init(switch_core_session *session) &err, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, err); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success [%s]:[%d]\n", ip, sdp_port); @@ -491,7 +491,7 @@ static switch_status activate_rtp(struct private_object *tech_pvt) if (tech_pvt->realm) { if (!(key = (char *) switch_core_hash_find(globals.srtp_hash, tech_pvt->realm))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "undefined Realm %s\n", tech_pvt->realm); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_set_flag(tech_pvt, TFLAG_BYE); switch_clear_flag(tech_pvt, TFLAG_IO); return SWITCH_STATUS_FALSE; @@ -526,7 +526,7 @@ static switch_status activate_rtp(struct private_object *tech_pvt) } else { switch_channel *channel = switch_core_session_get_channel(tech_pvt->session); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_set_flag(tech_pvt, TFLAG_BYE); switch_clear_flag(tech_pvt, TFLAG_IO); return SWITCH_STATUS_FALSE; @@ -680,7 +680,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram switch_clear_flag(tech_pvt, TFLAG_READING); if (switch_test_flag(tech_pvt, TFLAG_BYE)) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); return SWITCH_STATUS_FALSE; } @@ -713,7 +713,7 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra } if (switch_test_flag(tech_pvt, TFLAG_BYE)) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); return SWITCH_STATUS_FALSE; } @@ -1197,7 +1197,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) char *stun_ip = globals.extrtpip + 5; if (!stun_ip) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } if (switch_stun_lookup(&ip, @@ -1207,7 +1207,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) &err, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, err); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success [%s]:[%d]\n", ip, sdp_port); @@ -1313,7 +1313,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } else { if (switch_core_codec_init(&tech_pvt->write_codec, @@ -1324,7 +1324,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } else { int ms; @@ -1378,7 +1378,7 @@ static void destroy_call_by_event(eXosip_event_t * event) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy %s\n", switch_channel_get_name(channel)); exosip_kill_channel(tech_pvt->session, SWITCH_SIG_KILL); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); } @@ -1443,14 +1443,14 @@ static void handle_answer(eXosip_event_t * event) if (!event->response) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Someone answered... with no SDP information - WTF?!?\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return; } /* Get all of the remote SDP elements... stuff */ if ((remote_sdp = eXosip_get_sdp_info(event->response)) == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant Find SDP?\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return; } @@ -1487,7 +1487,7 @@ static void handle_answer(eXosip_event_t * event) SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return; } else { if (switch_core_codec_init(&tech_pvt->write_codec, @@ -1499,7 +1499,7 @@ static void handle_answer(eXosip_event_t * event) NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return; } else { int ms; @@ -1527,7 +1527,7 @@ static void handle_answer(eXosip_event_t * event) if (activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { exosip_on_hangup(tech_pvt->session); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); return; } diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c index d47b05dea4..828caa4011 100644 --- a/src/mod/endpoints/mod_iax/mod_iax.c +++ b/src/mod/endpoints/mod_iax/mod_iax.c @@ -532,7 +532,7 @@ static switch_status channel_kill_channel(switch_core_session *session, int sig) switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_VOICE); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); //switch_thread_cond_signal(tech_pvt->cond); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel)); @@ -1042,7 +1042,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) if ((channel = switch_core_session_get_channel(tech_pvt->session)) != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel)); switch_set_flag(tech_pvt, TFLAG_HANGUP); - switch_channel_hangup(channel); + switch_channel_hangup(channel, iaxevent->etype == IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING : SWITCH_CAUSE_FACILITY_REJECTED); //switch_thread_cond_signal(tech_pvt->cond); iaxevent->session = NULL; } else { diff --git a/src/mod/endpoints/mod_opal/mod_opal.c b/src/mod/endpoints/mod_opal/mod_opal.c index ea44d0bbc3..50d69a5906 100644 --- a/src/mod/endpoints/mod_opal/mod_opal.c +++ b/src/mod/endpoints/mod_opal/mod_opal.c @@ -157,7 +157,7 @@ static switch_status channel_kill_channel(switch_core_session *session, int sig) tech_pvt = switch_core_session_get_private(session); assert(tech_pvt != NULL); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel)); diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 2b6580bf87..c503122d43 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -233,7 +233,7 @@ static switch_status channel_kill_channel(switch_core_session *session, int sig) switch_clear_flag(tech_pvt, TFLAG_IO); deactivate_audio_device(tech_pvt); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel)); @@ -851,7 +851,7 @@ static switch_status hup_call(char *callid, char *out, size_t outlen) tech_pvt = val; channel = switch_core_session_get_channel(tech_pvt->session); assert(channel != NULL); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); i++; } @@ -865,7 +865,7 @@ static switch_status hup_call(char *callid, char *out, size_t outlen) channel = switch_core_session_get_channel(tech_pvt->session); assert(channel != NULL); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); strncpy(out, "OK", outlen - 1); } else { strncpy(out, "NO SUCH CALL", outlen - 1); diff --git a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c index 7141fcbc9f..53543c5c0a 100644 --- a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c +++ b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c @@ -251,7 +251,7 @@ static switch_status wanpipe_on_init(switch_core_session *session) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ADJUSTED MTU AFTER SETTING IT TO %d is %d %d [%s]\n", new_mtu, mtu_mru, err, strerror(err)); if (mtu_mru != globals.mtu) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure to adjust MTU\n"); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } } @@ -260,7 +260,7 @@ static switch_status wanpipe_on_init(switch_core_session *session) (&tech_pvt->read_codec, "L16", rate, 20, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel)); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } @@ -268,7 +268,7 @@ static switch_status wanpipe_on_init(switch_core_session *session) (&tech_pvt->write_codec, "L16", rate, 20, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel)); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } tech_pvt->read_frame.rate = rate; @@ -1194,7 +1194,7 @@ static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, switch_channel *channel; channel = switch_core_session_get_channel(session); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hanging Up channel %s\n", switch_channel_get_name(channel)); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); } if ((fd = sangoma_open_tdmapi_span_chan(spri->span, event->restart.channel)) < 0) { diff --git a/src/mod/endpoints/mod_woomera/mod_woomera.c b/src/mod/endpoints/mod_woomera/mod_woomera.c index 5aff61ed6b..c543765361 100644 --- a/src/mod/endpoints/mod_woomera/mod_woomera.c +++ b/src/mod/endpoints/mod_woomera/mod_woomera.c @@ -213,7 +213,7 @@ static switch_status woomerachan_on_init(switch_core_session *session) (&tech_pvt->read_codec, "L16", rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel)); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } @@ -221,7 +221,7 @@ static switch_status woomerachan_on_init(switch_core_session *session) (&tech_pvt->write_codec, "L16", rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel)); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } tech_pvt->frame.rate = rate; @@ -328,7 +328,7 @@ static switch_status woomerachan_kill_channel(switch_core_session *session, int udp_socket_close(tech_pvt); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERACHAN KILL\n", switch_channel_get_name(channel)); @@ -1126,7 +1126,7 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n", tech_pvt->profile->name, ip); } - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NETWORK_OUT_OF_ORDER); } } } diff --git a/src/mod/languages/mod_perl/switch_swig.c b/src/mod/languages/mod_perl/switch_swig.c index a08668cb13..c63a961ae7 100644 --- a/src/mod/languages/mod_perl/switch_swig.c +++ b/src/mod/languages/mod_perl/switch_swig.c @@ -84,7 +84,7 @@ void fs_channel_pre_answer(struct switch_core_session *session) void fs_channel_hangup(struct switch_core_session *session) { switch_channel *channel = switch_core_session_get_channel(session); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); } void fs_channel_set_variable(struct switch_core_session *session, char *var, char *val) diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 19cf669629..cada70221a 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -665,7 +665,7 @@ static JSBool session_hangup(JSContext *cx, JSObject *obj, uintN argc, jsval *ar channel = switch_core_session_get_channel(jss->session); assert(channel != NULL); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); switch_core_session_kill_channel(jss->session, SWITCH_SIG_KILL); return JS_TRUE; } @@ -1052,7 +1052,7 @@ static void session_destroy(JSContext *cx, JSObject *obj) if (jss->session) { channel = switch_core_session_get_channel(jss->session); - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); } } } diff --git a/src/switch_channel.c b/src/switch_channel.c index d41b9aed6f..3056d529f6 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -569,7 +569,7 @@ SWITCH_DECLARE(switch_caller_extension *) switch_channel_get_caller_extension(sw } -SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel) +SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel, switch_call_cause_t hangup_cause) { assert(channel != NULL); @@ -579,6 +579,7 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *chann if (channel->state < CS_HANGUP) { channel->state = CS_HANGUP; + channel->hangup_cause = hangup_cause; switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL); switch_core_session_signal_state_change(channel->session); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 7939069f5a..ca78c4cd22 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -180,7 +180,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_record_file(switch_core_session *sessio file, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_GENERR; } @@ -280,7 +280,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session, file, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { - switch_channel_hangup(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_GENERR; } @@ -782,12 +782,12 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj) if (his_thread->running > 0 && switch_channel_test_flag(chan_a, CF_ORIGINATOR)) { if (!switch_channel_test_flag(chan_b, CF_TRANSFER)) { switch_core_session_kill_channel(session_b, SWITCH_SIG_KILL); - switch_channel_hangup(chan_b); + switch_channel_hangup(chan_b, SWITCH_CAUSE_NORMAL_CLEARING); } switch_channel_clear_flag(chan_a, CF_ORIGINATOR); } else if (!switch_channel_test_flag(chan_a, CF_ORIGINATOR) && !switch_channel_test_flag(chan_a, CF_TRANSFER)) { switch_core_session_kill_channel(session_a, SWITCH_SIG_KILL); - switch_channel_hangup(chan_a); + switch_channel_hangup(chan_a, SWITCH_CAUSE_NORMAL_CLEARING); } while (his_thread->running > 0) {