Replaced ike_sa_t.create_child_sa_iterator with enumerator.
This required two new methods on ike_sa_t. One returns the number of CHILD_SAs and one allows to remove a CHILD_SA.
This commit is contained in:
@@ -256,11 +256,11 @@ static void build_cookie(private_ike_mobike_t *this, message_t *message)
|
||||
*/
|
||||
static void update_children(private_ike_mobike_t *this)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
child_sa_t *child_sa;
|
||||
|
||||
iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
|
||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
||||
enumerator = this->ike_sa->create_child_sa_enumerator(this->ike_sa);
|
||||
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||
{
|
||||
if (child_sa->update(child_sa,
|
||||
this->ike_sa->get_my_host(this->ike_sa),
|
||||
@@ -273,7 +273,7 @@ static void update_children(private_ike_mobike_t *this)
|
||||
child_sa->get_spi(child_sa, TRUE));
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,7 +57,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
||||
{
|
||||
ike_sa_t *new;
|
||||
host_t *host;
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
child_sa_t *child_sa;
|
||||
peer_cfg_t *peer_cfg;
|
||||
|
||||
@@ -67,8 +67,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
||||
peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
|
||||
|
||||
/* reauthenticate only if we have children */
|
||||
iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
|
||||
if (iterator->get_count(iterator) == 0
|
||||
if (this->ike_sa->get_child_count(this->ike_sa) == 0
|
||||
#ifdef ME
|
||||
/* we allow peers to reauth mediation connections (without children) */
|
||||
&& !peer_cfg->is_mediation(peer_cfg)
|
||||
@@ -76,7 +75,6 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
||||
)
|
||||
{
|
||||
DBG1(DBG_IKE, "unable to reauthenticate IKE_SA, no CHILD_SA to recreate");
|
||||
iterator->destroy(iterator);
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
@@ -110,14 +108,15 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
||||
}
|
||||
#endif /* ME */
|
||||
|
||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
||||
enumerator = this->ike_sa->create_child_sa_enumerator(this->ike_sa);
|
||||
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||
{
|
||||
switch (child_sa->get_state(child_sa))
|
||||
{
|
||||
case CHILD_ROUTED:
|
||||
{
|
||||
/* move routed child directly */
|
||||
iterator->remove(iterator);
|
||||
this->ike_sa->remove_child_sa(this->ike_sa, enumerator);
|
||||
new->add_child_sa(new, child_sa);
|
||||
break;
|
||||
}
|
||||
@@ -128,7 +127,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
||||
child_cfg->get_ref(child_cfg);
|
||||
if (new->initiate(new, child_cfg, 0, NULL, NULL) == DESTROY_ME)
|
||||
{
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
charon->ike_sa_manager->checkin_and_destroy(
|
||||
charon->ike_sa_manager, new);
|
||||
/* set threads active IKE_SA after checkin */
|
||||
@@ -140,7 +139,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
charon->ike_sa_manager->checkin(charon->ike_sa_manager, new);
|
||||
/* set threads active IKE_SA after checkin */
|
||||
charon->bus->set_sa(charon->bus, this->ike_sa);
|
||||
|
||||
@@ -147,8 +147,8 @@ METHOD(task_t, build_i, status_t,
|
||||
METHOD(task_t, process_r, status_t,
|
||||
private_ike_rekey_t *this, message_t *message)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
peer_cfg_t *peer_cfg;
|
||||
iterator_t *iterator;
|
||||
child_sa_t *child_sa;
|
||||
|
||||
if (this->ike_sa->get_state(this->ike_sa) == IKE_DELETING)
|
||||
@@ -157,8 +157,8 @@ METHOD(task_t, process_r, status_t,
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
|
||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
||||
enumerator = this->ike_sa->create_child_sa_enumerator(this->ike_sa);
|
||||
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||
{
|
||||
switch (child_sa->get_state(child_sa))
|
||||
{
|
||||
@@ -167,13 +167,13 @@ METHOD(task_t, process_r, status_t,
|
||||
case CHILD_DELETING:
|
||||
/* we do not allow rekeying while we have children in-progress */
|
||||
DBG1(DBG_IKE, "peer initiated rekeying, but a child is half-open");
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
return NEED_MORE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
this->new_sa = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
|
||||
FALSE);
|
||||
|
||||
Reference in New Issue
Block a user