Migrated eap_mschapv2 plugin to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-04-05 14:23:59 +02:00
parent 689f887147
commit dae5a088c5
@@ -560,19 +560,15 @@ static void set_ms_length(eap_mschapv2_header_t *eap, u_int16_t len)
memcpy(&eap->ms_length, &len, sizeof(u_int16_t)); memcpy(&eap->ms_length, &len, sizeof(u_int16_t));
} }
/** METHOD(eap_method_t, initiate_peer, status_t,
* Implementation of eap_method_t.initiate for the peer private_eap_mschapv2_t *this, eap_payload_t **out)
*/
static status_t initiate_peer(private_eap_mschapv2_t *this, eap_payload_t **out)
{ {
/* peer never initiates */ /* peer never initiates */
return FAILED; return FAILED;
} }
/** METHOD(eap_method_t, initiate_server, status_t,
* Implementation of eap_method_t.initiate for the server private_eap_mschapv2_t *this, eap_payload_t **out)
*/
static status_t initiate_server(private_eap_mschapv2_t *this, eap_payload_t **out)
{ {
rng_t *rng; rng_t *rng;
eap_mschapv2_header_t *eap; eap_mschapv2_header_t *eap;
@@ -904,11 +900,8 @@ error:
return status; return status;
} }
/** METHOD(eap_method_t, process_peer, status_t,
* Implementation of eap_method_t.process for the peer private_eap_mschapv2_t *this, eap_payload_t *in, eap_payload_t **out)
*/
static status_t process_peer(private_eap_mschapv2_t *this, eap_payload_t *in,
eap_payload_t **out)
{ {
chunk_t data; chunk_t data;
eap_mschapv2_header_t *eap; eap_mschapv2_header_t *eap;
@@ -1091,11 +1084,8 @@ static status_t process_server_response(private_eap_mschapv2_t *this,
return process_server_retry(this, out); return process_server_retry(this, out);
} }
/** METHOD(eap_method_t, process_server, status_t,
* Implementation of eap_method_t.process for the server private_eap_mschapv2_t *this, eap_payload_t *in, eap_payload_t **out)
*/
static status_t process_server(private_eap_mschapv2_t *this, eap_payload_t *in,
eap_payload_t **out)
{ {
eap_mschapv2_header_t *eap; eap_mschapv2_header_t *eap;
chunk_t data; chunk_t data;
@@ -1140,19 +1130,15 @@ static status_t process_server(private_eap_mschapv2_t *this, eap_payload_t *in,
return FAILED; return FAILED;
} }
/** METHOD(eap_method_t, get_type, eap_type_t,
* Implementation of eap_method_t.get_type. private_eap_mschapv2_t *this, u_int32_t *vendor)
*/
static eap_type_t get_type(private_eap_mschapv2_t *this, u_int32_t *vendor)
{ {
*vendor = 0; *vendor = 0;
return EAP_MSCHAPV2; return EAP_MSCHAPV2;
} }
/** METHOD(eap_method_t, get_msk, status_t,
* Implementation of eap_method_t.get_msk. private_eap_mschapv2_t *this, chunk_t *msk)
*/
static status_t get_msk(private_eap_mschapv2_t *this, chunk_t *msk)
{ {
if (this->msk.ptr) if (this->msk.ptr)
{ {
@@ -1162,18 +1148,14 @@ static status_t get_msk(private_eap_mschapv2_t *this, chunk_t *msk)
return FAILED; return FAILED;
} }
/** METHOD(eap_method_t, is_mutual, bool,
* Implementation of eap_method_t.is_mutual. private_eap_mschapv2_t *this)
*/
static bool is_mutual(private_eap_mschapv2_t *this)
{ {
return FALSE; return FALSE;
} }
/** METHOD(eap_method_t, destroy, void,
* Implementation of eap_method_t.destroy. private_eap_mschapv2_t *this)
*/
static void destroy(private_eap_mschapv2_t *this)
{ {
this->peer->destroy(this->peer); this->peer->destroy(this->peer);
this->server->destroy(this->server); this->server->destroy(this->server);
@@ -1189,25 +1171,20 @@ static void destroy(private_eap_mschapv2_t *this)
*/ */
static private_eap_mschapv2_t *eap_mschapv2_create_generic(identification_t *server, identification_t *peer) static private_eap_mschapv2_t *eap_mschapv2_create_generic(identification_t *server, identification_t *peer)
{ {
private_eap_mschapv2_t *this = malloc_thing(private_eap_mschapv2_t); private_eap_mschapv2_t *this;
this->public.eap_method_interface.initiate = NULL; INIT(this,
this->public.eap_method_interface.process = NULL; .public = {
this->public.eap_method_interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type; .eap_method_interface = {
this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual; .get_type = _get_type,
this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk; .is_mutual = _is_mutual,
this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy; .get_msk = _get_msk,
.destroy = _destroy,
/* private data */ },
this->peer = peer->clone(peer); },
this->server = server->clone(server); .peer = peer->clone(peer),
this->challenge = chunk_empty; .server = server->clone(server),
this->nt_response = chunk_empty; );
this->auth_response = chunk_empty;
this->msk = chunk_empty;
this->identifier = 0;
this->mschapv2id = 0;
this->retries = 0;
return this; return this;
} }
@@ -1219,8 +1196,8 @@ eap_mschapv2_t *eap_mschapv2_create_server(identification_t *server, identificat
{ {
private_eap_mschapv2_t *this = eap_mschapv2_create_generic(server, peer); private_eap_mschapv2_t *this = eap_mschapv2_create_generic(server, peer);
this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_server; this->public.eap_method_interface.initiate = _initiate_server;
this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*, eap_payload_t**))process_server; this->public.eap_method_interface.process = _process_server;
/* generate a non-zero identifier */ /* generate a non-zero identifier */
do do
@@ -1240,8 +1217,8 @@ eap_mschapv2_t *eap_mschapv2_create_peer(identification_t *server, identificatio
{ {
private_eap_mschapv2_t *this = eap_mschapv2_create_generic(server, peer); private_eap_mschapv2_t *this = eap_mschapv2_create_generic(server, peer);
this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_peer; this->public.eap_method_interface.initiate = _initiate_peer;
this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*, eap_payload_t**))process_peer; this->public.eap_method_interface.process = _process_peer;
return &this->public; return &this->public;
} }