76
76
77
77
typedef struct {
78
78
ns_list_link_t link ; /**< Link */
79
+ uint16_t pan_id ; /**< PAN ID */
80
+ char network_name [33 ]; /**< Network name */
79
81
kmp_service_t * kmp_service ; /**< KMP service */
80
82
protocol_interface_info_entry_t * interface_ptr ; /**< Interface pointer */
81
83
ws_pae_auth_gtk_hash_set * hash_set ; /**< GTK hash set callback */
82
84
ws_pae_auth_nw_key_insert * nw_key_insert ; /**< Key insert callback */
85
+ ws_pae_auth_nw_keys_remove * nw_keys_remove ; /**< Network keys remove callback */
83
86
ws_pae_auth_nw_key_index_set * nw_key_index_set ; /**< Key index set callback */
84
87
supp_list_t active_supp_list ; /**< List of active supplicants */
85
88
supp_list_t inactive_supp_list ; /**< List of inactive supplicants */
@@ -140,13 +143,17 @@ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr, sec_prot
140
143
return -1 ;
141
144
}
142
145
146
+
147
+ memset (& pae_auth -> network_name , 0 , 33 );
148
+ pae_auth -> pan_id = 0xffff ;
143
149
pae_auth -> interface_ptr = interface_ptr ;
144
150
ws_pae_lib_supp_list_init (& pae_auth -> active_supp_list );
145
151
ws_pae_lib_supp_list_init (& pae_auth -> inactive_supp_list );
146
152
pae_auth -> timer = NULL ;
147
153
148
154
pae_auth -> hash_set = NULL ;
149
155
pae_auth -> nw_key_insert = NULL ;
156
+ pae_auth -> nw_keys_remove = NULL ;
150
157
pae_auth -> nw_key_index_set = NULL ;
151
158
152
159
pae_auth -> gtks = gtks ;
@@ -254,7 +261,7 @@ int8_t ws_pae_auth_delete(protocol_interface_info_entry_t *interface_ptr)
254
261
return 0 ;
255
262
}
256
263
257
- void ws_pae_auth_cb_register (protocol_interface_info_entry_t * interface_ptr , ws_pae_auth_gtk_hash_set * hash_set , ws_pae_auth_nw_key_insert * nw_key_insert , ws_pae_auth_nw_key_index_set * nw_key_index_set )
264
+ void ws_pae_auth_cb_register (protocol_interface_info_entry_t * interface_ptr , ws_pae_auth_gtk_hash_set * hash_set , ws_pae_auth_nw_key_insert * nw_key_insert , ws_pae_auth_nw_key_index_set * nw_key_index_set , ws_pae_auth_nw_keys_remove * nw_keys_remove )
258
265
{
259
266
if (!interface_ptr ) {
260
267
return ;
@@ -268,6 +275,7 @@ void ws_pae_auth_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_
268
275
pae_auth -> hash_set = hash_set ;
269
276
pae_auth -> nw_key_insert = nw_key_insert ;
270
277
pae_auth -> nw_key_index_set = nw_key_index_set ;
278
+ pae_auth -> nw_keys_remove = nw_keys_remove ;
271
279
}
272
280
273
281
void ws_pae_auth_start (protocol_interface_info_entry_t * interface_ptr )
@@ -455,6 +463,48 @@ void ws_pae_auth_forced_gc(protocol_interface_info_entry_t *interface_ptr)
455
463
ws_pae_lib_supp_list_purge (& pae_auth -> active_supp_list , & pae_auth -> inactive_supp_list , 0 , SUPPLICANT_NUMBER_TO_PURGE );
456
464
}
457
465
466
+ int8_t ws_pae_auth_nw_info_set (protocol_interface_info_entry_t * interface_ptr , uint16_t pan_id , char * network_name )
467
+ {
468
+ if (!interface_ptr || !network_name ) {
469
+ return -1 ;
470
+ }
471
+
472
+ pae_auth_t * pae_auth = ws_pae_auth_get (interface_ptr );
473
+ if (!pae_auth ) {
474
+ return -1 ;
475
+ }
476
+
477
+ bool update_keys = false;
478
+ if (pae_auth -> pan_id != 0xffff && pae_auth -> pan_id != pan_id ) {
479
+ update_keys = true;
480
+ }
481
+ pae_auth -> pan_id = pan_id ;
482
+
483
+ if (strlen ((char * ) & pae_auth -> network_name ) > 0 && strcmp ((char * ) & pae_auth -> network_name , network_name ) != 0 ) {
484
+ update_keys = true;
485
+ }
486
+ strcpy ((char * ) & pae_auth -> network_name , network_name );
487
+
488
+ if (!update_keys ) {
489
+ return 0 ;
490
+ }
491
+
492
+ if (pae_auth -> nw_keys_remove ) {
493
+ pae_auth -> nw_keys_remove (pae_auth -> interface_ptr );
494
+ }
495
+
496
+ ws_pae_auth_network_keys_from_gtks_set (pae_auth );
497
+
498
+ int8_t index = sec_prot_keys_gtk_status_active_get (pae_auth -> gtks );
499
+ if (index >= 0 ) {
500
+ // Sets active key index
501
+ ws_pae_auth_network_key_index_set (pae_auth , index );
502
+ }
503
+
504
+ return 0 ;
505
+ }
506
+
507
+
458
508
static int8_t ws_pae_auth_network_keys_from_gtks_set (pae_auth_t * pae_auth )
459
509
{
460
510
// Authenticator keys are always fresh
0 commit comments