implemented ike_up() bus hook
This commit is contained in:
@@ -513,6 +513,35 @@ static void child_keys(private_bus_t *this, child_sa_t *child_sa,
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of bus_t.ike_updown
|
||||
*/
|
||||
static void ike_updown(private_bus_t *this, ike_sa_t *ike_sa, bool up)
|
||||
{
|
||||
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_updown)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entry->calling++;
|
||||
keep = entry->listener->ike_updown(entry->listener, ike_sa, up);
|
||||
entry->calling--;
|
||||
if (!keep)
|
||||
{
|
||||
unregister_listener(this, entry, enumerator);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of bus_t.ike_rekey
|
||||
*/
|
||||
@@ -673,6 +702,7 @@ 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_updown = (void(*)(bus_t*, ike_sa_t *ike_sa, bool up))ike_updown;
|
||||
this->public.ike_rekey = (void(*)(bus_t*, ike_sa_t *old, ike_sa_t *new))ike_rekey;
|
||||
this->public.child_updown = (void(*)(bus_t*, child_sa_t *child_sa, bool up))child_updown;
|
||||
this->public.child_rekey = (void(*)(bus_t*, child_sa_t *old, child_sa_t *new))child_rekey;
|
||||
|
||||
@@ -261,6 +261,14 @@ 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 up/down hook.
|
||||
*
|
||||
* @param ike_sa IKE_SA coming up/going down
|
||||
* @param up TRUE for an up event, FALSE for a down event
|
||||
*/
|
||||
void (*ike_updown)(bus_t *this, ike_sa_t *ike_sa, bool up);
|
||||
|
||||
/**
|
||||
* IKE_SA rekeying hook.
|
||||
*
|
||||
|
||||
@@ -738,6 +738,7 @@ static status_t build_r(private_ike_auth_t *this, message_t *message)
|
||||
this->ike_sa->get_my_id(this->ike_sa),
|
||||
this->ike_sa->get_other_host(this->ike_sa),
|
||||
this->ike_sa->get_other_id(this->ike_sa));
|
||||
charon->bus->ike_updown(charon->bus, this->ike_sa, TRUE);
|
||||
return SUCCESS;
|
||||
}
|
||||
return NEED_MORE;
|
||||
@@ -916,6 +917,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
|
||||
this->ike_sa->get_my_id(this->ike_sa),
|
||||
this->ike_sa->get_other_host(this->ike_sa),
|
||||
this->ike_sa->get_other_id(this->ike_sa));
|
||||
charon->bus->ike_updown(charon->bus, this->ike_sa, TRUE);
|
||||
return SUCCESS;
|
||||
}
|
||||
return NEED_MORE;
|
||||
|
||||
Reference in New Issue
Block a user