added a "purgeike" command to stroke, deleting all IKE_SAs without a CHILD_SA
This commit is contained in:
@@ -357,6 +357,46 @@ static void terminate_srcip(private_stroke_control_t *this,
|
||||
DESTROY_IF(end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of stroke_control_t.purge_ike
|
||||
*/
|
||||
static void purge_ike(private_stroke_control_t *this, stroke_msg_t *msg, FILE *out)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
iterator_t *iterator;
|
||||
ike_sa_t *ike_sa;
|
||||
child_sa_t *child_sa;
|
||||
linked_list_t *list;
|
||||
uintptr_t del;
|
||||
stroke_log_info_t info;
|
||||
|
||||
info.out = out;
|
||||
info.level = msg->output_verbosity;
|
||||
|
||||
list = linked_list_create();
|
||||
enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
|
||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||
{
|
||||
iterator = ike_sa->create_child_sa_iterator(ike_sa);
|
||||
if (!iterator->iterate(iterator, (void**)&child_sa))
|
||||
{
|
||||
list->insert_last(list,
|
||||
(void*)(uintptr_t)ike_sa->get_unique_id(ike_sa));
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
enumerator = list->create_enumerator(list);
|
||||
while (enumerator->enumerate(enumerator, &del))
|
||||
{
|
||||
charon->controller->terminate_ike(charon->controller, del,
|
||||
(controller_cb_t)stroke_log, &info);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
list->destroy(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of stroke_control_t.route.
|
||||
*/
|
||||
@@ -441,6 +481,7 @@ stroke_control_t *stroke_control_create()
|
||||
this->public.initiate = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))initiate;
|
||||
this->public.terminate = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))terminate;
|
||||
this->public.terminate_srcip = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))terminate_srcip;
|
||||
this->public.purge_ike = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))purge_ike;
|
||||
this->public.route = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))route;
|
||||
this->public.unroute = (void(*)(stroke_control_t*, stroke_msg_t *msg, FILE *out))unroute;
|
||||
this->public.destroy = (void(*)(stroke_control_t*))destroy;
|
||||
|
||||
@@ -53,6 +53,13 @@ struct stroke_control_t {
|
||||
*/
|
||||
void (*terminate_srcip)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
|
||||
|
||||
/**
|
||||
* Delete IKE_SAs without a CHILD_SA.
|
||||
*
|
||||
* @param msg stroke message
|
||||
*/
|
||||
void (*purge_ike)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
|
||||
|
||||
/**
|
||||
* Route a connection.
|
||||
*
|
||||
@@ -68,9 +75,9 @@ struct stroke_control_t {
|
||||
void (*unroute)(stroke_control_t *this, stroke_msg_t *msg, FILE *out);
|
||||
|
||||
/**
|
||||
* Destroy a stroke_control instance.
|
||||
*/
|
||||
void (*destroy)(stroke_control_t *this);
|
||||
* Destroy a stroke_control instance.
|
||||
*/
|
||||
void (*destroy)(stroke_control_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -341,8 +341,15 @@ static void stroke_reread(private_stroke_socket_t *this,
|
||||
static void stroke_purge(private_stroke_socket_t *this,
|
||||
stroke_msg_t *msg, FILE *out)
|
||||
{
|
||||
charon->credentials->flush_cache(charon->credentials,
|
||||
CERT_X509_OCSP_RESPONSE);
|
||||
if (msg->purge.flags & PURGE_OCSP)
|
||||
{
|
||||
charon->credentials->flush_cache(charon->credentials,
|
||||
CERT_X509_OCSP_RESPONSE);
|
||||
}
|
||||
if (msg->purge.flags & PURGE_IKE)
|
||||
{
|
||||
this->control->purge_ike(this->control, msg, out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user