1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #13502 from aabadie/pr/examples/wolfssl_cleanup

examples/dtls-wolfssl: cleanup output messages
This commit is contained in:
MichelRottleuthner 2020-03-02 11:59:36 +01:00 committed by GitHub
commit 0611920f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 17 deletions

View File

@ -111,20 +111,20 @@ int dtls_client(int argc, char **argv)
else {
gnrc_netif_t *netif = gnrc_netif_get_by_pid(atoi(iface));
if (netif == NULL) {
LOG(LOG_ERROR, "ERROR: interface not valid");
LOG(LOG_ERROR, "ERROR: interface not valid\n");
usage(argv[0]);
return -1;
}
remote.netif = (uint16_t)netif->pid;
}
if (ipv6_addr_from_str((ipv6_addr_t *)remote.addr.ipv6, addr_str) == NULL) {
LOG(LOG_ERROR, "ERROR: unable to parse destination address");
LOG(LOG_ERROR, "ERROR: unable to parse destination address\n");
usage(argv[0]);
return -1;
}
remote.port = SERVER_PORT;
if (sock_dtls_create(sk, &local, &remote, 0, wolfDTLSv1_2_client_method()) != 0) {
LOG(LOG_ERROR, "ERROR: Unable to create DTLS sock");
LOG(LOG_ERROR, "ERROR: Unable to create DTLS sock\n");
return -1;
}
@ -147,7 +147,7 @@ int dtls_client(int argc, char **argv)
if (sock_dtls_session_create(sk) < 0)
return -1;
wolfSSL_dtls_set_timeout_init(sk->ssl, 5);
LOG(LOG_INFO, "connecting to server...");
LOG(LOG_INFO, "connecting to server...\n");
/* attempt to connect until the connection is successful */
do {
ret = wolfSSL_connect(sk->ssl);
@ -179,13 +179,13 @@ int dtls_client(int argc, char **argv)
/* wait for a reply, indefinitely */
do {
ret = wolfSSL_read(sk->ssl, buf, APP_DTLS_BUF_SIZE - 1);
LOG(LOG_INFO, "wolfSSL_read returned %d\r\n", ret);
LOG(LOG_INFO, "wolfSSL_read returned %d\n", ret);
} while (ret <= 0);
buf[ret] = (char)0;
LOG(LOG_INFO, "Received: '%s'\r\n", buf);
LOG(LOG_INFO, "Received: '%s'\n", buf);
/* Clean up and exit. */
LOG(LOG_INFO, "Closing connection.\r\n");
LOG(LOG_INFO, "Closing connection.\n");
sock_dtls_session_destroy(sk);
sock_dtls_close(sk);
return 0;

View File

@ -94,7 +94,7 @@ int dtls_server(int argc, char **argv)
(void)argv;
if (sock_dtls_create(sk, &local, NULL, 0, wolfDTLSv1_2_server_method()) != 0) {
LOG(LOG_ERROR, "ERROR: Unable to create DTLS sock\r\n");
LOG(LOG_ERROR, "ERROR: Unable to create DTLS sock\n");
return -1;
}
@ -103,7 +103,7 @@ int dtls_server(int argc, char **argv)
if (wolfSSL_CTX_use_certificate_buffer(sk->ctx, server_cert,
server_cert_len, SSL_FILETYPE_ASN1 ) != SSL_SUCCESS)
{
LOG(LOG_ERROR, "Failed to load certificate from memory.\r\n");
LOG(LOG_ERROR, "Failed to load certificate from memory.\n");
return -1;
}
@ -111,7 +111,7 @@ int dtls_server(int argc, char **argv)
if (wolfSSL_CTX_use_PrivateKey_buffer(sk->ctx, server_key,
server_key_len, SSL_FILETYPE_ASN1 ) != SSL_SUCCESS)
{
LOG(LOG_ERROR, "Failed to load private key from memory.\r\n");
LOG(LOG_ERROR, "Failed to load private key from memory.\n");
return -1;
}
#else
@ -123,7 +123,7 @@ int dtls_server(int argc, char **argv)
ret = sock_dtls_session_create(sk);
if (ret < 0)
{
LOG(LOG_ERROR, "Failed to create DTLS session (err: %s)\r\n", strerror(-ret));
LOG(LOG_ERROR, "Failed to create DTLS session (err: %s)\n", strerror(-ret));
return -1;
}
@ -141,19 +141,19 @@ int dtls_server(int argc, char **argv)
}
/* Wait until data is received */
LOG(LOG_INFO, "Connection accepted\r\n");
LOG(LOG_INFO, "Connection accepted\n");
ret = wolfSSL_read(sk->ssl, buf, APP_DTLS_BUF_SIZE);
if (ret > 0) {
buf[ret] = (char)0;
LOG(LOG_INFO, "Received '%s'\r\n", buf);
LOG(LOG_INFO, "Received '%s'\n", buf);
}
/* Send reply */
LOG(LOG_INFO, "Sending 'DTLS OK'...\r\n");
LOG(LOG_INFO, "Sending 'DTLS OK'...\n");
wolfSSL_write(sk->ssl, Test_dtls_string, sizeof(Test_dtls_string));
/* Cleanup/shutdown */
LOG(LOG_INFO, "Closing connection.\r\n");
LOG(LOG_INFO, "Closing connection.\n");
sock_dtls_session_destroy(sk);
sock_dtls_close(sk);
break;

View File

@ -62,12 +62,12 @@ int main(void)
/* we need a message queue for the thread running the shell in order to
* receive potentially fast incoming networking packets */
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
LOG(LOG_INFO, "RIOT wolfSSL DTLS testing implementation");
LOG(LOG_INFO, "RIOT wolfSSL DTLS testing implementation\n");
wolfSSL_Init();
wolfSSL_Debugging_ON();
/* start shell */
LOG(LOG_INFO, "All up, running the shell now");
LOG(LOG_INFO, "All up, running the shell now\n");
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);