aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/sa/ikev1
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2012-08-27 14:09:47 +0200
committerMartin Willi <martin@revosec.ch>2012-08-30 16:43:42 +0200
commitfeb8550401c85218523c007f0d52a1c9bf006342 (patch)
tree71b28e039b7f2e1cc574b977c5952b2af8bc2a41 /src/libcharon/sa/ikev1
parent96c2b3cf89aa1825d70c51ddb3d800ed4720d6c0 (diff)
downloadstrongswan-feb8550401c85218523c007f0d52a1c9bf006342.tar.bz2
strongswan-feb8550401c85218523c007f0d52a1c9bf006342.tar.xz
Pass a list instead of a single virtual IP to attribute enumerators
Diffstat (limited to 'src/libcharon/sa/ikev1')
-rw-r--r--src/libcharon/sa/ikev1/tasks/mode_config.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/src/libcharon/sa/ikev1/tasks/mode_config.c b/src/libcharon/sa/ikev1/tasks/mode_config.c
index bad599b83..6b8ed079b 100644
--- a/src/libcharon/sa/ikev1/tasks/mode_config.c
+++ b/src/libcharon/sa/ikev1/tasks/mode_config.c
@@ -239,30 +239,44 @@ METHOD(task_t, build_i, status_t,
peer_cfg_t *config;
configuration_attribute_type_t type;
chunk_t data;
- host_t *vip;
+ linked_list_t *vips;
+ host_t *host;
+
+ vips = linked_list_create();
/* reuse virtual IP if we already have one */
enumerator = this->ike_sa->create_virtual_ip_enumerator(this->ike_sa, TRUE);
- if (!enumerator->enumerate(enumerator, &vip))
+ while (enumerator->enumerate(enumerator, &host))
+ {
+ vips->insert_last(vips, host);
+ }
+ enumerator->destroy(enumerator);
+
+ if (vips->get_count(vips) == 0)
{
- enumerator->destroy(enumerator);
config = this->ike_sa->get_peer_cfg(this->ike_sa);
enumerator = config->create_virtual_ip_enumerator(config);
- if (!enumerator->enumerate(enumerator, &vip))
+ while (enumerator->enumerate(enumerator, &host))
{
- vip = NULL;
+ vips->insert_last(vips, host);
}
+ enumerator->destroy(enumerator);
}
- enumerator->destroy(enumerator);
- if (vip)
+ if (vips->get_count(vips))
{
cp = cp_payload_create_type(CONFIGURATION_V1, CFG_REQUEST);
- cp->add_attribute(cp, build_vip(vip));
+ enumerator = vips->create_enumerator(vips);
+ while (enumerator->enumerate(enumerator, &host))
+ {
+ cp->add_attribute(cp, build_vip(host));
+ }
+ enumerator->destroy(enumerator);
}
- enumerator = hydra->attributes->create_initiator_enumerator(hydra->attributes,
- this->ike_sa->get_other_id(this->ike_sa), vip);
+ enumerator = hydra->attributes->create_initiator_enumerator(
+ hydra->attributes,
+ this->ike_sa->get_other_id(this->ike_sa), vips);
while (enumerator->enumerate(enumerator, &handler, &type, &data))
{
configuration_attribute_t *ca;
@@ -286,6 +300,8 @@ METHOD(task_t, build_i, status_t,
}
enumerator->destroy(enumerator);
+ vips->destroy(vips);
+
if (cp)
{
message->add_payload(message, (payload_t*)cp);
@@ -310,6 +326,7 @@ METHOD(task_t, build_r, status_t,
cp_payload_t *cp = NULL;
peer_cfg_t *config;
identification_t *id;
+ linked_list_t *vips;
char *pool;
id = this->ike_sa->get_other_eap_id(this->ike_sa);
@@ -342,8 +359,14 @@ METHOD(task_t, build_r, status_t,
}
}
/* query registered providers for additional attributes to include */
+ vips = linked_list_create();
+ /* TODO: use list with all assigned VIPs */
+ if (vip)
+ {
+ vips->insert_last(vips, vip);
+ }
enumerator = hydra->attributes->create_responder_enumerator(
- hydra->attributes, pool, id, vip);
+ hydra->attributes, pool, id, vips);
while (enumerator->enumerate(enumerator, &type, &value))
{
if (!cp)
@@ -357,6 +380,7 @@ METHOD(task_t, build_r, status_t,
type, value));
}
enumerator->destroy(enumerator);
+ vips->destroy(vips);
if (cp)
{