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; eap_sim_file_triplets_t *triplets;
}; };
/** METHOD(sim_card_t, get_triplet, bool,
* Implementation of sim_card_t.get_triplet 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])
static bool get_triplet(private_eap_sim_file_card_t *this,
identification_t *id, char *rand, char *sres, char *kc)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
identification_t *cand; identification_t *cand;
@@ -68,18 +66,16 @@ static bool get_triplet(private_eap_sim_file_card_t *this,
return FALSE; return FALSE;
} }
/** METHOD(sim_card_t, get_quintuplet, status_t,
* Implementation of sim_card_t.get_quintuplet 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],
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_file_card_t, destroy, void,
* Implementation of eap_sim_file_card_t.destroy. private_eap_sim_file_card_t *this)
*/
static void destroy(private_eap_sim_file_card_t *this)
{ {
free(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) 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; 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_file_card_t*))destroy; .set_pseudonym = (void*)nop,
.get_reauth = (void*)return_null,
this->triplets = triplets; .set_reauth = (void*)nop,
},
.destroy = _destroy,
},
.triplets = triplets,
);
return &this->public; return &this->public;
} }
@@ -35,11 +35,9 @@ struct private_eap_sim_file_provider_t {
eap_sim_file_triplets_t *triplets; eap_sim_file_triplets_t *triplets;
}; };
/** METHOD(sim_provider_t, get_triplet, bool,
* Implementation of sim_provider_t.get_triplet 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])
static bool get_triplet(private_eap_sim_file_provider_t *this,
identification_t *id, char *rand, char *sres, char *kc)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
identification_t *cand; identification_t *cand;
@@ -61,10 +59,8 @@ static bool get_triplet(private_eap_sim_file_provider_t *this,
return FALSE; return FALSE;
} }
/** METHOD(eap_sim_file_provider_t, destroy, void,
* Implementation of eap_sim_file_provider_t.destroy. private_eap_sim_file_provider_t *this)
*/
static void destroy(private_eap_sim_file_provider_t *this)
{ {
free(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_provider_t *eap_sim_file_provider_create(
eap_sim_file_triplets_t *triplets) 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; INIT(this,
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; .public = {
this->public.provider.resync = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false; .provider = {
this->public.provider.is_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null; .get_triplet = _get_triplet,
this->public.provider.gen_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null; .get_quintuplet = (void*)return_false,
this->public.provider.is_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_null; .resync = (void*)return_false,
this->public.provider.gen_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))return_null; .is_pseudonym = (void*)return_null,
this->public.destroy = (void(*)(eap_sim_file_provider_t*))destroy; .gen_pseudonym = (void*)return_null,
.is_reauth = (void*)return_null,
this->triplets = triplets; .gen_reauth = (void*)return_null,
},
.destroy = _destroy,
},
.triplets = triplets,
);
return &this->public; return &this->public;
} }
@@ -117,10 +117,8 @@ static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **ims
return FALSE; return FALSE;
} }
/** METHOD(eap_sim_file_triplets_t, create_enumerator, enumerator_t*,
* Implementation of eap_sim_file_triplets_t.create_enumerator private_eap_sim_file_triplets_t *this)
*/
static enumerator_t* create_enumerator(private_eap_sim_file_triplets_t *this)
{ {
triplet_enumerator_t *enumerator = malloc_thing(triplet_enumerator_t); 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); this->triplets->get_count(this->triplets), path);
} }
/** METHOD(eap_sim_file_triplets_t, destroy, void,
* Implementation of eap_sim_file_triplets_t.destroy. private_eap_sim_file_triplets_t *this)
*/
static void destroy(private_eap_sim_file_triplets_t *this)
{ {
this->triplets->destroy_function(this->triplets, (void*)triplet_destroy); this->triplets->destroy_function(this->triplets, (void*)triplet_destroy);
this->mutex->destroy(this->mutex); 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) 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); private_eap_sim_file_triplets_t *this;
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);
INIT(this,
.public = {
.create_enumerator = _create_enumerator,
.destroy = _destroy,
},
.triplets = linked_list_create(),
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
);
read_triplets(this, file); read_triplets(this, file);
return &this->public; return &this->public;