]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
causes part 2
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 22 Apr 2006 03:05:25 +0000 (03:05 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 22 Apr 2006 03:05:25 +0000 (03:05 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1226 d0543943-73ff-0310-b7d9-9358b9ac24b2

19 files changed:
src/include/switch_channel.h
src/mod/applications/mod_bridgecall/mod_bridgecall.c
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_ivrtest/mod_ivrtest.c
src/mod/applications/mod_playback/mod_playback.c
src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c
src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
src/mod/dialplans/mod_pcre/mod_pcre.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_exosip/mod_exosip.c
src/mod/endpoints/mod_iax/mod_iax.c
src/mod/endpoints/mod_opal/mod_opal.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
src/mod/endpoints/mod_woomera/mod_woomera.c
src/mod/languages/mod_perl/switch_swig.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
src/switch_channel.c
src/switch_ivr.c

index 23bb912749b8c471b5cc4ab2a0bf21b05232f62f..e1cd0a85f48a38eb3ba8c976f26bc7be9b5b1f84 100644 (file)
@@ -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
index 7f0ccde07fd3746b365a5fe3e6ba76eed374f6af..0bddb79ea96fdd7a17d410f1c38e71a5bdc0c61b 100644 (file)
@@ -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);
index e35de19a51f70aa09ae166b4e32b49abe09b79de..3c32bc9e1638c30d45dd0915f35a1d94902a31a8 100644 (file)
@@ -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");
index d1ac8bf14cd84c9e7c9d6577697eefef49ab01a7..9884724c510c3b85338f247252bdcb49cfe79421 100644 (file)
@@ -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;
                }
 
index c668b607d69902848154586a1304c49fe9bd9482..6a7f3fe028366e89dee21a88f531a2d71901c765 100644 (file)
@@ -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);
        }
        
 }
index a891d53cc448962da5e9c0285c14bb9f9325a31d..b34bfe516a3440b94f59cd872639f6ec1b3cc8ea 100644 (file)
@@ -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;
index d141f7fbc8f9e9c07ab86dde63db1f44b04d963b..ce2a8a47b1abfb17f9aa2cfa15a5854f0daf915d 100644 (file)
@@ -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;
index a66985d8657d6bb066db535f515d0faa0c6faa22..c760c51edc0df2b666b1b359c5430dee050c6845 100644 (file)
@@ -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();
index 341b8b899bf8e273c69dc18acbe8607b573f5172..074f7dabeb1b24c0ebb07547dbeaba8560993a28 100644 (file)
@@ -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");
index 501ead7ac773262d4b4e895865219d299ec0fc4a..966cc19124951e030166f4ba7950b15336a976ae 100644 (file)
@@ -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;
        }
 
index d47b05dea47ad9329cd06918855223dbd2b30dc2..828caa40113e8ba2ca81b0e0b496619af366dd76 100644 (file)
@@ -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 {
index ea44d0bbc3960f19d7a0ae458cc1665ed008b661..50d69a5906142c3ac5819c21fcec7d7dc8a22532 100644 (file)
@@ -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));
 
 
index 2b6580bf87f2017f74bfa83e8e707e78c035406a..c503122d43859e15840ab22a0181dd10f47b4360 100644 (file)
@@ -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);
index 7141fcbc9f7c6605eaa43920a0f428a5da6f7b96..53543c5c0a78311438b585c94fb06e2d2205dff2 100644 (file)
@@ -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) {
index 5aff61ed6b63be13311fe2f1ff62b7f32590367a..c54376536116b0037169469cee90bfa61474aac1 100644 (file)
@@ -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);
                                        }
                                }
                        }
index a08668cb134c43e6894b38804b0363e7b97fbd8e..c63a961ae72674bf4ebe65fa39ce28f25375b4c5 100644 (file)
@@ -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)
index 19cf6696291232e378a5ff20ae599f9141165c86..cada70221adf9e04badac30f225066829f9daaa6 100644 (file)
@@ -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);
                                }
                        }
                }
index d41b9aed6f1573592809aafe55d5cfba2f290e4a..3056d529f6fd5561886f12a42a6cf39093eeb536 100644 (file)
@@ -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);
        }
index 7939069f5a881ba62f4de30d59fe19784aa5d2e1..ca78c4cd227f48d1332c2e9ea5a5602a0753d031 100644 (file)
@@ -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) {