@@ -102,10 +102,13 @@ typedef struct secure_session {
102
102
} secure_session_t ;
103
103
104
104
static NS_LIST_DEFINE (secure_session_list , secure_session_t , link ) ;
105
+
106
+ #ifdef COAP_SECURITY_AVAILABLE
105
107
static int secure_session_sendto (int8_t socket_id , void * handle , const void * buf , size_t len );
106
108
static int secure_session_recvfrom (int8_t socket_id , unsigned char * buf , size_t len );
107
109
static void start_timer (int8_t timer_id , uint32_t int_ms , uint32_t fin_ms );
108
110
static int timer_status (int8_t timer_id );
111
+ #endif //COAP_SECURITY_AVAILABLE
109
112
110
113
static secure_session_t * secure_session_find_by_timer_id (int8_t timer_id )
111
114
{
@@ -237,7 +240,9 @@ static void clear_secure_sessions(internal_socket_t *this)
237
240
if (this ) {
238
241
ns_list_foreach_safe (secure_session_t , cur_ptr , & secure_session_list ) {
239
242
if (cur_ptr -> parent == this ) {
243
+ #ifdef COAP_SECURITY_AVAILABLE
240
244
coap_security_send_close_alert (cur_ptr -> sec_handler );
245
+ #endif //COAP_SECURITY_AVAILABLE
241
246
secure_session_delete (cur_ptr );
242
247
}
243
248
}
@@ -430,6 +435,7 @@ static int send_to_real_socket(int8_t socket_id, const ns_address_t *address, co
430
435
return socket_sendmsg (socket_id , & msghdr , 0 );
431
436
}
432
437
438
+ #ifdef COAP_SECURITY_AVAILABLE
433
439
static int secure_session_sendto (int8_t socket_id , void * handle , const void * buf , size_t len )
434
440
{
435
441
secure_session_t * session = handle ;
@@ -462,7 +468,9 @@ static int secure_session_sendto(int8_t socket_id, void *handle, const void *buf
462
468
}
463
469
return len ;
464
470
}
471
+ #endif //COAP_SECURITY_AVAILABLE
465
472
473
+ #ifdef COAP_SECURITY_AVAILABLE
466
474
static int secure_session_recvfrom (int8_t socket_id , unsigned char * buf , size_t len )
467
475
{
468
476
(void )len ;
@@ -477,6 +485,7 @@ static int secure_session_recvfrom(int8_t socket_id, unsigned char *buf, size_t
477
485
}
478
486
return MBEDTLS_ERR_SSL_WANT_READ ;
479
487
}
488
+ #endif //COAP_SECURITY_AVAILABLE
480
489
481
490
/**
482
491
* Callback timer. Maybe called in interrupt context
@@ -516,6 +525,7 @@ static void timer_cb(void *param)
516
525
}
517
526
}
518
527
528
+ #ifdef COAP_SECURITY_AVAILABLE
519
529
static void start_timer (int8_t timer_id , uint32_t int_ms , uint32_t fin_ms )
520
530
{
521
531
secure_session_t * sec = secure_session_find_by_timer_id (timer_id );
@@ -538,7 +548,9 @@ static void start_timer(int8_t timer_id, uint32_t int_ms, uint32_t fin_ms)
538
548
}
539
549
}
540
550
}
551
+ #endif //COAP_SECURITY_AVAILABLE
541
552
553
+ #ifdef COAP_SECURITY_AVAILABLE
542
554
static int timer_status (int8_t timer_id )
543
555
{
544
556
secure_session_t * sec = secure_session_find_by_timer_id (timer_id );
@@ -547,6 +559,7 @@ static int timer_status(int8_t timer_id)
547
559
}
548
560
return TIMER_STATE_CANCELLED ;
549
561
}
562
+ #endif //COAP_SECURITY_AVAILABLE
550
563
551
564
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
565
{
@@ -872,7 +885,9 @@ void connection_handler_close_secure_connection(coap_conn_handler_t *handler, ui
872
885
if (handler -> socket && handler -> socket -> is_secure ) {
873
886
secure_session_t * session = secure_session_find (handler -> socket , destination_addr_ptr , port );
874
887
if (session ) {
888
+ #ifdef COAP_SECURITY_AVAILABLE
875
889
coap_security_send_close_alert (session -> sec_handler );
890
+ #endif //COAP_SECURITY_AVAILABLE
876
891
session -> session_state = SECURE_SESSION_CLOSED ;
877
892
session -> last_contact_time = coap_service_get_internal_timer_ticks ();
878
893
}
0 commit comments