strongswan/src/libcharon/plugins/eap_simaka_pseudonym/eap_simaka_pseudonym_plugin.c

114 lines
2.5 KiB
C

/*
* Copyright (C) 2009 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "eap_simaka_pseudonym_plugin.h"
#include "eap_simaka_pseudonym_card.h"
#include "eap_simaka_pseudonym_provider.h"
#include <daemon.h>
typedef struct private_eap_simaka_pseudonym_t private_eap_simaka_pseudonym_t;
/**
* Private data of an eap_simaka_pseudonym_t object.
*/
struct private_eap_simaka_pseudonym_t {
/**
* Public eap_simaka_pseudonym_plugin_t interface.
*/
eap_simaka_pseudonym_plugin_t public;
/**
* SIM card
*/
eap_simaka_pseudonym_card_t *card;
/**
* SIM provider
*/
eap_simaka_pseudonym_provider_t *provider;
};
METHOD(plugin_t, get_name, char*,
private_eap_simaka_pseudonym_t *this)
{
return "eap-simaka-pseudonym";
}
METHOD(plugin_t, destroy, void,
private_eap_simaka_pseudonym_t *this)
{
simaka_manager_t *mgr;
mgr = lib->get(lib, "sim-manager");
if (mgr)
{
mgr->remove_card(mgr, &this->card->card);
mgr->remove_provider(mgr, &this->provider->provider);
}
mgr = lib->get(lib, "aka-manager");
if (mgr)
{
mgr->remove_card(mgr, &this->card->card);
mgr->remove_provider(mgr, &this->provider->provider);
}
this->card->destroy(this->card);
this->provider->destroy(this->provider);
free(this);
}
/**
* See header
*/
plugin_t *eap_simaka_pseudonym_plugin_create()
{
private_eap_simaka_pseudonym_t *this;
simaka_manager_t *mgr;
INIT(this,
.public = {
.plugin = {
.get_name = _get_name,
.reload = (void*)return_false,
.destroy = _destroy,
},
},
.provider = eap_simaka_pseudonym_provider_create(),
);
if (!this->provider)
{
free(this);
return NULL;
}
this->card = eap_simaka_pseudonym_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;
}