diff options
author | Jan Hutter <jhutter@hsr.ch> | 2005-11-28 18:24:10 +0000 |
---|---|---|
committer | Jan Hutter <jhutter@hsr.ch> | 2005-11-28 18:24:10 +0000 |
commit | 3fe058703ffe537dfdf68b9ad4d9143644230321 (patch) | |
tree | 2c64a96cf7130f7422430d6abafbcb3173d41ace /Source/charon/encoding/payloads/transform_attribute.c | |
parent | 297c889cf33b3bd3241d33fa32b2fbf50c9789c1 (diff) | |
download | strongswan-3fe058703ffe537dfdf68b9ad4d9143644230321.tar.bz2 strongswan-3fe058703ffe537dfdf68b9ad4d9143644230321.tar.xz |
- removed memory allocation checks!!!
Diffstat (limited to 'Source/charon/encoding/payloads/transform_attribute.c')
-rw-r--r-- | Source/charon/encoding/payloads/transform_attribute.c | 121 |
1 files changed, 41 insertions, 80 deletions
diff --git a/Source/charon/encoding/payloads/transform_attribute.c b/Source/charon/encoding/payloads/transform_attribute.c index f949fca9c..40f06bd8c 100644 --- a/Source/charon/encoding/payloads/transform_attribute.c +++ b/Source/charon/encoding/payloads/transform_attribute.c @@ -1,9 +1,7 @@ /** * @file transform_attribute.c * - * @brief Declaration of the class transform_attribute_t. - * - * An object of this type represents an IKEv2 TRANSFORM attribute. + * @brief Implementation of transform_attribute_t. * */ @@ -34,17 +32,17 @@ typedef struct private_transform_attribute_t private_transform_attribute_t; /** - * Private data of an transform_attribute_t Object + * Private data of an transform_attribute_t object. * */ struct private_transform_attribute_t { /** - * public transform_attribute_t interface + * Public transform_attribute_t interface. */ transform_attribute_t public; /** - * Attribute Format Flag + * Attribute Format Flag. * * - TRUE means value is stored in attribute_length_or_value * - FALSE means value is stored in attribute_value @@ -52,25 +50,23 @@ struct private_transform_attribute_t { bool attribute_format; /** - * Type of the attribute + * Type of the attribute. */ u_int16_t attribute_type; /** - * Attribute Length if attribute_format is 0, attribute Value otherwise + * Attribute Length if attribute_format is 0, attribute Value otherwise. */ u_int16_t attribute_length_or_value; /** - * Attribute value as chunk if attribute_format is 0 (FALSE) + * Attribute value as chunk if attribute_format is 0 (FALSE). */ chunk_t attribute_value; }; - - /** - * string mappings for transform_attribute_type_t + * String mappings for transform_attribute_type_t. */ mapping_t transform_attribute_type_m[] = { {ATTRIBUTE_UNDEFINED, "ATTRIBUTE_UNDEFINED"}, @@ -79,7 +75,7 @@ mapping_t transform_attribute_type_m[] = { }; /** - * Encoding rules to parse or generate a Transform attribute + * Encoding rules to parse or generate a Transform attribute. * * The defined offsets are the positions in a object of type * private_transform_attribute_t. @@ -109,8 +105,7 @@ encoding_rule_t transform_attribute_encodings[] = { */ /** - * Implements payload_t's verify function. - * See #payload_s.verify for description. + * Implementation of payload_t.verify. */ static status_t verify(private_transform_attribute_t *this) { @@ -123,20 +118,16 @@ static status_t verify(private_transform_attribute_t *this) } /** - * Implements payload_t's get_encoding_rules function. - * See #payload_s.get_encoding_rules for description. + * Implementation of payload_t.get_encoding_rules. */ -static status_t get_encoding_rules(private_transform_attribute_t *this, encoding_rule_t **rules, size_t *rule_count) +static void get_encoding_rules(private_transform_attribute_t *this, encoding_rule_t **rules, size_t *rule_count) { *rules = transform_attribute_encodings; *rule_count = sizeof(transform_attribute_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_transform_attribute_t *this) { @@ -144,8 +135,7 @@ static payload_type_t get_type(private_transform_attribute_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_transform_attribute_t *this) { @@ -153,17 +143,14 @@ static payload_type_t get_next_type(private_transform_attribute_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_transform_attribute_t *this,payload_type_t type) +static void set_next_type(private_transform_attribute_t *this,payload_type_t type) { - return SUCCESS; } /** - * Implements payload_t's get_length function. - * See #payload_s.get_length for description. + * Implementation of transform_attribute_t.get_length. */ static size_t get_length(private_transform_attribute_t *this) { @@ -174,11 +161,11 @@ static size_t get_length(private_transform_attribute_t *this) } return (this->attribute_length_or_value + 4); } + /** - * Implements transform_attribute_t's set_value function. - * See #transform_attribute_s.set_value for description. + * Implementation of transform_attribute_t.set_value_chunk. */ -static status_t set_value_chunk(private_transform_attribute_t *this, chunk_t value) +static void set_value_chunk(private_transform_attribute_t *this, chunk_t value) { if (this->attribute_value.ptr != NULL) { @@ -192,10 +179,6 @@ static status_t set_value_chunk(private_transform_attribute_t *this, chunk_t val if (value.len > 2) { this->attribute_value.ptr = allocator_clone_bytes(value.ptr,value.len); - if (this->attribute_value.ptr == NULL) - { - return OUT_OF_RES; - } this->attribute_value.len = value.len; this->attribute_length_or_value = value.len; /* attribute has not a fixed length */ @@ -205,14 +188,12 @@ static status_t set_value_chunk(private_transform_attribute_t *this, chunk_t val { memcpy(&(this->attribute_length_or_value),value.ptr,value.len); } - return SUCCESS; } /** - * Implements transform_attribute_t's set_value function. - * See #transform_attribute_s.set_value for description. + * Implementation of transform_attribute_t.set_value. */ -static status_t set_value(private_transform_attribute_t *this, u_int16_t value) +static void set_value(private_transform_attribute_t *this, u_int16_t value) { if (this->attribute_value.ptr != NULL) { @@ -223,12 +204,10 @@ static status_t set_value(private_transform_attribute_t *this, u_int16_t value) } this->attribute_length_or_value = value; - return SUCCESS; } /** - * Implements transform_attribute_t's get_value_chunk function. - * See #transform_attribute_s.get_value_chunk for description. + * Implementation of transform_attribute_t.get_value_chunk. */ static chunk_t get_value_chunk (private_transform_attribute_t *this) { @@ -249,8 +228,7 @@ static chunk_t get_value_chunk (private_transform_attribute_t *this) } /** - * Implements transform_attribute_t's get_value function. - * See #transform_attribute_s.get_value for description. + * Implementation of transform_attribute_t.get_value. */ static u_int16_t get_value (private_transform_attribute_t *this) { @@ -259,18 +237,15 @@ static u_int16_t get_value (private_transform_attribute_t *this) /** - * Implements transform_attribute_t's set_attribute_type function. - * See #transform_attribute_s.set_attribute_type for description. + * Implementation of transform_attribute_t.set_attribute_type. */ -static status_t set_attribute_type (private_transform_attribute_t *this, u_int16_t type) +static void set_attribute_type (private_transform_attribute_t *this, u_int16_t type) { this->attribute_type = type & 0x7FFF; - return SUCCESS; } /** - * Implements transform_attribute_t's get_attribute_type function. - * See #transform_attribute_s.get_attribute_type for description. + * Implementation of transform_attribute_t.get_attribute_type. */ static u_int16_t get_attribute_type (private_transform_attribute_t *this) { @@ -278,10 +253,9 @@ static u_int16_t get_attribute_type (private_transform_attribute_t *this) } /** - * Implements transform_attribute_t's clone function. - * See transform_attribute_s.clone for description. + * Implementation of transform_attribute_t.clone. */ -static status_t clone(private_transform_attribute_t *this,transform_attribute_t **clone) +static void clone(private_transform_attribute_t *this,transform_attribute_t **clone) { private_transform_attribute_t *new_clone; @@ -295,61 +269,48 @@ static status_t clone(private_transform_attribute_t *this,transform_attribute_t { new_clone->attribute_value.ptr = allocator_clone_bytes(this->attribute_value.ptr,this->attribute_value.len); new_clone->attribute_value.len = this->attribute_value.len; - if (new_clone->attribute_value.ptr == NULL) - { - new_clone->public.destroy(&(new_clone->public)); - return OUT_OF_RES; - } } *clone = (transform_attribute_t *) new_clone; - return SUCCESS; } /** - * Implements payload_t's and transform_attribute_t's destroy function. - * See #payload_s.destroy or transform_attribute_s.destroy for description. + * Implementation of transform_attribute_t.destroy and payload_t.destroy. */ -static status_t destroy(private_transform_attribute_t *this) +static void destroy(private_transform_attribute_t *this) { if (this->attribute_value.ptr != NULL) { allocator_free(this->attribute_value.ptr); } allocator_free(this); - - return SUCCESS; } /* - * Described in header + * Described in header. */ transform_attribute_t *transform_attribute_create() { private_transform_attribute_t *this = allocator_alloc_thing(private_transform_attribute_t); - if (this == NULL) - { - return NULL; - } - + /* payload interface */ 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.set_value_chunk = (status_t (*) (transform_attribute_t *,chunk_t)) set_value_chunk; - this->public.set_value = (status_t (*) (transform_attribute_t *,u_int16_t)) set_value; + this->public.set_value_chunk = (void (*) (transform_attribute_t *,chunk_t)) set_value_chunk; + this->public.set_value = (void (*) (transform_attribute_t *,u_int16_t)) set_value; this->public.get_value_chunk = (chunk_t (*) (transform_attribute_t *)) get_value_chunk; this->public.get_value = (u_int16_t (*) (transform_attribute_t *)) get_value; - this->public.set_attribute_type = (status_t (*) (transform_attribute_t *,u_int16_t type)) set_attribute_type; + this->public.set_attribute_type = (void (*) (transform_attribute_t *,u_int16_t type)) set_attribute_type; this->public.get_attribute_type = (u_int16_t (*) (transform_attribute_t *)) get_attribute_type; - this->public.clone = (status_t (*) (transform_attribute_t *,transform_attribute_t **)) clone; - this->public.destroy = (status_t (*) (transform_attribute_t *)) destroy; + this->public.clone = (void (*) (transform_attribute_t *,transform_attribute_t **)) clone; + this->public.destroy = (void (*) (transform_attribute_t *)) destroy; /* set default values of the fields */ this->attribute_format = TRUE; |