- removed memory allocation checks!!!

This commit is contained in:
Jan Hutter
2005-11-28 18:24:10 +00:00
parent 297c889cf3
commit 3fe058703f
24 changed files with 722 additions and 1197 deletions
+27 -58
View File
@@ -1,9 +1,7 @@
/**
* @file nonce_payload.h
*
* @brief Declaration of the class nonce_payload_t.
*
* An object of this type represents an IKEv2 Nonce-Payload.
* @brief Implementation of nonce_payload_t.
*
*/
@@ -34,32 +32,32 @@
typedef struct private_nonce_payload_t private_nonce_payload_t;
/**
* Private data of an nonce_payload_t' Object
* Private data of an nonce_payload_t object.
*
*/
struct private_nonce_payload_t {
/**
* public nonce_payload_t interface
* Public nonce_payload_t interface.
*/
nonce_payload_t public;
/**
* next payload type
* Next payload type.
*/
u_int8_t next_payload;
/**
* Critical flag
* Critical flag.
*/
bool critical;
/**
* Length of this payload
* Length of this payload.
*/
u_int16_t payload_length;
/**
* the contained nonce value
* The contained nonce value.
*/
chunk_t nonce;
@@ -67,10 +65,8 @@ struct private_nonce_payload_t {
* @brief Computes the length of this payload.
*
* @param this calling private_nonce_payload_t object
* @return
* SUCCESS in any case
*/
status_t (*compute_length) (private_nonce_payload_t *this);
void (*compute_length) (private_nonce_payload_t *this);
};
/**
@@ -111,8 +107,7 @@ encoding_rule_t nonce_payload_encodings[] = {
*/
/**
* Implements payload_t's verify function.
* See #payload_s.verify for description.
* Implementation of payload_t.verify.
*/
static status_t verify(private_nonce_payload_t *this)
{
@@ -131,8 +126,7 @@ static status_t verify(private_nonce_payload_t *this)
}
/**
* Implements nonce_payload_t's set_nonce function.
* See #nonce_payload_t.set_nonce for description.
* Implementation of nonce_payload_t.set_nonce.
*/
static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce)
{
@@ -140,10 +134,6 @@ static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce)
{
this->nonce.ptr = allocator_clone_bytes(nonce.ptr, nonce.len);
if (this->nonce.ptr == NULL)
{
return OUT_OF_RES;
}
this->nonce.len = nonce.len;
this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len;
return SUCCESS;
@@ -152,36 +142,25 @@ static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce)
}
/**
* Implements nonce_payload_t's get_nonce function.
* See #nonce_payload_t.get_nonce for description.
* Implementation of nonce_payload_t.get_nonce.
*/
static status_t get_nonce(private_nonce_payload_t *this, chunk_t *nonce)
static void get_nonce(private_nonce_payload_t *this, chunk_t *nonce)
{
nonce->ptr = allocator_clone_bytes(this->nonce.ptr,this->nonce.len);
if (nonce->ptr == NULL)
{
return OUT_OF_RES;
}
nonce->len = this->nonce.len;
return SUCCESS;
}
/**
* Implements payload_t's get_encoding_rules function.
* See #payload_s.get_encoding_rules for description.
* Implementation of nonce_payload_t.get_encoding_rules.
*/
static status_t get_encoding_rules(private_nonce_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
static void get_encoding_rules(private_nonce_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
{
*rules = nonce_payload_encodings;
*rule_count = sizeof(nonce_payload_encodings) / sizeof(encoding_rule_t);
return SUCCESS;
}
/**
* Implements payload_t's get_type function.
* See #payload_s.get_type for description.
* Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_nonce_payload_t *this)
{
@@ -189,8 +168,7 @@ static payload_type_t get_type(private_nonce_payload_t *this)
}
/**
* Implements payload_t's get_next_type function.
* See #payload_s.get_next_type for description.
* Implementation of payload_t.get_next_type.
*/
static payload_type_t get_next_type(private_nonce_payload_t *this)
{
@@ -198,18 +176,15 @@ static payload_type_t get_next_type(private_nonce_payload_t *this)
}
/**
* Implements payload_t's set_next_type function.
* See #payload_s.set_next_type for description.
* Implementation of payload_t.set_next_type.
*/
static status_t set_next_type(private_nonce_payload_t *this,payload_type_t type)
static void set_next_type(private_nonce_payload_t *this,payload_type_t type)
{
this->next_payload = type;
return SUCCESS;
}
/**
* Implements payload_t's get_length function.
* See #payload_s.get_length for description.
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_nonce_payload_t *this)
{
@@ -218,10 +193,9 @@ static size_t get_length(private_nonce_payload_t *this)
}
/**
* Implements payload_t's and nonce_payload_t's destroy function.
* See #payload_s.destroy or nonce_payload_s.destroy for description.
* Implementation of payload_t.destroy and nonce_payload_t.destroy.
*/
static status_t destroy(private_nonce_payload_t *this)
static void destroy(private_nonce_payload_t *this)
{
if (this->nonce.ptr != NULL)
{
@@ -229,7 +203,6 @@ static status_t destroy(private_nonce_payload_t *this)
}
allocator_free(this);
return SUCCESS;
}
/*
@@ -238,24 +211,20 @@ static status_t destroy(private_nonce_payload_t *this)
nonce_payload_t *nonce_payload_create()
{
private_nonce_payload_t *this = allocator_alloc_thing(private_nonce_payload_t);
if (this == NULL)
{
return NULL;
}
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
this->public.payload_interface.get_encoding_rules = (status_t (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
this->public.payload_interface.get_encoding_rules = (void (*) (payload_t *, encoding_rule_t **, size_t *) ) get_encoding_rules;
this->public.payload_interface.get_length = (size_t (*) (payload_t *)) get_length;
this->public.payload_interface.get_next_type = (payload_type_t (*) (payload_t *)) get_next_type;
this->public.payload_interface.set_next_type = (status_t (*) (payload_t *,payload_type_t)) set_next_type;
this->public.payload_interface.set_next_type = (void (*) (payload_t *,payload_type_t)) set_next_type;
this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
this->public.payload_interface.destroy = (status_t (*) (payload_t *))destroy;
this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
/* public functions */
this->public.destroy = (status_t (*) (nonce_payload_t *)) destroy;
this->public.destroy = (void (*) (nonce_payload_t *)) destroy;
this->public.set_nonce = (status_t (*) (nonce_payload_t *,chunk_t)) set_nonce;
this->public.get_nonce = (status_t (*) (nonce_payload_t *,chunk_t*)) get_nonce;
this->public.get_nonce = (void (*) (nonce_payload_t *,chunk_t*)) get_nonce;
/* private variables */
this->critical = FALSE;