Migrated eap_identity plugin to INIT/METHOD macros
This commit is contained in:
@@ -59,11 +59,8 @@ struct eap_identity_header_t {
|
|||||||
u_int8_t data[];
|
u_int8_t data[];
|
||||||
} __attribute__((__packed__));
|
} __attribute__((__packed__));
|
||||||
|
|
||||||
/**
|
METHOD(eap_method_t, process_peer, status_t,
|
||||||
* Implementation of eap_method_t.process for the peer
|
private_eap_identity_t *this, eap_payload_t *in, eap_payload_t **out)
|
||||||
*/
|
|
||||||
static status_t process_peer(private_eap_identity_t *this,
|
|
||||||
eap_payload_t *in, eap_payload_t **out)
|
|
||||||
{
|
{
|
||||||
chunk_t id;
|
chunk_t id;
|
||||||
eap_identity_header_t *hdr;
|
eap_identity_header_t *hdr;
|
||||||
@@ -83,20 +80,15 @@ static status_t process_peer(private_eap_identity_t *this,
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(eap_method_t, initiate_peer, status_t,
|
||||||
* Implementation of eap_method_t.initiate for the peer
|
private_eap_identity_t *this, eap_payload_t **out)
|
||||||
*/
|
|
||||||
static status_t initiate_peer(private_eap_identity_t *this, eap_payload_t **out)
|
|
||||||
{
|
{
|
||||||
/* peer never initiates */
|
/* peer never initiates */
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(eap_method_t, process_server, status_t,
|
||||||
* Implementation of eap_method_t.process for the server
|
private_eap_identity_t *this, eap_payload_t *in, eap_payload_t **out)
|
||||||
*/
|
|
||||||
static status_t process_server(private_eap_identity_t *this,
|
|
||||||
eap_payload_t *in, eap_payload_t **out)
|
|
||||||
{
|
{
|
||||||
chunk_t data;
|
chunk_t data;
|
||||||
|
|
||||||
@@ -108,10 +100,8 @@ static status_t process_server(private_eap_identity_t *this,
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(eap_method_t, initiate_server, status_t,
|
||||||
* Implementation of eap_method_t.initiate for the server
|
private_eap_identity_t *this, eap_payload_t **out)
|
||||||
*/
|
|
||||||
static status_t initiate_server(private_eap_identity_t *this, eap_payload_t **out)
|
|
||||||
{
|
{
|
||||||
eap_identity_header_t hdr;
|
eap_identity_header_t hdr;
|
||||||
|
|
||||||
@@ -125,19 +115,15 @@ static status_t initiate_server(private_eap_identity_t *this, eap_payload_t **ou
|
|||||||
return NEED_MORE;
|
return NEED_MORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(eap_method_t, get_type, eap_type_t,
|
||||||
* Implementation of eap_method_t.get_type.
|
private_eap_identity_t *this, u_int32_t *vendor)
|
||||||
*/
|
|
||||||
static eap_type_t get_type(private_eap_identity_t *this, u_int32_t *vendor)
|
|
||||||
{
|
{
|
||||||
*vendor = 0;
|
*vendor = 0;
|
||||||
return EAP_IDENTITY;
|
return EAP_IDENTITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(eap_method_t, get_msk, status_t,
|
||||||
* Implementation of eap_method_t.get_msk.
|
private_eap_identity_t *this, chunk_t *msk)
|
||||||
*/
|
|
||||||
static status_t get_msk(private_eap_identity_t *this, chunk_t *msk)
|
|
||||||
{
|
{
|
||||||
if (this->identity.ptr)
|
if (this->identity.ptr)
|
||||||
{
|
{
|
||||||
@@ -147,56 +133,42 @@ static status_t get_msk(private_eap_identity_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_identity_t *this)
|
||||||
*/
|
|
||||||
static bool is_mutual(private_eap_identity_t *this)
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(eap_method_t, destroy, void,
|
||||||
* Implementation of eap_method_t.destroy.
|
private_eap_identity_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_eap_identity_t *this)
|
|
||||||
{
|
{
|
||||||
this->peer->destroy(this->peer);
|
this->peer->destroy(this->peer);
|
||||||
free(this->identity.ptr);
|
free(this->identity.ptr);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic constructor
|
|
||||||
*/
|
|
||||||
static private_eap_identity_t *eap_identity_create(identification_t *server,
|
|
||||||
identification_t *peer)
|
|
||||||
{
|
|
||||||
private_eap_identity_t *this = malloc_thing(private_eap_identity_t);
|
|
||||||
|
|
||||||
this->public.eap_method_interface.initiate = NULL;
|
|
||||||
this->public.eap_method_interface.process = NULL;
|
|
||||||
this->public.eap_method_interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
|
|
||||||
this->public.eap_method_interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
|
|
||||||
this->public.eap_method_interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
|
|
||||||
this->public.eap_method_interface.destroy = (void(*)(eap_method_t*))destroy;
|
|
||||||
|
|
||||||
this->peer = peer->clone(peer);
|
|
||||||
this->identity = chunk_empty;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Described in header.
|
* Described in header.
|
||||||
*/
|
*/
|
||||||
eap_identity_t *eap_identity_create_peer(identification_t *server,
|
eap_identity_t *eap_identity_create_peer(identification_t *server,
|
||||||
identification_t *peer)
|
identification_t *peer)
|
||||||
{
|
{
|
||||||
private_eap_identity_t *this = eap_identity_create(server, peer);
|
private_eap_identity_t *this;
|
||||||
|
|
||||||
/* public functions */
|
INIT(this,
|
||||||
this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_peer;
|
.public = {
|
||||||
this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process_peer;
|
.eap_method_interface = {
|
||||||
|
.initiate = _initiate_peer,
|
||||||
|
.process = _process_peer,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.is_mutual = _is_mutual,
|
||||||
|
.get_msk = _get_msk,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.peer = peer->clone(peer),
|
||||||
|
.identity = chunk_empty,
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
@@ -207,11 +179,22 @@ eap_identity_t *eap_identity_create_peer(identification_t *server,
|
|||||||
eap_identity_t *eap_identity_create_server(identification_t *server,
|
eap_identity_t *eap_identity_create_server(identification_t *server,
|
||||||
identification_t *peer)
|
identification_t *peer)
|
||||||
{
|
{
|
||||||
private_eap_identity_t *this = eap_identity_create(server, peer);
|
private_eap_identity_t *this;
|
||||||
|
|
||||||
/* public functions */
|
INIT(this,
|
||||||
this->public.eap_method_interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate_server;
|
.public = {
|
||||||
this->public.eap_method_interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process_server;
|
.eap_method_interface = {
|
||||||
|
.initiate = _initiate_server,
|
||||||
|
.process = _process_server,
|
||||||
|
.get_type = _get_type,
|
||||||
|
.is_mutual = _is_mutual,
|
||||||
|
.get_msk = _get_msk,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.peer = peer->clone(peer),
|
||||||
|
.identity = chunk_empty,
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "eap_identity_plugin.h"
|
#include "eap_identity_plugin.h"
|
||||||
|
|
||||||
#include "eap_identity.h"
|
#include "eap_identity.h"
|
||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
|
|
||||||
/**
|
METHOD(plugin_t, destroy, void,
|
||||||
* Implementation of plugin_t.destroy
|
eap_identity_plugin_t *this)
|
||||||
*/
|
|
||||||
static void destroy(eap_identity_plugin_t *this)
|
|
||||||
{
|
{
|
||||||
charon->eap->remove_method(charon->eap,
|
charon->eap->remove_method(charon->eap,
|
||||||
(eap_constructor_t)eap_identity_create_server);
|
(eap_constructor_t)eap_identity_create_server);
|
||||||
@@ -36,9 +33,13 @@ static void destroy(eap_identity_plugin_t *this)
|
|||||||
*/
|
*/
|
||||||
plugin_t *eap_identity_plugin_create()
|
plugin_t *eap_identity_plugin_create()
|
||||||
{
|
{
|
||||||
eap_identity_plugin_t *this = malloc_thing(eap_identity_plugin_t);
|
eap_identity_plugin_t *this;
|
||||||
|
|
||||||
this->plugin.destroy = (void(*)(plugin_t*))destroy;
|
INIT(this,
|
||||||
|
.plugin = {
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
charon->eap->add_method(charon->eap, EAP_IDENTITY, 0, EAP_SERVER,
|
charon->eap->add_method(charon->eap, EAP_IDENTITY, 0, EAP_SERVER,
|
||||||
(eap_constructor_t)eap_identity_create_server);
|
(eap_constructor_t)eap_identity_create_server);
|
||||||
|
|||||||
Reference in New Issue
Block a user