Migrated eap_aka_3gpp2_provider_t to INIT/METHOD macros.
authorTobias Brunner <tobias@strongswan.org>
Tue, 4 Oct 2011 13:24:00 +0000 (15:24 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 4 Oct 2011 13:24:00 +0000 (15:24 +0200)
src/libcharon/plugins/eap_aka_3gpp2/eap_aka_3gpp2_provider.c

index ce6ae37..b2b43da 100644 (file)
@@ -80,14 +80,10 @@ void eap_aka_3gpp2_get_sqn(char sqn[AKA_SQN_LEN], int offset)
        memcpy(sqn + 4, &time.tv_usec, 2);
 }
 
-/**
- * Implementation of simaka_provider_t.get_quintuplet
- */
-static bool get_quintuplet(private_eap_aka_3gpp2_provider_t *this,
-                                                  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])
+METHOD(simaka_provider_t, get_quintuplet, bool,
+       private_eap_aka_3gpp2_provider_t *this, 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])
 {
        rng_t *rng;
        char mac[AKA_MAC_LEN], ak[AKA_AK_LEN], k[AKA_K_LEN];
@@ -131,12 +127,9 @@ static bool get_quintuplet(private_eap_aka_3gpp2_provider_t *this,
        return TRUE;
 }
 
-/**
- * Implementation of simaka_provider_t.resync
- */
-static bool resync(private_eap_aka_3gpp2_provider_t *this,
-                                  identification_t *id, char rand[AKA_RAND_LEN],
-                                  char auts[AKA_AUTS_LEN])
+METHOD(simaka_provider_t, resync, bool,
+       private_eap_aka_3gpp2_provider_t *this, identification_t *id,
+       char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN])
 {
        char *sqn, *macs;
        char aks[AKA_AK_LEN], k[AKA_K_LEN], amf[AKA_AMF_LEN], xmacs[AKA_MAC_LEN];
@@ -169,10 +162,8 @@ static bool resync(private_eap_aka_3gpp2_provider_t *this,
        return TRUE;
 }
 
-/**
- * Implementation of eap_aka_3gpp2_provider_t.destroy.
- */
-static void destroy(private_eap_aka_3gpp2_provider_t *this)
+METHOD(eap_aka_3gpp2_provider_t, destroy, void,
+       private_eap_aka_3gpp2_provider_t *this)
 {
        free(this);
 }
@@ -183,18 +174,23 @@ static void destroy(private_eap_aka_3gpp2_provider_t *this)
 eap_aka_3gpp2_provider_t *eap_aka_3gpp2_provider_create(
                                                                                                eap_aka_3gpp2_functions_t *f)
 {
-       private_eap_aka_3gpp2_provider_t *this = malloc_thing(private_eap_aka_3gpp2_provider_t);
-
-       this->public.provider.get_triplet = (bool(*)(simaka_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
-       this->public.provider.get_quintuplet = (bool(*)(simaka_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]))get_quintuplet;
-       this->public.provider.resync = (bool(*)(simaka_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))resync;
-       this->public.provider.is_pseudonym = (identification_t*(*)(simaka_provider_t*, identification_t *id))return_null;
-       this->public.provider.gen_pseudonym = (identification_t*(*)(simaka_provider_t*, identification_t *id))return_null;
-       this->public.provider.is_reauth = (identification_t*(*)(simaka_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_null;
-       this->public.provider.gen_reauth = (identification_t*(*)(simaka_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))return_null;
-       this->public.destroy = (void(*)(eap_aka_3gpp2_provider_t*))destroy;
-
-       this->f = f;
+       private_eap_aka_3gpp2_provider_t *this;
+
+       INIT(this,
+               .public = {
+                       .provider = {
+                               .get_triplet = (void*)return_false,
+                               .get_quintuplet = _get_quintuplet,
+                               .resync = _resync,
+                               .is_pseudonym = (void*)return_null,
+                               .gen_pseudonym = (void*)return_null,
+                               .is_reauth = (void*)return_null,
+                               .gen_reauth = (void*)return_null,
+                       },
+                       .destroy = _destroy,
+               },
+               .f = f,
+       );
        /* use an offset to accept clock skew between client/server without resync */
        eap_aka_3gpp2_get_sqn(this->sqn, 180);