emit a single assig_vips bus message for all VIPs

This commit is contained in:
Andreas Steffen
2013-04-06 14:16:30 +02:00
parent ba2880d569
commit 12fa1784d0
8 changed files with 57 additions and 62 deletions
+5 -6
View File
@@ -759,8 +759,8 @@ 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)
METHOD(bus_t, assign_vips, void,
private_bus_t *this, ike_sa_t *ike_sa, bool assign)
{
enumerator_t *enumerator;
entry_t *entry;
@@ -770,13 +770,12 @@ METHOD(bus_t, assign_vip, void,
enumerator = this->listeners->create_enumerator(this->listeners);
while (enumerator->enumerate(enumerator, &entry))
{
if (entry->calling || !entry->listener->assign_vip)
if (entry->calling || !entry->listener->assign_vips)
{
continue;
}
entry->calling++;
keep = entry->listener->assign_vip(entry->listener, ike_sa,
vip, assign);
keep = entry->listener->assign_vips(entry->listener, ike_sa, assign);
entry->calling--;
if (!keep)
{
@@ -835,7 +834,7 @@ bus_t *bus_create()
.child_rekey = _child_rekey,
.authorize = _authorize,
.narrow = _narrow,
.assign_vip = _assign_vip,
.assign_vips = _assign_vips,
.destroy = _destroy,
},
.listeners = linked_list_create(),
+2 -3
View File
@@ -388,11 +388,10 @@ struct bus_t {
/**
* Virtual IP assignment hook.
*
* @param ike_sa IKE_SA the VIP is assigned to
* @param vip Virtual IPv4 or IV6 address
* @param ike_sa IKE_SA the VIPs are assigned to
* @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);
void (*assign_vips)(bus_t *this, ike_sa_t *ike_sa, bool assign);
/**
* Destroy the event bus.
+2 -4
View File
@@ -197,13 +197,11 @@ struct listener_t {
* 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 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_vip)(listener_t *this, ike_sa_t *ike_sa, host_t *vip,
bool assign);
bool (*assign_vips)(listener_t *this, ike_sa_t *ike_sa, bool assign);
};