Skip to content

Commit 684b714

Browse files
author
Mika Leppänen
authored
Added support for retries and multiple sockets to RADIUS client (ARMmbed#2426)
* Added support for retries and multiple sockets to RADIUS client - RADIUS EAP-TLS and client now supports retries - RADIUS client now allocates message identifiers from a poll - Message identifiers on the poll are freed for re-use based in timer - If message identifier space runs out (255) a new socket is created - Maximum number of sockets is 3 - Added shared component support to security protocols to allow creation of message identifier pools - Improved peer message deletion by adding peer delete callback to security protocols
1 parent 89e0ae0 commit 684b714

File tree

11 files changed

+788
-113
lines changed

11 files changed

+788
-113
lines changed

source/6LoWPAN/ws/ws_pae_auth.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ typedef struct {
9494
ws_pae_auth_nw_info_updated *nw_info_updated; /**< Security keys network info updated callback */
9595
ws_pae_auth_ip_addr_get *ip_addr_get; /**< IP address get callback */
9696
supp_list_t active_supp_list; /**< List of active supplicants */
97+
shared_comp_list_t shared_comp_list; /**< Shared component list */
9798
arm_event_storage_t *timer; /**< Timer */
9899
sec_prot_gtk_keys_t *next_gtks; /**< Next GTKs */
99100
const sec_prot_certs_t *certs; /**< Certificates */
@@ -121,6 +122,8 @@ static int8_t ws_pae_auth_timer_if_start(kmp_service_t *service, kmp_api_t *kmp)
121122
static int8_t ws_pae_auth_timer_if_stop(kmp_service_t *service, kmp_api_t *kmp);
122123
static int8_t ws_pae_auth_timer_start(pae_auth_t *pae_auth);
123124
static int8_t ws_pae_auth_timer_stop(pae_auth_t *pae_auth);
125+
static int8_t ws_pae_auth_shared_comp_add(kmp_service_t *service, kmp_shared_comp_t *data);
126+
static int8_t ws_pae_auth_shared_comp_remove(kmp_service_t *service, kmp_shared_comp_t *data);
124127
static bool ws_pae_auth_timer_running(pae_auth_t *pae_auth);
125128
static void ws_pae_auth_kmp_service_addr_get(kmp_service_t *service, kmp_api_t *kmp, kmp_addr_t *local_addr, kmp_addr_t *remote_addr);
126129
static void ws_pae_auth_kmp_service_ip_addr_get(kmp_service_t *service, kmp_api_t *kmp, uint8_t *address);
@@ -156,6 +159,7 @@ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr, sec_prot
156159
pae_auth->pan_id = 0xffff;
157160
pae_auth->interface_ptr = interface_ptr;
158161
ws_pae_lib_supp_list_init(&pae_auth->active_supp_list);
162+
ws_pae_lib_shared_comp_list_init(&pae_auth->shared_comp_list);
159163
pae_auth->timer = NULL;
160164

161165
pae_auth->hash_set = NULL;
@@ -192,6 +196,10 @@ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr, sec_prot
192196
goto error;
193197
}
194198

199+
if (kmp_service_shared_comp_if_register(pae_auth->kmp_service, ws_pae_auth_shared_comp_add, ws_pae_auth_shared_comp_remove)) {
200+
goto error;
201+
}
202+
195203
if (auth_key_sec_prot_register(pae_auth->kmp_service) < 0) {
196204
goto error;
197205
}
@@ -594,6 +602,8 @@ static void ws_pae_auth_free(pae_auth_t *pae_auth)
594602
return;
595603
}
596604

605+
ws_pae_lib_shared_comp_list_free(&pae_auth->shared_comp_list);
606+
597607
ws_pae_lib_supp_list_delete(&pae_auth->active_supp_list);
598608

599609
kmp_socket_if_unregister(pae_auth->kmp_service);
@@ -741,6 +751,8 @@ void ws_pae_auth_slow_timer(uint16_t seconds)
741751
}
742752

743753
ws_pae_lib_supp_list_slow_timer_update(&pae_auth->active_supp_list, seconds);
754+
755+
ws_pae_lib_shared_comp_list_timeout(&pae_auth->shared_comp_list, seconds);
744756
}
745757

746758
// Update key storage timer
@@ -837,6 +849,26 @@ static int8_t ws_pae_auth_timer_if_stop(kmp_service_t *service, kmp_api_t *kmp)
837849
return 0;
838850
}
839851

852+
static int8_t ws_pae_auth_shared_comp_add(kmp_service_t *service, kmp_shared_comp_t *data)
853+
{
854+
pae_auth_t *pae_auth = ws_pae_auth_by_kmp_service_get(service);
855+
if (!pae_auth) {
856+
return -1;
857+
}
858+
859+
return ws_pae_lib_shared_comp_list_add(&pae_auth->shared_comp_list, data);
860+
}
861+
862+
static int8_t ws_pae_auth_shared_comp_remove(kmp_service_t *service, kmp_shared_comp_t *data)
863+
{
864+
pae_auth_t *pae_auth = ws_pae_auth_by_kmp_service_get(service);
865+
if (!pae_auth) {
866+
return -1;
867+
}
868+
869+
return ws_pae_lib_shared_comp_list_remove(&pae_auth->shared_comp_list, data);
870+
}
871+
840872
static int8_t ws_pae_auth_timer_start(pae_auth_t *pae_auth)
841873
{
842874
pae_auth->timer_running = true;

source/6LoWPAN/ws/ws_pae_lib.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,64 @@ supp_entry_t *ws_pae_lib_supp_list_entry_retry_timer_get(supp_list_t *supp_list)
448448
return retry_supp;
449449
}
450450

451+
int8_t ws_pae_lib_shared_comp_list_init(shared_comp_list_t *comp_list)
452+
{
453+
ns_list_init(comp_list);
454+
return 0;
455+
}
456+
457+
int8_t ws_pae_lib_shared_comp_list_free(shared_comp_list_t *comp_list)
458+
{
459+
ns_list_foreach_safe(shared_comp_entry_t, entry, comp_list) {
460+
if (entry->data->delete) {
461+
entry->data->delete ();
462+
}
463+
ns_list_remove(comp_list, entry);
464+
ns_dyn_mem_free(entry);
465+
}
466+
return 0;
467+
}
468+
469+
int8_t ws_pae_lib_shared_comp_list_add(shared_comp_list_t *comp_list, kmp_shared_comp_t *data)
470+
{
471+
ns_list_foreach(shared_comp_entry_t, entry, comp_list) {
472+
if (entry->data == data) {
473+
return -1;
474+
}
475+
}
476+
477+
shared_comp_entry_t *entry = ns_dyn_mem_alloc(sizeof(shared_comp_entry_t));
478+
if (!entry) {
479+
return -1;
480+
}
481+
entry->data = data;
482+
ns_list_add_to_end(comp_list, entry);
483+
484+
return 0;
485+
}
486+
487+
int8_t ws_pae_lib_shared_comp_list_remove(shared_comp_list_t *comp_list, kmp_shared_comp_t *data)
488+
{
489+
ns_list_foreach(shared_comp_entry_t, entry, comp_list) {
490+
if (entry->data == data) {
491+
ns_list_remove(comp_list, entry);
492+
ns_dyn_mem_free(entry);
493+
return 0;
494+
}
495+
}
496+
497+
return 0;
498+
}
499+
500+
int8_t ws_pae_lib_shared_comp_list_timeout(shared_comp_list_t *comp_list, uint16_t ticks)
501+
{
502+
ns_list_foreach(shared_comp_entry_t, entry, comp_list) {
503+
if (entry->data->timeout) {
504+
entry->data->timeout(ticks);
505+
}
506+
}
507+
508+
return 0;
509+
}
510+
451511
#endif /* HAVE_WS */

source/6LoWPAN/ws/ws_pae_lib.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ typedef struct supp_entry_s {
4545

4646
typedef NS_LIST_HEAD(supp_entry_t, link) supp_list_t;
4747

48+
typedef struct {
49+
kmp_shared_comp_t *data; /**< KMP shared component data */
50+
ns_list_link_t link; /**< Link */
51+
} shared_comp_entry_t;
52+
53+
typedef NS_LIST_HEAD(shared_comp_entry_t, link) shared_comp_list_t;
54+
4855
/**
4956
* ws_pae_lib_kmp_list_init initializes KMP list
5057
*
@@ -388,4 +395,62 @@ kmp_api_t *ws_pae_lib_supp_list_kmp_receive_check(supp_list_t *supp_list, const
388395
*/
389396
supp_entry_t *ws_pae_lib_supp_list_entry_retry_timer_get(supp_list_t *supp_list);
390397

398+
/**
399+
* ws_pae_lib_shared_comp_list_init init shared component list
400+
*
401+
* \param comp_list component list
402+
*
403+
* \return < 0 failure
404+
* \return >= 0 success
405+
*
406+
*/
407+
int8_t ws_pae_lib_shared_comp_list_init(shared_comp_list_t *comp_list);
408+
409+
/**
410+
* ws_pae_lib_shared_comp_list_free free shared component list
411+
*
412+
* \param comp_list component list
413+
*
414+
* \return < 0 failure
415+
* \return >= 0 success
416+
*
417+
*/
418+
int8_t ws_pae_lib_shared_comp_list_free(shared_comp_list_t *comp_list);
419+
420+
/**
421+
* ws_pae_lib_shared_comp_list_add add to shared component list
422+
*
423+
* \param comp_list component list
424+
* \param data shared component
425+
*
426+
* \return < 0 failure
427+
* \return >= 0 success
428+
*
429+
*/
430+
int8_t ws_pae_lib_shared_comp_list_add(shared_comp_list_t *comp_list, kmp_shared_comp_t *data);
431+
432+
/**
433+
* ws_pae_lib_shared_comp_list_remove remove from shared component list
434+
*
435+
* \param comp_list component list
436+
* \param data shared component
437+
*
438+
* \return < 0 failure
439+
* \return >= 0 success
440+
*
441+
*/
442+
int8_t ws_pae_lib_shared_comp_list_remove(shared_comp_list_t *comp_list, kmp_shared_comp_t *data);
443+
444+
/**
445+
* ws_pae_lib_shared_comp_list_timeout timeout to shared component list
446+
*
447+
* \param comp_list component list
448+
* \param ticks elapsed time in seconds
449+
*
450+
* \return < 0 failure
451+
* \return >= 0 success
452+
*
453+
*/
454+
int8_t ws_pae_lib_shared_comp_list_timeout(shared_comp_list_t *comp_list, uint16_t ticks);
455+
391456
#endif /* WS_PAE_AUTH_H_ */

0 commit comments

Comments
 (0)