Browse code

tls: added debug log level modparam

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.

Andrei Pelinescu-Onciul authored on 15/08/2010 16:51:38
Showing 5 changed files
... ...
@@ -32,6 +32,7 @@
32 32
 #include "../../compiler_opt.h"
33 33
 #include "../../dprint.h"
34 34
 #include "../../ut.h"
35
+#include "tls_cfg.h"
35 36
 
36 37
 /* 0xf2 should be unused (as of openssl 1.0.0 max.
37 38
    internal defined BIO is 23) */
... ...
@@ -44,10 +45,12 @@
44 45
 #ifdef TLS_BIO_DEBUG
45 46
 	#ifdef __SUNPRO_C
46 47
 		#define TLS_BIO_DBG(...) \
47
-			LOG_(DEFAULT_FACILITY, L_INFO, "tls_BIO: " LOC_INFO,  __VA_ARGS__)
48
+			LOG_(DEFAULT_FACILITY, cfg_get(tls, tls_cfg, debug),\
49
+					"tls_BIO: " LOC_INFO,  __VA_ARGS__)
48 50
 	#else
49 51
 		#define TLS_BIO_DBG(args...) \
50
-			LOG_(DEFAULT_FACILITY, L_INFO, "tls_BIO: " LOC_INFO, ## args)
52
+			LOG_(DEFAULT_FACILITY, cfg_get(tls, tls_cfg, debug),\
53
+					"tls_BIO: " LOC_INFO, ## args)
51 54
 	#endif /* __SUNPRO_c */
52 55
 #else /* TLS_BIO_DEBUG */
53 56
 	#ifdef __SUNPRO_C
... ...
@@ -50,7 +50,8 @@ struct cfg_group_tls default_tls_cfg = {
50 50
 	0, /* session_cache */
51 51
 	STR_STATIC_INIT("sip-router-tls-3.1"), /* session_id */
52 52
 	STR_NULL, /* config_file */
53
-	3, /* log */
53
+	3, /* log  (L_DBG)*/
54
+	3, /* debug (L_DBG) */
54 55
 	600, /* con_lifetime (s)*/
55 56
 	1, /* disable_compression */
56 57
 #if OPENSSL_VERSION_NUMBER >= 0x01000000L
... ...
@@ -164,6 +165,8 @@ cfg_def_t	tls_cfg_def[] = {
164 165
 		"tls config file name (used for the per domain options)" },
165 166
 	{"log", CFG_VAR_INT | CFG_ATOMIC, 0, 1000, 0, 0,
166 167
 		"tls info messages log level" },
168
+	{"debug", CFG_VAR_INT | CFG_ATOMIC, 0, 1000, 0, 0,
169
+		"tls debug messages log level" },
167 170
 	{"connection_timeout", CFG_VAR_INT | CFG_ATOMIC,
168 171
 							-1, MAX_TLS_CON_LIFETIME, fix_con_lt, 0,
169 172
 		"initial connection lifetime (in s) (obsolete)" },
... ...
@@ -54,6 +54,7 @@ struct cfg_group_tls {
54 54
 	str session_id;
55 55
 	str config_file;
56 56
 	int log;
57
+	int debug;
57 58
 	int con_lifetime;
58 59
 	int disable_compression;
59 60
 	/* release internal openssl read or write buffer when they are no longer
... ...
@@ -194,7 +194,8 @@ static param_export_t params[] = {
194 194
 	{"certificate",         PARAM_STR,    &default_tls_cfg.certificate  },
195 195
 	{"cipher_list",         PARAM_STR,    &default_tls_cfg.cipher_list  },
196 196
 	{"connection_timeout",  PARAM_INT,    &default_tls_cfg.con_lifetime },
197
-	{"tls_log",             PARAM_INT,    &default_tls_cfg.log      },
197
+	{"tls_log",             PARAM_INT,    &default_tls_cfg.log          },
198
+	{"tls_debug",           PARAM_INT,    &default_tls_cfg.debug        },
198 199
 	{"session_cache",       PARAM_INT,    &default_tls_cfg.session_cache},
199 200
 	{"session_id",          PARAM_STR,    &default_tls_cfg.session_id   },
200 201
 	{"config",              PARAM_STR,    &default_tls_cfg.config_file  },
... ...
@@ -90,11 +90,13 @@
90 90
 #ifdef TLS_F_DEBUG
91 91
 	#ifdef __SUNPRO_C
92 92
 		#define TLS_F_TRACE(fmt, ...) \
93
-			LOG_(DEFAULT_FACILITY, L_INFO, "TLS_TRACE: " LOC_INFO, " %s" fmt,\
93
+			LOG_(DEFAULT_FACILITY, cfg_get(tls, tls_cfg, debug),\
94
+					"TLS_TRACE: " LOC_INFO, " %s" fmt,\
94 95
 					_FUNC_NAME_,  __VA_ARGS__)
95 96
 	#else
96 97
 		#define TLS_F_TRACE(fmt, args...) \
97
-			LOG_(DEFAULT_FACILITY, L_INFO, "TLS_TRACE: " LOC_INFO, " %s" fmt,\
98
+			LOG_(DEFAULT_FACILITY, cfg_get(tls, tls_cfg, debug),\
99
+					"TLS_TRACE: " LOC_INFO, " %s" fmt,\
98 100
 					_FUNC_NAME_, ## args)
99 101
 	#endif /* __SUNPRO_c */
100 102
 #else /* TLS_F_DEBUG */