forked from wolfSSL/wolfssl
SCTP-DTLS examples
1. Added the set SCTP mode command to client and server. 2. Added a 4K buffer test case.
This commit is contained in:
@ -70,6 +70,10 @@ int main()
|
|||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
err_sys("ctx new dtls client failed");
|
err_sys("ctx new dtls client failed");
|
||||||
|
|
||||||
|
ret = wolfSSL_CTX_dtls_set_sctp(ctx);
|
||||||
|
if (ret != SSL_SUCCESS)
|
||||||
|
err_sys("set sctp mode failed");
|
||||||
|
|
||||||
ret = wolfSSL_CTX_load_verify_locations(ctx, cacert, NULL);
|
ret = wolfSSL_CTX_load_verify_locations(ctx, cacert, NULL);
|
||||||
if (ret != SSL_SUCCESS)
|
if (ret != SSL_SUCCESS)
|
||||||
err_sys("ca cert error");
|
err_sys("ca cert error");
|
||||||
@ -95,6 +99,22 @@ int main()
|
|||||||
printf("server said: %s\n", buffer);
|
printf("server said: %s\n", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char bigBuf[4096];
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < (int)sizeof(bigBuf); i++)
|
||||||
|
bigBuf[i] = (unsigned char)(i & 0xFF);
|
||||||
|
wolfSSL_write(ssl, bigBuf, sizeof(bigBuf));
|
||||||
|
memset(bigBuf, 0, sizeof(bigBuf));
|
||||||
|
|
||||||
|
wolfSSL_read(ssl, bigBuf, sizeof(bigBuf));
|
||||||
|
for (i = 0; i < sizeof(bigBuf); i++) {
|
||||||
|
if (bigBuf[i] != (unsigned char)(i & 0xFF)) {
|
||||||
|
printf("big message check fail\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wolfSSL_shutdown(ssl);
|
wolfSSL_shutdown(ssl);
|
||||||
wolfSSL_free(ssl);
|
wolfSSL_free(ssl);
|
||||||
wolfSSL_CTX_free(ctx);
|
wolfSSL_CTX_free(ctx);
|
||||||
|
@ -76,6 +76,10 @@ int main()
|
|||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
err_sys("ctx new dtls server failed");
|
err_sys("ctx new dtls server failed");
|
||||||
|
|
||||||
|
ret = wolfSSL_CTX_dtls_set_sctp(ctx);
|
||||||
|
if (ret != SSL_SUCCESS)
|
||||||
|
err_sys("set sctp mode failed");
|
||||||
|
|
||||||
ret = wolfSSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM);
|
ret = wolfSSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM);
|
||||||
if (ret != SSL_SUCCESS)
|
if (ret != SSL_SUCCESS)
|
||||||
err_sys("use private key error");
|
err_sys("use private key error");
|
||||||
@ -105,6 +109,11 @@ int main()
|
|||||||
}
|
}
|
||||||
wolfSSL_write(ssl, response, (int)strlen(response));
|
wolfSSL_write(ssl, response, (int)strlen(response));
|
||||||
|
|
||||||
|
unsigned char bigBuf[4096];
|
||||||
|
|
||||||
|
got = wolfSSL_read(ssl, bigBuf, sizeof(bigBuf));
|
||||||
|
wolfSSL_write(ssl, bigBuf, sizeof(bigBuf));
|
||||||
|
|
||||||
wolfSSL_shutdown(ssl);
|
wolfSSL_shutdown(ssl);
|
||||||
wolfSSL_free(ssl);
|
wolfSSL_free(ssl);
|
||||||
wolfSSL_CTX_free(ctx);
|
wolfSSL_CTX_free(ctx);
|
||||||
|
Reference in New Issue
Block a user