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