Migrated eap_sim_file to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-04-22 11:30:42 +02:00
parent 406051ea4e
commit 6ab1a83059
3 changed files with 59 additions and 59 deletions
@@ -35,11 +35,9 @@ struct private_eap_sim_file_card_t {
eap_sim_file_triplets_t *triplets;
};
/**
* Implementation of sim_card_t.get_triplet
*/
static bool get_triplet(private_eap_sim_file_card_t *this,
identification_t *id, char *rand, char *sres, char *kc)
METHOD(sim_card_t, get_triplet, bool,
private_eap_sim_file_card_t *this, identification_t *id,
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
{
enumerator_t *enumerator;
identification_t *cand;
@@ -68,18 +66,16 @@ static bool get_triplet(private_eap_sim_file_card_t *this,
return FALSE;
}
/**
* Implementation of sim_card_t.get_quintuplet
*/
static status_t get_quintuplet()
METHOD(sim_card_t, get_quintuplet, status_t,
private_eap_sim_file_card_t *this, 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)
{
return NOT_SUPPORTED;
}
/**
* Implementation of eap_sim_file_card_t.destroy.
*/
static void destroy(private_eap_sim_file_card_t *this)
METHOD(eap_sim_file_card_t, destroy, void,
private_eap_sim_file_card_t *this)
{
free(this);
}
@@ -89,18 +85,23 @@ static void destroy(private_eap_sim_file_card_t *this)
*/
eap_sim_file_card_t *eap_sim_file_card_create(eap_sim_file_triplets_t *triplets)
{
private_eap_sim_file_card_t *this = malloc_thing(private_eap_sim_file_card_t);
private_eap_sim_file_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;
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;
this->public.card.resync = (bool(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
this->public.card.get_pseudonym = (identification_t*(*)(sim_card_t*, identification_t *perm))return_null;
this->public.card.set_pseudonym = (void(*)(sim_card_t*, identification_t *id, identification_t *pseudonym))nop;
this->public.card.get_reauth = (identification_t*(*)(sim_card_t*, identification_t *id, char mk[HASH_SIZE_SHA1], u_int16_t *counter))return_null;
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;
this->public.destroy = (void(*)(eap_sim_file_card_t*))destroy;
this->triplets = triplets;
INIT(this,
.public = {
.card = {
.get_triplet = _get_triplet,
.get_quintuplet = _get_quintuplet,
.resync = (void*)return_false,
.get_pseudonym = (void*)return_null,
.set_pseudonym = (void*)nop,
.get_reauth = (void*)return_null,
.set_reauth = (void*)nop,
},
.destroy = _destroy,
},
.triplets = triplets,
);
return &this->public;
}
@@ -35,11 +35,9 @@ struct private_eap_sim_file_provider_t {
eap_sim_file_triplets_t *triplets;
};
/**
* Implementation of sim_provider_t.get_triplet
*/
static bool get_triplet(private_eap_sim_file_provider_t *this,
identification_t *id, char *rand, char *sres, char *kc)
METHOD(sim_provider_t, get_triplet, bool,
private_eap_sim_file_provider_t *this, identification_t *id,
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
{
enumerator_t *enumerator;
identification_t *cand;
@@ -61,10 +59,8 @@ static bool get_triplet(private_eap_sim_file_provider_t *this,
return FALSE;
}
/**
* Implementation of eap_sim_file_provider_t.destroy.
*/
static void destroy(private_eap_sim_file_provider_t *this)
METHOD(eap_sim_file_provider_t, destroy, void,
private_eap_sim_file_provider_t *this)
{
free(this);
}
@@ -75,18 +71,23 @@ static void destroy(private_eap_sim_file_provider_t *this)
eap_sim_file_provider_t *eap_sim_file_provider_create(
eap_sim_file_triplets_t *triplets)
{
private_eap_sim_file_provider_t *this = malloc_thing(private_eap_sim_file_provider_t);
private_eap_sim_file_provider_t *this;
this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))get_triplet;
this->public.provider.get_quintuplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len, char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN]))return_false;
this->public.provider.resync = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
this->public.provider.is_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null;
this->public.provider.gen_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null;
this->public.provider.is_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_null;
this->public.provider.gen_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))return_null;
this->public.destroy = (void(*)(eap_sim_file_provider_t*))destroy;
this->triplets = triplets;
INIT(this,
.public = {
.provider = {
.get_triplet = _get_triplet,
.get_quintuplet = (void*)return_false,
.resync = (void*)return_false,
.is_pseudonym = (void*)return_null,
.gen_pseudonym = (void*)return_null,
.is_reauth = (void*)return_null,
.gen_reauth = (void*)return_null,
},
.destroy = _destroy,
},
.triplets = triplets,
);
return &this->public;
}
@@ -117,10 +117,8 @@ static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **ims
return FALSE;
}
/**
* Implementation of eap_sim_file_triplets_t.create_enumerator
*/
static enumerator_t* create_enumerator(private_eap_sim_file_triplets_t *this)
METHOD(eap_sim_file_triplets_t, create_enumerator, enumerator_t*,
private_eap_sim_file_triplets_t *this)
{
triplet_enumerator_t *enumerator = malloc_thing(triplet_enumerator_t);
@@ -230,10 +228,8 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
this->triplets->get_count(this->triplets), path);
}
/**
* Implementation of eap_sim_file_triplets_t.destroy.
*/
static void destroy(private_eap_sim_file_triplets_t *this)
METHOD(eap_sim_file_triplets_t, destroy, void,
private_eap_sim_file_triplets_t *this)
{
this->triplets->destroy_function(this->triplets, (void*)triplet_destroy);
this->mutex->destroy(this->mutex);
@@ -245,14 +241,16 @@ static void destroy(private_eap_sim_file_triplets_t *this)
*/
eap_sim_file_triplets_t *eap_sim_file_triplets_create(char *file)
{
private_eap_sim_file_triplets_t *this = malloc_thing(private_eap_sim_file_triplets_t);
this->public.create_enumerator = (enumerator_t*(*)(eap_sim_file_triplets_t*))create_enumerator;
this->public.destroy = (void(*)(eap_sim_file_triplets_t*))destroy;
this->triplets = linked_list_create();
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
private_eap_sim_file_triplets_t *this;
INIT(this,
.public = {
.create_enumerator = _create_enumerator,
.destroy = _destroy,
},
.triplets = linked_list_create(),
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
);
read_triplets(this, file);
return &this->public;