aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2014-11-04 15:20:41 +0100
committerMartin Willi <martin@revosec.ch>2015-02-20 13:34:56 +0100
commita12f357b40c75987965ee0ea9ff4f8ad5573fc5a (patch)
tree3e8b21b65dc73fc9e5fcaad3711a797d4e049b7e /src
parenta16058a49125ba9db08ee5e1cac929566546a764 (diff)
downloadstrongswan-a12f357b40c75987965ee0ea9ff4f8ad5573fc5a.tar.bz2
strongswan-a12f357b40c75987965ee0ea9ff4f8ad5573fc5a.tar.xz
attribute-manager: Pass full IKE_SA to handler methods
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/attributes/attribute_manager.c24
-rw-r--r--src/libcharon/attributes/attribute_manager.h13
-rw-r--r--src/libcharon/sa/ike_sa.c2
-rw-r--r--src/libcharon/sa/ikev1/tasks/mode_config.c6
-rw-r--r--src/libcharon/sa/ikev2/tasks/ike_config.c6
5 files changed, 28 insertions, 23 deletions
diff --git a/src/libcharon/attributes/attribute_manager.c b/src/libcharon/attributes/attribute_manager.c
index 8b974928a..b6afd9a4b 100644
--- a/src/libcharon/attributes/attribute_manager.c
+++ b/src/libcharon/attributes/attribute_manager.c
@@ -162,13 +162,16 @@ METHOD(attribute_manager_t, remove_provider, void,
}
METHOD(attribute_manager_t, handle, attribute_handler_t*,
- private_attribute_manager_t *this, identification_t *server,
+ private_attribute_manager_t *this, ike_sa_t *ike_sa,
attribute_handler_t *handler, configuration_attribute_type_t type,
chunk_t data)
{
enumerator_t *enumerator;
+ identification_t *server;
attribute_handler_t *current, *handled = NULL;
+ server = ike_sa->get_other_id(ike_sa);
+
this->lock->read_lock(this->lock);
/* try to find the passed handler */
@@ -207,10 +210,13 @@ METHOD(attribute_manager_t, handle, attribute_handler_t*,
METHOD(attribute_manager_t, release, void,
private_attribute_manager_t *this, attribute_handler_t *handler,
- identification_t *server, configuration_attribute_type_t type, chunk_t data)
+ ike_sa_t *ike_sa, configuration_attribute_type_t type, chunk_t data)
{
enumerator_t *enumerator;
attribute_handler_t *current;
+ identification_t *server;
+
+ server = ike_sa->get_other_id(ike_sa);
this->lock->read_lock(this->lock);
enumerator = this->handlers->create_enumerator(this->handlers);
@@ -240,8 +246,8 @@ typedef struct {
enumerator_t *outer;
/** inner enumerator over current handlers attributes */
enumerator_t *inner;
- /** server ID we want attributes for */
- identification_t *id;
+ /** IKE_SA to request attributes for */
+ ike_sa_t *ike_sa;
/** virtual IPs we are requesting along with attriubutes */
linked_list_t *vips;
} initiator_enumerator_t;
@@ -254,6 +260,10 @@ static bool initiator_enumerate(initiator_enumerator_t *this,
configuration_attribute_type_t *type,
chunk_t *value)
{
+ identification_t *id;
+
+ id = this->ike_sa->get_other_id(this->ike_sa);
+
/* enumerate inner attributes using outer handler enumerator */
while (!this->inner || !this->inner->enumerate(this->inner, type, value))
{
@@ -263,7 +273,7 @@ static bool initiator_enumerate(initiator_enumerator_t *this,
}
DESTROY_IF(this->inner);
this->inner = this->handler->create_attribute_enumerator(this->handler,
- this->id, this->vips);
+ id, this->vips);
}
/* inject the handler as additional attribute */
*handler = this->handler;
@@ -282,7 +292,7 @@ static void initiator_destroy(initiator_enumerator_t *this)
}
METHOD(attribute_manager_t, create_initiator_enumerator, enumerator_t*,
- private_attribute_manager_t *this, identification_t *id, linked_list_t *vips)
+ private_attribute_manager_t *this, ike_sa_t *ike_sa, linked_list_t *vips)
{
initiator_enumerator_t *enumerator;
@@ -294,7 +304,7 @@ METHOD(attribute_manager_t, create_initiator_enumerator, enumerator_t*,
.destroy = (void*)initiator_destroy,
},
.this = this,
- .id = id,
+ .ike_sa = ike_sa,
.vips = vips,
.outer = this->handlers->create_enumerator(this->handlers),
);
diff --git a/src/libcharon/attributes/attribute_manager.h b/src/libcharon/attributes/attribute_manager.h
index b1827ba99..6db664968 100644
--- a/src/libcharon/attributes/attribute_manager.h
+++ b/src/libcharon/attributes/attribute_manager.h
@@ -92,38 +92,37 @@ struct attribute_manager_t {
/**
* Handle a configuration attribute by passing them to the handlers.
*
- * @param server server from which the attribute was received
+ * @param ike_sa associated IKE_SA to handle an attribute for
* @param handler handler we requested the attribute for, if any
* @param type type of configuration attribute
* @param data associated attribute data
* @return handler which handled this attribute, NULL if none
*/
attribute_handler_t* (*handle)(attribute_manager_t *this,
- identification_t *server, attribute_handler_t *handler,
+ ike_sa_t *ike_sa, attribute_handler_t *handler,
configuration_attribute_type_t type, chunk_t data);
/**
* Release an attribute previously handle()d by a handler.
*
- * @param handler handler returned by handle() for this attribute
+ * @param ike_sa associated IKE_SA to release an attribute for
* @param server server from which the attribute was received
* @param type type of attribute to release
* @param data associated attribute data
*/
void (*release)(attribute_manager_t *this, attribute_handler_t *handler,
- identification_t *server,
- configuration_attribute_type_t type,
+ ike_sa_t *ike_sa, configuration_attribute_type_t type,
chunk_t data);
/**
* Create an enumerator over attributes to request from server.
*
- * @param id server identity to hand out attributes to
+ * @param ike_sa associated IKE_SA to request attributes for
* @param vip list of virtual IPs (host_t*) going to request
* @return enumerator (attribute_handler_t, ca_type_t, chunk_t)
*/
enumerator_t* (*create_initiator_enumerator)(attribute_manager_t *this,
- identification_t *id, linked_list_t *vips);
+ ike_sa_t *ike_sa, linked_list_t *vips);
/**
* Register an attribute handler to the manager.
diff --git a/src/libcharon/sa/ike_sa.c b/src/libcharon/sa/ike_sa.c
index 955d291ff..d4ef7b861 100644
--- a/src/libcharon/sa/ike_sa.c
+++ b/src/libcharon/sa/ike_sa.c
@@ -2347,7 +2347,7 @@ METHOD(ike_sa_t, destroy, void,
if (entry.handler)
{
charon->attributes->release(charon->attributes, entry.handler,
- this->other_id, entry.type, entry.data);
+ &this->public, entry.type, entry.data);
}
free(entry.data.ptr);
}
diff --git a/src/libcharon/sa/ikev1/tasks/mode_config.c b/src/libcharon/sa/ikev1/tasks/mode_config.c
index b7f55423e..160d4af57 100644
--- a/src/libcharon/sa/ikev1/tasks/mode_config.c
+++ b/src/libcharon/sa/ikev1/tasks/mode_config.c
@@ -136,8 +136,7 @@ static void handle_attribute(private_mode_config_t *this,
/* and pass it to the handle function */
handler = charon->attributes->handle(charon->attributes,
- this->ike_sa->get_other_id(this->ike_sa), handler,
- ca->get_type(ca), ca->get_chunk(ca));
+ this->ike_sa, handler, ca->get_type(ca), ca->get_chunk(ca));
this->ike_sa->add_configuration_attribute(this->ike_sa,
handler, ca->get_type(ca), ca->get_chunk(ca));
}
@@ -326,8 +325,7 @@ static status_t build_request(private_mode_config_t *this, message_t *message)
}
enumerator = charon->attributes->create_initiator_enumerator(
- charon->attributes,
- this->ike_sa->get_other_id(this->ike_sa), vips);
+ charon->attributes, this->ike_sa, vips);
while (enumerator->enumerate(enumerator, &handler, &type, &data))
{
add_attribute(this, cp, type, data, handler);
diff --git a/src/libcharon/sa/ikev2/tasks/ike_config.c b/src/libcharon/sa/ikev2/tasks/ike_config.c
index ed937b5da..646f20c61 100644
--- a/src/libcharon/sa/ikev2/tasks/ike_config.c
+++ b/src/libcharon/sa/ikev2/tasks/ike_config.c
@@ -127,8 +127,7 @@ static void handle_attribute(private_ike_config_t *this,
/* and pass it to the handle function */
handler = charon->attributes->handle(charon->attributes,
- this->ike_sa->get_other_id(this->ike_sa), handler,
- ca->get_type(ca), ca->get_chunk(ca));
+ this->ike_sa, handler, ca->get_type(ca), ca->get_chunk(ca));
this->ike_sa->add_configuration_attribute(this->ike_sa,
handler, ca->get_type(ca), ca->get_chunk(ca));
}
@@ -274,8 +273,7 @@ METHOD(task_t, build_i, status_t,
}
enumerator = charon->attributes->create_initiator_enumerator(
- charon->attributes,
- this->ike_sa->get_other_id(this->ike_sa), vips);
+ charon->attributes, this->ike_sa, vips);
while (enumerator->enumerate(enumerator, &handler, &type, &data))
{
configuration_attribute_t *ca;