Migrated simaka_message to INIT/METHOD macros
This commit is contained in:
@@ -198,34 +198,26 @@ struct private_simaka_message_t {
|
|||||||
chunk_t iv;
|
chunk_t iv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, is_request, bool,
|
||||||
* Implementation of simaka_message_t.is_request
|
private_simaka_message_t *this)
|
||||||
*/
|
|
||||||
static bool is_request(private_simaka_message_t *this)
|
|
||||||
{
|
{
|
||||||
return this->hdr->code == EAP_REQUEST;
|
return this->hdr->code == EAP_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, get_identifier, u_int8_t,
|
||||||
* Implementation of simaka_message_t.get_identifier
|
private_simaka_message_t *this)
|
||||||
*/
|
|
||||||
static u_int8_t get_identifier(private_simaka_message_t *this)
|
|
||||||
{
|
{
|
||||||
return this->hdr->identifier;
|
return this->hdr->identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, get_subtype, simaka_subtype_t,
|
||||||
* Implementation of simaka_message_t.get_subtype
|
private_simaka_message_t *this)
|
||||||
*/
|
|
||||||
static simaka_subtype_t get_subtype(private_simaka_message_t *this)
|
|
||||||
{
|
{
|
||||||
return this->hdr->subtype;
|
return this->hdr->subtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, get_type, eap_type_t,
|
||||||
* Implementation of simaka_message_t.get_type
|
private_simaka_message_t *this)
|
||||||
*/
|
|
||||||
static eap_type_t get_type(private_simaka_message_t *this)
|
|
||||||
{
|
{
|
||||||
return this->hdr->type;
|
return this->hdr->type;
|
||||||
}
|
}
|
||||||
@@ -243,21 +235,16 @@ static bool attr_enum_filter(void *null, attr_t **in, simaka_attribute_t *type,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, create_attribute_enumerator, enumerator_t*,
|
||||||
* Implementation of simaka_message_t.create_attribute_enumerator
|
private_simaka_message_t *this)
|
||||||
*/
|
|
||||||
static enumerator_t* create_attribute_enumerator(private_simaka_message_t *this)
|
|
||||||
{
|
{
|
||||||
return enumerator_create_filter(
|
return enumerator_create_filter(
|
||||||
this->attributes->create_enumerator(this->attributes),
|
this->attributes->create_enumerator(this->attributes),
|
||||||
(void*)attr_enum_filter, NULL, NULL);
|
(void*)attr_enum_filter, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, add_attribute, void,
|
||||||
* Implementation of simaka_message_t.add_attribute
|
private_simaka_message_t *this, simaka_attribute_t type, chunk_t data)
|
||||||
*/
|
|
||||||
static void add_attribute(private_simaka_message_t *this,
|
|
||||||
simaka_attribute_t type, chunk_t data)
|
|
||||||
{
|
{
|
||||||
attr_t *attr;
|
attr_t *attr;
|
||||||
|
|
||||||
@@ -522,10 +509,8 @@ static bool decrypt(private_simaka_message_t *this)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, parse, bool,
|
||||||
* Implementation of simaka_message_t.parse
|
private_simaka_message_t *this)
|
||||||
*/
|
|
||||||
static bool parse(private_simaka_message_t *this)
|
|
||||||
{
|
{
|
||||||
chunk_t in;
|
chunk_t in;
|
||||||
|
|
||||||
@@ -543,10 +528,8 @@ static bool parse(private_simaka_message_t *this)
|
|||||||
return decrypt(this);
|
return decrypt(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, verify, bool,
|
||||||
* Implementation of simaka_message_t.verify
|
private_simaka_message_t *this, chunk_t sigdata)
|
||||||
*/
|
|
||||||
static bool verify(private_simaka_message_t *this, chunk_t sigdata)
|
|
||||||
{
|
{
|
||||||
chunk_t data, backup;
|
chunk_t data, backup;
|
||||||
signer_t *signer;
|
signer_t *signer;
|
||||||
@@ -616,10 +599,8 @@ static bool verify(private_simaka_message_t *this, chunk_t sigdata)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, generate, chunk_t,
|
||||||
* Implementation of simaka_message_t.generate
|
private_simaka_message_t *this, chunk_t sigdata)
|
||||||
*/
|
|
||||||
static chunk_t generate(private_simaka_message_t *this, chunk_t sigdata)
|
|
||||||
{
|
{
|
||||||
/* buffers large enough for messages we generate */
|
/* buffers large enough for messages we generate */
|
||||||
char out_buf[1024], encr_buf[512];
|
char out_buf[1024], encr_buf[512];
|
||||||
@@ -849,10 +830,8 @@ static chunk_t generate(private_simaka_message_t *this, chunk_t sigdata)
|
|||||||
return chunk_clone(out);
|
return chunk_clone(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(simaka_message_t, destroy, void,
|
||||||
* Implementation of simaka_message_t.destroy.
|
private_simaka_message_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_simaka_message_t *this)
|
|
||||||
{
|
{
|
||||||
this->attributes->destroy_function(this->attributes, free);
|
this->attributes->destroy_function(this->attributes, free);
|
||||||
free(this->hdr);
|
free(this->hdr);
|
||||||
@@ -886,27 +865,24 @@ static simaka_message_t *simaka_message_create_data(chunk_t data,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this = malloc_thing(private_simaka_message_t);
|
INIT(this,
|
||||||
|
.public = {
|
||||||
this->public.is_request = (bool(*)(simaka_message_t*))is_request;
|
.is_request = _is_request,
|
||||||
this->public.get_identifier = (u_int8_t(*)(simaka_message_t*))get_identifier;
|
.get_identifier = _get_identifier,
|
||||||
this->public.get_type = (eap_type_t(*)(simaka_message_t*))get_type;
|
.get_type = _get_type,
|
||||||
this->public.get_subtype = (simaka_subtype_t(*)(simaka_message_t*))get_subtype;
|
.get_subtype = _get_subtype,
|
||||||
this->public.create_attribute_enumerator = (enumerator_t*(*)(simaka_message_t*))create_attribute_enumerator;
|
.create_attribute_enumerator = _create_attribute_enumerator,
|
||||||
this->public.add_attribute = (void(*)(simaka_message_t*, simaka_attribute_t type, chunk_t data))add_attribute;
|
.add_attribute = _add_attribute,
|
||||||
this->public.parse = (bool(*)(simaka_message_t*))parse;
|
.parse = _parse,
|
||||||
this->public.verify = (bool(*)(simaka_message_t*, chunk_t sigdata))verify;
|
.verify = _verify,
|
||||||
this->public.generate = (chunk_t(*)(simaka_message_t*, chunk_t sigdata))generate;
|
.generate = _generate,
|
||||||
this->public.destroy = (void(*)(simaka_message_t*))destroy;
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
this->attributes = linked_list_create();
|
.attributes = linked_list_create(),
|
||||||
this->encrypted = FALSE;
|
.crypto = crypto,
|
||||||
this->crypto = crypto;
|
.p_bit = TRUE,
|
||||||
this->p_bit = TRUE;
|
.hdr = malloc(data.len),
|
||||||
this->mac = chunk_empty;
|
);
|
||||||
this->encr = chunk_empty;
|
|
||||||
this->iv = chunk_empty;
|
|
||||||
this->hdr = malloc(data.len);
|
|
||||||
memcpy(this->hdr, hdr, data.len);
|
memcpy(this->hdr, hdr, data.len);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
|
|||||||
Reference in New Issue
Block a user