- changed creation of iterator

- chanded all clone calls
This commit is contained in:
Jan Hutter
2005-11-29 08:54:48 +00:00
parent c6ec246d0d
commit a0753941e1
24 changed files with 92 additions and 122 deletions
+1 -1
View File
@@ -227,7 +227,7 @@ static status_t select_proposals_for_host(private_configuration_manager_t *this,
in->current(in,(void **) &first_suggested_proposal); in->current(in,(void **) &first_suggested_proposal);
first_suggested_proposal->clone(first_suggested_proposal,&selected_proposal); selected_proposal = first_suggested_proposal->clone(first_suggested_proposal);
out->insert_after(out,selected_proposal); out->insert_after(out,selected_proposal);
return SUCCESS; return SUCCESS;
+3 -3
View File
@@ -771,7 +771,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
iterator_t *iterator; iterator_t *iterator;
/* create forward iterator */ /* create forward iterator */
proposals->create_iterator(proposals,&iterator,TRUE); iterator = proposals->create_iterator(proposals,TRUE);
/* every proposal is processed (iterative call )*/ /* every proposal is processed (iterative call )*/
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
@@ -805,7 +805,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
iterator_t *iterator; iterator_t *iterator;
/* create forward iterator */ /* create forward iterator */
transforms->create_iterator(transforms,&iterator,TRUE); iterator = transforms->create_iterator(transforms,TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
payload_t *current_transform; payload_t *current_transform;
@@ -840,7 +840,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
iterator_t *iterator; iterator_t *iterator;
/* create forward iterator */ /* create forward iterator */
transform_attributes->create_iterator(transform_attributes,&iterator,TRUE); iterator = transform_attributes->create_iterator(transform_attributes,TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
payload_t *current_attribute; payload_t *current_attribute;
+7 -35
View File
@@ -429,9 +429,9 @@ static void get_destination(private_message_t *this, host_t **host)
/** /**
* Implementation of message_t.get_destination. * Implementation of message_t.get_destination.
*/ */
static void get_payload_iterator(private_message_t *this, iterator_t **iterator) static iterator_t *get_payload_iterator(private_message_t *this)
{ {
this->payloads->create_iterator(this->payloads, iterator, TRUE); return this->payloads->create_iterator(this->payloads, TRUE);
} }
@@ -477,7 +477,7 @@ static status_t generate(private_message_t *this, crypter_t *crypter, signer_t*
payload = (payload_t*)ike_header; payload = (payload_t*)ike_header;
this->payloads->create_iterator(this->payloads, &iterator, TRUE); iterator = this->payloads->create_iterator(this->payloads, TRUE);
/* generate every payload, except last one */ /* generate every payload, except last one */
while(iterator->has_next(iterator)) while(iterator->has_next(iterator))
@@ -666,9 +666,7 @@ static status_t verify(private_message_t *this)
this->logger->log(this->logger, ERROR, "could not get supported payloads: %s"); this->logger->log(this->logger, ERROR, "could not get supported payloads: %s");
return status; return status;
} }
iterator = this->payloads->create_iterator(this->payloads,TRUE);
this->payloads->create_iterator(this->payloads,&iterator,TRUE);
/* check for payloads with wrong count*/ /* check for payloads with wrong count*/
for (i = 0; i < supported_payloads_count;i++) for (i = 0; i < supported_payloads_count;i++)
{ {
@@ -684,6 +682,7 @@ static status_t verify(private_message_t *this)
payload_t *current_payload; payload_t *current_payload;
iterator->current(iterator,(void **)&current_payload); iterator->current(iterator,(void **)&current_payload);
if (current_payload->get_type(current_payload) == payload_type) if (current_payload->get_type(current_payload) == payload_type)
{ {
found_payloads++; found_payloads++;
@@ -725,7 +724,7 @@ static void destroy (private_message_t *this)
this->ike_sa_id->destroy(this->ike_sa_id); this->ike_sa_id->destroy(this->ike_sa_id);
} }
this->payloads->create_iterator(this->payloads, &iterator, TRUE); iterator = this->payloads->create_iterator(this->payloads, TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
payload_t *payload; payload_t *payload;
@@ -748,10 +747,6 @@ static void destroy (private_message_t *this)
message_t *message_create_from_packet(packet_t *packet) message_t *message_create_from_packet(packet_t *packet)
{ {
private_message_t *this = allocator_alloc_thing(private_message_t); private_message_t *this = allocator_alloc_thing(private_message_t);
if (this == NULL)
{
return NULL;
}
/* public functions */ /* public functions */
this->public.set_major_version = (void(*)(message_t*, u_int8_t))set_major_version; this->public.set_major_version = (void(*)(message_t*, u_int8_t))set_major_version;
@@ -773,7 +768,7 @@ message_t *message_create_from_packet(packet_t *packet)
this->public.get_source = (void (*) (message_t*,host_t**)) get_source; this->public.get_source = (void (*) (message_t*,host_t**)) get_source;
this->public.set_destination = (void (*) (message_t*,host_t*)) set_destination; this->public.set_destination = (void (*) (message_t*,host_t*)) set_destination;
this->public.get_destination = (void (*) (message_t*,host_t**)) get_destination; this->public.get_destination = (void (*) (message_t*,host_t**)) get_destination;
this->public.get_payload_iterator = (void (*) (message_t *, iterator_t **)) get_payload_iterator; this->public.get_payload_iterator = (iterator_t * (*) (message_t *)) get_payload_iterator;
this->public.parse_header = (status_t (*) (message_t *)) parse_header; this->public.parse_header = (status_t (*) (message_t *)) parse_header;
this->public.parse_body = (status_t (*) (message_t *,crypter_t*,signer_t*)) parse_body; this->public.parse_body = (status_t (*) (message_t *,crypter_t*,signer_t*)) parse_body;
this->public.verify = (status_t (*) (message_t*)) verify; this->public.verify = (status_t (*) (message_t*)) verify;
@@ -794,36 +789,13 @@ message_t *message_create_from_packet(packet_t *packet)
{ {
packet = packet_create(); packet = packet_create();
} }
if (packet == NULL)
{
allocator_free(this);
return NULL;
}
this->packet = packet; this->packet = packet;
this->payloads = linked_list_create(); this->payloads = linked_list_create();
if (this->payloads == NULL)
{
allocator_free(this);
return NULL;
}
/* parser is created from data of packet */ /* parser is created from data of packet */
this->parser = parser_create(this->packet->data); this->parser = parser_create(this->packet->data);
if (this->parser == NULL)
{
this->payloads->destroy(this->payloads);
allocator_free(this);
return NULL;
}
this->logger = global_logger_manager->create_logger(global_logger_manager, MESSAGE, NULL); this->logger = global_logger_manager->create_logger(global_logger_manager, MESSAGE, NULL);
if (this->logger == NULL)
{
this->parser->destroy(this->parser);
this->payloads->destroy(this->payloads);
allocator_free(this);
return NULL;
}
return (&this->public); return (&this->public);
} }
+1 -1
View File
@@ -226,7 +226,7 @@ struct message_t {
void (*set_source) (message_t *this, host_t *host); void (*set_source) (message_t *this, host_t *host);
void (*get_destination) (message_t *this, host_t **host); void (*get_destination) (message_t *this, host_t **host);
void (*set_destination) (message_t *this, host_t *host); void (*set_destination) (message_t *this, host_t *host);
void (*get_payload_iterator) (message_t *this, iterator_t **iterator); iterator_t * (*get_payload_iterator) (message_t *this);
/** /**
* @brief Destroys a message and all including objects * @brief Destroys a message and all including objects
@@ -287,9 +287,9 @@ static size_t get_length(private_encryption_payload_t *this)
/** /**
* Implementation of payload_t.create_payload_iterator. * Implementation of payload_t.create_payload_iterator.
*/ */
static void create_payload_iterator (private_encryption_payload_t *this, iterator_t **iterator, bool forward) static iterator_t *create_payload_iterator (private_encryption_payload_t *this, bool forward)
{ {
this->payloads->create_iterator(this->payloads, iterator, forward); return (this->payloads->create_iterator(this->payloads, forward));
} }
/** /**
@@ -506,7 +506,7 @@ static void generate(private_encryption_payload_t *this)
iterator_t *iterator; iterator_t *iterator;
/* create iterator */ /* create iterator */
this->payloads->create_iterator(this->payloads, &iterator, TRUE); iterator = this->payloads->create_iterator(this->payloads, TRUE);
/* get first payload */ /* get first payload */
if (iterator->has_next(iterator)) if (iterator->has_next(iterator))
@@ -598,7 +598,7 @@ static void compute_length(private_encryption_payload_t *this)
{ {
iterator_t *iterator; iterator_t *iterator;
size_t length = ENCRYPTION_PAYLOAD_HEADER_LENGTH; size_t length = ENCRYPTION_PAYLOAD_HEADER_LENGTH;
this->payloads->create_iterator(this->payloads, &iterator, TRUE); iterator = this->payloads->create_iterator(this->payloads, TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
@@ -629,7 +629,7 @@ encryption_payload_t *encryption_payload_create()
this->public.payload_interface.destroy = (void (*) (payload_t *))destroy; this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
/* public functions */ /* public functions */
this->public.create_payload_iterator = (void (*) (encryption_payload_t *,iterator_t **,bool)) create_payload_iterator; this->public.create_payload_iterator = (iterator_t * (*) (encryption_payload_t *,bool)) create_payload_iterator;
this->public.add_payload = (void (*) (encryption_payload_t *,payload_t *)) add_payload; 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.encrypt = (status_t (*) (encryption_payload_t *, crypter_t*)) encrypt;
this->public.decrypt = (status_t (*) (encryption_payload_t *, crypter_t*)) decrypt; this->public.decrypt = (status_t (*) (encryption_payload_t *, crypter_t*)) decrypt;
@@ -50,11 +50,13 @@ struct encryption_payload_t {
/** /**
* @brief Creates an iterator for all contained payloads. * @brief Creates an iterator for all contained payloads.
* *
* @warning iterator_t object has to get destroyed by the caller.
*
* @param this calling encryption_payload_t object * @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) * @param[in] forward iterator direction (TRUE: front to end)
* return created iterator_t object
*/ */
void (*create_payload_iterator) (encryption_payload_t *this, iterator_t **iterator, bool forward); iterator_t *(*create_payload_iterator) (encryption_payload_t *this, bool forward);
/** /**
* @brief Adds a payload to this encryption payload. * @brief Adds a payload to this encryption payload.
@@ -205,9 +205,9 @@ static size_t get_length(private_proposal_substructure_t *this)
/** /**
* Implementation of proposal_substructure_t.create_transform_substructure_iterator. * Implementation of proposal_substructure_t.create_transform_substructure_iterator.
*/ */
static void create_transform_substructure_iterator (private_proposal_substructure_t *this,iterator_t **iterator,bool forward) static iterator_t *create_transform_substructure_iterator (private_proposal_substructure_t *this,bool forward)
{ {
this->transforms->create_iterator(this->transforms,iterator,forward); return (this->transforms->create_iterator(this->transforms,forward));
} }
/** /**
@@ -304,7 +304,7 @@ static status_t get_info_for_transform_type (private_proposal_substructure_t *th
u_int16_t found_transform_id; u_int16_t found_transform_id;
u_int16_t found_key_length; u_int16_t found_key_length;
this->transforms->create_iterator(this->transforms,&iterator,TRUE); iterator = this->transforms->create_iterator(this->transforms,TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
@@ -337,7 +337,7 @@ static void compute_length (private_proposal_substructure_t *this)
iterator_t *iterator; iterator_t *iterator;
size_t transforms_count = 0; size_t transforms_count = 0;
size_t length = PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH; size_t length = PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH;
this->transforms->create_iterator(this->transforms,&iterator,TRUE); iterator = this->transforms->create_iterator(this->transforms,TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
payload_t * current_transform; payload_t * current_transform;
@@ -356,7 +356,7 @@ static void compute_length (private_proposal_substructure_t *this)
/** /**
* Implementation of proposal_substructure_t.clone. * Implementation of proposal_substructure_t.clone.
*/ */
static void clone(private_proposal_substructure_t *this, private_proposal_substructure_t **clone) static private_proposal_substructure_t* clone(private_proposal_substructure_t *this)
{ {
private_proposal_substructure_t * new_clone; private_proposal_substructure_t * new_clone;
iterator_t *transforms; iterator_t *transforms;
@@ -373,7 +373,7 @@ static void clone(private_proposal_substructure_t *this, private_proposal_substr
new_clone->spi.len = this->spi.len; new_clone->spi.len = this->spi.len;
} }
this->transforms->create_iterator(this->transforms,&transforms,FALSE); transforms = this->transforms->create_iterator(this->transforms,FALSE);
while (transforms->has_next(transforms)) while (transforms->has_next(transforms))
{ {
@@ -382,14 +382,14 @@ static void clone(private_proposal_substructure_t *this, private_proposal_substr
transforms->current(transforms,(void **) &current_transform); transforms->current(transforms,(void **) &current_transform);
current_transform->clone(current_transform,&current_transform_clone); current_transform_clone = current_transform->clone(current_transform);
new_clone->public.add_transform_substructure(&(new_clone->public),current_transform_clone); new_clone->public.add_transform_substructure(&(new_clone->public),current_transform_clone);
} }
transforms->destroy(transforms); transforms->destroy(transforms);
*clone = new_clone; return new_clone;
} }
/** /**
@@ -437,7 +437,7 @@ proposal_substructure_t *proposal_substructure_create()
this->public.payload_interface.destroy = (void (*) (payload_t *))destroy; this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
/* public functions */ /* public functions */
this->public.create_transform_substructure_iterator = (void (*) (proposal_substructure_t *,iterator_t **,bool)) create_transform_substructure_iterator; this->public.create_transform_substructure_iterator = (iterator_t* (*) (proposal_substructure_t *,bool)) create_transform_substructure_iterator;
this->public.add_transform_substructure = (void (*) (proposal_substructure_t *,transform_substructure_t *)) add_transform_substructure; 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.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.get_proposal_number = (u_int8_t (*) (proposal_substructure_t *)) get_proposal_number;
@@ -446,7 +446,7 @@ proposal_substructure_t *proposal_substructure_create()
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.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 = (void (*) (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.get_spi = (chunk_t (*) (proposal_substructure_t *)) get_spi;
this->public.clone = (void (*) (proposal_substructure_t *, proposal_substructure_t **)) clone; this->public.clone = (proposal_substructure_t * (*) (proposal_substructure_t *)) clone;
this->public.destroy = (void (*) (proposal_substructure_t *)) destroy; this->public.destroy = (void (*) (proposal_substructure_t *)) destroy;
@@ -74,10 +74,10 @@ struct proposal_substructure_t {
* get_size to make sure the length and number values are ok. * get_size to make sure the length and number values are ok.
* *
* @param this calling proposal_substructure_t object * @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) * @param[in] forward iterator direction (TRUE: front to end)
* @return created iterator_t object
*/ */
void (*create_transform_substructure_iterator) (proposal_substructure_t *this,iterator_t **iterator, bool forward); iterator_t * (*create_transform_substructure_iterator) (proposal_substructure_t *this, bool forward);
/** /**
* @brief Adds a transform_substructure_t object to this object. * @brief Adds a transform_substructure_t object to this object.
@@ -161,9 +161,9 @@ struct proposal_substructure_t {
* @brief Clones an proposal_substructure_t object. * @brief Clones an proposal_substructure_t object.
* *
* @param this proposal_substructure_t object to clone * @param this proposal_substructure_t object to clone
* @param clone cloned object will be written there * @return cloned object
*/ */
void (*clone) (proposal_substructure_t *this,proposal_substructure_t **clone); proposal_substructure_t* (*clone) (proposal_substructure_t *this);
/** /**
* @brief Destroys an proposal_substructure_t object. * @brief Destroys an proposal_substructure_t object.
+5 -5
View File
@@ -126,7 +126,7 @@ static status_t verify(private_sa_payload_t *this)
} }
/* check proposal numbering */ /* check proposal numbering */
this->proposals->create_iterator(this->proposals,&iterator,TRUE); iterator = this->proposals->create_iterator(this->proposals,TRUE);
while(iterator->has_next(iterator)) while(iterator->has_next(iterator))
{ {
@@ -230,9 +230,9 @@ static size_t get_length(private_sa_payload_t *this)
/** /**
* Implementation of sa_payload_t.create_proposal_substructure_iterator. * Implementation of sa_payload_t.create_proposal_substructure_iterator.
*/ */
static void create_proposal_substructure_iterator (private_sa_payload_t *this,iterator_t **iterator,bool forward) static iterator_t *create_proposal_substructure_iterator (private_sa_payload_t *this,bool forward)
{ {
this->proposals->create_iterator(this->proposals,iterator,forward); return this->proposals->create_iterator(this->proposals,forward);
} }
/** /**
@@ -251,7 +251,7 @@ static void compute_length (private_sa_payload_t *this)
{ {
iterator_t *iterator; iterator_t *iterator;
size_t length = SA_PAYLOAD_HEADER_LENGTH; size_t length = SA_PAYLOAD_HEADER_LENGTH;
this->proposals->create_iterator(this->proposals,&iterator,TRUE); iterator = this->proposals->create_iterator(this->proposals,TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
payload_t *current_proposal; payload_t *current_proposal;
@@ -280,7 +280,7 @@ sa_payload_t *sa_payload_create()
this->public.payload_interface.destroy = (void (*) (payload_t *))destroy; this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
/* public functions */ /* public functions */
this->public.create_proposal_substructure_iterator = (void (*) (sa_payload_t *,iterator_t **,bool)) create_proposal_substructure_iterator; this->public.create_proposal_substructure_iterator = (iterator_t* (*) (sa_payload_t *,bool)) create_proposal_substructure_iterator;
this->public.add_proposal_substructure = (void (*) (sa_payload_t *,proposal_substructure_t *)) add_proposal_substructure; this->public.add_proposal_substructure = (void (*) (sa_payload_t *,proposal_substructure_t *)) add_proposal_substructure;
this->public.destroy = (void (*) (sa_payload_t *)) destroy; this->public.destroy = (void (*) (sa_payload_t *)) destroy;
+2 -2
View File
@@ -67,10 +67,10 @@ struct sa_payload_t {
* by calling get_length()! * by calling get_length()!
* *
* @param this calling sa_payload_t object * @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) * @param[in] forward iterator direction (TRUE: front to end)
* @return created iterator_t object
*/ */
void (*create_proposal_substructure_iterator) (sa_payload_t *this,iterator_t **iterator, bool forward); iterator_t *(*create_proposal_substructure_iterator) (sa_payload_t *this, bool forward);
/** /**
* @brief Adds a proposal_substructure_t object to this object. * @brief Adds a proposal_substructure_t object to this object.
@@ -255,7 +255,7 @@ static u_int16_t get_attribute_type (private_transform_attribute_t *this)
/** /**
* Implementation of transform_attribute_t.clone. * Implementation of transform_attribute_t.clone.
*/ */
static void clone(private_transform_attribute_t *this,transform_attribute_t **clone) static transform_attribute_t * clone(private_transform_attribute_t *this)
{ {
private_transform_attribute_t *new_clone; private_transform_attribute_t *new_clone;
@@ -271,7 +271,7 @@ static void clone(private_transform_attribute_t *this,transform_attribute_t **cl
new_clone->attribute_value.len = this->attribute_value.len; new_clone->attribute_value.len = this->attribute_value.len;
} }
*clone = (transform_attribute_t *) new_clone; return (transform_attribute_t *) new_clone;
} }
/** /**
@@ -309,7 +309,7 @@ transform_attribute_t *transform_attribute_create()
this->public.get_value = (u_int16_t (*) (transform_attribute_t *)) get_value; this->public.get_value = (u_int16_t (*) (transform_attribute_t *)) get_value;
this->public.set_attribute_type = (void (*) (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.get_attribute_type = (u_int16_t (*) (transform_attribute_t *)) get_attribute_type;
this->public.clone = (void (*) (transform_attribute_t *,transform_attribute_t **)) clone; this->public.clone = (transform_attribute_t * (*) (transform_attribute_t *)) clone;
this->public.destroy = (void (*) (transform_attribute_t *)) destroy; this->public.destroy = (void (*) (transform_attribute_t *)) destroy;
/* set default values of the fields */ /* set default values of the fields */
@@ -119,9 +119,9 @@ struct transform_attribute_t {
* @brief Clones an transform_attribute_t object. * @brief Clones an transform_attribute_t object.
* *
* @param this transform_attribute_t object to clone * @param this transform_attribute_t object to clone
* @param clone the new clone will be written there * @return cloned transform_attribute_t object
*/ */
void (*clone) (transform_attribute_t *this,transform_attribute_t **clone); transform_attribute_t * (*clone) (transform_attribute_t *this);
/** /**
* @brief Destroys an transform_attribute_t object. * @brief Destroys an transform_attribute_t object.
@@ -261,9 +261,9 @@ static size_t get_length(private_transform_substructure_t *this)
/** /**
* Implementation of transform_substructure_t.create_transform_attribute_iterator. * Implementation of transform_substructure_t.create_transform_attribute_iterator.
*/ */
static void create_transform_attribute_iterator (private_transform_substructure_t *this,iterator_t **iterator,bool forward) static iterator_t *create_transform_attribute_iterator (private_transform_substructure_t *this,bool forward)
{ {
this->attributes->create_iterator(this->attributes,iterator,forward); return this->attributes->create_iterator(this->attributes,forward);
} }
/** /**
@@ -337,7 +337,7 @@ static void compute_length (private_transform_substructure_t *this)
{ {
iterator_t *iterator; iterator_t *iterator;
size_t length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH; size_t length = TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH;
this->attributes->create_iterator(this->attributes,&iterator,TRUE); iterator = this->attributes->create_iterator(this->attributes,TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
payload_t * current_attribute; payload_t * current_attribute;
@@ -353,7 +353,7 @@ static void compute_length (private_transform_substructure_t *this)
/** /**
* Implementation of transform_substructure_t.clone. * Implementation of transform_substructure_t.clone.
*/ */
static void clone(private_transform_substructure_t *this,transform_substructure_t **clone) static transform_substructure_t *clone(private_transform_substructure_t *this)
{ {
private_transform_substructure_t *new_clone; private_transform_substructure_t *new_clone;
iterator_t *attributes; iterator_t *attributes;
@@ -364,7 +364,7 @@ static void clone(private_transform_substructure_t *this,transform_substructure_
new_clone->transform_type = this->transform_type; new_clone->transform_type = this->transform_type;
new_clone->transform_id = this->transform_id; new_clone->transform_id = this->transform_id;
this->attributes->create_iterator(this->attributes,&attributes,FALSE); attributes = this->attributes->create_iterator(this->attributes,FALSE);
while (attributes->has_next(attributes)) while (attributes->has_next(attributes))
{ {
@@ -372,14 +372,14 @@ static void clone(private_transform_substructure_t *this,transform_substructure_
transform_attribute_t *current_attribute_clone; transform_attribute_t *current_attribute_clone;
attributes->current(attributes,(void **) &current_attribute); attributes->current(attributes,(void **) &current_attribute);
current_attribute->clone(current_attribute,&current_attribute_clone); current_attribute_clone = current_attribute->clone(current_attribute);
new_clone->public.add_transform_attribute(&(new_clone->public),current_attribute_clone); new_clone->public.add_transform_attribute(&(new_clone->public),current_attribute_clone);
} }
attributes->destroy(attributes); attributes->destroy(attributes);
*clone = &(new_clone->public); return &(new_clone->public);
} }
@@ -390,7 +390,7 @@ static status_t get_key_length(private_transform_substructure_t *this, u_int16_t
{ {
iterator_t *attributes; iterator_t *attributes;
this->attributes->create_iterator(this->attributes,&attributes,TRUE); attributes = this->attributes->create_iterator(this->attributes,TRUE);
while (attributes->has_next(attributes)) while (attributes->has_next(attributes))
{ {
@@ -445,7 +445,7 @@ transform_substructure_t *transform_substructure_create()
this->public.payload_interface.destroy = (void (*) (payload_t *))destroy; this->public.payload_interface.destroy = (void (*) (payload_t *))destroy;
/* public functions */ /* public functions */
this->public.create_transform_attribute_iterator = (void (*) (transform_substructure_t *,iterator_t **,bool)) create_transform_attribute_iterator; this->public.create_transform_attribute_iterator = (iterator_t * (*) (transform_substructure_t *,bool)) create_transform_attribute_iterator;
this->public.add_transform_attribute = (void (*) (transform_substructure_t *,transform_attribute_t *)) add_transform_attribute; 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.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.get_is_last_transform = (bool (*) (transform_substructure_t *)) get_is_last_transform;
@@ -454,7 +454,7 @@ transform_substructure_t *transform_substructure_create()
this->public.set_transform_id = (void (*) (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_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.get_key_length = (status_t (*) (transform_substructure_t *,u_int16_t *)) get_key_length;
this->public.clone = (void (*) (transform_substructure_t *,transform_substructure_t **)) clone; this->public.clone = (transform_substructure_t* (*) (transform_substructure_t *)) clone;
this->public.destroy = (void (*) (transform_substructure_t *)) destroy; this->public.destroy = (void (*) (transform_substructure_t *)) destroy;
/* private functions */ /* private functions */
@@ -117,10 +117,10 @@ struct transform_substructure_t {
* by calling get_length()! * by calling get_length()!
* *
* @param this calling transform_substructure_t object * @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) * @param[in] forward iterator direction (TRUE: front to end)
* @return created iterator_t object.
*/ */
void (*create_transform_attribute_iterator) (transform_substructure_t *this,iterator_t **iterator, bool forward); iterator_t * (*create_transform_attribute_iterator) (transform_substructure_t *this, bool forward);
/** /**
* @brief Adds a transform_attribute_t object to this object. * @brief Adds a transform_attribute_t object to this object.
@@ -200,10 +200,9 @@ struct transform_substructure_t {
* @brief Clones an transform_substructure_t object. * @brief Clones an transform_substructure_t object.
* *
* @param this transform_substructure_t object to clone * @param this transform_substructure_t object to clone
* @param clone pointer to a transform_substructure_t object pointer * @return cloned transform_substructure_t object
* where the new object is stored to.
*/ */
void (*clone) (transform_substructure_t *this,transform_substructure_t **clone); transform_substructure_t* (*clone) (transform_substructure_t *this);
/** /**
* @brief Destroys an transform_substructure_t object. * @brief Destroys an transform_substructure_t object.
+1 -1
View File
@@ -253,7 +253,7 @@ static void add_absolute(private_event_queue_t *this, job_t *job, timeval_t time
iterator_t * iterator; iterator_t * iterator;
this->list->create_iterator(this->list,&iterator,TRUE); iterator = this->list->create_iterator(this->list,TRUE);
iterator->has_next(iterator); iterator->has_next(iterator);
/* first element has not to be checked (already done) */ /* first element has not to be checked (already done) */
+4 -4
View File
@@ -209,7 +209,7 @@ static status_t get_entry_by_id(private_ike_sa_manager_t *this, ike_sa_id_t *ike
status_t status; status_t status;
/* create iterator over list of ike_sa's */ /* create iterator over list of ike_sa's */
list->create_iterator(list, &iterator, TRUE); iterator = list->create_iterator(list, TRUE);
/* default status */ /* default status */
status = NOT_FOUND; status = NOT_FOUND;
@@ -252,7 +252,7 @@ static status_t get_entry_by_sa(private_ike_sa_manager_t *this, ike_sa_t *ike_sa
iterator_t *iterator; iterator_t *iterator;
status_t status; status_t status;
list->create_iterator(list, &iterator, TRUE); iterator = list->create_iterator(list, TRUE);
/* default status */ /* default status */
status = NOT_FOUND; status = NOT_FOUND;
@@ -284,7 +284,7 @@ static status_t delete_entry(private_ike_sa_manager_t *this, ike_sa_entry_t *ent
iterator_t *iterator; iterator_t *iterator;
status_t status; status_t status;
list->create_iterator(list, &iterator, TRUE); iterator = list->create_iterator(list, TRUE);
status = NOT_FOUND; status = NOT_FOUND;
@@ -606,7 +606,7 @@ static void destroy(private_ike_sa_manager_t *this)
this->logger->log(this->logger,CONTROL | MORE,"Going to destroy IKE_SA manager and all managed IKE_SA's"); this->logger->log(this->logger,CONTROL | MORE,"Going to destroy IKE_SA manager and all managed IKE_SA's");
/* Step 1: drive out all waiting threads */ /* Step 1: drive out all waiting threads */
list->create_iterator(list, &iterator, TRUE); iterator = list->create_iterator(list, TRUE);
this->logger->log(this->logger,CONTROL | MOST,"Set driveout flags for all stored IKE_SA's"); this->logger->log(this->logger,CONTROL | MOST,"Set driveout flags for all stored IKE_SA's");
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
@@ -120,7 +120,7 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
ike_sa_id->set_responder_spi(ike_sa_id,responder_spi); ike_sa_id->set_responder_spi(ike_sa_id,responder_spi);
/* iterate over incoming payloads */ /* iterate over incoming payloads */
message->get_payload_iterator(message, &payloads); payloads = message->get_payload_iterator(message);
while (payloads->has_next(payloads)) while (payloads->has_next(payloads))
{ {
payload_t *payload; payload_t *payload;
@@ -138,7 +138,7 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
/* get the list of suggested proposals */ /* get the list of suggested proposals */
sa_payload->create_proposal_substructure_iterator(sa_payload, &suggested_proposals, TRUE); suggested_proposals = sa_payload->create_proposal_substructure_iterator(sa_payload, TRUE);
/* now let the configuration-manager check the selected proposals*/ /* now let the configuration-manager check the selected proposals*/
+3 -3
View File
@@ -174,7 +174,7 @@ static status_t initiate_connection (private_initiator_init_t *this, char *name)
} }
/* get proposals */ /* get proposals */
this->proposals->create_iterator(this->proposals, &proposal_iterator, FALSE); proposal_iterator = this->proposals->create_iterator(this->proposals, FALSE);
status = global_configuration_manager->get_proposals_for_host(global_configuration_manager, this->ike_sa->get_other_host(this->ike_sa), proposal_iterator); status = global_configuration_manager->get_proposals_for_host(global_configuration_manager, this->ike_sa->get_other_host(this->ike_sa), proposal_iterator);
proposal_iterator->destroy(proposal_iterator); proposal_iterator->destroy(proposal_iterator);
if (status != SUCCESS) if (status != SUCCESS)
@@ -292,7 +292,7 @@ static void build_sa_payload(private_initiator_init_t *this, payload_t **payload
*/ */
this->logger->log(this->logger, CONTROL|MORE, "building sa payload"); this->logger->log(this->logger, CONTROL|MORE, "building sa payload");
this->proposals->create_iterator(this->proposals, &proposal_iterator, FALSE); proposal_iterator = this->proposals->create_iterator(this->proposals, FALSE);
sa_payload = sa_payload_create(); sa_payload = sa_payload_create();
@@ -302,7 +302,7 @@ static void build_sa_payload(private_initiator_init_t *this, payload_t **payload
proposal_substructure_t *current_proposal_clone; proposal_substructure_t *current_proposal_clone;
proposal_iterator->current(proposal_iterator,(void **) &current_proposal); proposal_iterator->current(proposal_iterator,(void **) &current_proposal);
current_proposal->clone(current_proposal,&current_proposal_clone); current_proposal_clone = current_proposal->clone(current_proposal);
sa_payload->add_proposal_substructure(sa_payload,current_proposal_clone); sa_payload->add_proposal_substructure(sa_payload,current_proposal_clone);
} }
+5 -6
View File
@@ -179,9 +179,8 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
this->logger->log(this->logger, ERROR | MORE, "Could not parse body of request message"); this->logger->log(this->logger, ERROR | MORE, "Could not parse body of request message");
return status; return status;
} }
/* iterate over incoming payloads. We can be sure, the message contains only accepted payloads! */ /* iterate over incoming payloads. We can be sure, the message contains only accepted payloads! */
message->get_payload_iterator(message, &payloads); payloads = message->get_payload_iterator(message);
while (payloads->has_next(payloads)) while (payloads->has_next(payloads))
{ {
@@ -199,10 +198,10 @@ static status_t process_message(private_responder_init_t *this, message_t *messa
iterator_t *suggested_proposals, *accepted_proposals; iterator_t *suggested_proposals, *accepted_proposals;
proposal_substructure_t *accepted_proposal; proposal_substructure_t *accepted_proposal;
this->proposals->create_iterator(this->proposals, &accepted_proposals, FALSE); accepted_proposals = this->proposals->create_iterator(this->proposals, FALSE);
/* get the list of suggested proposals */ /* get the list of suggested proposals */
sa_payload->create_proposal_substructure_iterator(sa_payload, &suggested_proposals, TRUE); suggested_proposals = sa_payload->create_proposal_substructure_iterator(sa_payload, TRUE);
/* now let the configuration-manager select a subset of the proposals */ /* now let the configuration-manager select a subset of the proposals */
status = global_configuration_manager->select_proposals_for_host(global_configuration_manager, status = global_configuration_manager->select_proposals_for_host(global_configuration_manager,
@@ -395,7 +394,7 @@ static void build_sa_payload(private_responder_init_t *this, payload_t **payload
this->logger->log(this->logger, CONTROL|MORE, "building sa payload"); this->logger->log(this->logger, CONTROL|MORE, "building sa payload");
this->proposals->create_iterator(this->proposals, &proposal_iterator, FALSE); proposal_iterator = this->proposals->create_iterator(this->proposals, FALSE);
sa_payload = sa_payload_create(); sa_payload = sa_payload_create();
@@ -405,7 +404,7 @@ static void build_sa_payload(private_responder_init_t *this, payload_t **payload
proposal_substructure_t *current_proposal_clone; proposal_substructure_t *current_proposal_clone;
proposal_iterator->current(proposal_iterator,(void **) &current_proposal); proposal_iterator->current(proposal_iterator,(void **) &current_proposal);
current_proposal->clone(current_proposal,&current_proposal_clone); current_proposal_clone = current_proposal->clone(current_proposal);
sa_payload->add_proposal_substructure(sa_payload,current_proposal_clone); sa_payload->add_proposal_substructure(sa_payload,current_proposal_clone);
} }
+3 -3
View File
@@ -105,7 +105,7 @@ void test_linked_list_iterator(tester_t *tester)
iterator_t * iterator2; iterator_t * iterator2;
linked_list->create_iterator(linked_list,&iterator,TRUE); iterator = linked_list->create_iterator(linked_list,TRUE);
tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check"); tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check");
iterator->current(iterator,&value); iterator->current(iterator,&value);
@@ -115,7 +115,7 @@ void test_linked_list_iterator(tester_t *tester)
iterator->current(iterator,&value); iterator->current(iterator,&value);
tester->assert_true(tester,(strcmp((char *) value,"four") == 0), "it 1 current value check"); tester->assert_true(tester,(strcmp((char *) value,"four") == 0), "it 1 current value check");
linked_list->create_iterator(linked_list,&iterator2,FALSE); iterator2 = linked_list->create_iterator(linked_list,FALSE);
tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check"); tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check");
iterator2->current(iterator2,&value); iterator2->current(iterator2,&value);
@@ -170,7 +170,7 @@ void test_linked_list_insert_and_remove(tester_t *tester)
linked_list->create_iterator(linked_list,&iterator,TRUE); iterator = linked_list->create_iterator(linked_list,TRUE);
iterator->has_next(iterator); iterator->has_next(iterator);
iterator->has_next(iterator); iterator->has_next(iterator);
+3 -3
View File
@@ -129,7 +129,7 @@ void test_parser_with_sa_payload(tester_t *tester)
} }
sa_payload->create_proposal_substructure_iterator(sa_payload, &proposals, TRUE); proposals = sa_payload->create_proposal_substructure_iterator(sa_payload, TRUE);
while (proposals->has_next(proposals)) while (proposals->has_next(proposals))
{ {
proposal_substructure_t *proposal; proposal_substructure_t *proposal;
@@ -142,7 +142,7 @@ void test_parser_with_sa_payload(tester_t *tester)
spi = proposal->get_spi(proposal); spi = proposal->get_spi(proposal);
tester->assert_false(tester,(memcmp(&spi_should, spi.ptr, spi.len)),"proposal spi"); tester->assert_false(tester,(memcmp(&spi_should, spi.ptr, spi.len)),"proposal spi");
proposal->create_transform_substructure_iterator(proposal, &transforms, TRUE); transforms = proposal->create_transform_substructure_iterator(proposal, TRUE);
while(transforms->has_next(transforms)) while(transforms->has_next(transforms))
{ {
transform_substructure_t *transform; transform_substructure_t *transform;
@@ -150,7 +150,7 @@ void test_parser_with_sa_payload(tester_t *tester)
transforms->current(transforms, (void**)&transform); transforms->current(transforms, (void**)&transform);
tester->assert_true(tester,(transform->get_transform_type(transform) == 7),"transform type"); tester->assert_true(tester,(transform->get_transform_type(transform) == 7),"transform type");
tester->assert_true(tester,(transform->get_transform_id(transform) == 3),"transform id"); tester->assert_true(tester,(transform->get_transform_id(transform) == 3),"transform id");
transform->create_transform_attribute_iterator(transform, &attributes, TRUE); attributes = transform->create_transform_attribute_iterator(transform, TRUE);
loopi = 0; loopi = 0;
while (attributes->has_next(attributes)) while (attributes->has_next(attributes))
{ {
+3 -3
View File
@@ -482,7 +482,7 @@ static status_t get_last(private_linked_list_t *this, void **item)
/** /**
* Implementation of linked_list_t.create_iterator. * Implementation of linked_list_t.create_iterator.
*/ */
static void create_iterator (private_linked_list_t *linked_list, iterator_t **iterator,bool forward) static iterator_t *create_iterator (private_linked_list_t *linked_list,bool forward)
{ {
private_iterator_t *this = allocator_alloc_thing(private_iterator_t); private_iterator_t *this = allocator_alloc_thing(private_iterator_t);
@@ -498,7 +498,7 @@ static void create_iterator (private_linked_list_t *linked_list, iterator_t **it
this->current = NULL; this->current = NULL;
this->list = linked_list; this->list = linked_list;
*iterator = &(this->public); return &(this->public);
} }
/** /**
@@ -525,7 +525,7 @@ linked_list_t *linked_list_create()
private_linked_list_t *this = allocator_alloc_thing(private_linked_list_t); private_linked_list_t *this = allocator_alloc_thing(private_linked_list_t);
this->public.get_count = (int (*) (linked_list_t *linked_list)) get_count; this->public.get_count = (int (*) (linked_list_t *linked_list)) get_count;
this->public.create_iterator = (void (*) (linked_list_t *linked_list, iterator_t **iterator,bool forward)) create_iterator; this->public.create_iterator = (iterator_t * (*) (linked_list_t *linked_list,bool forward)) create_iterator;
this->public.get_first = (status_t (*) (linked_list_t *linked_list, void **item)) get_first; this->public.get_first = (status_t (*) (linked_list_t *linked_list, void **item)) get_first;
this->public.get_last = (status_t (*) (linked_list_t *linked_list, void **item)) get_last; this->public.get_last = (status_t (*) (linked_list_t *linked_list, void **item)) get_last;
this->public.insert_first = (void (*) (linked_list_t *linked_list, void *item)) insert_first; this->public.insert_first = (void (*) (linked_list_t *linked_list, void *item)) insert_first;
+3 -5
View File
@@ -51,13 +51,13 @@ struct linked_list_t {
/** /**
* @brief Creates a iterator for the given list. * @brief Creates a iterator for the given list.
* *
* @warning Created iterator has to get destroyed by the caller. * @warning Created iterator_t object has to get destroyed by the caller.
* *
* @param linked_list calling object * @param linked_list calling object
* @param[out] iterator place where the iterator is written
* @param[in] forward iterator direction (TRUE: front to end) * @param[in] forward iterator direction (TRUE: front to end)
* @return new iterator_t object
*/ */
void (*create_iterator) (linked_list_t *linked_list, iterator_t **iterator, bool forward); iterator_t * (*create_iterator) (linked_list_t *linked_list, bool forward);
/** /**
* @brief Inserts a new item at the beginning of the list. * @brief Inserts a new item at the beginning of the list.
@@ -128,8 +128,6 @@ struct linked_list_t {
* memory leaks! * memory leaks!
* *
* @param linked_list calling object * @param linked_list calling object
* @return
* - SUCCESS
*/ */
void (*destroy) (linked_list_t *linked_list); void (*destroy) (linked_list_t *linked_list);
}; };
+4 -4
View File
@@ -205,7 +205,7 @@ static logger_level_t get_logger_level (private_logger_manager_t *this, logger_c
pthread_mutex_lock(&(this->mutex)); pthread_mutex_lock(&(this->mutex));
this->logger_levels->create_iterator(this->logger_levels, &iterator,TRUE); iterator = this->logger_levels->create_iterator(this->logger_levels,TRUE);
/* check for existing logger_level entry */ /* check for existing logger_level entry */
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
@@ -232,7 +232,7 @@ static void destroy_logger(private_logger_manager_t *this,logger_t *logger)
pthread_mutex_lock(&(this->mutex)); pthread_mutex_lock(&(this->mutex));
this->loggers->create_iterator(this->loggers,&iterator,TRUE); iterator = this->loggers->create_iterator(this->loggers,TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
loggers_entry_t * entry; loggers_entry_t * entry;
@@ -258,7 +258,7 @@ static void set_logger_level(private_logger_manager_t *this, logger_context_t co
bool found = FALSE; bool found = FALSE;
pthread_mutex_lock(&(this->mutex)); pthread_mutex_lock(&(this->mutex));
this->logger_levels->create_iterator(this->logger_levels,&iterator,TRUE); iterator = this->logger_levels->create_iterator(this->logger_levels,TRUE);
/* find existing logger_level entry */ /* find existing logger_level entry */
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
@@ -292,7 +292,7 @@ static void set_logger_level(private_logger_manager_t *this, logger_context_t co
this->logger_levels->insert_last(this->logger_levels,entry); this->logger_levels->insert_last(this->logger_levels,entry);
} }
this->loggers->create_iterator(this->loggers,&iterator,TRUE); iterator = this->loggers->create_iterator(this->loggers,TRUE);
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
loggers_entry_t * entry; loggers_entry_t * entry;