implemented ike_rekey()/child_rekey() bus hooks
This commit is contained in:
@@ -513,6 +513,67 @@ static void child_keys(private_bus_t *this, child_sa_t *child_sa,
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of bus_t.ike_rekey
|
||||
*/
|
||||
static void ike_rekey(private_bus_t *this, ike_sa_t *old, ike_sa_t *new)
|
||||
{
|
||||
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->ike_rekey)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entry->calling++;
|
||||
keep = entry->listener->ike_rekey(entry->listener, old, new);
|
||||
entry->calling--;
|
||||
if (!keep)
|
||||
{
|
||||
unregister_listener(this, entry, enumerator);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of bus_t.child_rekey
|
||||
*/
|
||||
static void child_rekey(private_bus_t *this, child_sa_t *old, child_sa_t *new)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
ike_sa_t *ike_sa;
|
||||
entry_t *entry;
|
||||
bool keep;
|
||||
|
||||
ike_sa = pthread_getspecific(this->thread_sa);
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (entry->calling || !entry->listener->child_rekey)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entry->calling++;
|
||||
keep = entry->listener->child_rekey(entry->listener, ike_sa, old, new);
|
||||
entry->calling--;
|
||||
if (!keep)
|
||||
{
|
||||
unregister_listener(this, entry, enumerator);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of bus_t.authorize
|
||||
*/
|
||||
@@ -579,6 +640,8 @@ bus_t *bus_create()
|
||||
this->public.message = (void(*)(bus_t*, message_t *message, bool incoming))message;
|
||||
this->public.ike_keys = (void(*)(bus_t*, ike_sa_t *ike_sa, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey))ike_keys;
|
||||
this->public.child_keys = (void(*)(bus_t*, child_sa_t *child_sa, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r))child_keys;
|
||||
this->public.ike_rekey = (void(*)(bus_t*, ike_sa_t *old, ike_sa_t *new))ike_rekey;
|
||||
this->public.child_rekey = (void(*)(bus_t*, child_sa_t *old, child_sa_t *new))child_rekey;
|
||||
this->public.authorize = (bool(*)(bus_t*, linked_list_t *auth, bool final))authorize;
|
||||
this->public.destroy = (void(*)(bus_t*)) destroy;
|
||||
|
||||
|
||||
@@ -260,6 +260,23 @@ struct bus_t {
|
||||
*/
|
||||
void (*child_keys)(bus_t *this, child_sa_t *child_sa, diffie_hellman_t *dh,
|
||||
chunk_t nonce_i, chunk_t nonce_r);
|
||||
|
||||
/**
|
||||
* IKE_SA rekeying hook.
|
||||
*
|
||||
* @param old rekeyed and obsolete IKE_SA
|
||||
* @param new new IKE_SA replacing old
|
||||
*/
|
||||
void (*ike_rekey)(bus_t *this, ike_sa_t *old, ike_sa_t *new);
|
||||
|
||||
/**
|
||||
* CHILD_SA rekeying hook.
|
||||
*
|
||||
* @param old rekeyed and obsolete CHILD_SA
|
||||
* @param new new CHILD_SA replacing old
|
||||
*/
|
||||
void (*child_rekey)(bus_t *this, child_sa_t *old, child_sa_t *new);
|
||||
|
||||
/**
|
||||
* Destroy the event bus.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user