tls: added debug log level modparam
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Sun, 15 Aug 2010 16:51:38 +0000 (18:51 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Sun, 15 Aug 2010 16:51:38 +0000 (18:51 +0200)
The log level used for debug messages can now be configured via
the new tls_debug modparam. It can be also changed at runtime
(tls.debug).
Note that for now debug messages will be logged only if tls is
compiled with one of -DTLS_RD_DEBUG, -DTLS_WR_DEBUG or
-DTLS_BIO_DEBUG.

modules/tls/tls_bio.c
modules/tls/tls_cfg.c
modules/tls/tls_cfg.h
modules/tls/tls_mod.c
modules/tls/tls_server.c

index c9b4af0..1013bf7 100644 (file)
@@ -32,6 +32,7 @@
 #include "../../compiler_opt.h"
 #include "../../dprint.h"
 #include "../../ut.h"
+#include "tls_cfg.h"
 
 /* 0xf2 should be unused (as of openssl 1.0.0 max.
    internal defined BIO is 23) */
 #ifdef TLS_BIO_DEBUG
        #ifdef __SUNPRO_C
                #define TLS_BIO_DBG(...) \
-                       LOG_(DEFAULT_FACILITY, L_INFO, "tls_BIO: " LOC_INFO,  __VA_ARGS__)
+                       LOG_(DEFAULT_FACILITY, cfg_get(tls, tls_cfg, debug),\
+                                       "tls_BIO: " LOC_INFO,  __VA_ARGS__)
        #else
                #define TLS_BIO_DBG(args...) \
-                       LOG_(DEFAULT_FACILITY, L_INFO, "tls_BIO: " LOC_INFO, ## args)
+                       LOG_(DEFAULT_FACILITY, cfg_get(tls, tls_cfg, debug),\
+                                       "tls_BIO: " LOC_INFO, ## args)
        #endif /* __SUNPRO_c */
 #else /* TLS_BIO_DEBUG */
        #ifdef __SUNPRO_C
index 88b9b0f..046e202 100644 (file)
@@ -50,7 +50,8 @@ struct cfg_group_tls default_tls_cfg = {
        0, /* session_cache */
        STR_STATIC_INIT("sip-router-tls-3.1"), /* session_id */
        STR_NULL, /* config_file */
-       3, /* log */
+       3, /* log  (L_DBG)*/
+       3, /* debug (L_DBG) */
        600, /* con_lifetime (s)*/
        1, /* disable_compression */
 #if OPENSSL_VERSION_NUMBER >= 0x01000000L
@@ -164,6 +165,8 @@ cfg_def_t   tls_cfg_def[] = {
                "tls config file name (used for the per domain options)" },
        {"log", CFG_VAR_INT | CFG_ATOMIC, 0, 1000, 0, 0,
                "tls info messages log level" },
+       {"debug", CFG_VAR_INT | CFG_ATOMIC, 0, 1000, 0, 0,
+               "tls debug messages log level" },
        {"connection_timeout", CFG_VAR_INT | CFG_ATOMIC,
                                                        -1, MAX_TLS_CON_LIFETIME, fix_con_lt, 0,
                "initial connection lifetime (in s) (obsolete)" },
index eea7292..9ec2570 100644 (file)
@@ -54,6 +54,7 @@ struct cfg_group_tls {
        str session_id;
        str config_file;
        int log;
+       int debug;
        int con_lifetime;
        int disable_compression;
        /* release internal openssl read or write buffer when they are no longer
index 895d18e..19518f8 100644 (file)
@@ -194,7 +194,8 @@ static param_export_t params[] = {
        {"certificate",         PARAM_STR,    &default_tls_cfg.certificate  },
        {"cipher_list",         PARAM_STR,    &default_tls_cfg.cipher_list  },
        {"connection_timeout",  PARAM_INT,    &default_tls_cfg.con_lifetime },
-       {"tls_log",             PARAM_INT,    &default_tls_cfg.log      },
+       {"tls_log",             PARAM_INT,    &default_tls_cfg.log          },
+       {"tls_debug",           PARAM_INT,    &default_tls_cfg.debug        },
        {"session_cache",       PARAM_INT,    &default_tls_cfg.session_cache},
        {"session_id",          PARAM_STR,    &default_tls_cfg.session_id   },
        {"config",              PARAM_STR,    &default_tls_cfg.config_file  },
index 122141e..a910767 100644 (file)
 #ifdef TLS_F_DEBUG
        #ifdef __SUNPRO_C
                #define TLS_F_TRACE(fmt, ...) \
-                       LOG_(DEFAULT_FACILITY, L_INFO, "TLS_TRACE: " LOC_INFO, " %s" fmt,\
+                       LOG_(DEFAULT_FACILITY, cfg_get(tls, tls_cfg, debug),\
+                                       "TLS_TRACE: " LOC_INFO, " %s" fmt,\
                                        _FUNC_NAME_,  __VA_ARGS__)
        #else
                #define TLS_F_TRACE(fmt, args...) \
-                       LOG_(DEFAULT_FACILITY, L_INFO, "TLS_TRACE: " LOC_INFO, " %s" fmt,\
+                       LOG_(DEFAULT_FACILITY, cfg_get(tls, tls_cfg, debug),\
+                                       "TLS_TRACE: " LOC_INFO, " %s" fmt,\
                                        _FUNC_NAME_, ## args)
        #endif /* __SUNPRO_c */
 #else /* TLS_F_DEBUG */