Pass all configured pool names to attribute provider enumerator
authorMartin Willi <martin@revosec.ch>
Mon, 27 Aug 2012 12:48:41 +0000 (14:48 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 30 Aug 2012 14:43:43 +0000 (16:43 +0200)
src/libcharon/plugins/dhcp/dhcp_provider.c
src/libcharon/plugins/stroke/stroke_attribute.c
src/libcharon/sa/ikev1/tasks/mode_config.c
src/libcharon/sa/ikev2/tasks/ike_config.c
src/libhydra/attributes/attribute_manager.c
src/libhydra/attributes/attribute_manager.h
src/libhydra/attributes/attribute_provider.h
src/libhydra/plugins/attr/attr_provider.c
src/libhydra/plugins/attr_sql/sql_attribute.c

index 7050634..3d72b44 100644 (file)
@@ -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;
index cec6334..3e01223 100644 (file)
@@ -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;
index 6b8ed07..ecf2e62 100644 (file)
@@ -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)
        {
index f3c0c2f..d0e0285 100644 (file)
@@ -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)
                {
index b1c2c95..a2ee773 100644 (file)
@@ -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,
        );
index 385580e..8bc80ca 100644 (file)
@@ -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.
index 104e5ca..327135f 100644 (file)
@@ -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_ @}*/
index f81f643..673c721 100644 (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*,
-       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))
index b0f8c16..e5a4cdc 100644 (file)
@@ -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");