diff --git a/Freeswitch.2008.sln b/Freeswitch.2008.sln index 9efe45cf47..9ca0c4121a 100644 --- a/Freeswitch.2008.sln +++ b/Freeswitch.2008.sln @@ -128,6 +128,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles", "sip_profile ProjectSection(SolutionItems) = preProject conf\sip_profiles\default.xml = conf\sip_profiles\default.xml conf\sip_profiles\nat.xml = conf\sip_profiles\nat.xml + conf\sip_profiles\outbound.xml = conf\sip_profiles\outbound.xml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang", "lang", "{09455AA9-C243-4F16-A1A1-A016881A2765}" diff --git a/conf/sip_profiles/default.xml b/conf/sip_profiles/default.xml index c0c57d6be9..743e499c2d 100644 --- a/conf/sip_profiles/default.xml +++ b/conf/sip_profiles/default.xml @@ -16,6 +16,8 @@ + + sip_trace diff --git a/conf/sip_profiles/nat.xml b/conf/sip_profiles/nat.xml index 5a9c3007ee..2dabcc524f 100644 --- a/conf/sip_profiles/nat.xml +++ b/conf/sip_profiles/nat.xml @@ -6,6 +6,7 @@ + diff --git a/conf/sip_profiles/outbound.xml b/conf/sip_profiles/outbound.xml index b1b108a48c..8c8edef5d4 100644 --- a/conf/sip_profiles/outbound.xml +++ b/conf/sip_profiles/outbound.xml @@ -11,6 +11,7 @@ + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.2008.vcproj b/src/mod/endpoints/mod_sofia/mod_sofia.2008.vcproj index dee6763333..3276eacda6 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.2008.vcproj +++ b/src/mod/endpoints/mod_sofia/mod_sofia.2008.vcproj @@ -39,7 +39,7 @@ /> [start|stop|restart|flush_inbound_reg|[register|unregister] [|all]] [reloadxml]\n" "sofia status [[profile | gateway] ]\n" + "sofia loglevel [0-9]\n" "--------------------------------------------------------------------------------\n"; if (session) { @@ -1379,6 +1380,20 @@ SWITCH_STANDARD_API(sofia_function) func = cmd_profile; } else if (!strcasecmp(argv[0], "status")) { func = cmd_status; + } else if (!strcasecmp(argv[0], "loglevel")) { + if (argc > 1 && argv[1]) { + int level; + level = atoi(argv[1]); + if (level >= 0 && level <= 9) { + su_log_set_level(NULL, atoi(argv[1])); + stream->write_function(stream, "Sofia-sip log level set to [%d]", level); + } else { + stream->write_function(stream, "%s", usage_string); + } + } else { + stream->write_function(stream, "%s", usage_string); + } + goto done; } else if (!strcasecmp(argv[0], "help")) { stream->write_function(stream, "%s", usage_string); goto done; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 064840d799..015b040ba0 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -148,7 +148,8 @@ typedef enum { TFLAG_INB_NOMEDIA = (1 << 23), TFLAG_LATE_NEGOTIATION = (1 << 24), TFLAG_SDP = (1 << 25), - TFLAG_VIDEO = (1 << 26) + TFLAG_VIDEO = (1 << 26), + TFLAG_TPORT_LOG = (1 << 27) } TFLAGS; struct mod_sofia_globals { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 2cbc6c60a7..cd4ebd5353 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -36,8 +36,19 @@ #include "mod_sofia.h" #include "sofia-sip/msg_parser.h" #include "sofia-sip/sip_extra.h" +#include "sofia-sip/tport_tag.h" extern su_log_t tport_log[]; +extern su_log_t iptsec_log[]; +extern su_log_t nea_log[]; +extern su_log_t nta_log[]; +extern su_log_t nth_client_log[]; +extern su_log_t nth_server_log[]; +extern su_log_t nua_log[]; +extern su_log_t soa_log[]; +extern su_log_t sresolv_log[]; +extern su_log_t stun_log[]; + static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, char const *phrase, @@ -334,6 +345,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void uint32_t ireg_loops = 0; uint32_t gateway_loops = 0; switch_event_t *s_event; + int tport_log = 0; switch_mutex_lock(mod_sofia_globals.mutex); mod_sofia_globals.threads++; @@ -350,10 +362,14 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void goto end; } + if (switch_test_flag(profile, TFLAG_TPORT_LOG)) { + tport_log = 1; + } + profile->nua = nua_create(profile->s_root, /* Event loop */ sofia_event_callback, /* Callback for processing events */ profile, /* Additional data to pass to callback */ - NUTAG_URL(profile->bindurl), NTATAG_UDP_MTU(65536), TAG_END()); /* Last tag should always finish the sequence */ + NUTAG_URL(profile->bindurl), NTATAG_UDP_MTU(65536), TAG_IF(tport_log,TPTAG_LOG(1)), TAG_END()); /* Last tag should always finish the sequence */ if (!profile->nua) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s\n", profile->name); @@ -755,8 +771,6 @@ switch_status_t config_sofia(int reload, char *profile_name) char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "log-level")) { su_log_set_level(NULL, atoi(val)); - } else if (!strcasecmp(var, "log-level-trace")) { - su_log_set_level(tport_log, atoi(val)); } } } @@ -813,7 +827,8 @@ switch_status_t config_sofia(int reload, char *profile_name) profile->debug = atoi(val); } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) { switch_set_flag(profile, TFLAG_TIMER); - + } else if (!strcasecmp(var, "sip_trace") && switch_true(val)) { + switch_set_flag(profile, TFLAG_TPORT_LOG); } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { #ifdef SWITCH_HAVE_ODBC profile->odbc_dsn = switch_core_strdup(profile->pool, val);