126126#endif
127127
128128#ifdef WOLFSSL_DTLS
129- #ifdef BENCH_EMBEDDED
130- /* WOLFSSL_MAX_MTU in internal.h */
131- #define TEST_DTLS_PACKET_SIZE (1500)
132- #else
133- /* MAX_UDP_SIZE in interna.h */
134- #define TEST_DTLS_PACKET_SIZE (8092)
135- #endif
129+ /* Must fit in one DTLS record: WOLFSSL_MAX_MTU (1400) - MAX_MSG_EXTRA (~102).
130+ * Define WOLFSSL_DTLS_MTU and call wolfSSL_dtls_set_mtu() to use larger
131+ * packets; or build with WOLFSSL_NO_DTLS_SIZE_CHECK to auto-fragment. */
132+ #define TEST_DTLS_PACKET_SIZE (1200)
136133#endif
137134
138135/* In memory transfer buffer maximum size */
@@ -1304,27 +1301,31 @@ static int SetupSocketAndListen(int* listenFd, word32 port, int doDTLS)
13041301 fprintf (stderr , "ERROR: failed to create the socket\n" );
13051302 return -1 ;
13061303 }
1304+ }
13071305
1308- /* allow reuse */
1309- if (setsockopt (* listenFd , SOL_SOCKET , SO_REUSEADDR ,
1310- & optval , sizeof (optval )) == -1 ) {
1311- fprintf (stderr , "setsockopt SO_REUSEADDR failed\n" );
1312- return -1 ;
1313- }
1314-
1315- /* Listen for the client. */
1316- if (bind (* listenFd , (struct sockaddr * )& servAddr ,
1317- sizeof (servAddr )) == -1 ) {
1318- fprintf (stderr , "ERROR: failed to bind\n" );
1319- return -1 ;
1320- }
1306+ /* allow reuse */
1307+ if (setsockopt (* listenFd , SOL_SOCKET , SO_REUSEADDR ,
1308+ & optval , sizeof (optval )) == -1 ) {
1309+ fprintf (stderr , "setsockopt SO_REUSEADDR failed\n" );
1310+ return -1 ;
13211311 }
13221312
1323- if (listen (* listenFd , 5 ) != 0 ) {
1324- fprintf (stderr , "ERROR: failed to listen\n" );
1313+ if (bind (* listenFd , (struct sockaddr * )& servAddr ,
1314+ sizeof (servAddr )) == -1 ) {
1315+ fprintf (stderr , "ERROR: failed to bind\n" );
13251316 return -1 ;
13261317 }
13271318
1319+ #ifdef WOLFSSL_DTLS
1320+ if (!doDTLS )
1321+ #endif
1322+ {
1323+ if (listen (* listenFd , 5 ) != 0 ) {
1324+ fprintf (stderr , "ERROR: failed to listen\n" );
1325+ return -1 ;
1326+ }
1327+ }
1328+
13281329#ifdef BENCH_USE_NONBLOCK
13291330 if (SetSocketNonBlocking (* listenFd ) != 0 ) {
13301331 return -1 ;
@@ -2119,7 +2120,14 @@ int bench_tls(void* args)
21192120 }
21202121 }
21212122#endif
2122- fprintf (stderr , "Running TLS Benchmarks...\n" );
2123+ #ifdef WOLFSSL_DTLS
2124+ if (doDTLS ) {
2125+ fprintf (stderr , "Running DTLS Benchmarks...\n" );
2126+ } else
2127+ #endif
2128+ {
2129+ fprintf (stderr , "Running TLS Benchmarks...\n" );
2130+ }
21232131
21242132 /* parse by : */
21252133 while ((cipher != NULL ) && (cipher [0 ] != '\0' )) {
@@ -2135,6 +2143,14 @@ int bench_tls(void* args)
21352143 fprintf (stderr , "Cipher: %s\n" , cipher );
21362144 }
21372145
2146+ #if defined(WOLFSSL_DTLS ) && !defined(WOLFSSL_DTLS13 )
2147+ if (doDTLS && XSTRNCMP (cipher , "TLS13" , 5 ) == 0 ) {
2148+ /* DTLS 1.3 not compiled in; skip TLS 1.3 ciphers */
2149+ cipher = (next_cipher != NULL ) ? (next_cipher + 1 ) : NULL ;
2150+ continue ;
2151+ }
2152+ #endif
2153+
21382154#if defined(WOLFSSL_TLS13 ) && defined(HAVE_SUPPORTED_CURVES )
21392155 for (group_index = 0 ; groups [group_index ].name != NULL ; group_index ++ ) {
21402156 const char * gname = theadInfo [0 ].group == 0 ? "N/A"
0 commit comments