summaryrefslogtreecommitdiffstats
path: root/test/dtlstest.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-09-06 08:30:00 +0200
committerBernd Edlinger <bernd.edlinger@hotmail.de>2017-09-06 08:30:00 +0200
commitfa4b82cc7cc556c03c652d40bd966ef3d4445592 (patch)
treefd5ae2fb6d4fdc2a8661d90d0c5eb31763c51ab7 /test/dtlstest.c
parentFix OSSL_STORE's 'file' loader: make sure peekbuf is initialised (diff)
downloadopenssl-fa4b82cc7cc556c03c652d40bd966ef3d4445592.tar.xz
openssl-fa4b82cc7cc556c03c652d40bd966ef3d4445592.zip
add callback handler for setting DTLS timer interval
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/4011)
Diffstat (limited to 'test/dtlstest.c')
-rw-r--r--test/dtlstest.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/dtlstest.c b/test/dtlstest.c
index 1bf173509e..7e511f7d6f 100644
--- a/test/dtlstest.c
+++ b/test/dtlstest.c
@@ -17,6 +17,7 @@
static char *cert = NULL;
static char *privkey = NULL;
+static unsigned int timer_cb_count;
#define NUM_TESTS 2
@@ -40,6 +41,16 @@ static unsigned char certstatus[] = {
#define RECORD_SEQUENCE 10
+static unsigned int timer_cb(SSL *s, unsigned int timer_us)
+{
+ ++timer_cb_count;
+
+ if (timer_us == 0)
+ return 1000000;
+ else
+ return 2 * timer_us;
+}
+
static int test_dtls_unprocessed(int testidx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
@@ -47,6 +58,8 @@ static int test_dtls_unprocessed(int testidx)
BIO *c_to_s_fbio, *c_to_s_mempacket;
int testresult = 0;
+ timer_cb_count = 0;
+
if (!TEST_true(create_ssl_ctx_pair(DTLS_server_method(),
DTLS_client_method(), &sctx,
&cctx, cert, privkey)))
@@ -64,6 +77,8 @@ static int test_dtls_unprocessed(int testidx)
NULL, c_to_s_fbio)))
goto end;
+ DTLS_set_timer_cb(clientssl1, timer_cb);
+
if (testidx == 1)
certstatus[RECORD_SEQUENCE] = 0xff;
@@ -83,6 +98,11 @@ static int test_dtls_unprocessed(int testidx)
SSL_ERROR_NONE)))
goto end;
+ if (timer_cb_count == 0) {
+ printf("timer_callback was not called.\n");
+ goto end;
+ }
+
testresult = 1;
end:
SSL_free(serverssl1);