Attributes moved from libstrongswan to libhydra.
authorTobias Brunner <tobias@strongswan.org>
Wed, 24 Mar 2010 16:40:15 +0000 (17:40 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 24 Mar 2010 17:53:10 +0000 (18:53 +0100)
The attribute_manager_t instance is now located on the new hydra object
instead of the lib object.

19 files changed:
src/libcharon/daemon.h
src/libhydra/Makefile.am
src/libhydra/attributes/attribute_handler.h [new file with mode: 0644]
src/libhydra/attributes/attribute_manager.c [new file with mode: 0644]
src/libhydra/attributes/attribute_manager.h [new file with mode: 0644]
src/libhydra/attributes/attribute_provider.h [new file with mode: 0644]
src/libhydra/attributes/attributes.c [new file with mode: 0644]
src/libhydra/attributes/attributes.h [new file with mode: 0644]
src/libhydra/hydra.c
src/libhydra/hydra.h
src/libstrongswan/Makefile.am
src/libstrongswan/attributes/attribute_handler.h [deleted file]
src/libstrongswan/attributes/attribute_manager.c [deleted file]
src/libstrongswan/attributes/attribute_manager.h [deleted file]
src/libstrongswan/attributes/attribute_provider.h [deleted file]
src/libstrongswan/attributes/attributes.c [deleted file]
src/libstrongswan/attributes/attributes.h [deleted file]
src/libstrongswan/library.c
src/libstrongswan/library.h

index eb97a16..c1df00e 100644 (file)
@@ -28,9 +28,6 @@
  * @defgroup config config
  * @ingroup libcharon
  *
- * @defgroup attributes attributes
- * @ingroup config
- *
  * @defgroup control control
  * @ingroup libcharon
  *
index 35a807e..94d3968 100644 (file)
@@ -1,7 +1,10 @@
 lib_LTLIBRARIES = libhydra.la
 
 libhydra_la_SOURCES = \
-hydra.c hydra.h
+hydra.c hydra.h \
+attributes/attributes.c attributes/attributes.h \
+attributes/attribute_provider.h attributes/attribute_handler.h \
+attributes/attribute_manager.c attributes/attribute_manager.h
 
 libhydra_la_LIBADD =
 
diff --git a/src/libhydra/attributes/attribute_handler.h b/src/libhydra/attributes/attribute_handler.h
new file mode 100644 (file)
index 0000000..d042f47
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 Martin Willi
+ * 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 attribute_handler attribute_handler
+ * @{ @ingroup attributes
+ */
+
+#ifndef ATTRIBUTE_HANDLER_H_
+#define ATTRIBUTE_HANDLER_H_
+
+#include <chunk.h>
+#include <utils/host.h>
+#include <utils/identification.h>
+
+#include "attributes.h"
+
+typedef struct attribute_handler_t attribute_handler_t;
+
+/**
+ * Interface to handle configuration payload attributes.
+ */
+struct attribute_handler_t {
+
+       /**
+        * Handle a configuration attribute.
+        *
+        * 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, 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
+        * connection gets closed. Depending on the implementation, this is required
+        * to remove the attribute.
+        */
+       void (*release)(attribute_handler_t *this, identification_t *server,
+                                       configuration_attribute_type_t type, chunk_t data);
+
+       /**
+        * Enumerate attributes to request from a server.
+        *
+        * @param server                server identity to request attributes from
+        * @param vip                   virtual IP we are requesting, if any
+        * @return                              enumerator (configuration_attribute_type_t, chunk_t)
+        */
+       enumerator_t* (*create_attribute_enumerator)(attribute_handler_t *this,
+                                                                               identification_t *server, host_t *vip);
+};
+
+#endif /** ATTRIBUTE_HANDLER_H_ @}*/
diff --git a/src/libhydra/attributes/attribute_manager.c b/src/libhydra/attributes/attribute_manager.c
new file mode 100644 (file)
index 0000000..91fa1eb
--- /dev/null
@@ -0,0 +1,374 @@
+/*
+ * Copyright (C) 2008 Martin Willi
+ * 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 "attribute_manager.h"
+
+#include <debug.h>
+#include <utils/linked_list.h>
+#include <threading/rwlock.h>
+
+typedef struct private_attribute_manager_t private_attribute_manager_t;
+
+/**
+ * private data of attribute_manager
+ */
+struct private_attribute_manager_t {
+
+       /**
+        * public functions
+        */
+       attribute_manager_t public;
+
+       /**
+        * list of registered providers
+        */
+       linked_list_t *providers;
+
+       /**
+        * list of registered handlers
+        */
+       linked_list_t *handlers;
+
+       /**
+        * rwlock provider list
+        */
+       rwlock_t *lock;
+};
+
+/**
+ * Data to pass to enumerator filters
+ */
+typedef struct {
+       /** server/peer identity */
+       identification_t *id;
+       /** requesting/assigned virtual IP */
+       host_t *vip;
+} enum_data_t;
+
+/**
+ * Implementation of attribute_manager_t.acquire_address.
+ */
+static host_t* acquire_address(private_attribute_manager_t *this,
+                                                          char *pool, identification_t *id,
+                                                          host_t *requested)
+{
+       enumerator_t *enumerator;
+       attribute_provider_t *current;
+       host_t *host = NULL;
+
+       this->lock->read_lock(this->lock);
+       enumerator = this->providers->create_enumerator(this->providers);
+       while (enumerator->enumerate(enumerator, &current))
+       {
+               host = current->acquire_address(current, pool, id, requested);
+               if (host)
+               {
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+       this->lock->unlock(this->lock);
+
+       if (!host)
+       {
+               DBG1("acquiring address from pool '%s' failed", pool);
+       }
+       return host;
+}
+
+/**
+ * Implementation of attribute_manager_t.release_address.
+ */
+static void release_address(private_attribute_manager_t *this,
+                                                       char *pool, host_t *address, identification_t *id)
+{
+       enumerator_t *enumerator;
+       attribute_provider_t *current;
+       bool found = FALSE;
+
+       this->lock->read_lock(this->lock);
+       enumerator = this->providers->create_enumerator(this->providers);
+       while (enumerator->enumerate(enumerator, &current))
+       {
+               if (current->release_address(current, pool, address, id))
+               {
+                       found = TRUE;
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+       this->lock->unlock(this->lock);
+
+       if (!found)
+       {
+               DBG1("releasing address to pool '%s' failed", pool);
+       }
+}
+
+/**
+ * inner enumerator constructor for responder attributes
+ */
+static enumerator_t *responder_enum_create(attribute_provider_t *provider,
+                                                                                  enum_data_t *data)
+{
+       return provider->create_attribute_enumerator(provider, data->id, data->vip);
+}
+
+/**
+ * Implementation of attribute_manager_t.create_responder_enumerator
+ */
+static enumerator_t* create_responder_enumerator(
+                       private_attribute_manager_t *this, identification_t *id, host_t *vip)
+{
+       enum_data_t *data = malloc_thing(enum_data_t);
+
+       data->id = id;
+       data->vip = vip;
+       this->lock->read_lock(this->lock);
+       return enumerator_create_cleaner(
+                               enumerator_create_nested(
+                                       this->providers->create_enumerator(this->providers),
+                                       (void*)responder_enum_create, data, free),
+                               (void*)this->lock->unlock, this->lock);
+}
+
+/**
+ * Implementation of attribute_manager_t.add_provider.
+ */
+static void add_provider(private_attribute_manager_t *this,
+                                                attribute_provider_t *provider)
+{
+       this->lock->write_lock(this->lock);
+       this->providers->insert_last(this->providers, provider);
+       this->lock->unlock(this->lock);
+}
+
+/**
+ * Implementation of attribute_manager_t.remove_provider.
+ */
+static void remove_provider(private_attribute_manager_t *this,
+                                                       attribute_provider_t *provider)
+{
+       this->lock->write_lock(this->lock);
+       this->providers->remove(this->providers, provider, NULL);
+       this->lock->unlock(this->lock);
+}
+
+/**
+ * Implementation of attribute_manager_t.handle
+ */
+static attribute_handler_t* handle(private_attribute_manager_t *this,
+                                               identification_t *server, attribute_handler_t *handler,
+                                               configuration_attribute_type_t type, chunk_t data)
+{
+       enumerator_t *enumerator;
+       attribute_handler_t *current, *handled = NULL;
+
+       this->lock->read_lock(this->lock);
+
+       /* try to find the passed handler */
+       enumerator = this->handlers->create_enumerator(this->handlers);
+       while (enumerator->enumerate(enumerator, &current))
+       {
+               if (current == handler && current->handle(current, server, type, data))
+               {
+                       handled = current;
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+       if (!handled)
+       {       /* handler requesting this attribute not found, try any other */
+               enumerator = this->handlers->create_enumerator(this->handlers);
+               while (enumerator->enumerate(enumerator, &current))
+               {
+                       if (current->handle(current, server, type, data))
+                       {
+                               handled = current;
+                               break;
+                       }
+               }
+               enumerator->destroy(enumerator);
+       }
+       this->lock->unlock(this->lock);
+
+       if (!handled)
+       {
+               DBG1("handling %N attribute failed",
+                        configuration_attribute_type_names, type);
+       }
+       return handled;
+}
+
+/**
+ * Implementation of attribute_manager_t.release
+ */
+static void release(private_attribute_manager_t *this,
+                                       attribute_handler_t *handler,
+                                       identification_t *server,
+                                       configuration_attribute_type_t type, chunk_t data)
+{
+       enumerator_t *enumerator;
+       attribute_handler_t *current;
+
+       this->lock->read_lock(this->lock);
+       enumerator = this->handlers->create_enumerator(this->handlers);
+       while (enumerator->enumerate(enumerator, &current))
+       {
+               if (current == handler)
+               {
+                       current->release(current, server, type, data);
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+       this->lock->unlock(this->lock);
+}
+
+/**
+ * Enumerator implementation to enumerate nested initiator attributes
+ */
+typedef struct {
+       /** implements enumerator_t */
+       enumerator_t public;
+       /** back ref */
+       private_attribute_manager_t *this;
+       /** currently processing handler */
+       attribute_handler_t *handler;
+       /** outer enumerator over handlers */
+       enumerator_t *outer;
+       /** inner enumerator over current handlers attributes */
+       enumerator_t *inner;
+       /** server ID we want attributes for */
+       identification_t *id;
+       /** virtual IP we are requesting along with attriubutes */
+       host_t *vip;
+} initiator_enumerator_t;
+
+/**
+ * Enumerator implementation for initiator attributes
+ */
+static bool initiator_enumerate(initiator_enumerator_t *this,
+                                                               attribute_handler_t **handler,
+                                                               configuration_attribute_type_t *type,
+                                                               chunk_t *value)
+{
+       /* enumerate inner attributes using outer handler enumerator */
+       while (!this->inner || !this->inner->enumerate(this->inner, type, value))
+       {
+               if (!this->outer->enumerate(this->outer, &this->handler))
+               {
+                       return FALSE;
+               }
+               DESTROY_IF(this->inner);
+               this->inner = this->handler->create_attribute_enumerator(this->handler,
+                                                                                                               this->id, this->vip);
+       }
+       /* inject the handler as additional attribute */
+       *handler = this->handler;
+       return TRUE;
+}
+
+/**
+ * Cleanup function of initiator attribute enumerator
+ */
+static void initiator_destroy(initiator_enumerator_t *this)
+{
+       this->this->lock->unlock(this->this->lock);
+       this->outer->destroy(this->outer);
+       DESTROY_IF(this->inner);
+       free(this);
+}
+
+/**
+ * Implementation of attribute_manager_t.create_initiator_enumerator
+ */
+static enumerator_t* create_initiator_enumerator(
+               private_attribute_manager_t *this, identification_t *id, host_t *vip)
+{
+       initiator_enumerator_t *enumerator = malloc_thing(initiator_enumerator_t);
+
+       this->lock->read_lock(this->lock);
+       enumerator->public.enumerate = (void*)initiator_enumerate;
+       enumerator->public.destroy = (void*)initiator_destroy;
+       enumerator->this = this;
+       enumerator->id = id;
+       enumerator->vip = vip;
+       enumerator->outer = this->handlers->create_enumerator(this->handlers);
+       enumerator->inner = NULL;
+       enumerator->handler = NULL;
+
+       return &enumerator->public;
+}
+
+/**
+ * Implementation of attribute_manager_t.add_handler
+ */
+static void add_handler(private_attribute_manager_t *this,
+                                               attribute_handler_t *handler)
+{
+       this->lock->write_lock(this->lock);
+       this->handlers->insert_last(this->handlers, handler);
+       this->lock->unlock(this->lock);
+}
+
+/**
+ * Implementation of attribute_manager_t.remove_handler
+ */
+static void remove_handler(private_attribute_manager_t *this,
+                                               attribute_handler_t *handler)
+{
+       this->lock->write_lock(this->lock);
+       this->handlers->remove(this->handlers, handler, NULL);
+       this->lock->unlock(this->lock);
+}
+
+/**
+ * Implementation of attribute_manager_t.destroy
+ */
+static void destroy(private_attribute_manager_t *this)
+{
+       this->providers->destroy(this->providers);
+       this->handlers->destroy(this->handlers);
+       this->lock->destroy(this->lock);
+       free(this);
+}
+
+/*
+ * see header file
+ */
+attribute_manager_t *attribute_manager_create()
+{
+       private_attribute_manager_t *this = malloc_thing(private_attribute_manager_t);
+
+       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_responder_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t*, host_t*))create_responder_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*,identification_t*, attribute_handler_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.create_initiator_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t*, host_t*))create_initiator_enumerator;
+       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();
+       this->handlers = linked_list_create();
+       this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
+
+       return &this->public;
+}
+
diff --git a/src/libhydra/attributes/attribute_manager.h b/src/libhydra/attributes/attribute_manager.h
new file mode 100644 (file)
index 0000000..6426623
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2008-2009 Martin Willi
+ * 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 attribute_manager attribute_manager
+ * @{ @ingroup attributes
+ */
+
+#ifndef ATTRIBUTE_MANAGER_H_
+#define ATTRIBUTE_MANAGER_H_
+
+#include "attribute_provider.h"
+#include "attribute_handler.h"
+
+typedef struct attribute_manager_t attribute_manager_t;
+
+/**
+ * The attribute manager hands out attributes or handles them.
+ *
+ * The attribute manager manages both, attribute providers and attribute
+ * handlers. Attribute providers are responsible to hand out attributes if
+ * a connecting peer requests them. Handlers handle such attributes if they
+ * are received on the requesting peer.
+ */
+struct attribute_manager_t {
+
+       /**
+        * Acquire a virtual IP address to assign to a peer.
+        *
+        * @param pool                  pool name to acquire address from
+        * @param id                    peer identity to get address forua
+        * @param requested             IP in configuration request
+        * @return                              allocated address, NULL to serve none
+        */
+       host_t* (*acquire_address)(attribute_manager_t *this,
+                                                          char *pool, identification_t *id,
+                                                          host_t *requested);
+
+       /**
+        * Release a previously acquired address.
+        *
+        * @param pool                  pool name from which the address was acquired
+        * @param address               address to release
+        * @param id                    peer identity to get address for
+        */
+       void (*release_address)(attribute_manager_t *this,
+                                                       char *pool, host_t *address, identification_t *id);
+
+       /**
+        * Create an enumerator over attributes to hand out to a peer.
+        *
+        * @param id                    peer identity to hand out attributes to
+        * @param vip                   virtual IP to assign to peer, if any
+        * @return                              enumerator (configuration_attribute_type_t, chunk_t)
+        */
+       enumerator_t* (*create_responder_enumerator)(attribute_manager_t *this,
+                                                                                       identification_t *id, host_t *vip);
+
+       /**
+        * Register an attribute provider to the manager.
+        *
+        * @param provider              attribute provider to register
+        */
+       void (*add_provider)(attribute_manager_t *this,
+                                                attribute_provider_t *provider);
+       /**
+        * Unregister an attribute provider from the manager.
+        *
+        * @param provider              attribute provider to unregister
+        */
+       void (*remove_provider)(attribute_manager_t *this,
+                                                       attribute_provider_t *provider);
+
+       /**
+        * Handle a configuration attribute by passing them to the handlers.
+        *
+        * @param server                server from which the attribute was received
+        * @param handler               handler we requested the attribute for, if any
+        * @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,
+                                               identification_t *server, attribute_handler_t *handler,
+                                               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 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,
+                                               identification_t *server,
+                                               configuration_attribute_type_t type,
+                                               chunk_t data);
+
+       /**
+        * Create an enumerator over attributes to request from server.
+        *
+        * @param id                    server identity to hand out attributes to
+        * @param vip                   virtual IP going to request, if any
+        * @return                              enumerator (attribute_handler_t, ca_type_t, chunk_t)
+        */
+       enumerator_t* (*create_initiator_enumerator)(attribute_manager_t *this,
+                                                                                       identification_t *id, host_t *vip);
+
+       /**
+        * Register an attribute handler to the manager.
+        *
+        * @param handler               attribute handler to register
+        */
+       void (*add_handler)(attribute_manager_t *this,
+                                               attribute_handler_t *handler);
+
+       /**
+        * Unregister an attribute handler from the manager.
+        *
+        * @param handler               attribute handler to unregister
+        */
+       void (*remove_handler)(attribute_manager_t *this,
+                                                  attribute_handler_t *handler);
+
+       /**
+        * Destroy a attribute_manager instance.
+        */
+       void (*destroy)(attribute_manager_t *this);
+};
+
+/**
+ * Create a attribute_manager instance.
+ */
+attribute_manager_t *attribute_manager_create();
+
+#endif /** ATTRIBUTE_MANAGER_H_ @}*/
diff --git a/src/libhydra/attributes/attribute_provider.h b/src/libhydra/attributes/attribute_provider.h
new file mode 100644 (file)
index 0000000..f8485cc
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2008 Martin Willi
+ * 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 attribute_provider attribute_provider
+ * @{ @ingroup attributes
+ */
+
+#ifndef ATTRIBUTE_PROVIDER_H_
+#define ATTRIBUTE_PROVIDER_H_
+
+#include <utils/host.h>
+#include <utils/identification.h>
+
+typedef struct attribute_provider_t attribute_provider_t;
+
+/**
+ * Interface to provide attributes to peers through attribute manager.
+ */
+struct attribute_provider_t {
+
+       /**
+        * Acquire a virtual IP address to assign to a peer.
+        *
+        * @param pool                  name of the pool to acquire address from
+        * @param id                    peer ID
+        * @param requested             IP in configuration request
+        * @return                              allocated address, NULL to serve none
+        */
+       host_t* (*acquire_address)(attribute_provider_t *this,
+                                                          char *pool, identification_t *id,
+                                                          host_t *requested);
+       /**
+        * Release a previously acquired address.
+        *
+        * @param pool                  name of the pool this address was acquired from
+        * @param address               address to release
+        * @param id                    peer ID
+        * @return                              TRUE if the address has been released by the provider
+        */
+       bool (*release_address)(attribute_provider_t *this,
+                                                       char *pool, host_t *address, identification_t *id);
+
+       /**
+        * Create an enumerator over attributes to hand out to a peer.
+        *
+        * @param id                    peer ID
+        * @param vip                   virtual IP to assign to peer, if any
+        * @return                              enumerator (configuration_attribute_type_t, chunk_t)
+        */
+       enumerator_t* (*create_attribute_enumerator)(attribute_provider_t *this,
+                                                                                       identification_t *id, host_t *vip);
+};
+
+#endif /** ATTRIBUTE_PROVIDER_H_ @}*/
diff --git a/src/libhydra/attributes/attributes.c b/src/libhydra/attributes/attributes.c
new file mode 100644 (file)
index 0000000..83feed1
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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_PREFIX,
+       "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",
+       "MIP6_HOME_PREFIX",
+       "INTERNAL_IP6_LINK",
+       "INTERNAL_IP6_PREFIX");
+ENUM_NEXT(configuration_attribute_type_names, INTERNAL_IP4_SERVER, INTERNAL_IP6_SERVER, INTERNAL_IP6_PREFIX,
+       "INTERNAL_IP4_SERVER",
+       "INTERNAL_IP6_SERVER");
+ENUM_END(configuration_attribute_type_names, INTERNAL_IP6_SERVER);
+
diff --git a/src/libhydra/attributes/attributes.h b/src/libhydra/attributes/attributes.h
new file mode 100644 (file)
index 0000000..f4a396f
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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_g 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,
+       MIP6_HOME_PREFIX = 16,
+       INTERNAL_IP6_LINK = 17,
+       INTERNAL_IP6_PREFIX = 18,
+       /* 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 edc48f7..8775df0 100644 (file)
 
 #include <debug.h>
 
+typedef struct private_hydra_t private_hydra_t;
+
+/**
+ * Private additions to hydra_t.
+ */
+struct private_hydra_t {
+       /**
+        * Public members of hydra_t.
+        */
+       hydra_t public;
+};
+
+/**
+ * Single instance of hydra_t.
+ */
+hydra_t *hydra;
+
 /**
  * Described in header.
  */
 void libhydra_deinit()
 {
+       private_hydra_t *this = (private_hydra_t*)hydra;
+       this->public.attributes->destroy(this->public.attributes);
+       free(this);
+       hydra = NULL;
 }
 
 /**
@@ -29,6 +50,15 @@ void libhydra_deinit()
  */
 bool libhydra_init()
 {
+       private_hydra_t *this;
+
+       INIT(this,
+               .public = {
+                       .attributes = attribute_manager_create(),
+               },
+       );
+       hydra = &this->public;
+
        if (lib->integrity &&
                !lib->integrity->check(lib->integrity, "libhydra", libhydra_init))
        {
index acbaa01..2d8ef9c 100644 (file)
@@ -16,6 +16,9 @@
 /**
  * @defgroup libhydra libhydra
  *
+ * @defgroup attributes attributes
+ * @ingroup libhydra
+ *
  * @defgroup hplugins plugins
  * @ingroup libhydra
  *
 #ifndef HYDRA_H_
 #define HYDRA_H_
 
+typedef struct hydra_t hydra_t;
+
+#include <attributes/attribute_manager.h>
+
 #include <library.h>
 
 /**
+ * IKE Daemon support object.
+ */
+struct hydra_t {
+       /**
+        * manager for payload attributes
+        */
+       attribute_manager_t *attributes;
+};
+
+/**
+ * The single instance of hydra_t. Set between calls to libhydra_init() and
+ * libhydra_deinit() calls.
+ */
+extern hydra_t *hydra;
+
+/**
  * Initialize libhydra.
  * @return                             FALSE if integrity check failed
  */
index 5620ff7..157d37b 100644 (file)
@@ -10,9 +10,6 @@ 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 \
diff --git a/src/libstrongswan/attributes/attribute_handler.h b/src/libstrongswan/attributes/attribute_handler.h
deleted file mode 100644 (file)
index d042f47..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2009 Martin Willi
- * 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 attribute_handler attribute_handler
- * @{ @ingroup attributes
- */
-
-#ifndef ATTRIBUTE_HANDLER_H_
-#define ATTRIBUTE_HANDLER_H_
-
-#include <chunk.h>
-#include <utils/host.h>
-#include <utils/identification.h>
-
-#include "attributes.h"
-
-typedef struct attribute_handler_t attribute_handler_t;
-
-/**
- * Interface to handle configuration payload attributes.
- */
-struct attribute_handler_t {
-
-       /**
-        * Handle a configuration attribute.
-        *
-        * 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, 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
-        * connection gets closed. Depending on the implementation, this is required
-        * to remove the attribute.
-        */
-       void (*release)(attribute_handler_t *this, identification_t *server,
-                                       configuration_attribute_type_t type, chunk_t data);
-
-       /**
-        * Enumerate attributes to request from a server.
-        *
-        * @param server                server identity to request attributes from
-        * @param vip                   virtual IP we are requesting, if any
-        * @return                              enumerator (configuration_attribute_type_t, chunk_t)
-        */
-       enumerator_t* (*create_attribute_enumerator)(attribute_handler_t *this,
-                                                                               identification_t *server, host_t *vip);
-};
-
-#endif /** ATTRIBUTE_HANDLER_H_ @}*/
diff --git a/src/libstrongswan/attributes/attribute_manager.c b/src/libstrongswan/attributes/attribute_manager.c
deleted file mode 100644 (file)
index 91fa1eb..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright (C) 2008 Martin Willi
- * 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 "attribute_manager.h"
-
-#include <debug.h>
-#include <utils/linked_list.h>
-#include <threading/rwlock.h>
-
-typedef struct private_attribute_manager_t private_attribute_manager_t;
-
-/**
- * private data of attribute_manager
- */
-struct private_attribute_manager_t {
-
-       /**
-        * public functions
-        */
-       attribute_manager_t public;
-
-       /**
-        * list of registered providers
-        */
-       linked_list_t *providers;
-
-       /**
-        * list of registered handlers
-        */
-       linked_list_t *handlers;
-
-       /**
-        * rwlock provider list
-        */
-       rwlock_t *lock;
-};
-
-/**
- * Data to pass to enumerator filters
- */
-typedef struct {
-       /** server/peer identity */
-       identification_t *id;
-       /** requesting/assigned virtual IP */
-       host_t *vip;
-} enum_data_t;
-
-/**
- * Implementation of attribute_manager_t.acquire_address.
- */
-static host_t* acquire_address(private_attribute_manager_t *this,
-                                                          char *pool, identification_t *id,
-                                                          host_t *requested)
-{
-       enumerator_t *enumerator;
-       attribute_provider_t *current;
-       host_t *host = NULL;
-
-       this->lock->read_lock(this->lock);
-       enumerator = this->providers->create_enumerator(this->providers);
-       while (enumerator->enumerate(enumerator, &current))
-       {
-               host = current->acquire_address(current, pool, id, requested);
-               if (host)
-               {
-                       break;
-               }
-       }
-       enumerator->destroy(enumerator);
-       this->lock->unlock(this->lock);
-
-       if (!host)
-       {
-               DBG1("acquiring address from pool '%s' failed", pool);
-       }
-       return host;
-}
-
-/**
- * Implementation of attribute_manager_t.release_address.
- */
-static void release_address(private_attribute_manager_t *this,
-                                                       char *pool, host_t *address, identification_t *id)
-{
-       enumerator_t *enumerator;
-       attribute_provider_t *current;
-       bool found = FALSE;
-
-       this->lock->read_lock(this->lock);
-       enumerator = this->providers->create_enumerator(this->providers);
-       while (enumerator->enumerate(enumerator, &current))
-       {
-               if (current->release_address(current, pool, address, id))
-               {
-                       found = TRUE;
-                       break;
-               }
-       }
-       enumerator->destroy(enumerator);
-       this->lock->unlock(this->lock);
-
-       if (!found)
-       {
-               DBG1("releasing address to pool '%s' failed", pool);
-       }
-}
-
-/**
- * inner enumerator constructor for responder attributes
- */
-static enumerator_t *responder_enum_create(attribute_provider_t *provider,
-                                                                                  enum_data_t *data)
-{
-       return provider->create_attribute_enumerator(provider, data->id, data->vip);
-}
-
-/**
- * Implementation of attribute_manager_t.create_responder_enumerator
- */
-static enumerator_t* create_responder_enumerator(
-                       private_attribute_manager_t *this, identification_t *id, host_t *vip)
-{
-       enum_data_t *data = malloc_thing(enum_data_t);
-
-       data->id = id;
-       data->vip = vip;
-       this->lock->read_lock(this->lock);
-       return enumerator_create_cleaner(
-                               enumerator_create_nested(
-                                       this->providers->create_enumerator(this->providers),
-                                       (void*)responder_enum_create, data, free),
-                               (void*)this->lock->unlock, this->lock);
-}
-
-/**
- * Implementation of attribute_manager_t.add_provider.
- */
-static void add_provider(private_attribute_manager_t *this,
-                                                attribute_provider_t *provider)
-{
-       this->lock->write_lock(this->lock);
-       this->providers->insert_last(this->providers, provider);
-       this->lock->unlock(this->lock);
-}
-
-/**
- * Implementation of attribute_manager_t.remove_provider.
- */
-static void remove_provider(private_attribute_manager_t *this,
-                                                       attribute_provider_t *provider)
-{
-       this->lock->write_lock(this->lock);
-       this->providers->remove(this->providers, provider, NULL);
-       this->lock->unlock(this->lock);
-}
-
-/**
- * Implementation of attribute_manager_t.handle
- */
-static attribute_handler_t* handle(private_attribute_manager_t *this,
-                                               identification_t *server, attribute_handler_t *handler,
-                                               configuration_attribute_type_t type, chunk_t data)
-{
-       enumerator_t *enumerator;
-       attribute_handler_t *current, *handled = NULL;
-
-       this->lock->read_lock(this->lock);
-
-       /* try to find the passed handler */
-       enumerator = this->handlers->create_enumerator(this->handlers);
-       while (enumerator->enumerate(enumerator, &current))
-       {
-               if (current == handler && current->handle(current, server, type, data))
-               {
-                       handled = current;
-                       break;
-               }
-       }
-       enumerator->destroy(enumerator);
-       if (!handled)
-       {       /* handler requesting this attribute not found, try any other */
-               enumerator = this->handlers->create_enumerator(this->handlers);
-               while (enumerator->enumerate(enumerator, &current))
-               {
-                       if (current->handle(current, server, type, data))
-                       {
-                               handled = current;
-                               break;
-                       }
-               }
-               enumerator->destroy(enumerator);
-       }
-       this->lock->unlock(this->lock);
-
-       if (!handled)
-       {
-               DBG1("handling %N attribute failed",
-                        configuration_attribute_type_names, type);
-       }
-       return handled;
-}
-
-/**
- * Implementation of attribute_manager_t.release
- */
-static void release(private_attribute_manager_t *this,
-                                       attribute_handler_t *handler,
-                                       identification_t *server,
-                                       configuration_attribute_type_t type, chunk_t data)
-{
-       enumerator_t *enumerator;
-       attribute_handler_t *current;
-
-       this->lock->read_lock(this->lock);
-       enumerator = this->handlers->create_enumerator(this->handlers);
-       while (enumerator->enumerate(enumerator, &current))
-       {
-               if (current == handler)
-               {
-                       current->release(current, server, type, data);
-                       break;
-               }
-       }
-       enumerator->destroy(enumerator);
-       this->lock->unlock(this->lock);
-}
-
-/**
- * Enumerator implementation to enumerate nested initiator attributes
- */
-typedef struct {
-       /** implements enumerator_t */
-       enumerator_t public;
-       /** back ref */
-       private_attribute_manager_t *this;
-       /** currently processing handler */
-       attribute_handler_t *handler;
-       /** outer enumerator over handlers */
-       enumerator_t *outer;
-       /** inner enumerator over current handlers attributes */
-       enumerator_t *inner;
-       /** server ID we want attributes for */
-       identification_t *id;
-       /** virtual IP we are requesting along with attriubutes */
-       host_t *vip;
-} initiator_enumerator_t;
-
-/**
- * Enumerator implementation for initiator attributes
- */
-static bool initiator_enumerate(initiator_enumerator_t *this,
-                                                               attribute_handler_t **handler,
-                                                               configuration_attribute_type_t *type,
-                                                               chunk_t *value)
-{
-       /* enumerate inner attributes using outer handler enumerator */
-       while (!this->inner || !this->inner->enumerate(this->inner, type, value))
-       {
-               if (!this->outer->enumerate(this->outer, &this->handler))
-               {
-                       return FALSE;
-               }
-               DESTROY_IF(this->inner);
-               this->inner = this->handler->create_attribute_enumerator(this->handler,
-                                                                                                               this->id, this->vip);
-       }
-       /* inject the handler as additional attribute */
-       *handler = this->handler;
-       return TRUE;
-}
-
-/**
- * Cleanup function of initiator attribute enumerator
- */
-static void initiator_destroy(initiator_enumerator_t *this)
-{
-       this->this->lock->unlock(this->this->lock);
-       this->outer->destroy(this->outer);
-       DESTROY_IF(this->inner);
-       free(this);
-}
-
-/**
- * Implementation of attribute_manager_t.create_initiator_enumerator
- */
-static enumerator_t* create_initiator_enumerator(
-               private_attribute_manager_t *this, identification_t *id, host_t *vip)
-{
-       initiator_enumerator_t *enumerator = malloc_thing(initiator_enumerator_t);
-
-       this->lock->read_lock(this->lock);
-       enumerator->public.enumerate = (void*)initiator_enumerate;
-       enumerator->public.destroy = (void*)initiator_destroy;
-       enumerator->this = this;
-       enumerator->id = id;
-       enumerator->vip = vip;
-       enumerator->outer = this->handlers->create_enumerator(this->handlers);
-       enumerator->inner = NULL;
-       enumerator->handler = NULL;
-
-       return &enumerator->public;
-}
-
-/**
- * Implementation of attribute_manager_t.add_handler
- */
-static void add_handler(private_attribute_manager_t *this,
-                                               attribute_handler_t *handler)
-{
-       this->lock->write_lock(this->lock);
-       this->handlers->insert_last(this->handlers, handler);
-       this->lock->unlock(this->lock);
-}
-
-/**
- * Implementation of attribute_manager_t.remove_handler
- */
-static void remove_handler(private_attribute_manager_t *this,
-                                               attribute_handler_t *handler)
-{
-       this->lock->write_lock(this->lock);
-       this->handlers->remove(this->handlers, handler, NULL);
-       this->lock->unlock(this->lock);
-}
-
-/**
- * Implementation of attribute_manager_t.destroy
- */
-static void destroy(private_attribute_manager_t *this)
-{
-       this->providers->destroy(this->providers);
-       this->handlers->destroy(this->handlers);
-       this->lock->destroy(this->lock);
-       free(this);
-}
-
-/*
- * see header file
- */
-attribute_manager_t *attribute_manager_create()
-{
-       private_attribute_manager_t *this = malloc_thing(private_attribute_manager_t);
-
-       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_responder_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t*, host_t*))create_responder_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*,identification_t*, attribute_handler_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.create_initiator_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t*, host_t*))create_initiator_enumerator;
-       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();
-       this->handlers = linked_list_create();
-       this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
-
-       return &this->public;
-}
-
diff --git a/src/libstrongswan/attributes/attribute_manager.h b/src/libstrongswan/attributes/attribute_manager.h
deleted file mode 100644 (file)
index 6426623..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2008-2009 Martin Willi
- * 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 attribute_manager attribute_manager
- * @{ @ingroup attributes
- */
-
-#ifndef ATTRIBUTE_MANAGER_H_
-#define ATTRIBUTE_MANAGER_H_
-
-#include "attribute_provider.h"
-#include "attribute_handler.h"
-
-typedef struct attribute_manager_t attribute_manager_t;
-
-/**
- * The attribute manager hands out attributes or handles them.
- *
- * The attribute manager manages both, attribute providers and attribute
- * handlers. Attribute providers are responsible to hand out attributes if
- * a connecting peer requests them. Handlers handle such attributes if they
- * are received on the requesting peer.
- */
-struct attribute_manager_t {
-
-       /**
-        * Acquire a virtual IP address to assign to a peer.
-        *
-        * @param pool                  pool name to acquire address from
-        * @param id                    peer identity to get address forua
-        * @param requested             IP in configuration request
-        * @return                              allocated address, NULL to serve none
-        */
-       host_t* (*acquire_address)(attribute_manager_t *this,
-                                                          char *pool, identification_t *id,
-                                                          host_t *requested);
-
-       /**
-        * Release a previously acquired address.
-        *
-        * @param pool                  pool name from which the address was acquired
-        * @param address               address to release
-        * @param id                    peer identity to get address for
-        */
-       void (*release_address)(attribute_manager_t *this,
-                                                       char *pool, host_t *address, identification_t *id);
-
-       /**
-        * Create an enumerator over attributes to hand out to a peer.
-        *
-        * @param id                    peer identity to hand out attributes to
-        * @param vip                   virtual IP to assign to peer, if any
-        * @return                              enumerator (configuration_attribute_type_t, chunk_t)
-        */
-       enumerator_t* (*create_responder_enumerator)(attribute_manager_t *this,
-                                                                                       identification_t *id, host_t *vip);
-
-       /**
-        * Register an attribute provider to the manager.
-        *
-        * @param provider              attribute provider to register
-        */
-       void (*add_provider)(attribute_manager_t *this,
-                                                attribute_provider_t *provider);
-       /**
-        * Unregister an attribute provider from the manager.
-        *
-        * @param provider              attribute provider to unregister
-        */
-       void (*remove_provider)(attribute_manager_t *this,
-                                                       attribute_provider_t *provider);
-
-       /**
-        * Handle a configuration attribute by passing them to the handlers.
-        *
-        * @param server                server from which the attribute was received
-        * @param handler               handler we requested the attribute for, if any
-        * @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,
-                                               identification_t *server, attribute_handler_t *handler,
-                                               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 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,
-                                               identification_t *server,
-                                               configuration_attribute_type_t type,
-                                               chunk_t data);
-
-       /**
-        * Create an enumerator over attributes to request from server.
-        *
-        * @param id                    server identity to hand out attributes to
-        * @param vip                   virtual IP going to request, if any
-        * @return                              enumerator (attribute_handler_t, ca_type_t, chunk_t)
-        */
-       enumerator_t* (*create_initiator_enumerator)(attribute_manager_t *this,
-                                                                                       identification_t *id, host_t *vip);
-
-       /**
-        * Register an attribute handler to the manager.
-        *
-        * @param handler               attribute handler to register
-        */
-       void (*add_handler)(attribute_manager_t *this,
-                                               attribute_handler_t *handler);
-
-       /**
-        * Unregister an attribute handler from the manager.
-        *
-        * @param handler               attribute handler to unregister
-        */
-       void (*remove_handler)(attribute_manager_t *this,
-                                                  attribute_handler_t *handler);
-
-       /**
-        * Destroy a attribute_manager instance.
-        */
-       void (*destroy)(attribute_manager_t *this);
-};
-
-/**
- * Create a attribute_manager instance.
- */
-attribute_manager_t *attribute_manager_create();
-
-#endif /** ATTRIBUTE_MANAGER_H_ @}*/
diff --git a/src/libstrongswan/attributes/attribute_provider.h b/src/libstrongswan/attributes/attribute_provider.h
deleted file mode 100644 (file)
index f8485cc..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2008 Martin Willi
- * 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 attribute_provider attribute_provider
- * @{ @ingroup attributes
- */
-
-#ifndef ATTRIBUTE_PROVIDER_H_
-#define ATTRIBUTE_PROVIDER_H_
-
-#include <utils/host.h>
-#include <utils/identification.h>
-
-typedef struct attribute_provider_t attribute_provider_t;
-
-/**
- * Interface to provide attributes to peers through attribute manager.
- */
-struct attribute_provider_t {
-
-       /**
-        * Acquire a virtual IP address to assign to a peer.
-        *
-        * @param pool                  name of the pool to acquire address from
-        * @param id                    peer ID
-        * @param requested             IP in configuration request
-        * @return                              allocated address, NULL to serve none
-        */
-       host_t* (*acquire_address)(attribute_provider_t *this,
-                                                          char *pool, identification_t *id,
-                                                          host_t *requested);
-       /**
-        * Release a previously acquired address.
-        *
-        * @param pool                  name of the pool this address was acquired from
-        * @param address               address to release
-        * @param id                    peer ID
-        * @return                              TRUE if the address has been released by the provider
-        */
-       bool (*release_address)(attribute_provider_t *this,
-                                                       char *pool, host_t *address, identification_t *id);
-
-       /**
-        * Create an enumerator over attributes to hand out to a peer.
-        *
-        * @param id                    peer ID
-        * @param vip                   virtual IP to assign to peer, if any
-        * @return                              enumerator (configuration_attribute_type_t, chunk_t)
-        */
-       enumerator_t* (*create_attribute_enumerator)(attribute_provider_t *this,
-                                                                                       identification_t *id, host_t *vip);
-};
-
-#endif /** ATTRIBUTE_PROVIDER_H_ @}*/
diff --git a/src/libstrongswan/attributes/attributes.c b/src/libstrongswan/attributes/attributes.c
deleted file mode 100644 (file)
index 83feed1..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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_PREFIX,
-       "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",
-       "MIP6_HOME_PREFIX",
-       "INTERNAL_IP6_LINK",
-       "INTERNAL_IP6_PREFIX");
-ENUM_NEXT(configuration_attribute_type_names, INTERNAL_IP4_SERVER, INTERNAL_IP6_SERVER, INTERNAL_IP6_PREFIX,
-       "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
deleted file mode 100644 (file)
index f4a396f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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_g 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,
-       MIP6_HOME_PREFIX = 16,
-       INTERNAL_IP6_LINK = 17,
-       INTERNAL_IP6_PREFIX = 18,
-       /* 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 10d94a2..02ac0cb 100644 (file)
@@ -66,7 +66,6 @@ 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)
@@ -131,7 +130,6 @@ 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 ffc0b1c..2410841 100644 (file)
@@ -63,7 +63,6 @@
 #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"
@@ -101,11 +100,6 @@ struct library_t {
        fetcher_manager_t *fetcher;
 
        /**
-        * manager for payload attributes
-        */
-       attribute_manager_t *attributes;
-
-       /**
         * database construction factory
         */
        database_factory_t *db;