Listen to ike_updown/rekey hook instead of ike_state_change

This commit is contained in:
Martin Willi
2010-04-07 13:55:16 +02:00
committed by Martin Willi
parent c866a42737
commit f24ca1dd55
+16 -13
View File
@@ -125,10 +125,9 @@ static bool ike_keys(private_ha_ike_t *this, ike_sa_t *ike_sa,
} }
/** /**
* Implementation of listener_t.ike_state_change * Implementation of listener_t.ike_updown
*/ */
static bool ike_state_change(private_ha_ike_t *this, ike_sa_t *ike_sa, static bool ike_updown(private_ha_ike_t *this, ike_sa_t *ike_sa, bool up)
ike_sa_state_t state)
{ {
ha_message_t *m; ha_message_t *m;
@@ -141,9 +140,7 @@ static bool ike_state_change(private_ha_ike_t *this, ike_sa_t *ike_sa,
return TRUE; return TRUE;
} }
switch (state) if (up)
{
case IKE_ESTABLISHED:
{ {
iterator_t *iterator; iterator_t *iterator;
peer_cfg_t *peer_cfg; peer_cfg_t *peer_cfg;
@@ -188,21 +185,26 @@ static bool ike_state_change(private_ha_ike_t *this, ike_sa_t *ike_sa,
m->add_attribute(m, HA_ADDITIONAL_ADDR, addr); m->add_attribute(m, HA_ADDITIONAL_ADDR, addr);
} }
iterator->destroy(iterator); iterator->destroy(iterator);
break;
} }
case IKE_DESTROYING: else
{ {
m = ha_message_create(HA_IKE_DELETE); m = ha_message_create(HA_IKE_DELETE);
m->add_attribute(m, HA_IKE_ID, ike_sa->get_id(ike_sa)); m->add_attribute(m, HA_IKE_ID, ike_sa->get_id(ike_sa));
break;
}
default:
return TRUE;
} }
this->socket->push(this->socket, m); this->socket->push(this->socket, m);
return TRUE; return TRUE;
} }
/**
* Implementation of listener_t.ike_rekey
*/
static bool ike_rekey(private_ha_ike_t *this, ike_sa_t *old, ike_sa_t *new)
{
ike_updown(this, old, FALSE);
ike_updown(this, new, TRUE);
return TRUE;
}
/** /**
* Implementation of listener_t.message * Implementation of listener_t.message
*/ */
@@ -271,7 +273,8 @@ ha_ike_t *ha_ike_create(ha_socket_t *socket, ha_tunnel_t *tunnel)
memset(&this->public.listener, 0, sizeof(listener_t)); memset(&this->public.listener, 0, sizeof(listener_t));
this->public.listener.ike_keys = (bool(*)(listener_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.listener.ike_keys = (bool(*)(listener_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.listener.ike_state_change = (bool(*)(listener_t*,ike_sa_t *ike_sa, ike_sa_state_t state))ike_state_change; this->public.listener.ike_updown = (bool(*)(listener_t*,ike_sa_t *ike_sa, bool up))ike_updown;
this->public.listener.ike_rekey = (bool(*)(listener_t*,ike_sa_t *old, ike_sa_t *new))ike_rekey;
this->public.listener.message = (bool(*)(listener_t*, ike_sa_t *, message_t *,bool))message_hook; this->public.listener.message = (bool(*)(listener_t*, ike_sa_t *, message_t *,bool))message_hook;
this->public.destroy = (void(*)(ha_ike_t*))destroy; this->public.destroy = (void(*)(ha_ike_t*))destroy;