Migrated eap_sim_pcsc plugin to INIT/METHOD macros
This commit is contained in:
@@ -87,11 +87,9 @@ static bool decode_imsi_ef(unsigned char *input, int input_len, char *output)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(sim_card_t, get_triplet, bool,
|
||||||
* Implementation of sim_card_t.get_triplet
|
private_eap_sim_pcsc_card_t *this, identification_t *id,
|
||||||
*/
|
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
|
||||||
static bool get_triplet(private_eap_sim_pcsc_card_t *this,
|
|
||||||
identification_t *id, char *rand, char *sres, char *kc)
|
|
||||||
{
|
{
|
||||||
status_t found = FALSE;
|
status_t found = FALSE;
|
||||||
LONG rv;
|
LONG rv;
|
||||||
@@ -319,18 +317,16 @@ static bool get_triplet(private_eap_sim_pcsc_card_t *this,
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(sim_card_t, get_quintuplet, status_t,
|
||||||
* Implementation of sim_card_t.get_quintuplet
|
private_eap_sim_pcsc_card_t *this, identification_t *id,
|
||||||
*/
|
char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN],
|
||||||
static status_t get_quintuplet()
|
char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len)
|
||||||
{
|
{
|
||||||
return NOT_SUPPORTED;
|
return NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(eap_sim_pcsc_card_t, destroy, void,
|
||||||
* Implementation of eap_sim_pcsc_card_t.destroy.
|
private_eap_sim_pcsc_card_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_eap_sim_pcsc_card_t *this)
|
|
||||||
{
|
{
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
@@ -340,16 +336,22 @@ static void destroy(private_eap_sim_pcsc_card_t *this)
|
|||||||
*/
|
*/
|
||||||
eap_sim_pcsc_card_t *eap_sim_pcsc_card_create()
|
eap_sim_pcsc_card_t *eap_sim_pcsc_card_create()
|
||||||
{
|
{
|
||||||
private_eap_sim_pcsc_card_t *this = malloc_thing(private_eap_sim_pcsc_card_t);
|
private_eap_sim_pcsc_card_t *this;
|
||||||
|
|
||||||
this->public.card.get_triplet = (bool(*)(sim_card_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))get_triplet;
|
INIT(this,
|
||||||
this->public.card.get_quintuplet = (status_t(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len))get_quintuplet;
|
.public = {
|
||||||
this->public.card.resync = (bool(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
.card = {
|
||||||
this->public.card.get_pseudonym = (identification_t*(*)(sim_card_t*, identification_t *perm))return_null;
|
.get_triplet = _get_triplet,
|
||||||
this->public.card.set_pseudonym = (void(*)(sim_card_t*, identification_t *id, identification_t *pseudonym))nop;
|
.get_quintuplet = _get_quintuplet,
|
||||||
this->public.card.get_reauth = (identification_t*(*)(sim_card_t*, identification_t *id, char mk[HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
.resync = (void*)return_false,
|
||||||
this->public.card.set_reauth = (void(*)(sim_card_t*, identification_t *id, identification_t* next, char mk[HASH_SIZE_SHA1], u_int16_t counter))nop;
|
.get_pseudonym = (void*)return_null,
|
||||||
this->public.destroy = (void(*)(eap_sim_pcsc_card_t*))destroy;
|
.set_pseudonym = (void*)nop,
|
||||||
|
.get_reauth = (void*)return_null,
|
||||||
|
.set_reauth = (void*)nop,
|
||||||
|
},
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
|
|
||||||
typedef struct private_eap_sim_pcsc_t private_eap_sim_pcsc_t;
|
typedef struct private_eap_sim_pcsc_plugin_t private_eap_sim_pcsc_plugin_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data of an eap_sim_pcsc_t object.
|
* Private data of an eap_sim_pcsc_t object.
|
||||||
*/
|
*/
|
||||||
struct private_eap_sim_pcsc_t {
|
struct private_eap_sim_pcsc_plugin_t {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public eap_sim_pcsc_plugin_t interface.
|
* Public eap_sim_pcsc_plugin_t interface.
|
||||||
@@ -35,10 +35,8 @@ struct private_eap_sim_pcsc_t {
|
|||||||
eap_sim_pcsc_card_t *card;
|
eap_sim_pcsc_card_t *card;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
METHOD(plugin_t, destroy, void,
|
||||||
* Implementation of eap_sim_pcsc_t.destroy.
|
private_eap_sim_pcsc_plugin_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_eap_sim_pcsc_t *this)
|
|
||||||
{
|
{
|
||||||
charon->sim->remove_card(charon->sim, &this->card->card);
|
charon->sim->remove_card(charon->sim, &this->card->card);
|
||||||
this->card->destroy(this->card);
|
this->card->destroy(this->card);
|
||||||
@@ -50,10 +48,16 @@ static void destroy(private_eap_sim_pcsc_t *this)
|
|||||||
*/
|
*/
|
||||||
plugin_t *eap_sim_pcsc_plugin_create()
|
plugin_t *eap_sim_pcsc_plugin_create()
|
||||||
{
|
{
|
||||||
private_eap_sim_pcsc_t *this = malloc_thing(private_eap_sim_pcsc_t);
|
private_eap_sim_pcsc_plugin_t *this;
|
||||||
|
|
||||||
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
|
INIT(this,
|
||||||
this->card = eap_sim_pcsc_card_create();
|
.public = {
|
||||||
|
.plugin = {
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.card = eap_sim_pcsc_card_create(),
|
||||||
|
);
|
||||||
charon->sim->add_card(charon->sim, &this->card->card);
|
charon->sim->add_card(charon->sim, &this->card->card);
|
||||||
|
|
||||||
return &this->public.plugin;
|
return &this->public.plugin;
|
||||||
|
|||||||
Reference in New Issue
Block a user