aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2009-10-13 13:46:27 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2009-10-13 13:46:27 +0200
commit930443afffae63f1978df94fb854f10974f42fcf (patch)
treee14756f98cf944eab82c4e9bfcd9f4001b7a17e0 /src/charon
parenta2b50c5d60fc9d828d1b36243acee391d9b01826 (diff)
downloadstrongswan-930443afffae63f1978df94fb854f10974f42fcf.tar.bz2
strongswan-930443afffae63f1978df94fb854f10974f42fcf.tar.xz
moved attribute_manager to libstrongswan
Diffstat (limited to 'src/charon')
-rw-r--r--src/charon/Makefile.am3
-rw-r--r--src/charon/config/attributes/attribute_handler.h58
-rw-r--r--src/charon/config/attributes/attribute_manager.c267
-rw-r--r--src/charon/config/attributes/attribute_manager.h135
-rw-r--r--src/charon/config/attributes/attribute_provider.h67
-rw-r--r--src/charon/daemon.c3
-rw-r--r--src/charon/daemon.h6
-rw-r--r--src/charon/encoding/payloads/configuration_attribute.c21
-rw-r--r--src/charon/encoding/payloads/configuration_attribute.h31
-rw-r--r--src/charon/plugins/attr/attr_plugin.c4
-rw-r--r--src/charon/plugins/attr/attr_provider.h2
-rw-r--r--src/charon/plugins/nm/nm_handler.c6
-rw-r--r--src/charon/plugins/nm/nm_handler.h2
-rw-r--r--src/charon/plugins/nm/nm_plugin.c4
-rw-r--r--src/charon/plugins/resolve/resolve_handler.c12
-rw-r--r--src/charon/plugins/resolve/resolve_handler.h2
-rw-r--r--src/charon/plugins/resolve/resolve_plugin.c5
-rw-r--r--src/charon/plugins/sql/sql_attribute.h3
-rw-r--r--src/charon/plugins/sql/sql_plugin.c4
-rw-r--r--src/charon/plugins/stroke/stroke_attribute.h2
-rw-r--r--src/charon/plugins/stroke/stroke_socket.c4
-rw-r--r--src/charon/sa/ike_sa.c10
-rw-r--r--src/charon/sa/tasks/ike_config.c6
23 files changed, 34 insertions, 623 deletions
diff --git a/src/charon/Makefile.am b/src/charon/Makefile.am
index 6b5a340cb..0da3c3dfb 100644
--- a/src/charon/Makefile.am
+++ b/src/charon/Makefile.am
@@ -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 \
diff --git a/src/charon/config/attributes/attribute_handler.h b/src/charon/config/attributes/attribute_handler.h
deleted file mode 100644
index d752d512e..000000000
--- a/src/charon/config/attributes/attribute_handler.h
+++ /dev/null
@@ -1,58 +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 <sa/ike_sa.h>
-#include <encoding/payloads/configuration_attribute.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 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,
- 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
- * to remove the attribute.
- */
- void (*release)(attribute_handler_t *this, ike_sa_t *ike_sa,
- configuration_attribute_type_t type, chunk_t data);
-};
-
-#endif /* ATTRIBUTE_HANDLER_ @}*/
diff --git a/src/charon/config/attributes/attribute_manager.c b/src/charon/config/attributes/attribute_manager.c
deleted file mode 100644
index 86d7d0759..000000000
--- a/src/charon/config/attributes/attribute_manager.c
+++ /dev/null
@@ -1,267 +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 <daemon.h>
-#include <utils/linked_list.h>
-#include <utils/mutex.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;
-};
-
-/**
- * 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(DBG_CFG, "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(DBG_CFG, "releasing address to pool '%s' failed", pool);
- }
-}
-
-/**
- * inner enumerator constructor for attributes
- */
-static enumerator_t *attrib_enum_create(attribute_provider_t *provider,
- identification_t *id)
-{
- return provider->create_attribute_enumerator(provider, id);
-}
-
-/**
- * Implementation of attribute_manager_t.create_attribute_enumerator
- */
-static enumerator_t* create_attribute_enumerator(
- private_attribute_manager_t *this, identification_t *id)
-{
- this->lock->read_lock(this->lock);
- return enumerator_create_cleaner(
- enumerator_create_nested(
- this->providers->create_enumerator(this->providers),
- (void*)attrib_enum_create, id, NULL),
- (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,
- ike_sa_t *ike_sa, configuration_attribute_type_t type,
- chunk_t data)
-{
- enumerator_t *enumerator;
- attribute_handler_t *current, *handled = NULL;
-
- this->lock->read_lock(this->lock);
- enumerator = this->handlers->create_enumerator(this->handlers);
- while (enumerator->enumerate(enumerator, &current))
- {
- if (current->handle(current, ike_sa, type, data))
- {
- handled = current;
- break;
- }
- }
- enumerator->destroy(enumerator);
- this->lock->unlock(this->lock);
-
- if (!handled)
- {
- DBG1(DBG_CFG, "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, ike_sa_t *ike_sa,
- 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, ike_sa, type, data);
- break;
- }
- }
- enumerator->destroy(enumerator);
- this->lock->unlock(this->lock);
-}
-
-/**
- * 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_attribute_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t *id))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.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/charon/config/attributes/attribute_manager.h b/src/charon/config/attributes/attribute_manager.h
deleted file mode 100644
index 68eb8b1bf..000000000
--- a/src/charon/config/attributes/attribute_manager.h
+++ /dev/null
@@ -1,135 +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 <config/attributes/attribute_provider.h>
-#include <config/attributes/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
- * @return enumerator (configuration_attribute_type_t, chunk_t)
- */
- enumerator_t* (*create_attribute_enumerator)(attribute_manager_t *this,
- identification_t *id);
-
- /**
- * 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 ike_sa IKE_SA where 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,
- 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 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,
- chunk_t data);
-
- /**
- * 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/charon/config/attributes/attribute_provider.h b/src/charon/config/attributes/attribute_provider.h
deleted file mode 100644
index b8825723d..000000000
--- a/src/charon/config/attributes/attribute_provider.h
+++ /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 <library.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
- * @return enumerator (configuration_attribute_type_t, chunk_t)
- */
- enumerator_t* (*create_attribute_enumerator)(attribute_provider_t *this,
- identification_t *id);
-};
-
-#endif /** ATTRIBUTE_PROVIDER_H_ @}*/
diff --git a/src/charon/daemon.c b/src/charon/daemon.c
index 490357c13..919592088 100644
--- a/src/charon/daemon.c
+++ b/src/charon/daemon.c
@@ -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;
diff --git a/src/charon/daemon.h b/src/charon/daemon.h
index 2b863f7d8..435232834 100644
--- a/src/charon/daemon.h
+++ b/src/charon/daemon.h
@@ -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>
@@ -221,11 +220,6 @@ struct daemon_t {
backend_manager_t *backends;
/**
- * Manager for IKEv2 cfg payload attributes
- */
- attribute_manager_t *attributes;
-
- /**
* Manager for the credential backends
*/
credential_manager_t *credentials;
diff --git a/src/charon/encoding/payloads/configuration_attribute.c b/src/charon/encoding/payloads/configuration_attribute.c
index fe65eab49..caba34a6c 100644
--- a/src/charon/encoding/payloads/configuration_attribute.c
+++ b/src/charon/encoding/payloads/configuration_attribute.c
@@ -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.
*
diff --git a/src/charon/encoding/payloads/configuration_attribute.h b/src/charon/encoding/payloads/configuration_attribute.h
index f4201130b..f30fbfa72 100644
--- a/src/charon/encoding/payloads/configuration_attribute.h
+++ b/src/charon/encoding/payloads/configuration_attribute.h
@@ -22,10 +22,10 @@
#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>
@@ -35,35 +35,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.
*
* The CONFIGURATION ATTRIBUTE format is described in RFC section 3.15.1.
diff --git a/src/charon/plugins/attr/attr_plugin.c b/src/charon/plugins/attr/attr_plugin.c
index a3e83fe61..6dfb10271 100644
--- a/src/charon/plugins/attr/attr_plugin.c
+++ b/src/charon/plugins/attr/attr_plugin.c
@@ -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;
}
diff --git a/src/charon/plugins/attr/attr_provider.h b/src/charon/plugins/attr/attr_provider.h
index e867f2b20..a41466718 100644
--- a/src/charon/plugins/attr/attr_provider.h
+++ b/src/charon/plugins/attr/attr_provider.h
@@ -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;
diff --git a/src/charon/plugins/nm/nm_handler.c b/src/charon/plugins/nm/nm_handler.c
index 7b9c10b65..7756b8e7a 100644
--- a/src/charon/plugins/nm/nm_handler.c
+++ b/src/charon/plugins/nm/nm_handler.c
@@ -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;
diff --git a/src/charon/plugins/nm/nm_handler.h b/src/charon/plugins/nm/nm_handler.h
index 3904ce1f0..6c15ae6de 100644
--- a/src/charon/plugins/nm/nm_handler.h
+++ b/src/charon/plugins/nm/nm_handler.h
@@ -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;
diff --git a/src/charon/plugins/nm/nm_plugin.c b/src/charon/plugins/nm/nm_plugin.c
index 46cc9c39e..daf2cc660 100644
--- a/src/charon/plugins/nm/nm_plugin.c
+++ b/src/charon/plugins/nm/nm_plugin.c
@@ -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)
{
diff --git a/src/charon/plugins/resolve/resolve_handler.c b/src/charon/plugins/resolve/resolve_handler.c
index 86057ddbb..6f72546dd 100644
--- a/src/charon/plugins/resolve/resolve_handler.c
+++ b/src/charon/plugins/resolve/resolve_handler.c
@@ -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);
diff --git a/src/charon/plugins/resolve/resolve_handler.h b/src/charon/plugins/resolve/resolve_handler.h
index d56d06863..8a2c77f53 100644
--- a/src/charon/plugins/resolve/resolve_handler.h
+++ b/src/charon/plugins/resolve/resolve_handler.h
@@ -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;
diff --git a/src/charon/plugins/resolve/resolve_plugin.c b/src/charon/plugins/resolve/resolve_plugin.c
index 63cd9af6d..c564981ef 100644
--- a/src/charon/plugins/resolve/resolve_plugin.c
+++ b/src/charon/plugins/resolve/resolve_plugin.c
@@ -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;
}
diff --git a/src/charon/plugins/sql/sql_attribute.h b/src/charon/plugins/sql/sql_attribute.h
index 358ab92af..27a39651b 100644
--- a/src/charon/plugins/sql/sql_attribute.h
+++ b/src/charon/plugins/sql/sql_attribute.h
@@ -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;
diff --git a/src/charon/plugins/sql/sql_plugin.c b/src/charon/plugins/sql/sql_plugin.c
index 65691cc00..05cdad559 100644
--- a/src/charon/plugins/sql/sql_plugin.c
+++ b/src/charon/plugins/sql/sql_plugin.c
@@ -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;
diff --git a/src/charon/plugins/stroke/stroke_attribute.h b/src/charon/plugins/stroke/stroke_attribute.h
index 0bb8ae4bf..cf6c950a6 100644
--- a/src/charon/plugins/stroke/stroke_attribute.h
+++ b/src/charon/plugins/stroke/stroke_attribute.h
@@ -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;
diff --git a/src/charon/plugins/stroke/stroke_socket.c b/src/charon/plugins/stroke/stroke_socket.c
index 7ae00d118..2faa2353b 100644
--- a/src/charon/plugins/stroke/stroke_socket.c
+++ b/src/charon/plugins/stroke/stroke_socket.c
@@ -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);
diff --git a/src/charon/sa/ike_sa.c b/src/charon/sa/ike_sa.c
index dc420dab1..c681b0180 100644
--- a/src/charon/sa/ike_sa.c
+++ b/src/charon/sa/ike_sa.c
@@ -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);
}
diff --git a/src/charon/sa/tasks/ike_config.c b/src/charon/sa/tasks/ike_config.c
index bb5779e50..0e2340a6a 100644
--- a/src/charon/sa/tasks/ike_config.c
+++ b/src/charon/sa/tasks/ike_config.c
@@ -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();