# HG changeset patch # User Sebastien Decugis # Date 1282122789 -32400 # Node ID e5f06199cee78031339e17742a896b11e0466a4e # Parent d4fc98a3b79c55f1fc09b9e5ce058e2d23d15050 New command-line option to enable GNUTLS debugging diff -r d4fc98a3b79c -r e5f06199cee7 freeDiameter/main.c --- a/freeDiameter/main.c Tue Aug 17 16:35:19 2010 +0900 +++ b/freeDiameter/main.c Wed Aug 18 18:13:09 2010 +0900 @@ -179,6 +179,11 @@ return ret; } +/* gnutls debug */ +static void fd_gnutls_debug(int level, const char * str) { + fd_log_debug(" [gnutls:%d] %s", level, str); +} + /* Parse the command-line */ static int main_cmdline(int argc, char *argv[]) { @@ -195,6 +200,7 @@ { "dbglocale", optional_argument, NULL, 'l' }, { "dbg_func", required_argument, NULL, 'f' }, { "dbg_file", required_argument, NULL, 'F' }, + { "dbg_gnutls", required_argument, NULL, 'g' }, { NULL, 0, NULL, 0 } }; @@ -252,6 +258,22 @@ #endif /* DEBUG */ break; + case 'g': /* Full debug for the function with this name. */ + #ifdef DEBUG + { + int l = (int)atoi(optarg); + if (l) { + gnutls_global_set_log_function((gnutls_log_func)fd_gnutls_debug); + gnutls_global_set_log_level (l); + TRACE_DEBUG(INFO, "Enabled GNUTLS debug at level %d", l); + } + } + #else /* DEBUG */ + TRACE_DEBUG(INFO, "Error: must compile with DEBUG support to use this feature"); + return EINVAL; + #endif /* DEBUG */ + break; + case 'q': /* Decrease verbosity then remove debug messages. */ fd_g_debug_lvl--; break;