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.
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
*/
.authorize = _authorize,
.narrow = _narrow,
.assign_vips = _assign_vips,
+ .handle_vips = _handle_vips,
.destroy = _destroy,
},
.listeners = linked_list_create(),
*/
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.
*/
*/
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_ @}*/
}
/* remove attributes first, as we pass the IKE_SA to the handler */
+ charon->bus->handle_vips(charon->bus, &this->public, FALSE);
while (array_remove(this->attributes, ARRAY_TAIL, &entry))
{
if (entry.handler)
}
}
enumerator->destroy(enumerator);
+
+ charon->bus->handle_vips(charon->bus, this->ike_sa, TRUE);
}
METHOD(task_t, process_r, status_t,
}
}
enumerator->destroy(enumerator);
+
+ charon->bus->handle_vips(charon->bus, this->ike_sa, TRUE);
return SUCCESS;
}
return NEED_MORE;