diff options
author | Martin Willi <martin@strongswan.org> | 2006-10-24 14:20:45 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2006-10-24 14:20:45 +0000 |
commit | 191a26a6a713e81361bd677bb0297744f03e4f36 (patch) | |
tree | 95bbdbc6be919e5748ddcab93d985592f264e593 /src/charon/encoding/generator.c | |
parent | 55bbff11ec96f74b27afc36dd8ca3e34ff425b40 (diff) | |
download | strongswan-191a26a6a713e81361bd677bb0297744f03e4f36.tar.bz2 strongswan-191a26a6a713e81361bd677bb0297744f03e4f36.tar.xz |
removed deprecated iterator methods (has_next & current)
added iterator hook to manipulate iterator the clean way
Diffstat (limited to 'src/charon/encoding/generator.c')
-rw-r--r-- | src/charon/encoding/generator.c | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/src/charon/encoding/generator.c b/src/charon/encoding/generator.c index 392a4602d..6eb3c5d66 100644 --- a/src/charon/encoding/generator.c +++ b/src/charon/encoding/generator.c @@ -803,19 +803,17 @@ static void generate_payload (private_generator_t *this,payload_t *payload) u_int16_t int16_val; /* proposals are stored in a linked list and so accessed */ linked_list_t *proposals = *((linked_list_t **)(this->data_struct + rules[i].offset)); - iterator_t *iterator; + payload_t *current_proposal; + /* create forward iterator */ iterator = proposals->create_iterator(proposals,TRUE); /* every proposal is processed (iterative call )*/ - while (iterator->has_next(iterator)) + while (iterator->iterate(iterator, (void**)¤t_proposal)) { - payload_t *current_proposal; u_int32_t before_generate_position_offset; u_int32_t after_generate_position_offset; - iterator->current(iterator,(void **)¤t_proposal); - before_generate_position_offset = this->get_current_buffer_offset(this); this->public.generate_payload(&(this->public),current_proposal); after_generate_position_offset = this->get_current_buffer_offset(this); @@ -828,26 +826,24 @@ static void generate_payload (private_generator_t *this,payload_t *payload) int16_val = htons(length_of_sa_payload); this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset); break; - } + } case TRANSFORMS: - { + { /* before iterative generate the transforms, store the current length position */ u_int32_t payload_length_position_offset = this->last_payload_length_position_offset; u_int16_t length_of_proposal = PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH + this->last_spi_size; u_int16_t int16_val; linked_list_t *transforms = *((linked_list_t **)(this->data_struct + rules[i].offset)); iterator_t *iterator; - + payload_t *current_transform; + /* create forward iterator */ iterator = transforms->create_iterator(transforms,TRUE); - while (iterator->has_next(iterator)) + while (iterator->iterate(iterator, (void**)¤t_transform)) { - payload_t *current_transform; u_int32_t before_generate_position_offset; u_int32_t after_generate_position_offset; - iterator->current(iterator,(void **)¤t_transform); - before_generate_position_offset = this->get_current_buffer_offset(this); this->public.generate_payload(&(this->public),current_transform); after_generate_position_offset = this->get_current_buffer_offset(this); @@ -857,7 +853,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload) } iterator->destroy(iterator); - + int16_val = htons(length_of_proposal); this->write_bytes_to_buffer_at_offset(this,&int16_val,sizeof(u_int16_t),payload_length_position_offset); @@ -867,22 +863,19 @@ static void generate_payload (private_generator_t *this,payload_t *payload) { /* before iterative generate the transform attributes, store the current length position */ u_int32_t transform_length_position_offset = this->last_payload_length_position_offset; - u_int16_t length_of_transform = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH; u_int16_t int16_val; linked_list_t *transform_attributes =*((linked_list_t **)(this->data_struct + rules[i].offset)); - iterator_t *iterator; + payload_t *current_attribute; + /* create forward iterator */ iterator = transform_attributes->create_iterator(transform_attributes,TRUE); - while (iterator->has_next(iterator)) + while (iterator->iterate(iterator, (void**)¤t_attribute)) { - 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); @@ -902,22 +895,19 @@ static void generate_payload (private_generator_t *this,payload_t *payload) { /* 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; + payload_t *current_attribute; + /* create forward iterator */ iterator = configuration_attributes->create_iterator(configuration_attributes,TRUE); - while (iterator->has_next(iterator)) + while (iterator->iterate(iterator, (void**)¤t_attribute)) { - 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); @@ -974,18 +964,16 @@ static void generate_payload (private_generator_t *this,payload_t *payload) u_int16_t int16_val; /* traffic selectors are stored in a linked list and so accessed */ linked_list_t *traffic_selectors = *((linked_list_t **)(this->data_struct + rules[i].offset)); - iterator_t *iterator; + payload_t *current_traffic_selector_substructure; + /* create forward iterator */ iterator = traffic_selectors->create_iterator(traffic_selectors,TRUE); /* every proposal is processed (iterative call )*/ - while (iterator->has_next(iterator)) + while (iterator->iterate(iterator, (void **)¤t_traffic_selector_substructure)) { - payload_t *current_traffic_selector_substructure; u_int32_t before_generate_position_offset; u_int32_t after_generate_position_offset; - - iterator->current(iterator,(void **)¤t_traffic_selector_substructure); before_generate_position_offset = this->get_current_buffer_offset(this); this->public.generate_payload(&(this->public),current_traffic_selector_substructure); |