Replaced ike_sa_t.create_child_sa_iterator with enumerator.
This required two new methods on ike_sa_t. One returns the number of CHILD_SAs and one allows to remove a CHILD_SA.
This commit is contained in:
@@ -114,8 +114,7 @@ static job_requeue_t rekey_ike(char *config)
|
|||||||
*/
|
*/
|
||||||
static job_requeue_t rekey_child(char *config)
|
static job_requeue_t rekey_child(char *config)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator, *children;
|
||||||
iterator_t *children;
|
|
||||||
ike_sa_t *ike_sa;
|
ike_sa_t *ike_sa;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
u_int32_t reqid = 0, spi = 0;
|
u_int32_t reqid = 0, spi = 0;
|
||||||
@@ -125,8 +124,8 @@ static job_requeue_t rekey_child(char *config)
|
|||||||
charon->controller, TRUE);
|
charon->controller, TRUE);
|
||||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||||
{
|
{
|
||||||
children = ike_sa->create_child_sa_iterator(ike_sa);
|
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (streq(config, child_sa->get_name(child_sa)))
|
if (streq(config, child_sa->get_name(child_sa)))
|
||||||
{
|
{
|
||||||
@@ -222,8 +221,7 @@ static job_requeue_t close_ike(char *config)
|
|||||||
*/
|
*/
|
||||||
static job_requeue_t close_child(char *config)
|
static job_requeue_t close_child(char *config)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator, *children;
|
||||||
iterator_t *children;
|
|
||||||
ike_sa_t *ike_sa;
|
ike_sa_t *ike_sa;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
@@ -233,8 +231,8 @@ static job_requeue_t close_child(char *config)
|
|||||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||||
{
|
{
|
||||||
|
|
||||||
children = ike_sa->create_child_sa_iterator(ike_sa);
|
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (streq(config, child_sa->get_name(child_sa)))
|
if (streq(config, child_sa->get_name(child_sa)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -564,15 +564,15 @@ METHOD(bus_t, ike_updown, void,
|
|||||||
/* a down event for IKE_SA implicitly downs all CHILD_SAs */
|
/* a down event for IKE_SA implicitly downs all CHILD_SAs */
|
||||||
if (!up)
|
if (!up)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
|
|
||||||
iterator = ike_sa->create_child_sa_iterator(ike_sa);
|
enumerator = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
child_updown(this, child_sa, FALSE);
|
child_updown(this, child_sa, FALSE);
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ METHOD(controller_t, terminate_child, status_t,
|
|||||||
{
|
{
|
||||||
ike_sa_t *ike_sa;
|
ike_sa_t *ike_sa;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
interface_job_t job = {
|
interface_job_t job = {
|
||||||
.listener = {
|
.listener = {
|
||||||
.public = {
|
.public = {
|
||||||
@@ -397,8 +397,8 @@ METHOD(controller_t, terminate_child, status_t,
|
|||||||
}
|
}
|
||||||
job.listener.ike_sa = ike_sa;
|
job.listener.ike_sa = ike_sa;
|
||||||
|
|
||||||
iterator = ike_sa->create_child_sa_iterator(ike_sa);
|
enumerator = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (child_sa->get_state(child_sa) != CHILD_ROUTED &&
|
if (child_sa->get_state(child_sa) != CHILD_ROUTED &&
|
||||||
child_sa->get_reqid(child_sa) == reqid)
|
child_sa->get_reqid(child_sa) == reqid)
|
||||||
@@ -407,7 +407,7 @@ METHOD(controller_t, terminate_child, status_t,
|
|||||||
}
|
}
|
||||||
child_sa = NULL;
|
child_sa = NULL;
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
if (child_sa == NULL)
|
if (child_sa == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -196,12 +196,12 @@ METHOD(ha_cache_t, delete_, void,
|
|||||||
*/
|
*/
|
||||||
static status_t rekey_children(ike_sa_t *ike_sa)
|
static status_t rekey_children(ike_sa_t *ike_sa)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
status_t status = SUCCESS;
|
status_t status = SUCCESS;
|
||||||
|
|
||||||
iterator = ike_sa->create_child_sa_iterator(ike_sa);
|
enumerator = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
DBG1(DBG_CFG, "resyncing CHILD_SA");
|
DBG1(DBG_CFG, "resyncing CHILD_SA");
|
||||||
status = ike_sa->rekey_child_sa(ike_sa, child_sa->get_protocol(child_sa),
|
status = ike_sa->rekey_child_sa(ike_sa, child_sa->get_protocol(child_sa),
|
||||||
@@ -211,7 +211,7 @@ static status_t rekey_children(ike_sa_t *ike_sa)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
|
|||||||
{
|
{
|
||||||
ike_sa_id_t *id;
|
ike_sa_id_t *id;
|
||||||
host_t *local, *remote;
|
host_t *local, *remote;
|
||||||
iterator_t *children;
|
enumerator_t *children;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
|
|
||||||
id = ike_sa->get_id(ike_sa);
|
id = ike_sa->get_id(ike_sa);
|
||||||
@@ -264,8 +264,8 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
|
|||||||
|
|
||||||
/* <childsalist> */
|
/* <childsalist> */
|
||||||
xmlTextWriterStartElement(writer, "childsalist");
|
xmlTextWriterStartElement(writer, "childsalist");
|
||||||
children = ike_sa->create_child_sa_iterator(ike_sa);
|
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
write_child(writer, child_sa);
|
write_child(writer, child_sa);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,12 +294,12 @@ METHOD(stroke_control_t, terminate, void,
|
|||||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||||
{
|
{
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
iterator_t *children;
|
enumerator_t *children;
|
||||||
|
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
children = ike_sa->create_child_sa_iterator(ike_sa);
|
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (streq(name, child_sa->get_name(child_sa)))
|
if (streq(name, child_sa->get_name(child_sa)))
|
||||||
{
|
{
|
||||||
@@ -374,12 +374,12 @@ METHOD(stroke_control_t, rekey, void,
|
|||||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||||
{
|
{
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
iterator_t *children;
|
enumerator_t *children;
|
||||||
|
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
children = ike_sa->create_child_sa_iterator(ike_sa);
|
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if ((name && streq(name, child_sa->get_name(child_sa))) ||
|
if ((name && streq(name, child_sa->get_name(child_sa))) ||
|
||||||
(id && id == child_sa->get_reqid(child_sa)))
|
(id && id == child_sa->get_reqid(child_sa)))
|
||||||
@@ -486,8 +486,7 @@ METHOD(stroke_control_t, terminate_srcip, void,
|
|||||||
METHOD(stroke_control_t, purge_ike, void,
|
METHOD(stroke_control_t, purge_ike, void,
|
||||||
private_stroke_control_t *this, stroke_msg_t *msg, FILE *out)
|
private_stroke_control_t *this, stroke_msg_t *msg, FILE *out)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator, *children;
|
||||||
iterator_t *iterator;
|
|
||||||
ike_sa_t *ike_sa;
|
ike_sa_t *ike_sa;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
linked_list_t *list;
|
linked_list_t *list;
|
||||||
@@ -502,13 +501,13 @@ METHOD(stroke_control_t, purge_ike, void,
|
|||||||
charon->controller, TRUE);
|
charon->controller, TRUE);
|
||||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||||
{
|
{
|
||||||
iterator = ike_sa->create_child_sa_iterator(ike_sa);
|
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
if (!iterator->iterate(iterator, (void**)&child_sa))
|
if (!children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
list->insert_last(list,
|
list->insert_last(list,
|
||||||
(void*)(uintptr_t)ike_sa->get_unique_id(ike_sa));
|
(void*)(uintptr_t)ike_sa->get_unique_id(ike_sa));
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
children->destroy(children);
|
||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ METHOD(stroke_list_t, status, void,
|
|||||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||||
{
|
{
|
||||||
bool ike_printed = FALSE;
|
bool ike_printed = FALSE;
|
||||||
iterator_t *children = ike_sa->create_child_sa_iterator(ike_sa);
|
enumerator_t *children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
|
|
||||||
if (name == NULL || streq(name, ike_sa->get_name(ike_sa)))
|
if (name == NULL || streq(name, ike_sa->get_name(ike_sa)))
|
||||||
{
|
{
|
||||||
@@ -585,7 +585,7 @@ METHOD(stroke_list_t, status, void,
|
|||||||
ike_printed = TRUE;
|
ike_printed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (name == NULL || streq(name, child_sa->get_name(child_sa)))
|
if (name == NULL || streq(name, child_sa->get_name(child_sa)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ static void write_fifo(private_uci_control_t *this, char *format, ...)
|
|||||||
*/
|
*/
|
||||||
static void status(private_uci_control_t *this, char *name)
|
static void status(private_uci_control_t *this, char *name)
|
||||||
{
|
{
|
||||||
enumerator_t *configs, *sas;
|
enumerator_t *configs, *sas, *children;
|
||||||
iterator_t *children;
|
|
||||||
ike_sa_t *ike_sa;
|
ike_sa_t *ike_sa;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
@@ -111,8 +110,8 @@ static void status(private_uci_control_t *this, char *name)
|
|||||||
fprintf(out, "%-8s %-20D %-16H ", ike_sa->get_name(ike_sa),
|
fprintf(out, "%-8s %-20D %-16H ", ike_sa->get_name(ike_sa),
|
||||||
ike_sa->get_other_id(ike_sa), ike_sa->get_other_host(ike_sa));
|
ike_sa->get_other_id(ike_sa), ike_sa->get_other_host(ike_sa));
|
||||||
|
|
||||||
children = ike_sa->create_child_sa_iterator(ike_sa);
|
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
fprintf(out, "%#R",
|
fprintf(out, "%#R",
|
||||||
child_sa->get_traffic_selectors(child_sa, FALSE));
|
child_sa->get_traffic_selectors(child_sa, FALSE));
|
||||||
|
|||||||
@@ -61,15 +61,15 @@ METHOD(job_t, execute, void,
|
|||||||
this->reqid, TRUE);
|
this->reqid, TRUE);
|
||||||
if (ike_sa)
|
if (ike_sa)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
u_int32_t delete = 0;
|
u_int32_t delete = 0;
|
||||||
protocol_id_t proto = 0;
|
protocol_id_t proto = 0;
|
||||||
int children = 0;
|
int children = 0;
|
||||||
status_t status = SUCCESS;
|
status_t status = SUCCESS;
|
||||||
|
|
||||||
iterator = ike_sa->create_child_sa_iterator(ike_sa);
|
enumerator = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (child_sa->get_reqid(child_sa) == this->reqid)
|
if (child_sa->get_reqid(child_sa) == this->reqid)
|
||||||
{
|
{
|
||||||
@@ -94,7 +94,7 @@ METHOD(job_t, execute, void,
|
|||||||
}
|
}
|
||||||
children++;
|
children++;
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,12 +79,12 @@ METHOD(job_t, execute, void,
|
|||||||
}
|
}
|
||||||
if (ike_sa)
|
if (ike_sa)
|
||||||
{
|
{
|
||||||
iterator_t *children;
|
enumerator_t *children;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
host_t *host;
|
host_t *host;
|
||||||
|
|
||||||
children = ike_sa->create_child_sa_iterator(ike_sa);
|
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (child_sa->get_reqid(child_sa) == this->reqid)
|
if (child_sa->get_reqid(child_sa) == this->reqid)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2008 Tobias Brunner
|
* Copyright (C) 2006-2011 Tobias Brunner
|
||||||
* Copyright (C) 2006 Daniel Roethlisberger
|
* Copyright (C) 2006 Daniel Roethlisberger
|
||||||
* Copyright (C) 2005-2009 Martin Willi
|
* Copyright (C) 2005-2009 Martin Willi
|
||||||
* Copyright (C) 2005 Jan Hutter
|
* Copyright (C) 2005 Jan Hutter
|
||||||
@@ -1393,10 +1393,22 @@ METHOD(ike_sa_t, get_child_sa, child_sa_t*,
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(ike_sa_t, create_child_sa_iterator, iterator_t*,
|
METHOD(ike_sa_t, get_child_count, int,
|
||||||
private_ike_sa_t *this)
|
private_ike_sa_t *this)
|
||||||
{
|
{
|
||||||
return this->child_sas->create_iterator(this->child_sas, TRUE);
|
return this->child_sas->get_count(this->child_sas);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(ike_sa_t, create_child_sa_enumerator, enumerator_t*,
|
||||||
|
private_ike_sa_t *this)
|
||||||
|
{
|
||||||
|
return this->child_sas->create_enumerator(this->child_sas);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(ike_sa_t, remove_child_sa, void,
|
||||||
|
private_ike_sa_t *this, enumerator_t *enumerator)
|
||||||
|
{
|
||||||
|
this->child_sas->remove_at(this->child_sas, enumerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(ike_sa_t, rekey_child_sa, status_t,
|
METHOD(ike_sa_t, rekey_child_sa, status_t,
|
||||||
@@ -2113,7 +2125,9 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
|
|||||||
.get_keymat = _get_keymat,
|
.get_keymat = _get_keymat,
|
||||||
.add_child_sa = _add_child_sa,
|
.add_child_sa = _add_child_sa,
|
||||||
.get_child_sa = _get_child_sa,
|
.get_child_sa = _get_child_sa,
|
||||||
.create_child_sa_iterator = _create_child_sa_iterator,
|
.get_child_count = _get_child_count,
|
||||||
|
.create_child_sa_enumerator = _create_child_sa_enumerator,
|
||||||
|
.remove_child_sa = _remove_child_sa,
|
||||||
.rekey_child_sa = _rekey_child_sa,
|
.rekey_child_sa = _rekey_child_sa,
|
||||||
.delete_child_sa = _delete_child_sa,
|
.delete_child_sa = _delete_child_sa,
|
||||||
.destroy_child_sa = _destroy_child_sa,
|
.destroy_child_sa = _destroy_child_sa,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2008 Tobias Brunner
|
* Copyright (C) 2006-2011 Tobias Brunner
|
||||||
* Copyright (C) 2006 Daniel Roethlisberger
|
* Copyright (C) 2006 Daniel Roethlisberger
|
||||||
* Copyright (C) 2005-2009 Martin Willi
|
* Copyright (C) 2005-2009 Martin Willi
|
||||||
* Copyright (C) 2005 Jan Hutter
|
* Copyright (C) 2005 Jan Hutter
|
||||||
@@ -769,11 +769,25 @@ struct ike_sa_t {
|
|||||||
u_int32_t spi, bool inbound);
|
u_int32_t spi, bool inbound);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an iterator over all CHILD_SAs.
|
* Get the number of CHILD_SAs.
|
||||||
*
|
*
|
||||||
* @return iterator
|
* @return number of CHILD_SAs
|
||||||
*/
|
*/
|
||||||
iterator_t* (*create_child_sa_iterator) (ike_sa_t *this);
|
int (*get_child_count) (ike_sa_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an enumerator over all CHILD_SAs.
|
||||||
|
*
|
||||||
|
* @return enumerator
|
||||||
|
*/
|
||||||
|
enumerator_t* (*create_child_sa_enumerator) (ike_sa_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the CHILD_SA the given enumerator points to from this IKE_SA.
|
||||||
|
*
|
||||||
|
* @param enumerator enumerator pointing to CHILD_SA
|
||||||
|
*/
|
||||||
|
void (*remove_child_sa) (ike_sa_t *this, enumerator_t *enumerator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rekey the CHILD SA with the specified reqid.
|
* Rekey the CHILD SA with the specified reqid.
|
||||||
|
|||||||
@@ -1134,8 +1134,7 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
|
|||||||
METHOD(ike_sa_manager_t, checkout_by_id, ike_sa_t*,
|
METHOD(ike_sa_manager_t, checkout_by_id, ike_sa_t*,
|
||||||
private_ike_sa_manager_t *this, u_int32_t id, bool child)
|
private_ike_sa_manager_t *this, u_int32_t id, bool child)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator, *children;
|
||||||
iterator_t *children;
|
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
ike_sa_t *ike_sa = NULL;
|
ike_sa_t *ike_sa = NULL;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
@@ -1151,8 +1150,8 @@ METHOD(ike_sa_manager_t, checkout_by_id, ike_sa_t*,
|
|||||||
/* look for a child with such a reqid ... */
|
/* look for a child with such a reqid ... */
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
children = entry->ike_sa->create_child_sa_iterator(entry->ike_sa);
|
children = entry->ike_sa->create_child_sa_enumerator(entry->ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (child_sa->get_reqid(child_sa) == id)
|
if (child_sa->get_reqid(child_sa) == id)
|
||||||
{
|
{
|
||||||
@@ -1188,8 +1187,7 @@ METHOD(ike_sa_manager_t, checkout_by_id, ike_sa_t*,
|
|||||||
METHOD(ike_sa_manager_t, checkout_by_name, ike_sa_t*,
|
METHOD(ike_sa_manager_t, checkout_by_name, ike_sa_t*,
|
||||||
private_ike_sa_manager_t *this, char *name, bool child)
|
private_ike_sa_manager_t *this, char *name, bool child)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator, *children;
|
||||||
iterator_t *children;
|
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
ike_sa_t *ike_sa = NULL;
|
ike_sa_t *ike_sa = NULL;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
@@ -1203,8 +1201,8 @@ METHOD(ike_sa_manager_t, checkout_by_name, ike_sa_t*,
|
|||||||
/* look for a child with such a policy name ... */
|
/* look for a child with such a policy name ... */
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
children = entry->ike_sa->create_child_sa_iterator(entry->ike_sa);
|
children = entry->ike_sa->create_child_sa_enumerator(entry->ike_sa);
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
while (children->enumerate(children, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (streq(child_sa->get_name(child_sa), name))
|
if (streq(child_sa->get_name(child_sa), name))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -256,11 +256,11 @@ static void build_cookie(private_ike_mobike_t *this, message_t *message)
|
|||||||
*/
|
*/
|
||||||
static void update_children(private_ike_mobike_t *this)
|
static void update_children(private_ike_mobike_t *this)
|
||||||
{
|
{
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
|
|
||||||
iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
|
enumerator = this->ike_sa->create_child_sa_enumerator(this->ike_sa);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
if (child_sa->update(child_sa,
|
if (child_sa->update(child_sa,
|
||||||
this->ike_sa->get_my_host(this->ike_sa),
|
this->ike_sa->get_my_host(this->ike_sa),
|
||||||
@@ -273,7 +273,7 @@ static void update_children(private_ike_mobike_t *this)
|
|||||||
child_sa->get_spi(child_sa, TRUE));
|
child_sa->get_spi(child_sa, TRUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
|||||||
{
|
{
|
||||||
ike_sa_t *new;
|
ike_sa_t *new;
|
||||||
host_t *host;
|
host_t *host;
|
||||||
iterator_t *iterator;
|
enumerator_t *enumerator;
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
|
|
||||||
@@ -67,8 +67,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
|||||||
peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
|
peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
|
||||||
|
|
||||||
/* reauthenticate only if we have children */
|
/* reauthenticate only if we have children */
|
||||||
iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
|
if (this->ike_sa->get_child_count(this->ike_sa) == 0
|
||||||
if (iterator->get_count(iterator) == 0
|
|
||||||
#ifdef ME
|
#ifdef ME
|
||||||
/* we allow peers to reauth mediation connections (without children) */
|
/* we allow peers to reauth mediation connections (without children) */
|
||||||
&& !peer_cfg->is_mediation(peer_cfg)
|
&& !peer_cfg->is_mediation(peer_cfg)
|
||||||
@@ -76,7 +75,6 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
DBG1(DBG_IKE, "unable to reauthenticate IKE_SA, no CHILD_SA to recreate");
|
DBG1(DBG_IKE, "unable to reauthenticate IKE_SA, no CHILD_SA to recreate");
|
||||||
iterator->destroy(iterator);
|
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,14 +108,15 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
|||||||
}
|
}
|
||||||
#endif /* ME */
|
#endif /* ME */
|
||||||
|
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
enumerator = this->ike_sa->create_child_sa_enumerator(this->ike_sa);
|
||||||
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
switch (child_sa->get_state(child_sa))
|
switch (child_sa->get_state(child_sa))
|
||||||
{
|
{
|
||||||
case CHILD_ROUTED:
|
case CHILD_ROUTED:
|
||||||
{
|
{
|
||||||
/* move routed child directly */
|
/* move routed child directly */
|
||||||
iterator->remove(iterator);
|
this->ike_sa->remove_child_sa(this->ike_sa, enumerator);
|
||||||
new->add_child_sa(new, child_sa);
|
new->add_child_sa(new, child_sa);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -128,7 +127,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
|||||||
child_cfg->get_ref(child_cfg);
|
child_cfg->get_ref(child_cfg);
|
||||||
if (new->initiate(new, child_cfg, 0, NULL, NULL) == DESTROY_ME)
|
if (new->initiate(new, child_cfg, 0, NULL, NULL) == DESTROY_ME)
|
||||||
{
|
{
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
charon->ike_sa_manager->checkin_and_destroy(
|
charon->ike_sa_manager->checkin_and_destroy(
|
||||||
charon->ike_sa_manager, new);
|
charon->ike_sa_manager, new);
|
||||||
/* set threads active IKE_SA after checkin */
|
/* set threads active IKE_SA after checkin */
|
||||||
@@ -140,7 +139,7 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
charon->ike_sa_manager->checkin(charon->ike_sa_manager, new);
|
charon->ike_sa_manager->checkin(charon->ike_sa_manager, new);
|
||||||
/* set threads active IKE_SA after checkin */
|
/* set threads active IKE_SA after checkin */
|
||||||
charon->bus->set_sa(charon->bus, this->ike_sa);
|
charon->bus->set_sa(charon->bus, this->ike_sa);
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ METHOD(task_t, build_i, status_t,
|
|||||||
METHOD(task_t, process_r, status_t,
|
METHOD(task_t, process_r, status_t,
|
||||||
private_ike_rekey_t *this, message_t *message)
|
private_ike_rekey_t *this, message_t *message)
|
||||||
{
|
{
|
||||||
|
enumerator_t *enumerator;
|
||||||
peer_cfg_t *peer_cfg;
|
peer_cfg_t *peer_cfg;
|
||||||
iterator_t *iterator;
|
|
||||||
child_sa_t *child_sa;
|
child_sa_t *child_sa;
|
||||||
|
|
||||||
if (this->ike_sa->get_state(this->ike_sa) == IKE_DELETING)
|
if (this->ike_sa->get_state(this->ike_sa) == IKE_DELETING)
|
||||||
@@ -157,8 +157,8 @@ METHOD(task_t, process_r, status_t,
|
|||||||
return NEED_MORE;
|
return NEED_MORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator = this->ike_sa->create_child_sa_iterator(this->ike_sa);
|
enumerator = this->ike_sa->create_child_sa_enumerator(this->ike_sa);
|
||||||
while (iterator->iterate(iterator, (void**)&child_sa))
|
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||||
{
|
{
|
||||||
switch (child_sa->get_state(child_sa))
|
switch (child_sa->get_state(child_sa))
|
||||||
{
|
{
|
||||||
@@ -167,13 +167,13 @@ METHOD(task_t, process_r, status_t,
|
|||||||
case CHILD_DELETING:
|
case CHILD_DELETING:
|
||||||
/* we do not allow rekeying while we have children in-progress */
|
/* we do not allow rekeying while we have children in-progress */
|
||||||
DBG1(DBG_IKE, "peer initiated rekeying, but a child is half-open");
|
DBG1(DBG_IKE, "peer initiated rekeying, but a child is half-open");
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
return NEED_MORE;
|
return NEED_MORE;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iterator->destroy(iterator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
this->new_sa = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
|
this->new_sa = charon->ike_sa_manager->checkout_new(charon->ike_sa_manager,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|||||||
Reference in New Issue
Block a user