Skip to content

Commit ae5d042

Browse files
author
Arto Kinnunen
committed
Squashed 'features/nanostack/coap-service/' changes from 5aa54b8..4a126bd
4a126bd Fix compiler and cppcheck warnings (ARMmbed#131) ca7ca7d Merge pull request ARMmbed#130 from PelionIoT/sync_from_mbedos 15d73dc (via Mbed OS)Remove call to function-like macro with no effect git-subtree-dir: features/nanostack/coap-service git-subtree-split: 4a126bd
1 parent 681f511 commit ae5d042

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

features/nanostack/coap-service/source/coap_connection_handler.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ static NS_LIST_DEFINE(socket_list, internal_socket_t, link);
6666
static uint8_t max_handshakes = MAX_ONGOING_HANDSHAKES;
6767
static uint8_t max_sessions = MAX_SECURE_SESSION_COUNT;
6868

69+
#ifdef COAP_SECURITY_AVAILABLE
6970
static void timer_cb(void *param);
71+
#endif
7072

7173
static void recv_sckt_msg(void *cb_res);
7274
#ifdef COAP_SECURITY_AVAILABLE
@@ -102,10 +104,13 @@ typedef struct secure_session {
102104
} secure_session_t;
103105

104106
static NS_LIST_DEFINE(secure_session_list, secure_session_t, link);
107+
108+
#ifdef COAP_SECURITY_AVAILABLE
105109
static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf, size_t len);
106110
static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t len);
107111
static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms);
108112
static int timer_status(int8_t timer_id);
113+
#endif //COAP_SECURITY_AVAILABLE
109114

110115
static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
111116
{
@@ -119,6 +124,7 @@ static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
119124
return this;
120125
}
121126

127+
#ifdef COAP_SECURITY_AVAILABLE
122128
static bool is_secure_session_valid(secure_session_t *session)
123129
{
124130
ns_list_foreach(secure_session_t, cur_ptr, &secure_session_list) {
@@ -128,6 +134,7 @@ static bool is_secure_session_valid(secure_session_t *session)
128134
}
129135
return false;
130136
}
137+
#endif
131138

132139
static void secure_session_delete(secure_session_t *this)
133140
{
@@ -161,6 +168,7 @@ static int8_t virtual_socket_id_allocate()
161168

162169
static secure_session_t *secure_session_create(internal_socket_t *parent, const uint8_t *address_ptr, uint16_t port, SecureConnectionMode secure_mode)
163170
{
171+
(void) secure_mode;
164172
uint8_t handshakes = 0;
165173
if (!address_ptr) {
166174
return NULL;
@@ -237,7 +245,9 @@ static void clear_secure_sessions(internal_socket_t *this)
237245
if (this) {
238246
ns_list_foreach_safe(secure_session_t, cur_ptr, &secure_session_list) {
239247
if (cur_ptr->parent == this) {
248+
#ifdef COAP_SECURITY_AVAILABLE
240249
coap_security_send_close_alert(cur_ptr->sec_handler);
250+
#endif //COAP_SECURITY_AVAILABLE
241251
secure_session_delete(cur_ptr);
242252
}
243253
}
@@ -430,6 +440,7 @@ static int send_to_real_socket(int8_t socket_id, const ns_address_t *address, co
430440
return socket_sendmsg(socket_id, &msghdr, 0);
431441
}
432442

443+
#ifdef COAP_SECURITY_AVAILABLE
433444
static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf, size_t len)
434445
{
435446
secure_session_t *session = handle;
@@ -462,7 +473,9 @@ static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf
462473
}
463474
return len;
464475
}
476+
#endif //COAP_SECURITY_AVAILABLE
465477

478+
#ifdef COAP_SECURITY_AVAILABLE
466479
static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t len)
467480
{
468481
(void)len;
@@ -477,13 +490,15 @@ static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t
477490
}
478491
return MBEDTLS_ERR_SSL_WANT_READ;
479492
}
493+
#endif //COAP_SECURITY_AVAILABLE
480494

481495
/**
482496
* Callback timer. Maybe called in interrupt context
483497
* so keep it simple.
484498
* TODO - might be better to use an event timer in conjunction with
485499
* CoAP tasklet
486500
*/
501+
#ifdef COAP_SECURITY_AVAILABLE
487502
static void timer_cb(void *param)
488503
{
489504
secure_session_t *sec = param;
@@ -515,7 +530,9 @@ static void timer_cb(void *param)
515530
}
516531
}
517532
}
533+
#endif
518534

535+
#ifdef COAP_SECURITY_AVAILABLE
519536
static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms)
520537
{
521538
secure_session_t *sec = secure_session_find_by_timer_id(timer_id);
@@ -538,7 +555,9 @@ static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms)
538555
}
539556
}
540557
}
558+
#endif //COAP_SECURITY_AVAILABLE
541559

560+
#ifdef COAP_SECURITY_AVAILABLE
542561
static int timer_status(int8_t timer_id)
543562
{
544563
secure_session_t *sec = secure_session_find_by_timer_id(timer_id);
@@ -547,6 +566,7 @@ static int timer_status(int8_t timer_id)
547566
}
548567
return TIMER_STATE_CANCELLED;
549568
}
569+
#endif //COAP_SECURITY_AVAILABLE
550570

551571
static int read_data(socket_callback_t *sckt_data, internal_socket_t *sock, ns_address_t *src_address, uint8_t dst_address[static 16])
552572
{
@@ -872,7 +892,9 @@ void connection_handler_close_secure_connection(coap_conn_handler_t *handler, ui
872892
if (handler->socket && handler->socket->is_secure) {
873893
secure_session_t *session = secure_session_find(handler->socket, destination_addr_ptr, port);
874894
if (session) {
895+
#ifdef COAP_SECURITY_AVAILABLE
875896
coap_security_send_close_alert(session->sec_handler);
897+
#endif //COAP_SECURITY_AVAILABLE
876898
session->session_state = SECURE_SESSION_CLOSED;
877899
session->last_contact_time = coap_service_get_internal_timer_ticks();
878900
}

features/nanostack/coap-service/source/include/coap_security_handler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#if !defined(MBEDTLS_CONFIG_FILE)
2424
#include "mbedtls/config.h"
2525
#else
26+
// cppcheck-suppress preprocessorErrorDirective
2627
#include MBEDTLS_CONFIG_FILE
2728
#endif
2829

0 commit comments

Comments
 (0)