18
18
typedef enum session_state_e {
19
19
SECURE_SESSION_HANDSHAKE_ONGOING = 0 ,
20
20
SECURE_SESSION_OK ,
21
- SECURE_SESSION_ALERT_SENT
21
+ SECURE_SESSION_CLOSED
22
22
}session_state_t ;
23
23
24
24
typedef struct internal_socket_s {
@@ -67,7 +67,7 @@ typedef struct secure_session {
67
67
secure_timer_t timer ;
68
68
69
69
session_state_t session_state ;
70
- uint32_t session_start_timestamp ;
70
+ uint32_t last_contact_time ;
71
71
ns_list_link_t link ;
72
72
} secure_session_t ;
73
73
@@ -117,8 +117,8 @@ static secure_session_t *secure_session_create(internal_socket_t *parent, uint8_
117
117
// Seek & destroy oldest session where close notify have been sent
118
118
secure_session_t * to_be_removed = NULL ;
119
119
ns_list_foreach (secure_session_t , cur_ptr , & secure_session_list ) {
120
- if (cur_ptr -> session_state == SECURE_SESSION_ALERT_SENT ){
121
- if (!to_be_removed || cur_ptr -> session_start_timestamp < to_be_removed -> session_start_timestamp ){
120
+ if (cur_ptr -> session_state == SECURE_SESSION_CLOSED ){
121
+ if (!to_be_removed || cur_ptr -> last_contact_time < to_be_removed -> last_contact_time ){
122
122
to_be_removed = cur_ptr ;
123
123
}
124
124
}
@@ -444,7 +444,7 @@ static void secure_recv_sckt_msg(void *cb_res)
444
444
tr_err ("secure_recv_sckt_msg session creation failed - OOM" );
445
445
return ;
446
446
}
447
- session -> session_start_timestamp = coap_service_get_internal_timer_ticks ();
447
+ session -> last_contact_time = coap_service_get_internal_timer_ticks ();
448
448
// Start handshake
449
449
if ( !session -> sec_handler -> _is_started ){
450
450
uint8_t * pw = (uint8_t * )ns_dyn_mem_alloc (64 );
@@ -545,7 +545,7 @@ int coap_connection_handler_virtual_recv(coap_conn_handler_t *handler, uint8_t a
545
545
return -1 ;
546
546
}
547
547
548
- session -> session_start_timestamp = coap_service_get_internal_timer_ticks ();
548
+ session -> last_contact_time = coap_service_get_internal_timer_ticks ();
549
549
550
550
if ( !session -> sec_handler -> _is_started ){
551
551
uint8_t * pw = (uint8_t * )ns_dyn_mem_alloc (64 );
@@ -651,8 +651,8 @@ void connection_handler_close_secure_connection( coap_conn_handler_t *handler, u
651
651
secure_session_t * session = secure_session_find ( handler -> socket , destination_addr_ptr , port );
652
652
if ( session ){
653
653
coap_security_send_close_alert ( session -> sec_handler );
654
- session -> session_state = SECURE_SESSION_ALERT_SENT ;
655
- session -> session_start_timestamp = coap_service_get_internal_timer_ticks ();
654
+ session -> session_state = SECURE_SESSION_CLOSED ;
655
+ session -> last_contact_time = coap_service_get_internal_timer_ticks ();
656
656
}
657
657
}
658
658
}
@@ -706,7 +706,7 @@ int coap_connection_handler_send_data(coap_conn_handler_t *handler, ns_address_t
706
706
if ( !session ){
707
707
return -1 ;
708
708
}
709
- session -> session_start_timestamp = coap_service_get_internal_timer_ticks ();
709
+ session -> last_contact_time = coap_service_get_internal_timer_ticks ();
710
710
memcpy ( handler -> socket -> dest_addr .address , dest_addr -> address , 16 );
711
711
handler -> socket -> dest_addr .identifier = dest_addr -> identifier ;
712
712
handler -> socket -> dest_addr .type = dest_addr -> type ;
@@ -731,7 +731,7 @@ int coap_connection_handler_send_data(coap_conn_handler_t *handler, ns_address_t
731
731
}
732
732
}else if ( session -> session_state == SECURE_SESSION_OK ){
733
733
if ( coap_security_handler_send_message (session -> sec_handler , data_ptr , data_len ) > 0 ){
734
- session -> session_start_timestamp = coap_service_get_internal_timer_ticks ();
734
+ session -> last_contact_time = coap_service_get_internal_timer_ticks ();
735
735
return 0 ;
736
736
}
737
737
}
@@ -780,14 +780,14 @@ void coap_connection_handler_exec(uint32_t time)
780
780
if (ns_list_count (& secure_session_list )){
781
781
// Seek & destroy old sessions where close notify have been sent
782
782
ns_list_foreach (secure_session_t , cur_ptr , & secure_session_list ) {
783
- if (cur_ptr -> session_state == SECURE_SESSION_ALERT_SENT ||
783
+ if (cur_ptr -> session_state == SECURE_SESSION_CLOSED ||
784
784
cur_ptr -> session_state == SECURE_SESSION_HANDSHAKE_ONGOING ){
785
- if ((cur_ptr -> session_start_timestamp + CLOSED_SECURE_SESSION_TIMEOUT ) <= time ){
785
+ if ((cur_ptr -> last_contact_time + CLOSED_SECURE_SESSION_TIMEOUT ) <= time ){
786
786
secure_session_delete (cur_ptr );
787
787
}
788
788
}
789
789
if (cur_ptr -> session_state == SECURE_SESSION_OK ){
790
- if ((cur_ptr -> session_start_timestamp + OPEN_SECURE_SESSION_TIMEOUT ) <= time ){
790
+ if ((cur_ptr -> last_contact_time + OPEN_SECURE_SESSION_TIMEOUT ) <= time ){
791
791
secure_session_delete (cur_ptr );
792
792
}
793
793
}
0 commit comments