Replaced simple iterator usages.
This commit is contained in:
parent
28623fc538
commit
e26304348c
|
@ -65,7 +65,7 @@ struct controller_t {
|
||||||
* Create an enumerator for all IKE_SAs.
|
* Create an enumerator for all IKE_SAs.
|
||||||
*
|
*
|
||||||
* The enumerator blocks the IKE_SA manager until it gets destroyed. Do
|
* 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
|
* @param wait TRUE to wait for checked out SAs, FALSE to skip
|
||||||
* @return enumerator, locks IKE_SA manager until destroyed
|
* @return enumerator, locks IKE_SA manager until destroyed
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct cp_payload_t {
|
||||||
payload_t payload_interface;
|
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
|
* @return enumerator over configration_attribute_T
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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,
|
static void remove_initiated(private_connect_manager_t *this,
|
||||||
initiated_t *initiated)
|
initiated_t *initiated)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
initiated_t *current;
|
initiated_t *current;
|
||||||
|
|
||||||
iterator = this->initiated->create_iterator(this->initiated, TRUE);
|
enumerator = this->initiated->create_enumerator(this->initiated);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
if (current == initiated)
|
if (current == initiated)
|
||||||
{
|
{
|
||||||
iterator->remove(iterator);
|
this->initiated->remove_at(this->initiated, enumerator);
|
||||||
break;
|
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,
|
static void remove_checklist(private_connect_manager_t *this,
|
||||||
check_list_t *checklist)
|
check_list_t *checklist)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
check_list_t *current;
|
check_list_t *current;
|
||||||
|
|
||||||
iterator = this->checklists->create_iterator(this->checklists, TRUE);
|
enumerator = this->checklists->create_enumerator(this->checklists);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
if (current == checklist)
|
if (current == checklist)
|
||||||
{
|
{
|
||||||
iterator->remove(iterator);
|
this->checklists->remove_at(this->checklists, enumerator);
|
||||||
break;
|
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,
|
static status_t get_triggered_pair(check_list_t *checklist,
|
||||||
endpoint_pair_t **pair)
|
endpoint_pair_t **pair)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
endpoint_pair_t *current;
|
endpoint_pair_t *current;
|
||||||
status_t status = NOT_FOUND;
|
status_t status = NOT_FOUND;
|
||||||
|
|
||||||
iterator = checklist->triggered->create_iterator(checklist->triggered, TRUE);
|
enumerator = checklist->triggered->create_enumerator(checklist->triggered);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
iterator->remove(iterator);
|
checklist->triggered->remove_at(checklist->triggered, enumerator);
|
||||||
|
|
||||||
if (current->state == CHECK_WAITING)
|
if (current->state == CHECK_WAITING)
|
||||||
{
|
{
|
||||||
|
@ -650,7 +650,7 @@ static status_t get_triggered_pair(check_list_t *checklist,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -660,17 +660,17 @@ static status_t get_triggered_pair(check_list_t *checklist,
|
||||||
*/
|
*/
|
||||||
static void print_checklist(check_list_t *checklist)
|
static void print_checklist(check_list_t *checklist)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
endpoint_pair_t *current;
|
endpoint_pair_t *current;
|
||||||
|
|
||||||
DBG1(DBG_IKE, "pairs on checklist %#B:", &checklist->connect_id);
|
DBG1(DBG_IKE, "pairs on checklist %#B:", &checklist->connect_id);
|
||||||
iterator = checklist->pairs->create_iterator(checklist->pairs, TRUE);
|
enumerator = checklist->pairs->create_enumerator(checklist->pairs);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
DBG1(DBG_IKE, " * %#H - %#H (%d)", current->local, current->remote,
|
DBG1(DBG_IKE, " * %#H - %#H (%d)", current->local, current->remote,
|
||||||
current->priority);
|
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)
|
static void build_pairs(check_list_t *checklist)
|
||||||
{
|
{
|
||||||
/* FIXME: limit endpoints and pairs */
|
/* FIXME: limit endpoints and pairs */
|
||||||
iterator_t *iterator_i, *iterator_r;
|
enumerator_t *enumerator_i, *enumerator_r;
|
||||||
endpoint_notify_t *initiator, *responder;
|
endpoint_notify_t *initiator, *responder;
|
||||||
|
|
||||||
iterator_i = checklist->initiator.endpoints->create_iterator(
|
enumerator_i = checklist->initiator.endpoints->create_enumerator(
|
||||||
checklist->initiator.endpoints, TRUE);
|
checklist->initiator.endpoints);
|
||||||
while (iterator_i->iterate(iterator_i, (void**)&initiator))
|
while (enumerator_i->enumerate(enumerator_i, (void**)&initiator))
|
||||||
{
|
{
|
||||||
iterator_r = checklist->responder.endpoints->create_iterator(
|
enumerator_r = checklist->responder.endpoints->create_enumerator(
|
||||||
checklist->responder.endpoints, TRUE);
|
checklist->responder.endpoints);
|
||||||
while (iterator_r->iterate(iterator_r, (void**)&responder))
|
while (enumerator_r->enumerate(enumerator_r, (void**)&responder))
|
||||||
{
|
{
|
||||||
if (initiator->get_family(initiator) != responder->get_family(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(
|
insert_pair_by_priority(checklist->pairs, endpoint_pair_create(
|
||||||
initiator, responder, checklist->is_initiator));
|
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);
|
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,
|
static void update_checklist_state(private_connect_manager_t *this,
|
||||||
check_list_t *checklist)
|
check_list_t *checklist)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
endpoint_pair_t *current;
|
endpoint_pair_t *current;
|
||||||
bool in_progress = FALSE, succeeded = FALSE;
|
bool in_progress = FALSE, succeeded = FALSE;
|
||||||
|
|
||||||
iterator = checklist->pairs->create_iterator(checklist->pairs, TRUE);
|
enumerator = checklist->pairs->create_enumerator(checklist->pairs);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
switch(current->state)
|
switch(current->state)
|
||||||
{
|
{
|
||||||
case CHECK_WAITING:
|
case CHECK_WAITING:
|
||||||
/* at least one is still waiting -> checklist remains
|
/* at least one is still waiting -> checklist remains
|
||||||
* in waiting state */
|
* in waiting state */
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return;
|
return;
|
||||||
case CHECK_IN_PROGRESS:
|
case CHECK_IN_PROGRESS:
|
||||||
in_progress = TRUE;
|
in_progress = TRUE;
|
||||||
|
@ -919,7 +919,7 @@ static void update_checklist_state(private_connect_manager_t *this,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
if (checklist->is_initiator && succeeded && !checklist->is_finishing)
|
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)
|
if (get_best_valid_pair(checklist, &pair) == SUCCESS)
|
||||||
{
|
{
|
||||||
ike_sa_id_t *waiting_sa;
|
ike_sa_id_t *waiting_sa;
|
||||||
iterator_t *iterator = initiated->mediated->create_iterator(initiated->mediated, TRUE);
|
enumerator_t *enumerator = initiated->mediated->create_enumerator(
|
||||||
while (iterator->iterate(iterator, (void**)&waiting_sa))
|
initiated->mediated);
|
||||||
|
while (enumerator->enumerate(enumerator, (void**)&waiting_sa))
|
||||||
{
|
{
|
||||||
ike_sa_t *sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager, 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)
|
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);
|
charon->ike_sa_manager->checkin(charon->ike_sa_manager, sa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1474,15 +1475,15 @@ static void check_and_initiate(private_connect_manager_t *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
ike_sa_id_t *waiting_sa;
|
ike_sa_id_t *waiting_sa;
|
||||||
iterator_t *iterator = initiated->mediated->create_iterator(
|
enumerator_t *enumerator = initiated->mediated->create_enumerator(
|
||||||
initiated->mediated, TRUE);
|
initiated->mediated);
|
||||||
while (iterator->iterate(iterator, (void**)&waiting_sa))
|
while (enumerator->enumerate(enumerator, (void**)&waiting_sa))
|
||||||
{
|
{
|
||||||
job_t *job = (job_t*)reinitiate_mediation_job_create(mediation_sa,
|
job_t *job = (job_t*)reinitiate_mediation_job_create(mediation_sa,
|
||||||
waiting_sa);
|
waiting_sa);
|
||||||
lib->processor->queue_job(lib->processor, job);
|
lib->processor->queue_job(lib->processor, job);
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
this->mutex->unlock(this->mutex);
|
this->mutex->unlock(this->mutex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -869,11 +869,11 @@ METHOD(ike_sa_t, update_hosts, void,
|
||||||
/* update all associated CHILD_SAs, if required */
|
/* update all associated CHILD_SAs, if required */
|
||||||
if (update)
|
if (update)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
|
|
||||||
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
enumerator = this->child_sas->create_enumerator(this->child_sas);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (child_sa->update(child_sa, this->my_host,
|
if (child_sa->update(child_sa, this->my_host,
|
||||||
this->other_host, this->my_virtual_ip,
|
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));
|
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*,
|
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)
|
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;
|
child_sa_t *current, *found = NULL;
|
||||||
|
|
||||||
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
enumerator = this->child_sas->create_enumerator(this->child_sas);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
if (current->get_spi(current, inbound) == spi &&
|
if (current->get_spi(current, inbound) == spi &&
|
||||||
current->get_protocol(current) == protocol)
|
current->get_protocol(current) == protocol)
|
||||||
|
@ -1389,7 +1389,7 @@ METHOD(ike_sa_t, get_child_sa, child_sa_t*,
|
||||||
found = current;
|
found = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1422,23 +1422,23 @@ METHOD(ike_sa_t, delete_child_sa, status_t,
|
||||||
METHOD(ike_sa_t, destroy_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)
|
private_ike_sa_t *this, protocol_id_t protocol, u_int32_t spi)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
status_t status = NOT_FOUND;
|
status_t status = NOT_FOUND;
|
||||||
|
|
||||||
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
enumerator = this->child_sas->create_enumerator(this->child_sas);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (child_sa->get_protocol(child_sa) == protocol &&
|
if (child_sa->get_protocol(child_sa) == protocol &&
|
||||||
child_sa->get_spi(child_sa, TRUE) == spi)
|
child_sa->get_spi(child_sa, TRUE) == spi)
|
||||||
{
|
{
|
||||||
|
this->child_sas->remove_at(this->child_sas, enumerator);
|
||||||
child_sa->destroy(child_sa);
|
child_sa->destroy(child_sa);
|
||||||
iterator->remove(iterator);
|
|
||||||
status = SUCCESS;
|
status = SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1521,15 +1521,15 @@ METHOD(ike_sa_t, reestablish, status_t,
|
||||||
ike_sa_t *new;
|
ike_sa_t *new;
|
||||||
host_t *host;
|
host_t *host;
|
||||||
action_t action;
|
action_t action;
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg;
|
||||||
bool restart = FALSE;
|
bool restart = FALSE;
|
||||||
status_t status = FAILED;
|
status_t status = FAILED;
|
||||||
|
|
||||||
/* check if we have children to keep up at all */
|
/* check if we have children to keep up at all */
|
||||||
iterator = create_child_sa_iterator(this);
|
enumerator = this->child_sas->create_enumerator(this->child_sas);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (this->state == IKE_DELETING)
|
if (this->state == IKE_DELETING)
|
||||||
{
|
{
|
||||||
|
@ -1552,7 +1552,7 @@ METHOD(ike_sa_t, reestablish, status_t,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
#ifdef ME
|
#ifdef ME
|
||||||
/* mediation connections have no children, keep them up anyway */
|
/* mediation connections have no children, keep them up anyway */
|
||||||
if (this->peer_cfg->is_mediation(this->peer_cfg))
|
if (this->peer_cfg->is_mediation(this->peer_cfg))
|
||||||
|
@ -1599,8 +1599,8 @@ METHOD(ike_sa_t, reestablish, status_t,
|
||||||
else
|
else
|
||||||
#endif /* ME */
|
#endif /* ME */
|
||||||
{
|
{
|
||||||
iterator = create_child_sa_iterator(this);
|
enumerator = this->child_sas->create_enumerator(this->child_sas);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (this->state == IKE_DELETING)
|
if (this->state == IKE_DELETING)
|
||||||
{
|
{
|
||||||
|
@ -1627,7 +1627,7 @@ METHOD(ike_sa_t, reestablish, status_t,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == DESTROY_ME)
|
if (status == DESTROY_ME)
|
||||||
|
|
|
@ -90,19 +90,19 @@ struct private_mediation_manager_t {
|
||||||
*/
|
*/
|
||||||
static void register_peer(peer_t *peer, identification_t *peer_id)
|
static void register_peer(peer_t *peer, identification_t *peer_id)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
identification_t *current;
|
identification_t *current;
|
||||||
|
|
||||||
iterator = peer->requested_by->create_iterator(peer->requested_by, TRUE);
|
enumerator = peer->requested_by->create_enumerator(peer->requested_by);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
if (peer_id->equals(peer_id, current))
|
if (peer_id->equals(peer_id, current))
|
||||||
{
|
{
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
peer->requested_by->insert_last(peer->requested_by,
|
peer->requested_by->insert_last(peer->requested_by,
|
||||||
peer_id->clone(peer_id));
|
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,
|
static status_t get_peer_by_id(private_mediation_manager_t *this,
|
||||||
identification_t *id, peer_t **peer)
|
identification_t *id, peer_t **peer)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
peer_t *current;
|
peer_t *current;
|
||||||
status_t status = NOT_FOUND;
|
status_t status = NOT_FOUND;
|
||||||
|
|
||||||
iterator = this->peers->create_iterator(this->peers, TRUE);
|
enumerator = this->peers->create_enumerator(this->peers);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
if (id->equals(id, current->id))
|
if (id->equals(id, current->id))
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ static status_t get_peer_by_id(private_mediation_manager_t *this,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
return status;
|
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,
|
static void unregister_peer(private_mediation_manager_t *this,
|
||||||
identification_t *peer_id)
|
identification_t *peer_id)
|
||||||
{
|
{
|
||||||
iterator_t *iterator, *iterator_r;
|
enumerator_t *enumerator, *enumerator_r;
|
||||||
peer_t *peer;
|
peer_t *peer;
|
||||||
identification_t *registered;
|
identification_t *registered;
|
||||||
|
|
||||||
iterator = this->peers->create_iterator(this->peers, TRUE);
|
enumerator = this->peers->create_enumerator(this->peers);
|
||||||
while (iterator->iterate(iterator, (void**)&peer))
|
while (enumerator->enumerate(enumerator, (void**)&peer))
|
||||||
{
|
{
|
||||||
iterator_r = peer->requested_by->create_iterator(peer->requested_by,
|
enumerator_r = peer->requested_by->create_enumerator(peer->requested_by);
|
||||||
TRUE);
|
while (enumerator_r->enumerate(enumerator_r, (void**)®istered))
|
||||||
while (iterator_r->iterate(iterator_r, (void**)®istered))
|
|
||||||
{
|
{
|
||||||
if (peer_id->equals(peer_id, 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);
|
registered->destroy(registered);
|
||||||
break;
|
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);
|
peer_destroy(peer);
|
||||||
break;
|
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)
|
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;
|
peer_t *peer;
|
||||||
|
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
|
|
||||||
iterator = this->peers->create_iterator(this->peers, TRUE);
|
enumerator = this->peers->create_enumerator(this->peers);
|
||||||
while (iterator->iterate(iterator, (void**)&peer))
|
while (enumerator->enumerate(enumerator, (void**)&peer))
|
||||||
{
|
{
|
||||||
if (ike_sa_id->equals(ike_sa_id, peer->ike_sa_id))
|
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);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
this->mutex->unlock(this->mutex);
|
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)
|
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;
|
peer_t *peer;
|
||||||
bool found = FALSE;
|
bool found = FALSE;
|
||||||
|
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
|
|
||||||
iterator = this->peers->create_iterator(this->peers, TRUE);
|
enumerator = this->peers->create_enumerator(this->peers);
|
||||||
while (iterator->iterate(iterator, (void**)&peer))
|
while (enumerator->enumerate(enumerator, (void**)&peer))
|
||||||
{
|
{
|
||||||
if (peer_id->equals(peer_id, peer->id))
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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)
|
static bool activate_task(private_task_manager_t *this, task_type_t type)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
task_t *task;
|
task_t *task;
|
||||||
bool found = FALSE;
|
bool found = FALSE;
|
||||||
|
|
||||||
iterator = this->queued_tasks->create_iterator(this->queued_tasks, TRUE);
|
enumerator = this->queued_tasks->create_enumerator(this->queued_tasks);
|
||||||
while (iterator->iterate(iterator, (void**)&task))
|
while (enumerator->enumerate(enumerator, (void**)&task))
|
||||||
{
|
{
|
||||||
if (task->get_type(task) == type)
|
if (task->get_type(task) == type)
|
||||||
{
|
{
|
||||||
DBG2(DBG_IKE, " activating %N task", task_type_names, 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);
|
this->active_tasks->insert_last(this->active_tasks, task);
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,14 +202,14 @@ METHOD(task_manager_t, retransmit, status_t,
|
||||||
{
|
{
|
||||||
u_int32_t timeout;
|
u_int32_t timeout;
|
||||||
job_t *job;
|
job_t *job;
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
packet_t *packet;
|
packet_t *packet;
|
||||||
task_t *task;
|
task_t *task;
|
||||||
ike_mobike_t *mobike = NULL;
|
ike_mobike_t *mobike = NULL;
|
||||||
|
|
||||||
/* check if we are retransmitting a MOBIKE routability check */
|
/* check if we are retransmitting a MOBIKE routability check */
|
||||||
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
|
enumerator = this->active_tasks->create_enumerator(this->active_tasks);
|
||||||
while (iterator->iterate(iterator, (void*)&task))
|
while (enumerator->enumerate(enumerator, (void*)&task))
|
||||||
{
|
{
|
||||||
if (task->get_type(task) == IKE_MOBIKE)
|
if (task->get_type(task) == IKE_MOBIKE)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,7 @@ METHOD(task_manager_t, retransmit, status_t,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
if (mobike == NULL)
|
if (mobike == NULL)
|
||||||
{
|
{
|
||||||
|
@ -282,7 +282,7 @@ METHOD(task_manager_t, retransmit, status_t,
|
||||||
METHOD(task_manager_t, initiate, status_t,
|
METHOD(task_manager_t, initiate, status_t,
|
||||||
private_task_manager_t *this)
|
private_task_manager_t *this)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
task_t *task;
|
task_t *task;
|
||||||
message_t *message;
|
message_t *message;
|
||||||
host_t *me, *other;
|
host_t *me, *other;
|
||||||
|
@ -387,8 +387,8 @@ METHOD(task_manager_t, initiate, status_t,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBG2(DBG_IKE, "reinitiating already active tasks");
|
DBG2(DBG_IKE, "reinitiating already active tasks");
|
||||||
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
|
enumerator = this->active_tasks->create_enumerator(this->active_tasks);
|
||||||
while (iterator->iterate(iterator, (void**)&task))
|
while (enumerator->enumerate(enumerator, (void**)&task))
|
||||||
{
|
{
|
||||||
DBG2(DBG_IKE, " %N task", task_type_names, task->get_type(task));
|
DBG2(DBG_IKE, " %N task", task_type_names, task->get_type(task));
|
||||||
switch (task->get_type(task))
|
switch (task->get_type(task))
|
||||||
|
@ -411,7 +411,7 @@ METHOD(task_manager_t, initiate, status_t,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exchange == 0)
|
if (exchange == 0)
|
||||||
|
@ -432,14 +432,14 @@ METHOD(task_manager_t, initiate, status_t,
|
||||||
this->initiating.type = exchange;
|
this->initiating.type = exchange;
|
||||||
this->initiating.retransmitted = 0;
|
this->initiating.retransmitted = 0;
|
||||||
|
|
||||||
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
|
enumerator = this->active_tasks->create_enumerator(this->active_tasks);
|
||||||
while (iterator->iterate(iterator, (void*)&task))
|
while (enumerator->enumerate(enumerator, (void*)&task))
|
||||||
{
|
{
|
||||||
switch (task->build(task, message))
|
switch (task->build(task, message))
|
||||||
{
|
{
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
/* task completed, remove it */
|
/* task completed, remove it */
|
||||||
iterator->remove(iterator);
|
this->active_tasks->remove_at(this->active_tasks, enumerator);
|
||||||
task->destroy(task);
|
task->destroy(task);
|
||||||
break;
|
break;
|
||||||
case NEED_MORE:
|
case NEED_MORE:
|
||||||
|
@ -454,13 +454,13 @@ METHOD(task_manager_t, initiate, status_t,
|
||||||
/* FALL */
|
/* FALL */
|
||||||
case DESTROY_ME:
|
case DESTROY_ME:
|
||||||
/* critical failure, destroy IKE_SA */
|
/* critical failure, destroy IKE_SA */
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
message->destroy(message);
|
message->destroy(message);
|
||||||
flush(this);
|
flush(this);
|
||||||
return DESTROY_ME;
|
return DESTROY_ME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
/* update exchange type if a task changed it */
|
/* update exchange type if a task changed it */
|
||||||
this->initiating.type = message->get_exchange_type(message);
|
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,
|
static status_t process_response(private_task_manager_t *this,
|
||||||
message_t *message)
|
message_t *message)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
task_t *task;
|
task_t *task;
|
||||||
|
|
||||||
if (message->get_exchange_type(message) != this->initiating.type)
|
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 */
|
/* catch if we get resetted while processing */
|
||||||
this->reset = FALSE;
|
this->reset = FALSE;
|
||||||
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
|
enumerator = this->active_tasks->create_enumerator(this->active_tasks);
|
||||||
while (iterator->iterate(iterator, (void*)&task))
|
while (enumerator->enumerate(enumerator, (void*)&task))
|
||||||
{
|
{
|
||||||
switch (task->process(task, message))
|
switch (task->process(task, message))
|
||||||
{
|
{
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
/* task completed, remove it */
|
/* task completed, remove it */
|
||||||
iterator->remove(iterator);
|
this->active_tasks->remove_at(this->active_tasks, enumerator);
|
||||||
task->destroy(task);
|
task->destroy(task);
|
||||||
break;
|
break;
|
||||||
case NEED_MORE:
|
case NEED_MORE:
|
||||||
|
@ -520,19 +520,19 @@ static status_t process_response(private_task_manager_t *this,
|
||||||
/* FALL */
|
/* FALL */
|
||||||
case DESTROY_ME:
|
case DESTROY_ME:
|
||||||
/* critical failure, destroy IKE_SA */
|
/* critical failure, destroy IKE_SA */
|
||||||
iterator->remove(iterator);
|
this->active_tasks->remove_at(this->active_tasks, enumerator);
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
task->destroy(task);
|
task->destroy(task);
|
||||||
return DESTROY_ME;
|
return DESTROY_ME;
|
||||||
}
|
}
|
||||||
if (this->reset)
|
if (this->reset)
|
||||||
{ /* start all over again if we were reset */
|
{ /* start all over again if we were reset */
|
||||||
this->reset = FALSE;
|
this->reset = FALSE;
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return initiate(this);
|
return initiate(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
this->initiating.mid++;
|
this->initiating.mid++;
|
||||||
this->initiating.type = EXCHANGE_TYPE_UNDEFINED;
|
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)
|
static bool handle_collisions(private_task_manager_t *this, task_t *task)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
task_t *active;
|
task_t *active;
|
||||||
task_type_t type;
|
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)
|
type == CHILD_DELETE || type == IKE_DELETE || type == IKE_REAUTH)
|
||||||
{
|
{
|
||||||
/* find an exchange collision, and notify these tasks */
|
/* find an exchange collision, and notify these tasks */
|
||||||
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
|
enumerator = this->active_tasks->create_enumerator(this->active_tasks);
|
||||||
while (iterator->iterate(iterator, (void**)&active))
|
while (enumerator->enumerate(enumerator, (void**)&active))
|
||||||
{
|
{
|
||||||
switch (active->get_type(active))
|
switch (active->get_type(active))
|
||||||
{
|
{
|
||||||
|
@ -583,10 +583,10 @@ static bool handle_collisions(private_task_manager_t *this, task_t *task)
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
return FALSE;
|
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)
|
static status_t build_response(private_task_manager_t *this, message_t *request)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
task_t *task;
|
task_t *task;
|
||||||
message_t *message;
|
message_t *message;
|
||||||
host_t *me, *other;
|
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_message_id(message, this->responding.mid);
|
||||||
message->set_request(message, FALSE);
|
message->set_request(message, FALSE);
|
||||||
|
|
||||||
iterator = this->passive_tasks->create_iterator(this->passive_tasks, TRUE);
|
enumerator = this->passive_tasks->create_enumerator(this->passive_tasks);
|
||||||
while (iterator->iterate(iterator, (void*)&task))
|
while (enumerator->enumerate(enumerator, (void*)&task))
|
||||||
{
|
{
|
||||||
switch (task->build(task, message))
|
switch (task->build(task, message))
|
||||||
{
|
{
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
/* task completed, remove it */
|
/* task completed, remove it */
|
||||||
iterator->remove(iterator);
|
this->passive_tasks->remove_at(this->passive_tasks, enumerator);
|
||||||
if (!handle_collisions(this, task))
|
if (!handle_collisions(this, task))
|
||||||
{
|
{
|
||||||
task->destroy(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 */
|
/* processed, but task needs another exchange */
|
||||||
if (handle_collisions(this, task))
|
if (handle_collisions(this, task))
|
||||||
{
|
{
|
||||||
iterator->remove(iterator);
|
this->passive_tasks->remove_at(this->passive_tasks,
|
||||||
|
enumerator);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FAILED:
|
case FAILED:
|
||||||
|
@ -648,7 +649,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
/* remove resonder SPI if IKE_SA_INIT failed */
|
/* remove resonder SPI if IKE_SA_INIT failed */
|
||||||
if (delete && request->get_exchange_type(request) == IKE_SA_INIT)
|
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)
|
message_t *message)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
iterator_t *iterator;
|
|
||||||
task_t *task = NULL;
|
task_t *task = NULL;
|
||||||
payload_t *payload;
|
payload_t *payload;
|
||||||
notify_payload_t *notify;
|
notify_payload_t *notify;
|
||||||
|
@ -854,14 +854,14 @@ static status_t process_request(private_task_manager_t *this,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* let the tasks process the message */
|
/* let the tasks process the message */
|
||||||
iterator = this->passive_tasks->create_iterator(this->passive_tasks, TRUE);
|
enumerator = this->passive_tasks->create_enumerator(this->passive_tasks);
|
||||||
while (iterator->iterate(iterator, (void*)&task))
|
while (enumerator->enumerate(enumerator, (void*)&task))
|
||||||
{
|
{
|
||||||
switch (task->process(task, message))
|
switch (task->process(task, message))
|
||||||
{
|
{
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
/* task completed, remove it */
|
/* task completed, remove it */
|
||||||
iterator->remove(iterator);
|
this->passive_tasks->remove_at(this->passive_tasks, enumerator);
|
||||||
task->destroy(task);
|
task->destroy(task);
|
||||||
break;
|
break;
|
||||||
case NEED_MORE:
|
case NEED_MORE:
|
||||||
|
@ -873,13 +873,13 @@ static status_t process_request(private_task_manager_t *this,
|
||||||
/* FALL */
|
/* FALL */
|
||||||
case DESTROY_ME:
|
case DESTROY_ME:
|
||||||
/* critical failure, destroy IKE_SA */
|
/* critical failure, destroy IKE_SA */
|
||||||
iterator->remove(iterator);
|
this->passive_tasks->remove_at(this->passive_tasks, enumerator);
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
task->destroy(task);
|
task->destroy(task);
|
||||||
return DESTROY_ME;
|
return DESTROY_ME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
return build_response(this, message);
|
return build_response(this, message);
|
||||||
}
|
}
|
||||||
|
@ -978,20 +978,20 @@ METHOD(task_manager_t, queue_task, void,
|
||||||
{
|
{
|
||||||
if (task->get_type(task) == IKE_MOBIKE)
|
if (task->get_type(task) == IKE_MOBIKE)
|
||||||
{ /* there is no need to queue more than one mobike task */
|
{ /* there is no need to queue more than one mobike task */
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
task_t *current;
|
task_t *current;
|
||||||
|
|
||||||
iterator = this->queued_tasks->create_iterator(this->queued_tasks, TRUE);
|
enumerator = this->queued_tasks->create_enumerator(this->queued_tasks);
|
||||||
while (iterator->iterate(iterator, (void**)¤t))
|
while (enumerator->enumerate(enumerator, (void**)¤t))
|
||||||
{
|
{
|
||||||
if (current->get_type(current) == IKE_MOBIKE)
|
if (current->get_type(current) == IKE_MOBIKE)
|
||||||
{
|
{
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
task->destroy(task);
|
task->destroy(task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
DBG2(DBG_IKE, "queueing %N task", task_type_names, task->get_type(task));
|
DBG2(DBG_IKE, "queueing %N task", task_type_names, task->get_type(task));
|
||||||
this->queued_tasks->insert_last(this->queued_tasks, task);
|
this->queued_tasks->insert_last(this->queued_tasks, task);
|
||||||
|
|
|
@ -213,13 +213,13 @@ static bool ts_list_is_host(linked_list_t *list, host_t *host)
|
||||||
{
|
{
|
||||||
traffic_selector_t *ts;
|
traffic_selector_t *ts;
|
||||||
bool is_host = TRUE;
|
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);
|
is_host = is_host && ts->is_host(ts, host);
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return is_host;
|
return is_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,11 +73,11 @@ struct private_child_delete_t {
|
||||||
static void build_payloads(private_child_delete_t *this, message_t *message)
|
static void build_payloads(private_child_delete_t *this, message_t *message)
|
||||||
{
|
{
|
||||||
delete_payload_t *ah = NULL, *esp = NULL;
|
delete_payload_t *ah = NULL, *esp = NULL;
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
|
|
||||||
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
enumerator = this->child_sas->create_enumerator(this->child_sas);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
protocol_id_t protocol = child_sa->get_protocol(child_sa);
|
protocol_id_t protocol = child_sa->get_protocol(child_sa);
|
||||||
u_int32_t spi = child_sa->get_spi(child_sa, TRUE);
|
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);
|
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)
|
static status_t destroy_and_reestablish(private_child_delete_t *this)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
child_cfg_t *child_cfg;
|
child_cfg_t *child_cfg;
|
||||||
protocol_id_t protocol;
|
protocol_id_t protocol;
|
||||||
|
@ -194,8 +194,8 @@ static status_t destroy_and_reestablish(private_child_delete_t *this)
|
||||||
action_t action;
|
action_t action;
|
||||||
status_t status = SUCCESS;
|
status_t status = SUCCESS;
|
||||||
|
|
||||||
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
enumerator = this->child_sas->create_enumerator(this->child_sas);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
/* signal child down event if we are not rekeying */
|
/* signal child down event if we are not rekeying */
|
||||||
if (!this->rekeyed)
|
if (!this->rekeyed)
|
||||||
|
@ -231,7 +231,7 @@ static status_t destroy_and_reestablish(private_child_delete_t *this)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return status;
|
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)
|
static void log_children(private_child_delete_t *this)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
u_int64_t bytes_in, bytes_out;
|
u_int64_t bytes_in, bytes_out;
|
||||||
|
|
||||||
iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
|
enumerator = this->child_sas->create_enumerator(this->child_sas);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in);
|
child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in);
|
||||||
child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out);
|
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, TRUE),
|
||||||
child_sa->get_traffic_selectors(child_sa, FALSE));
|
child_sa->get_traffic_selectors(child_sa, FALSE));
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -112,7 +112,7 @@ static void build_payloads(private_ike_init_t *this, message_t *message)
|
||||||
linked_list_t *proposal_list;
|
linked_list_t *proposal_list;
|
||||||
ike_sa_id_t *id;
|
ike_sa_id_t *id;
|
||||||
proposal_t *proposal;
|
proposal_t *proposal;
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
|
|
||||||
id = this->ike_sa->get_id(this->ike_sa);
|
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)
|
if (this->old_sa)
|
||||||
{
|
{
|
||||||
/* include SPI of new IKE_SA when we are rekeying */
|
/* include SPI of new IKE_SA when we are rekeying */
|
||||||
iterator = proposal_list->create_iterator(proposal_list, TRUE);
|
enumerator = proposal_list->create_enumerator(proposal_list);
|
||||||
while (iterator->iterate(iterator, (void**)&proposal))
|
while (enumerator->enumerate(enumerator, (void**)&proposal))
|
||||||
{
|
{
|
||||||
proposal->set_spi(proposal, id->get_initiator_spi(id));
|
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);
|
sa_payload = sa_payload_create_from_proposal_list(proposal_list);
|
||||||
|
|
|
@ -111,15 +111,15 @@ struct private_ike_me_t {
|
||||||
*/
|
*/
|
||||||
static void add_endpoints_to_message(message_t *message, linked_list_t *endpoints)
|
static void add_endpoints_to_message(message_t *message, linked_list_t *endpoints)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
endpoint_notify_t *endpoint;
|
endpoint_notify_t *endpoint;
|
||||||
|
|
||||||
iterator = endpoints->create_iterator(endpoints, TRUE);
|
enumerator = endpoints->create_enumerator(endpoints);
|
||||||
while (iterator->iterate(iterator, (void**)&endpoint))
|
while (enumerator->enumerate(enumerator, (void**)&endpoint))
|
||||||
{
|
{
|
||||||
message->add_payload(message, (payload_t*)endpoint->build_notify(endpoint));
|
message->add_payload(message, (payload_t*)endpoint->build_notify(endpoint));
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -193,16 +193,16 @@ struct private_kernel_netlink_net_t {
|
||||||
*/
|
*/
|
||||||
static int get_vip_refcount(private_kernel_netlink_net_t *this, host_t* ip)
|
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;
|
iface_entry_t *iface;
|
||||||
addr_entry_t *addr;
|
addr_entry_t *addr;
|
||||||
int refcount = 0;
|
int refcount = 0;
|
||||||
|
|
||||||
ifaces = this->ifaces->create_iterator(this->ifaces, TRUE);
|
ifaces = this->ifaces->create_enumerator(this->ifaces);
|
||||||
while (ifaces->iterate(ifaces, (void**)&iface))
|
while (ifaces->enumerate(ifaces, (void**)&iface))
|
||||||
{
|
{
|
||||||
addrs = iface->addrs->create_iterator(iface->addrs, TRUE);
|
addrs = iface->addrs->create_enumerator(iface->addrs);
|
||||||
while (addrs->iterate(addrs, (void**)&addr))
|
while (addrs->enumerate(addrs, (void**)&addr))
|
||||||
{
|
{
|
||||||
if (addr->virtual && (iface->flags & IFF_UP) &&
|
if (addr->virtual && (iface->flags & IFF_UP) &&
|
||||||
ip->ip_equals(ip, addr->ip))
|
ip->ip_equals(ip, addr->ip))
|
||||||
|
|
|
@ -198,7 +198,7 @@ static attribute_t *attribute_create(int oid, chunk_t value)
|
||||||
*/
|
*/
|
||||||
static void build_encoding(private_pkcs9_t *this)
|
static void build_encoding(private_pkcs9_t *this)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
attribute_t *attribute;
|
attribute_t *attribute;
|
||||||
u_int attributes_len = 0;
|
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 */
|
/* 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;
|
attributes_len += attribute->encoding.len;
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
/* allocate memory for the attributes and build the encoding */
|
/* allocate memory for the attributes and build the encoding */
|
||||||
{
|
{
|
||||||
u_char *pos = asn1_build_object(&this->encoding, ASN1_SET, attributes_len);
|
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);
|
memcpy(pos, attribute->encoding.ptr, attribute->encoding.len);
|
||||||
pos += 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)
|
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;
|
chunk_t value = chunk_empty;
|
||||||
attribute_t *attribute;
|
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)
|
if (attribute->oid == oid)
|
||||||
{
|
{
|
||||||
|
@ -264,7 +265,7 @@ static chunk_t get_attribute(private_pkcs9_t *this, int oid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,11 +179,11 @@ static bool parse_directoryName(chunk_t blob, int level, bool implicit, identifi
|
||||||
|
|
||||||
if (has_directoryName)
|
if (has_directoryName)
|
||||||
{
|
{
|
||||||
iterator_t *iterator = list->create_iterator(list, TRUE);
|
enumerator_t *enumerator = list->create_enumerator(list);
|
||||||
identification_t *directoryName;
|
identification_t *directoryName;
|
||||||
bool first = TRUE;
|
bool first = TRUE;
|
||||||
|
|
||||||
while (iterator->iterate(iterator, (void**)&directoryName))
|
while (enumerator->enumerate(enumerator, (void**)&directoryName))
|
||||||
{
|
{
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ static bool parse_directoryName(chunk_t blob, int level, bool implicit, identifi
|
||||||
directoryName->destroy(directoryName);
|
directoryName->destroy(directoryName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -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]));
|
private_traffic_selector_t *this = *((private_traffic_selector_t**)(args[0]));
|
||||||
linked_list_t *list = *((linked_list_t**)(args[0]));
|
linked_list_t *list = *((linked_list_t**)(args[0]));
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
char from_str[INET6_ADDRSTRLEN] = "";
|
char from_str[INET6_ADDRSTRLEN] = "";
|
||||||
char to_str[INET6_ADDRSTRLEN] = "";
|
char to_str[INET6_ADDRSTRLEN] = "";
|
||||||
char *serv_proto = NULL;
|
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)
|
if (spec->hash)
|
||||||
{
|
{
|
||||||
iterator = list->create_iterator(list, TRUE);
|
enumerator = list->create_enumerator(list);
|
||||||
while (iterator->iterate(iterator, (void**)&this))
|
while (enumerator->enumerate(enumerator, (void**)&this))
|
||||||
{
|
{
|
||||||
/* call recursivly */
|
/* call recursivly */
|
||||||
written += print_in_hook(dst, len, "%R ", this);
|
written += print_in_hook(dst, len, "%R ", this);
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ typedef struct enumerator_t enumerator_t;
|
||||||
#include "../utils.h"
|
#include "../utils.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumerate is simpler, but more flexible than iterator.
|
* Enumerator interface, allows enumeration over collections.
|
||||||
*/
|
*/
|
||||||
struct enumerator_t {
|
struct enumerator_t {
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
|
|
||||||
#include <context.h>
|
#include <context.h>
|
||||||
|
|
||||||
#include <utils/iterator.h>
|
|
||||||
|
|
||||||
typedef struct manager_t manager_t;
|
typedef struct manager_t manager_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +44,7 @@ struct manager_t {
|
||||||
context_t context;
|
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
|
* enumerate() arguments: int id, char *name, int port, char *address
|
||||||
* If port is 0, address is a Unix socket address.
|
* If port is 0, address is a Unix socket address.
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct storage_t {
|
||||||
int (*login)(storage_t *this, char *username, char *password);
|
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
|
* enumerate() arguments: int id, char *name, int port, char *address
|
||||||
* If port is 0, address is a Unix socket address.
|
* If port is 0, address is a Unix socket address.
|
||||||
|
|
Loading…
Reference in New Issue