forked from wolfSSL/wolfssl
tests: support udp in test_server_nofail()
This commit is contained in:
30
tests/api.c
30
tests/api.c
@ -4518,6 +4518,10 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args)
|
|||||||
int idx;
|
int idx;
|
||||||
int ret, err = 0;
|
int ret, err = 0;
|
||||||
int sharedCtx = 0;
|
int sharedCtx = 0;
|
||||||
|
int doUdp = 0;
|
||||||
|
SOCKADDR_IN_T cliAddr;
|
||||||
|
socklen_t cliLen;
|
||||||
|
|
||||||
#if defined(OPENSSL_ALL) || defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_WPAS)
|
#if defined(OPENSSL_ALL) || defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_WPAS)
|
||||||
size_t msg_len = 0;
|
size_t msg_len = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -4540,6 +4544,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args)
|
|||||||
WOLFSSL_METHOD* method = NULL;
|
WOLFSSL_METHOD* method = NULL;
|
||||||
if (cbf != NULL && cbf->method != NULL) {
|
if (cbf != NULL && cbf->method != NULL) {
|
||||||
method = cbf->method();
|
method = cbf->method();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
method = wolfSSLv23_server_method();
|
method = wolfSSLv23_server_method();
|
||||||
@ -4574,9 +4579,24 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args)
|
|||||||
port = wolfSSLPort;
|
port = wolfSSLPort;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (cbf != NULL)
|
||||||
|
doUdp = cbf->doUdp;
|
||||||
|
|
||||||
/* do it here to detect failure */
|
/* do it here to detect failure */
|
||||||
tcp_accept(&sockfd, &clientfd, opts, port, 0, 0, 0, 0, 1, 0, 0);
|
tcp_accept(
|
||||||
CloseSocket(sockfd);
|
&sockfd, &clientfd, opts, port, 0, doUdp, 0, 0, 1, 0, 0);
|
||||||
|
|
||||||
|
if (doUdp) {
|
||||||
|
cliLen = sizeof(cliAddr);
|
||||||
|
|
||||||
|
idx = (int)recvfrom(sockfd, input, sizeof(input), MSG_PEEK,
|
||||||
|
(struct sockaddr*)&cliAddr, &cliLen);
|
||||||
|
|
||||||
|
AssertIntGT(idx, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CloseSocket(sockfd);
|
||||||
|
}
|
||||||
|
|
||||||
wolfSSL_CTX_set_verify(ctx,
|
wolfSSL_CTX_set_verify(ctx,
|
||||||
WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||||
@ -4623,6 +4643,12 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doUdp) {
|
||||||
|
err = wolfSSL_dtls_set_peer(ssl, &cliAddr, cliLen);
|
||||||
|
if (err != WOLFSSL_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_SESSION_EXPORT
|
#ifdef WOLFSSL_SESSION_EXPORT
|
||||||
/* only add in more complex nonblocking case with session export tests */
|
/* only add in more complex nonblocking case with session export tests */
|
||||||
if (args && opts->argc > 0) {
|
if (args && opts->argc > 0) {
|
||||||
|
@ -515,6 +515,7 @@ typedef struct callback_functions {
|
|||||||
unsigned char isSharedCtx:1;
|
unsigned char isSharedCtx:1;
|
||||||
unsigned char loadToSSL:1;
|
unsigned char loadToSSL:1;
|
||||||
unsigned char ticNoInit:1;
|
unsigned char ticNoInit:1;
|
||||||
|
unsigned char doUdp:1;
|
||||||
} callback_functions;
|
} callback_functions;
|
||||||
|
|
||||||
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
|
Reference in New Issue
Block a user