Pass all configured pool names to attribute provider enumerator

This commit is contained in:
Martin Willi
2012-08-30 16:43:43 +02:00
parent feb8550401
commit d55fe264d1
9 changed files with 42 additions and 26 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ METHOD(attribute_provider_t, release_address, bool,
} }
METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*, METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
private_dhcp_provider_t *this, char *pool, identification_t *id, private_dhcp_provider_t *this, linked_list_t *pools, identification_t *id,
linked_list_t *vips) linked_list_t *vips)
{ {
dhcp_transaction_t *transaction = NULL; dhcp_transaction_t *transaction = NULL;
@@ -148,8 +148,8 @@ static bool attr_filter(void *lock, host_t **in,
} }
METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*, METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
private_stroke_attribute_t *this, char *pool, identification_t *id, private_stroke_attribute_t *this, linked_list_t *pools,
linked_list_t *vips) identification_t *id, linked_list_t *vips)
{ {
ike_sa_t *ike_sa; ike_sa_t *ike_sa;
peer_cfg_t *peer_cfg; peer_cfg_t *peer_cfg;
+9 -2
View File
@@ -326,7 +326,7 @@ METHOD(task_t, build_r, status_t,
cp_payload_t *cp = NULL; cp_payload_t *cp = NULL;
peer_cfg_t *config; peer_cfg_t *config;
identification_t *id; identification_t *id;
linked_list_t *vips; linked_list_t *vips, *pools;
char *pool; char *pool;
id = this->ike_sa->get_other_eap_id(this->ike_sa); id = this->ike_sa->get_other_eap_id(this->ike_sa);
@@ -365,8 +365,14 @@ METHOD(task_t, build_r, status_t,
{ {
vips->insert_last(vips, vip); vips->insert_last(vips, vip);
} }
pools = linked_list_create();
/* TODO: use list of all pools */
if (pool)
{
pools->insert_last(pools, pool);
}
enumerator = hydra->attributes->create_responder_enumerator( enumerator = hydra->attributes->create_responder_enumerator(
hydra->attributes, pool, id, vips); hydra->attributes, pools, id, vips);
while (enumerator->enumerate(enumerator, &type, &value)) while (enumerator->enumerate(enumerator, &type, &value))
{ {
if (!cp) if (!cp)
@@ -381,6 +387,7 @@ METHOD(task_t, build_r, status_t,
} }
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
vips->destroy(vips); vips->destroy(vips);
pools->destroy(pools);
if (cp) if (cp)
{ {
+9 -2
View File
@@ -338,7 +338,7 @@ METHOD(task_t, build_r, status_t,
cp_payload_t *cp = NULL; cp_payload_t *cp = NULL;
peer_cfg_t *config; peer_cfg_t *config;
identification_t *id; identification_t *id;
linked_list_t *vips; linked_list_t *vips, *pools;
char *pool; char *pool;
id = this->ike_sa->get_other_eap_id(this->ike_sa); id = this->ike_sa->get_other_eap_id(this->ike_sa);
@@ -381,8 +381,14 @@ METHOD(task_t, build_r, status_t,
{ {
vips->insert_last(vips, vip); vips->insert_last(vips, vip);
} }
pools = linked_list_create();
/* TODO: use list of all pools */
if (pool)
{
pools->insert_last(pools, pool);
}
enumerator = hydra->attributes->create_responder_enumerator( enumerator = hydra->attributes->create_responder_enumerator(
hydra->attributes, pool, id, vips); hydra->attributes, pools, id, vips);
while (enumerator->enumerate(enumerator, &type, &value)) while (enumerator->enumerate(enumerator, &type, &value))
{ {
if (!cp) if (!cp)
@@ -397,6 +403,7 @@ METHOD(task_t, build_r, status_t,
} }
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
vips->destroy(vips); vips->destroy(vips);
pools->destroy(pools);
if (cp) if (cp)
{ {
+6 -6
View File
@@ -51,8 +51,8 @@ struct private_attribute_manager_t {
* Data to pass to enumerator filters * Data to pass to enumerator filters
*/ */
typedef struct { typedef struct {
/** attribute group pool */ /** attribute group pools */
char *pool; linked_list_t *pools;
/** server/peer identity */ /** server/peer identity */
identification_t *id; identification_t *id;
/** requesting/assigned virtual IPs */ /** requesting/assigned virtual IPs */
@@ -117,18 +117,18 @@ METHOD(attribute_manager_t, release_address, bool,
static enumerator_t *responder_enum_create(attribute_provider_t *provider, static enumerator_t *responder_enum_create(attribute_provider_t *provider,
enum_data_t *data) enum_data_t *data)
{ {
return provider->create_attribute_enumerator(provider, data->pool, return provider->create_attribute_enumerator(provider, data->pools,
data->id, data->vips); data->id, data->vips);
} }
METHOD(attribute_manager_t, create_responder_enumerator, enumerator_t*, METHOD(attribute_manager_t, create_responder_enumerator, enumerator_t*,
private_attribute_manager_t *this, char *pool, identification_t *id, private_attribute_manager_t *this, linked_list_t *pools,
linked_list_t *vips) identification_t *id, linked_list_t *vips)
{ {
enum_data_t *data; enum_data_t *data;
INIT(data, INIT(data,
.pool = pool, .pools = pools,
.id = id, .id = id,
.vips = vips, .vips = vips,
); );
+3 -2
View File
@@ -62,13 +62,14 @@ struct attribute_manager_t {
/** /**
* Create an enumerator over attributes to hand out to a peer. * Create an enumerator over attributes to hand out to a peer.
* *
* @param pool pool name to get attributes from * @param pool list of pools names (char*) to query attributes from
* @param id peer identity to hand out attributes to * @param id peer identity to hand out attributes to
* @param vip list of virtual IPs (host_t*) to assign to peer * @param vip list of virtual IPs (host_t*) to assign to peer
* @return enumerator (configuration_attribute_type_t, chunk_t) * @return enumerator (configuration_attribute_type_t, chunk_t)
*/ */
enumerator_t* (*create_responder_enumerator)(attribute_manager_t *this, enumerator_t* (*create_responder_enumerator)(attribute_manager_t *this,
char *pool, identification_t *id, linked_list_t *vips); linked_list_t *pool, identification_t *id,
linked_list_t *vips);
/** /**
* Register an attribute provider to the manager. * Register an attribute provider to the manager.
+3 -2
View File
@@ -57,13 +57,14 @@ struct attribute_provider_t {
/** /**
* Create an enumerator over attributes to hand out to a peer. * Create an enumerator over attributes to hand out to a peer.
* *
* @param pool pool name to get attributes from * @param pool list of pools names (char*) to query attributes from
* @param id peer ID * @param id peer ID
* @param vip list of virtual IPs (host_t*) to assign to peer * @param vip list of virtual IPs (host_t*) to assign to peer
* @return enumerator (configuration_attribute_type_t, chunk_t) * @return enumerator (configuration_attribute_type_t, chunk_t)
*/ */
enumerator_t* (*create_attribute_enumerator)(attribute_provider_t *this, enumerator_t* (*create_attribute_enumerator)(attribute_provider_t *this,
char *pool, identification_t *id, linked_list_t *vips); linked_list_t *pools, identification_t *id,
linked_list_t *vips);
}; };
#endif /** ATTRIBUTE_PROVIDER_H_ @}*/ #endif /** ATTRIBUTE_PROVIDER_H_ @}*/
+1 -1
View File
@@ -77,7 +77,7 @@ static bool attr_enum_filter(void *null, attribute_entry_t **in,
} }
METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*, METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
private_attr_provider_t *this, char *pool, private_attr_provider_t *this, linked_list_t *pools,
identification_t *id, linked_list_t *vips) identification_t *id, linked_list_t *vips)
{ {
if (vips->get_count(vips)) if (vips->get_count(vips))
@@ -339,14 +339,14 @@ METHOD(attribute_provider_t, release_address, bool,
} }
METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*, METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
private_sql_attribute_t *this, char *names, identification_t *id, private_sql_attribute_t *this, linked_list_t *pools, identification_t *id,
linked_list_t *vips) linked_list_t *vips)
{ {
enumerator_t *attr_enumerator = NULL; enumerator_t *attr_enumerator = NULL;
if (vips->get_count(vips)) if (vips->get_count(vips))
{ {
enumerator_t *names_enumerator; enumerator_t *pool_enumerator;
u_int count; u_int count;
char *name; char *name;
@@ -357,8 +357,8 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
{ {
u_int identity = get_identity(this, id); u_int identity = get_identity(this, id);
names_enumerator = enumerator_create_token(names, ",", " "); pool_enumerator = pools->create_enumerator(pools);
while (names_enumerator->enumerate(names_enumerator, &name)) while (pool_enumerator->enumerate(pool_enumerator, &name))
{ {
u_int attr_pool = get_attr_pool(this, name); u_int attr_pool = get_attr_pool(this, name);
if (!attr_pool) if (!attr_pool)
@@ -385,14 +385,14 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
DESTROY_IF(attr_enumerator); DESTROY_IF(attr_enumerator);
attr_enumerator = NULL; attr_enumerator = NULL;
} }
names_enumerator->destroy(names_enumerator); pool_enumerator->destroy(pool_enumerator);
} }
/* in a second step check for attributes that match name */ /* in a second step check for attributes that match name */
if (!attr_enumerator) if (!attr_enumerator)
{ {
names_enumerator = enumerator_create_token(names, ",", " "); pool_enumerator = pools->create_enumerator(pools);
while (names_enumerator->enumerate(names_enumerator, &name)) while (pool_enumerator->enumerate(pool_enumerator, &name))
{ {
u_int attr_pool = get_attr_pool(this, name); u_int attr_pool = get_attr_pool(this, name);
if (!attr_pool) if (!attr_pool)
@@ -419,7 +419,7 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
DESTROY_IF(attr_enumerator); DESTROY_IF(attr_enumerator);
attr_enumerator = NULL; attr_enumerator = NULL;
} }
names_enumerator->destroy(names_enumerator); pool_enumerator->destroy(pool_enumerator);
} }
this->db->execute(this->db, NULL, "END TRANSACTION"); this->db->execute(this->db, NULL, "END TRANSACTION");