aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-07-09 13:44:06 +0200
committerMartin Willi <martin@strongswan.org>2009-07-09 15:25:16 +0200
commitfa1d3c6629320c52a12b92130ff7059d0c5b3eaa (patch)
tree8b60c087573ad7f85b2c55b3536d2f0fd79d1ad5 /src
parentf5f37cc7fa75c2611832ee3e266fbd3931562d2f (diff)
downloadstrongswan-fa1d3c6629320c52a12b92130ff7059d0c5b3eaa.tar.bz2
strongswan-fa1d3c6629320c52a12b92130ff7059d0c5b3eaa.tar.xz
implemented ike_up() bus hook
Diffstat (limited to 'src')
-rw-r--r--src/charon/bus/bus.c30
-rw-r--r--src/charon/bus/bus.h8
-rw-r--r--src/charon/sa/tasks/ike_auth.c2
3 files changed, 40 insertions, 0 deletions
diff --git a/src/charon/bus/bus.c b/src/charon/bus/bus.c
index 71b120a33..d54aa1806 100644
--- a/src/charon/bus/bus.c
+++ b/src/charon/bus/bus.c
@@ -514,6 +514,35 @@ static void child_keys(private_bus_t *this, child_sa_t *child_sa,
}
/**
+ * Implementation of bus_t.ike_updown
+ */
+static void ike_updown(private_bus_t *this, ike_sa_t *ike_sa, bool up)
+{
+ enumerator_t *enumerator;
+ entry_t *entry;
+ bool keep;
+
+ this->mutex->lock(this->mutex);
+ enumerator = this->listeners->create_enumerator(this->listeners);
+ while (enumerator->enumerate(enumerator, &entry))
+ {
+ if (entry->calling || !entry->listener->ike_updown)
+ {
+ continue;
+ }
+ entry->calling++;
+ keep = entry->listener->ike_updown(entry->listener, ike_sa, up);
+ entry->calling--;
+ if (!keep)
+ {
+ unregister_listener(this, entry, enumerator);
+ }
+ }
+ enumerator->destroy(enumerator);
+ this->mutex->unlock(this->mutex);
+}
+
+/**
* Implementation of bus_t.ike_rekey
*/
static void ike_rekey(private_bus_t *this, ike_sa_t *old, ike_sa_t *new)
@@ -673,6 +702,7 @@ bus_t *bus_create()
this->public.message = (void(*)(bus_t*, message_t *message, bool incoming))message;
this->public.ike_keys = (void(*)(bus_t*, ike_sa_t *ike_sa, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey))ike_keys;
this->public.child_keys = (void(*)(bus_t*, child_sa_t *child_sa, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r))child_keys;
+ this->public.ike_updown = (void(*)(bus_t*, ike_sa_t *ike_sa, bool up))ike_updown;
this->public.ike_rekey = (void(*)(bus_t*, ike_sa_t *old, ike_sa_t *new))ike_rekey;
this->public.child_updown = (void(*)(bus_t*, child_sa_t *child_sa, bool up))child_updown;
this->public.child_rekey = (void(*)(bus_t*, child_sa_t *old, child_sa_t *new))child_rekey;
diff --git a/src/charon/bus/bus.h b/src/charon/bus/bus.h
index 53437f9a0..67603bf21 100644
--- a/src/charon/bus/bus.h
+++ b/src/charon/bus/bus.h
@@ -262,6 +262,14 @@ struct bus_t {
chunk_t nonce_i, chunk_t nonce_r);
/**
+ * IKE_SA up/down hook.
+ *
+ * @param ike_sa IKE_SA coming up/going down
+ * @param up TRUE for an up event, FALSE for a down event
+ */
+ void (*ike_updown)(bus_t *this, ike_sa_t *ike_sa, bool up);
+
+ /**
* IKE_SA rekeying hook.
*
* @param old rekeyed and obsolete IKE_SA
diff --git a/src/charon/sa/tasks/ike_auth.c b/src/charon/sa/tasks/ike_auth.c
index 8d6cd56bd..d0b2a7e91 100644
--- a/src/charon/sa/tasks/ike_auth.c
+++ b/src/charon/sa/tasks/ike_auth.c
@@ -738,6 +738,7 @@ static status_t build_r(private_ike_auth_t *this, message_t *message)
this->ike_sa->get_my_id(this->ike_sa),
this->ike_sa->get_other_host(this->ike_sa),
this->ike_sa->get_other_id(this->ike_sa));
+ charon->bus->ike_updown(charon->bus, this->ike_sa, TRUE);
return SUCCESS;
}
return NEED_MORE;
@@ -916,6 +917,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
this->ike_sa->get_my_id(this->ike_sa),
this->ike_sa->get_other_host(this->ike_sa),
this->ike_sa->get_other_id(this->ike_sa));
+ charon->bus->ike_updown(charon->bus, this->ike_sa, TRUE);
return SUCCESS;
}
return NEED_MORE;