1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Add a dtls option to test server and client

This commit is contained in:
Manuel Pégourié-Gonnard
2014-02-06 14:02:55 +01:00
committed by Paul Bakker
parent d66645130c
commit e29fd4beaf
2 changed files with 29 additions and 0 deletions

View File

@ -95,6 +95,7 @@ int main( int argc, char *argv[] )
#define DFL_RECO_DELAY 0
#define DFL_TICKETS SSL_SESSION_TICKETS_ENABLED
#define DFL_ALPN_STRING NULL
#define DFL_TRANSPORT SSL_TRANSPORT_STREAM
#define GET_REQUEST "GET %s HTTP/1.0\r\nExtra-header: "
#define GET_REQUEST_END "\r\n\r\n"
@ -132,6 +133,7 @@ struct options
int reco_delay; /* delay in seconds before resuming session */
int tickets; /* enable / disable session tickets */
const char *alpn_string; /* ALPN supported protocols */
int transport; /* TLS or DTLS? */
} opt;
static void my_debug( void *ctx, int level, const char *str )
@ -293,6 +295,7 @@ static int my_verify( void *data, x509_crt *crt, int depth, int *flags )
" request_page=%%s default: \".\"\n" \
" request_size=%%d default: about 34 (basic request)\n" \
" (minimum: 0, max: 16384)\n" \
" dtls=%%d default: 0 (TLS)\n" \
" debug_level=%%d default: 0 (disabled)\n" \
" nbio=%%d default: 0 (blocking I/O)\n" \
" options: 1 (non-blocking), 2 (added delays)\n" \
@ -431,6 +434,16 @@ int main( int argc, char *argv[] )
if( opt.server_port < 1 || opt.server_port > 65535 )
goto usage;
}
else if( strcmp( p, "dtls" ) == 0 )
{
int t = atoi( q );
if( t == 0 )
opt.transport = SSL_TRANSPORT_STREAM;
else if( t == 1 )
opt.transport = SSL_TRANSPORT_DATAGRAM;
else
goto usage;
}
else if( strcmp( p, "debug_level" ) == 0 )
{
opt.debug_level = atoi( q );
@ -863,6 +876,7 @@ int main( int argc, char *argv[] )
#endif
ssl_set_endpoint( &ssl, SSL_IS_CLIENT );
ssl_set_transport( &ssl, opt.transport );
ssl_set_authmode( &ssl, opt.auth_mode );
#if defined(POLARSSL_SSL_MAX_FRAGMENT_LENGTH)