aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon/encoding')
-rw-r--r--src/charon/encoding/payloads/configuration_attribute.c156
-rw-r--r--src/charon/encoding/payloads/configuration_attribute.h59
-rw-r--r--src/charon/encoding/payloads/cp_payload.c103
-rw-r--r--src/charon/encoding/payloads/cp_payload.h49
4 files changed, 164 insertions, 203 deletions
diff --git a/src/charon/encoding/payloads/configuration_attribute.c b/src/charon/encoding/payloads/configuration_attribute.c
index caba34a6c..9094fd44d 100644
--- a/src/charon/encoding/payloads/configuration_attribute.c
+++ b/src/charon/encoding/payloads/configuration_attribute.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2006 Martin Willi
+ * Copyright (C) 2005-2009 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -38,17 +38,17 @@ struct private_configuration_attribute_t {
/**
* Type of the attribute.
*/
- u_int16_t attribute_type;
+ u_int16_t type;
/**
* Length of the attribute.
*/
- u_int16_t attribute_length;
+ u_int16_t length;
/**
* Attribute value as chunk.
*/
- chunk_t attribute_value;
+ chunk_t value;
};
/**
@@ -56,17 +56,16 @@ struct private_configuration_attribute_t {
*
* The defined offsets are the positions in a object of type
* private_configuration_attribute_t.
- *
*/
encoding_rule_t configuration_attribute_encodings[] = {
- { RESERVED_BIT, 0 },
+ { RESERVED_BIT, 0 },
/* type of the attribute as 15 bit unsigned integer */
- { ATTRIBUTE_TYPE, offsetof(private_configuration_attribute_t, attribute_type) },
+ { ATTRIBUTE_TYPE, offsetof(private_configuration_attribute_t, type) },
/* Length of attribute value */
- { CONFIGURATION_ATTRIBUTE_LENGTH, offsetof(private_configuration_attribute_t, attribute_length)},
+ { CONFIGURATION_ATTRIBUTE_LENGTH, offsetof(private_configuration_attribute_t, length) },
/* Value of attribute if attribute format flag is zero */
- { CONFIGURATION_ATTRIBUTE_VALUE, offsetof(private_configuration_attribute_t, attribute_value)}
+ { CONFIGURATION_ATTRIBUTE_VALUE, offsetof(private_configuration_attribute_t, value) }
};
/*
@@ -88,13 +87,13 @@ static status_t verify(private_configuration_attribute_t *this)
{
bool failed = FALSE;
- if (this->attribute_length != this->attribute_value.len)
+ if (this->length != this->value.len)
{
DBG1(DBG_ENC, "invalid attribute length");
return FAILED;
}
- switch (this->attribute_type)
+ switch (this->type)
{
case INTERNAL_IP4_ADDRESS:
case INTERNAL_IP4_NETMASK:
@@ -102,20 +101,20 @@ static status_t verify(private_configuration_attribute_t *this)
case INTERNAL_IP4_NBNS:
case INTERNAL_ADDRESS_EXPIRY:
case INTERNAL_IP4_DHCP:
- if (this->attribute_length != 0 && this->attribute_length != 4)
+ if (this->length != 0 && this->length != 4)
{
failed = TRUE;
}
break;
case INTERNAL_IP4_SUBNET:
- if (this->attribute_length != 0 && this->attribute_length != 8)
+ if (this->length != 0 && this->length != 8)
{
failed = TRUE;
}
break;
case INTERNAL_IP6_ADDRESS:
case INTERNAL_IP6_SUBNET:
- if (this->attribute_length != 0 && this->attribute_length != 17)
+ if (this->length != 0 && this->length != 17)
{
failed = TRUE;
}
@@ -123,13 +122,13 @@ static status_t verify(private_configuration_attribute_t *this)
case INTERNAL_IP6_DNS:
case INTERNAL_IP6_NBNS:
case INTERNAL_IP6_DHCP:
- if (this->attribute_length != 0 && this->attribute_length != 16)
+ if (this->length != 0 && this->length != 16)
{
failed = TRUE;
}
break;
case SUPPORTED_ATTRIBUTES:
- if (this->attribute_length % 2)
+ if (this->length % 2)
{
failed = TRUE;
}
@@ -139,15 +138,14 @@ static status_t verify(private_configuration_attribute_t *this)
break;
default:
DBG1(DBG_ENC, "unknown attribute type %N",
- configuration_attribute_type_names, this->attribute_type);
+ configuration_attribute_type_names, this->type);
break;
}
if (failed)
{
DBG1(DBG_ENC, "invalid attribute length %d for %N",
- this->attribute_length, configuration_attribute_type_names,
- this->attribute_type);
+ this->length, configuration_attribute_type_names, this->type);
return FAILED;
}
return SUCCESS;
@@ -156,7 +154,8 @@ static status_t verify(private_configuration_attribute_t *this)
/**
* Implementation of payload_t.get_encoding_rules.
*/
-static void get_encoding_rules(private_configuration_attribute_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(private_configuration_attribute_t *this,
+ encoding_rule_t **rules, size_t *rule_count)
{
*rules = configuration_attribute_encodings;
*rule_count = sizeof(configuration_attribute_encodings) / sizeof(encoding_rule_t);
@@ -175,13 +174,14 @@ static payload_type_t get_type(private_configuration_attribute_t *this)
*/
static payload_type_t get_next_type(private_configuration_attribute_t *this)
{
- return (NO_PAYLOAD);
+ return NO_PAYLOAD;
}
/**
* Implementation of payload_t.set_next_type.
*/
-static void set_next_type(private_configuration_attribute_t *this,payload_type_t type)
+static void set_next_type(private_configuration_attribute_t *this,
+ payload_type_t type)
{
}
@@ -190,99 +190,75 @@ static void set_next_type(private_configuration_attribute_t *this,payload_type_t
*/
static size_t get_length(private_configuration_attribute_t *this)
{
- return (this->attribute_value.len + CONFIGURATION_ATTRIBUTE_HEADER_LENGTH);
+ return this->value.len + CONFIGURATION_ATTRIBUTE_HEADER_LENGTH;
}
/**
- * Implementation of configuration_attribute_t.set_value.
+ * Implementation of configuration_attribute_t.get_type.
*/
-static void set_value(private_configuration_attribute_t *this, chunk_t value)
+static configuration_attribute_type_t get_configuration_attribute_type(
+ private_configuration_attribute_t *this)
{
- if (this->attribute_value.ptr != NULL)
- {
- /* free existing value */
- chunk_free(&(this->attribute_value));
- }
-
- this->attribute_value.ptr = clalloc(value.ptr,value.len);
- this->attribute_value.len = value.len;
-
- this->attribute_length = this->attribute_value.len;
+ return this->type;
}
/**
* Implementation of configuration_attribute_t.get_value.
*/
-static chunk_t get_value (private_configuration_attribute_t *this)
+static chunk_t get_value(private_configuration_attribute_t *this)
{
- return this->attribute_value;
+ return this->value;
}
/**
- * Implementation of configuration_attribute_t.set_type.
+ * Implementation of configuration_attribute_t.destroy and payload_t.destroy.
*/
-static void set_attribute_type (private_configuration_attribute_t *this, u_int16_t type)
+static void destroy(private_configuration_attribute_t *this)
{
- this->attribute_type = type & 0x7FFF;
+ free(this->value.ptr);
+ free(this);
}
-/**
- * Implementation of configuration_attribute_t.get_type.
+/*
+ * Described in header.
*/
-static u_int16_t get_attribute_type (private_configuration_attribute_t *this)
+configuration_attribute_t *configuration_attribute_create()
{
- return this->attribute_type;
+ private_configuration_attribute_t *this;
+
+ this = malloc_thing(private_configuration_attribute_t);
+ this->public.payload_interface.verify = (status_t(*)(payload_t *))verify;
+ 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 = (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 = (void(*)(payload_t*))destroy;
+
+ this->public.get_value = (chunk_t(*)(configuration_attribute_t *))get_value;
+ this->public.get_type = (configuration_attribute_type_t(*)(configuration_attribute_t *))get_configuration_attribute_type;
+ this->public.destroy = (void (*)(configuration_attribute_t*))destroy;
+
+ this->type = 0;
+ this->value = chunk_empty;
+ this->length = 0;
+
+ return &this->public;
}
-/**
- * Implementation of configuration_attribute_t.get_length.
+/*
+ * Described in header.
*/
-static u_int16_t get_attribute_length (private_configuration_attribute_t *this)
+configuration_attribute_t *configuration_attribute_create_value(
+ configuration_attribute_type_t type, chunk_t value)
{
- return this->attribute_length;
-}
+ private_configuration_attribute_t *this;
+ this = (private_configuration_attribute_t*)configuration_attribute_create();
+ this->type = ((u_int16_t)type) & 0x7FFF;
+ this->value = chunk_clone(value);
+ this->length = value.len;
-/**
- * Implementation of configuration_attribute_t.destroy and payload_t.destroy.
- */
-static void destroy(private_configuration_attribute_t *this)
-{
- if (this->attribute_value.ptr != NULL)
- {
- free(this->attribute_value.ptr);
- }
- free(this);
+ return &this->public;
}
-/*
- * Described in header.
- */
-configuration_attribute_t *configuration_attribute_create()
-{
- private_configuration_attribute_t *this = malloc_thing(private_configuration_attribute_t);
-
- /* payload interface */
- this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
- 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 = (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 = (void (*) (payload_t *))destroy;
-
- /* public functions */
- this->public.set_value = (void (*) (configuration_attribute_t *,chunk_t)) set_value;
- this->public.get_value = (chunk_t (*) (configuration_attribute_t *)) get_value;
- this->public.set_type = (void (*) (configuration_attribute_t *,u_int16_t type)) set_attribute_type;
- this->public.get_type = (u_int16_t (*) (configuration_attribute_t *)) get_attribute_type;
- this->public.get_length = (u_int16_t (*) (configuration_attribute_t *)) get_attribute_length;
- this->public.destroy = (void (*) (configuration_attribute_t *)) destroy;
-
- /* set default values of the fields */
- this->attribute_type = 0;
- this->attribute_value = chunk_empty;
- this->attribute_length = 0;
-
- return (&(this->public));
-}
diff --git a/src/charon/encoding/payloads/configuration_attribute.h b/src/charon/encoding/payloads/configuration_attribute.h
index f30fbfa72..6e4b018bb 100644
--- a/src/charon/encoding/payloads/configuration_attribute.h
+++ b/src/charon/encoding/payloads/configuration_attribute.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2006 Martin Willi
+ * Copyright (C) 2005-2009 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -28,7 +28,6 @@ typedef struct configuration_attribute_t configuration_attribute_t;
#include <attributes/attributes.h>
#include <encoding/payloads/payload.h>
-
/**
* Configuration attribute header length in bytes.
*/
@@ -40,49 +39,25 @@ typedef struct configuration_attribute_t configuration_attribute_t;
* The CONFIGURATION ATTRIBUTE format is described in RFC section 3.15.1.
*/
struct configuration_attribute_t {
- /**
- * The payload_t interface.
- */
- payload_t payload_interface;
-
- /**
- * Returns the currently set value of the attribute.
- *
- * @warning Returned data are not copied.
- *
- * @return chunk_t pointing to the value
- */
- chunk_t (*get_value) (configuration_attribute_t *this);
-
- /**
- * Sets the value of the attribute.
- *
- * Value is getting copied.
- *
- * @param value chunk_t pointing to the value to set
- */
- void (*set_value) (configuration_attribute_t *this, chunk_t value);
/**
- * Sets the type of the attribute.
- *
- * @param type type to set (most significant bit is set to zero)
+ * Implements payload_t interface.
*/
- void (*set_type) (configuration_attribute_t *this, u_int16_t type);
+ payload_t payload_interface;
/**
- * get the type of the attribute.
+ * Get the type of the attribute.
*
- * @return type of the value
+ * @return type of the configuration attribute
*/
- u_int16_t (*get_type) (configuration_attribute_t *this);
+ configuration_attribute_type_t (*get_type)(configuration_attribute_t *this);
/**
- * get the length of an attribute.
+ * Returns the value of the attribute.
*
- * @return type of the value
+ * @return chunk_t pointing to the internal value
*/
- u_int16_t (*get_length) (configuration_attribute_t *this);
+ chunk_t (*get_value) (configuration_attribute_t *this);
/**
* Destroys an configuration_attribute_t object.
@@ -91,10 +66,20 @@ struct configuration_attribute_t {
};
/**
- * Creates an empty configuration_attribute_t object.
+ * Creates an empty configuration attribute.
+ *
+ * @return created configuration attribute
+ */
+configuration_attribute_t *configuration_attribute_create();
+
+/**
+ * Creates a configuration attribute with type and value.
*
- * @return created configuration_attribute_t object
+ * @param type type of configuration attribute
+ * @param value value, gets cloned
+ * @return created configuration attribute
*/
-configuration_attribute_t *configuration_attribute_create(void);
+configuration_attribute_t *configuration_attribute_create_value(
+ configuration_attribute_type_t type, chunk_t value);
#endif /** CONFIGURATION_ATTRIBUTE_H_ @}*/
diff --git a/src/charon/encoding/payloads/cp_payload.c b/src/charon/encoding/payloads/cp_payload.c
index 8dc4b69f2..f0a26eee2 100644
--- a/src/charon/encoding/payloads/cp_payload.c
+++ b/src/charon/encoding/payloads/cp_payload.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2006 Martin Willi
+ * Copyright (C) 2005-2009 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -56,14 +56,14 @@ struct private_cp_payload_t {
u_int16_t payload_length;
/**
- * Configuration Attributes in this payload are stored in a linked_list_t.
+ * List of attributes, as configuration_attribute_t
*/
- linked_list_t * attributes;
+ linked_list_t *attributes;
/**
* Config Type.
*/
- u_int8_t config_type;
+ u_int8_t type;
};
/**
@@ -90,7 +90,7 @@ encoding_rule_t cp_payload_encodings[] = {
{ PAYLOAD_LENGTH, offsetof(private_cp_payload_t, payload_length) },
/* Proposals are stored in a proposal substructure,
offset points to a linked_list_t pointer */
- { U_INT_8, offsetof(private_cp_payload_t, config_type) },
+ { U_INT_8, offsetof(private_cp_payload_t, type) },
{ RESERVED_BYTE,0 },
{ RESERVED_BYTE,0 },
{ RESERVED_BYTE,0 },
@@ -117,26 +117,27 @@ encoding_rule_t cp_payload_encodings[] = {
static status_t verify(private_cp_payload_t *this)
{
status_t status = SUCCESS;
- iterator_t *iterator;
- configuration_attribute_t *attribute;
+ enumerator_t *enumerator;
+ payload_t *attribute;
- iterator = this->attributes->create_iterator(this->attributes,TRUE);
- while(iterator->iterate(iterator, (void**)&attribute))
+ enumerator = this->attributes->create_enumerator(this->attributes);
+ while (enumerator->enumerate(enumerator, &attribute))
{
- status = attribute->payload_interface.verify(&attribute->payload_interface);
+ status = attribute->verify(attribute);
if (status != SUCCESS)
{
break;
}
}
- iterator->destroy(iterator);
+ enumerator->destroy(enumerator);
return status;
}
/**
* Implementation of payload_t.get_encoding_rules.
*/
-static void get_encoding_rules(private_cp_payload_t *this, encoding_rule_t **rules, size_t *rule_count)
+static void get_encoding_rules(private_cp_payload_t *this,
+ encoding_rule_t **rules, size_t *rule_count)
{
*rules = cp_payload_encodings;
*rule_count = sizeof(cp_payload_encodings) / sizeof(encoding_rule_t);
@@ -155,7 +156,7 @@ static payload_type_t get_type(private_cp_payload_t *this)
*/
static payload_type_t get_next_type(private_cp_payload_t *this)
{
- return (this->next_payload);
+ return this->next_payload;
}
/**
@@ -171,18 +172,17 @@ static void set_next_type(private_cp_payload_t *this,payload_type_t type)
*/
static void compute_length(private_cp_payload_t *this)
{
- iterator_t *iterator;
- payload_t *current_attribute;
- size_t length = CP_PAYLOAD_HEADER_LENGTH;
+ enumerator_t *enumerator;
+ payload_t *attribute;
- iterator = this->attributes->create_iterator(this->attributes,TRUE);
- while (iterator->iterate(iterator, (void**)&current_attribute))
+ this->payload_length = CP_PAYLOAD_HEADER_LENGTH;
+
+ enumerator = this->attributes->create_enumerator(this->attributes);
+ while (enumerator->enumerate(enumerator, &attribute))
{
- length += current_attribute->get_length(current_attribute);
+ this->payload_length += attribute->get_length(attribute);
}
- iterator->destroy(iterator);
-
- this->payload_length = length;
+ enumerator->destroy(enumerator);
}
/**
@@ -190,41 +190,33 @@ static void compute_length(private_cp_payload_t *this)
*/
static size_t get_length(private_cp_payload_t *this)
{
- compute_length(this);
return this->payload_length;
}
/**
- * Implementation of cp_payload_t.create_configuration_attribute_iterator.
+ * Implementation of cp_payload_t.create_attribute_enumerator.
*/
-static iterator_t *create_attribute_iterator (private_cp_payload_t *this)
+static enumerator_t *create_attribute_enumerator(private_cp_payload_t *this)
{
- return this->attributes->create_iterator(this->attributes, TRUE);
+ return this->attributes->create_enumerator(this->attributes);
}
/**
- * Implementation of cp_payload_t.add_proposal_substructure.
+ * Implementation of cp_payload_t.add_attribute.
*/
-static void add_configuration_attribute (private_cp_payload_t *this,configuration_attribute_t *attribute)
+static void add_attribute(private_cp_payload_t *this,
+ configuration_attribute_t *attribute)
{
- this->attributes->insert_last(this->attributes,(void *) attribute);
+ this->attributes->insert_last(this->attributes, attribute);
compute_length(this);
}
/**
- * Implementation of cp_payload_t.set_config_type.
- */
-static void set_config_type (private_cp_payload_t *this,config_type_t config_type)
-{
- this->config_type = config_type;
-}
-
-/**
- * Implementation of cp_payload_t.get_config_type.
+ * Implementation of cp_payload_t.get_type.
*/
-static config_type_t get_config_type (private_cp_payload_t *this)
+static config_type_t get_config_type(private_cp_payload_t *this)
{
- return this->config_type;
+ return this->type;
}
/**
@@ -233,7 +225,7 @@ static config_type_t get_config_type (private_cp_payload_t *this)
static void destroy(private_cp_payload_t *this)
{
this->attributes->destroy_offset(this->attributes,
- offsetof(configuration_attribute_t, destroy));
+ offsetof(configuration_attribute_t, destroy));
free(this);
}
@@ -244,7 +236,6 @@ cp_payload_t *cp_payload_create()
{
private_cp_payload_t *this = malloc_thing(private_cp_payload_t);
- /* public interface */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
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;
@@ -253,18 +244,30 @@ cp_payload_t *cp_payload_create()
this->public.payload_interface.get_type = (payload_type_t (*) (payload_t *)) get_type;
this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
- /* public functions */
- this->public.create_attribute_iterator = (iterator_t* (*) (cp_payload_t *)) create_attribute_iterator;
- this->public.add_configuration_attribute = (void (*) (cp_payload_t *,configuration_attribute_t *)) add_configuration_attribute;
- this->public.set_config_type = (void (*) (cp_payload_t *, config_type_t)) set_config_type;
- this->public.get_config_type = (config_type_t (*) (cp_payload_t *)) get_config_type;
- this->public.destroy = (void (*) (cp_payload_t *)) destroy;
+ this->public.create_attribute_enumerator = (enumerator_t*(*)(cp_payload_t *))create_attribute_enumerator;
+ this->public.add_attribute = (void (*) (cp_payload_t *,configuration_attribute_t*))add_attribute;
+ this->public.get_type = (config_type_t (*) (cp_payload_t *))get_config_type;
+ this->public.destroy = (void (*)(cp_payload_t *))destroy;
/* set default values of the fields */
this->critical = FALSE;
this->next_payload = NO_PAYLOAD;
this->payload_length = CP_PAYLOAD_HEADER_LENGTH;
-
this->attributes = linked_list_create();
- return (&(this->public));
+ this->type = CFG_REQUEST;
+
+ return &this->public;
+}
+
+/*
+ * Described in header.
+ */
+cp_payload_t *cp_payload_create_type(config_type_t type)
+{
+ private_cp_payload_t *this = (private_cp_payload_t*)cp_payload_create();
+
+ this->type = type;
+
+ return &this->public;
}
+
diff --git a/src/charon/encoding/payloads/cp_payload.h b/src/charon/encoding/payloads/cp_payload.h
index 11f5061b9..c0760885a 100644
--- a/src/charon/encoding/payloads/cp_payload.h
+++ b/src/charon/encoding/payloads/cp_payload.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2006 Martin Willi
+ * Copyright (C) 2005-2009 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -28,7 +28,7 @@ typedef struct cp_payload_t cp_payload_t;
#include <library.h>
#include <encoding/payloads/payload.h>
#include <encoding/payloads/configuration_attribute.h>
-#include <utils/linked_list.h>
+#include <utils/enumerator.h>
/**
* CP_PAYLOAD length in bytes without any proposal substructure.
@@ -56,6 +56,7 @@ extern enum_name_t *config_type_names;
* The CP Payload format is described in RFC section 3.15.
*/
struct cp_payload_t {
+
/**
* The payload_t interface.
*/
@@ -64,36 +65,24 @@ struct cp_payload_t {
/**
* Creates an iterator of stored configuration_attribute_t objects.
*
- * When deleting an attribute using this iterator, the length of this
- * configuration_attribute_t has to be refreshed by calling get_length()!
- *
- * @return created iterator_t object
+ * @return enumerator over configration_attribute_T
*/
- iterator_t *(*create_attribute_iterator) (cp_payload_t *this);
+ enumerator_t *(*create_attribute_enumerator) (cp_payload_t *this);
/**
- * Adds a configuration_attribute_t object to this object.
- *
- * The added configuration_attribute_t object is getting destroyed in
- * destroy function of cp_payload_t.
+ * Adds a configuration attribute to the configuration payload.
*
- * @param attribute configuration_attribute_t object to add
+ * @param attribute attribute to add
*/
- void (*add_configuration_attribute) (cp_payload_t *this, configuration_attribute_t *attribute);
+ void (*add_attribute)(cp_payload_t *this,
+ configuration_attribute_t *attribute);
/**
- * Set the config type.
+ * Get the configuration payload type.
*
- * @param config_type config_type_t to set
+ * @return type of configuration payload
*/
- void (*set_config_type) (cp_payload_t *this,config_type_t config_type);
-
- /**
- * Get the config type.
- *
- * @return config_type_t
- */
- config_type_t (*get_config_type) (cp_payload_t *this);
+ config_type_t (*get_type) (cp_payload_t *this);
/**
* Destroys an cp_payload_t object.
@@ -102,10 +91,18 @@ struct cp_payload_t {
};
/**
- * Creates an empty cp_payload_t object
+ * Creates an empty configuration payload
+ *
+ * @return empty configuration payload
+ */
+cp_payload_t *cp_payload_create();
+
+/**
+ * Creates an cp_payload_t with type and value
*
- * @return cp_payload_t object
+ * @param type type of configuration payload to create
+ * @return created configuration payload
*/
-cp_payload_t *cp_payload_create(void);
+cp_payload_t *cp_payload_create_type(config_type_t config_type);
#endif /** CP_PAYLOAD_H_ @}*/