reintegrated eap-radius branch into trunk
[strongswan.git] / src / charon / plugins / eap_radius / eap_radius_plugin.c
1 /*
2 * Copyright (C) 2009 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 #include "eap_radius_plugin.h"
19
20 #include "eap_radius.h"
21 #include "radius_client.h"
22
23 #include <daemon.h>
24
25 /**
26 * Implementation of plugin_t.destroy
27 */
28 static void destroy(eap_radius_plugin_t *this)
29 {
30 charon->eap->remove_method(charon->eap, (eap_constructor_t)eap_radius_create);
31 radius_client_cleanup();
32 free(this);
33 }
34
35 /*
36 * see header file
37 */
38 plugin_t *plugin_create()
39 {
40 eap_radius_plugin_t *this;
41
42 if (!radius_client_init())
43 {
44 DBG1(DBG_CFG, "RADIUS plugin initialization failed");
45 return NULL;
46 }
47
48 this = malloc_thing(eap_radius_plugin_t);
49 this->plugin.destroy = (void(*)(plugin_t*))destroy;
50
51 charon->eap->add_method(charon->eap, EAP_RADIUS, 0,
52 EAP_SERVER, (eap_constructor_t)eap_radius_create);
53
54 return &this->plugin;
55 }
56