Annotation of embedaddon/strongswan/src/libcharon/plugins/eap_simaka_reauth/eap_simaka_reauth_plugin.c, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 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_simaka_reauth_plugin.h"
                     17: #include "eap_simaka_reauth_card.h"
                     18: #include "eap_simaka_reauth_provider.h"
                     19: 
                     20: #include <daemon.h>
                     21: 
                     22: typedef struct private_eap_simaka_reauth_t private_eap_simaka_reauth_t;
                     23: 
                     24: /**
                     25:  * Private data of an eap_simaka_reauth_t object.
                     26:  */
                     27: struct private_eap_simaka_reauth_t {
                     28: 
                     29:        /**
                     30:         * Public eap_simaka_reauth_plugin_t interface.
                     31:         */
                     32:        eap_simaka_reauth_plugin_t public;
                     33: 
                     34:        /**
                     35:         * SIM card
                     36:         */
                     37:        eap_simaka_reauth_card_t *card;
                     38: 
                     39:        /**
                     40:         * SIM provider
                     41:         */
                     42:        eap_simaka_reauth_provider_t *provider;
                     43: };
                     44: 
                     45: METHOD(plugin_t, get_name, char*,
                     46:        private_eap_simaka_reauth_t *this)
                     47: {
                     48:        return "eap-simaka-reauth";
                     49: }
                     50: 
                     51: /**
                     52:  * Callback providing our card to register
                     53:  */
                     54: static simaka_card_t* get_card(private_eap_simaka_reauth_t *this)
                     55: {
                     56:        if (!this->card)
                     57:        {
                     58:                this->card = eap_simaka_reauth_card_create();
                     59:        }
                     60:        return &this->card->card;
                     61: }
                     62: 
                     63: /**
                     64:  * Callback providing our provider to register
                     65:  */
                     66: static simaka_provider_t* get_provider(private_eap_simaka_reauth_t *this)
                     67: {
                     68:        if (!this->provider)
                     69:        {
                     70:                this->provider = eap_simaka_reauth_provider_create();
                     71:                if (!this->provider)
                     72:                {
                     73:                        return NULL;
                     74:                }
                     75:        }
                     76:        return &this->provider->provider;
                     77: }
                     78: 
                     79: METHOD(plugin_t, get_features, int,
                     80:        private_eap_simaka_reauth_t *this, plugin_feature_t *features[])
                     81: {
                     82:        static plugin_feature_t f[] = {
                     83:                PLUGIN_CALLBACK(simaka_manager_register, get_card),
                     84:                        PLUGIN_PROVIDE(CUSTOM, "aka-card"),
                     85:                                PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
                     86:                        PLUGIN_PROVIDE(CUSTOM, "sim-card"),
                     87:                                PLUGIN_DEPENDS(CUSTOM, "sim-manager"),
                     88:                PLUGIN_CALLBACK(simaka_manager_register, get_provider),
                     89:                        PLUGIN_PROVIDE(CUSTOM, "aka-provider"),
                     90:                                PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
                     91:                                PLUGIN_DEPENDS(RNG, RNG_WEAK),
                     92:                        PLUGIN_PROVIDE(CUSTOM, "sim-provider"),
                     93:                                PLUGIN_DEPENDS(CUSTOM, "sim-manager"),
                     94:                                PLUGIN_DEPENDS(RNG, RNG_WEAK),
                     95:        };
                     96:        *features = f;
                     97:        return countof(f);
                     98: }
                     99: 
                    100: METHOD(plugin_t, destroy, void,
                    101:        private_eap_simaka_reauth_t *this)
                    102: {
                    103:        DESTROY_IF(this->card);
                    104:        DESTROY_IF(this->provider);
                    105:        free(this);
                    106: }
                    107: 
                    108: /**
                    109:  * See header
                    110:  */
                    111: plugin_t *eap_simaka_reauth_plugin_create()
                    112: {
                    113:        private_eap_simaka_reauth_t *this;
                    114: 
                    115:        INIT(this,
                    116:                .public = {
                    117:                        .plugin = {
                    118:                                .get_name = _get_name,
                    119:                                .get_features = _get_features,
                    120:                                .destroy = _destroy,
                    121:                        },
                    122:                },
                    123:        );
                    124: 
                    125:        return &this->public.plugin;
                    126: }
                    127: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>