diff --git a/src/libcharon/daemon.h b/src/libcharon/daemon.h index eb97a1688..c1df00e65 100644 --- a/src/libcharon/daemon.h +++ b/src/libcharon/daemon.h @@ -28,9 +28,6 @@ * @defgroup config config * @ingroup libcharon * - * @defgroup attributes attributes - * @ingroup config - * * @defgroup control control * @ingroup libcharon * diff --git a/src/libhydra/Makefile.am b/src/libhydra/Makefile.am index 35a807ef4..94d3968de 100644 --- a/src/libhydra/Makefile.am +++ b/src/libhydra/Makefile.am @@ -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/libstrongswan/attributes/attribute_handler.h b/src/libhydra/attributes/attribute_handler.h similarity index 100% rename from src/libstrongswan/attributes/attribute_handler.h rename to src/libhydra/attributes/attribute_handler.h diff --git a/src/libstrongswan/attributes/attribute_manager.c b/src/libhydra/attributes/attribute_manager.c similarity index 100% rename from src/libstrongswan/attributes/attribute_manager.c rename to src/libhydra/attributes/attribute_manager.c diff --git a/src/libstrongswan/attributes/attribute_manager.h b/src/libhydra/attributes/attribute_manager.h similarity index 100% rename from src/libstrongswan/attributes/attribute_manager.h rename to src/libhydra/attributes/attribute_manager.h diff --git a/src/libstrongswan/attributes/attribute_provider.h b/src/libhydra/attributes/attribute_provider.h similarity index 100% rename from src/libstrongswan/attributes/attribute_provider.h rename to src/libhydra/attributes/attribute_provider.h diff --git a/src/libstrongswan/attributes/attributes.c b/src/libhydra/attributes/attributes.c similarity index 100% rename from src/libstrongswan/attributes/attributes.c rename to src/libhydra/attributes/attributes.c diff --git a/src/libstrongswan/attributes/attributes.h b/src/libhydra/attributes/attributes.h similarity index 100% rename from src/libstrongswan/attributes/attributes.h rename to src/libhydra/attributes/attributes.h diff --git a/src/libhydra/hydra.c b/src/libhydra/hydra.c index edc48f748..8775df08c 100644 --- a/src/libhydra/hydra.c +++ b/src/libhydra/hydra.c @@ -17,11 +17,32 @@ #include +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)) { diff --git a/src/libhydra/hydra.h b/src/libhydra/hydra.h index acbaa01cc..2d8ef9cc1 100644 --- a/src/libhydra/hydra.h +++ b/src/libhydra/hydra.h @@ -16,6 +16,9 @@ /** * @defgroup libhydra libhydra * + * @defgroup attributes attributes + * @ingroup libhydra + * * @defgroup hplugins plugins * @ingroup libhydra * @@ -26,8 +29,28 @@ #ifndef HYDRA_H_ #define HYDRA_H_ +typedef struct hydra_t hydra_t; + +#include + #include +/** + * 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 diff --git a/src/libstrongswan/Makefile.am b/src/libstrongswan/Makefile.am index 5620ff74b..157d37b5e 100644 --- a/src/libstrongswan/Makefile.am +++ b/src/libstrongswan/Makefile.am @@ -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/library.c b/src/libstrongswan/library.c index 10d94a23b..02ac0cb31 100644 --- a/src/libstrongswan/library.c +++ b/src/libstrongswan/library.c @@ -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; diff --git a/src/libstrongswan/library.h b/src/libstrongswan/library.h index ffc0b1c46..241084155 100644 --- a/src/libstrongswan/library.h +++ b/src/libstrongswan/library.h @@ -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" @@ -100,11 +99,6 @@ struct library_t { */ fetcher_manager_t *fetcher; - /** - * manager for payload attributes - */ - attribute_manager_t *attributes; - /** * database construction factory */