Moving charon to libcharon.
[strongswan.git] / src / libcharon / plugins / eap_simaka_pseudonym / eap_simaka_pseudonym_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
16 #include "eap_simaka_pseudonym_plugin.h"
17 #include "eap_simaka_pseudonym_card.h"
18 #include "eap_simaka_pseudonym_provider.h"
19
20 #include <daemon.h>
21
22 typedef struct private_eap_simaka_pseudonym_t private_eap_simaka_pseudonym_t;
23
24 /**
25 * Private data of an eap_simaka_pseudonym_t object.
26 */
27 struct private_eap_simaka_pseudonym_t {
28
29 /**
30 * Public eap_simaka_pseudonym_plugin_t interface.
31 */
32 eap_simaka_pseudonym_plugin_t public;
33
34 /**
35 * SIM card
36 */
37 eap_simaka_pseudonym_card_t *card;
38
39 /**
40 * SIM provider
41 */
42 eap_simaka_pseudonym_provider_t *provider;
43 };
44
45 /**
46 * Implementation of eap_simaka_pseudonym_t.destroy.
47 */
48 static void destroy(private_eap_simaka_pseudonym_t *this)
49 {
50 charon->sim->remove_card(charon->sim, &this->card->card);
51 charon->sim->remove_provider(charon->sim, &this->provider->provider);
52 this->card->destroy(this->card);
53 this->provider->destroy(this->provider);
54 free(this);
55 }
56
57 /**
58 * See header
59 */
60 plugin_t *eap_simaka_pseudonym_plugin_create()
61 {
62 private_eap_simaka_pseudonym_t *this;
63
64 this = malloc_thing(private_eap_simaka_pseudonym_t);
65
66 this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
67
68 this->provider = eap_simaka_pseudonym_provider_create();
69 if (!this->provider)
70 {
71 free(this);
72 return NULL;
73 }
74 this->card = eap_simaka_pseudonym_card_create();
75
76 charon->sim->add_card(charon->sim, &this->card->card);
77 charon->sim->add_provider(charon->sim, &this->provider->provider);
78
79 return &this->public.plugin;
80 }
81