@@ -66,7 +66,9 @@ static NS_LIST_DEFINE(socket_list, internal_socket_t, link);
6666static uint8_t max_handshakes = MAX_ONGOING_HANDSHAKES ;
6767static uint8_t max_sessions = MAX_SECURE_SESSION_COUNT ;
6868
69+ #ifdef COAP_SECURITY_AVAILABLE
6970static void timer_cb (void * param );
71+ #endif
7072
7173static 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
104106static NS_LIST_DEFINE (secure_session_list , secure_session_t , link ) ;
107+
108+ #ifdef COAP_SECURITY_AVAILABLE
105109static int secure_session_sendto (int8_t socket_id , void * handle , const void * buf , size_t len );
106110static int secure_session_recvfrom (int8_t socket_id , unsigned char * buf , size_t len );
107111static void start_timer (int8_t timer_id , uint32_t int_ms , uint32_t fin_ms );
108112static int timer_status (int8_t timer_id );
113+ #endif //COAP_SECURITY_AVAILABLE
109114
110115static 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
122128static 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
132139static void secure_session_delete (secure_session_t * this )
133140{
@@ -161,6 +168,7 @@ static int8_t virtual_socket_id_allocate()
161168
162169static 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
433444static 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
466479static 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
487502static 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
519536static 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
542561static 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
551571static 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 }
0 commit comments