Replaced simple iterator usages.
authorTobias Brunner <tobias@strongswan.org>
Thu, 19 May 2011 14:18:30 +0000 (16:18 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 6 Jul 2011 07:43:45 +0000 (09:43 +0200)
17 files changed:
src/libcharon/control/controller.h
src/libcharon/encoding/payloads/cp_payload.h
src/libcharon/sa/connect_manager.c
src/libcharon/sa/ike_sa.c
src/libcharon/sa/mediation_manager.c
src/libcharon/sa/task_manager.c
src/libcharon/sa/tasks/child_create.c
src/libcharon/sa/tasks/child_delete.c
src/libcharon/sa/tasks/ike_init.c
src/libcharon/sa/tasks/ike_me.c
src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c
src/libstrongswan/crypto/pkcs9.c
src/libstrongswan/plugins/x509/x509_ac.c
src/libstrongswan/selectors/traffic_selector.c
src/libstrongswan/utils/enumerator.h
src/manager/manager.h
src/manager/storage.h

index 738c1d4..81c83d9 100644 (file)
@@ -65,7 +65,7 @@ struct controller_t {
         * Create an enumerator for all IKE_SAs.
         *
         * The enumerator blocks the IKE_SA manager until it gets destroyed. Do
-        * not call another interface/manager method while the iterator is alive.
+        * not call another interface/manager method while the enumerator is alive.
         *
         * @param wait                  TRUE to wait for checked out SAs, FALSE to skip
         * @return                              enumerator, locks IKE_SA manager until destroyed
index 7dcf58f..afae609 100644 (file)
@@ -63,7 +63,7 @@ struct cp_payload_t {
        payload_t payload_interface;
 
        /**
-        * Creates an iterator of stored configuration_attribute_t objects.
+        * Creates an enumerator of stored configuration_attribute_t objects.
         *
         * @return                      enumerator over configration_attribute_T
         */
index 972cc98..fdc917a 100644 (file)
@@ -476,19 +476,19 @@ static status_t get_initiated_by_ids(private_connect_manager_t *this,
 static void remove_initiated(private_connect_manager_t *this,
                                                         initiated_t *initiated)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        initiated_t *current;
 
-       iterator = this->initiated->create_iterator(this->initiated, TRUE);
-       while (iterator->iterate(iterator, (void**)&current))
+       enumerator = this->initiated->create_enumerator(this->initiated);
+       while (enumerator->enumerate(enumerator, (void**)&current))
        {
                if (current == initiated)
                {
-                       iterator->remove(iterator);
+                       this->initiated->remove_at(this->initiated, enumerator);
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 }
 
 /**
@@ -514,19 +514,19 @@ static status_t get_checklist_by_id(private_connect_manager_t *this,
 static void remove_checklist(private_connect_manager_t *this,
                                                         check_list_t *checklist)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        check_list_t *current;
 
-       iterator = this->checklists->create_iterator(this->checklists, TRUE);
-       while (iterator->iterate(iterator, (void**)&current))
+       enumerator = this->checklists->create_enumerator(this->checklists);
+       while (enumerator->enumerate(enumerator, (void**)&current))
        {
                if (current == checklist)
                {
-                       iterator->remove(iterator);
+                       this->checklists->remove_at(this->checklists, enumerator);
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 }
 
 /**
@@ -631,14 +631,14 @@ static bool match_waiting_pair(endpoint_pair_t *current)
 static status_t get_triggered_pair(check_list_t *checklist,
                                                                   endpoint_pair_t **pair)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        endpoint_pair_t *current;
        status_t status = NOT_FOUND;
 
-       iterator = checklist->triggered->create_iterator(checklist->triggered, TRUE);
-       while (iterator->iterate(iterator, (void**)&current))
+       enumerator = checklist->triggered->create_enumerator(checklist->triggered);
+       while (enumerator->enumerate(enumerator, (void**)&current))
        {
-               iterator->remove(iterator);
+               checklist->triggered->remove_at(checklist->triggered, enumerator);
 
                if (current->state == CHECK_WAITING)
                {
@@ -650,7 +650,7 @@ static status_t get_triggered_pair(check_list_t *checklist,
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        return status;
 }
@@ -660,17 +660,17 @@ static status_t get_triggered_pair(check_list_t *checklist,
  */
 static void print_checklist(check_list_t *checklist)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        endpoint_pair_t *current;
 
        DBG1(DBG_IKE, "pairs on checklist %#B:", &checklist->connect_id);
-       iterator = checklist->pairs->create_iterator(checklist->pairs, TRUE);
-       while (iterator->iterate(iterator, (void**)&current))
+       enumerator = checklist->pairs->create_enumerator(checklist->pairs);
+       while (enumerator->enumerate(enumerator, (void**)&current))
        {
                DBG1(DBG_IKE, " * %#H - %#H (%d)", current->local, current->remote,
                         current->priority);
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 }
 
 /**
@@ -721,16 +721,16 @@ static void prune_pairs(linked_list_t *pairs)
 static void build_pairs(check_list_t *checklist)
 {
        /* FIXME: limit endpoints and pairs */
-       iterator_t *iterator_i, *iterator_r;
+       enumerator_t *enumerator_i, *enumerator_r;
        endpoint_notify_t *initiator, *responder;
 
-       iterator_i = checklist->initiator.endpoints->create_iterator(
-                                                                               checklist->initiator.endpoints, TRUE);
-       while (iterator_i->iterate(iterator_i, (void**)&initiator))
+       enumerator_i = checklist->initiator.endpoints->create_enumerator(
+                                                                               checklist->initiator.endpoints);
+       while (enumerator_i->enumerate(enumerator_i, (void**)&initiator))
        {
-               iterator_r = checklist->responder.endpoints->create_iterator(
-                                                                               checklist->responder.endpoints, TRUE);
-               while (iterator_r->iterate(iterator_r, (void**)&responder))
+               enumerator_r = checklist->responder.endpoints->create_enumerator(
+                                                                               checklist->responder.endpoints);
+               while (enumerator_r->enumerate(enumerator_r, (void**)&responder))
                {
                        if (initiator->get_family(initiator) != responder->get_family(responder))
                        {
@@ -740,9 +740,9 @@ static void build_pairs(check_list_t *checklist)
                        insert_pair_by_priority(checklist->pairs, endpoint_pair_create(
                                                        initiator, responder, checklist->is_initiator));
                }
-               iterator_r->destroy(iterator_r);
+               enumerator_r->destroy(enumerator_r);
        }
-       iterator_i->destroy(iterator_i);
+       enumerator_i->destroy(enumerator_i);
 
        print_checklist(checklist);
 
@@ -895,19 +895,19 @@ static job_requeue_t initiator_finish(callback_data_t *data)
 static void update_checklist_state(private_connect_manager_t *this,
                                                                   check_list_t *checklist)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        endpoint_pair_t *current;
        bool in_progress = FALSE, succeeded = FALSE;
 
-       iterator = checklist->pairs->create_iterator(checklist->pairs, TRUE);
-       while (iterator->iterate(iterator, (void**)&current))
+       enumerator = checklist->pairs->create_enumerator(checklist->pairs);
+       while (enumerator->enumerate(enumerator, (void**)&current))
        {
                switch(current->state)
                {
                        case CHECK_WAITING:
                                /* at least one is still waiting -> checklist remains
                                 * in waiting state */
-                               iterator->destroy(iterator);
+                               enumerator->destroy(enumerator);
                                return;
                        case CHECK_IN_PROGRESS:
                                in_progress = TRUE;
@@ -919,7 +919,7 @@ static void update_checklist_state(private_connect_manager_t *this,
                                break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        if (checklist->is_initiator && succeeded && !checklist->is_finishing)
        {
@@ -1185,8 +1185,9 @@ static job_requeue_t initiate_mediated(initiate_data_t *data)
        if (get_best_valid_pair(checklist, &pair) == SUCCESS)
        {
                ike_sa_id_t *waiting_sa;
-               iterator_t *iterator = initiated->mediated->create_iterator(initiated->mediated, TRUE);
-               while (iterator->iterate(iterator, (void**)&waiting_sa))
+               enumerator_t *enumerator = initiated->mediated->create_enumerator(
+                                                                                                               initiated->mediated);
+               while (enumerator->enumerate(enumerator, (void**)&waiting_sa))
                {
                        ike_sa_t *sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager, waiting_sa);
                        if (sa->initiate_mediated(sa, pair->local, pair->remote, checklist->connect_id) != SUCCESS)
@@ -1199,7 +1200,7 @@ static job_requeue_t initiate_mediated(initiate_data_t *data)
                                charon->ike_sa_manager->checkin(charon->ike_sa_manager, sa);
                        }
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
        }
        else
        {
@@ -1474,15 +1475,15 @@ static void check_and_initiate(private_connect_manager_t *this,
        }
 
        ike_sa_id_t *waiting_sa;
-       iterator_t *iterator = initiated->mediated->create_iterator(
-                                                                                                       initiated->mediated, TRUE);
-       while (iterator->iterate(iterator, (void**)&waiting_sa))
+       enumerator_t *enumerator = initiated->mediated->create_enumerator(
+                                                                                                               initiated->mediated);
+       while (enumerator->enumerate(enumerator, (void**)&waiting_sa))
        {
                job_t *job = (job_t*)reinitiate_mediation_job_create(mediation_sa,
                                                                                                                         waiting_sa);
                lib->processor->queue_job(lib->processor, job);
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        this->mutex->unlock(this->mutex);
 }
index 9a5530e..be93ca4 100644 (file)
@@ -869,11 +869,11 @@ METHOD(ike_sa_t, update_hosts, void,
        /* update all associated CHILD_SAs, if required */
        if (update)
        {
-               iterator_t *iterator;
+               enumerator_t *enumerator;
                child_sa_t *child_sa;
 
-               iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
-               while (iterator->iterate(iterator, (void**)&child_sa))
+               enumerator = this->child_sas->create_enumerator(this->child_sas);
+               while (enumerator->enumerate(enumerator, (void**)&child_sa))
                {
                        if (child_sa->update(child_sa, this->my_host,
                                                this->other_host, this->my_virtual_ip,
@@ -884,7 +884,7 @@ METHOD(ike_sa_t, update_hosts, void,
                                                child_sa->get_spi(child_sa, TRUE));
                        }
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
        }
 }
 
@@ -1377,11 +1377,11 @@ METHOD(ike_sa_t, add_child_sa, void,
 METHOD(ike_sa_t, get_child_sa, child_sa_t*,
        private_ike_sa_t *this, protocol_id_t protocol, u_int32_t spi, bool inbound)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        child_sa_t *current, *found = NULL;
 
-       iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
-       while (iterator->iterate(iterator, (void**)&current))
+       enumerator = this->child_sas->create_enumerator(this->child_sas);
+       while (enumerator->enumerate(enumerator, (void**)&current))
        {
                if (current->get_spi(current, inbound) == spi &&
                        current->get_protocol(current) == protocol)
@@ -1389,7 +1389,7 @@ METHOD(ike_sa_t, get_child_sa, child_sa_t*,
                        found = current;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
        return found;
 }
 
@@ -1422,23 +1422,23 @@ METHOD(ike_sa_t, delete_child_sa, status_t,
 METHOD(ike_sa_t, destroy_child_sa, status_t,
        private_ike_sa_t *this, protocol_id_t protocol, u_int32_t spi)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        child_sa_t *child_sa;
        status_t status = NOT_FOUND;
 
-       iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
-       while (iterator->iterate(iterator, (void**)&child_sa))
+       enumerator = this->child_sas->create_enumerator(this->child_sas);
+       while (enumerator->enumerate(enumerator, (void**)&child_sa))
        {
                if (child_sa->get_protocol(child_sa) == protocol &&
                        child_sa->get_spi(child_sa, TRUE) == spi)
                {
+                       this->child_sas->remove_at(this->child_sas, enumerator);
                        child_sa->destroy(child_sa);
-                       iterator->remove(iterator);
                        status = SUCCESS;
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
        return status;
 }
 
@@ -1521,15 +1521,15 @@ METHOD(ike_sa_t, reestablish, status_t,
        ike_sa_t *new;
        host_t *host;
        action_t action;
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        child_sa_t *child_sa;
        child_cfg_t *child_cfg;
        bool restart = FALSE;
        status_t status = FAILED;
 
        /* check if we have children to keep up at all */
-       iterator = create_child_sa_iterator(this);
-       while (iterator->iterate(iterator, (void**)&child_sa))
+       enumerator = this->child_sas->create_enumerator(this->child_sas);
+       while (enumerator->enumerate(enumerator, (void**)&child_sa))
        {
                if (this->state == IKE_DELETING)
                {
@@ -1552,7 +1552,7 @@ METHOD(ike_sa_t, reestablish, status_t,
                                break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 #ifdef ME
        /* mediation connections have no children, keep them up anyway */
        if (this->peer_cfg->is_mediation(this->peer_cfg))
@@ -1599,8 +1599,8 @@ METHOD(ike_sa_t, reestablish, status_t,
        else
 #endif /* ME */
        {
-               iterator = create_child_sa_iterator(this);
-               while (iterator->iterate(iterator, (void**)&child_sa))
+               enumerator = this->child_sas->create_enumerator(this->child_sas);
+               while (enumerator->enumerate(enumerator, (void**)&child_sa))
                {
                        if (this->state == IKE_DELETING)
                        {
@@ -1627,7 +1627,7 @@ METHOD(ike_sa_t, reestablish, status_t,
                                break;
                        }
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
        }
 
        if (status == DESTROY_ME)
index 2fbab7c..5d4d9ba 100644 (file)
@@ -90,19 +90,19 @@ struct private_mediation_manager_t {
  */
 static void register_peer(peer_t *peer, identification_t *peer_id)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        identification_t *current;
 
-       iterator = peer->requested_by->create_iterator(peer->requested_by, TRUE);
-       while (iterator->iterate(iterator, (void**)&current))
+       enumerator = peer->requested_by->create_enumerator(peer->requested_by);
+       while (enumerator->enumerate(enumerator, (void**)&current))
        {
                if (peer_id->equals(peer_id, current))
                {
-                       iterator->destroy(iterator);
+                       enumerator->destroy(enumerator);
                        return;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        peer->requested_by->insert_last(peer->requested_by,
                                                                        peer_id->clone(peer_id));
@@ -114,12 +114,12 @@ static void register_peer(peer_t *peer, identification_t *peer_id)
 static status_t get_peer_by_id(private_mediation_manager_t *this,
                                                           identification_t *id, peer_t **peer)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        peer_t *current;
        status_t status = NOT_FOUND;
 
-       iterator = this->peers->create_iterator(this->peers, TRUE);
-       while (iterator->iterate(iterator, (void**)&current))
+       enumerator = this->peers->create_enumerator(this->peers);
+       while (enumerator->enumerate(enumerator, (void**)&current))
        {
                if (id->equals(id, current->id))
                {
@@ -131,7 +131,7 @@ static status_t get_peer_by_id(private_mediation_manager_t *this,
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        return status;
 }
@@ -144,34 +144,34 @@ static status_t get_peer_by_id(private_mediation_manager_t *this,
 static void unregister_peer(private_mediation_manager_t *this,
                                                        identification_t *peer_id)
 {
-       iterator_t *iterator, *iterator_r;
+       enumerator_t *enumerator, *enumerator_r;
        peer_t *peer;
        identification_t *registered;
 
-       iterator = this->peers->create_iterator(this->peers, TRUE);
-       while (iterator->iterate(iterator, (void**)&peer))
+       enumerator = this->peers->create_enumerator(this->peers);
+       while (enumerator->enumerate(enumerator, (void**)&peer))
        {
-               iterator_r = peer->requested_by->create_iterator(peer->requested_by,
-                                                                                                                TRUE);
-               while (iterator_r->iterate(iterator_r, (void**)&registered))
+               enumerator_r = peer->requested_by->create_enumerator(peer->requested_by);
+               while (enumerator_r->enumerate(enumerator_r, (void**)&registered))
                {
                        if (peer_id->equals(peer_id, registered))
                        {
-                               iterator_r->remove(iterator_r);
+                               peer->requested_by->remove_at(peer->requested_by, enumerator_r);
                                registered->destroy(registered);
                                break;
                        }
                }
-               iterator_r->destroy(iterator_r);
+               enumerator_r->destroy(enumerator_r);
 
-               if (!peer->ike_sa_id && !peer->requested_by->get_count(peer->requested_by))
+               if (!peer->ike_sa_id &&
+                       !peer->requested_by->get_count(peer->requested_by))
                {
-                       iterator->remove(iterator);
+                       this->peers->remove_at(this->peers, enumerator);
                        peer_destroy(peer);
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 }
 
 /**
@@ -179,17 +179,17 @@ static void unregister_peer(private_mediation_manager_t *this,
  */
 static void remove_sa(private_mediation_manager_t *this, ike_sa_id_t *ike_sa_id)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        peer_t *peer;
 
        this->mutex->lock(this->mutex);
 
-       iterator = this->peers->create_iterator(this->peers, TRUE);
-       while (iterator->iterate(iterator, (void**)&peer))
+       enumerator = this->peers->create_enumerator(this->peers);
+       while (enumerator->enumerate(enumerator, (void**)&peer))
        {
                if (ike_sa_id->equals(ike_sa_id, peer->ike_sa_id))
                {
-                       iterator->remove(iterator);
+                       this->peers->remove_at(this->peers, enumerator);
 
                        unregister_peer(this, peer->id);
 
@@ -197,7 +197,7 @@ static void remove_sa(private_mediation_manager_t *this, ike_sa_id_t *ike_sa_id)
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        this->mutex->unlock(this->mutex);
 }
@@ -207,14 +207,14 @@ static void remove_sa(private_mediation_manager_t *this, ike_sa_id_t *ike_sa_id)
  */
 static void update_sa_id(private_mediation_manager_t *this, identification_t *peer_id, ike_sa_id_t *ike_sa_id)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        peer_t *peer;
        bool found = FALSE;
 
        this->mutex->lock(this->mutex);
 
-       iterator = this->peers->create_iterator(this->peers, TRUE);
-       while (iterator->iterate(iterator, (void**)&peer))
+       enumerator = this->peers->create_enumerator(this->peers);
+       while (enumerator->enumerate(enumerator, (void**)&peer))
        {
                if (peer_id->equals(peer_id, peer->id))
                {
@@ -223,7 +223,7 @@ static void update_sa_id(private_mediation_manager_t *this, identification_t *pe
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        if (!found)
        {
index f07d2e3..c99de28 100644 (file)
@@ -175,23 +175,23 @@ static void flush(private_task_manager_t *this)
  */
 static bool activate_task(private_task_manager_t *this, task_type_t type)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        task_t *task;
        bool found = FALSE;
 
-       iterator = this->queued_tasks->create_iterator(this->queued_tasks, TRUE);
-       while (iterator->iterate(iterator, (void**)&task))
+       enumerator = this->queued_tasks->create_enumerator(this->queued_tasks);
+       while (enumerator->enumerate(enumerator, (void**)&task))
        {
                if (task->get_type(task) == type)
                {
                        DBG2(DBG_IKE, "  activating %N task", task_type_names, type);
-                       iterator->remove(iterator);
+                       this->queued_tasks->remove_at(this->queued_tasks, enumerator);
                        this->active_tasks->insert_last(this->active_tasks, task);
                        found = TRUE;
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
        return found;
 }
 
@@ -202,14 +202,14 @@ METHOD(task_manager_t, retransmit, status_t,
        {
                u_int32_t timeout;
                job_t *job;
-               iterator_t *iterator;
+               enumerator_t *enumerator;
                packet_t *packet;
                task_t *task;
                ike_mobike_t *mobike = NULL;
 
                /* check if we are retransmitting a MOBIKE routability check */
-               iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
-               while (iterator->iterate(iterator, (void*)&task))
+               enumerator = this->active_tasks->create_enumerator(this->active_tasks);
+               while (enumerator->enumerate(enumerator, (void*)&task))
                {
                        if (task->get_type(task) == IKE_MOBIKE)
                        {
@@ -221,7 +221,7 @@ METHOD(task_manager_t, retransmit, status_t,
                                break;
                        }
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
 
                if (mobike == NULL)
                {
@@ -282,7 +282,7 @@ METHOD(task_manager_t, retransmit, status_t,
 METHOD(task_manager_t, initiate, status_t,
        private_task_manager_t *this)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        task_t *task;
        message_t *message;
        host_t *me, *other;
@@ -387,8 +387,8 @@ METHOD(task_manager_t, initiate, status_t,
        else
        {
                DBG2(DBG_IKE, "reinitiating already active tasks");
-               iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
-               while (iterator->iterate(iterator, (void**)&task))
+               enumerator = this->active_tasks->create_enumerator(this->active_tasks);
+               while (enumerator->enumerate(enumerator, (void**)&task))
                {
                        DBG2(DBG_IKE, "  %N task", task_type_names, task->get_type(task));
                        switch (task->get_type(task))
@@ -411,7 +411,7 @@ METHOD(task_manager_t, initiate, status_t,
                        }
                        break;
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
        }
 
        if (exchange == 0)
@@ -432,14 +432,14 @@ METHOD(task_manager_t, initiate, status_t,
        this->initiating.type = exchange;
        this->initiating.retransmitted = 0;
 
-       iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
-       while (iterator->iterate(iterator, (void*)&task))
+       enumerator = this->active_tasks->create_enumerator(this->active_tasks);
+       while (enumerator->enumerate(enumerator, (void*)&task))
        {
                switch (task->build(task, message))
                {
                        case SUCCESS:
                                /* task completed, remove it */
-                               iterator->remove(iterator);
+                               this->active_tasks->remove_at(this->active_tasks, enumerator);
                                task->destroy(task);
                                break;
                        case NEED_MORE:
@@ -454,13 +454,13 @@ METHOD(task_manager_t, initiate, status_t,
                                /* FALL */
                        case DESTROY_ME:
                                /* critical failure, destroy IKE_SA */
-                               iterator->destroy(iterator);
+                               enumerator->destroy(enumerator);
                                message->destroy(message);
                                flush(this);
                                return DESTROY_ME;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        /* update exchange type if a task changed it */
        this->initiating.type = message->get_exchange_type(message);
@@ -487,7 +487,7 @@ METHOD(task_manager_t, initiate, status_t,
 static status_t process_response(private_task_manager_t *this,
                                                                 message_t *message)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        task_t *task;
 
        if (message->get_exchange_type(message) != this->initiating.type)
@@ -501,14 +501,14 @@ static status_t process_response(private_task_manager_t *this,
 
        /* catch if we get resetted while processing */
        this->reset = FALSE;
-       iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
-       while (iterator->iterate(iterator, (void*)&task))
+       enumerator = this->active_tasks->create_enumerator(this->active_tasks);
+       while (enumerator->enumerate(enumerator, (void*)&task))
        {
                switch (task->process(task, message))
                {
                        case SUCCESS:
                                /* task completed, remove it */
-                               iterator->remove(iterator);
+                               this->active_tasks->remove_at(this->active_tasks, enumerator);
                                task->destroy(task);
                                break;
                        case NEED_MORE:
@@ -520,19 +520,19 @@ static status_t process_response(private_task_manager_t *this,
                                /* FALL */
                        case DESTROY_ME:
                                /* critical failure, destroy IKE_SA */
-                               iterator->remove(iterator);
-                               iterator->destroy(iterator);
+                               this->active_tasks->remove_at(this->active_tasks, enumerator);
+                               enumerator->destroy(enumerator);
                                task->destroy(task);
                                return DESTROY_ME;
                }
                if (this->reset)
                {       /* start all over again if we were reset */
                        this->reset = FALSE;
-                       iterator->destroy(iterator);
+                       enumerator->destroy(enumerator);
                        return initiate(this);
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        this->initiating.mid++;
        this->initiating.type = EXCHANGE_TYPE_UNDEFINED;
@@ -547,7 +547,7 @@ static status_t process_response(private_task_manager_t *this,
  */
 static bool handle_collisions(private_task_manager_t *this, task_t *task)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        task_t *active;
        task_type_t type;
 
@@ -558,8 +558,8 @@ static bool handle_collisions(private_task_manager_t *this, task_t *task)
                type == CHILD_DELETE || type == IKE_DELETE || type == IKE_REAUTH)
        {
                /* find an exchange collision, and notify these tasks */
-               iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
-               while (iterator->iterate(iterator, (void**)&active))
+               enumerator = this->active_tasks->create_enumerator(this->active_tasks);
+               while (enumerator->enumerate(enumerator, (void**)&active))
                {
                        switch (active->get_type(active))
                        {
@@ -583,10 +583,10 @@ static bool handle_collisions(private_task_manager_t *this, task_t *task)
                                default:
                                        continue;
                        }
-                       iterator->destroy(iterator);
+                       enumerator->destroy(enumerator);
                        return TRUE;
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
        }
        return FALSE;
 }
@@ -596,7 +596,7 @@ static bool handle_collisions(private_task_manager_t *this, task_t *task)
  */
 static status_t build_response(private_task_manager_t *this, message_t *request)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        task_t *task;
        message_t *message;
        host_t *me, *other;
@@ -614,14 +614,14 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
        message->set_message_id(message, this->responding.mid);
        message->set_request(message, FALSE);
 
-       iterator = this->passive_tasks->create_iterator(this->passive_tasks, TRUE);
-       while (iterator->iterate(iterator, (void*)&task))
+       enumerator = this->passive_tasks->create_enumerator(this->passive_tasks);
+       while (enumerator->enumerate(enumerator, (void*)&task))
        {
                switch (task->build(task, message))
                {
                        case SUCCESS:
                                /* task completed, remove it */
-                               iterator->remove(iterator);
+                               this->passive_tasks->remove_at(this->passive_tasks, enumerator);
                                if (!handle_collisions(this, task))
                                {
                                        task->destroy(task);
@@ -631,7 +631,8 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
                                /* processed, but task needs another exchange */
                                if (handle_collisions(this, task))
                                {
-                                       iterator->remove(iterator);
+                                       this->passive_tasks->remove_at(this->passive_tasks,
+                                                                                                  enumerator);
                                }
                                break;
                        case FAILED:
@@ -648,7 +649,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        /* remove resonder SPI if IKE_SA_INIT failed */
        if (delete && request->get_exchange_type(request) == IKE_SA_INIT)
@@ -685,7 +686,6 @@ static status_t process_request(private_task_manager_t *this,
                                                                message_t *message)
 {
        enumerator_t *enumerator;
-       iterator_t *iterator;
        task_t *task = NULL;
        payload_t *payload;
        notify_payload_t *notify;
@@ -854,14 +854,14 @@ static status_t process_request(private_task_manager_t *this,
        }
 
        /* let the tasks process the message */
-       iterator = this->passive_tasks->create_iterator(this->passive_tasks, TRUE);
-       while (iterator->iterate(iterator, (void*)&task))
+       enumerator = this->passive_tasks->create_enumerator(this->passive_tasks);
+       while (enumerator->enumerate(enumerator, (void*)&task))
        {
                switch (task->process(task, message))
                {
                        case SUCCESS:
                                /* task completed, remove it */
-                               iterator->remove(iterator);
+                               this->passive_tasks->remove_at(this->passive_tasks, enumerator);
                                task->destroy(task);
                                break;
                        case NEED_MORE:
@@ -873,13 +873,13 @@ static status_t process_request(private_task_manager_t *this,
                                /* FALL */
                        case DESTROY_ME:
                                /* critical failure, destroy IKE_SA */
-                               iterator->remove(iterator);
-                               iterator->destroy(iterator);
+                               this->passive_tasks->remove_at(this->passive_tasks, enumerator);
+                               enumerator->destroy(enumerator);
                                task->destroy(task);
                                return DESTROY_ME;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        return build_response(this, message);
 }
@@ -978,20 +978,20 @@ METHOD(task_manager_t, queue_task, void,
 {
        if (task->get_type(task) == IKE_MOBIKE)
        {       /*  there is no need to queue more than one mobike task */
-               iterator_t *iterator;
+               enumerator_t *enumerator;
                task_t *current;
 
-               iterator = this->queued_tasks->create_iterator(this->queued_tasks, TRUE);
-               while (iterator->iterate(iterator, (void**)&current))
+               enumerator = this->queued_tasks->create_enumerator(this->queued_tasks);
+               while (enumerator->enumerate(enumerator, (void**)&current))
                {
                        if (current->get_type(current) == IKE_MOBIKE)
                        {
-                               iterator->destroy(iterator);
+                               enumerator->destroy(enumerator);
                                task->destroy(task);
                                return;
                        }
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
        }
        DBG2(DBG_IKE, "queueing %N task", task_type_names, task->get_type(task));
        this->queued_tasks->insert_last(this->queued_tasks, task);
index fc02a33..2997361 100644 (file)
@@ -213,13 +213,13 @@ static bool ts_list_is_host(linked_list_t *list, host_t *host)
 {
        traffic_selector_t *ts;
        bool is_host = TRUE;
-       iterator_t *iterator = list->create_iterator(list, TRUE);
+       enumerator_t *enumerator = list->create_enumerator(list);
 
-       while (is_host && iterator->iterate(iterator, (void**)&ts))
+       while (is_host && enumerator->enumerate(enumerator, (void**)&ts))
        {
                is_host = is_host && ts->is_host(ts, host);
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
        return is_host;
 }
 
index e6834a9..18a3645 100644 (file)
@@ -73,11 +73,11 @@ struct private_child_delete_t {
 static void build_payloads(private_child_delete_t *this, message_t *message)
 {
        delete_payload_t *ah = NULL, *esp = NULL;
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        child_sa_t *child_sa;
 
-       iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
-       while (iterator->iterate(iterator, (void**)&child_sa))
+       enumerator = this->child_sas->create_enumerator(this->child_sas);
+       while (enumerator->enumerate(enumerator, (void**)&child_sa))
        {
                protocol_id_t protocol = child_sa->get_protocol(child_sa);
                u_int32_t spi = child_sa->get_spi(child_sa, TRUE);
@@ -109,7 +109,7 @@ static void build_payloads(private_child_delete_t *this, message_t *message)
                }
                child_sa->set_state(child_sa, CHILD_DELETING);
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 }
 
 /**
@@ -186,7 +186,7 @@ static void process_payloads(private_child_delete_t *this, message_t *message)
  */
 static status_t destroy_and_reestablish(private_child_delete_t *this)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        child_sa_t *child_sa;
        child_cfg_t *child_cfg;
        protocol_id_t protocol;
@@ -194,8 +194,8 @@ static status_t destroy_and_reestablish(private_child_delete_t *this)
        action_t action;
        status_t status = SUCCESS;
 
-       iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
-       while (iterator->iterate(iterator, (void**)&child_sa))
+       enumerator = this->child_sas->create_enumerator(this->child_sas);
+       while (enumerator->enumerate(enumerator, (void**)&child_sa))
        {
                /* signal child down event if we are not rekeying */
                if (!this->rekeyed)
@@ -231,7 +231,7 @@ static status_t destroy_and_reestablish(private_child_delete_t *this)
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
        return status;
 }
 
@@ -240,12 +240,12 @@ static status_t destroy_and_reestablish(private_child_delete_t *this)
  */
 static void log_children(private_child_delete_t *this)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        child_sa_t *child_sa;
        u_int64_t bytes_in, bytes_out;
 
-       iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
-       while (iterator->iterate(iterator, (void**)&child_sa))
+       enumerator = this->child_sas->create_enumerator(this->child_sas);
+       while (enumerator->enumerate(enumerator, (void**)&child_sa))
        {
                child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in);
                child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out);
@@ -258,7 +258,7 @@ static void log_children(private_child_delete_t *this)
                         child_sa->get_traffic_selectors(child_sa, TRUE),
                         child_sa->get_traffic_selectors(child_sa, FALSE));
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 }
 
 /**
index dd4a5f5..7aee809 100644 (file)
@@ -112,7 +112,7 @@ static void build_payloads(private_ike_init_t *this, message_t *message)
        linked_list_t *proposal_list;
        ike_sa_id_t *id;
        proposal_t *proposal;
-       iterator_t *iterator;
+       enumerator_t *enumerator;
 
        id = this->ike_sa->get_id(this->ike_sa);
 
@@ -124,12 +124,12 @@ static void build_payloads(private_ike_init_t *this, message_t *message)
                if (this->old_sa)
                {
                        /* include SPI of new IKE_SA when we are rekeying */
-                       iterator = proposal_list->create_iterator(proposal_list, TRUE);
-                       while (iterator->iterate(iterator, (void**)&proposal))
+                       enumerator = proposal_list->create_enumerator(proposal_list);
+                       while (enumerator->enumerate(enumerator, (void**)&proposal))
                        {
                                proposal->set_spi(proposal, id->get_initiator_spi(id));
                        }
-                       iterator->destroy(iterator);
+                       enumerator->destroy(enumerator);
                }
 
                sa_payload = sa_payload_create_from_proposal_list(proposal_list);
index 1de6ae8..c3c0138 100644 (file)
@@ -111,15 +111,15 @@ struct private_ike_me_t {
  */
 static void add_endpoints_to_message(message_t *message, linked_list_t *endpoints)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        endpoint_notify_t *endpoint;
 
-       iterator = endpoints->create_iterator(endpoints, TRUE);
-       while (iterator->iterate(iterator, (void**)&endpoint))
+       enumerator = endpoints->create_enumerator(endpoints);
+       while (enumerator->enumerate(enumerator, (void**)&endpoint))
        {
                message->add_payload(message, (payload_t*)endpoint->build_notify(endpoint));
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 }
 
 /**
index 050b753..9161be7 100644 (file)
@@ -193,16 +193,16 @@ struct private_kernel_netlink_net_t {
  */
 static int get_vip_refcount(private_kernel_netlink_net_t *this, host_t* ip)
 {
-       iterator_t *ifaces, *addrs;
+       enumerator_t *ifaces, *addrs;
        iface_entry_t *iface;
        addr_entry_t *addr;
        int refcount = 0;
 
-       ifaces = this->ifaces->create_iterator(this->ifaces, TRUE);
-       while (ifaces->iterate(ifaces, (void**)&iface))
+       ifaces = this->ifaces->create_enumerator(this->ifaces);
+       while (ifaces->enumerate(ifaces, (void**)&iface))
        {
-               addrs = iface->addrs->create_iterator(iface->addrs, TRUE);
-               while (addrs->iterate(addrs, (void**)&addr))
+               addrs = iface->addrs->create_enumerator(iface->addrs);
+               while (addrs->enumerate(addrs, (void**)&addr))
                {
                        if (addr->virtual && (iface->flags & IFF_UP) &&
                                ip->ip_equals(ip, addr->ip))
index 0226fbd..af34cfa 100644 (file)
@@ -198,7 +198,7 @@ static attribute_t *attribute_create(int oid, chunk_t value)
  */
 static void build_encoding(private_pkcs9_t *this)
 {
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        attribute_t *attribute;
        u_int attributes_len = 0;
 
@@ -212,26 +212,26 @@ static void build_encoding(private_pkcs9_t *this)
        }
 
        /* compute the total length of the encoded attributes */
-       iterator = this->attributes->create_iterator(this->attributes, TRUE);
+       enumerator = this->attributes->create_enumerator(this->attributes);
 
-       while (iterator->iterate(iterator, (void**)&attribute))
+       while (enumerator->enumerate(enumerator, (void**)&attribute))
        {
                attributes_len += attribute->encoding.len;
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
 
        /* allocate memory for the attributes and build the encoding */
        {
                u_char *pos = asn1_build_object(&this->encoding, ASN1_SET, attributes_len);
 
-               iterator = this->attributes->create_iterator(this->attributes, TRUE);
+               enumerator = this->attributes->create_enumerator(this->attributes);
 
-               while (iterator->iterate(iterator, (void**)&attribute))
+               while (enumerator->enumerate(enumerator, (void**)&attribute))
                {
                        memcpy(pos, attribute->encoding.ptr, attribute->encoding.len);
                        pos += attribute->encoding.len;
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
        }
 }
 
@@ -252,11 +252,12 @@ static chunk_t get_encoding(private_pkcs9_t *this)
  */
 static chunk_t get_attribute(private_pkcs9_t *this, int oid)
 {
-       iterator_t *iterator = this->attributes->create_iterator(this->attributes, TRUE);
+       enumerator_t *enumerator;
        chunk_t value = chunk_empty;
        attribute_t *attribute;
 
-       while (iterator->iterate(iterator, (void**)&attribute))
+       enumerator = this->attributes->create_enumerator(this->attributes);
+       while (enumerator->enumerate(enumerator, (void**)&attribute))
        {
                if (attribute->oid == oid)
                {
@@ -264,7 +265,7 @@ static chunk_t get_attribute(private_pkcs9_t *this, int oid)
                        break;
                }
        }
-       iterator->destroy(iterator);
+       enumerator->destroy(enumerator);
        return value;
 }
 
index ba0357c..72b101b 100644 (file)
@@ -179,11 +179,11 @@ static bool parse_directoryName(chunk_t blob, int level, bool implicit, identifi
 
        if (has_directoryName)
        {
-               iterator_t *iterator = list->create_iterator(list, TRUE);
+               enumerator_t *enumerator = list->create_enumerator(list);
                identification_t *directoryName;
                bool first = TRUE;
 
-               while (iterator->iterate(iterator, (void**)&directoryName))
+               while (enumerator->enumerate(enumerator, (void**)&directoryName))
                {
                        if (first)
                        {
@@ -196,7 +196,7 @@ static bool parse_directoryName(chunk_t blob, int level, bool implicit, identifi
                                directoryName->destroy(directoryName);
                        }
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
        }
        else
        {
index 8af5c84..98cc3bd 100644 (file)
@@ -62,7 +62,7 @@ struct private_traffic_selector_t {
        bool dynamic;
 
        /**
-        * subnet size in CIDR notation, 255 means a non-subnet address range 
+        * subnet size in CIDR notation, 255 means a non-subnet address range
         */
        u_int8_t netbits;
 
@@ -130,12 +130,12 @@ static void calc_range(private_traffic_selector_t *this, u_int8_t netbits)
 static u_int8_t calc_netbits(private_traffic_selector_t *this)
 {
        int byte, bit;
-       u_int8_t netbits; 
+       u_int8_t netbits;
        size_t size = (this->type == TS_IPV4_ADDR_RANGE) ? 4 : 16;
        bool prefix = TRUE;
-       
+
        /* a perfect match results in a single address with a /32 or /128 netmask */
-       netbits = (size * 8); 
+       netbits = (size * 8);
        this->netbits = netbits;
 
        /* go through all bits of the addresses, beginning in the front.
@@ -153,7 +153,7 @@ static u_int8_t calc_netbits(private_traffic_selector_t *this)
                                {
                                        /* store the common prefix which might be a true subnet */
                                        netbits = (7 - bit) + (byte * 8);
-                                       this->netbits = netbits; 
+                                       this->netbits = netbits;
                                        prefix = FALSE;
                                }
                        }
@@ -165,7 +165,7 @@ static u_int8_t calc_netbits(private_traffic_selector_t *this)
                                        return netbits;  /* return a pseudo subnet */
 
                                }
-                       }                                       
+                       }
                }
        }
        return netbits;  /* return a true subnet */
@@ -184,7 +184,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
 {
        private_traffic_selector_t *this = *((private_traffic_selector_t**)(args[0]));
        linked_list_t *list = *((linked_list_t**)(args[0]));
-       iterator_t *iterator;
+       enumerator_t *enumerator;
        char from_str[INET6_ADDRSTRLEN] = "";
        char to_str[INET6_ADDRSTRLEN] = "";
        char *serv_proto = NULL;
@@ -200,13 +200,13 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
 
        if (spec->hash)
        {
-               iterator = list->create_iterator(list, TRUE);
-               while (iterator->iterate(iterator, (void**)&this))
+               enumerator = list->create_enumerator(list);
+               while (enumerator->enumerate(enumerator, (void**)&this))
                {
                        /* call recursivly */
                        written += print_in_hook(dst, len, "%R ", this);
                }
-               iterator->destroy(iterator);
+               enumerator->destroy(enumerator);
                return written;
        }
 
index 537bf69..e9693a5 100644 (file)
@@ -26,7 +26,7 @@ typedef struct enumerator_t enumerator_t;
 #include "../utils.h"
 
 /**
- * Enumerate is simpler, but more flexible than iterator.
+ * Enumerator interface, allows enumeration over collections.
  */
 struct enumerator_t {
 
index 231b0f5..f762083 100644 (file)
@@ -31,8 +31,6 @@
 
 #include <context.h>
 
-#include <utils/iterator.h>
-
 typedef struct manager_t manager_t;
 
 /**
@@ -46,7 +44,7 @@ struct manager_t {
        context_t context;
 
        /**
-        * Create an iterator over all configured gateways.
+        * Create an enumerator over all configured gateways.
         *
         * enumerate() arguments: int id, char *name, int port, char *address
         * If port is 0, address is a Unix socket address.
index d8e8b74..69459e5 100644 (file)
@@ -41,7 +41,7 @@ struct storage_t {
        int (*login)(storage_t *this, char *username, char *password);
 
        /**
-        * Create an iterator over the gateways.
+        * Create an enumerator over the gateways.
         *
         * enumerate() arguments: int id, char *name, int port, char *address
         * If port is 0, address is a Unix socket address.