Annotation of embedaddon/strongswan/src/libcharon/plugins/eap_aka_3gpp2/eap_aka_3gpp2_plugin.c, revision 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: #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: METHOD(plugin_t, get_name, char*,
! 52: private_eap_aka_3gpp2_t *this)
! 53: {
! 54: return "eap-aka-3gpp2";
! 55: }
! 56:
! 57: /**
! 58: * Try to instantiate 3gpp2 functions and card/provider backends
! 59: */
! 60: static bool register_functions(private_eap_aka_3gpp2_t *this,
! 61: plugin_feature_t *feature, bool reg, void *data)
! 62: {
! 63: if (reg)
! 64: {
! 65: this->functions = eap_aka_3gpp2_functions_create();
! 66: if (!this->functions)
! 67: {
! 68: return FALSE;
! 69: }
! 70: this->card = eap_aka_3gpp2_card_create(this->functions);
! 71: this->provider = eap_aka_3gpp2_provider_create(this->functions);
! 72: return TRUE;
! 73: }
! 74: this->card->destroy(this->card);
! 75: this->provider->destroy(this->provider);
! 76: this->functions->destroy(this->functions);
! 77: this->card = NULL;
! 78: this->provider = NULL;
! 79: this->functions = NULL;
! 80: return TRUE;
! 81: }
! 82:
! 83: /**
! 84: * Callback providing our card to register
! 85: */
! 86: static simaka_card_t* get_card(private_eap_aka_3gpp2_t *this)
! 87: {
! 88: return &this->card->card;
! 89: }
! 90:
! 91: /**
! 92: * Callback providing our provider to register
! 93: */
! 94: static simaka_provider_t* get_provider(private_eap_aka_3gpp2_t *this)
! 95: {
! 96: return &this->provider->provider;
! 97: }
! 98:
! 99: METHOD(plugin_t, get_features, int,
! 100: private_eap_aka_3gpp2_t *this, plugin_feature_t *features[])
! 101: {
! 102: static plugin_feature_t f[] = {
! 103: PLUGIN_CALLBACK((void*)register_functions, NULL),
! 104: PLUGIN_PROVIDE(CUSTOM, "eap-aka-3gpp2-functions"),
! 105: PLUGIN_DEPENDS(PRF, PRF_KEYED_SHA1),
! 106: PLUGIN_CALLBACK(simaka_manager_register, get_card),
! 107: PLUGIN_PROVIDE(CUSTOM, "aka-card"),
! 108: PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
! 109: PLUGIN_DEPENDS(CUSTOM, "eap-aka-3gpp2-functions"),
! 110: PLUGIN_CALLBACK(simaka_manager_register, get_provider),
! 111: PLUGIN_PROVIDE(CUSTOM, "aka-provider"),
! 112: PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
! 113: PLUGIN_DEPENDS(CUSTOM, "eap-aka-3gpp2-functions"),
! 114: };
! 115: *features = f;
! 116: return countof(f);
! 117: }
! 118:
! 119: METHOD(plugin_t, destroy, void,
! 120: private_eap_aka_3gpp2_t *this)
! 121: {
! 122: free(this);
! 123: }
! 124:
! 125: /**
! 126: * See header
! 127: */
! 128: plugin_t *eap_aka_3gpp2_plugin_create()
! 129: {
! 130: private_eap_aka_3gpp2_t *this;
! 131:
! 132: INIT(this,
! 133: .public = {
! 134: .plugin = {
! 135: .get_name = _get_name,
! 136: .get_features = _get_features,
! 137: .destroy = _destroy,
! 138: },
! 139: },
! 140: );
! 141:
! 142: return &this->public.plugin;
! 143: }
! 144:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>