diff options
| author | jsing <> | 2021-02-06 07:33:27 +0000 |
|---|---|---|
| committer | jsing <> | 2021-02-06 07:33:27 +0000 |
| commit | c35cb6ba121851f99e93e656d387e0bb9d36c7e6 (patch) | |
| tree | 22c69a77a98d917d75e292377622d33f214263e2 /src | |
| parent | d6d50e500ca9581b9fa9970114855f753fe024b0 (diff) | |
| download | openbsd-c35cb6ba121851f99e93e656d387e0bb9d36c7e6.tar.gz openbsd-c35cb6ba121851f99e93e656d387e0bb9d36c7e6.tar.bz2 openbsd-c35cb6ba121851f99e93e656d387e0bb9d36c7e6.zip | |
Test reads and writes between the client and server.
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libssl/dtls/dtlstest.c | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/src/regress/lib/libssl/dtls/dtlstest.c b/src/regress/lib/libssl/dtls/dtlstest.c index ae8075f709..cb83ced4d3 100644 --- a/src/regress/lib/libssl/dtls/dtlstest.c +++ b/src/regress/lib/libssl/dtls/dtlstest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dtlstest.c,v 1.4 2020/10/16 17:57:20 tb Exp $ */ | 1 | /* $OpenBSD: dtlstest.c,v 1.5 2021/02/06 07:33:27 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -284,7 +284,7 @@ static void | |||
| 284 | dtls_info_callback(const SSL *ssl, int type, int val) | 284 | dtls_info_callback(const SSL *ssl, int type, int val) |
| 285 | { | 285 | { |
| 286 | /* | 286 | /* |
| 287 | * Squeal's ahead... remove the bbio from the info callback, so we can | 287 | * Squeals ahead... remove the bbio from the info callback, so we can |
| 288 | * drop specific messages. Ideally this would be an option for the SSL. | 288 | * drop specific messages. Ideally this would be an option for the SSL. |
| 289 | */ | 289 | */ |
| 290 | if (ssl->wbio == ssl->bbio) | 290 | if (ssl->wbio == ssl->bbio) |
| @@ -428,6 +428,38 @@ do_accept(SSL *ssl, const char *name, int *done, short *events) | |||
| 428 | } | 428 | } |
| 429 | 429 | ||
| 430 | static int | 430 | static int |
| 431 | do_read(SSL *ssl, const char *name, int *done, short *events) | ||
| 432 | { | ||
| 433 | uint8_t buf[512]; | ||
| 434 | int ssl_ret; | ||
| 435 | |||
| 436 | if ((ssl_ret = SSL_read(ssl, buf, sizeof(buf))) > 0) { | ||
| 437 | fprintf(stderr, "INFO: %s read done\n", name); | ||
| 438 | if (debug) | ||
| 439 | hexdump(buf, ssl_ret); | ||
| 440 | *done = 1; | ||
| 441 | return 1; | ||
| 442 | } | ||
| 443 | |||
| 444 | return ssl_error(ssl, name, "read", ssl_ret, events); | ||
| 445 | } | ||
| 446 | |||
| 447 | static int | ||
| 448 | do_write(SSL *ssl, const char *name, int *done, short *events) | ||
| 449 | { | ||
| 450 | const uint8_t buf[] = "Hello, World!\n"; | ||
| 451 | int ssl_ret; | ||
| 452 | |||
| 453 | if ((ssl_ret = SSL_write(ssl, buf, sizeof(buf))) > 0) { | ||
| 454 | fprintf(stderr, "INFO: %s write done\n", name); | ||
| 455 | *done = 1; | ||
| 456 | return 1; | ||
| 457 | } | ||
| 458 | |||
| 459 | return ssl_error(ssl, name, "write", ssl_ret, events); | ||
| 460 | } | ||
| 461 | |||
| 462 | static int | ||
| 431 | do_shutdown(SSL *ssl, const char *name, int *done, short *events) | 463 | do_shutdown(SSL *ssl, const char *name, int *done, short *events) |
| 432 | { | 464 | { |
| 433 | int ssl_ret; | 465 | int ssl_ret; |
| @@ -657,7 +689,21 @@ dtlstest(const struct dtls_test *dt) | |||
| 657 | goto failure; | 689 | goto failure; |
| 658 | } | 690 | } |
| 659 | 691 | ||
| 660 | /* XXX - do reads and writes. */ | 692 | pfd[0].events = POLLIN; |
| 693 | pfd[1].events = POLLOUT; | ||
| 694 | |||
| 695 | if (!do_client_server_loop(client, do_read, server, do_write, pfd)) { | ||
| 696 | fprintf(stderr, "FAIL: client read and server write I/O failed\n"); | ||
| 697 | goto failure; | ||
| 698 | } | ||
| 699 | |||
| 700 | pfd[0].events = POLLOUT; | ||
| 701 | pfd[1].events = POLLIN; | ||
| 702 | |||
| 703 | if (!do_client_server_loop(client, do_write, server, do_read, pfd)) { | ||
| 704 | fprintf(stderr, "FAIL: client write and server read I/O failed\n"); | ||
| 705 | goto failure; | ||
| 706 | } | ||
| 661 | 707 | ||
| 662 | pfd[0].events = POLLOUT; | 708 | pfd[0].events = POLLOUT; |
| 663 | pfd[1].events = POLLOUT; | 709 | pfd[1].events = POLLOUT; |
