]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add 'sofia global siptrace on' so we don't have to always teach people to enable...
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 20 Sep 2010 21:55:09 +0000 (16:55 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 20 Sep 2010 21:55:09 +0000 (16:55 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_glue.c

index 1e8876e6381157ff5e364ecf8035542fd004d4e8..c5de286696f1a62341bc8ff4707426e7d44df823 100644 (file)
@@ -3507,6 +3507,7 @@ SWITCH_STANDARD_API(sofia_function)
                "sofia status|xmlstatus gateway <name>\n"
                "sofia loglevel <all|default|tport|iptsec|nea|nta|nth_client|nth_server|nua|soa|sresolv|stun> [0-9]\n"
                "sofia tracelevel <console|alert|crit|err|warning|notice|info|debug>\n"
+               "sofa global siptrace [on|off]\n"
                "--------------------------------------------------------------------------------\n";
 
        if (session) {
@@ -3562,6 +3563,26 @@ SWITCH_STANDARD_API(sofia_function)
        } else if (!strcasecmp(argv[0], "help")) {
                stream->write_function(stream, "%s", usage_string);
                goto done;
+       } else if (!strcasecmp(argv[0], "global")) {
+               int on = -1;
+
+               if (argc > 1) {
+                       if (!strcasecmp(argv[1], "siptrace")) {
+                               if (argc > 2) {
+                                       on = switch_true(argv[2]);
+                               }
+                       }
+               }
+
+               if (on != -1) {
+                       sofia_glue_global_siptrace(on);
+                       stream->write_function(stream, "+OK Global siptrace %s", on ? "on" : "off");
+               } else {
+                       stream->write_function(stream, "-ERR Usage: siptrace on|off");
+               }
+               
+               goto done;
+
        } else if (!strcasecmp(argv[0], "recover")) {
                if (argv[1] && !strcasecmp(argv[1], "flush")) {
                        sofia_glue_recover(SWITCH_TRUE);
@@ -4637,6 +4658,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
        switch_console_set_complete("add sofia loglevel ::[all:default:tport:iptsec:nea:nta:nth_client:nth_server:nua:soa:sresolv:stun ::[0:1:2:3:4:5:6:7:8:9");
        switch_console_set_complete("add sofia tracelevel ::[console:alert:crit:err:warning:notice:info:debug");
 
+       switch_console_set_complete("add sofia global siptrace ::[on:off");
+
        switch_console_set_complete("add sofia profile");
        switch_console_set_complete("add sofia profile restart all");
 
index 5a6995806a9ce751effa7fe46ec02cef3893846a..4e0c4fda1ca8df37a64a539eb9b64611380294bf 100644 (file)
@@ -1012,3 +1012,4 @@ char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefi
 void sofia_glue_tech_simplify(private_object_t *tech_pvt);
 switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host);
 switch_bool_t sofia_glue_profile_exists(const char *key);
+void sofia_glue_global_siptrace(switch_bool_t on);
index 4018407961e0201a4a0f5cccaa3d885ca4d16c25..0d3d9d2b60c8fe21eb39647a15f37092c206fa84 100644 (file)
@@ -4342,6 +4342,27 @@ void sofia_glue_restart_all_profiles(void)
 
 }
 
+
+void sofia_glue_global_siptrace(switch_bool_t on)
+{
+       switch_hash_index_t *hi;
+       const void *var;
+       void *val;
+       sofia_profile_t *pptr;
+
+       switch_mutex_lock(mod_sofia_globals.hash_mutex);
+       if (mod_sofia_globals.profile_hash) {
+               for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+                       switch_hash_this(hi, &var, NULL, &val);
+                       if ((pptr = (sofia_profile_t *) val)) {
+                               nua_set_params(pptr->nua, TPTAG_LOG(on), TAG_END());                            
+                       }
+               }
+       }
+       switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+
+}
+
 void sofia_glue_del_profile(sofia_profile_t *profile)
 {
        sofia_gateway_t *gp;