Pass a list instead of a single virtual IP to attribute enumerators

This commit is contained in:
Martin Willi committed 2012-08-30 16:43:42 +02:00
1 parent 96c2b3cf89
commit feb8550401
15 files changed
+199 -110

No files matched your search

@@ -196,7 +196,7 @@ METHOD(enumerator_t, enumerate_dns, bool,
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
android_handler_t *this, identification_t *id, host_t *vip)
android_handler_t *this, identification_t *id, linked_list_t *vips)
{
enumerator_t *enumerator;
+15 -8
View File
@@ -130,17 +130,24 @@ METHOD(attribute_provider_t, release_address, bool,
METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
private_dhcp_provider_t *this, char *pool, identification_t *id,
host_t *vip)
linked_list_t *vips)
{
dhcp_transaction_t *transaction;
dhcp_transaction_t *transaction = NULL;
enumerator_t *enumerator;
host_t *vip;
if (!vip)
{
return NULL;
}
this->mutex->lock(this->mutex);
transaction = this->transactions->get(this->transactions,
(void*)hash_id_host(id, vip));
enumerator = vips->create_enumerator(vips);
while (enumerator->enumerate(enumerator, &vip))
{
transaction = this->transactions->get(this->transactions,
(void*)hash_id_host(id, vip));
if (transaction)
{
break;
}
}
enumerator->destroy(enumerator);
if (!transaction)
{
this->mutex->unlock(this->mutex);
@@ -149,7 +149,7 @@ static bool attr_filter(void *lock, host_t **in,
METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
private_stroke_attribute_t *this, char *pool, identification_t *id,
host_t *vip)
linked_list_t *vips)
{
ike_sa_t *ike_sa;
peer_cfg_t *peer_cfg;
@@ -94,7 +94,8 @@ static bool attr_filter(void *lock, host_t **in,
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
private_stroke_handler_t *this, identification_t *server, host_t *vip)
private_stroke_handler_t *this, identification_t *server,
linked_list_t *vips)
{
ike_sa_t *ike_sa;
peer_cfg_t *peer_cfg;
+39 -15
View File
@@ -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))
{
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))
{
vip = NULL;
}
vips->insert_last(vips, host);
}
enumerator->destroy(enumerator);
if (vip)
if (vips->get_count(vips) == 0)
{
cp = cp_payload_create_type(CONFIGURATION_V1, CFG_REQUEST);
cp->add_attribute(cp, build_vip(vip));
config = this->ike_sa->get_peer_cfg(this->ike_sa);
enumerator = config->create_virtual_ip_enumerator(config);
while (enumerator->enumerate(enumerator, &host))
{
vips->insert_last(vips, host);
}
enumerator->destroy(enumerator);
}
enumerator = hydra->attributes->create_initiator_enumerator(hydra->attributes,
this->ike_sa->get_other_id(this->ike_sa), vip);
if (vips->get_count(vips))
{
cp = cp_payload_create_type(CONFIGURATION_V1, CFG_REQUEST);
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), 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)
{
+40 -15
View File
@@ -242,30 +242,45 @@ 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))
{
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))
{
vip = NULL;
}
vips->insert_last(vips, host);
}
enumerator->destroy(enumerator);
if (vip)
if (vips->get_count(vips) == 0)
{
cp = cp_payload_create_type(CONFIGURATION, CFG_REQUEST);
cp->add_attribute(cp, build_vip(vip));
config = this->ike_sa->get_peer_cfg(this->ike_sa);
enumerator = config->create_virtual_ip_enumerator(config);
while (enumerator->enumerate(enumerator, &host))
{
vips->insert_last(vips, host);
}
enumerator->destroy(enumerator);
}
enumerator = hydra->attributes->create_initiator_enumerator(hydra->attributes,
this->ike_sa->get_other_id(this->ike_sa), vip);
if (vips->get_count(vips))
{
cp = cp_payload_create_type(CONFIGURATION, CFG_REQUEST);
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), vips);
while (enumerator->enumerate(enumerator, &handler, &type, &data))
{
configuration_attribute_t *ca;
@@ -291,6 +306,8 @@ METHOD(task_t, build_i, status_t,
}
enumerator->destroy(enumerator);
vips->destroy(vips);
if (cp)
{
message->add_payload(message, (payload_t*)cp);
@@ -321,6 +338,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);
@@ -357,8 +375,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)
@@ -372,6 +396,7 @@ METHOD(task_t, build_r, status_t,
type, value));
}
enumerator->destroy(enumerator);
vips->destroy(vips);
if (cp)
{