]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add callee id to events and add global param verbose-channel-events and fsctl verbose...
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 27 Apr 2010 21:52:29 +0000 (16:52 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 27 Apr 2010 21:52:40 +0000 (16:52 -0500)
conf/autoload_configs/switch.conf.xml
src/include/switch_types.h
src/mod/applications/mod_commands/mod_commands.c
src/switch_caller.c
src/switch_channel.c
src/switch_core.c

index ff44243303efe846e1cf17073993ae4f38e7e308..03bc993372c51099a8e6be473473f510b82d7e5c 100644 (file)
@@ -72,6 +72,8 @@
     <param name="mailer-app" value="sendmail"/>
     <param name="mailer-app-args" value="-t"/>
     <param name="dump-cores" value="yes"/>
+    <!-- enable verbose-channel-events to dump every detail about a channel on every event  -->
+    <!--<param name="verbose-channel-events" value="no"/>-->
     <!--RTP port range -->
     <!--<param name="rtp-start-port" value="16384"/>-->
     <!--<param name="rtp-end-port" value="32768"/>-->
index 7e9f6ae42b95f38a5171ee67e0af2cac27a8ac50..a3a9599b62228faf500fc4ef322321e0b9489b45 100644 (file)
@@ -248,7 +248,8 @@ typedef enum {
        SCF_EARLY_HANGUP = (1 << 7),
        SCF_CALIBRATE_CLOCK = (1 << 8),
        SCF_USE_HEAVY_TIMING = (1 << 9),
-       SCF_USE_CLOCK_RT = (1 << 10)
+       SCF_USE_CLOCK_RT = (1 << 10),
+       SCF_VERBOSE_EVENTS = (1 << 11)
 } switch_core_flag_enum_t;
 typedef uint32_t switch_core_flag_t;
 
@@ -1494,7 +1495,8 @@ typedef enum {
        SCSC_CALIBRATE_CLOCK,
        SCSC_SAVE_HISTORY,
        SCSC_CRASH,
-       SCSC_MIN_IDLE_CPU
+       SCSC_MIN_IDLE_CPU,
+       SCSC_VERBOSE_EVENTS
 } switch_session_ctl_t;
 
 typedef enum {
index 6dc2d8c913df946b5f5d967943a76b616c37a994..fa8246d44f29c6066dc7cd861fd4572ca25e41ea 100644 (file)
@@ -1500,6 +1500,16 @@ SWITCH_STANDARD_API(ctl_function)
                } else if (!strcasecmp(argv[0], "crash")) {
                        switch_core_session_ctl(SCSC_CRASH, NULL);
                        stream->write_function(stream, "+OK\n");
+               } else if (!strcasecmp(argv[0], "verbose_events")) {
+                       arg = -1;
+                       if (argv[1]) {
+                               arg = switch_true(argv[1]);
+                       }
+
+                       switch_core_session_ctl(SCSC_VERBOSE_EVENTS, &arg);
+
+                       stream->write_function(stream, "+OK verbose_events is %s \n", arg ? "on" : "off");
+                       
                } else if (!strcasecmp(argv[0], "save_history")) {
                        switch_core_session_ctl(SCSC_SAVE_HISTORY, NULL);
                        stream->write_function(stream, "+OK\n");
index 16c03f71440b74f41d71c7ab9a98320d7cb99e61..b611b09ebda0796be1dab0a2a2f64beadfe90ddb 100644 (file)
@@ -271,6 +271,14 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_
                switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_number);
        }
+       if (!zstr(caller_profile->callee_id_name)) {
+               switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Name", prefix);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_name);
+       }
+       if (!zstr(caller_profile->callee_id_number)) {
+               switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Number", prefix);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_number);
+       }
        if (!zstr(caller_profile->network_addr)) {
                switch_snprintf(header_name, sizeof(header_name), "%s-Network-Addr", prefix);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->network_addr);
index e08bc4f63a4277da92b13b632c4355f4b2caf678..b826da45d5575b1963957509b5b093ae17511197 100644 (file)
@@ -1677,11 +1677,13 @@ SWITCH_DECLARE(void) switch_channel_event_set_basic_data(switch_channel_t *chann
 SWITCH_DECLARE(void) switch_channel_event_set_extended_data(switch_channel_t *channel, switch_event_t *event)
 {
        switch_event_header_t *hi;
-       int x;
+       int x, global_verbos_events = 0;
 
        switch_mutex_lock(channel->profile_mutex);
 
-       if (switch_channel_test_flag(channel, CF_VERBOSE_EVENTS) ||
+       switch_core_session_ctl(SCSC_VERBOSE_EVENTS, &global_verbos_events);
+
+       if (global_verbos_events || switch_channel_test_flag(channel, CF_VERBOSE_EVENTS) ||
                event->event_id == SWITCH_EVENT_CHANNEL_CREATE ||
                event->event_id == SWITCH_EVENT_CHANNEL_ORIGINATE ||
                event->event_id == SWITCH_EVENT_CHANNEL_UUID ||
index 78296ebe7b478d361605cab4edec481fe40c5150..3dfcdb239f120bf5d2fa1db9c4eec87e456564b5 100644 (file)
@@ -1448,6 +1448,13 @@ static void switch_load_core_config(const char *file)
                                        switch_time_set_matrix(switch_true(var));
                                } else if (!strcasecmp(var, "max-sessions") && !zstr(val)) {
                                        switch_core_session_limit(atoi(val));
+                               } else if (!strcasecmp(var, "verbose-channel-events") && !zstr(val)) {
+                                       int v = switch_true(val);
+                                       if (v) {
+                                               switch_set_flag((&runtime), SCF_VERBOSE_EVENTS);
+                                       } else {
+                                               switch_clear_flag((&runtime), SCF_VERBOSE_EVENTS);
+                                       }
                                } else if (!strcasecmp(var, "min-idle-cpu") && !zstr(val)) {
                                        switch_core_min_idle_cpu(atof(val));
                                } else if (!strcasecmp(var, "tipping-point") && !zstr(val)) {
@@ -1639,12 +1646,29 @@ SWITCH_DECLARE(uint32_t) switch_core_debug_level(void)
 SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *val)
 {
        int *intval = (int *) val;
+       int oldintval = 0, newintval = 0;
+       
+       if (intval) {
+               oldintval = *intval;
+       }
 
        if (switch_test_flag((&runtime), SCF_SHUTTING_DOWN)) {
                return -1;
        }
 
        switch (cmd) {
+       case SCSC_VERBOSE_EVENTS:
+               if (intval) {
+                       if (oldintval > -1) {
+                               if (oldintval) {
+                                       switch_set_flag((&runtime), SCF_VERBOSE_EVENTS);
+                               } else {
+                                       switch_clear_flag((&runtime), SCF_VERBOSE_EVENTS);
+                               }
+                       }
+                       newintval = switch_test_flag((&runtime), SCF_VERBOSE_EVENTS);
+               }
+               break;
        case SCSC_CALIBRATE_CLOCK:
                switch_time_calibrate_clock();
                break;
@@ -1656,10 +1680,10 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *
                break;
        case SCSC_SYNC_CLOCK:
                switch_time_sync();
-               *intval = 0;
+               newintval = 0;
                break;
        case SCSC_PAUSE_INBOUND:
-               if (*intval) {
+               if (oldintval) {
                        switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
                } else {
                        switch_clear_flag((&runtime), SCF_NO_NEW_SESSIONS);
@@ -1710,7 +1734,7 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *
                                win_shutdown();
 #endif
 
-                               if (*intval) {
+                               if (oldintval) {
                                        switch_set_flag((&runtime), SCF_RESTART);
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
                                } else {
@@ -1732,7 +1756,7 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *
                win_shutdown();
 #endif
 
-               if (*intval) {
+               if (oldintval) {
                        switch_set_flag((&runtime), SCF_RESTART);
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
                } else {
@@ -1744,62 +1768,69 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *
                runtime.running = 0;
                break;
        case SCSC_CHECK_RUNNING:
-               *intval = runtime.running;
+               newintval = runtime.running;
                break;
        case SCSC_LOGLEVEL:
-               if (*intval > -1) {
-                       runtime.hard_log_level = *intval;
+               if (oldintval > -1) {
+                       runtime.hard_log_level = oldintval;
                }
 
                if (runtime.hard_log_level > SWITCH_LOG_DEBUG) {
                        runtime.hard_log_level = SWITCH_LOG_DEBUG;
                }
-               *intval = runtime.hard_log_level;
+               newintval = runtime.hard_log_level;
                break;
        case SCSC_DEBUG_LEVEL:
-               if (*intval > -1) {
-                       if (*intval > 10)
-                               *intval = 10;
-                       runtime.debug_level = *intval;
+               if (oldintval > -1) {
+                       if (oldintval > 10)
+                               newintval = 10;
+                       runtime.debug_level = oldintval;
                }
-               *intval = runtime.debug_level;
+               newintval = runtime.debug_level;
                break;
        case SCSC_MIN_IDLE_CPU:
                {
                        double *dval = (double *) val;
-                       *dval = switch_core_min_idle_cpu(*dval);
+                       if (dval) {
+                               *dval = switch_core_min_idle_cpu(*dval);
+                       }
+                       intval = NULL;
                }
                break;
        case SCSC_MAX_SESSIONS:
-               *intval = switch_core_session_limit(*intval);
+               newintval = switch_core_session_limit(oldintval);
                break;
        case SCSC_LAST_SPS:
-               *intval = runtime.sps_last;
+               newintval = runtime.sps_last;
                break;
        case SCSC_MAX_DTMF_DURATION:
-               *intval = switch_core_max_dtmf_duration(*intval);
+               newintval = switch_core_max_dtmf_duration(oldintval);
                break;
        case SCSC_MIN_DTMF_DURATION:
-               *intval = switch_core_min_dtmf_duration(*intval);
+               newintval = switch_core_min_dtmf_duration(oldintval);
                break;
        case SCSC_DEFAULT_DTMF_DURATION:
-               *intval = switch_core_default_dtmf_duration(*intval);
+               newintval = switch_core_default_dtmf_duration(oldintval);
                break;
        case SCSC_SPS:
                switch_mutex_lock(runtime.throttle_mutex);
-               if (*intval > 0) {
-                       runtime.sps_total = *intval;
+               if (oldintval > 0) {
+                       runtime.sps_total = oldintval;
                }
-               *intval = runtime.sps_total;
+               newintval = runtime.sps_total;
                switch_mutex_unlock(runtime.throttle_mutex);
                break;
 
        case SCSC_RECLAIM:
                switch_core_memory_reclaim_all();
-               *intval = 0;
+               newintval = 0;
                break;
        }
 
+       if (intval) {
+               *intval = newintval;
+       }
+
 
        return 0;
 }