]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
moved attribute_manager to libstrongswan
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 13 Oct 2009 11:46:27 +0000 (13:46 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 13 Oct 2009 11:46:27 +0000 (13:46 +0200)
31 files changed:
src/charon/Makefile.am
src/charon/daemon.c
src/charon/daemon.h
src/charon/encoding/payloads/configuration_attribute.c
src/charon/encoding/payloads/configuration_attribute.h
src/charon/plugins/attr/attr_plugin.c
src/charon/plugins/attr/attr_provider.h
src/charon/plugins/nm/nm_handler.c
src/charon/plugins/nm/nm_handler.h
src/charon/plugins/nm/nm_plugin.c
src/charon/plugins/resolve/resolve_handler.c
src/charon/plugins/resolve/resolve_handler.h
src/charon/plugins/resolve/resolve_plugin.c
src/charon/plugins/sql/sql_attribute.h
src/charon/plugins/sql/sql_plugin.c
src/charon/plugins/stroke/stroke_attribute.h
src/charon/plugins/stroke/stroke_socket.c
src/charon/sa/ike_sa.c
src/charon/sa/tasks/ike_config.c
src/libstrongswan/Makefile.am
src/libstrongswan/attributes/attribute_handler.h [moved from src/charon/config/attributes/attribute_handler.h with 81% similarity]
src/libstrongswan/attributes/attribute_manager.c [moved from src/charon/config/attributes/attribute_manager.c with 88% similarity]
src/libstrongswan/attributes/attribute_manager.h [moved from src/charon/config/attributes/attribute_manager.h with 91% similarity]
src/libstrongswan/attributes/attribute_provider.h [moved from src/charon/config/attributes/attribute_provider.h with 98% similarity]
src/libstrongswan/attributes/attributes.c [new file with mode: 0644]
src/libstrongswan/attributes/attributes.h [new file with mode: 0644]
src/libstrongswan/library.c
src/libstrongswan/library.h
src/libstrongswan/utils/host.h
src/libstrongswan/utils/identification.c
src/libstrongswan/utils/identification.h

index 6b5a340cbac686597a87ad84afa6eeda02cb0c71..0da3c3dfb7c656838971080c28f9930b59edf319 100644 (file)
@@ -12,9 +12,6 @@ config/peer_cfg.c config/peer_cfg.h \
 config/proposal.c config/proposal.h \
 config/auth_cfg.c config/auth_cfg.h \
 config/traffic_selector.c config/traffic_selector.h \
-config/attributes/attribute_provider.h \
-config/attributes/attribute_handler.h \
-config/attributes/attribute_manager.c config/attributes/attribute_manager.h \
 control/controller.c control/controller.h \
 daemon.c daemon.h \
 encoding/generator.c encoding/generator.h \
index 490357c13f6b2ba8f929e501133745fda214f456..919592088c0f015accd57c8b4e062d1fcb8179ae 100644 (file)
@@ -195,7 +195,6 @@ static void destroy(private_daemon_t *this)
        DESTROY_IF(this->public.mediation_manager);
 #endif /* ME */
        DESTROY_IF(this->public.backends);
-       DESTROY_IF(this->public.attributes);
        DESTROY_IF(this->public.credentials);
        DESTROY_IF(this->public.sender);
        DESTROY_IF(this->public.receiver);
@@ -487,7 +486,6 @@ static bool initialize(private_daemon_t *this, bool syslog, level_t levels[])
        this->public.eap = eap_manager_create();
        this->public.sim = sim_manager_create();
        this->public.backends = backend_manager_create();
-       this->public.attributes = attribute_manager_create();
        this->public.kernel_interface = kernel_interface_create();
        this->public.socket = socket_create();
        this->public.traps = trap_manager_create();
@@ -559,7 +557,6 @@ private_daemon_t *daemon_create(void)
        this->public.traps = NULL;
        this->public.credentials = NULL;
        this->public.backends = NULL;
-       this->public.attributes = NULL;
        this->public.sender= NULL;
        this->public.receiver = NULL;
        this->public.scheduler = NULL;
index 2b863f7d81c8080d5dd1938fa86f2aec8dda58c6..435232834f60aa01f108fb9b66bbdd2fbb6ab8b3 100644 (file)
@@ -159,7 +159,6 @@ typedef struct daemon_t daemon_t;
 #include <sa/ike_sa_manager.h>
 #include <sa/trap_manager.h>
 #include <config/backend_manager.h>
-#include <config/attributes/attribute_manager.h>
 #include <credentials/credential_manager.h>
 #include <sa/authenticators/eap/eap_manager.h>
 #include <sa/authenticators/eap/sim_manager.h>
@@ -220,11 +219,6 @@ struct daemon_t {
         */
        backend_manager_t *backends;
 
-       /**
-        * Manager for IKEv2 cfg payload attributes
-        */
-       attribute_manager_t *attributes;
-
        /**
         * Manager for the credential backends
         */
index fe65eab49955c32d9cdd4962696a265ae644d4c4..caba34a6c41bfc3ba9c401793dfef07861c1a108 100644 (file)
@@ -51,27 +51,6 @@ struct private_configuration_attribute_t {
        chunk_t attribute_value;
 };
 
-ENUM_BEGIN(configuration_attribute_type_names, INTERNAL_IP4_ADDRESS, INTERNAL_IP6_SUBNET,
-       "INTERNAL_IP4_ADDRESS",
-       "INTERNAL_IP4_NETMASK",
-       "INTERNAL_IP4_DNS",
-       "INTERNAL_IP4_NBNS",
-       "INTERNAL_ADDRESS_EXPIRY",
-       "INTERNAL_IP4_DHCP",
-       "APPLICATION_VERSION",
-       "INTERNAL_IP6_ADDRESS",
-       "INTERNAL_IP6_NETMASK",
-       "INTERNAL_IP6_DNS",
-       "INTERNAL_IP6_NBNS",
-       "INTERNAL_IP6_DHCP",
-       "INTERNAL_IP4_SUBNET",
-       "SUPPORTED_ATTRIBUTES",
-       "INTERNAL_IP6_SUBNET");
-ENUM_NEXT(configuration_attribute_type_names, INTERNAL_IP4_SERVER, INTERNAL_IP6_SERVER, INTERNAL_IP6_SUBNET,
-       "INTERNAL_IP4_SERVER",
-       "INTERNAL_IP6_SERVER");
-ENUM_END(configuration_attribute_type_names, INTERNAL_IP6_SERVER);
-
 /**
  * Encoding rules to parse or generate a configuration attribute.
  *
index f4201130b6c486abc12cbe70ec1e8d7c57b1f2e9..f30fbfa7247a88ffdc7309d83e117123a121a5cd 100644 (file)
 #ifndef CONFIGURATION_ATTRIBUTE_H_
 #define CONFIGURATION_ATTRIBUTE_H_
 
-typedef enum configuration_attribute_type_t configuration_attribute_type_t;
 typedef struct configuration_attribute_t configuration_attribute_t;
 
 #include <library.h>
+#include <attributes/attributes.h>
 #include <encoding/payloads/payload.h>
 
 
@@ -34,35 +34,6 @@ typedef struct configuration_attribute_t configuration_attribute_t;
  */
 #define CONFIGURATION_ATTRIBUTE_HEADER_LENGTH 4
 
-/**
- * Type of the attribute, as in IKEv2 RFC 3.15.1.
- */
-enum configuration_attribute_type_t {
-       INTERNAL_IP4_ADDRESS = 1,
-       INTERNAL_IP4_NETMASK = 2,
-       INTERNAL_IP4_DNS = 3,
-       INTERNAL_IP4_NBNS = 4,
-       INTERNAL_ADDRESS_EXPIRY = 5,
-       INTERNAL_IP4_DHCP = 6,
-       APPLICATION_VERSION = 7,
-       INTERNAL_IP6_ADDRESS = 8,
-       INTERNAL_IP6_NETMASK = 9,
-       INTERNAL_IP6_DNS = 10,
-       INTERNAL_IP6_NBNS = 11,
-       INTERNAL_IP6_DHCP = 12,
-       INTERNAL_IP4_SUBNET = 13,
-       SUPPORTED_ATTRIBUTES = 14,
-       INTERNAL_IP6_SUBNET = 15,
-       /* proprietary Microsoft attributes */
-       INTERNAL_IP4_SERVER = 23456,
-       INTERNAL_IP6_SERVER = 23457
-};
-
-/**
- * enum names for configuration_attribute_type_t.
- */
-extern enum_name_t *configuration_attribute_type_names;
-
 /**
  * Class representing an IKEv2-CONFIGURATION Attribute.
  *
index a3e83fe61bca6b5dcbc9a1be8f2aff6d475a3b15..6dfb102714e775cbd615bf1f0982fc26c8af6b24 100644 (file)
@@ -41,7 +41,7 @@ struct private_attr_plugin_t {
  */
 static void destroy(private_attr_plugin_t *this)
 {
-       charon->attributes->remove_provider(charon->attributes, &this->provider->provider);
+       lib->attributes->remove_provider(lib->attributes, &this->provider->provider);
        this->provider->destroy(this->provider);
        free(this);
 }
@@ -56,7 +56,7 @@ plugin_t *plugin_create()
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
 
        this->provider = attr_provider_create();
-       charon->attributes->add_provider(charon->attributes, &this->provider->provider);
+       lib->attributes->add_provider(lib->attributes, &this->provider->provider);
 
        return &this->public.plugin;
 }
index e867f2b20bb1354588059e2ed17479bec8b2d387..a41466718aa00eb5d996a29ad1a072004dfcb4f7 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef ATTR_PROVIDER_H_
 #define ATTR_PROVIDER_H_
 
-#include <config/attributes/attribute_provider.h>
+#include <attributes/attribute_provider.h>
 
 typedef struct attr_provider_t attr_provider_t;
 
index 7b9c10b65062bccf9006d3dc1b9dbb156298a7d7..7756b8e7afc104d7fda4d186017aeccf50d00a71 100644 (file)
@@ -43,7 +43,7 @@ struct private_nm_handler_t {
 /**
  * Implementation of attribute_handler_t.handle
  */
-static bool handle(private_nm_handler_t *this, ike_sa_t *ike_sa,
+static bool handle(private_nm_handler_t *this, identification_t *server,
                                   configuration_attribute_type_t type, chunk_t data)
 {
        linked_list_t *list;
@@ -134,8 +134,8 @@ nm_handler_t *nm_handler_create()
 {
        private_nm_handler_t *this = malloc_thing(private_nm_handler_t);
 
-       this->public.handler.handle = (bool(*)(attribute_handler_t*, ike_sa_t*, configuration_attribute_type_t, chunk_t))handle;
-       this->public.handler.release = (void(*)(attribute_handler_t*, ike_sa_t*, configuration_attribute_type_t, chunk_t))nop;
+       this->public.handler.handle = (bool(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))handle;
+       this->public.handler.release = (void(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))nop;
        this->public.create_enumerator = (enumerator_t*(*)(nm_handler_t*, configuration_attribute_type_t type))create_enumerator;
        this->public.reset = (void(*)(nm_handler_t*))reset;
        this->public.destroy = (void(*)(nm_handler_t*))destroy;
index 3904ce1f0f8a3db5e543e77273d274778a6c35c4..6c15ae6decf73536161112dedc3526c558510c5f 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef NM_HANDLER_H_
 #define NM_HANDLER_H_
 
-#include <config/attributes/attribute_handler.h>
+#include <attributes/attribute_handler.h>
 
 typedef struct nm_handler_t nm_handler_t;
 
index 46cc9c39e04c512de9d1ba67b410975f9c9f97e8..daf2cc66007684232490ce6294e57c7be286be05 100644 (file)
@@ -84,8 +84,8 @@ static void destroy(private_nm_plugin_t *this)
                g_object_unref(this->plugin);
        }
        charon->credentials->remove_set(charon->credentials, &this->creds->set);
+       lib->attributes->remove_handler(lib->attributes, &this->handler->handler);
        this->creds->destroy(this->creds);
-       charon->attributes->remove_handler(charon->attributes, &this->handler->handler);
        this->handler->destroy(this->handler);
        free(this);
 }
@@ -108,8 +108,8 @@ plugin_t *plugin_create()
 
        this->creds = nm_creds_create();
        this->handler = nm_handler_create();
+       lib->attributes->add_handler(lib->attributes, &this->handler->handler);
        charon->credentials->add_set(charon->credentials, &this->creds->set);
-       charon->attributes->add_handler(charon->attributes, &this->handler->handler);
        this->plugin = nm_strongswan_plugin_new(this->creds, this->handler);
        if (!this->plugin)
        {
index 86057ddbb1e59ede2356c9b688f48f694f1cd406..6f72546dda35e20a60b93bc1618a578ea84e910a 100644 (file)
@@ -46,7 +46,7 @@ struct private_resolve_handler_t {
 /**
  * Implementation of attribute_handler_t.handle
  */
-static bool handle(private_resolve_handler_t *this, ike_sa_t *ike_sa,
+static bool handle(private_resolve_handler_t *this, identification_t *server,
                                   configuration_attribute_type_t type, chunk_t data)
 {
        FILE *in, *out;
@@ -78,7 +78,7 @@ static bool handle(private_resolve_handler_t *this, ike_sa_t *ike_sa,
        {
                addr = host_create_from_chunk(family, data, 0);
                fprintf(out, "nameserver %H   # by strongSwan, from %Y\n",
-                               addr, ike_sa->get_other_id(ike_sa));
+                               addr, server);
                DBG1(DBG_IKE, "installing DNS server %H to %s", addr, this->file);
                addr->destroy(addr);
                handled = TRUE;
@@ -106,7 +106,7 @@ static bool handle(private_resolve_handler_t *this, ike_sa_t *ike_sa,
 /**
  * Implementation of attribute_handler_t.release
  */
-static void release(private_resolve_handler_t *this, ike_sa_t *ike_sa,
+static void release(private_resolve_handler_t *this, identification_t *server,
                                        configuration_attribute_type_t type, chunk_t data)
 {
        FILE *in, *out;
@@ -139,7 +139,7 @@ static void release(private_resolve_handler_t *this, ike_sa_t *ike_sa,
                        addr = host_create_from_chunk(family, data, 0);
                        snprintf(matcher, sizeof(matcher),
                                         "nameserver %H   # by strongSwan, from %Y\n",
-                                        addr, ike_sa->get_other_id(ike_sa));
+                                        addr, server);
 
                        /* copy all, but matching line */
                        while ((pos = fgets(line, sizeof(line), in)))
@@ -179,8 +179,8 @@ resolve_handler_t *resolve_handler_create()
 {
        private_resolve_handler_t *this = malloc_thing(private_resolve_handler_t);
 
-       this->public.handler.handle = (bool(*)(attribute_handler_t*, ike_sa_t*, configuration_attribute_type_t, chunk_t))handle;
-       this->public.handler.release = (void(*)(attribute_handler_t*, ike_sa_t*, configuration_attribute_type_t, chunk_t))release;
+       this->public.handler.handle = (bool(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))handle;
+       this->public.handler.release = (void(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))release;
        this->public.destroy = (void(*)(resolve_handler_t*))destroy;
 
        this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
index d56d06863c4edb80d1c2601682dcdb71b65f7f4c..8a2c77f538d4c9e2dcef8e2c669f95cd007b762c 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef RESOLVE_HANDLER_H_
 #define RESOLVE_HANDLER_H_
 
-#include <config/attributes/attribute_handler.h>
+#include <attributes/attribute_handler.h>
 
 typedef struct resolve_handler_t resolve_handler_t;
 
index 63cd9af6dba2b2d034f779b2ec8d239a7c2905f4..c564981ef94b9817393c3f0560abccda1245982e 100644 (file)
@@ -41,8 +41,7 @@ struct private_resolve_plugin_t {
  */
 static void destroy(private_resolve_plugin_t *this)
 {
-       charon->attributes->remove_handler(charon->attributes,
-                                                                          &this->handler->handler);
+       lib->attributes->remove_handler(lib->attributes, &this->handler->handler);
        this->handler->destroy(this->handler);
        free(this);
 }
@@ -56,7 +55,7 @@ plugin_t *plugin_create()
 
        this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
        this->handler = resolve_handler_create();
-       charon->attributes->add_handler(charon->attributes, &this->handler->handler);
+       lib->attributes->add_handler(lib->attributes, &this->handler->handler);
 
        return &this->public.plugin;
 }
index 358ab92af3c854b6dea1c0306de5cf7f98d561a9..27a39651ba8ac494ba6827f5e90ac3f418c3e90f 100644 (file)
@@ -21,7 +21,8 @@
 #ifndef SQL_ATTRIBUTE_H_
 #define SQL_ATTRIBUTE_H_
 
-#include <config/attributes/attribute_provider.h>
+#include <attributes/attribute_provider.h>
+#include <database/database.h>
 
 typedef struct sql_attribute_t sql_attribute_t;
 
index 65691cc00c5c6e5969ecf28842373f07fccf50ec..05cdad5597568fd49dc33fa5b75cc3073b342830 100644 (file)
@@ -66,8 +66,8 @@ static void destroy(private_sql_plugin_t *this)
 {
        charon->backends->remove_backend(charon->backends, &this->config->backend);
        charon->credentials->remove_set(charon->credentials, &this->cred->set);
-       charon->attributes->remove_provider(charon->attributes, &this->attribute->provider);
        charon->bus->remove_listener(charon->bus, &this->logger->listener);
+       lib->attributes->remove_provider(lib->attributes, &this->attribute->provider);
        this->config->destroy(this->config);
        this->cred->destroy(this->cred);
        this->attribute->destroy(this->attribute);
@@ -107,9 +107,9 @@ plugin_t *plugin_create()
        this->attribute = sql_attribute_create(this->db);
        this->logger = sql_logger_create(this->db);
 
+       lib->attributes->add_provider(lib->attributes, &this->attribute->provider);
        charon->backends->add_backend(charon->backends, &this->config->backend);
        charon->credentials->add_set(charon->credentials, &this->cred->set);
-       charon->attributes->add_provider(charon->attributes, &this->attribute->provider);
        charon->bus->add_listener(charon->bus, &this->logger->listener);
 
        return &this->public.plugin;
index 0bb8ae4bf189780a13b6dd0cf777b60df80ce028..cf6c950a6dc19f073778d7c29e4780a2d7296036 100644 (file)
@@ -22,7 +22,7 @@
 #define STROKE_ATTRIBUTE_H_
 
 #include <stroke_msg.h>
-#include <config/attributes/attribute_provider.h>
+#include <attributes/attribute_provider.h>
 
 typedef struct stroke_attribute_t stroke_attribute_t;
 
index 7ae00d118bbf50c99519b5229273f130a4190f2e..2faa2353ba639665ab37fb12777248e8b57ffd49 100644 (file)
@@ -625,7 +625,7 @@ static void destroy(private_stroke_socket_t *this)
        charon->credentials->remove_set(charon->credentials, &this->ca->set);
        charon->credentials->remove_set(charon->credentials, &this->cred->set);
        charon->backends->remove_backend(charon->backends, &this->config->backend);
-       charon->attributes->remove_provider(charon->attributes, &this->attribute->provider);
+       lib->attributes->remove_provider(lib->attributes, &this->attribute->provider);
        this->cred->destroy(this->cred);
        this->ca->destroy(this->ca);
        this->config->destroy(this->config);
@@ -660,7 +660,7 @@ stroke_socket_t *stroke_socket_create()
        charon->credentials->add_set(charon->credentials, &this->ca->set);
        charon->credentials->add_set(charon->credentials, &this->cred->set);
        charon->backends->add_backend(charon->backends, &this->config->backend);
-       charon->attributes->add_provider(charon->attributes, &this->attribute->provider);
+       lib->attributes->add_provider(lib->attributes, &this->attribute->provider);
 
        this->job = callback_job_create((callback_job_cb_t)receive,
                                                                        this, NULL, NULL);
index dc420dab15df2873a3468237eed1939d65046d38..c681b0180da61b6c0f6a61cde83a8262545d2e28 100644 (file)
@@ -1848,8 +1848,8 @@ static void add_configuration_attribute(private_ike_sa_t *this,
        attribute_entry_t *entry;
        attribute_handler_t *handler;
 
-       handler = charon->attributes->handle(charon->attributes,
-                                                                                &this->public, type, data);
+       handler = lib->attributes->handle(lib->attributes, this->other_id,
+                                                                         type, data);
        if (handler)
        {
                entry = malloc_thing(attribute_entry_t);
@@ -1962,8 +1962,8 @@ static void destroy(private_ike_sa_t *this)
        while (this->attributes->remove_last(this->attributes,
                                                                                 (void**)&entry) == SUCCESS)
        {
-               charon->attributes->release(charon->attributes, entry->handler,
-                                                                       &this->public, entry->type, entry->data);
+               lib->attributes->release(lib->attributes, entry->handler,
+                                                                this->other_id, entry->type, entry->data);
                free(entry->data.ptr);
                free(entry);
        }
@@ -1987,7 +1987,7 @@ static void destroy(private_ike_sa_t *this)
        {
                if (this->peer_cfg && this->peer_cfg->get_pool(this->peer_cfg))
                {
-                       charon->attributes->release_address(charon->attributes,
+                       lib->attributes->release_address(lib->attributes,
                                                                        this->peer_cfg->get_pool(this->peer_cfg),
                                                                        this->other_virtual_ip, this->other_id);
                }
index bb5779e50d5bb9b32fc4363669303cf5ecdeda7d..0e2340a6a1aabd57f82436f7b0f75e5d5a401726 100644 (file)
@@ -258,7 +258,7 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
                        DBG1(DBG_IKE, "peer requested virtual IP %H", this->virtual_ip);
                        if (config->get_pool(config))
                        {
-                               vip = charon->attributes->acquire_address(charon->attributes,
+                               vip = lib->attributes->acquire_address(lib->attributes,
                                                                        config->get_pool(config),
                                                                        this->ike_sa->get_other_id(this->ike_sa),
                                                                        this->virtual_ip);
@@ -281,8 +281,8 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
                        vip->destroy(vip);
 
                        /* if we add an IP, we also look for other attributes */
-                       enumerator = charon->attributes->create_attribute_enumerator(
-                               charon->attributes, this->ike_sa->get_other_id(this->ike_sa));
+                       enumerator = lib->attributes->create_attribute_enumerator(
+                                       lib->attributes, this->ike_sa->get_other_id(this->ike_sa));
                        while (enumerator->enumerate(enumerator, &type, &value))
                        {
                                ca = configuration_attribute_create();
index 5a53cc57c965065a5d5d4abdb37322f9aeb5ba31..b9565885795f9e5565275da842e7fcbcc1ccdcda 100644 (file)
@@ -10,6 +10,9 @@ printf_hook.c printf_hook.h \
 asn1/asn1.c asn1/asn1.h \
 asn1/asn1_parser.c asn1/asn1_parser.h \
 asn1/oid.c asn1/oid.h \
+attributes/attributes.c attributes/attributes.h \
+attributes/attribute_provider.h attributes/attribute_handler.h \
+attributes/attribute_manager.c attributes/attribute_manager.h \
 crypto/crypters/crypter.c crypto/crypters/crypter.h \
 crypto/hashers/hasher.h crypto/hashers/hasher.c \
 crypto/pkcs9.c crypto/pkcs9.h \
similarity index 81%
rename from src/charon/config/attributes/attribute_handler.h
rename to src/libstrongswan/attributes/attribute_handler.h
index d752d512e636192b1244b02754c42d55d2435b3a..fba40b24b02a904fd742945b5f4a863f2e958c76 100644 (file)
 #ifndef ATTRIBUTE_HANDLER_H_
 #define ATTRIBUTE_HANDLER_H_
 
-#include <sa/ike_sa.h>
-#include <encoding/payloads/configuration_attribute.h>
+#include <chunk.h>
+#include <utils/identification.h>
+
+#include "attributes.h"
 
 typedef struct attribute_handler_t attribute_handler_t;
 
@@ -37,21 +39,22 @@ struct attribute_handler_t {
         * After receiving a configuration attriubte, it is passed to each
         * attribute handler until it is handled.
         *
+        * @param server        server from which the attribute was received
         * @param type          type of configuration attribute to handle
         * @param data          associated attribute data
         * @return                      TRUE if attribute handled
         */
-       bool (*handle)(attribute_handler_t *this, ike_sa_t *ike_sa,
+       bool (*handle)(attribute_handler_t *this, identification_t *server,
                                   configuration_attribute_type_t type, chunk_t data);
 
        /**
         * Release an attribute handled during handle().
         *
         * A handler that handle()d an attribute gets a call to release() when the
-        * IKE_SA gets closed. Depending on the implementation, this is required
+        * connection gets closed. Depending on the implementation, this is required
         * to remove the attribute.
         */
-       void (*release)(attribute_handler_t *this, ike_sa_t *ike_sa,
+       void (*release)(attribute_handler_t *this, identification_t *server,
                                        configuration_attribute_type_t type, chunk_t data);
 };
 
similarity index 88%
rename from src/charon/config/attributes/attribute_manager.c
rename to src/libstrongswan/attributes/attribute_manager.c
index 86d7d0759bf553e655d9c9edf07cad942cb37ae6..e09c211dc45ae84048b9f0c5fce2025f2d0ed8e0 100644 (file)
@@ -15,7 +15,7 @@
 
 #include "attribute_manager.h"
 
-#include <daemon.h>
+#include <debug.h>
 #include <utils/linked_list.h>
 #include <utils/mutex.h>
 
@@ -73,7 +73,7 @@ static host_t* acquire_address(private_attribute_manager_t *this,
 
        if (!host)
        {
-               DBG1(DBG_CFG, "acquiring address from pool '%s' failed", pool);
+               DBG1("acquiring address from pool '%s' failed", pool);
        }
        return host;
 }
@@ -103,7 +103,7 @@ static void release_address(private_attribute_manager_t *this,
 
        if (!found)
        {
-               DBG1(DBG_CFG, "releasing address to pool '%s' failed", pool);
+               DBG1("releasing address to pool '%s' failed", pool);
        }
 }
 
@@ -156,8 +156,9 @@ static void remove_provider(private_attribute_manager_t *this,
  * Implementation of attribute_manager_t.handle
  */
 static attribute_handler_t* handle(private_attribute_manager_t *this,
-                                               ike_sa_t *ike_sa, configuration_attribute_type_t type,
-                                               chunk_t data)
+                                                                  identification_t *server,
+                                                                  configuration_attribute_type_t type,
+                                                                  chunk_t data)
 {
        enumerator_t *enumerator;
        attribute_handler_t *current, *handled = NULL;
@@ -166,7 +167,7 @@ static attribute_handler_t* handle(private_attribute_manager_t *this,
        enumerator = this->handlers->create_enumerator(this->handlers);
        while (enumerator->enumerate(enumerator, &current))
        {
-               if (current->handle(current, ike_sa, type, data))
+               if (current->handle(current, server, type, data))
                {
                        handled = current;
                        break;
@@ -177,7 +178,7 @@ static attribute_handler_t* handle(private_attribute_manager_t *this,
 
        if (!handled)
        {
-               DBG1(DBG_CFG, "handling %N attribute failed",
+               DBG1("handling %N attribute failed",
                         configuration_attribute_type_names, type);
        }
        return handled;
@@ -187,8 +188,9 @@ static attribute_handler_t* handle(private_attribute_manager_t *this,
  * Implementation of attribute_manager_t.release
  */
 static void release(private_attribute_manager_t *this,
-                                               attribute_handler_t *handler, ike_sa_t *ike_sa,
-                                               configuration_attribute_type_t type, chunk_t data)
+                                       attribute_handler_t *handler,
+                                       identification_t *server,
+                                       configuration_attribute_type_t type, chunk_t data)
 {
        enumerator_t *enumerator;
        attribute_handler_t *current;
@@ -199,7 +201,7 @@ static void release(private_attribute_manager_t *this,
        {
                if (current == handler)
                {
-                       current->release(current, ike_sa, type, data);
+                       current->release(current, server, type, data);
                        break;
                }
        }
@@ -249,13 +251,13 @@ attribute_manager_t *attribute_manager_create()
 
        this->public.acquire_address = (host_t*(*)(attribute_manager_t*, char*, identification_t*,host_t*))acquire_address;
        this->public.release_address = (void(*)(attribute_manager_t*, char *, host_t*, identification_t*))release_address;
-       this->public.create_attribute_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t *id))create_attribute_enumerator;
+       this->public.create_attribute_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t*))create_attribute_enumerator;
        this->public.add_provider = (void(*)(attribute_manager_t*, attribute_provider_t *provider))add_provider;
        this->public.remove_provider = (void(*)(attribute_manager_t*, attribute_provider_t *provider))remove_provider;
-       this->public.handle = (attribute_handler_t*(*)(attribute_manager_t*, ike_sa_t *ike_sa, configuration_attribute_type_t type, chunk_t data))handle;
-       this->public.release = (void(*)(attribute_manager_t*, attribute_handler_t *handler, ike_sa_t *ike_sa, configuration_attribute_type_t type, chunk_t data))release;
-       this->public.add_handler = (void(*)(attribute_manager_t*, attribute_handler_t *handler))add_handler;
-       this->public.remove_handler = (void(*)(attribute_manager_t*, attribute_handler_t *handler))remove_handler;
+       this->public.handle = (attribute_handler_t*(*)(attribute_manager_t*, identification_t*, configuration_attribute_type_t, chunk_t))handle;
+       this->public.release = (void(*)(attribute_manager_t*, attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))release;
+       this->public.add_handler = (void(*)(attribute_manager_t*, attribute_handler_t*))add_handler;
+       this->public.remove_handler = (void(*)(attribute_manager_t*, attribute_handler_t*))remove_handler;
        this->public.destroy = (void(*)(attribute_manager_t*))destroy;
 
        this->providers = linked_list_create();
similarity index 91%
rename from src/charon/config/attributes/attribute_manager.h
rename to src/libstrongswan/attributes/attribute_manager.h
index 68eb8b1bf66a28796dcde8fd99c783a88adb4085..ba194b5630be4b22f7c68ec6fc0a897221a2d003 100644 (file)
@@ -21,8 +21,8 @@
 #ifndef ATTRIBUTE_MANAGER_H_
 #define ATTRIBUTE_MANAGER_H_
 
-#include <config/attributes/attribute_provider.h>
-#include <config/attributes/attribute_handler.h>
+#include "attribute_provider.h"
+#include "attribute_handler.h"
 
 typedef struct attribute_manager_t attribute_manager_t;
 
@@ -85,24 +85,26 @@ struct attribute_manager_t {
        /**
         * Handle a configuration attribute by passing them to the handlers.
         *
-        * @param ike_sa                IKE_SA where attribute was received
+        * @param server                server from which the attribute was received
         * @param type                  type of configuration attribute
         * @param data                  associated attribute data
         * @return                              handler which handled this attribute, NULL if none
         */
-       attribute_handler_t* (*handle)(attribute_manager_t *this, ike_sa_t *ike_sa,
+       attribute_handler_t* (*handle)(attribute_manager_t *this,
+                                                       identification_t *server,
                                                        configuration_attribute_type_t type, chunk_t data);
 
        /**
         * Release an attribute previously handle()d by a handler.
         *
         * @param handler               handler returned by handle() for this attribute
-        * @param ike_sa                IKE_SA owning the attribute
+        * @param server                server from which the attribute was received
         * @param type                  type of attribute to release
         * @param data                  associated attribute data
         */
        void (*release)(attribute_manager_t *this, attribute_handler_t *handler,
-                                               ike_sa_t *ike_sa, configuration_attribute_type_t type,
+                                               identification_t *server,
+                                               configuration_attribute_type_t type,
                                                chunk_t data);
 
        /**
similarity index 98%
rename from src/charon/config/attributes/attribute_provider.h
rename to src/libstrongswan/attributes/attribute_provider.h
index b8825723d8022bc9500f7bc5fefac2d3403861bb..14721d9214fd877b821dd77ebd4a7928b127765b 100644 (file)
@@ -21,7 +21,6 @@
 #ifndef ATTRIBUTE_PROVIDER_H_
 #define ATTRIBUTE_PROVIDER_H_
 
-#include <library.h>
 #include <utils/host.h>
 #include <utils/identification.h>
 
diff --git a/src/libstrongswan/attributes/attributes.c b/src/libstrongswan/attributes/attributes.c
new file mode 100644 (file)
index 0000000..6ddf302
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2005-2006 Martin Willi
+ * Copyright (C) 2005 Jan Hutter
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+
+#include "attributes.h"
+
+ENUM_BEGIN(configuration_attribute_type_names, INTERNAL_IP4_ADDRESS, INTERNAL_IP6_SUBNET,
+       "INTERNAL_IP4_ADDRESS",
+       "INTERNAL_IP4_NETMASK",
+       "INTERNAL_IP4_DNS",
+       "INTERNAL_IP4_NBNS",
+       "INTERNAL_ADDRESS_EXPIRY",
+       "INTERNAL_IP4_DHCP",
+       "APPLICATION_VERSION",
+       "INTERNAL_IP6_ADDRESS",
+       "INTERNAL_IP6_NETMASK",
+       "INTERNAL_IP6_DNS",
+       "INTERNAL_IP6_NBNS",
+       "INTERNAL_IP6_DHCP",
+       "INTERNAL_IP4_SUBNET",
+       "SUPPORTED_ATTRIBUTES",
+       "INTERNAL_IP6_SUBNET");
+ENUM_NEXT(configuration_attribute_type_names, INTERNAL_IP4_SERVER, INTERNAL_IP6_SERVER, INTERNAL_IP6_SUBNET,
+       "INTERNAL_IP4_SERVER",
+       "INTERNAL_IP6_SERVER");
+ENUM_END(configuration_attribute_type_names, INTERNAL_IP6_SERVER);
+
diff --git a/src/libstrongswan/attributes/attributes.h b/src/libstrongswan/attributes/attributes.h
new file mode 100644 (file)
index 0000000..5365fd0
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2005-2006 Martin Willi
+ * Copyright (C) 2005 Jan Hutter
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup attributes attributes
+ * @{ @ingroup attributes
+ */
+
+#ifndef ATTRIBUTES_H_
+#define ATTRIBUTES_H_
+
+typedef enum configuration_attribute_type_t configuration_attribute_type_t;
+
+#include <enum.h>
+
+/**
+ * Type of the attribute, as in IKEv2 RFC 3.15.1 or IKEv1 ModeConfig.
+ */
+enum configuration_attribute_type_t {
+       INTERNAL_IP4_ADDRESS = 1,
+       INTERNAL_IP4_NETMASK = 2,
+       INTERNAL_IP4_DNS = 3,
+       INTERNAL_IP4_NBNS = 4,
+       INTERNAL_ADDRESS_EXPIRY = 5,
+       INTERNAL_IP4_DHCP = 6,
+       APPLICATION_VERSION = 7,
+       INTERNAL_IP6_ADDRESS = 8,
+       INTERNAL_IP6_NETMASK = 9,
+       INTERNAL_IP6_DNS = 10,
+       INTERNAL_IP6_NBNS = 11,
+       INTERNAL_IP6_DHCP = 12,
+       INTERNAL_IP4_SUBNET = 13,
+       SUPPORTED_ATTRIBUTES = 14,
+       INTERNAL_IP6_SUBNET = 15,
+       /* proprietary Microsoft attributes */
+       INTERNAL_IP4_SERVER = 23456,
+       INTERNAL_IP6_SERVER = 23457
+};
+
+/**
+ * enum names for configuration_attribute_type_t.
+ */
+extern enum_name_t *configuration_attribute_type_names;
+
+
+#endif /** ATTRIBUTES_H_ @}*/
index 001f5380966c88fae54e5667dfafeb91c09c0a8d..5aeb5c038deca9aef52e47bc1b3402629935b139 100644 (file)
@@ -67,6 +67,7 @@ void library_deinit()
        this->public.encoding->destroy(this->public.encoding);
        this->public.crypto->destroy(this->public.crypto);
        this->public.fetcher->destroy(this->public.fetcher);
+       this->public.attributes->destroy(this->public.attributes);
        this->public.db->destroy(this->public.db);
        this->public.printf_hook->destroy(this->public.printf_hook);
        if (this->public.integrity)
@@ -126,6 +127,7 @@ bool library_init(char *settings)
        this->public.creds = credential_factory_create();
        this->public.encoding = key_encoding_create();
        this->public.fetcher = fetcher_manager_create();
+       this->public.attributes = attribute_manager_create();
        this->public.db = database_factory_create();
        this->public.plugins = plugin_loader_create();
        this->public.integrity = NULL;
index c4c6d80d2f0f272d4f920b102b52574718406c87..2673afa4bb7ad642025b3af83a810612324de350 100644 (file)
@@ -60,6 +60,7 @@
 #include <plugins/plugin_loader.h>
 #include <crypto/crypto_factory.h>
 #include <fetcher/fetcher_manager.h>
+#include <attributes/attribute_manager.h>
 #include <database/database_factory.h>
 #include <credentials/credential_factory.h>
 #include <credentials/keys/key_encoding.h>
@@ -96,6 +97,11 @@ struct library_t {
         */
        fetcher_manager_t *fetcher;
 
+       /**
+        * manager for payload attributes
+        */
+       attribute_manager_t *attributes;
+
        /**
         * database construction factory
         */
index 315d80184a1d0cb5a7919198a28687d0117d8077..f5796154cf91073beea1f084fce458c2943c0b6a 100644 (file)
@@ -34,7 +34,7 @@ typedef struct host_t host_t;
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#include <library.h>
+#include <chunk.h>
 
 /**
  * Differences between two hosts. They differ in
index 20cfc902ba83ecda36608ebb7ca0c17a0f8fca14..dfb6465d7bee445c04a1120081af22a8f9297b67 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <asn1/oid.h>
 #include <asn1/asn1.h>
+#include <crypto/hashers/hasher.h>
 
 ENUM_BEGIN(id_match_names, ID_MATCH_NONE, ID_MATCH_MAX_WILDCARDS,
        "MATCH_NONE",
index a53ec3877bda79ab50fdf2f566edc3fbff094cb5..f619d0c44991bba46b32b9ec93887b8ff320e318 100644 (file)
@@ -29,7 +29,8 @@ typedef struct identification_t identification_t;
 typedef enum id_match_t id_match_t;
 typedef enum id_part_t id_part_t;
 
-#include <library.h>
+#include <chunk.h>
+#include <utils/enumerator.h>
 
 /**
  * Matches returned from identification_t.match