Merge pull request #6580 from yanrayw/mbedtls-2.28
Backport 2.28: Add build version to the output of ssl_client2 and ssl_server2
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index 30ecf68..5efd147 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -375,6 +375,8 @@
" a second non-empty message before attempting\n" \
" to read a response from the server\n" \
" debug_level=%%d default: 0 (disabled)\n" \
+ " build_version=%%d default: none (disabled)\n" \
+ " option: 1 (print build version only and stop)\n" \
" nbio=%%d default: 0 (blocking I/O)\n" \
" options: 1 (non-blocking), 2 (added delays)\n" \
" event=%%d default: 0 (loop)\n" \
@@ -901,6 +903,16 @@
if( opt.debug_level < 0 || opt.debug_level > 65535 )
goto usage;
}
+ else if( strcmp( p, "build_version" ) == 0 )
+ {
+ if( strcmp( q, "1" ) == 0 )
+ {
+ mbedtls_printf( "build version: %s (build %d)\n",
+ MBEDTLS_VERSION_STRING_FULL,
+ MBEDTLS_VERSION_NUMBER );
+ goto exit;
+ }
+ }
else if( strcmp( p, "context_crt_cb" ) == 0 )
{
opt.context_crt_cb = atoi( q );
@@ -1531,6 +1543,9 @@
}
#endif /* MBEDTLS_SSL_ALPN */
+ mbedtls_printf( "build version: %s (build %d)\n",
+ MBEDTLS_VERSION_STRING_FULL, MBEDTLS_VERSION_NUMBER );
+
/*
* 0. Initialize the RNG and the session data
*/
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index 283216b..1f0ac55 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -466,6 +466,8 @@
" server_addr=%%s default: (all interfaces)\n" \
" server_port=%%d default: 4433\n" \
" debug_level=%%d default: 0 (disabled)\n" \
+ " build_version=%%d default: none (disabled)\n" \
+ " option: 1 (print build version only and stop)\n" \
" buffer_size=%%d default: 200 \n" \
" (minimum: 1, max: 16385)\n" \
" response_size=%%d default: about 152 (basic response)\n" \
@@ -1588,6 +1590,16 @@
if( opt.debug_level < 0 || opt.debug_level > 65535 )
goto usage;
}
+ else if( strcmp( p, "build_version" ) == 0 )
+ {
+ if( strcmp( q, "1" ) == 0 )
+ {
+ mbedtls_printf( "build version: %s (build %d)\n",
+ MBEDTLS_VERSION_STRING_FULL,
+ MBEDTLS_VERSION_NUMBER );
+ goto exit;
+ }
+ }
else if( strcmp( p, "nbio" ) == 0 )
{
opt.nbio = atoi( q );
@@ -2335,6 +2347,9 @@
}
#endif /* MBEDTLS_SSL_ALPN */
+ mbedtls_printf( "build version: %s (build %d)\n",
+ MBEDTLS_VERSION_STRING_FULL, MBEDTLS_VERSION_NUMBER );
+
/*
* 0. Initialize the RNG and the session data
*/
diff --git a/programs/ssl/ssl_test_lib.h b/programs/ssl/ssl_test_lib.h
index e58e2da..e02cf0a 100644
--- a/programs/ssl/ssl_test_lib.h
+++ b/programs/ssl/ssl_test_lib.h
@@ -20,6 +20,8 @@
#ifndef MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H
#define MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H
+#include "mbedtls/version.h"
+
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else