@@ -100,6 +100,9 @@ typedef struct announce {
100
100
typedef struct thread_management_server {
101
101
scan_query_t * scan_ptr ;
102
102
announce_t * announce_ptr ;
103
+ timeout_t * join_ent_timer ;
104
+ uint8_t destination_address [16 ];
105
+ uint8_t one_time_key [16 ];
103
106
uint16_t relay_port_joiner ;
104
107
uint16_t external_commissioner_port ;
105
108
int8_t interface_id ;
@@ -994,7 +997,6 @@ static int thread_management_server_energy_scan_cb(int8_t service_id, uint8_t so
994
997
return -1 ;
995
998
}
996
999
997
-
998
1000
static void thread_announce_timeout_cb (void * arg )
999
1001
{
1000
1002
link_configuration_s * linkConfiguration ;
@@ -1132,6 +1134,9 @@ int thread_management_server_init(int8_t interface_id)
1132
1134
this -> relay_port_joiner = 0 ;
1133
1135
this -> scan_ptr = NULL ;
1134
1136
this -> announce_ptr = NULL ;
1137
+ this -> join_ent_timer = NULL ;
1138
+ memset (this -> destination_address ,0 ,16 );
1139
+ memset (this -> one_time_key ,0 ,16 );
1135
1140
this -> external_commissioner_port = THREAD_COMMISSIONING_PORT ;
1136
1141
1137
1142
#ifdef HAVE_THREAD_ROUTER
@@ -1312,6 +1317,19 @@ static int thread_management_server_entrust_send(thread_management_server_t *thi
1312
1317
ns_dyn_mem_free (response_ptr );
1313
1318
return 0 ;
1314
1319
}
1320
+
1321
+ static void thread_join_ent_timeout_cb (void * arg )
1322
+ {
1323
+ thread_management_server_t * this = arg ;
1324
+ if (!this || !this -> join_ent_timer ) {
1325
+ return ;
1326
+ }
1327
+
1328
+ this -> join_ent_timer = NULL ;
1329
+ thread_management_server_entrust_send (this , this -> destination_address , this -> one_time_key );
1330
+ return ;
1331
+ }
1332
+
1315
1333
void joiner_router_recv_commission_msg (void * cb_res )
1316
1334
{
1317
1335
socket_callback_t * sckt_data = 0 ;
@@ -1412,7 +1430,13 @@ static int thread_management_server_relay_tx_cb(int8_t service_id, uint8_t sourc
1412
1430
if (0 < thread_meshcop_tlv_find (request_ptr -> payload_ptr , request_ptr -> payload_len , MESHCOP_TLV_JOINER_ROUTER_KEK , & kek_ptr )) {
1413
1431
// KEK present in relay set pairwise key and send entrust
1414
1432
tr_debug ("Kek received" );
1415
- thread_management_server_entrust_send (this , destination_address .address , kek_ptr );
1433
+ if (this -> join_ent_timer ) {
1434
+ eventOS_timeout_cancel (this -> join_ent_timer );
1435
+ thread_management_server_entrust_send (this , this -> destination_address , this -> one_time_key );
1436
+ }
1437
+ memcpy (this -> destination_address , destination_address .address , 16 );
1438
+ memcpy (this -> one_time_key , kek_ptr , 16 );
1439
+ this -> join_ent_timer = eventOS_timeout_ms (thread_join_ent_timeout_cb , THREAD_DELAY_JOIN_ENT , this );
1416
1440
}
1417
1441
tr_debug ("Relay TX sendto addr:%s port:%d, length:%d" , trace_ipv6 (destination_address .address ), port , udp_data_len );
1418
1442
thci_trace ("joinerrouterJoinerDataRelayedOutbound" );
0 commit comments