@@ -66,7 +66,9 @@ static NS_LIST_DEFINE(socket_list, internal_socket_t, link);
66
66
static uint8_t max_handshakes = MAX_ONGOING_HANDSHAKES ;
67
67
static uint8_t max_sessions = MAX_SECURE_SESSION_COUNT ;
68
68
69
+ #ifdef COAP_SECURITY_AVAILABLE
69
70
static void timer_cb (void * param );
71
+ #endif
70
72
71
73
static void recv_sckt_msg (void * cb_res );
72
74
#ifdef COAP_SECURITY_AVAILABLE
@@ -102,10 +104,13 @@ typedef struct secure_session {
102
104
} secure_session_t ;
103
105
104
106
static NS_LIST_DEFINE (secure_session_list , secure_session_t , link ) ;
107
+
108
+ #ifdef COAP_SECURITY_AVAILABLE
105
109
static int secure_session_sendto (int8_t socket_id , void * handle , const void * buf , size_t len );
106
110
static int secure_session_recvfrom (int8_t socket_id , unsigned char * buf , size_t len );
107
111
static void start_timer (int8_t timer_id , uint32_t int_ms , uint32_t fin_ms );
108
112
static int timer_status (int8_t timer_id );
113
+ #endif //COAP_SECURITY_AVAILABLE
109
114
110
115
static secure_session_t * secure_session_find_by_timer_id (int8_t timer_id )
111
116
{
@@ -119,6 +124,7 @@ static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
119
124
return this ;
120
125
}
121
126
127
+ #ifdef COAP_SECURITY_AVAILABLE
122
128
static bool is_secure_session_valid (secure_session_t * session )
123
129
{
124
130
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)
128
134
}
129
135
return false;
130
136
}
137
+ #endif
131
138
132
139
static void secure_session_delete (secure_session_t * this )
133
140
{
@@ -161,6 +168,7 @@ static int8_t virtual_socket_id_allocate()
161
168
162
169
static secure_session_t * secure_session_create (internal_socket_t * parent , const uint8_t * address_ptr , uint16_t port , SecureConnectionMode secure_mode )
163
170
{
171
+ (void ) secure_mode ;
164
172
uint8_t handshakes = 0 ;
165
173
if (!address_ptr ) {
166
174
return NULL ;
@@ -237,7 +245,9 @@ static void clear_secure_sessions(internal_socket_t *this)
237
245
if (this ) {
238
246
ns_list_foreach_safe (secure_session_t , cur_ptr , & secure_session_list ) {
239
247
if (cur_ptr -> parent == this ) {
248
+ #ifdef COAP_SECURITY_AVAILABLE
240
249
coap_security_send_close_alert (cur_ptr -> sec_handler );
250
+ #endif //COAP_SECURITY_AVAILABLE
241
251
secure_session_delete (cur_ptr );
242
252
}
243
253
}
@@ -430,6 +440,7 @@ static int send_to_real_socket(int8_t socket_id, const ns_address_t *address, co
430
440
return socket_sendmsg (socket_id , & msghdr , 0 );
431
441
}
432
442
443
+ #ifdef COAP_SECURITY_AVAILABLE
433
444
static int secure_session_sendto (int8_t socket_id , void * handle , const void * buf , size_t len )
434
445
{
435
446
secure_session_t * session = handle ;
@@ -462,7 +473,9 @@ static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf
462
473
}
463
474
return len ;
464
475
}
476
+ #endif //COAP_SECURITY_AVAILABLE
465
477
478
+ #ifdef COAP_SECURITY_AVAILABLE
466
479
static int secure_session_recvfrom (int8_t socket_id , unsigned char * buf , size_t len )
467
480
{
468
481
(void )len ;
@@ -477,13 +490,15 @@ static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t
477
490
}
478
491
return MBEDTLS_ERR_SSL_WANT_READ ;
479
492
}
493
+ #endif //COAP_SECURITY_AVAILABLE
480
494
481
495
/**
482
496
* Callback timer. Maybe called in interrupt context
483
497
* so keep it simple.
484
498
* TODO - might be better to use an event timer in conjunction with
485
499
* CoAP tasklet
486
500
*/
501
+ #ifdef COAP_SECURITY_AVAILABLE
487
502
static void timer_cb (void * param )
488
503
{
489
504
secure_session_t * sec = param ;
@@ -515,7 +530,9 @@ static void timer_cb(void *param)
515
530
}
516
531
}
517
532
}
533
+ #endif
518
534
535
+ #ifdef COAP_SECURITY_AVAILABLE
519
536
static void start_timer (int8_t timer_id , uint32_t int_ms , uint32_t fin_ms )
520
537
{
521
538
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)
538
555
}
539
556
}
540
557
}
558
+ #endif //COAP_SECURITY_AVAILABLE
541
559
560
+ #ifdef COAP_SECURITY_AVAILABLE
542
561
static int timer_status (int8_t timer_id )
543
562
{
544
563
secure_session_t * sec = secure_session_find_by_timer_id (timer_id );
@@ -547,6 +566,7 @@ static int timer_status(int8_t timer_id)
547
566
}
548
567
return TIMER_STATE_CANCELLED ;
549
568
}
569
+ #endif //COAP_SECURITY_AVAILABLE
550
570
551
571
static int read_data (socket_callback_t * sckt_data , internal_socket_t * sock , ns_address_t * src_address , uint8_t dst_address [static 16 ])
552
572
{
@@ -872,7 +892,9 @@ void connection_handler_close_secure_connection(coap_conn_handler_t *handler, ui
872
892
if (handler -> socket && handler -> socket -> is_secure ) {
873
893
secure_session_t * session = secure_session_find (handler -> socket , destination_addr_ptr , port );
874
894
if (session ) {
895
+ #ifdef COAP_SECURITY_AVAILABLE
875
896
coap_security_send_close_alert (session -> sec_handler );
897
+ #endif //COAP_SECURITY_AVAILABLE
876
898
session -> session_state = SECURE_SESSION_CLOSED ;
877
899
session -> last_contact_time = coap_service_get_internal_timer_ticks ();
878
900
}
0 commit comments