Annotation of embedaddon/strongswan/src/libcharon/plugins/eap_aka_3gpp/eap_aka_3gpp_plugin.c, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2008-2009 Martin Willi
3: * HSR 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: * Copyright (C) 2015 Thomas Strangert
17: * Polystar System AB, Sweden
18: *
19: * Permission is hereby granted, free of charge, to any person obtaining a copy
20: * of this software and associated documentation files (the "Software"), to deal
21: * in the Software without restriction, including without limitation the rights
22: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23: * copies of the Software, and to permit persons to whom the Software is
24: * furnished to do so, subject to the following conditions:
25: *
26: * The above copyright notice and this permission notice shall be included in
27: * all copies or substantial portions of the Software.
28: *
29: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35: * THE SOFTWARE.
36: */
37:
38: #include "eap_aka_3gpp_plugin.h"
39: #include "eap_aka_3gpp_card.h"
40: #include "eap_aka_3gpp_provider.h"
41: #include "eap_aka_3gpp_functions.h"
42:
43: #include <daemon.h>
44:
45: typedef struct private_eap_aka_3gpp_t private_eap_aka_3gpp_t;
46:
47: /**
48: * Private data of an eap_aka_3gpp_t object.
49: */
50: struct private_eap_aka_3gpp_t {
51:
52: /**
53: * Public eap_aka_3gpp_plugin_t interface.
54: */
55: eap_aka_3gpp_plugin_t public;
56:
57: /**
58: * USIM/EAP-AKA card
59: */
60: eap_aka_3gpp_card_t *card;
61:
62: /**
63: * EAP-AKA provider
64: */
65: eap_aka_3gpp_provider_t *provider;
66:
67: /**
68: * AKA functions
69: */
70: eap_aka_3gpp_functions_t *functions;
71: };
72:
73: METHOD(plugin_t, get_name, char*,
74: private_eap_aka_3gpp_t *this)
75: {
76: return "eap-aka-3gpp";
77: }
78:
79: /**
80: * Try to instantiate ea_aka_3gpp functions and card/provider backends
81: */
82: static bool register_functions(private_eap_aka_3gpp_t *this,
83: plugin_feature_t *feature, bool reg, void *data)
84: {
85: if (reg)
86: {
87: this->functions = eap_aka_3gpp_functions_create();
88: if (!this->functions)
89: {
90: return FALSE;
91: }
92: this->card = eap_aka_3gpp_card_create(this->functions);
93: this->provider = eap_aka_3gpp_provider_create(this->functions);
94: return TRUE;
95: }
96: this->card->destroy(this->card);
97: this->provider->destroy(this->provider);
98: this->functions->destroy(this->functions);
99: this->card = NULL;
100: this->provider = NULL;
101: this->functions = NULL;
102: return TRUE;
103: }
104:
105: /**
106: * Callback providing our card to register
107: */
108: static simaka_card_t* get_card(private_eap_aka_3gpp_t *this)
109: {
110: return &this->card->card;
111: }
112:
113: /**
114: * Callback providing our provider to register
115: */
116: static simaka_provider_t* get_provider(private_eap_aka_3gpp_t *this)
117: {
118: return &this->provider->provider;
119: }
120:
121: METHOD(plugin_t, get_features, int,
122: private_eap_aka_3gpp_t *this, plugin_feature_t *features[])
123: {
124: static plugin_feature_t f[] = {
125: PLUGIN_CALLBACK((void*)register_functions, NULL),
126: PLUGIN_PROVIDE(CUSTOM, "eap-aka-3gpp-functions"),
127: PLUGIN_DEPENDS(CRYPTER, ENCR_AES_CBC, 16),
128: PLUGIN_CALLBACK(simaka_manager_register, get_card),
129: PLUGIN_PROVIDE(CUSTOM, "aka-card"),
130: PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
131: PLUGIN_DEPENDS(CUSTOM, "eap-aka-3gpp-functions"),
132: PLUGIN_CALLBACK(simaka_manager_register, get_provider),
133: PLUGIN_PROVIDE(CUSTOM, "aka-provider"),
134: PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
135: PLUGIN_DEPENDS(CUSTOM, "eap-aka-3gpp-functions"),
136: };
137: *features = f;
138: return countof(f);
139: }
140:
141: METHOD(plugin_t, destroy, void, private_eap_aka_3gpp_t *this)
142: {
143: free(this);
144: }
145:
146: /**
147: * See header
148: */
149: plugin_t *eap_aka_3gpp_plugin_create()
150: {
151: private_eap_aka_3gpp_t *this;
152:
153: INIT(this,
154: .public = {
155: .plugin = {
156: .get_name = _get_name,
157: .get_features = _get_features,
158: .destroy = _destroy,
159: },
160: },
161: );
162:
163: return &this->public.plugin;
164: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>