mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-16 17:09:24 +01:00
eap: Add dynamic EAP method registration
This commit is contained in:
parent
02eeb82c53
commit
cdfc854056
51
src/eap.c
51
src/eap.c
@ -412,15 +412,54 @@ int eap_unregister_method(struct eap_method *method)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
void eap_init(void) {
|
||||
eap_methods = l_queue_new();
|
||||
static void __eap_method_enable(struct eap_method_desc *start,
|
||||
struct eap_method_desc *stop)
|
||||
{
|
||||
struct eap_method_desc *desc;
|
||||
|
||||
eap_register_method(&eap_md5);
|
||||
eap_register_method(&eap_tls);
|
||||
eap_register_method(&eap_ttls);
|
||||
l_debug("");
|
||||
|
||||
if (start == NULL || stop == NULL)
|
||||
return;
|
||||
|
||||
for (desc = start; desc < stop; desc++) {
|
||||
if (!desc->init)
|
||||
continue;
|
||||
|
||||
desc->init();
|
||||
}
|
||||
}
|
||||
|
||||
void eap_exit(void) {
|
||||
static void __eap_method_disable(struct eap_method_desc *start,
|
||||
struct eap_method_desc *stop)
|
||||
{
|
||||
struct eap_method_desc *desc;
|
||||
|
||||
l_debug("");
|
||||
|
||||
if (start == NULL || stop == NULL)
|
||||
return;
|
||||
|
||||
for (desc = start; desc < stop; desc++) {
|
||||
if (!desc->exit)
|
||||
continue;
|
||||
|
||||
desc->exit();
|
||||
}
|
||||
}
|
||||
|
||||
extern struct eap_method_desc __start___eap[];
|
||||
extern struct eap_method_desc __stop___eap[];
|
||||
|
||||
void eap_init(void)
|
||||
{
|
||||
eap_methods = l_queue_new();
|
||||
__eap_method_enable(__start___eap, __stop___eap);
|
||||
}
|
||||
|
||||
void eap_exit(void)
|
||||
{
|
||||
__eap_method_disable(__start___eap, __stop___eap);
|
||||
l_queue_destroy(eap_methods, NULL);
|
||||
}
|
||||
|
||||
|
16
src/eap.h
16
src/eap.h
@ -95,6 +95,18 @@ struct eap_method {
|
||||
const uint8_t *pkt, size_t len);
|
||||
};
|
||||
|
||||
struct eap_method_desc {
|
||||
const char *name;
|
||||
int (*init)(void);
|
||||
void (*exit)(void);
|
||||
} __attribute__((aligned(8)));
|
||||
|
||||
#define EAP_METHOD_BUILTIN(name, init, exit) \
|
||||
static struct eap_method_desc __eap_builtin_ ## name \
|
||||
__attribute__((used, section("__eap"), aligned(8))) = { \
|
||||
#name, init, exit \
|
||||
}; \
|
||||
|
||||
int eap_register_method(struct eap_method *method);
|
||||
int eap_unregister_method(struct eap_method *method);
|
||||
|
||||
@ -117,7 +129,3 @@ void eap_method_error(struct eap_state *eap);
|
||||
|
||||
void eap_save_last_id(struct eap_state *eap, uint8_t *last_id);
|
||||
void eap_restore_last_id(struct eap_state *eap, uint8_t last_id);
|
||||
|
||||
extern struct eap_method eap_md5;
|
||||
extern struct eap_method eap_tls;
|
||||
extern struct eap_method eap_ttls;
|
||||
|
Loading…
Reference in New Issue
Block a user