aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-04-03 17:08:00 +0200
committerMartin Willi <martin@revosec.ch>2013-04-03 17:08:00 +0200
commitbee8b5e38553fbd164573631018ea7f59ff641b9 (patch)
treed7fca85124405f7ad3f0f4c71219419ef00e575f /src
parentac48d9e458699aa68f774aaa3168533cf42f95b0 (diff)
downloadstrongswan-bee8b5e38553fbd164573631018ea7f59ff641b9.tar.bz2
strongswan-bee8b5e38553fbd164573631018ea7f59ff641b9.tar.xz
Refactor check_for_rekeyed_child() in quick_mode task
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/sa/ikev1/tasks/quick_mode.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/libcharon/sa/ikev1/tasks/quick_mode.c b/src/libcharon/sa/ikev1/tasks/quick_mode.c
index bb50ca9ca..7a0fb5788 100644
--- a/src/libcharon/sa/ikev1/tasks/quick_mode.c
+++ b/src/libcharon/sa/ikev1/tasks/quick_mode.c
@@ -921,31 +921,37 @@ static void check_for_rekeyed_child(private_quick_mode_t *this)
enumerator_t *enumerator, *policies;
traffic_selector_t *local, *remote;
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);
while (this->reqid == 0 && enumerator->enumerate(enumerator, &child_sa))
{
- if ((child_sa->get_state(child_sa) == CHILD_INSTALLED ||
- child_sa->get_state(child_sa) == CHILD_REKEYING) &&
- streq(child_sa->get_name(child_sa),
- this->config->get_name(this->config)))
+ if (streq(child_sa->get_name(child_sa), name))
{
- policies = child_sa->create_policy_enumerator(child_sa);
- if (policies->enumerate(policies, &local, &remote))
+ proposal = child_sa->get_proposal(child_sa);
+ switch (child_sa->get_state(child_sa))
{
- if (local->equals(local, this->tsr) &&
- remote->equals(remote, this->tsi) &&
- this->proposal->equals(this->proposal,
- child_sa->get_proposal(child_sa)))
- {
- this->reqid = child_sa->get_reqid(child_sa);
- 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);
- }
+ case CHILD_INSTALLED:
+ case CHILD_REKEYING:
+ policies = child_sa->create_policy_enumerator(child_sa);
+ if (policies->enumerate(policies, &local, &remote) &&
+ local->equals(local, this->tsr) &&
+ remote->equals(remote, this->tsi) &&
+ this->proposal->equals(this->proposal, proposal))
+ {
+ this->reqid = child_sa->get_reqid(child_sa);
+ 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);