Moving charon to libcharon.
[strongswan.git] / src / libcharon / plugins / eap_aka_3gpp2 / eap_aka_3gpp2_plugin.c
1 /*
2 * Copyright (C) 2008-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
16 #include "eap_aka_3gpp2_plugin.h"
17 #include "eap_aka_3gpp2_card.h"
18 #include "eap_aka_3gpp2_provider.h"
19 #include "eap_aka_3gpp2_functions.h"
20
21 #include <daemon.h>
22
23 typedef struct private_eap_aka_3gpp2_t private_eap_aka_3gpp2_t;
24
25 /**
26 * Private data of an eap_aka_3gpp2_t object.
27 */
28 struct private_eap_aka_3gpp2_t {
29
30 /**
31 * Public eap_aka_3gpp2_plugin_t interface.
32 */
33 eap_aka_3gpp2_plugin_t public;
34
35 /**
36 * SIM card
37 */
38 eap_aka_3gpp2_card_t *card;
39
40 /**
41 * SIM provider
42 */
43 eap_aka_3gpp2_provider_t *provider;
44
45 /**
46 * AKA functions
47 */
48 eap_aka_3gpp2_functions_t *functions;
49 };
50
51 /**
52 * Implementation of eap_aka_3gpp2_t.destroy.
53 */
54 static void destroy(private_eap_aka_3gpp2_t *this)
55 {
56 charon->sim->remove_card(charon->sim, &this->card->card);
57 charon->sim->remove_provider(charon->sim, &this->provider->provider);
58 this->card->destroy(this->card);
59 this->provider->destroy(this->provider);
60 this->functions->destroy(this->functions);
61 free(this);
62 }
63
64 /**
65 * See header
66 */
67 plugin_t *eap_aka_3gpp2_plugin_create()
68 {
69 private_eap_aka_3gpp2_t *this = malloc_thing(private_eap_aka_3gpp2_t);
70
71 this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
72
73 this->functions = eap_aka_3gpp2_functions_create();
74 if (!this->functions)
75 {
76 free(this);
77 return NULL;
78 }
79 this->card = eap_aka_3gpp2_card_create(this->functions);
80 this->provider = eap_aka_3gpp2_provider_create(this->functions);
81
82 charon->sim->add_card(charon->sim, &this->card->card);
83 charon->sim->add_provider(charon->sim, &this->provider->provider);
84
85 return &this->public.plugin;
86 }
87