Added a method to enumerate registered EAP methods
[strongswan.git] / src / libcharon / sa / eap / eap_manager.h
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2008 Martin Willi
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 /**
18 * @defgroup eap_manager eap_manager
19 * @{ @ingroup eap
20 */
21
22 #ifndef EAP_MANAGER_H_
23 #define EAP_MANAGER_H_
24
25 #include <sa/eap/eap_method.h>
26
27 typedef struct eap_manager_t eap_manager_t;
28
29 /**
30 * The EAP manager manages all EAP implementations and creates instances.
31 *
32 * A plugin registers it's implemented EAP method at the manager by
33 * providing type and a contructor function. The manager then instanciates
34 * eap_method_t instances through the provided constructor to handle
35 * EAP authentication.
36 */
37 struct eap_manager_t {
38
39 /**
40 * Register a EAP method implementation.
41 *
42 * @param method vendor specific method, if vendor != 0
43 * @param vendor vendor ID, 0 for non-vendor (default) EAP methods
44 * @param role EAP role of the registered method
45 * @param constructor constructor function, returns an eap_method_t
46 */
47 void (*add_method)(eap_manager_t *this, eap_type_t type, u_int32_t vendor,
48 eap_role_t role, eap_constructor_t constructor);
49
50 /**
51 * Unregister a EAP method implementation using it's constructor.
52 *
53 * @param constructor constructor function to remove, as added in add_method
54 */
55 void (*remove_method)(eap_manager_t *this, eap_constructor_t constructor);
56
57 /**
58 * Enumerate the registered EAP methods for the given role.
59 *
60 * @param role EAP role of methods to enumerate
61 * @return enumerator over (eap_type_t type, u_int32_t vendor)
62 */
63 enumerator_t* (*create_enumerator)(eap_manager_t *this, eap_role_t role);
64
65 /**
66 * Create a new EAP method instance.
67 *
68 * @param type type of the EAP method
69 * @param vendor vendor ID, 0 for non-vendor (default) EAP methods
70 * @param role role of EAP method, either EAP_SERVER or EAP_PEER
71 * @param server identity of the server
72 * @param peer identity of the peer (client)
73 * @return EAP method instance, NULL if no constructor found
74 */
75 eap_method_t* (*create_instance)(eap_manager_t *this, eap_type_t type,
76 u_int32_t vendor, eap_role_t role,
77 identification_t *server,
78 identification_t *peer);
79
80 /**
81 * Destroy a eap_manager instance.
82 */
83 void (*destroy)(eap_manager_t *this);
84 };
85
86 /**
87 * Create a eap_manager instance.
88 */
89 eap_manager_t *eap_manager_create();
90
91 #endif /** EAP_MANAGER_H_ @}*/