6363 long to wait for previous negotiation to complete */
6464#define EAP_TLS_NEGOTIATION_TRIGGER_TIMEOUT 60 * 10 // 60 seconds
6565
66+ // Default for maximum number of supplicants
67+ #define SUPPLICANT_MAX_NUMBER 1000
68+
69+ /* Default for number of supplicants to purge per garbage collect call from
70+ nanostack monitor */
71+ #define SUPPLICANT_NUMBER_TO_PURGE 5
72+
6673typedef struct {
6774 ns_list_link_t link ; /**< Link */
6875 kmp_service_t * kmp_service ; /**< KMP service */
@@ -77,6 +84,7 @@ typedef struct {
7784 sec_prot_gtk_keys_t * next_gtks ; /**< Next GTKs */
7885 const sec_prot_certs_t * certs ; /**< Certificates */
7986 timer_settings_t * timer_settings ; /**< Timer settings */
87+ uint16_t supp_max_number ; /**< Max number of stored supplicants */
8088 uint16_t slow_timer_seconds ; /**< Slow timer seconds */
8189 bool timer_running : 1 ; /**< Timer is running */
8290 bool gtk_new_inst_req_exp : 1 ; /**< GTK new install required timer expired */
@@ -140,6 +148,8 @@ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr, sec_prot
140148 pae_auth -> next_gtks = next_gtks ;
141149 pae_auth -> certs = certs ;
142150 pae_auth -> timer_settings = timer_settings ;
151+ pae_auth -> supp_max_number = SUPPLICANT_MAX_NUMBER ;
152+
143153 pae_auth -> slow_timer_seconds = 0 ;
144154 pae_auth -> gtk_new_inst_req_exp = false;
145155 pae_auth -> gtk_new_act_time_exp = false;
@@ -407,6 +417,38 @@ int8_t ws_pae_auth_node_access_revoke_start(protocol_interface_info_entry_t *int
407417 return 0 ;
408418}
409419
420+ int8_t ws_pae_auth_node_limit_set (protocol_interface_info_entry_t * interface_ptr , uint16_t limit )
421+ {
422+ if (!interface_ptr ) {
423+ return -1 ;
424+ }
425+
426+ pae_auth_t * pae_auth = ws_pae_auth_get (interface_ptr );
427+ if (!pae_auth ) {
428+ return -1 ;
429+ }
430+
431+ pae_auth -> supp_max_number = limit ;
432+
433+ return 0 ;
434+ }
435+
436+ void ws_pae_auth_forced_gc (protocol_interface_info_entry_t * interface_ptr )
437+ {
438+ if (!interface_ptr ) {
439+ return ;
440+ }
441+
442+ pae_auth_t * pae_auth = ws_pae_auth_get (interface_ptr );
443+ if (!pae_auth ) {
444+ return ;
445+ }
446+
447+ /* Purge in maximum five entries from supplicant list (starting from oldest one)
448+ per call to the function (called by nanostack monitor) */
449+ ws_pae_lib_supp_list_purge (& pae_auth -> active_supp_list , & pae_auth -> inactive_supp_list , 0 , SUPPLICANT_NUMBER_TO_PURGE );
450+ }
451+
410452static int8_t ws_pae_auth_network_keys_from_gtks_set (pae_auth_t * pae_auth )
411453{
412454 // Authenticator keys are always fresh
@@ -758,6 +800,9 @@ static kmp_api_t *ws_pae_auth_kmp_incoming_ind(kmp_service_t *service, kmp_type_
758800
759801 // If does not exists add it to list
760802 if (!supp_entry ) {
803+ // Checks if maximum number of supplicants is reached and purge supplicant list (starting from oldest one)
804+ ws_pae_lib_supp_list_purge (& pae_auth -> active_supp_list , & pae_auth -> inactive_supp_list , pae_auth -> supp_max_number , 0 );
805+
761806 supp_entry = ws_pae_lib_supp_list_add (& pae_auth -> active_supp_list , addr );
762807 if (!supp_entry ) {
763808 return 0 ;
0 commit comments