summaryrefslogtreecommitdiff
path: root/tests/mini-dtls-large.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-03-28 10:53:26 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-03-28 10:53:26 +0100
commit08f70d6ca83e3a039dbe767752ccf73bc8898fb9 (patch)
treebd2f69c796649fa0f4e5e401c7a5edb0d12771f6 /tests/mini-dtls-large.c
parent3a4c3414fe94270f02b0975f00dd9c4edc9e1f58 (diff)
downloadgnutls-08f70d6ca83e3a039dbe767752ccf73bc8898fb9.tar.gz
Added test for gnutls_record_cork() and uncork usage under DTLS.
Diffstat (limited to 'tests/mini-dtls-large.c')
-rw-r--r--tests/mini-dtls-large.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/tests/mini-dtls-large.c b/tests/mini-dtls-large.c
index 3d4f18604d..9ce749e066 100644
--- a/tests/mini-dtls-large.c
+++ b/tests/mini-dtls-large.c
@@ -70,7 +70,6 @@ static pid_t child;
#define MAX_BUF 24*1024
#define MAX_MTU 20*1024
-
static void client(int fd)
{
gnutls_session_t session;
@@ -129,8 +128,7 @@ static void client(int fd)
do {
ret = gnutls_record_recv(session, buffer, sizeof(buffer));
}
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED
- || ret > 0);
+ while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED || ret > 0);
if (ret < 0) {
fail("recv: %s\n", gnutls_strerror(ret));
@@ -146,7 +144,6 @@ static void client(int fd)
gnutls_global_deinit();
}
-
static void terminate(void)
{
int status;
@@ -207,7 +204,7 @@ static void server(int fd)
/* see the Getting peer's information example */
/* print_info(session); */
-
+
/* avoid uninitialized warnings */
memset(buffer, 1, sizeof(buffer));
@@ -260,6 +257,47 @@ static void server(int fd)
fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
}
+ /* test cork and uncork */
+ gnutls_record_cork(session);
+
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session));
+ if (ret < 0) {
+ terminate();
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ }
+
+ ret = gnutls_record_uncork(session, 0);
+ if (ret < 0) {
+ terminate();
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ }
+
+ gnutls_record_cork(session);
+
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session) - 16);
+ if (ret < 0) {
+ terminate();
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ }
+
+ ret =
+ gnutls_record_send(session, buffer,
+ gnutls_dtls_get_data_mtu(session));
+ if (ret != GNUTLS_E_LARGE_PACKET) {
+ terminate();
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ }
+
+ ret = gnutls_record_uncork(session, GNUTLS_RECORD_WAIT);
+ if (ret < 0) {
+ terminate();
+ fail("send[%d]: %s\n", __LINE__, gnutls_strerror(ret));
+ }
+
/* do not wait for the peer to close the connection.
*/
gnutls_bye(session, GNUTLS_SHUT_WR);