Skip to content

Commit e5a9c70

Browse files
authored
Merge pull request #8889 from holtrop/remove-dtls-from-echo-examples
Remove DTLS from echo examples
2 parents 6f78c26 + feaae9f commit e5a9c70

File tree

4 files changed

+5
-94
lines changed

4 files changed

+5
-94
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ AS_IF([test "$ax_enable_debug" = "yes"],
213213
[AM_CCASFLAGS="$AM_CCASFLAGS -DNDEBUG"])
214214

215215
AC_ARG_ENABLE([debug-code-points],
216-
[ AS_HELP_STRING([--enable-debug-code-points],[Include source file and line number in --enable-verbose messages.]) ],
216+
[ AS_HELP_STRING([--enable-debug-code-points],[Include source file and line number in --enable-debug messages.]) ],
217217
[ ENABLED_DEBUG_CODEPOINTS=$enableval ],
218218
[ ENABLED_DEBUG_CODEPOINTS=no ]
219219
)

examples/echoclient/echoclient.c

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838

3939
#include <wolfssl/ssl.h>
4040

41-
#ifdef WOLFSSL_DTLS
42-
#include <wolfssl/error-ssl.h>
43-
#endif
44-
4541
#if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
4642
#include <stdio.h>
4743
#include <string.h>
@@ -94,7 +90,6 @@ void echoclient_test(void* args)
9490
SSL* ssl = 0;
9591

9692
int ret = 0, err = 0;
97-
int doDTLS = 0;
9893
int doPSK = 0;
9994
int sendSz;
10095
#ifndef WOLFSSL_MDK_SHELL
@@ -123,10 +118,6 @@ void echoclient_test(void* args)
123118
if (!fin) err_sys("can't open input file");
124119
if (!fout) err_sys("can't open output file");
125120

126-
#ifdef WOLFSSL_DTLS
127-
doDTLS = 1;
128-
#endif
129-
130121
#ifdef WOLFSSL_LEANPSK
131122
doPSK = 1;
132123
#endif
@@ -142,13 +133,7 @@ void echoclient_test(void* args)
142133
port = wolfSSLPort;
143134
#endif
144135

145-
#if defined(WOLFSSL_DTLS)
146-
#ifdef WOLFSSL_DTLS13
147-
method = wolfDTLSv1_3_client_method();
148-
#elif !defined(WOLFSSL_NO_TLS12)
149-
method = DTLSv1_2_client_method();
150-
#endif
151-
#elif !defined(NO_TLS)
136+
#if !defined(NO_TLS)
152137
#if defined(WOLFSSL_TLS13) && defined(WOLFSSL_SNIFFER)
153138
method = wolfTLSv1_2_client_method();
154139
#else
@@ -239,13 +224,9 @@ void echoclient_test(void* args)
239224
#endif /* WOLFSSL_ASYNC_CRYPT */
240225

241226
ssl = SSL_new(ctx);
242-
tcp_connect(&sockfd, wolfSSLIP, port, doDTLS, 0, ssl);
227+
tcp_connect(&sockfd, wolfSSLIP, port, 0, 0, ssl);
243228

244229
SSL_set_fd(ssl, sockfd);
245-
#if defined(USE_WINDOWS_API) && defined(WOLFSSL_DTLS) && defined(NO_MAIN_DRIVER)
246-
/* let echoserver bind first, TODO: add Windows signal like pthreads does */
247-
Sleep(100);
248-
#endif
249230

250231
do {
251232
err = 0; /* Reset error */
@@ -324,16 +305,6 @@ void echoclient_test(void* args)
324305
LIBCALL_CHECK_RET(fflush(fout));
325306
sendSz -= ret;
326307
}
327-
#ifdef WOLFSSL_DTLS
328-
else if (wolfSSL_dtls(ssl) &&
329-
err == WC_NO_ERR_TRACE(DECRYPT_ERROR))
330-
{
331-
/* This condition is OK. The packet should be dropped
332-
* silently when there is a decrypt or MAC error on
333-
* a DTLS record. */
334-
sendSz = 0;
335-
}
336-
#endif
337308
else {
338309
fprintf(stderr, "SSL_read msg error %d, %s\n", err,
339310
ERR_error_string((unsigned long)err, buffer));
@@ -342,27 +313,7 @@ void echoclient_test(void* args)
342313
}
343314
}
344315

345-
346-
#ifdef WOLFSSL_DTLS
347-
strncpy(msg, "break", 6);
348-
sendSz = (int)strlen(msg);
349-
/* try to tell server done */
350-
do {
351-
err = 0; /* reset error */
352-
ret = SSL_write(ssl, msg, sendSz);
353-
if (ret <= 0) {
354-
err = SSL_get_error(ssl, 0);
355-
#ifdef WOLFSSL_ASYNC_CRYPT
356-
if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
357-
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
358-
if (ret < 0) break;
359-
}
360-
#endif
361-
}
362-
} while (err == WC_NO_ERR_TRACE(WC_PENDING_E));
363-
#else
364316
SSL_shutdown(ssl);
365-
#endif
366317

367318
SSL_free(ssl);
368319
SSL_CTX_free(ctx);

examples/echoserver/echoserver.c

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args)
9797
WOLFSSL_CTX* ctx = 0;
9898

9999
int ret = 0;
100-
int doDTLS = 0;
101100
int doPSK;
102101
int outCreated = 0;
103102
int shutDown = 0;
@@ -124,10 +123,6 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args)
124123

125124
((func_args*)args)->return_code = -1; /* error state */
126125

127-
#ifdef WOLFSSL_DTLS
128-
doDTLS = 1;
129-
#endif
130-
131126
#if (defined(NO_RSA) && !defined(HAVE_ECC) && !defined(HAVE_ED25519) && \
132127
!defined(HAVE_ED448)) || defined(WOLFSSL_LEANPSK)
133128
doPSK = 1;
@@ -153,15 +148,9 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args)
153148
fdOpenSession(Task_self());
154149
#endif
155150

156-
tcp_listen(&sockfd, &port, useAnyAddr, doDTLS, 0);
151+
tcp_listen(&sockfd, &port, useAnyAddr, 0, 0);
157152

158-
#if defined(WOLFSSL_DTLS)
159-
#ifdef WOLFSSL_DTLS13
160-
method = wolfDTLSv1_3_server_method();
161-
#elif !defined(WOLFSSL_NO_TLS12)
162-
method = wolfDTLSv1_2_server_method();
163-
#endif
164-
#elif !defined(NO_TLS)
153+
#if !defined(NO_TLS)
165154
#if defined(WOLFSSL_TLS13) && defined(WOLFSSL_SNIFFER)
166155
method = wolfTLSv1_2_server_method();
167156
#else
@@ -312,31 +301,13 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args)
312301
int err = 0;
313302
SOCKADDR_IN_T client;
314303
socklen_t client_len = sizeof(client);
315-
#ifndef WOLFSSL_DTLS
316304
clientfd = accept(sockfd, (struct sockaddr*)&client,
317305
(ACCEPT_THIRD_T)&client_len);
318-
#else
319-
clientfd = sockfd;
320-
{
321-
/* For DTLS, peek at the next datagram so we can get the client's
322-
* address and set it into the ssl object later to generate the
323-
* cookie. */
324-
int n;
325-
byte b[1500];
326-
n = (int)recvfrom(clientfd, (char*)b, sizeof(b), MSG_PEEK,
327-
(struct sockaddr*)&client, &client_len);
328-
if (n <= 0)
329-
err_sys("recvfrom failed");
330-
}
331-
#endif
332306
if (WOLFSSL_SOCKET_IS_INVALID(clientfd)) err_sys("tcp accept failed");
333307

334308
ssl = wolfSSL_new(ctx);
335309
if (ssl == NULL) err_sys("SSL_new failed");
336310
wolfSSL_set_fd(ssl, clientfd);
337-
#ifdef WOLFSSL_DTLS
338-
wolfSSL_dtls_set_peer(ssl, &client, client_len);
339-
#endif
340311
#if !defined(NO_FILESYSTEM) && !defined(NO_DH) && !defined(NO_ASN)
341312
wolfSSL_SetTmpDH_file(ssl, dhParamFile, WOLFSSL_FILETYPE_PEM);
342313
#elif !defined(NO_DH)
@@ -492,18 +463,12 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args)
492463
err_sys("SSL_write echo failed");
493464
}
494465
}
495-
#ifndef WOLFSSL_DTLS
496466
wolfSSL_shutdown(ssl);
497-
#endif
498467
#ifdef HAVE_WRITE_DUP
499468
wolfSSL_free(write_ssl);
500469
#endif
501470
wolfSSL_free(ssl);
502471
CloseSocket(clientfd);
503-
#ifdef WOLFSSL_DTLS
504-
tcp_listen(&sockfd, &port, useAnyAddr, doDTLS, 0);
505-
SignalReady(args, port);
506-
#endif
507472
}
508473

509474
CloseSocket(sockfd);

testsuite/testsuite.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,6 @@ static int test_tls(func_args* server_args)
467467
if (echo_args.return_code != 0)
468468
return echo_args.return_code;
469469

470-
#ifdef WOLFSSL_DTLS
471-
/* Ensure server is ready for UDP data. */
472-
wait_tcp_ready(server_args);
473-
#endif
474-
475470
/* Next client connection - send quit to shutdown server. */
476471
echo_args.argc = 2;
477472
XSTRLCPY(arg[1], "quit", sizeof(arg[1]));

0 commit comments

Comments
 (0)