From: Martin Willi Date: Thu, 13 Oct 2011 15:28:29 +0000 (+0200) Subject: Add features support tp eap-simaka-reauth plugin X-Git-Tag: 4.6.0~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67c1d3655495f32841729a6d100d508ae9df2716;p=thirdparty%2Fstrongswan.git Add features support tp eap-simaka-reauth plugin --- diff --git a/src/libcharon/plugins/eap_simaka_reauth/Makefile.am b/src/libcharon/plugins/eap_simaka_reauth/Makefile.am index 0191c9de6d..0b35c75216 100644 --- a/src/libcharon/plugins/eap_simaka_reauth/Makefile.am +++ b/src/libcharon/plugins/eap_simaka_reauth/Makefile.am @@ -8,6 +8,7 @@ if MONOLITHIC noinst_LTLIBRARIES = libstrongswan-eap-simaka-reauth.la else plugin_LTLIBRARIES = libstrongswan-eap-simaka-reauth.la +libstrongswan_eap_simaka_reauth_la_LIBADD = $(top_builddir)/src/libsimaka/libsimaka.la endif libstrongswan_eap_simaka_reauth_la_SOURCES = \ diff --git a/src/libcharon/plugins/eap_simaka_reauth/eap_simaka_reauth_plugin.c b/src/libcharon/plugins/eap_simaka_reauth/eap_simaka_reauth_plugin.c index 2a0377c044..ab3ab2f4d9 100644 --- a/src/libcharon/plugins/eap_simaka_reauth/eap_simaka_reauth_plugin.c +++ b/src/libcharon/plugins/eap_simaka_reauth/eap_simaka_reauth_plugin.c @@ -48,25 +48,60 @@ METHOD(plugin_t, get_name, char*, return "eap-simaka-reauth"; } -METHOD(plugin_t, destroy, void, - private_eap_simaka_reauth_t *this) +/** + * Callback providing our card to register + */ +static simaka_card_t* get_card(private_eap_simaka_reauth_t *this) { - simaka_manager_t *mgr; - - mgr = lib->get(lib, "sim-manager"); - if (mgr) + if (!this->card) { - mgr->remove_card(mgr, &this->card->card); - mgr->remove_provider(mgr, &this->provider->provider); + this->card = eap_simaka_reauth_card_create(); } - mgr = lib->get(lib, "aka-manager"); - if (mgr) + return &this->card->card; +} + +/** + * Callback providing our provider to register + */ +static simaka_provider_t* get_provider(private_eap_simaka_reauth_t *this) +{ + if (!this->provider) { - mgr->remove_card(mgr, &this->card->card); - mgr->remove_provider(mgr, &this->provider->provider); + this->provider = eap_simaka_reauth_provider_create(); + if (!this->provider) + { + return NULL; + } } - this->card->destroy(this->card); - this->provider->destroy(this->provider); + return &this->provider->provider; +} + +METHOD(plugin_t, get_features, int, + private_eap_simaka_reauth_t *this, plugin_feature_t *features[]) +{ + static plugin_feature_t f[] = { + PLUGIN_CALLBACK(simaka_manager_register, get_card), + PLUGIN_PROVIDE(CUSTOM, "aka-card"), + PLUGIN_DEPENDS(CUSTOM, "aka-manager"), + PLUGIN_PROVIDE(CUSTOM, "sim-card"), + PLUGIN_DEPENDS(CUSTOM, "sim-manager"), + PLUGIN_CALLBACK(simaka_manager_register, get_provider), + PLUGIN_PROVIDE(CUSTOM, "aka-provider"), + PLUGIN_DEPENDS(CUSTOM, "aka-manager"), + PLUGIN_DEPENDS(RNG, RNG_WEAK), + PLUGIN_PROVIDE(CUSTOM, "sim-provider"), + PLUGIN_DEPENDS(CUSTOM, "sim-manager"), + PLUGIN_DEPENDS(RNG, RNG_WEAK), + }; + *features = f; + return countof(f); +} + +METHOD(plugin_t, destroy, void, + private_eap_simaka_reauth_t *this) +{ + DESTROY_IF(this->card); + DESTROY_IF(this->provider); free(this); } @@ -76,38 +111,17 @@ METHOD(plugin_t, destroy, void, plugin_t *eap_simaka_reauth_plugin_create() { private_eap_simaka_reauth_t *this; - simaka_manager_t *mgr; INIT(this, .public = { .plugin = { .get_name = _get_name, - .reload = (void*)return_false, + .get_features = _get_features, .destroy = _destroy, }, }, - .provider = eap_simaka_reauth_provider_create(), ); - if (!this->provider) - { - free(this); - return NULL; - } - this->card = eap_simaka_reauth_card_create(); - - mgr = lib->get(lib, "sim-manager"); - if (mgr) - { - mgr->add_card(mgr, &this->card->card); - mgr->add_provider(mgr, &this->provider->provider); - } - mgr = lib->get(lib, "aka-manager"); - if (mgr) - { - mgr->add_card(mgr, &this->card->card); - mgr->add_provider(mgr, &this->provider->provider); - } return &this->public.plugin; }