Pass all configured pool names to attribute provider enumerator
This commit is contained in:
parent
feb8550401
commit
d55fe264d1
|
@ -129,7 +129,7 @@ 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,
|
||||
private_dhcp_provider_t *this, linked_list_t *pools, identification_t *id,
|
||||
linked_list_t *vips)
|
||||
{
|
||||
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*,
|
||||
private_stroke_attribute_t *this, char *pool, identification_t *id,
|
||||
linked_list_t *vips)
|
||||
private_stroke_attribute_t *this, linked_list_t *pools,
|
||||
identification_t *id, linked_list_t *vips)
|
||||
{
|
||||
ike_sa_t *ike_sa;
|
||||
peer_cfg_t *peer_cfg;
|
||||
|
|
|
@ -326,7 +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;
|
||||
linked_list_t *vips, *pools;
|
||||
char *pool;
|
||||
|
||||
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);
|
||||
}
|
||||
pools = linked_list_create();
|
||||
/* TODO: use list of all pools */
|
||||
if (pool)
|
||||
{
|
||||
pools->insert_last(pools, pool);
|
||||
}
|
||||
enumerator = hydra->attributes->create_responder_enumerator(
|
||||
hydra->attributes, pool, id, vips);
|
||||
hydra->attributes, pools, id, vips);
|
||||
while (enumerator->enumerate(enumerator, &type, &value))
|
||||
{
|
||||
if (!cp)
|
||||
|
@ -381,6 +387,7 @@ METHOD(task_t, build_r, status_t,
|
|||
}
|
||||
enumerator->destroy(enumerator);
|
||||
vips->destroy(vips);
|
||||
pools->destroy(pools);
|
||||
|
||||
if (cp)
|
||||
{
|
||||
|
|
|
@ -338,7 +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;
|
||||
linked_list_t *vips, *pools;
|
||||
char *pool;
|
||||
|
||||
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);
|
||||
}
|
||||
pools = linked_list_create();
|
||||
/* TODO: use list of all pools */
|
||||
if (pool)
|
||||
{
|
||||
pools->insert_last(pools, pool);
|
||||
}
|
||||
enumerator = hydra->attributes->create_responder_enumerator(
|
||||
hydra->attributes, pool, id, vips);
|
||||
hydra->attributes, pools, id, vips);
|
||||
while (enumerator->enumerate(enumerator, &type, &value))
|
||||
{
|
||||
if (!cp)
|
||||
|
@ -397,6 +403,7 @@ METHOD(task_t, build_r, status_t,
|
|||
}
|
||||
enumerator->destroy(enumerator);
|
||||
vips->destroy(vips);
|
||||
pools->destroy(pools);
|
||||
|
||||
if (cp)
|
||||
{
|
||||
|
|
|
@ -51,8 +51,8 @@ struct private_attribute_manager_t {
|
|||
* Data to pass to enumerator filters
|
||||
*/
|
||||
typedef struct {
|
||||
/** attribute group pool */
|
||||
char *pool;
|
||||
/** attribute group pools */
|
||||
linked_list_t *pools;
|
||||
/** server/peer identity */
|
||||
identification_t *id;
|
||||
/** 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,
|
||||
enum_data_t *data)
|
||||
{
|
||||
return provider->create_attribute_enumerator(provider, data->pool,
|
||||
return provider->create_attribute_enumerator(provider, data->pools,
|
||||
data->id, data->vips);
|
||||
}
|
||||
|
||||
METHOD(attribute_manager_t, create_responder_enumerator, enumerator_t*,
|
||||
private_attribute_manager_t *this, char *pool, identification_t *id,
|
||||
linked_list_t *vips)
|
||||
private_attribute_manager_t *this, linked_list_t *pools,
|
||||
identification_t *id, linked_list_t *vips)
|
||||
{
|
||||
enum_data_t *data;
|
||||
|
||||
INIT(data,
|
||||
.pool = pool,
|
||||
.pools = pools,
|
||||
.id = id,
|
||||
.vips = vips,
|
||||
);
|
||||
|
|
|
@ -62,13 +62,14 @@ struct attribute_manager_t {
|
|||
/**
|
||||
* 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 vip list of virtual IPs (host_t*) to assign to peer
|
||||
* @return enumerator (configuration_attribute_type_t, chunk_t)
|
||||
*/
|
||||
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.
|
||||
|
|
|
@ -57,13 +57,14 @@ struct attribute_provider_t {
|
|||
/**
|
||||
* 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 vip list of virtual IPs (host_t*) to assign to peer
|
||||
* @return enumerator (configuration_attribute_type_t, chunk_t)
|
||||
*/
|
||||
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_ @}*/
|
||||
|
|
|
@ -77,7 +77,7 @@ static bool attr_enum_filter(void *null, attribute_entry_t **in,
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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*,
|
||||
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)
|
||||
{
|
||||
enumerator_t *attr_enumerator = NULL;
|
||||
|
||||
if (vips->get_count(vips))
|
||||
{
|
||||
enumerator_t *names_enumerator;
|
||||
enumerator_t *pool_enumerator;
|
||||
u_int count;
|
||||
char *name;
|
||||
|
||||
|
@ -357,8 +357,8 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
|
|||
{
|
||||
u_int identity = get_identity(this, id);
|
||||
|
||||
names_enumerator = enumerator_create_token(names, ",", " ");
|
||||
while (names_enumerator->enumerate(names_enumerator, &name))
|
||||
pool_enumerator = pools->create_enumerator(pools);
|
||||
while (pool_enumerator->enumerate(pool_enumerator, &name))
|
||||
{
|
||||
u_int attr_pool = get_attr_pool(this, name);
|
||||
if (!attr_pool)
|
||||
|
@ -385,14 +385,14 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
|
|||
DESTROY_IF(attr_enumerator);
|
||||
attr_enumerator = NULL;
|
||||
}
|
||||
names_enumerator->destroy(names_enumerator);
|
||||
pool_enumerator->destroy(pool_enumerator);
|
||||
}
|
||||
|
||||
/* in a second step check for attributes that match name */
|
||||
if (!attr_enumerator)
|
||||
{
|
||||
names_enumerator = enumerator_create_token(names, ",", " ");
|
||||
while (names_enumerator->enumerate(names_enumerator, &name))
|
||||
pool_enumerator = pools->create_enumerator(pools);
|
||||
while (pool_enumerator->enumerate(pool_enumerator, &name))
|
||||
{
|
||||
u_int attr_pool = get_attr_pool(this, name);
|
||||
if (!attr_pool)
|
||||
|
@ -419,7 +419,7 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
|
|||
DESTROY_IF(attr_enumerator);
|
||||
attr_enumerator = NULL;
|
||||
}
|
||||
names_enumerator->destroy(names_enumerator);
|
||||
pool_enumerator->destroy(pool_enumerator);
|
||||
}
|
||||
|
||||
this->db->execute(this->db, NULL, "END TRANSACTION");
|
||||
|
|
Loading…
Reference in New Issue