ifmap plugin subscribes to assing_vip bus signal
This commit is contained in:
@@ -759,6 +759,34 @@ METHOD(bus_t, narrow, void,
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
|
||||
METHOD(bus_t, assign_vip, void,
|
||||
private_bus_t *this, ike_sa_t *ike_sa, host_t *vip, 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_vip)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entry->calling++;
|
||||
keep = entry->listener->assign_vip(entry->listener, ike_sa,
|
||||
vip, 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 +835,7 @@ bus_t *bus_create()
|
||||
.child_rekey = _child_rekey,
|
||||
.authorize = _authorize,
|
||||
.narrow = _narrow,
|
||||
.assign_vip = _assign_vip,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.listeners = linked_list_create(),
|
||||
|
||||
@@ -385,6 +385,15 @@ 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 VIP is assigned to
|
||||
* @param vip Virtual IPv4 or IV6 address
|
||||
* @param assign TRUE if assigned to IKE_SA, FALSE if released
|
||||
*/
|
||||
void (*assign_vip)(bus_t *this, ike_sa_t *ike_sa, host_t *vip, bool assign);
|
||||
|
||||
/**
|
||||
* Destroy the event bus.
|
||||
*/
|
||||
|
||||
@@ -190,6 +190,21 @@ 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 VIP is assigned to
|
||||
* @param vip Virtual IPv4 or IV6 address
|
||||
* @param assign TRUE if assigned to IKE_SA, FALSE if released
|
||||
* @return TRUE to stay registered, FALSE to unregister
|
||||
*/
|
||||
bool (*assign_vip)(listener_t *this, ike_sa_t *ike_sa, host_t *vip,
|
||||
bool assign);
|
||||
|
||||
};
|
||||
|
||||
#endif /** LISTENER_H_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user