Refactor check_for_rekeyed_child() in quick_mode task
This commit is contained in:
@@ -921,31 +921,37 @@ static void check_for_rekeyed_child(private_quick_mode_t *this)
|
|||||||
enumerator_t *enumerator, *policies;
|
enumerator_t *enumerator, *policies;
|
||||||
traffic_selector_t *local, *remote;
|
traffic_selector_t *local, *remote;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
|
proposal_t *proposal;
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
name = this->config->get_name(this->config);
|
||||||
enumerator = this->ike_sa->create_child_sa_enumerator(this->ike_sa);
|
enumerator = this->ike_sa->create_child_sa_enumerator(this->ike_sa);
|
||||||
while (this->reqid == 0 && enumerator->enumerate(enumerator, &child_sa))
|
while (this->reqid == 0 && enumerator->enumerate(enumerator, &child_sa))
|
||||||
{
|
{
|
||||||
if ((child_sa->get_state(child_sa) == CHILD_INSTALLED ||
|
if (streq(child_sa->get_name(child_sa), name))
|
||||||
child_sa->get_state(child_sa) == CHILD_REKEYING) &&
|
|
||||||
streq(child_sa->get_name(child_sa),
|
|
||||||
this->config->get_name(this->config)))
|
|
||||||
{
|
{
|
||||||
policies = child_sa->create_policy_enumerator(child_sa);
|
proposal = child_sa->get_proposal(child_sa);
|
||||||
if (policies->enumerate(policies, &local, &remote))
|
switch (child_sa->get_state(child_sa))
|
||||||
{
|
{
|
||||||
if (local->equals(local, this->tsr) &&
|
case CHILD_INSTALLED:
|
||||||
remote->equals(remote, this->tsi) &&
|
case CHILD_REKEYING:
|
||||||
this->proposal->equals(this->proposal,
|
policies = child_sa->create_policy_enumerator(child_sa);
|
||||||
child_sa->get_proposal(child_sa)))
|
if (policies->enumerate(policies, &local, &remote) &&
|
||||||
{
|
local->equals(local, this->tsr) &&
|
||||||
this->reqid = child_sa->get_reqid(child_sa);
|
remote->equals(remote, this->tsi) &&
|
||||||
this->rekey = child_sa->get_spi(child_sa, TRUE);
|
this->proposal->equals(this->proposal, proposal))
|
||||||
child_sa->set_state(child_sa, CHILD_REKEYING);
|
{
|
||||||
DBG1(DBG_IKE, "detected rekeying of CHILD_SA %s{%u}",
|
this->reqid = child_sa->get_reqid(child_sa);
|
||||||
child_sa->get_name(child_sa), this->reqid);
|
this->rekey = child_sa->get_spi(child_sa, TRUE);
|
||||||
}
|
child_sa->set_state(child_sa, CHILD_REKEYING);
|
||||||
|
DBG1(DBG_IKE, "detected rekeying of CHILD_SA %s{%u}",
|
||||||
|
child_sa->get_name(child_sa), this->reqid);
|
||||||
|
}
|
||||||
|
policies->destroy(policies);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
policies->destroy(policies);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
|||||||
Reference in New Issue
Block a user