diff options
author | Jan Hutter <jhutter@hsr.ch> | 2005-12-05 18:16:39 +0000 |
---|---|---|
committer | Jan Hutter <jhutter@hsr.ch> | 2005-12-05 18:16:39 +0000 |
commit | 7ba3f707df54449e3119fb50e684862898aa998c (patch) | |
tree | 331f3166b3976dd3e2af48dacc6e732e206bfda2 /Source/charon/encoding/generator.c | |
parent | f673471b10622a5b9f0d9d0fa66cfc951541b91d (diff) | |
download | strongswan-7ba3f707df54449e3119fb50e684862898aa998c.tar.bz2 strongswan-7ba3f707df54449e3119fb50e684862898aa998c.tar.xz |
- implemented and tested cp_payload_t
Diffstat (limited to 'Source/charon/encoding/generator.c')
-rw-r--r-- | Source/charon/encoding/generator.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/Source/charon/encoding/generator.c b/Source/charon/encoding/generator.c index 701d64821..9a2bfa3a0 100644 --- a/Source/charon/encoding/generator.c +++ b/Source/charon/encoding/generator.c @@ -47,6 +47,8 @@ #include <encoding/payloads/ts_payload.h> #include <encoding/payloads/delete_payload.h> #include <encoding/payloads/vendor_id_payload.h> +#include <encoding/payloads/cp_payload.h> +#include <encoding/payloads/configuration_attribute.h> typedef struct private_generator_t private_generator_t; @@ -295,6 +297,7 @@ static void generate_u_int_type (private_generator_t *this,encoding_type_t int_t number_of_bits = 8; break; case U_INT_16: + case CONFIGURATION_ATTRIBUTE_LENGTH: number_of_bits = 16; break; case U_INT_32: @@ -399,6 +402,7 @@ static void generate_u_int_type (private_generator_t *this,encoding_type_t int_t } case U_INT_16: + case CONFIGURATION_ATTRIBUTE_LENGTH: { u_int16_t int16_val = htons(*((u_int16_t*)(this->data_struct + offset))); this->logger->log_bytes(this->logger, RAW|MOST, " =>", (void*)&int16_val, sizeof(int16_val)); @@ -682,6 +686,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload) case IKE_SPI: case TS_TYPE: case ATTRIBUTE_TYPE: + case CONFIGURATION_ATTRIBUTE_LENGTH: { this->generate_u_int_type(this,rules[i].type,rules[i].offset); break; @@ -743,6 +748,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload) case CERT_DATA: case CERTREQ_DATA: case SPIS: + case CONFIGURATION_ATTRIBUTE_VALUE: case VID_DATA: { u_int32_t payload_length_position_offset; @@ -779,6 +785,9 @@ static void generate_payload (private_generator_t *this,payload_t *payload) case VID_DATA: header_length = VENDOR_ID_PAYLOAD_HEADER_LENGTH; break; + case CONFIGURATION_ATTRIBUTE_VALUE: + header_length = CONFIGURATION_ATTRIBUTE_HEADER_LENGTH; + break; default: break; } @@ -899,6 +908,41 @@ static void generate_payload (private_generator_t *this,payload_t *payload) this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),transform_length_position_offset); break; + } + case CONFIGURATION_ATTRIBUTES: + { + /* before iterative generate the configuration attributes, store the current length position */ + u_int32_t configurations_length_position_offset = this->last_payload_length_position_offset; + + u_int16_t length_of_configurations = CP_PAYLOAD_HEADER_LENGTH; + u_int16_t int16_val; + linked_list_t *configuration_attributes =*((linked_list_t **)(this->data_struct + rules[i].offset)); + + iterator_t *iterator; + /* create forward iterator */ + iterator = configuration_attributes->create_iterator(configuration_attributes,TRUE); + while (iterator->has_next(iterator)) + { + payload_t *current_attribute; + u_int32_t before_generate_position_offset; + u_int32_t after_generate_position_offset; + + iterator->current(iterator,(void **)¤t_attribute); + + before_generate_position_offset = this->get_current_buffer_offset(this); + this->public.generate_payload(&(this->public),current_attribute); + after_generate_position_offset = this->get_current_buffer_offset(this); + + /* increase size of transform */ + length_of_configurations += (after_generate_position_offset - before_generate_position_offset); + } + + iterator->destroy(iterator); + + int16_val = htons(length_of_configurations); + this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),configurations_length_position_offset); + + break; } case ATTRIBUTE_FORMAT: { @@ -922,7 +966,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload) // status = this->write_bytes_to_buffer(this,(this->data_struct + rules[i].offset),2); } break; - } + } case ATTRIBUTE_VALUE: { if (this->attribute_format == FALSE) |