diff options
author | Martin Willi <martin@revosec.ch> | 2014-02-11 10:09:08 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2014-06-17 15:14:51 +0200 |
commit | eef7427b0fe9de11d6cf877aea267692426ee35b (patch) | |
tree | a0119e8834ab21bfa62f68cfd03ca9bee99239f3 /src/libcharon/bus | |
parent | 7fc98a840b0f6fe0abace9b28db85234ca84b5ec (diff) | |
download | strongswan-eef7427b0fe9de11d6cf877aea267692426ee35b.tar.bz2 strongswan-eef7427b0fe9de11d6cf877aea267692426ee35b.tar.xz |
bus: Add a handle_vips() hook invoked after handling configuration attributes
Similar to assign_vips() used by a peer assigning virtual IPs to the other peer,
the handle_vips() hook gets invoked on a peers after receiving attributes. On
release of the same attributes the hook gets invoked again.
This is useful to inspect handled attributes, as the ike_updown() hook is
invoked after authentication, when attributes have not been handled yet.
Diffstat (limited to 'src/libcharon/bus')
-rw-r--r-- | src/libcharon/bus/bus.c | 28 | ||||
-rw-r--r-- | src/libcharon/bus/bus.h | 8 | ||||
-rw-r--r-- | src/libcharon/bus/listeners/listener.h | 12 |
3 files changed, 48 insertions, 0 deletions
diff --git a/src/libcharon/bus/bus.c b/src/libcharon/bus/bus.c index bc080d1c0..d467c3320 100644 --- a/src/libcharon/bus/bus.c +++ b/src/libcharon/bus/bus.c @@ -879,6 +879,33 @@ METHOD(bus_t, assign_vips, void, this->mutex->unlock(this->mutex); } +METHOD(bus_t, handle_vips, void, + private_bus_t *this, ike_sa_t *ike_sa, bool handle) +{ + 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->handle_vips) + { + continue; + } + entry->calling++; + keep = entry->listener->handle_vips(entry->listener, ike_sa, handle); + entry->calling--; + if (!keep) + { + unregister_listener(this, entry, enumerator); + } + } + enumerator->destroy(enumerator); + this->mutex->unlock(this->mutex); +} + /** * Credential manager hook function to forward bus alerts */ @@ -955,6 +982,7 @@ bus_t *bus_create() .authorize = _authorize, .narrow = _narrow, .assign_vips = _assign_vips, + .handle_vips = _handle_vips, .destroy = _destroy, }, .listeners = linked_list_create(), diff --git a/src/libcharon/bus/bus.h b/src/libcharon/bus/bus.h index 4a0ac68e3..1d708c5a5 100644 --- a/src/libcharon/bus/bus.h +++ b/src/libcharon/bus/bus.h @@ -412,6 +412,14 @@ struct bus_t { void (*assign_vips)(bus_t *this, ike_sa_t *ike_sa, bool assign); /** + * Virtual IP handler hook. + * + * @param ike_sa IKE_SA the VIPs/attributes got handled on + * @param assign TRUE after installing attributes, FALSE on release + */ + void (*handle_vips)(bus_t *this, ike_sa_t *ike_sa, bool handle); + + /** * Destroy the event bus. */ void (*destroy) (bus_t *this); diff --git a/src/libcharon/bus/listeners/listener.h b/src/libcharon/bus/listeners/listener.h index 9eee72264..abcc765e5 100644 --- a/src/libcharon/bus/listeners/listener.h +++ b/src/libcharon/bus/listeners/listener.h @@ -203,6 +203,18 @@ struct listener_t { */ bool (*assign_vips)(listener_t *this, ike_sa_t *ike_sa, bool assign); + /** + * Virtual IP and configuration attribute handler hook. + * + * This hook gets invoked after virtual IP and other configuration + * attributes just got installed or are about to get uninstalled on a peer + * receiving them. + * + * @param ike_sa IKE_SA the VIPs/attributes are handled on + * @param handle TRUE if handled by IKE_SA, FALSE on release + * @return TRUE to stay registered, FALSE to unregister + */ + bool (*handle_vips)(listener_t *this, ike_sa_t *ike_sa, bool handle); }; #endif /** LISTENER_H_ @}*/ |