From a6934776c90a834a321daf7eeb35f2ad7d402c50 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 4 Nov 2022 15:39:30 +0800 Subject: [PATCH] Add reco_debug_level to reduce debug output Signed-off-by: Jerry Yu --- programs/ssl/ssl_server2.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 1b4a94ab0..69e6b81e4 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -490,6 +490,8 @@ int main( void ) " debug_level=%%d default: 0 (disabled)\n" \ " build_version=%%d default: none (disabled)\n" \ " option: 1 (print build version only and stop)\n" \ + " reco_debug_level=%%d default: 0 (disabled)\n" \ + " debug_level for 2nd flight.\n" \ " buffer_size=%%d default: 200 \n" \ " (minimum: 1)\n" \ " response_size=%%d default: about 152 (basic response)\n" \ @@ -592,6 +594,7 @@ struct options const char *server_addr; /* address on which the ssl service runs */ const char *server_port; /* port on which the ssl service runs */ int debug_level; /* level of debugging */ + int reco_debug_level; /* level of 2nd flight debugging */ int nbio; /* should I/O be blocking? */ int event; /* loop or event-driven IO? level or edge triggered? */ uint32_t read_timeout; /* timeout on mbedtls_ssl_read() in milliseconds */ @@ -1629,6 +1632,7 @@ int main( int argc, char *argv[] ) opt.server_addr = DFL_SERVER_ADDR; opt.server_port = DFL_SERVER_PORT; opt.debug_level = DFL_DEBUG_LEVEL; + opt.reco_debug_level = DFL_DEBUG_LEVEL; opt.event = DFL_EVENT; opt.response_size = DFL_RESPONSE_SIZE; opt.nbio = DFL_NBIO; @@ -1755,6 +1759,12 @@ int main( int argc, char *argv[] ) goto exit; } } + else if( strcmp( p, "reco_debug_level" ) == 0 ) + { + opt.reco_debug_level = atoi( q ); + if( opt.reco_debug_level < 0 || opt.reco_debug_level > 65535 ) + goto usage; + } else if( strcmp( p, "nbio" ) == 0 ) { opt.nbio = atoi( q ); @@ -4284,6 +4294,11 @@ close_notify: mbedtls_printf( " done\n" ); +#if defined(MBEDTLS_DEBUG_C) + if( opt.reco_debug_level ) + mbedtls_debug_set_threshold( opt.reco_debug_level ); +#endif + goto reset; /*