diff options
Diffstat (limited to 'Source/charon/payloads/transform_attribute.c')
-rw-r--r-- | Source/charon/payloads/transform_attribute.c | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/Source/charon/payloads/transform_attribute.c b/Source/charon/payloads/transform_attribute.c index 3dc714e78..3b2404817 100644 --- a/Source/charon/payloads/transform_attribute.c +++ b/Source/charon/payloads/transform_attribute.c @@ -68,6 +68,16 @@ struct private_transform_attribute_s { }; + +/** + * string mappings for transform_attribute_type_t + */ +mapping_t transform_attribute_type_m[] = { + {ATTRIBUTE_UNDEFINED, "ATTRIBUTE_UNDEFINED"}, + {KEY_LENGTH, "KEY_LENGTH"}, + {MAPPING_END, NULL} +}; + /** * Encoding rules to parse or generate a Transform attribute * @@ -157,7 +167,7 @@ static size_t get_length(private_transform_attribute_t *this) * Implements transform_attribute_t's set_value function. * See #transform_attribute_s.set_value for description. */ -static status_t set_value (private_transform_attribute_t *this, chunk_t value) +static status_t set_value_chunk(private_transform_attribute_t *this, chunk_t value) { if (this->attribute_value.ptr != NULL) { @@ -188,10 +198,28 @@ static status_t set_value (private_transform_attribute_t *this, chunk_t value) } /** - * Implements transform_attribute_t's get_value function. - * See #transform_attribute_s.get_value for description. + * Implements transform_attribute_t's set_value function. + * See #transform_attribute_s.set_value for description. + */ +static status_t set_value(private_transform_attribute_t *this, u_int16_t value) +{ + if (this->attribute_value.ptr != NULL) + { + /* free existing value */ + allocator_free(this->attribute_value.ptr); + this->attribute_value.ptr = NULL; + this->attribute_value.len = 0; + + } + 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. */ -static chunk_t get_value (private_transform_attribute_t *this) +static chunk_t get_value_chunk (private_transform_attribute_t *this) { chunk_t value; @@ -210,6 +238,16 @@ static chunk_t get_value (private_transform_attribute_t *this) } /** + * Implements transform_attribute_t's get_value function. + * See #transform_attribute_s.get_value for description. + */ +static u_int16_t get_value (private_transform_attribute_t *this) +{ + return this->attribute_length_or_value; +} + + +/** * Implements transform_attribute_t's set_attribute_type function. * See #transform_attribute_s.set_attribute_type for description. */ @@ -245,8 +283,10 @@ transform_attribute_t *transform_attribute_create() this->public.payload_interface.set_next_type = (status_t (*) (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.set_value = (status_t (*) (transform_attribute_t *,chunk_t value)) set_value; - this->public.get_value = (chunk_t (*) (transform_attribute_t *)) get_value; + 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.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.get_attribute_type = (u_int16_t (*) (transform_attribute_t *)) get_attribute_type; this->public.destroy = (status_t (*) (transform_attribute_t *)) destroy; |