diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2013-04-30 17:51:33 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2013-04-30 17:51:33 +0200 |
commit | c83921a2b566aa9d55d8ccc7258f04fca6292ee6 (patch) | |
tree | 44039788fc816c84d5788df847d1555413ebe55a /src/libcharon/bus | |
parent | 10e5fb2b9b2f27c83b3e5a1d048b158d5cf42a43 (diff) | |
download | vyos-strongswan-c83921a2b566aa9d55d8ccc7258f04fca6292ee6.tar.gz vyos-strongswan-c83921a2b566aa9d55d8ccc7258f04fca6292ee6.zip |
Imported Upstream version 5.0.4
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 | 13 |
3 files changed, 49 insertions, 0 deletions
diff --git a/src/libcharon/bus/bus.c b/src/libcharon/bus/bus.c index b5cdaaa89..0db5a8a9c 100644 --- a/src/libcharon/bus/bus.c +++ b/src/libcharon/bus/bus.c @@ -759,6 +759,33 @@ METHOD(bus_t, narrow, void, this->mutex->unlock(this->mutex); } +METHOD(bus_t, assign_vips, void, + private_bus_t *this, ike_sa_t *ike_sa, bool assign) +{ + 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->assign_vips) + { + continue; + } + entry->calling++; + keep = entry->listener->assign_vips(entry->listener, ike_sa, assign); + entry->calling--; + if (!keep) + { + unregister_listener(this, entry, enumerator); + } + } + enumerator->destroy(enumerator); + this->mutex->unlock(this->mutex); +} + METHOD(bus_t, destroy, void, private_bus_t *this) { @@ -807,6 +834,7 @@ bus_t *bus_create() .child_rekey = _child_rekey, .authorize = _authorize, .narrow = _narrow, + .assign_vips = _assign_vips, .destroy = _destroy, }, .listeners = linked_list_create(), diff --git a/src/libcharon/bus/bus.h b/src/libcharon/bus/bus.h index 18d57bce1..75244d6bf 100644 --- a/src/libcharon/bus/bus.h +++ b/src/libcharon/bus/bus.h @@ -386,6 +386,14 @@ struct bus_t { void (*child_rekey)(bus_t *this, child_sa_t *old, child_sa_t *new); /** + * Virtual IP assignment hook. + * + * @param ike_sa IKE_SA the VIPs are assigned to + * @param assign TRUE if assigned to IKE_SA, FALSE if released + */ + void (*assign_vips)(bus_t *this, ike_sa_t *ike_sa, bool assign); + + /** * 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 782289302..ef4daced2 100644 --- a/src/libcharon/bus/listeners/listener.h +++ b/src/libcharon/bus/listeners/listener.h @@ -190,6 +190,19 @@ struct listener_t { */ bool (*narrow)(listener_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa, narrow_hook_t type, linked_list_t *local, linked_list_t *remote); + + /** + * Virtual IP address assignment hook + * + * This hook gets invoked when a a Virtual IP address is assigned to an + * IKE_SA (assign = TRUE) and again when it is released (assign = FALSE) + * + * @param ike_sa IKE_SA the VIPs are assigned to + * @param assign TRUE if assigned to IKE_SA, FALSE if released + * @return TRUE to stay registered, FALSE to unregister + */ + bool (*assign_vips)(listener_t *this, ike_sa_t *ike_sa, bool assign); + }; #endif /** LISTENER_H_ @}*/ |