aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'Source/charon/encoding')
-rw-r--r--Source/charon/encoding/generator.h2
-rw-r--r--Source/charon/encoding/payloads/encodings.c4
-rw-r--r--Source/charon/encoding/payloads/encodings.h74
-rw-r--r--Source/charon/encoding/payloads/encryption_payload.c197
-rw-r--r--Source/charon/encoding/payloads/encryption_payload.h27
-rw-r--r--Source/charon/encoding/payloads/ike_header.c128
-rw-r--r--Source/charon/encoding/payloads/ike_header.h87
-rw-r--r--Source/charon/encoding/payloads/ke_payload.c112
-rw-r--r--Source/charon/encoding/payloads/ke_payload.h38
-rw-r--r--Source/charon/encoding/payloads/nonce_payload.c85
-rw-r--r--Source/charon/encoding/payloads/nonce_payload.h29
-rw-r--r--Source/charon/encoding/payloads/notify_payload.c144
-rw-r--r--Source/charon/encoding/payloads/notify_payload.h48
-rw-r--r--Source/charon/encoding/payloads/payload.h50
-rw-r--r--Source/charon/encoding/payloads/proposal_substructure.c210
-rw-r--r--Source/charon/encoding/payloads/proposal_substructure.h56
-rw-r--r--Source/charon/encoding/payloads/sa_payload.c108
-rw-r--r--Source/charon/encoding/payloads/sa_payload.h38
-rw-r--r--Source/charon/encoding/payloads/transform_attribute.c121
-rw-r--r--Source/charon/encoding/payloads/transform_attribute.h55
-rw-r--r--Source/charon/encoding/payloads/transform_substructure.c210
-rw-r--r--Source/charon/encoding/payloads/transform_substructure.h68
22 files changed, 699 insertions, 1192 deletions
diff --git a/Source/charon/encoding/generator.h b/Source/charon/encoding/generator.h
index 1db9570de..b3163e671 100644
--- a/Source/charon/encoding/generator.h
+++ b/Source/charon/encoding/generator.h
@@ -41,7 +41,7 @@
typedef struct generator_t generator_t;
/**
- *A generator_t object which generates payloads of specific type.
+ * A generator_t class used to generate IKEv2 payloads.
*
* @ingroup encoding
*/
diff --git a/Source/charon/encoding/payloads/encodings.c b/Source/charon/encoding/payloads/encodings.c
index 4747ddc22..ab8c3f70e 100644
--- a/Source/charon/encoding/payloads/encodings.c
+++ b/Source/charon/encoding/payloads/encodings.c
@@ -1,8 +1,7 @@
/**
* @file encodings.c
*
- * @brief Type definitions for parser and generator,
- * also payload types are defined here.
+ * @brief Encoding types of fields in a IKEv2 payload.
*
*/
@@ -51,4 +50,3 @@ mapping_t encoding_type_m[] = {
{NONCE_DATA, "NONCE_DATA"},
{MAPPING_END, NULL}
};
-
diff --git a/Source/charon/encoding/payloads/encodings.h b/Source/charon/encoding/payloads/encodings.h
index 92fdc77a5..309527b38 100644
--- a/Source/charon/encoding/payloads/encodings.h
+++ b/Source/charon/encoding/payloads/encodings.h
@@ -1,13 +1,7 @@
/**
* @file encodings.h
*
- * @brief Type definitions for parser and generator,
- * also payload types are defined here.
- *
- * Header is parsed like a payload and gets its one payload_id
- * from PRIVATE USE space. Also the substructures
- * of specific payload types get their own payload_id
- * from PRIVATE_USE space. See RFC for mor informations.
+ * @brief Encoding types of fields in a IKEv2 payload.
*
*/
@@ -41,10 +35,17 @@ typedef enum encoding_type_t encoding_type_t;
* Each field of an IKEv2-Message (in header or payload)
* which has to be parsed or generated differently has its own
* type defined here.
+ *
+ * Header is parsed like a payload and gets its one payload_id
+ * from PRIVATE USE space. Also the substructures
+ * of specific payload types get their own payload_id
+ * from PRIVATE_USE space. See IKEv2-Draft for more informations.
+ *
+ * @ingroup payloads
*/
enum encoding_type_t{
/**
- * Representing a 4 Bit unsigned int value
+ * Representing a 4 Bit unsigned int value.
*
*
* When generating it must be changed from host to network order.
@@ -57,7 +58,7 @@ enum encoding_type_t{
*/
U_INT_4,
/**
- * Representing a 8 Bit unsigned int value
+ * Representing a 8 Bit unsigned int value.
*
*
* When generating it must be changed from host to network order.
@@ -70,7 +71,7 @@ enum encoding_type_t{
*/
U_INT_8,
/**
- * Representing a 16 Bit unsigned int value
+ * Representing a 16 Bit unsigned int value.
*
*
* When generating it must be changed from host to network order.
@@ -83,7 +84,7 @@ enum encoding_type_t{
*/
U_INT_16,
/**
- * Representing a 32 Bit unsigned int value
+ * Representing a 32 Bit unsigned int value.
*
* When generating it must be changed from host to network order.
* The value is read from the associated data struct.
@@ -96,7 +97,7 @@ enum encoding_type_t{
U_INT_32,
/**
- * Representing a 64 Bit unsigned int value
+ * Representing a 64 Bit unsigned int value.
*
* When generating it must be changed from host to network order.
* The value is read from the associated data struct.
@@ -108,7 +109,7 @@ enum encoding_type_t{
*/
U_INT_64,
/**
- * @brief represents a RESERVED_BIT used in FLAG-Bytes
+ * @brief represents a RESERVED_BIT used in FLAG-Bytes.
*
* When generating, the next bit is set to zero and the current write
* position is moved one bit forward.
@@ -121,7 +122,7 @@ enum encoding_type_t{
*/
RESERVED_BIT,
/**
- * @brief represents a RESERVED_BYTE
+ * @brief represents a RESERVED_BYTE.
*
* When generating, the next byte is set to zero and the current write
* position is moved one byte forward.
@@ -146,7 +147,7 @@ enum encoding_type_t{
*/
FLAG,
/**
- * Representating a length field of a payload
+ * Representating a length field of a payload.
*
* When generating it must be changed from host to network order.
* The value is read from the associated data struct.
@@ -158,7 +159,7 @@ enum encoding_type_t{
*/
PAYLOAD_LENGTH,
/**
- * Representating a length field of a header
+ * Representating a length field of a header.
*
* When generating it must be changed from host to network order.
* The value is read from the associated data struct.
@@ -170,7 +171,7 @@ enum encoding_type_t{
*/
HEADER_LENGTH,
/**
- * Representating a spi size field
+ * Representating a spi size field.
*
* When generating it must be changed from host to network order.
* The value is read from the associated data struct.
@@ -182,7 +183,7 @@ enum encoding_type_t{
*/
SPI_SIZE,
/**
- * Representating a spi field
+ * Representating a spi field.
*
* When generating the content of the chunkt pointing to
* is written.
@@ -191,7 +192,7 @@ enum encoding_type_t{
*/
SPI,
/**
- * Representating a Key Exchange Data field
+ * Representating a Key Exchange Data field.
*
* When generating the content of the chunkt pointing to
* is written.
@@ -200,7 +201,7 @@ enum encoding_type_t{
*/
KEY_EXCHANGE_DATA,
/**
- * Representating a Notification field
+ * Representating a Notification field.
*
* When generating the content of the chunkt pointing to
* is written.
@@ -209,7 +210,7 @@ enum encoding_type_t{
*/
NOTIFICATION_DATA,
/**
- * Representating one or more proposal substructures
+ * Representating one or more proposal substructures.
*
* The offset points to a linked_list_t pointer.
*
@@ -221,7 +222,7 @@ enum encoding_type_t{
*/
PROPOSALS,
/**
- * Representating one or more transform substructures
+ * Representating one or more transform substructures.
*
* The offset points to a linked_list_t pointer.
*
@@ -233,7 +234,7 @@ enum encoding_type_t{
*/
TRANSFORMS,
/**
- * Representating one or more Attributes of a transform substructure
+ * Representating one or more Attributes of a transform substructure.
*
* The offset points to a linked_list_t pointer.
*
@@ -258,7 +259,7 @@ enum encoding_type_t{
ATTRIBUTE_FORMAT,
/**
* Representing a 15 Bit unsigned int value used as attribute type
- * in an attribute transform
+ * in an attribute transform.
*
*
* When generating it must be changed from host to network order.
@@ -274,7 +275,7 @@ enum encoding_type_t{
/**
* Depending on the field of type ATTRIBUTE_FORMAT
* this field contains the length or the value of an transform attribute.
- * Its stored in a 16 unsigned integer field
+ * Its stored in a 16 unsigned integer field.
*
* When generating it must be changed from host to network order.
* The value is read from the associated data struct.
@@ -289,7 +290,7 @@ enum encoding_type_t{
/**
* Depending on the field of type ATTRIBUTE_FORMAT
* this field is available or missing and so parsed/generated
- * or not parsed/not generated
+ * or not parsed/not generated.
*
* When generating the content of the chunkt pointing to
* is written.
@@ -299,7 +300,7 @@ enum encoding_type_t{
ATTRIBUTE_VALUE,
/**
- * Representating a Nonce Data field
+ * Representating a Nonce Data field.
*
* When generating the content of the chunkt pointing to
* is written.
@@ -309,7 +310,7 @@ enum encoding_type_t{
NONCE_DATA,
/**
- * Representating an IKE_SPI field in an IKEv2 Header
+ * Representating an IKE_SPI field in an IKEv2 Header.
*
* When generating the value of the u_int64_t pointing to
* is written (host and networ order is not changed).
@@ -327,24 +328,27 @@ enum encoding_type_t{
*/
extern mapping_t encoding_type_m[];
+typedef struct encoding_rule_t encoding_rule_t;
+
/**
* An encoding rule is a mapping of a specific encoding type to
* a location in the data struct where the current field is stored to
* or read from.
*
- * For examples see directory encodings/.
+ * For examples see files in this directory.
*
* This rules are used by parser and generator.
+ *
+ * @ingroup payloads
*/
-typedef struct encoding_rule_t encoding_rule_t;
-
struct encoding_rule_t {
/**
- * Encoding type
+ * Encoding type.
*/
encoding_type_t type;
+
/**
- * Offset in the data struct
+ * Offset in the data struct.
*
* When parsing, data are written to this offset of the
* data struct.
@@ -355,8 +359,4 @@ struct encoding_rule_t {
u_int32_t offset;
};
-
-
-
-
#endif /*ENCODINGS_H_*/
diff --git a/Source/charon/encoding/payloads/encryption_payload.c b/Source/charon/encoding/payloads/encryption_payload.c
index d94576b61..c6a08af1a 100644
--- a/Source/charon/encoding/payloads/encryption_payload.c
+++ b/Source/charon/encoding/payloads/encryption_payload.c
@@ -40,12 +40,12 @@
typedef struct private_encryption_payload_t private_encryption_payload_t;
/**
- * Private data of an encryption_payload_t' Object
+ * Private data of an encryption_payload_t' Object.
*
*/
struct private_encryption_payload_t {
/**
- * public encryption_payload_t interface
+ * Public encryption_payload_t interface.
*/
encryption_payload_t public;
@@ -58,7 +58,7 @@ struct private_encryption_payload_t {
u_int8_t next_payload;
/**
- * Critical flag
+ * Critical flag.
*/
bool critical;
@@ -68,33 +68,33 @@ struct private_encryption_payload_t {
u_int16_t payload_length;
/**
- * initialization vector
+ * Initialization vector.
*/
chunk_t iv;
/**
- * integrity checksum
+ * Integrity checksum.
*/
chunk_t checksum;
/**
- * chunk containing the iv, data, padding,
- * and (an eventually not calculated) signature
+ * Chunk containing the iv, data, padding,
+ * and (an eventually not calculated) signature.
*/
chunk_t encrypted;
/**
- * chunk containing the data in decrypted (unpadded) form
+ * Chunk containing the data in decrypted (unpadded) form.
*/
chunk_t decrypted;
/**
- * signer set by set_signer
+ * Signer set by set_signer.
*/
signer_t *signer;
/**
- * Contained payloads of this encrpytion_payload
+ * Contained payloads of this encrpytion_payload.
*/
linked_list_t *payloads;
@@ -102,24 +102,20 @@ struct private_encryption_payload_t {
* @brief Computes the length of this payload.
*
* @param this calling private_encryption_payload_t object
- * @return
- * SUCCESS in any case
*/
- status_t (*compute_length) (private_encryption_payload_t *this);
+ void (*compute_length) (private_encryption_payload_t *this);
/**
* @brief Generate payloads (unencrypted) in chunk decrypted.
*
* @param this calling private_encryption_payload_t object
- * @return
- * SUCCESS in any case
*/
- status_t (*generate) (private_encryption_payload_t *this);
+ void (*generate) (private_encryption_payload_t *this);
status_t (*parse) (private_encryption_payload_t *this);
};
/**
- * Encoding rules to parse or generate a IKEv2-Encryption Payload
+ * Encoding rules to parse or generate a IKEv2-Encryption Payload.
*
* The defined offsets are the positions in a object of type
* private_encryption_payload_t.
@@ -164,8 +160,7 @@ encoding_rule_t encryption_payload_encodings[] = {
*/
/**
- * Implements payload_t's verify function.
- * See #payload_s.verify for description.
+ * Implementation of payload_t.verify.
*/
static status_t verify(private_encryption_payload_t *this)
{
@@ -225,18 +220,15 @@ static status_t verify(private_encryption_payload_t *this)
}
/**
- * implements payload_t.destroy
+ * Implementation of payload_t.destroy.
*/
-static status_t destroy(private_encryption_payload_t *this)
+static void destroy(private_encryption_payload_t *this)
{
/* all proposals are getting destroyed */
while (this->payloads->get_count(this->payloads) > 0)
{
payload_t *current_payload;
- if (this->payloads->remove_last(this->payloads,(void **)&current_payload) != SUCCESS)
- {
- break;
- }
+ this->payloads->remove_last(this->payloads,(void **)&current_payload);
current_payload->destroy(current_payload);
}
this->payloads->destroy(this->payloads);
@@ -246,23 +238,19 @@ static status_t destroy(private_encryption_payload_t *this)
allocator_free(this->decrypted.ptr);
allocator_free(this->checksum.ptr);
allocator_free(this);
-
- return SUCCESS;
}
/**
- * implements payload_t.get_encoding_rules
+ * Implementation of payload_t.get_encoding_rules.
*/
-static status_t get_encoding_rules(private_encryption_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(private_encryption_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
{
*rules = encryption_payload_encodings;
*rule_count = sizeof(encryption_payload_encodings) / sizeof(encoding_rule_t);
-
- return SUCCESS;
}
/**
- * implements payload_t.get_type
+ * Implementation of payload_t.get_type.
*/
static payload_type_t get_type(private_encryption_payload_t *this)
{
@@ -270,7 +258,7 @@ static payload_type_t get_type(private_encryption_payload_t *this)
}
/**
- * implements payload_t.get_next_type
+ * Implementation of payload_t.get_next_type.
*/
static payload_type_t get_next_type(private_encryption_payload_t *this)
{
@@ -279,16 +267,16 @@ static payload_type_t get_next_type(private_encryption_payload_t *this)
}
/**
- * implements payload_t.set_next_type
+ * Implementation of payload_t.set_next_type.
*/
-static status_t set_next_type(private_encryption_payload_t *this, payload_type_t type)
+static void set_next_type(private_encryption_payload_t *this, payload_type_t type)
{
- /* set next type is not allowed, since this payload MUST be the last one */
- return FAILED;
+ /* set next type is not allowed, since this payload MUST be the last one
+ * and so nothing is done in here*/
}
/**
- * implements payload_t.get_length
+ * Implementation of payload_t.get_length.
*/
static size_t get_length(private_encryption_payload_t *this)
{
@@ -297,7 +285,7 @@ static size_t get_length(private_encryption_payload_t *this)
}
/**
- * implements encryption_payload_t.create_payload_iterator
+ * Implementation of payload_t.create_payload_iterator.
*/
static status_t create_payload_iterator (private_encryption_payload_t *this, iterator_t **iterator, bool forward)
{
@@ -305,21 +293,16 @@ static status_t create_payload_iterator (private_encryption_payload_t *this, ite
}
/**
- * implements encryption_payload_t.add_payload
+ * Implementation of payload_t.add_payload.
*/
-static status_t add_payload(private_encryption_payload_t *this, payload_t *payload)
+static void add_payload(private_encryption_payload_t *this, payload_t *payload)
{
payload_t *last_payload;
- if ((this->payloads->get_count(this->payloads) > 0) &&
- (this->payloads->get_last(this->payloads,(void **) &last_payload) != SUCCESS))
+ if (this->payloads->get_count(this->payloads) > 0)
{
- return OUT_OF_RES;
+ this->payloads->get_last(this->payloads,(void **) &last_payload);
}
- if (this->payloads->insert_last(this->payloads, payload) != SUCCESS)
- {
- return OUT_OF_RES;
- }
if (this->payloads->get_count(this->payloads) == 1)
{
this->next_payload = payload->get_type(payload);
@@ -330,11 +313,10 @@ static status_t add_payload(private_encryption_payload_t *this, payload_t *paylo
}
payload->set_next_type(payload, NO_PAYLOAD);
this->compute_length(this);
- return SUCCESS;
}
/**
- * implements encryption_payload_t.encrypt
+ * Implementation of encryption_payload_t.encrypt.
*/
static status_t encrypt(private_encryption_payload_t *this, crypter_t *crypter)
{
@@ -349,18 +331,9 @@ static status_t encrypt(private_encryption_payload_t *this, crypter_t *crypter)
/* for random data in iv and padding */
randomizer = randomizer_create();
- if (randomizer == NULL)
- {
- return OUT_OF_RES;
- }
/* build payload chunk */
- status = this->generate(this);
- if (status != SUCCESS)
- {
- randomizer->destroy(randomizer);
- return status;
- }
+ this->generate(this);
/* build padding */
padding.len = (this->decrypted.len + 1) % crypter->get_block_size(crypter);
@@ -374,12 +347,7 @@ static status_t encrypt(private_encryption_payload_t *this, crypter_t *crypter)
/* concatenate payload data, padding, padding len */
concatenated.len = this->decrypted.len + padding.len + 1;
concatenated.ptr = allocator_alloc(concatenated.len);
- if (concatenated.ptr == NULL)
- {
- randomizer->destroy(randomizer);
- allocator_free(padding.ptr);
- return OUT_OF_RES;
- }
+
memcpy(concatenated.ptr, this->decrypted.ptr, this->decrypted.len);
memcpy(concatenated.ptr + this->decrypted.len, padding.ptr, padding.len);
*(concatenated.ptr + concatenated.len - 1) = padding.len;
@@ -387,15 +355,8 @@ static status_t encrypt(private_encryption_payload_t *this, crypter_t *crypter)
/* build iv */
iv.len = crypter->get_block_size(crypter);
- status = randomizer->allocate_pseudo_random_bytes(randomizer, iv.len, &iv);
+ randomizer->allocate_pseudo_random_bytes(randomizer, iv.len, &iv);
randomizer->destroy(randomizer);
- if (status != SUCCESS)
- {
- allocator_free(padding.ptr);
- allocator_free(concatenated.ptr);
- return status;
- }
-
/* encrypt concatenated chunk */
allocator_free(this->encrypted.ptr);
@@ -411,16 +372,11 @@ static status_t encrypt(private_encryption_payload_t *this, crypter_t *crypter)
/* append an empty signature */
this->encrypted.len += this->signer->get_block_size(this->signer);
allocator_realloc(this->encrypted.ptr, this->encrypted.len);
- if (this->encrypted.ptr == NULL)
- {
- return OUT_OF_RES;
- }
-
return SUCCESS;
}
/**
- * implements encryption_payload_t.decrypt
+ * Implementation of encryption_payload_t.encrypt.
*/
static status_t decrypt(private_encryption_payload_t *this, crypter_t *crypter)
{
@@ -480,16 +436,15 @@ static status_t decrypt(private_encryption_payload_t *this, crypter_t *crypter)
}
/**
- * implements encryption_payload_t.set_signer
+ * Implementation of encryption_payload_t.set_signer.
*/
-static status_t set_signer(private_encryption_payload_t *this, signer_t* signer)
+static void set_signer(private_encryption_payload_t *this, signer_t* signer)
{
this->signer = signer;
- return SUCCESS;
}
/**
- * implements encryption_payload_t.build_signature
+ * Implementation of encryption_payload_t.build_signature.
*/
static status_t build_signature(private_encryption_payload_t *this, chunk_t data)
{
@@ -509,7 +464,7 @@ static status_t build_signature(private_encryption_payload_t *this, chunk_t data
}
/**
- * implements encryption_payload_t.verify_signature
+ * Implementation of encryption_payload_t.verify_signature.
*/
static status_t verify_signature(private_encryption_payload_t *this, chunk_t data)
{
@@ -542,21 +497,16 @@ static status_t verify_signature(private_encryption_payload_t *this, chunk_t dat
}
/**
- * implements private_encryption_payload_t.generate
+ * Implementation of private_encryption_payload_t.generate.
*/
-static status_t generate(private_encryption_payload_t *this)
+static void generate(private_encryption_payload_t *this)
{
- status_t status;
payload_t *current_payload, *next_payload;
generator_t *generator;
iterator_t *iterator;
/* create iterator */
- status = this->payloads->create_iterator(this->payloads, &iterator, TRUE);
- if (status != SUCCESS)
- {
- return status;
- }
+ this->payloads->create_iterator(this->payloads, &iterator, TRUE);
/* get first payload */
if (iterator->has_next(iterator))
@@ -570,15 +520,10 @@ static status_t generate(private_encryption_payload_t *this)
allocator_free(this->decrypted.ptr);
this->decrypted = CHUNK_INITIALIZER;
iterator->destroy(iterator);
- return SUCCESS;
+ return;
}
generator = generator_create();
- if (generator == NULL)
- {
- iterator->destroy(iterator);
- return OUT_OF_RES;
- }
/* build all payload, except last */
while(iterator->has_next(iterator))
@@ -600,9 +545,11 @@ static status_t generate(private_encryption_payload_t *this)
generator->write_to_chunk(generator, &(this->decrypted));
generator->destroy(generator);
- return SUCCESS;
}
+/**
+ * Implementation of private_encryption_payload_t.parse.
+ */
static status_t parse(private_encryption_payload_t *this)
{
parser_t *parser;
@@ -617,11 +564,6 @@ static status_t parse(private_encryption_payload_t *this)
/* build a parser on the decrypted data */
parser = parser_create(this->decrypted);
- if (parser == NULL)
- {
- return OUT_OF_RES;
- }
-
current_payload_type = this->next_payload;
/* parse all payloads */
@@ -644,28 +586,20 @@ static status_t parse(private_encryption_payload_t *this)
/* get next payload type */
current_payload_type = current_payload->get_next_type(current_payload);
- status = this->payloads->insert_last(this->payloads,current_payload);
- if (status != SUCCESS)
- {
- return OUT_OF_RES;
- }
+ this->payloads->insert_last(this->payloads,current_payload);
}
return SUCCESS;
}
/**
- * implements private_encryption_payload_t.compute_length
+ * Implementation of private_encryption_payload_t.compute_length.
*/
-static status_t compute_length(private_encryption_payload_t *this)
+static void compute_length(private_encryption_payload_t *this)
{
iterator_t *iterator;
- status_t status;
size_t length = ENCRYPTION_PAYLOAD_HEADER_LENGTH;
- status = this->payloads->create_iterator(this->payloads, &iterator, TRUE);
- if (status != SUCCESS)
- {
- return status;
- }
+ this->payloads->create_iterator(this->payloads, &iterator, TRUE);
+
while (iterator->has_next(iterator))
{
payload_t *current_payload;
@@ -675,8 +609,7 @@ static status_t compute_length(private_encryption_payload_t *this)
iterator->destroy(iterator);
this->payload_length = length;
-
- return SUCCESS;
+
}
/*
@@ -685,29 +618,25 @@ static status_t compute_length(private_encryption_payload_t *this)
encryption_payload_t *encryption_payload_create()
{
private_encryption_payload_t *this = allocator_alloc_thing(private_encryption_payload_t);
- if (this == NULL)
- {
- return NULL;
- }
/* payload_t 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.create_payload_iterator = (status_t (*) (encryption_payload_t *,iterator_t **,bool)) create_payload_iterator;
- this->public.add_payload = (status_t (*) (encryption_payload_t *,payload_t *)) add_payload;
+ this->public.create_payload_iterator = (void (*) (encryption_payload_t *,iterator_t **,bool)) create_payload_iterator;
+ this->public.add_payload = (void (*) (encryption_payload_t *,payload_t *)) add_payload;
this->public.encrypt = (status_t (*) (encryption_payload_t *, crypter_t*)) encrypt;
this->public.decrypt = (status_t (*) (encryption_payload_t *, crypter_t*)) decrypt;
- this->public.set_signer = (status_t (*) (encryption_payload_t *,signer_t*)) set_signer;
+ this->public.set_signer = (void (*) (encryption_payload_t *,signer_t*)) set_signer;
this->public.build_signature = (status_t (*) (encryption_payload_t*, chunk_t)) build_signature;
this->public.verify_signature = (status_t (*) (encryption_payload_t*, chunk_t)) verify_signature;
- this->public.destroy = (status_t (*) (encryption_payload_t *)) destroy;
+ this->public.destroy = (void (*) (encryption_payload_t *)) destroy;
/* private functions */
this->compute_length = compute_length;
@@ -723,14 +652,8 @@ encryption_payload_t *encryption_payload_create()
this->decrypted = CHUNK_INITIALIZER;
this->checksum = CHUNK_INITIALIZER;
this->signer = NULL;
-
this->payloads = linked_list_create();
- if (this->payloads == NULL)
- {
- allocator_free(this);
- return NULL;
- }
return (&(this->public));
}
diff --git a/Source/charon/encoding/payloads/encryption_payload.h b/Source/charon/encoding/payloads/encryption_payload.h
index 63cf6c052..398adbaee 100644
--- a/Source/charon/encoding/payloads/encryption_payload.h
+++ b/Source/charon/encoding/payloads/encryption_payload.h
@@ -29,7 +29,7 @@
#include <utils/linked_list.h>
/**
- * encrpytion payload length in bytes without IV and following data
+ * Encrpytion payload length in bytes without IV and following data.
*/
#define ENCRYPTION_PAYLOAD_HEADER_LENGTH 4
@@ -39,10 +39,11 @@ typedef struct encryption_payload_t encryption_payload_t;
/**
* @brief The encryption payload as described in RFC section 3.14.
*
+ * @ingroup payloads
*/
struct encryption_payload_t {
/**
- * implements payload_t interface
+ * Implements payload_t interface.
*/
payload_t payload_interface;
@@ -52,21 +53,16 @@ struct encryption_payload_t {
* @param this calling encryption_payload_t object
* @param iterator the created iterator is stored at the pointed pointer
* @param[in] forward iterator direction (TRUE: front to end)
- * @return
- * - SUCCESS or
- * - OUT_OF_RES if iterator could not be created
*/
- status_t (*create_payload_iterator) (encryption_payload_t *this, iterator_t **iterator, bool forward);
+ void (*create_payload_iterator) (encryption_payload_t *this, iterator_t **iterator, bool forward);
/**
* @brief Adds a payload to this encryption payload.
*
* @param this calling encryption_payload_t object
* @param payload payload_t object to add
- * @return - SUCCESS if succeeded
- * - FAILED otherwise
*/
- status_t (*add_payload) (encryption_payload_t *this, payload_t *payload);
+ void (*add_payload) (encryption_payload_t *this, payload_t *payload);
/**
* @brief Decrypt and return contained data.
@@ -81,7 +77,7 @@ struct encryption_payload_t {
* - FAILED if crypter does not match data
*/
- status_t (*set_signer) (encryption_payload_t *this, signer_t *signer);
+ void (*set_signer) (encryption_payload_t *this, signer_t *signer);
status_t (*encrypt) (encryption_payload_t *this, crypter_t *crypter);
status_t (*decrypt) (encryption_payload_t *this, crypter_t *crypter);
@@ -93,21 +89,18 @@ struct encryption_payload_t {
* @brief Destroys an encryption_payload_t object.
*
* @param this encryption_payload_t object to destroy
- * @return
- * - SUCCESS in any case
*/
- status_t (*destroy) (encryption_payload_t *this);
+ void (*destroy) (encryption_payload_t *this);
};
/**
* @brief Creates an empty encryption_payload_t object.
*
- * @return
- * - created encryption_payload_t object, or
- * - NULL if failed
+ * @return created encryption_payload_t object
+ *
+ * @ingroup payloads
*/
encryption_payload_t *encryption_payload_create();
-
#endif /*ENCRYPTION_PAYLOAD_H_*/
diff --git a/Source/charon/encoding/payloads/ike_header.c b/Source/charon/encoding/payloads/ike_header.c
index 58091b5e0..784fce51d 100644
--- a/Source/charon/encoding/payloads/ike_header.c
+++ b/Source/charon/encoding/payloads/ike_header.c
@@ -1,10 +1,7 @@
/**
* @file ike_header.c
*
- * @brief Declaration of the class ike_header_t.
- *
- * An object of this type represents an ike header and is used to
- * generate and parse ike headers.
+ * @brief Implementation of ike_header_t.
*
*/
@@ -35,72 +32,78 @@
typedef struct private_ike_header_t private_ike_header_t;
/**
- * Private data of an ike_header_t Object
+ * Private data of an ike_header_t object.
*
*/
struct private_ike_header_t {
/**
- * public interface
+ * Public interface.
*/
ike_header_t public;
/**
- * SPI of the initiator
+ * SPI of the initiator.
*/
u_int64_t initiator_spi;
+
/**
- * SPI of the responder
+ * SPI of the responder.
*/
u_int64_t responder_spi;
+
/**
- * next payload type
+ * Next payload type.
*/
u_int8_t next_payload;
/**
- * IKE major version
+ * IKE major version.
*/
u_int8_t maj_version;
/**
- * IKE minor version
+ * IKE minor version.
*/
u_int8_t min_version;
/**
- * Exchange type
+ * Exchange type .
*/
u_int8_t exchange_type;
/**
- * Flags of the Message
+ * Flags of the Message.
*
*/
struct {
/**
- * Sender is initiator of the associated IKE_SA_INIT-Exchange
+ * Sender is initiator of the associated IKE_SA_INIT-Exchange.
*/
bool initiator;
+
/**
- * is protocol supporting higher version?
+ * Is protocol supporting higher version?
*/
bool version;
+
/**
- * TRUE, if this is a response, FALSE if its a Request
+ * TRUE, if this is a response, FALSE if its a Request.
*/
bool response;
} flags;
+
/**
- * Associated Message-ID
+ * Associated Message-ID.
*/
u_int32_t message_id;
+
/**
- * Length of the whole IKEv2-Message (header and all payloads)
+ * Length of the whole IKEv2-Message (header and all payloads).
*/
u_int32_t length;
};
/**
- * mappings used to get strings for exchange_type_t
+ * Mappings used to get strings for exchange_type_t.
*/
mapping_t exchange_type_m[] = {
{EXCHANGE_TYPE_UNDEFINED, "EXCHANGE_TYPE_UNDEFINED"},
@@ -112,7 +115,7 @@ mapping_t exchange_type_m[] = {
/**
- * Encoding rules to parse or generate a IKEv2-Header
+ * Encoding rules to parse or generate a IKEv2-Header.
*
* The defined offsets are the positions in a object of type
* ike_header_t.
@@ -168,8 +171,7 @@ encoding_rule_t ike_header_encodings[] = {
/**
- * Implements payload_t's verify function.
- * See #payload_s.verify for description.
+ * Implementation of payload_t.verify.
*/
static status_t verify(private_ike_header_t *this)
{
@@ -202,17 +204,14 @@ static status_t verify(private_ike_header_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(payload_t *this,payload_type_t type)
+static void set_next_type(payload_t *this,payload_type_t type)
{
((private_ike_header_t *)this)->next_payload = type;
- return SUCCESS;
}
/**
- * Implements ike_header_t's get_initiator_spi fuction.
- * See #ike_header_t.get_initiator_spi for description.
+ * Implementation of ike_header_t.get_initiator_spi.
*/
static u_int64_t get_initiator_spi(private_ike_header_t *this)
{
@@ -220,8 +219,7 @@ static u_int64_t get_initiator_spi(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's set_initiator_spi fuction.
- * See #ike_header_t.set_initiator_spi for description.
+ * Implementation of ike_header_t.set_initiator_spi.
*/
static void set_initiator_spi(private_ike_header_t *this, u_int64_t initiator_spi)
{
@@ -229,8 +227,7 @@ static void set_initiator_spi(private_ike_header_t *this, u_int64_t initiator_sp
}
/**
- * Implements ike_header_t's get_responder_spi fuction.
- * See #ike_header_t.get_responder_spi for description.
+ * Implementation of ike_header_t.get_responder_spi.
*/
static u_int64_t get_responder_spi(private_ike_header_t *this)
{
@@ -238,8 +235,7 @@ static u_int64_t get_responder_spi(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's set_responder_spi fuction.
- * See #ike_header_t.set_responder_spi for description.
+ * Implementation of ike_header_t.set_responder_spi.
*/
static void set_responder_spi(private_ike_header_t *this, u_int64_t responder_spi)
{
@@ -247,8 +243,7 @@ static void set_responder_spi(private_ike_header_t *this, u_int64_t responder_sp
}
/**
- * Implements ike_header_t's get_maj_version fuction.
- * See #ike_header_t.get_maj_version for description.
+ * Implementation of ike_header_t.get_maj_version.
*/
static u_int8_t get_maj_version(private_ike_header_t *this)
{
@@ -256,8 +251,7 @@ static u_int8_t get_maj_version(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's get_min_version fuction.
- * See #ike_header_t.get_min_version for description.
+ * Implementation of ike_header_t.get_min_version.
*/
static u_int8_t get_min_version(private_ike_header_t *this)
{
@@ -265,8 +259,7 @@ static u_int8_t get_min_version(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's get_response_flag fuction.
- * See #ike_header_t.get_response_flag for description.
+ * Implementation of ike_header_t.get_response_flag.
*/
static bool get_response_flag(private_ike_header_t *this)
{
@@ -274,8 +267,7 @@ static bool get_response_flag(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's set_response_flag fuction.
- * See #ike_header_t.set_response_flag for description.
+ * Implementation of ike_header_t.set_response_flag.
*/
static void set_response_flag(private_ike_header_t *this, bool response)
{
@@ -283,8 +275,7 @@ static void set_response_flag(private_ike_header_t *this, bool response)
}
/**
- * Implements ike_header_t's get_version_flag fuction.
- * See #ike_header_t.get_version_flag for description.
+ * Implementation of ike_header_t.get_version_flag.
*/
static bool get_version_flag(private_ike_header_t *this)
{
@@ -292,8 +283,7 @@ static bool get_version_flag(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's get_initiator_flag fuction.
- * See #ike_header_t.get_initiator_flag for description.
+ * Implementation of ike_header_t.get_initiator_flag.
*/
static bool get_initiator_flag(private_ike_header_t *this)
{
@@ -301,8 +291,7 @@ static bool get_initiator_flag(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's set_initiator_flag fuction.
- * See #ike_header_t.set_initiator_flag for description.
+ * Implementation of ike_header_t.set_initiator_flag.
*/
static void set_initiator_flag(private_ike_header_t *this, bool initiator)
{
@@ -310,8 +299,7 @@ static void set_initiator_flag(private_ike_header_t *this, bool initiator)
}
/**
- * Implements ike_header_t's get_exchange_type function
- * See #ike_header_t.get_exchange_type for description.
+ * Implementation of ike_header_t.get_exchange_type.
*/
static u_int8_t get_exchange_type(private_ike_header_t *this)
{
@@ -319,8 +307,7 @@ static u_int8_t get_exchange_type(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's set_exchange_type function.
- * See #ike_header_t.set_exchange_type for description.
+ * Implementation of ike_header_t.set_exchange_type.
*/
static void set_exchange_type(private_ike_header_t *this, u_int8_t exchange_type)
{
@@ -337,8 +324,7 @@ static u_int32_t get_message_id(private_ike_header_t *this)
}
/**
- * Implements ike_header_t's set_message_id function.
- * See #ike_header_t.set_message_id for description.
+ * Implementation of ike_header_t.set_message_id.
*/
static void set_message_id(private_ike_header_t *this, u_int32_t message_id)
{
@@ -346,31 +332,24 @@ static void set_message_id(private_ike_header_t *this, u_int32_t message_id)
}
/**
- * Implements payload_t's and ike_header_t's destroy function.
- * See #payload_s.destroy or ike_header_s.destroy for description.
+ * Implementation of ike_header_t.destroy and payload_t.destroy.
*/
-static status_t destroy(ike_header_t *this)
+static void destroy(ike_header_t *this)
{
allocator_free(this);
-
- return SUCCESS;
}
/**
- * 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(payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(payload_t *this, encoding_rule_t **rules, size_t *rule_count)
{
*rules = ike_header_encodings;
*rule_count = sizeof(ike_header_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(payload_t *this)
{
@@ -378,8 +357,7 @@ static payload_type_t get_type(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(payload_t *this)
{
@@ -387,8 +365,7 @@ static payload_type_t get_next_type(payload_t *this)
}
/**
- * 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(payload_t *this)
{
@@ -396,15 +373,11 @@ static size_t get_length(payload_t *this)
}
/*
- * Described in header
+ * Described in header.
*/
ike_header_t *ike_header_create()
{
private_ike_header_t *this = allocator_alloc_thing(private_ike_header_t);
- if (this == NULL)
- {
- return NULL;
- }
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
this->public.payload_interface.get_encoding_rules = get_encoding_rules;
@@ -412,7 +385,7 @@ ike_header_t *ike_header_create()
this->public.payload_interface.get_next_type = get_next_type;
this->public.payload_interface.set_next_type = set_next_type;
this->public.payload_interface.get_type = get_type;
- this->public.payload_interface.destroy = (status_t (*) (payload_t *))destroy;
+ this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
this->public.destroy = destroy;
this->public.get_initiator_spi = (u_int64_t (*) (ike_header_t*))get_initiator_spi;
@@ -444,8 +417,5 @@ ike_header_t *ike_header_create()
this->message_id = 0;
this->length = IKE_HEADER_LENGTH;
-
return (ike_header_t*)this;
}
-
-
diff --git a/Source/charon/encoding/payloads/ike_header.h b/Source/charon/encoding/payloads/ike_header.h
index 4f05c4431..c7f388092 100644
--- a/Source/charon/encoding/payloads/ike_header.h
+++ b/Source/charon/encoding/payloads/ike_header.h
@@ -1,10 +1,7 @@
/**
* @file ike_header.h
*
- * @brief Declaration of the class ike_header_t.
- *
- * An object of this type represents an ike header and is used to
- * generate and parse ike headers.
+ * @brief Interface of ike_header_t.
*
*/
@@ -30,22 +27,30 @@
#include <encoding/payloads/payload.h>
/**
- * Major Version of IKEv2
+ * Major Version of IKEv2.
+ *
+ * @ingroup payloads
*/
#define IKE_MAJOR_VERSION 2
/**
- * Minor Version of IKEv2
+ * Minor Version of IKEv2.
+ *
+ * @ingroup payloads
*/
#define IKE_MINOR_VERSION 0
/**
- * Flag in IKEv2-Header. Always 0
+ * Flag in IKEv2-Header. Always 0.
+ *
+ * @ingroup payloads
*/
#define HIGHER_VERSION_SUPPORTED_FLAG 0
/**
- * Length of IKE Header in Bytes
+ * Length of IKE Header in Bytes.
+ *
+ * @ingroup payloads
*/
#define IKE_HEADER_LENGTH 28
@@ -54,28 +59,34 @@ typedef enum exchange_type_t exchange_type_t;
/**
* @brief Different types of IKE-Exchanges.
*
- * See RFC for different types.
+ * See Draft for different types.
+ *
+ * @ingroup payloads
*/
enum exchange_type_t{
/**
- * EXCHANGE_TYPE_UNDEFINED, not a official message type :-)
+ * EXCHANGE_TYPE_UNDEFINED, not a official message type :-).
*/
EXCHANGE_TYPE_UNDEFINED = 240,
+
/**
- * IKE_SA_INIT
+ * IKE_SA_INIT.
*/
IKE_SA_INIT = 34,
+
/**
- * IKE_AUTH
+ * IKE_AUTH.
*/
IKE_AUTH = 35,
+
/**
- * CREATE_CHILD_SA
+ * CREATE_CHILD_SA.
*/
CREATE_CHILD_SA = 36,
+
/**
- * INFORMATIONAL
+ * INFORMATIONAL.
*/
INFORMATIONAL = 37
};
@@ -85,21 +96,24 @@ extern mapping_t exchange_type_m[];
typedef struct ike_header_t ike_header_t;
/**
- * Object representing an IKEv2-Header
+ * An object of this type represents an IKEv2 header and is used to
+ * generate and parse IKEv2 headers.
+ *
*
* The header format of an IKEv2-Message is compatible to the
* ISAKMP-Header format to allow implementations supporting
* both versions of the IKE-protocol.
*
+ * @ingroup payloads
*/
struct ike_header_t {
/**
- * implements payload_t interface
+ * The payload_t interface.
*/
payload_t payload_interface;
/**
- * @brief get the initiator spi
+ * @brief Get the initiator spi.
*
* @param this ike_header_t object
* @return initiator_spi
@@ -107,7 +121,7 @@ struct ike_header_t {
u_int64_t (*get_initiator_spi) (ike_header_t *this);
/**
- * @brief set the initiator spi
+ * @brief Set the initiator spi.
*
* @param this ike_header_t object
* @param initiator_spi initiator_spi
@@ -115,7 +129,7 @@ struct ike_header_t {
void (*set_initiator_spi) (ike_header_t *this, u_int64_t initiator_spi);
/**
- * @brief get the responder spi
+ * @brief Get the responder spi.
*
* @param this ike_header_t object
* @return responder_spi
@@ -123,7 +137,7 @@ struct ike_header_t {
u_int64_t (*get_responder_spi) (ike_header_t *this);
/**
- * @brief set the responder spi
+ * @brief Set the responder spi.
*
* @param this ike_header_t object
* @param responder_spi responder_spi
@@ -131,7 +145,7 @@ struct ike_header_t {
void (*set_responder_spi) (ike_header_t *this, u_int64_t responder_spi);
/**
- * @brief get the major version
+ * @brief Get the major version.
*
* @param this ike_header_t object
* @return major version
@@ -139,7 +153,7 @@ struct ike_header_t {
u_int8_t (*get_maj_version) (ike_header_t *this);
/**
- * @brief get the mainor version
+ * @brief Get the minor version.
*
* @param this ike_header_t object
* @return minor version
@@ -147,7 +161,7 @@ struct ike_header_t {
u_int8_t (*get_min_version) (ike_header_t *this);
/**
- * @brief get the response flag
+ * @brief Get the response flag.
*
* @param this ike_header_t object
* @return response flag
@@ -155,7 +169,7 @@ struct ike_header_t {
bool (*get_response_flag) (ike_header_t *this);
/**
- * @brief Set the response flag
+ * @brief Set the response flag-
*
* @param this ike_header_t object
* @param response response flag
@@ -163,7 +177,7 @@ struct ike_header_t {
*/
void (*set_response_flag) (ike_header_t *this, bool response);
/**
- * @brief get "higher version supported"-flag
+ * @brief Get "higher version supported"-flag.
*
* @param this ike_header_t object
* @return version flag
@@ -171,7 +185,7 @@ struct ike_header_t {
bool (*get_version_flag) (ike_header_t *this);
/**
- * @brief get the initiator flag
+ * @brief Get the initiator flag.
*
* @param this ike_header_t object
* @return initiator flag
@@ -179,7 +193,7 @@ struct ike_header_t {
bool (*get_initiator_flag) (ike_header_t *this);
/**
- * @brief Set the initiator flag
+ * @brief Set the initiator flag.
*
* @param this ike_header_t object
* @param initiator initiator flag
@@ -188,7 +202,7 @@ struct ike_header_t {
void (*set_initiator_flag) (ike_header_t *this, bool initiator);
/**
- * @brief get the exchange type
+ * @brief Get the exchange type.
*
* @param this ike_header_t object
* @return exchange type
@@ -196,7 +210,7 @@ struct ike_header_t {
u_int8_t (*get_exchange_type) (ike_header_t *this);
/**
- * @brief set the exchange type
+ * @brief Set the exchange type.
*
* @param this ike_header_t object
* @param exchange_type exchange type
@@ -204,7 +218,7 @@ struct ike_header_t {
void (*set_exchange_type) (ike_header_t *this, u_int8_t exchange_type);
/**
- * @brief get the message id
+ * @brief Get the message id.
*
* @param this ike_header_t object
* @return message id
@@ -212,7 +226,7 @@ struct ike_header_t {
u_int32_t (*get_message_id) (ike_header_t *this);
/**
- * @brief set the message id
+ * @brief Set the message id.
*
* @param this ike_header_t object
* @param initiator_spi message id
@@ -223,20 +237,17 @@ struct ike_header_t {
* @brief Destroys a ike_header_t object.
*
* @param this ike_header_t object to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (ike_header_t *this);
+ void (*destroy) (ike_header_t *this);
};
/**
* @brief Create an ike_header_t object
*
- * @return
- * - created ike_header, or
- * - NULL if failed
+ * @return created ike_header_t object
+ *
+ * @ingroup payloads
*/
-
ike_header_t *ike_header_create();
#endif /*IKE_HEADER_H_*/
diff --git a/Source/charon/encoding/payloads/ke_payload.c b/Source/charon/encoding/payloads/ke_payload.c
index d2181560d..9f1e7bdd3 100644
--- a/Source/charon/encoding/payloads/ke_payload.c
+++ b/Source/charon/encoding/payloads/ke_payload.c
@@ -1,11 +1,7 @@
/**
* @file ke_payload.c
*
- * @brief Declaration of the class ke_payload_t.
- *
- * An object of this type represents an IKEv2 KE-Payload.
- *
- * See section 3.4 of RFC for details of this payload type.
+ * @brief Implementation of ke_payload_t.
*
*/
@@ -36,38 +32,38 @@
typedef struct private_ke_payload_t private_ke_payload_t;
/**
- * Private data of an ke_payload_t Object
+ * Private data of an ke_payload_t object.
*
*/
struct private_ke_payload_t {
/**
- * public ke_payload_t interface
+ * Public ke_payload_t interface.
*/
ke_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;
/**
- * DH Group Number
+ * DH Group Number.
*/
diffie_hellman_group_t dh_group_number;
/**
- * Key Exchange Data of this KE payload
+ * Key Exchange Data of this KE payload.
*/
chunk_t key_exchange_data;
@@ -75,14 +71,12 @@ struct private_ke_payload_t {
* @brief Computes the length of this payload.
*
* @param this calling private_ke_payload_t object
- * @return
- * SUCCESS in any case
*/
- status_t (*compute_length) (private_ke_payload_t *this);
+ void (*compute_length) (private_ke_payload_t *this);
};
/**
- * Encoding rules to parse or generate a IKEv2-KE Payload
+ * Encoding rules to parse or generate a IKEv2-KE Payload.
*
* The defined offsets are the positions in a object of type
* private_ke_payload_t.
@@ -126,8 +120,7 @@ encoding_rule_t ke_payload_encodings[] = {
*/
/**
- * Implements payload_t's verify function.
- * See #payload_s.verify for description.
+ * Implementation of payload_t.verify.
*/
static status_t verify(private_ke_payload_t *this)
{
@@ -142,34 +135,28 @@ static status_t verify(private_ke_payload_t *this)
}
/**
- * Implements payload_t's and ke_payload_t's destroy function.
- * See #payload_s.destroy or ke_payload_s.destroy for description.
+ * Implementation of payload_t.destroy.
*/
-static status_t destroy(private_ke_payload_t *this)
+static void destroy(private_ke_payload_t *this)
{
if (this->key_exchange_data.ptr != NULL)
{
allocator_free(this->key_exchange_data.ptr);
}
allocator_free(this);
- return SUCCESS;
}
/**
- * 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_ke_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(private_ke_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
{
*rules = ke_payload_encodings;
*rule_count = sizeof(ke_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_ke_payload_t *this)
{
@@ -177,8 +164,7 @@ static payload_type_t get_type(private_ke_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_ke_payload_t *this)
{
@@ -186,18 +172,15 @@ static payload_type_t get_next_type(private_ke_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_ke_payload_t *this,payload_type_t type)
+static void set_next_type(private_ke_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_ke_payload_t *this)
{
@@ -206,37 +189,31 @@ static size_t get_length(private_ke_payload_t *this)
}
/**
- * Implements private_ke_payload_t's compute_length function.
- * See #private_ke_payload_s.compute_length for description.
+ * Implementation of private_ke_payload_t.compute_length.
*/
-static status_t compute_length (private_ke_payload_t *this)
+static void compute_length (private_ke_payload_t *this)
{
size_t length = KE_PAYLOAD_HEADER_LENGTH;
if (this->key_exchange_data.ptr != NULL)
{
length += this->key_exchange_data.len;
- }
-
+ }
this->payload_length = length;
-
- return SUCCESS;
}
/**
- * Implements ke_payload_t's get_key_exchange_data function.
- * See #ke_payload_t.get_key_exchange_data for description.
+ * Implementation of ke_payload_t.get_key_exchange_data.
*/
-chunk_t get_key_exchange_data(private_ke_payload_t *this)
+static chunk_t get_key_exchange_data(private_ke_payload_t *this)
{
return (this->key_exchange_data);
}
/**
- * Implements ke_payload_t's set_key_exchange_data function.
- * See #ke_payload_t.set_key_exchange_data for description.
+ * Implementation of ke_payload_t.set_key_exchange_data.
*/
-status_t set_key_exchange_data(private_ke_payload_t *this, chunk_t key_exchange_data)
+static void set_key_exchange_data(private_ke_payload_t *this, chunk_t key_exchange_data)
{
/* destroy existing data first */
if (this->key_exchange_data.ptr != NULL)
@@ -249,33 +226,25 @@ status_t set_key_exchange_data(private_ke_payload_t *this, chunk_t key_exchange_
}
this->key_exchange_data.ptr = allocator_clone_bytes(key_exchange_data.ptr,key_exchange_data.len);
- if (this->key_exchange_data.ptr == NULL)
- {
- return OUT_OF_RES;
- }
+
this->key_exchange_data.len = key_exchange_data.len;
this->compute_length(this);
-
- return SUCCESS;
}
/**
- * Implements ke_payload_t's get_dh_group_number function.
- * See #ke_payload_t.get_dh_group_number for description.
+ * Implementation of ke_payload_t.get_dh_group_number.
*/
-diffie_hellman_group_t get_dh_group_number(private_ke_payload_t *this)
+static diffie_hellman_group_t get_dh_group_number(private_ke_payload_t *this)
{
return this->dh_group_number;
}
/**
- * Implements ke_payload_t's set_dh_group_number function.
- * See #ke_payload_t.set_dh_group_number for description.
+ * Implementation of ke_payload_t.set_dh_group_number.
*/
-status_t set_dh_group_number(private_ke_payload_t *this, diffie_hellman_group_t dh_group_number)
+static void set_dh_group_number(private_ke_payload_t *this, diffie_hellman_group_t dh_group_number)
{
this->dh_group_number = dh_group_number;
- return SUCCESS;
}
/*
@@ -284,25 +253,22 @@ status_t set_dh_group_number(private_ke_payload_t *this, diffie_hellman_group_t
ke_payload_t *ke_payload_create()
{
private_ke_payload_t *this = allocator_alloc_thing(private_ke_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.get_key_exchange_data = (chunk_t (*) (ke_payload_t *)) get_key_exchange_data;
- this->public.set_key_exchange_data = (status_t (*) (ke_payload_t *,chunk_t)) set_key_exchange_data;
+ this->public.set_key_exchange_data = (void (*) (ke_payload_t *,chunk_t)) set_key_exchange_data;
this->public.get_dh_group_number = (diffie_hellman_group_t (*) (ke_payload_t *)) get_dh_group_number;
- this->public.set_dh_group_number =(status_t (*) (ke_payload_t *,diffie_hellman_group_t)) set_dh_group_number;
- this->public.destroy = (status_t (*) (ke_payload_t *)) destroy;
+ this->public.set_dh_group_number =(void (*) (ke_payload_t *,diffie_hellman_group_t)) set_dh_group_number;
+ this->public.destroy = (void (*) (ke_payload_t *)) destroy;
/* private functions */
this->compute_length = compute_length;
diff --git a/Source/charon/encoding/payloads/ke_payload.h b/Source/charon/encoding/payloads/ke_payload.h
index 60c7a1e56..ae153048c 100644
--- a/Source/charon/encoding/payloads/ke_payload.h
+++ b/Source/charon/encoding/payloads/ke_payload.h
@@ -1,11 +1,7 @@
/**
* @file ke_payload.h
*
- * @brief Declaration of the class ke_payload_t.
- *
- * An object of this type represents an IKEv2 KE-Payload.
- *
- * See section 3.4 of RFC for details of this payload type.
+ * @brief Interface of ke_payload_t.
*
*/
@@ -33,12 +29,16 @@
#include <utils/linked_list.h>
/**
- * Critical flag must not be set
+ * Critical flag must not be set.
+ *
+ * @ingroup payloads
*/
#define KE_PAYLOAD_CRITICAL_FLAG FALSE;
/**
- * KE payload length in bytes without any key exchange data
+ * KE payload length in bytes without any key exchange data.
+ *
+ * @ingroup payloads
*/
#define KE_PAYLOAD_HEADER_LENGTH 8
@@ -46,14 +46,15 @@
typedef struct ke_payload_t ke_payload_t;
/**
- * Object representing an IKEv2-KE Payload
+ * Object representing an IKEv2-KE Payload.
*
* The KE Payload format is described in RFC section 3.4.
*
+ * @ingroup payloads
*/
struct ke_payload_t {
/**
- * implements payload_t interface
+ * The payload_t interface.
*/
payload_t payload_interface;
@@ -74,11 +75,8 @@ struct ke_payload_t {
*
* @param this calling ke_payload_t object
* @param key_exchange_data chunk_t pointing to the value to set
- * @return
- * - SUCCESS or
- * - OUT_OF_RES
*/
- status_t (*set_key_exchange_data) (ke_payload_t *this, chunk_t key_exchange_data);
+ void (*set_key_exchange_data) (ke_payload_t *this, chunk_t key_exchange_data);
/**
* @brief Gets the Diffie-Hellman Group Number of this KE payload.
@@ -93,28 +91,24 @@ struct ke_payload_t {
*
* @param this calling ke_payload_t object
* @param dh_group_number DH Group to set
- * @return SUCCESS
*/
- status_t (*set_dh_group_number) (ke_payload_t *this, diffie_hellman_group_t dh_group_number);
+ void (*set_dh_group_number) (ke_payload_t *this, diffie_hellman_group_t dh_group_number);
/**
* @brief Destroys an ke_payload_t object.
*
* @param this ke_payload_t object to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (ke_payload_t *this);
+ void (*destroy) (ke_payload_t *this);
};
/**
* @brief Creates an empty ke_payload_t object
*
- * @return
- * - created ke_payload_t object, or
- * - NULL if failed
+ * @return created ke_payload_t object
+ *
+ * @ingroup payloads
*/
-
ke_payload_t *ke_payload_create();
diff --git a/Source/charon/encoding/payloads/nonce_payload.c b/Source/charon/encoding/payloads/nonce_payload.c
index 33860f585..e6ea14745 100644
--- a/Source/charon/encoding/payloads/nonce_payload.c
+++ b/Source/charon/encoding/payloads/nonce_payload.c
@@ -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;
diff --git a/Source/charon/encoding/payloads/nonce_payload.h b/Source/charon/encoding/payloads/nonce_payload.h
index c5abf9af0..95c78cfd0 100644
--- a/Source/charon/encoding/payloads/nonce_payload.h
+++ b/Source/charon/encoding/payloads/nonce_payload.h
@@ -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 Interface of nonce_payload_t.
*
*/
@@ -29,28 +27,32 @@
#include <encoding/payloads/payload.h>
/**
- * length of a nonce payload without a nonce in int
+ * Length of a nonce payload without a nonce in bytes.
+ *
+ * @ingroup payloads
*/
#define NONCE_PAYLOAD_HEADER_LENGTH 4
typedef struct nonce_payload_t nonce_payload_t;
/**
- * Object representing an IKEv2 Nonce payload
+ * Object representing an IKEv2 Nonce payload.
*
* The Nonce payload format is described in draft section 3.3.
*
+ * @ingroup payloads
+ *
*/
struct nonce_payload_t {
/**
- * implements payload_t interface
+ * The payload_t interface.
*/
payload_t payload_interface;
/**
* @brief Set the nonce value.
*
- * The nonce must have length between 16 and 256 bytes
+ * The nonce must have length between 16 and 256 bytes.
*
* @param this calling nonce_payload_t object
* @param nonce chunk containing the nonce, will be cloned
@@ -65,26 +67,23 @@ struct nonce_payload_t {
*
* @param this calling nonce_payload_t object
* @param[out] nonce chunk where nonce data is located (cloned)
- * @return SUCCESS in any case
*/
- status_t (*get_nonce) (nonce_payload_t *this, chunk_t *nonce);
+ void (*get_nonce) (nonce_payload_t *this, chunk_t *nonce);
/**
* @brief Destroys an nonce_payload_t object.
*
* @param this nonce_payload_t object to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (nonce_payload_t *this);
+ void (*destroy) (nonce_payload_t *this);
};
/**
* @brief Creates an empty nonce_payload_t object
*
- * @return
- * - created nonce_payload_t object, or
- * - NULL if failed
+ * @return created nonce_payload_t object
+ *
+ * @ingroup payloads
*/
nonce_payload_t *nonce_payload_create();
diff --git a/Source/charon/encoding/payloads/notify_payload.c b/Source/charon/encoding/payloads/notify_payload.c
index b8c58537c..31e02d2d6 100644
--- a/Source/charon/encoding/payloads/notify_payload.c
+++ b/Source/charon/encoding/payloads/notify_payload.c
@@ -1,11 +1,7 @@
/**
* @file notify_payload.c
*
- * @brief Declaration of the class notify_payload_t.
- *
- * An object of this type represents an IKEv2 Notify-Payload.
- *
- * See section 3.10 of Draft for details of this payload type.
+ * @brief Implementation of notify_payload_t.
*
*/
@@ -36,52 +32,52 @@
typedef struct private_notify_payload_t private_notify_payload_t;
/**
- * Private data of an notify_payload_t Object
+ * Private data of an notify_payload_t object.
*
*/
struct private_notify_payload_t {
/**
- * public notify_payload_t interface
+ * Public notify_payload_t interface.
*/
notify_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;
/**
- * protocol id
+ * Protocol id.
*/
u_int8_t protocol_id;
/**
- * spi size
+ * Spi size.
*/
u_int8_t spi_size;
/**
- * notify message type
+ * Notify message type.
*/
u_int16_t notify_message_type;
/**
- * Security parameter index (spi)
+ * Security parameter index (spi).
*/
chunk_t spi;
/**
- * Notification data
+ * Notification data.
*/
chunk_t notification_data;
@@ -89,14 +85,12 @@ struct private_notify_payload_t {
* @brief Computes the length of this payload.
*
* @param this calling private_ke_payload_t object
- * @return
- * SUCCESS in any case
*/
- status_t (*compute_length) (private_notify_payload_t *this);
+ void (*compute_length) (private_notify_payload_t *this);
};
/**
- * Encoding rules to parse or generate a IKEv2-Notify Payload
+ * Encoding rules to parse or generate a IKEv2-Notify Payload.
*
* The defined offsets are the positions in a object of type
* private_notify_payload_t.
@@ -148,8 +142,7 @@ encoding_rule_t notify_payload_encodings[] = {
*/
/**
- * Implements payload_t's verify function.
- * See #payload_s.verify for description.
+ * Implementation of payload_t.verify.
*/
static status_t verify(private_notify_payload_t *this)
{
@@ -170,19 +163,16 @@ static status_t verify(private_notify_payload_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_notify_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(private_notify_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
{
*rules = notify_payload_encodings;
*rule_count = sizeof(notify_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_notify_payload_t *this)
{
@@ -190,8 +180,7 @@ static payload_type_t get_type(private_notify_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_notify_payload_t *this)
{
@@ -199,18 +188,15 @@ static payload_type_t get_next_type(private_notify_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_notify_payload_t *this,payload_type_t type)
+static void set_next_type(private_notify_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_notify_payload_t *this)
{
@@ -219,10 +205,9 @@ static size_t get_length(private_notify_payload_t *this)
}
/**
- * Implements private_ke_payload_t's compute_length function.
- * See #private_ke_payload_s.compute_length for description.
+ * Implementation of private_notify_payload_t.compute_length.
*/
-static status_t compute_length (private_notify_payload_t *this)
+static void compute_length (private_notify_payload_t *this)
{
size_t length = NOTIFY_PAYLOAD_HEADER_LENGTH;
if (this->notification_data.ptr != NULL)
@@ -235,63 +220,53 @@ static status_t compute_length (private_notify_payload_t *this)
}
this->payload_length = length;
-
- return SUCCESS;
-}
+}
/**
- * Implements notify_payload_t's get_protocol_id function.
- * See #notify_payload_s.get_protocol_id for description.
+ * Implementation of notify_payload_t.get_protocol_id.
*/
-u_int8_t get_protocol_id(private_notify_payload_t *this)
+static u_int8_t get_protocol_id(private_notify_payload_t *this)
{
return this->protocol_id;
}
/**
- * Implements notify_payload_t's set_protocol_id function.
- * See #notify_payload_s.set_protocol_id for description.
+ * Implementation of notify_payload_t.set_protocol_id.
*/
-status_t set_protocol_id(private_notify_payload_t *this, u_int8_t protocol_id)
+static void set_protocol_id(private_notify_payload_t *this, u_int8_t protocol_id)
{
this->protocol_id = protocol_id;
- return SUCCESS;
}
/**
- * Implements notify_payload_t's get_notification_data function.
- * See #notify_payload_s.get_notification_data for description.
+ * Implementation of notify_payload_t.get_notify_message_type.
*/
-u_int16_t get_notify_message_type(private_notify_payload_t *this)
+static u_int16_t get_notify_message_type(private_notify_payload_t *this)
{
return this->notify_message_type;
}
/**
- * Implements notify_payload_t's get_notification_data function.
- * See #notify_payload_s.get_notification_data for description.
+ * Implementation of notify_payload_t.set_notify_message_type.
*/
-status_t set_notify_message_type(private_notify_payload_t *this, u_int16_t notify_message_type)
+static void set_notify_message_type(private_notify_payload_t *this, u_int16_t notify_message_type)
{
this->notify_message_type = notify_message_type;
- return SUCCESS;
}
/**
- * Implements notify_payload_t's get_spi function.
- * See #notify_payload_s.get_spi for description.
+ * Implementation of notify_payload_t.get_spi.
*/
-chunk_t get_spi(private_notify_payload_t *this)
+static chunk_t get_spi(private_notify_payload_t *this)
{
return (this->spi);
}
/**
- * Implements notify_payload_t's set_spi function.
- * See #notify_payload_s.set_spi for description.
+ * Implementation of notify_payload_t.set_spi.
*/
-status_t set_spi(private_notify_payload_t *this, chunk_t spi)
+static void set_spi(private_notify_payload_t *this, chunk_t spi)
{
/* destroy existing data first */
if (this->spi.ptr != NULL)
@@ -304,32 +279,25 @@ status_t set_spi(private_notify_payload_t *this, chunk_t spi)
}
this->spi.ptr = allocator_clone_bytes(spi.ptr,spi.len);
- if (this->spi.ptr == NULL)
- {
- return OUT_OF_RES;
- }
+
this->spi.len = spi.len;
this->spi_size = spi.len;
this->compute_length(this);
-
- return SUCCESS;
-}
+}
/**
- * Implements notify_payload_t's get_notification_data function.
- * See #notify_payload_s.get_notification_data for description.
+ * Implementation of notify_payload_t.get_notification_data.
*/
-chunk_t get_notification_data(private_notify_payload_t *this)
+static chunk_t get_notification_data(private_notify_payload_t *this)
{
return (this->notification_data);
}
/**
- * Implements notify_payload_t's get_notification_data function.
- * See #notify_payload_s.get_notification_data for description.
+ * Implementation of notify_payload_t.set_notification_data.
*/
-status_t set_notification_data(private_notify_payload_t *this, chunk_t notification_data)
+static status_t set_notification_data(private_notify_payload_t *this, chunk_t notification_data)
{
/* destroy existing data first */
if (this->notification_data.ptr != NULL)
@@ -342,10 +310,6 @@ status_t set_notification_data(private_notify_payload_t *this, chunk_t notificat
}
this->notification_data.ptr = allocator_clone_bytes(notification_data.ptr,notification_data.len);
- if (this->notification_data.ptr == NULL)
- {
- return OUT_OF_RES;
- }
this->notification_data.len = notification_data.len;
this->compute_length(this);
@@ -353,8 +317,7 @@ status_t set_notification_data(private_notify_payload_t *this, chunk_t notificat
}
/**
- * Implements payload_t's and notify_payload_t's destroy function.
- * See #payload_s.destroy or notify_payload_s.destroy for description.
+ * Implementation of notify_payload_t.destroy and notify_payload_t.destroy.
*/
static status_t destroy(private_notify_payload_t *this)
{
@@ -377,29 +340,26 @@ static status_t destroy(private_notify_payload_t *this)
notify_payload_t *notify_payload_create()
{
private_notify_payload_t *this = allocator_alloc_thing(private_notify_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.get_protocol_id = (u_int8_t (*) (notify_payload_t *)) get_protocol_id;
- this->public.set_protocol_id = (status_t (*) (notify_payload_t *,u_int8_t)) set_protocol_id;
+ this->public.set_protocol_id = (void (*) (notify_payload_t *,u_int8_t)) set_protocol_id;
this->public.get_notify_message_type = (u_int16_t (*) (notify_payload_t *)) get_notify_message_type;
- this->public.set_notify_message_type = (status_t (*) (notify_payload_t *,u_int16_t)) set_notify_message_type;
+ this->public.set_notify_message_type = (void (*) (notify_payload_t *,u_int16_t)) set_notify_message_type;
this->public.get_spi = (chunk_t (*) (notify_payload_t *)) get_spi;
- this->public.set_spi = (status_t (*) (notify_payload_t *,chunk_t)) set_spi;
+ this->public.set_spi = (void (*) (notify_payload_t *,chunk_t)) set_spi;
this->public.get_notification_data = (chunk_t (*) (notify_payload_t *)) get_notification_data;
- this->public.set_notification_data = (status_t (*) (notify_payload_t *,chunk_t)) set_notification_data;
- this->public.destroy = (status_t (*) (notify_payload_t *)) destroy;
+ this->public.set_notification_data = (void (*) (notify_payload_t *,chunk_t)) set_notification_data;
+ this->public.destroy = (void (*) (notify_payload_t *)) destroy;
/* private functions */
this->compute_length = compute_length;
diff --git a/Source/charon/encoding/payloads/notify_payload.h b/Source/charon/encoding/payloads/notify_payload.h
index ac810d935..19dd14ef0 100644
--- a/Source/charon/encoding/payloads/notify_payload.h
+++ b/Source/charon/encoding/payloads/notify_payload.h
@@ -1,11 +1,7 @@
/**
* @file notify_payload.h
*
- * @brief Declaration of the class notify_payload_t.
- *
- * An object of this type represents an IKEv2 Notify-Payload.
- *
- * See section 3.10 of Draft for details of this payload type.
+ * @brief Interface of notify_payload_t.
*
*/
@@ -33,26 +29,32 @@
#include <utils/linked_list.h>
/**
- * Critical flag must not be set
+ * Critical flag must not be set.
+ *
+ * @ingroup payloads
*/
#define NOTIFY_PAYLOAD_CRITICAL_FLAG FALSE;
/**
- * Notify payload length in bytes without any spi and notification data
+ * Notify payload length in bytes without any spi and notification data.
+ *
+ * @ingroup payloads
*/
#define NOTIFY_PAYLOAD_HEADER_LENGTH 8
typedef struct notify_payload_t notify_payload_t;
/**
- * Object representing an IKEv2-Notify Payload
+ * Object representing an IKEv2-Notify Payload.
*
* The Notify Payload format is described in Draft section 3.10.
- *
+ *
+ *
+ * @ingroup payloads
*/
struct notify_payload_t {
/**
- * implements payload_t interface
+ * The payload_t interface.
*/
payload_t payload_interface;
@@ -69,9 +71,8 @@ struct notify_payload_t {
*
* @param this calling notify_payload_t object
* @param protocol_id protocol id to set
- * @return SUCCESS
*/
- status_t (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
+ void (*set_protocol_id) (notify_payload_t *this, u_int8_t protocol_id);
/**
* @brief Gets the notify message type of this payload.
@@ -86,9 +87,8 @@ struct notify_payload_t {
*
* @param this calling notify_payload_t object
* @param notify_message_type notify message type to set
- * @return SUCCESS
*/
- status_t (*set_notify_message_type) (notify_payload_t *this, u_int16_t notify_message_type);
+ void (*set_notify_message_type) (notify_payload_t *this, u_int16_t notify_message_type);
/**
* @brief Returns the currently set spi of this payload.
@@ -107,11 +107,8 @@ struct notify_payload_t {
*
* @param this calling notify_payload_t object
* @param spi chunk_t pointing to the value to set
- * @return
- * - SUCCESS or
- * - OUT_OF_RES
*/
- status_t (*set_spi) (notify_payload_t *this, chunk_t spi);
+ void (*set_spi) (notify_payload_t *this, chunk_t spi);
/**
* @brief Returns the currently set notification data of payload.
@@ -130,28 +127,23 @@ struct notify_payload_t {
*
* @param this calling notify_payload_t object
* @param notification_data chunk_t pointing to the value to set
- * @return
- * - SUCCESS or
- * - OUT_OF_RES
*/
- status_t (*set_notification_data) (notify_payload_t *this, chunk_t notification_data);
+ void (*set_notification_data) (notify_payload_t *this, chunk_t notification_data);
/**
* @brief Destroys an notify_payload_t object.
*
* @param this notify_payload_t object to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (notify_payload_t *this);
+ void (*destroy) (notify_payload_t *this);
};
/**
* @brief Creates an empty notify_payload_t object
*
- * @return
- * - created notify_payload_t object, or
- * - NULL if failed
+ * @return created notify_payload_t object
+ *
+ * @ingroup payloads
*/
notify_payload_t *notify_payload_create();
diff --git a/Source/charon/encoding/payloads/payload.h b/Source/charon/encoding/payloads/payload.h
index a1c5cb007..1bd3bf00a 100644
--- a/Source/charon/encoding/payloads/payload.h
+++ b/Source/charon/encoding/payloads/payload.h
@@ -1,7 +1,7 @@
/**
* @file payload.h
*
- * @brief Generic payload interface
+ * @brief Generic payload interface.
*
*
*/
@@ -32,11 +32,13 @@
typedef enum payload_type_t payload_type_t;
/**
- * Payload-Types of a IKEv2-Message
+ * Payload-Types of a IKEv2-Message.
*
*
* Header and substructures are also defined as
* payload types with values from PRIVATE USE space.
+ *
+ * @ingroup payloads
*/
enum payload_type_t{
@@ -49,69 +51,84 @@ enum payload_type_t{
* SA
*/
SECURITY_ASSOCIATION = 33,
+
/**
* KE
*/
KEY_EXCHANGE = 34,
+
/**
* IDi
*/
ID_INITIATOR = 35,
+
/**
* IDr
*/
ID_RESPONDER = 36,
+
/**
* CERT
*/
CERTIFICATE = 37,
+
/**
* CERTREQ
*/
CERTIFICATE_REQUEST = 38,
+
/**
* AUTH
*/
AUTHENTICATION = 39,
+
/**
* Ni, Nr
*/
NONCE = 40,
+
/**
* N
*/
NOTIFY = 41,
+
/**
* D
*/
DELETE = 42,
+
/**
* V
*/
VENDOR_ID = 43,
+
/**
* TSi
*/
TRAFFIC_SELECTOR_INITIATOR = 44,
+
/**
* TSr
*/
TRAFFIC_SELECTOR_RESPONDER = 45,
+
/**
* E
*/
ENCRYPTED = 46,
+
/**
* CP
*/
CONFIGURATION = 47,
+
/**
* EAP
*/
EXTENSIBLE_AUTHENTICATION = 48,
/**
- * Header has a value of PRIVATE USE space
+ * Header has a value of PRIVATE USE space.
*
* This payload type is not send over wire and just
* used internally to handle IKEv2-Header like a payload.
@@ -119,7 +136,7 @@ enum payload_type_t{
HEADER = 140,
/**
- * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space
+ * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
*
* This payload type is not send over wire and just
* used internally to handle a proposal substructure like a payload.
@@ -127,7 +144,7 @@ enum payload_type_t{
PROPOSAL_SUBSTRUCTURE = 141,
/**
- * TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space
+ * TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space.
*
* This payload type is not send over wire and just
* used internally to handle a transform substructure like a payload.
@@ -135,7 +152,7 @@ enum payload_type_t{
TRANSFORM_SUBSTRUCTURE = 142,
/**
- * TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space
+ * TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space.
*
* This payload type is not send over wire and just
* used internally to handle a transform attribute like a payload.
@@ -145,7 +162,7 @@ enum payload_type_t{
/*
- * build string mapping array for payload_type_t
+ * Build string mapping array for payload_type_t.
*/
extern mapping_t payload_type_m[];
@@ -154,19 +171,17 @@ typedef struct payload_t payload_t;
/**
* @brief Generic interface for all payload types (inclusive
- * header and substructures)
- *
+ * header and substructures).
*
+ * @ingroup payloads
*/
struct payload_t {
/**
* @brief Destroys a payload and all included substructures.
*
* @param this payload to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (payload_t *this);
+ void (*destroy) (payload_t *this);
/**
* @brief Get encoding rules for this payload
@@ -174,10 +189,8 @@ struct payload_t {
* @param this calling object
* @param[out] rules location to store pointer of first rule
* @param[out] rule_count location to store number of rules
- * @return
- * SUCCESS in any case
*/
- status_t (*get_encoding_rules) (payload_t *this, encoding_rule_t **rules, size_t *rule_count);
+ void (*get_encoding_rules) (payload_t *this, encoding_rule_t **rules, size_t *rule_count);
/**
* @brief get type of payload
@@ -200,9 +213,8 @@ struct payload_t {
*
* @param this calling object
* @param type type of next payload
- * @return SUCCESS in any case
*/
- status_t (*set_next_type) (payload_t *this,payload_type_t type);
+ void (*set_next_type) (payload_t *this,payload_type_t type);
/**
* @brief get length of payload
@@ -230,9 +242,7 @@ struct payload_t {
* It supports all payload_t methods.
*
* @param type type of the payload to create
- * @return
- * - created payload, or
- * - NULL if failed
+ * @return created payload
*/
payload_t *payload_create(payload_type_t type);
diff --git a/Source/charon/encoding/payloads/proposal_substructure.c b/Source/charon/encoding/payloads/proposal_substructure.c
index b16fb9a85..765fd1d0d 100644
--- a/Source/charon/encoding/payloads/proposal_substructure.c
+++ b/Source/charon/encoding/payloads/proposal_substructure.c
@@ -1,9 +1,7 @@
/**
* @file proposal_substructure.h
*
- * @brief Declaration of the class proposal_substructure_t.
- *
- * An object of this type represents an IKEv2 PROPOSAL Substructure and contains transforms.
+ * @brief Implementation of proposal_substructure_t.
*
*/
@@ -36,54 +34,52 @@
typedef struct private_proposal_substructure_t private_proposal_substructure_t;
/**
- * Private data of an proposal_substructure_t' Object
+ * Private data of an proposal_substructure_t object.
*
*/
struct private_proposal_substructure_t {
/**
- * public proposal_substructure_t interface
+ * Public proposal_substructure_t interface.
*/
proposal_substructure_t public;
/**
- * next payload type
+ * Next payload type.
*/
u_int8_t next_payload;
-
/**
- * Length of this payload
+ * Length of this payload.
*/
u_int16_t proposal_length;
-
/**
- * Proposal number
+ * Proposal number.
*/
u_int8_t proposal_number;
/**
- * Protocol ID
+ * Protocol ID.
*/
u_int8_t protocol_id;
/**
- * SPI size of the following SPI
+ * SPI size of the following SPI.
*/
u_int8_t spi_size;
/**
- * Number of transforms
+ * Number of transforms.
*/
u_int8_t transforms_count;
/**
- * SPI is stored as chunk
+ * SPI is stored as chunk.
*/
chunk_t spi;
/**
- * Transforms are stored in a linked_list_t
+ * Transforms are stored in a linked_list_t.
*/
linked_list_t * transforms;
@@ -91,14 +87,12 @@ struct private_proposal_substructure_t {
* @brief Computes the length of this substructure.
*
* @param this calling private_proposal_substructure_t object
- * @return
- * SUCCESS in any case
*/
- status_t (*compute_length) (private_proposal_substructure_t *this);
+ void (*compute_length) (private_proposal_substructure_t *this);
};
/**
- * Encoding rules to parse or generate a Proposal substructure
+ * Encoding rules to parse or generate a Proposal substructure.
*
* The defined offsets are the positions in a object of type
* private_proposal_substructure_t.
@@ -143,8 +137,7 @@ encoding_rule_t proposal_substructure_encodings[] = {
*/
/**
- * Implements payload_t's verify function.
- * See #payload_s.verify for description.
+ * Implementation of payload_t.verify.
*/
static status_t verify(private_proposal_substructure_t *this)
{
@@ -170,20 +163,16 @@ static status_t verify(private_proposal_substructure_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_proposal_substructure_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(private_proposal_substructure_t *this, encoding_rule_t **rules, size_t *rule_count)
{
*rules = proposal_substructure_encodings;
*rule_count = sizeof(proposal_substructure_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_proposal_substructure_t *this)
{
@@ -191,8 +180,7 @@ static payload_type_t get_type(private_proposal_substructure_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_proposal_substructure_t *this)
{
@@ -200,17 +188,14 @@ static payload_type_t get_next_type(private_proposal_substructure_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_proposal_substructure_t *this,payload_type_t type)
+static void set_next_type(private_proposal_substructure_t *this,payload_type_t 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_proposal_substructure_t *this)
{
@@ -218,19 +203,17 @@ static size_t get_length(private_proposal_substructure_t *this)
}
/**
- * Implements proposal_substructure_t's create_transform_substructure_iterator function.
- * See #proposal_substructure_s.create_transform_substructure_iterator for description.
+ * Implementation of proposal_substructure_t.create_transform_substructure_iterator.
*/
-static status_t create_transform_substructure_iterator (private_proposal_substructure_t *this,iterator_t **iterator,bool forward)
+static void create_transform_substructure_iterator (private_proposal_substructure_t *this,iterator_t **iterator,bool forward)
{
- return (this->transforms->create_iterator(this->transforms,iterator,forward));
+ this->transforms->create_iterator(this->transforms,iterator,forward);
}
/**
- * Implements proposal_substructure_t's add_transform_substructure function.
- * See #proposal_substructure_s.add_transform_substructure for description.
+ * Implementation of proposal_substructure_t.add_transform_substructure.
*/
-static status_t add_transform_substructure (private_proposal_substructure_t *this,transform_substructure_t *transform)
+static void add_transform_substructure (private_proposal_substructure_t *this,transform_substructure_t *transform)
{
status_t status;
if (this->transforms->get_count(this->transforms) > 0)
@@ -243,24 +226,20 @@ static status_t add_transform_substructure (private_proposal_substructure_t *thi
}
transform->set_is_last_transform(transform,TRUE);
- status = this->transforms->insert_last(this->transforms,(void *) transform);
+ this->transforms->insert_last(this->transforms,(void *) transform);
this->compute_length(this);
- return status;
}
/**
- * Implements proposal_substructure_t's set_proposal_number function.
- * See #proposal_substructure_s.set_proposal_number for description.
+ * Implementation of proposal_substructure_t.set_proposal_number.
*/
-static status_t set_proposal_number(private_proposal_substructure_t *this,u_int8_t proposal_number)
+static void set_proposal_number(private_proposal_substructure_t *this,u_int8_t proposal_number)
{
this->proposal_number = proposal_number;
- return SUCCESS;
}
/**
- * Implements proposal_substructure_t's get_proposal_number function.
- * See #proposal_substructure_s.get_proposal_number for description.
+ * Implementation of proposal_substructure_t.get_proposal_number.
*/
static u_int8_t get_proposal_number (private_proposal_substructure_t *this)
{
@@ -268,30 +247,25 @@ static u_int8_t get_proposal_number (private_proposal_substructure_t *this)
}
/**
- * Implements proposal_substructure_t's set_protocol_id function.
- * See #proposal_substructure_s.set_protocol_id for description.
+ * Implementation of proposal_substructure_t.set_protocol_id.
*/
-static status_t set_protocol_id(private_proposal_substructure_t *this,u_int8_t protocol_id)
+static void set_protocol_id(private_proposal_substructure_t *this,u_int8_t protocol_id)
{
this->protocol_id = protocol_id;
- return SUCCESS;
}
/**
- * Implements proposal_substructure_t's get_protocol_id function.
- * See #proposal_substructure_s.get_protocol_id for description.
+ * Implementation of proposal_substructure_t.get_protocol_id.
*/
static u_int8_t get_protocol_id (private_proposal_substructure_t *this)
{
return (this->protocol_id);
}
-
/**
- * Implements proposal_substructure_t's set_spi function.
- * See #proposal_substructure_s.set_spi for description.
+ * Implementation of proposal_substructure_t.set_spi.
*/
-static status_t set_spi (private_proposal_substructure_t *this, chunk_t spi)
+static void set_spi (private_proposal_substructure_t *this, chunk_t spi)
{
/* first delete already set spi value */
if (this->spi.ptr != NULL)
@@ -303,20 +277,13 @@ static status_t set_spi (private_proposal_substructure_t *this, chunk_t spi)
}
this->spi.ptr = allocator_clone_bytes(spi.ptr,spi.len);
- if (this->spi.ptr == NULL)
- {
- return OUT_OF_RES;
- }
this->spi.len = spi.len;
this->spi_size = spi.len;
this->compute_length(this);
-
- return SUCCESS;
}
/**
- * Implements proposal_substructure_t's get_spi function.
- * See #proposal_substructure_s.get_spi for description.
+ * Implementation of proposal_substructure_t.get_spi.
*/
static chunk_t get_spi (private_proposal_substructure_t *this)
{
@@ -327,6 +294,9 @@ static chunk_t get_spi (private_proposal_substructure_t *this)
return spi;
}
+/**
+ * Implementation of proposal_substructure_t.get_info_for_transform_type.
+ */
static status_t get_info_for_transform_type (private_proposal_substructure_t *this,transform_type_t type, u_int16_t *transform_id, u_int16_t *key_length)
{
iterator_t *iterator;
@@ -334,11 +304,8 @@ static status_t get_info_for_transform_type (private_proposal_substructure_t *th
u_int16_t found_transform_id;
u_int16_t found_key_length;
- status = this->transforms->create_iterator(this->transforms,&iterator,TRUE);
- if (status != SUCCESS)
- {
- return status;
- }
+ this->transforms->create_iterator(this->transforms,&iterator,TRUE);
+
while (iterator->has_next(iterator))
{
transform_substructure_t *current_transform;
@@ -359,24 +326,18 @@ static status_t get_info_for_transform_type (private_proposal_substructure_t *th
}
}
iterator->destroy(iterator);
- return FAILED;
+ return NOT_FOUND;
}
/**
- * Implements private_proposal_substructure_t's compute_length function.
- * See #private_proposal_substructure_s.compute_length for description.
+ * Implementation of private_proposal_substructure_t.compute_length.
*/
-static status_t compute_length (private_proposal_substructure_t *this)
+static void compute_length (private_proposal_substructure_t *this)
{
iterator_t *iterator;
- status_t status;
size_t transforms_count = 0;
size_t length = PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH;
- status = this->transforms->create_iterator(this->transforms,&iterator,TRUE);
- if (status != SUCCESS)
- {
- return length;
- }
+ this->transforms->create_iterator(this->transforms,&iterator,TRUE);
while (iterator->has_next(iterator))
{
payload_t * current_transform;
@@ -390,18 +351,15 @@ static status_t compute_length (private_proposal_substructure_t *this)
this->transforms_count= transforms_count;
this->proposal_length = length;
- return SUCCESS;
}
/**
- * Implements proposal_substructure_t's clone function.
- * See #proposal_substructure_s.clone for description.
+ * Implementation of proposal_substructure_t.clone.
*/
-static status_t clone(private_proposal_substructure_t *this, private_proposal_substructure_t **clone)
+static void clone(private_proposal_substructure_t *this, private_proposal_substructure_t **clone)
{
private_proposal_substructure_t * new_clone;
iterator_t *transforms;
- status_t status;
new_clone = (private_proposal_substructure_t *) proposal_substructure_create();
@@ -412,55 +370,26 @@ static status_t clone(private_proposal_substructure_t *this, private_proposal_su
if (this->spi.ptr != NULL)
{
new_clone->spi.ptr = allocator_clone_bytes(this->spi.ptr,this->spi.len);
- if (new_clone->spi.ptr == NULL)
- {
- new_clone->public.destroy(&(new_clone->public));
- return OUT_OF_RES;
- }
new_clone->spi.len = this->spi.len;
}
- status = this->transforms->create_iterator(this->transforms,&transforms,FALSE);
- if (status != SUCCESS)
- {
- new_clone->public.destroy(&(new_clone->public));
- return status;
- }
+ this->transforms->create_iterator(this->transforms,&transforms,FALSE);
while (transforms->has_next(transforms))
{
transform_substructure_t *current_transform;
transform_substructure_t *current_transform_clone;
- status = transforms->current(transforms,(void **) &current_transform);
- if (status != SUCCESS)
- {
- transforms->destroy(transforms);
- new_clone->public.destroy(&(new_clone->public));
- return status;
- }
- status = current_transform->clone(current_transform,&current_transform_clone);
- if (status != SUCCESS)
- {
- transforms->destroy(transforms);
- new_clone->public.destroy(&(new_clone->public));
- return status;
- }
+
+ transforms->current(transforms,(void **) &current_transform);
+
+ current_transform->clone(current_transform,&current_transform_clone);
- status = new_clone->public.add_transform_substructure(&(new_clone->public),current_transform_clone);
- if (status != SUCCESS)
- {
- transforms->destroy(transforms);
- current_transform_clone->destroy(current_transform_clone);
- new_clone->public.destroy(&(new_clone->public));
- return status;
- }
+ new_clone->public.add_transform_substructure(&(new_clone->public),current_transform_clone);
}
transforms->destroy(transforms);
*clone = new_clone;
-
- return SUCCESS;
}
/**
@@ -492,37 +421,33 @@ static status_t destroy(private_proposal_substructure_t *this)
}
/*
- * Described in header
+ * Described in header.
*/
proposal_substructure_t *proposal_substructure_create()
{
private_proposal_substructure_t *this = allocator_alloc_thing(private_proposal_substructure_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.create_transform_substructure_iterator = (status_t (*) (proposal_substructure_t *,iterator_t **,bool)) create_transform_substructure_iterator;
- this->public.add_transform_substructure = (status_t (*) (proposal_substructure_t *,transform_substructure_t *)) add_transform_substructure;
- this->public.set_proposal_number = (status_t (*) (proposal_substructure_t *,u_int8_t))set_proposal_number;
+ this->public.create_transform_substructure_iterator = (void (*) (proposal_substructure_t *,iterator_t **,bool)) create_transform_substructure_iterator;
+ this->public.add_transform_substructure = (void (*) (proposal_substructure_t *,transform_substructure_t *)) add_transform_substructure;
+ this->public.set_proposal_number = (void (*) (proposal_substructure_t *,u_int8_t))set_proposal_number;
this->public.get_proposal_number = (u_int8_t (*) (proposal_substructure_t *)) get_proposal_number;
- this->public.set_protocol_id = (status_t (*) (proposal_substructure_t *,u_int8_t))set_protocol_id;
+ this->public.set_protocol_id = (void (*) (proposal_substructure_t *,u_int8_t))set_protocol_id;
this->public.get_protocol_id = (u_int8_t (*) (proposal_substructure_t *)) get_protocol_id;
this->public.get_info_for_transform_type = (status_t (*) (proposal_substructure_t *,transform_type_t,u_int16_t *, u_int16_t *))get_info_for_transform_type;
- this->public.set_spi = (status_t (*) (proposal_substructure_t *,chunk_t))set_spi;
+ this->public.set_spi = (void (*) (proposal_substructure_t *,chunk_t))set_spi;
this->public.get_spi = (chunk_t (*) (proposal_substructure_t *)) get_spi;
- this->public.clone = (status_t (*) (proposal_substructure_t *, proposal_substructure_t **)) clone;
- this->public.destroy = (status_t (*) (proposal_substructure_t *)) destroy;
+ this->public.clone = (void (*) (proposal_substructure_t *, proposal_substructure_t **)) clone;
+ this->public.destroy = (void (*) (proposal_substructure_t *)) destroy;
/* private functions */
@@ -539,11 +464,6 @@ proposal_substructure_t *proposal_substructure_create()
this->spi.len = 0;
this->transforms = linked_list_create();
-
- if (this->transforms == NULL)
- {
- allocator_free(this);
- return NULL;
- }
+
return (&(this->public));
}
diff --git a/Source/charon/encoding/payloads/proposal_substructure.h b/Source/charon/encoding/payloads/proposal_substructure.h
index ae54ef1d1..d92a92c0e 100644
--- a/Source/charon/encoding/payloads/proposal_substructure.h
+++ b/Source/charon/encoding/payloads/proposal_substructure.h
@@ -1,9 +1,7 @@
/**
* @file proposal_substructure.h
*
- * @brief Declaration of the class proposal_substructure_t.
- *
- * An object of this type represents an IKEv2 PROPOSAL Substructure and contains transforms.
+ * @brief Interface of proposal_substructure_t.
*
*/
@@ -32,7 +30,9 @@
/**
* Length of the proposal substructure header
- * (without spi)
+ * (without spi).
+ *
+ * @ingroup payloads
*/
#define PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH 8
@@ -40,7 +40,9 @@
typedef enum protocol_id_t protocol_id_t;
/**
- * Protocol ID of a proposal
+ * Protocol ID of a proposal.
+ *
+ * @ingroup payloads
*/
enum protocol_id_t {
UNDEFINED_PROTOCOL_ID = 201,
@@ -52,14 +54,15 @@ enum protocol_id_t {
typedef struct proposal_substructure_t proposal_substructure_t;
/**
- * Object representing an IKEv2- PROPOSAL SUBSTRUCTURE
+ * Object representing an IKEv2-PROPOSAL SUBSTRUCTURE.
*
* The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
*
+ * @ingroup payloads
*/
struct proposal_substructure_t {
/**
- * implements payload_t interface
+ * The payload_t interface.
*/
payload_t payload_interface;
@@ -73,11 +76,8 @@ struct proposal_substructure_t {
* @param this calling proposal_substructure_t object
* @param iterator the created iterator is stored at the pointed pointer
* @param[in] forward iterator direction (TRUE: front to end)
- * @return
- * - SUCCESS or
- * - OUT_OF_RES if iterator could not be created
*/
- status_t (*create_transform_substructure_iterator) (proposal_substructure_t *this,iterator_t **iterator, bool forward);
+ void (*create_transform_substructure_iterator) (proposal_substructure_t *this,iterator_t **iterator, bool forward);
/**
* @brief Adds a transform_substructure_t object to this object.
@@ -87,19 +87,16 @@ struct proposal_substructure_t {
*
* @param this calling proposal_substructure_t object
* @param transform transform_substructure_t object to add
- * @return - SUCCESS if succeeded
- * - FAILED otherwise
*/
- status_t (*add_transform_substructure) (proposal_substructure_t *this,transform_substructure_t *transform);
+ void (*add_transform_substructure) (proposal_substructure_t *this,transform_substructure_t *transform);
/**
* @brief Sets the proposal number of current proposal.
*
* @param this calling proposal_substructure_t object
* @param id proposal number to set
- * @return - SUCCESS
*/
- status_t (*set_proposal_number) (proposal_substructure_t *this,u_int8_t proposal_number);
+ void (*set_proposal_number) (proposal_substructure_t *this,u_int8_t proposal_number);
/**
* @brief get proposal number of current proposal.
@@ -114,9 +111,8 @@ struct proposal_substructure_t {
*
* @param this calling proposal_substructure_t object
* @param id protocol id to set
- * @return - SUCCESS
*/
- status_t (*set_protocol_id) (proposal_substructure_t *this,u_int8_t protocol_id);
+ void (*set_protocol_id) (proposal_substructure_t *this,u_int8_t protocol_id);
/**
* @brief get protocol id of current proposal.
@@ -136,8 +132,7 @@ struct proposal_substructure_t {
* @return
* - SUCCESS if transform type is part of this proposal and
* all data (incl. key length) could be fetched
- * - FAILED if transform type is not part of this proposal
- * - OUT_OF_RES
+ * - NOT_FOUND if transform type is not part of this proposal
*/
status_t (*get_info_for_transform_type) (proposal_substructure_t *this,transform_type_t type, u_int16_t *transform_id, u_int16_t *key_length);
@@ -159,41 +154,32 @@ struct proposal_substructure_t {
*
* @param this calling proposal_substructure_t object
* @param spi chunk_t pointing to the value to set
- * @return
- * - SUCCESS or
- * - OUT_OF_RES
*/
- status_t (*set_spi) (proposal_substructure_t *this, chunk_t spi);
+ void (*set_spi) (proposal_substructure_t *this, chunk_t spi);
/**
* @brief Clones an proposal_substructure_t object.
*
* @param this proposal_substructure_t object to clone
* @param clone cloned object will be written there
- * @return
- * - SUCCESS
- * - OUT_OF_RES
*/
- status_t (*clone) (proposal_substructure_t *this,proposal_substructure_t **clone);
+ void (*clone) (proposal_substructure_t *this,proposal_substructure_t **clone);
/**
* @brief Destroys an proposal_substructure_t object.
*
* @param this proposal_substructure_t object to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (proposal_substructure_t *this);
+ void (*destroy) (proposal_substructure_t *this);
};
/**
* @brief Creates an empty proposal_substructure_t object
*
- * @return
- * - created proposal_substructure_t object, or
- * - NULL if failed
+ * @return created proposal_substructure_t object
+ *
+ * @ingroup payloads
*/
-
proposal_substructure_t *proposal_substructure_create();
diff --git a/Source/charon/encoding/payloads/sa_payload.c b/Source/charon/encoding/payloads/sa_payload.c
index c760dc3a2..1a137de9d 100644
--- a/Source/charon/encoding/payloads/sa_payload.c
+++ b/Source/charon/encoding/payloads/sa_payload.c
@@ -1,10 +1,7 @@
/**
* @file sa_payload.c
*
- * @brief Declaration of the class sa_payload_t.
- *
- * An object of this type represents an IKEv2 SA-Payload and contains proposal
- * substructures.
+ * @brief Implementation of sa_payload_t.
*
*/
@@ -36,32 +33,32 @@
typedef struct private_sa_payload_t private_sa_payload_t;
/**
- * Private data of an sa_payload_t' Object
+ * Private data of an sa_payload_t object.
*
*/
struct private_sa_payload_t {
/**
- * public sa_payload_t interface
+ * Public sa_payload_t interface.
*/
sa_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;
/**
- * Proposals in this payload are stored in a linked_list_t
+ * Proposals in this payload are stored in a linked_list_t.
*/
linked_list_t * proposals;
@@ -69,10 +66,8 @@ struct private_sa_payload_t {
* @brief Computes the length of this payload.
*
* @param this calling private_sa_payload_t object
- * @return
- * SUCCESS in any case
*/
- status_t (*compute_length) (private_sa_payload_t *this);
+ void (*compute_length) (private_sa_payload_t *this);
};
/**
@@ -115,8 +110,7 @@ encoding_rule_t sa_payload_encodings[] = {
*/
/**
- * Implements payload_t's verify function.
- * See #payload_s.verify for description.
+ * Implementation of payload_t.verify.
*/
static status_t verify(private_sa_payload_t *this)
{
@@ -177,8 +171,7 @@ static status_t verify(private_sa_payload_t *this)
/**
- * Implements payload_t's and sa_payload_t's destroy function.
- * See #payload_s.destroy or sa_payload_s.destroy for description.
+ * Implementation of payload_t.destroy and sa_payload_t.destroy.
*/
static status_t destroy(private_sa_payload_t *this)
{
@@ -186,10 +179,7 @@ static status_t destroy(private_sa_payload_t *this)
while (this->proposals->get_count(this->proposals) > 0)
{
proposal_substructure_t *current_proposal;
- if (this->proposals->remove_last(this->proposals,(void **)&current_proposal) != SUCCESS)
- {
- break;
- }
+ this->proposals->remove_last(this->proposals,(void **)&current_proposal);
current_proposal->destroy(current_proposal);
}
this->proposals->destroy(this->proposals);
@@ -200,20 +190,16 @@ static status_t destroy(private_sa_payload_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_sa_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(private_sa_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
{
*rules = sa_payload_encodings;
*rule_count = sizeof(sa_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_sa_payload_t *this)
{
@@ -221,8 +207,7 @@ static payload_type_t get_type(private_sa_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_sa_payload_t *this)
{
@@ -230,18 +215,15 @@ static payload_type_t get_next_type(private_sa_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_sa_payload_t *this,payload_type_t type)
+static void set_next_type(private_sa_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_sa_payload_t *this)
{
@@ -250,40 +232,30 @@ static size_t get_length(private_sa_payload_t *this)
}
/**
- * Implements sa_payload_t's create_proposal_substructure_iterator function.
- * See #sa_payload_s.create_proposal_substructure_iterator for description.
+ * Implementation of sa_payload_t.create_proposal_substructure_iterator.
*/
-static status_t create_proposal_substructure_iterator (private_sa_payload_t *this,iterator_t **iterator,bool forward)
+static void create_proposal_substructure_iterator (private_sa_payload_t *this,iterator_t **iterator,bool forward)
{
- return (this->proposals->create_iterator(this->proposals,iterator,forward));
+ this->proposals->create_iterator(this->proposals,iterator,forward);
}
/**
- * Implements sa_payload_t's add_proposal_substructure function.
- * See #sa_payload_s.add_proposal_substructure for description.
+ * Implementation of sa_payload_t.add_proposal_substructure.
*/
-static status_t add_proposal_substructure (private_sa_payload_t *this,proposal_substructure_t *proposal)
+static void add_proposal_substructure (private_sa_payload_t *this,proposal_substructure_t *proposal)
{
- status_t status;
- status = this->proposals->insert_last(this->proposals,(void *) proposal);
+ this->proposals->insert_last(this->proposals,(void *) proposal);
this->compute_length(this);
- return status;
}
/**
- * Implements private_sa_payload_t's compute_length function.
- * See #private_sa_payload_s.compute_length for description.
+ * Implementation of private_sa_payload_t.compute_length.
*/
-static status_t compute_length (private_sa_payload_t *this)
+static void compute_length (private_sa_payload_t *this)
{
iterator_t *iterator;
- status_t status;
size_t length = SA_PAYLOAD_HEADER_LENGTH;
- status = this->proposals->create_iterator(this->proposals,&iterator,TRUE);
- if (status != SUCCESS)
- {
- return length;
- }
+ this->proposals->create_iterator(this->proposals,&iterator,TRUE);
while (iterator->has_next(iterator))
{
payload_t *current_proposal;
@@ -293,34 +265,28 @@ static status_t compute_length (private_sa_payload_t *this)
iterator->destroy(iterator);
this->payload_length = length;
-
- return SUCCESS;
}
/*
- * Described in header
+ * Described in header.
*/
sa_payload_t *sa_payload_create()
{
private_sa_payload_t *this = allocator_alloc_thing(private_sa_payload_t);
- if (this == NULL)
- {
- return NULL;
- }
/* public 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.create_proposal_substructure_iterator = (status_t (*) (sa_payload_t *,iterator_t **,bool)) create_proposal_substructure_iterator;
- this->public.add_proposal_substructure = (status_t (*) (sa_payload_t *,proposal_substructure_t *)) add_proposal_substructure;
- this->public.destroy = (status_t (*) (sa_payload_t *)) destroy;
+ this->public.create_proposal_substructure_iterator = (void (*) (sa_payload_t *,iterator_t **,bool)) create_proposal_substructure_iterator;
+ this->public.add_proposal_substructure = (void (*) (sa_payload_t *,proposal_substructure_t *)) add_proposal_substructure;
+ this->public.destroy = (void (*) (sa_payload_t *)) destroy;
/* private functions */
this->compute_length = compute_length;
@@ -331,12 +297,6 @@ sa_payload_t *sa_payload_create()
this->payload_length = SA_PAYLOAD_HEADER_LENGTH;
this->proposals = linked_list_create();
-
- if (this->proposals == NULL)
- {
- allocator_free(this);
- return NULL;
- }
return (&(this->public));
}
diff --git a/Source/charon/encoding/payloads/sa_payload.h b/Source/charon/encoding/payloads/sa_payload.h
index 7eada847c..5e5d94550 100644
--- a/Source/charon/encoding/payloads/sa_payload.h
+++ b/Source/charon/encoding/payloads/sa_payload.h
@@ -1,10 +1,7 @@
/**
* @file sa_payload.h
*
- * @brief Declaration of the class sa_payload_t.
- *
- * An object of this type represents an IKEv2 SA-Payload and contains proposal
- * substructures.
+ * @brief Interface of sa_payload_t.
*
*/
@@ -32,26 +29,31 @@
#include <utils/linked_list.h>
/**
- * Critical flag must not be set
+ * Critical flag must not be set.
+ *
+ * @ingroup payloads
*/
#define SA_PAYLOAD_CRITICAL_FLAG FALSE;
/**
- * SA_PAYLOAD length in bytes without any proposal substructure
+ * SA_PAYLOAD length in bytes without any proposal substructure.
+ *
+ * @ingroup payloads
*/
#define SA_PAYLOAD_HEADER_LENGTH 4
typedef struct sa_payload_t sa_payload_t;
/**
- * Object representing an IKEv2-SA Payload
+ * Class representing an IKEv2-SA Payload.
*
* The SA Payload format is described in RFC section 3.3.
*
+ * @ingroup payloads
*/
struct sa_payload_t {
/**
- * implements payload_t interface
+ * The payload_t interface.
*/
payload_t payload_interface;
@@ -67,11 +69,8 @@ struct sa_payload_t {
* @param this calling sa_payload_t object
* @param iterator the created iterator is stored at the pointed pointer
* @param[in] forward iterator direction (TRUE: front to end)
- * @return
- * - SUCCESS or
- * - OUT_OF_RES if iterator could not be created
*/
- status_t (*create_proposal_substructure_iterator) (sa_payload_t *this,iterator_t **iterator, bool forward);
+ void (*create_proposal_substructure_iterator) (sa_payload_t *this,iterator_t **iterator, bool forward);
/**
* @brief Adds a proposal_substructure_t object to this object.
@@ -81,29 +80,24 @@ struct sa_payload_t {
*
* @param this calling sa_payload_t object
* @param proposal proposal_substructure_t object to add
- * @return - SUCCESS if succeeded
- * - FAILED otherwise
*/
- status_t (*add_proposal_substructure) (sa_payload_t *this,proposal_substructure_t *proposal);
+ void (*add_proposal_substructure) (sa_payload_t *this,proposal_substructure_t *proposal);
/**
* @brief Destroys an sa_payload_t object.
*
* @param this sa_payload_t object to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (sa_payload_t *this);
+ void (*destroy) (sa_payload_t *this);
};
/**
* @brief Creates an empty sa_payload_t object
*
- * @return
- * - created sa_payload_t object, or
- * - NULL if failed
+ * @return created sa_payload_t object
+ *
+ * @ingroup payloads
*/
-
sa_payload_t *sa_payload_create();
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;
diff --git a/Source/charon/encoding/payloads/transform_attribute.h b/Source/charon/encoding/payloads/transform_attribute.h
index c268a7b1e..c436012ce 100644
--- a/Source/charon/encoding/payloads/transform_attribute.h
+++ b/Source/charon/encoding/payloads/transform_attribute.h
@@ -1,9 +1,7 @@
/**
* @file transform_attribute.h
*
- * @brief Declaration of the class transform_attribute_t.
- *
- * An object of this type represents an IKEv2 TRANSFORM attribute.
+ * @brief Interface of transform_attribute_t.
*
*/
@@ -32,7 +30,9 @@
typedef enum transform_attribute_type_t transform_attribute_type_t;
/**
- * Type of the attribute, as in IKEv2 draft 3.3.5
+ * Type of the attribute, as in IKEv2 draft 3.3.5.
+ *
+ * @ingroup payloads
*/
enum transform_attribute_type_t {
ATTRIBUTE_UNDEFINED = 16384,
@@ -40,28 +40,31 @@ enum transform_attribute_type_t {
};
/**
- * string mappings for transform_attribute_type_t
+ * String mappings for transform_attribute_type_t.
+ *
+ * @ingroup payloads
*/
extern mapping_t transform_attribute_type_m[];
typedef struct transform_attribute_t transform_attribute_t;
/**
- * Object representing an IKEv2- TRANSFORM Attribute
+ * Object representing an IKEv2- TRANSFORM Attribute.
*
* The TRANSFORM ATTRIBUTE format is described in RFC section 3.3.5.
*
+ * @ingroup payloads
*/
struct transform_attribute_t {
/**
- * implements payload_t interface
+ * The payload_t interface.
*/
payload_t payload_interface;
/**
- * @brief Returns the currently set value of the attribute
+ * @brief Returns the currently set value of the attribute.
*
- * @warning Returned data are not copied
+ * @warning Returned data are not copied.
*
* @param this calling transform_attribute_t object
* @return chunk_t pointing to the value
@@ -69,9 +72,9 @@ struct transform_attribute_t {
chunk_t (*get_value_chunk) (transform_attribute_t *this);
/**
- * @brief Returns the currently set value of the attribute
+ * @brief Returns the currently set value of the attribute.
*
- * @warning Returned data are not copied
+ * @warning Returned data are not copied.
*
* @param this calling transform_attribute_t object
* @return value
@@ -81,35 +84,28 @@ struct transform_attribute_t {
/**
* @brief Sets the value of the attribute.
*
- * @warning Value is getting copied
+ * @warning Value is getting copied.
*
* @param this calling transform_attribute_t object
* @param value chunk_t pointing to the value to set
- * @return
- * - SUCCESS or
- * - OUT_OF_RES
*/
- status_t (*set_value_chunk) (transform_attribute_t *this, chunk_t value);
+ void (*set_value_chunk) (transform_attribute_t *this, chunk_t value);
/**
* @brief Sets the value of the attribute.
*
* @param this calling transform_attribute_t object
* @param value value to set
- * @return
- * - SUCCESS or
- * - OUT_OF_RES
*/
- status_t (*set_value) (transform_attribute_t *this, u_int16_t value);
+ void (*set_value) (transform_attribute_t *this, u_int16_t value);
/**
* @brief Sets the type of the attribute.
*
* @param this calling transform_attribute_t object
* @param type type to set (most significant bit is set to zero)
- * @return SUCCESS
*/
- status_t (*set_attribute_type) (transform_attribute_t *this, u_int16_t type);
+ void (*set_attribute_type) (transform_attribute_t *this, u_int16_t type);
/**
* @brief get the type of the attribute.
@@ -124,30 +120,23 @@ struct transform_attribute_t {
*
* @param this transform_attribute_t object to clone
* @param clone the new clone will be written there
- * @return
- * - OUT_OF_RES
- * - SUCCESS
*/
- status_t (*clone) (transform_attribute_t *this,transform_attribute_t **clone);
+ void (*clone) (transform_attribute_t *this,transform_attribute_t **clone);
/**
* @brief Destroys an transform_attribute_t object.
*
* @param this transform_attribute_t object to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (transform_attribute_t *this);
+ void (*destroy) (transform_attribute_t *this);
};
/**
* @brief Creates an empty transform_attribute_t object
*
- * @return
- * - created transform_attribute_t object, or
- * - NULL if failed
+ * @return created transform_attribute_t object
+ * @ingroup payloads
*/
-
transform_attribute_t *transform_attribute_create();
#endif /*TRANSFORM_ATTRIBUTE_H_*/
diff --git a/Source/charon/encoding/payloads/transform_substructure.c b/Source/charon/encoding/payloads/transform_substructure.c
index ff08f6c00..cbbfb41e9 100644
--- a/Source/charon/encoding/payloads/transform_substructure.c
+++ b/Source/charon/encoding/payloads/transform_substructure.c
@@ -1,9 +1,7 @@
/**
* @file transform_substructure.h
*
- * @brief Declaration of the class transform_substructure_t.
- *
- * An object of this type represents an IKEv2 TRANSFORM Substructure and contains Attributes.
+ * @brief Implementation of transform_substructure_t.
*
*/
@@ -37,39 +35,39 @@
typedef struct private_transform_substructure_t private_transform_substructure_t;
/**
- * Private data of an transform_substructure_t' Object
+ * Private data of an transform_substructure_t object.
*
*/
struct private_transform_substructure_t {
/**
- * public transform_substructure_t interface
+ * Public transform_substructure_t interface.
*/
transform_substructure_t public;
/**
- * next payload type
+ * Next payload type.
*/
u_int8_t next_payload;
/**
- * Length of this payload
+ * Length of this payload.
*/
u_int16_t transform_length;
/**
- * Type of the transform
+ * Type of the transform.
*/
u_int8_t transform_type;
/**
- * Transform ID
+ * Transform ID.
*/
u_int16_t transform_id;
/**
- * Transforms Attributes are stored in a linked_list_t
+ * Transforms Attributes are stored in a linked_list_t.
*/
linked_list_t *attributes;
@@ -77,15 +75,13 @@ struct private_transform_substructure_t {
* @brief Computes the length of this substructure.
*
* @param this calling private_transform_substructure_t object
- * @return
- * SUCCESS in any case
*/
- status_t (*compute_length) (private_transform_substructure_t *this);
+ void (*compute_length) (private_transform_substructure_t *this);
};
/**
- * string mappings for transform_type_t
+ * String mappings for transform_type_t.
*/
mapping_t transform_type_m[] = {
{UNDEFINED_TRANSFORM_TYPE, "UNDEFINED_TRANSFORM_TYPE"},
@@ -99,7 +95,7 @@ mapping_t transform_type_m[] = {
/**
- * string mappings for extended_sequence_numbers_t
+ * String mappings for extended_sequence_numbers_t.
*/
mapping_t extended_sequence_numbers_m[] = {
{NO_EXT_SEQ_NUMBERS, "NO_EXT_SEQ_NUMBERS"},
@@ -108,7 +104,7 @@ mapping_t extended_sequence_numbers_m[] = {
};
/**
- * Encoding rules to parse or generate a Transform substructure
+ * Encoding rules to parse or generate a Transform substructure.
*
* The defined offsets are the positions in a object of type
* private_transform_substructure_t.
@@ -148,8 +144,7 @@ encoding_rule_t transform_substructure_encodings[] = {
/**
- * Implements payload_t's verify function.
- * See #payload_s.verify for description.
+ * Implementation of payload_t.verify.
*/
static status_t verify(private_transform_substructure_t *this)
{
@@ -229,20 +224,16 @@ static status_t verify(private_transform_substructure_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_substructure_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(private_transform_substructure_t *this, encoding_rule_t **rules, size_t *rule_count)
{
*rules = transform_substructure_encodings;
*rule_count = sizeof(transform_substructure_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_substructure_t *this)
{
@@ -250,8 +241,7 @@ static payload_type_t get_type(private_transform_substructure_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_substructure_t *this)
{
@@ -259,8 +249,7 @@ static payload_type_t get_next_type(private_transform_substructure_t *this)
}
/**
- * 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_transform_substructure_t *this)
{
@@ -270,39 +259,32 @@ static size_t get_length(private_transform_substructure_t *this)
}
/**
- * Implements transform_substructure_t's create_transform_attribute_iterator function.
- * See #transform_substructure_s.create_transform_attribute_iterator for description.
+ * Implementation of transform_substructure_t.create_transform_attribute_iterator.
*/
-static status_t create_transform_attribute_iterator (private_transform_substructure_t *this,iterator_t **iterator,bool forward)
+static void create_transform_attribute_iterator (private_transform_substructure_t *this,iterator_t **iterator,bool forward)
{
- return (this->attributes->create_iterator(this->attributes,iterator,forward));
+ this->attributes->create_iterator(this->attributes,iterator,forward);
}
/**
- * Implements transform_substructure_t's add_transform_attribute function.
- * See #transform_substructure_s.add_transform_attribute for description.
+ * Implementation of transform_substructure_t.add_transform_attribute.
*/
-static status_t add_transform_attribute (private_transform_substructure_t *this,transform_attribute_t *attribute)
+static void add_transform_attribute (private_transform_substructure_t *this,transform_attribute_t *attribute)
{
- status_t status;
- status = this->attributes->insert_last(this->attributes,(void *) attribute);
+ this->attributes->insert_last(this->attributes,(void *) attribute);
this->compute_length(this);
- return status;
}
/**
- * Implements transform_substructure_t's set_is_last_transform function.
- * See #transform_substructure_s.set_is_last_transform for description.
+ * Implementation of transform_substructure_t.set_is_last_transform.
*/
-static status_t set_is_last_transform (private_transform_substructure_t *this, bool is_last)
+static void set_is_last_transform (private_transform_substructure_t *this, bool is_last)
{
this->next_payload = (is_last) ? 0: TRANSFORM_TYPE_VALUE;
- return SUCCESS;
}
/**
- * Implements transform_substructure_t's get_is_last_transform function.
- * See #transform_substructure_s.get_is_last_transform for description.
+ * Implementation of transform_substructure_t.get_is_last_transform.
*/
static bool get_is_last_transform (private_transform_substructure_t *this)
{
@@ -310,27 +292,22 @@ static bool get_is_last_transform (private_transform_substructure_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_substructure_t *this,payload_type_t type)
+static void set_next_type(private_transform_substructure_t *this,payload_type_t type)
{
- return SUCCESS;
}
/**
- * Implements transform_substructure_t's set_transform_type function.
- * See #transform_substructure_s.set_transform_type for description.
+ * Implementation of transform_substructure_t.set_transform_type.
*/
-static status_t set_transform_type (private_transform_substructure_t *this,u_int8_t type)
+static void set_transform_type (private_transform_substructure_t *this,u_int8_t type)
{
this->transform_type = type;
- return SUCCESS;
}
/**
- * Implements transform_substructure_t's get_transform_type function.
- * See #transform_substructure_s.get_transform_type for description.
+ * Implementation of transform_substructure_t.get_transform_type.
*/
static u_int8_t get_transform_type (private_transform_substructure_t *this)
{
@@ -338,18 +315,15 @@ static u_int8_t get_transform_type (private_transform_substructure_t *this)
}
/**
- * Implements transform_substructure_t's set_transform_id function.
- * See #transform_substructure_s.set_transform_id for description.
+ * Implementation of transform_substructure_t.set_transform_id.
*/
-static status_t set_transform_id (private_transform_substructure_t *this,u_int16_t id)
+static void set_transform_id (private_transform_substructure_t *this,u_int16_t id)
{
this->transform_id = id;
- return SUCCESS;
}
/**
- * Implements transform_substructure_t's get_transform_id function.
- * See #transform_substructure_s.get_transform_id for description.
+ * Implementation of transform_substructure_t.get_transform_id.
*/
static u_int16_t get_transform_id (private_transform_substructure_t *this)
{
@@ -357,19 +331,13 @@ static u_int16_t get_transform_id (private_transform_substructure_t *this)
}
/**
- * Implements private_transform_substructure_t's compute_length function.
- * See #private_transform_substructure_s.compute_length for description.
+ * Implementation of private_transform_substructure_t.compute_length.
*/
-static status_t compute_length (private_transform_substructure_t *this)
+static void compute_length (private_transform_substructure_t *this)
{
iterator_t *iterator;
- status_t status;
size_t length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH;
- status = this->attributes->create_iterator(this->attributes,&iterator,TRUE);
- if (status != SUCCESS)
- {
- return length;
- }
+ this->attributes->create_iterator(this->attributes,&iterator,TRUE);
while (iterator->has_next(iterator))
{
payload_t * current_attribute;
@@ -380,18 +348,15 @@ static status_t compute_length (private_transform_substructure_t *this)
this->transform_length = length;
- return SUCCESS;
}
/**
- * Implements transform_substructure_t's clone function.
- * See transform_substructure_s.clone for description.
+ * Implementation of transform_substructure_t.clone.
*/
-static status_t clone(private_transform_substructure_t *this,transform_substructure_t **clone)
+static void clone(private_transform_substructure_t *this,transform_substructure_t **clone)
{
private_transform_substructure_t *new_clone;
iterator_t *attributes;
- status_t status;
new_clone = (private_transform_substructure_t *) transform_substructure_create();
@@ -399,46 +364,22 @@ static status_t clone(private_transform_substructure_t *this,transform_substruct
new_clone->transform_type = this->transform_type;
new_clone->transform_id = this->transform_id;
- status = this->attributes->create_iterator(this->attributes,&attributes,FALSE);
- if (status != SUCCESS)
- {
- new_clone->public.destroy(&(new_clone->public));
- return status;
- }
+ this->attributes->create_iterator(this->attributes,&attributes,FALSE);
while (attributes->has_next(attributes))
{
transform_attribute_t *current_attribute;
transform_attribute_t *current_attribute_clone;
- status = attributes->current(attributes,(void **) &current_attribute);
- if (status != SUCCESS)
- {
- attributes->destroy(attributes);
- new_clone->public.destroy(&(new_clone->public));
- return status;
- }
- status = current_attribute->clone(current_attribute,&current_attribute_clone);
- if (status != SUCCESS)
- {
- attributes->destroy(attributes);
- new_clone->public.destroy(&(new_clone->public));
- return status;
- }
+ attributes->current(attributes,(void **) &current_attribute);
+
+ current_attribute->clone(current_attribute,&current_attribute_clone);
- status = new_clone->public.add_transform_attribute(&(new_clone->public),current_attribute_clone);
- if (status != SUCCESS)
- {
- attributes->destroy(attributes);
- current_attribute_clone->destroy(current_attribute_clone);
- new_clone->public.destroy(&(new_clone->public));
- return status;
- }
+ new_clone->public.add_transform_attribute(&(new_clone->public),current_attribute_clone);
}
attributes->destroy(attributes);
*clone = &(new_clone->public);
- return SUCCESS;
}
@@ -448,23 +389,14 @@ static status_t clone(private_transform_substructure_t *this,transform_substruct
static status_t get_key_length(private_transform_substructure_t *this, u_int16_t *key_length)
{
iterator_t *attributes;
- status_t status;
-
- status = this->attributes->create_iterator(this->attributes,&attributes,TRUE);
- if (status != SUCCESS)
- {
- return status;
- }
+ this->attributes->create_iterator(this->attributes,&attributes,TRUE);
+
while (attributes->has_next(attributes))
{
transform_attribute_t *current_attribute;
- status = attributes->current(attributes,(void **) &current_attribute);
- if (status != SUCCESS)
- {
- attributes->destroy(attributes);
- return status;
- }
+ attributes->current(attributes,(void **) &current_attribute);
+
if (current_attribute->get_attribute_type(current_attribute) == KEY_LENGTH)
{
*key_length = current_attribute->get_value(current_attribute);
@@ -480,26 +412,20 @@ static status_t get_key_length(private_transform_substructure_t *this, u_int16_t
/**
- * Implements payload_t's and transform_substructure_t's destroy function.
- * See #payload_s.destroy or transform_substructure_s.destroy for description.
+ * Implementation of transform_substructure_t.destroy and payload_t.destroy.
*/
-static status_t destroy(private_transform_substructure_t *this)
+static void destroy(private_transform_substructure_t *this)
{
/* all proposals are getting destroyed */
while (this->attributes->get_count(this->attributes) > 0)
{
transform_attribute_t *current_attribute;
- if (this->attributes->remove_last(this->attributes,(void **)&current_attribute) != SUCCESS)
- {
- break;
- }
+ this->attributes->remove_last(this->attributes,(void **)&current_attribute);
current_attribute->destroy(current_attribute);
}
this->attributes->destroy(this->attributes);
allocator_free(this);
-
- return SUCCESS;
}
/*
@@ -508,32 +434,28 @@ static status_t destroy(private_transform_substructure_t *this)
transform_substructure_t *transform_substructure_create()
{
private_transform_substructure_t *this = allocator_alloc_thing(private_transform_substructure_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.create_transform_attribute_iterator = (status_t (*) (transform_substructure_t *,iterator_t **,bool)) create_transform_attribute_iterator;
- this->public.add_transform_attribute = (status_t (*) (transform_substructure_t *,transform_attribute_t *)) add_transform_attribute;
- this->public.set_is_last_transform = (status_t (*) (transform_substructure_t *,bool)) set_is_last_transform;
+ this->public.create_transform_attribute_iterator = (void (*) (transform_substructure_t *,iterator_t **,bool)) create_transform_attribute_iterator;
+ this->public.add_transform_attribute = (void (*) (transform_substructure_t *,transform_attribute_t *)) add_transform_attribute;
+ this->public.set_is_last_transform = (void (*) (transform_substructure_t *,bool)) set_is_last_transform;
this->public.get_is_last_transform = (bool (*) (transform_substructure_t *)) get_is_last_transform;
- this->public.set_transform_type = (status_t (*) (transform_substructure_t *,u_int8_t)) set_transform_type;
+ this->public.set_transform_type = (void (*) (transform_substructure_t *,u_int8_t)) set_transform_type;
this->public.get_transform_type = (u_int8_t (*) (transform_substructure_t *)) get_transform_type;
- this->public.set_transform_id = (status_t (*) (transform_substructure_t *,u_int16_t)) set_transform_id;
+ this->public.set_transform_id = (void (*) (transform_substructure_t *,u_int16_t)) set_transform_id;
this->public.get_transform_id = (u_int16_t (*) (transform_substructure_t *)) get_transform_id;
this->public.get_key_length = (status_t (*) (transform_substructure_t *,u_int16_t *)) get_key_length;
- this->public.clone = (status_t (*) (transform_substructure_t *,transform_substructure_t **)) clone;
- this->public.destroy = (status_t (*) (transform_substructure_t *)) destroy;
+ this->public.clone = (void (*) (transform_substructure_t *,transform_substructure_t **)) clone;
+ this->public.destroy = (void (*) (transform_substructure_t *)) destroy;
/* private functions */
this->compute_length = compute_length;
@@ -543,13 +465,7 @@ transform_substructure_t *transform_substructure_create()
this->transform_length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH;
this->transform_id = 0;
this->transform_type = 0;
-
this->attributes = linked_list_create();
- if (this->attributes == NULL)
- {
- allocator_free(this);
- return NULL;
- }
return (&(this->public));
}
diff --git a/Source/charon/encoding/payloads/transform_substructure.h b/Source/charon/encoding/payloads/transform_substructure.h
index 51119d275..39f642620 100644
--- a/Source/charon/encoding/payloads/transform_substructure.h
+++ b/Source/charon/encoding/payloads/transform_substructure.h
@@ -1,9 +1,7 @@
/**
* @file transform_substructure.h
*
- * @brief Declaration of the class transform_substructure_t.
- *
- * An object of this type represents an IKEv2 TRANSFORM Substructure and contains Attributes.
+ * @brief Interface of transform_substructure_t.
*
*/
@@ -37,12 +35,16 @@
/**
- * IKEv1 Value for a transform payload
+ * IKEv1 Value for a transform payload.
+ *
+ * @ingroup payloads
*/
#define TRANSFORM_TYPE_VALUE 3
/**
- * Length of the transform substructure header in bytes
+ * Length of the transform substructure header in bytes.
+ *
+ * @ingroup payloads
*/
#define TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH 8
@@ -50,7 +52,9 @@
typedef enum transform_type_t transform_type_t;
/**
- * Type of a transform, as in IKEv2 draft 3.3.2
+ * Type of a transform, as in IKEv2 draft 3.3.2.
+ *
+ * @ingroup payloads
*/
enum transform_type_t {
UNDEFINED_TRANSFORM_TYPE = 241,
@@ -62,7 +66,9 @@ enum transform_type_t {
};
/**
- * string mappings for transform_type_t
+ * String mappings for transform_type_t.
+ *
+ * @ingroup payloads
*/
extern mapping_t transform_type_m[];
@@ -70,7 +76,9 @@ extern mapping_t transform_type_m[];
typedef enum extended_sequence_numbers_t extended_sequence_numbers_t;
/**
- * Extended sequence numbers, as in IKEv2 draft 3.3.2
+ * Extended sequence numbers, as in IKEv2 draft 3.3.2.
+ *
+ * @ingroup payloads
*/
enum extended_sequence_numbers_t {
NO_EXT_SEQ_NUMBERS = 0,
@@ -78,21 +86,24 @@ enum extended_sequence_numbers_t {
};
/**
- * string mappings for extended_sequence_numbers_t
+ * String mappings for extended_sequence_numbers_t.
+ *
+ * @ingroup payloads
*/
extern mapping_t extended_sequence_numbers_m[];
typedef struct transform_substructure_t transform_substructure_t;
/**
- * Object representing an IKEv2- TRANSFORM SUBSTRUCTURE
+ * Object representing an IKEv2- TRANSFORM SUBSTRUCTURE.
*
* The TRANSFORM SUBSTRUCTURE format is described in RFC section 3.3.2.
*
+ * @ingroup payloads
*/
struct transform_substructure_t {
/**
- * implements payload_t interface
+ * The payload_t interface.
*/
payload_t payload_interface;
@@ -108,11 +119,8 @@ struct transform_substructure_t {
* @param this calling transform_substructure_t object
* @param iterator the created iterator is stored at the pointed pointer
* @param[in] forward iterator direction (TRUE: front to end)
- * @return
- * - SUCCESS or
- * - OUT_OF_RES if iterator could not be created
*/
- status_t (*create_transform_attribute_iterator) (transform_substructure_t *this,iterator_t **iterator, bool forward);
+ void (*create_transform_attribute_iterator) (transform_substructure_t *this,iterator_t **iterator, bool forward);
/**
* @brief Adds a transform_attribute_t object to this object.
@@ -122,10 +130,8 @@ struct transform_substructure_t {
*
* @param this calling transform_substructure_t object
* @param proposal transform_attribute_t object to add
- * @return - SUCCESS if succeeded
- * - FAILED otherwise
*/
- status_t (*add_transform_attribute) (transform_substructure_t *this,transform_attribute_t *attribute);
+ void (*add_transform_attribute) (transform_substructure_t *this,transform_attribute_t *attribute);
/**
* @brief Sets the next_payload field of this substructure
@@ -135,9 +141,8 @@ struct transform_substructure_t {
*
* @param this calling transform_substructure_t object
* @param is_last When TRUE, next payload field is set to 0, otherwise to 3
- * @return - SUCCESS
*/
- status_t (*set_is_last_transform) (transform_substructure_t *this, bool is_last);
+ void (*set_is_last_transform) (transform_substructure_t *this, bool is_last);
/**
* @brief Checks if this is the last transform.
@@ -152,9 +157,8 @@ struct transform_substructure_t {
*
* @param this calling transform_substructure_t object
* @param type type value to set
- * @return - SUCCESS
*/
- status_t (*set_transform_type) (transform_substructure_t *this,u_int8_t type);
+ void (*set_transform_type) (transform_substructure_t *this,u_int8_t type);
/**
* @brief get transform type of the current transform.
@@ -169,9 +173,8 @@ struct transform_substructure_t {
*
* @param this calling transform_substructure_t object
* @param id transform id to set
- * @return - SUCCESS
*/
- status_t (*set_transform_id) (transform_substructure_t *this,u_int16_t id);
+ void (*set_transform_id) (transform_substructure_t *this,u_int16_t id);
/**
* @brief get transform id of the current transform.
@@ -190,7 +193,6 @@ struct transform_substructure_t {
* - SUCCESS if a key length attribute is contained
* - FAILED if no key length attribute is part of this
* transform or key length uses more then 16 bit!
- * - OUT_OF_RES
*/
status_t (*get_key_length) (transform_substructure_t *this,u_int16_t *key_length);
@@ -200,30 +202,24 @@ struct transform_substructure_t {
* @param this transform_substructure_t object to clone
* @param clone pointer to a transform_substructure_t object pointer
* where the new object is stored to.
- * @return
- * - OUT_OF_RES
- * - SUCCESS in any case
*/
- status_t (*clone) (transform_substructure_t *this,transform_substructure_t **clone);
+ void (*clone) (transform_substructure_t *this,transform_substructure_t **clone);
/**
* @brief Destroys an transform_substructure_t object.
*
* @param this transform_substructure_t object to destroy
- * @return
- * SUCCESS in any case
*/
- status_t (*destroy) (transform_substructure_t *this);
+ void (*destroy) (transform_substructure_t *this);
};
/**
* @brief Creates an empty transform_substructure_t object
*
- * @return
- * - created transform_substructure_t object, or
- * - NULL if failed
+ * @return created transform_substructure_t object
+ *
+ * @ingroup payloads
*/
-
transform_substructure_t *transform_substructure_create();
#endif /*TRANSFORM_SUBSTRUCTURE_H_*/