diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2013-02-07 13:27:27 +0100 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2013-02-07 13:27:27 +0100 |
commit | 7585facf05d927eb6df3929ce09ed5e60d905437 (patch) | |
tree | e4d14b4dc180db20356b6b01ce0112f3a2d7897e /src/libcharon/plugins/tnc_imv | |
parent | c1343b3278cdf99533b7902744d15969f9d6fdc1 (diff) | |
download | vyos-strongswan-7585facf05d927eb6df3929ce09ed5e60d905437.tar.gz vyos-strongswan-7585facf05d927eb6df3929ce09ed5e60d905437.zip |
Imported Upstream version 5.0.2
Diffstat (limited to 'src/libcharon/plugins/tnc_imv')
-rw-r--r-- | src/libcharon/plugins/tnc_imv/Makefile.in | 32 | ||||
-rw-r--r-- | src/libcharon/plugins/tnc_imv/tnc_imv.c | 82 | ||||
-rw-r--r-- | src/libcharon/plugins/tnc_imv/tnc_imv.h | 26 | ||||
-rw-r--r-- | src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c | 2 | ||||
-rw-r--r-- | src/libcharon/plugins/tnc_imv/tnc_imv_manager.c | 116 | ||||
-rw-r--r-- | src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.c | 4 | ||||
-rw-r--r-- | src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.h | 2 |
7 files changed, 203 insertions, 61 deletions
diff --git a/src/libcharon/plugins/tnc_imv/Makefile.in b/src/libcharon/plugins/tnc_imv/Makefile.in index 13b011101..6e0133c2d 100644 --- a/src/libcharon/plugins/tnc_imv/Makefile.in +++ b/src/libcharon/plugins/tnc_imv/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -73,6 +73,12 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(plugindir)" LTLIBRARIES = $(noinst_LTLIBRARIES) $(plugin_LTLIBRARIES) @MONOLITHIC_FALSE@libstrongswan_tnc_imv_la_DEPENDENCIES = \ @@ -126,6 +132,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLIB = @DLLIB@ +DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -153,6 +160,7 @@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQLCFLAG = @MYSQLCFLAG@ MYSQLCONFIG = @MYSQLCONFIG@ @@ -180,6 +188,7 @@ RANLIB = @RANLIB@ RTLIB = @RTLIB@ RUBY = @RUBY@ RUBYINCLUDE = @RUBYINCLUDE@ +RUBYLIB = @RUBYLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -192,6 +201,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -245,7 +255,6 @@ libexecdir = @libexecdir@ linux_headers = @linux_headers@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ maemo_CFLAGS = @maemo_CFLAGS@ maemo_LIBS = @maemo_LIBS@ manager_plugins = @manager_plugins@ @@ -386,7 +395,7 @@ clean-pluginLTLIBRARIES: echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done -libstrongswan-tnc-imv.la: $(libstrongswan_tnc_imv_la_OBJECTS) $(libstrongswan_tnc_imv_la_DEPENDENCIES) +libstrongswan-tnc-imv.la: $(libstrongswan_tnc_imv_la_OBJECTS) $(libstrongswan_tnc_imv_la_DEPENDENCIES) $(EXTRA_libstrongswan_tnc_imv_la_DEPENDENCIES) $(libstrongswan_tnc_imv_la_LINK) $(am_libstrongswan_tnc_imv_la_rpath) $(libstrongswan_tnc_imv_la_OBJECTS) $(libstrongswan_tnc_imv_la_LIBADD) $(LIBS) mostlyclean-compile: @@ -527,10 +536,15 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv.c b/src/libcharon/plugins/tnc_imv/tnc_imv.c index f0b150743..ef0387d70 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv.c +++ b/src/libcharon/plugins/tnc_imv/tnc_imv.c @@ -20,9 +20,10 @@ #include <tncif_pa_subtypes.h> -#include <debug.h> +#include <utils/debug.h> +#include <daemon.h> #include <library.h> -#include <utils/linked_list.h> +#include <collections/linked_list.h> #include <threading/mutex.h> typedef struct private_tnc_imv_t private_tnc_imv_t; @@ -38,11 +39,6 @@ struct private_tnc_imv_t { imv_t public; /** - * Path of loaded IMV - */ - char *path; - - /** * Name of loaded IMV */ char *name; @@ -287,10 +283,10 @@ METHOD(imv_t, type_supported, bool, for (i = 0; i < this->type_count; i++) { - vid = this->supported_vids[i]; - subtype = this->supported_subtypes[i]; + vid = this->supported_vids[i]; + subtype = this->supported_subtypes[i]; - if ((vid == TNC_VENDORID_ANY && subtype == TNC_SUBTYPE_ANY) || + if ((vid == TNC_VENDORID_ANY && subtype == TNC_SUBTYPE_ANY) || (vid == msg_vid && (subtype == TNC_SUBTYPE_ANY || subtype == msg_subtype))) { @@ -303,20 +299,23 @@ METHOD(imv_t, type_supported, bool, METHOD(imv_t, destroy, void, private_tnc_imv_t *this) { - dlclose(this->handle); + if (this->handle && lib->settings->get_bool(lib->settings, + "%s.plugins.tnc-imv.dlclose", TRUE, charon->name)) + { + dlclose(this->handle); + } this->mutex->destroy(this->mutex); this->additional_ids->destroy_function(this->additional_ids, free); free(this->supported_vids); free(this->supported_subtypes); free(this->name); - free(this->path); free(this); } /** - * Described in header. + * Generic constructor. */ -imv_t* tnc_imv_create(char *name, char *path) +static private_tnc_imv_t* tnc_imv_create_empty(char *name) { private_tnc_imv_t *this; @@ -332,17 +331,28 @@ imv_t* tnc_imv_create(char *name, char *path) .type_supported = _type_supported, .destroy = _destroy, }, - .name = name, - .path = path, + .name = strdup(name), .additional_ids = linked_list_create(), .mutex = mutex_create(MUTEX_TYPE_DEFAULT), ); + return this; +} + +/** + * Described in header. + */ +imv_t* tnc_imv_create(char *name, char *path) +{ + private_tnc_imv_t *this; + + this = tnc_imv_create_empty(name); + this->handle = dlopen(path, RTLD_LAZY); if (!this->handle) { DBG1(DBG_TNC, "IMV \"%s\" failed to load: %s", name, dlerror()); - free(this); + destroy(this); return NULL; } @@ -351,8 +361,7 @@ imv_t* tnc_imv_create(char *name, char *path) { DBG1(DBG_TNC, "could not resolve TNC_IMV_Initialize in %s: %s\n", path, dlerror()); - dlclose(this->handle); - free(this); + destroy(this); return NULL; } this->public.notify_connection_change = @@ -363,8 +372,7 @@ imv_t* tnc_imv_create(char *name, char *path) { DBG1(DBG_TNC, "could not resolve TNC_IMV_SolicitRecommendation in %s: %s\n", path, dlerror()); - dlclose(this->handle); - free(this); + destroy(this); return NULL; } this->public.receive_message = @@ -381,10 +389,38 @@ imv_t* tnc_imv_create(char *name, char *path) { DBG1(DBG_TNC, "could not resolve TNC_IMV_ProvideBindFunction in %s: %s\n", path, dlerror()); - dlclose(this->handle); - free(this); + destroy(this); return NULL; } return &this->public; } + +/** + * Described in header. + */ +imv_t* tnc_imv_create_from_functions(char *name, + TNC_IMV_InitializePointer initialize, + TNC_IMV_NotifyConnectionChangePointer notify_connection_change, + TNC_IMV_ReceiveMessagePointer receive_message, + TNC_IMV_ReceiveMessageLongPointer receive_message_long, + TNC_IMV_SolicitRecommendationPointer solicit_recommendation, + TNC_IMV_BatchEndingPointer batch_ending, + TNC_IMV_TerminatePointer terminate, + TNC_IMV_ProvideBindFunctionPointer provide_bind_function) +{ + private_tnc_imv_t *this; + + this = tnc_imv_create_empty(name); + + this->public.initialize = initialize; + this->public.notify_connection_change = notify_connection_change; + this->public.receive_message = receive_message; + this->public.receive_message_long = receive_message_long; + this->public.solicit_recommendation = solicit_recommendation; + this->public.batch_ending = batch_ending; + this->public.terminate = terminate; + this->public.provide_bind_function = provide_bind_function; + + return &this->public; +} diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv.h b/src/libcharon/plugins/tnc_imv/tnc_imv.h index 75939e54c..e7c7b8b4f 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv.h +++ b/src/libcharon/plugins/tnc_imv/tnc_imv.h @@ -25,7 +25,7 @@ #include <tnc/imv/imv.h> /** - * Create an Integrity Measurement Verifier. + * Create an Integrity Measurement Verifier loaded from a library. * * @param name name of the IMV * @param filename path to the dynamic IMV library @@ -33,4 +33,28 @@ */ imv_t* tnc_imv_create(char *name, char *filename); +/** + * Create an Integrity Measurement Verifier from a set of IMV functions. + * + * @param name name of the IMV + * @param initialize TNC_IMV_InitializePointer + * @param notify_connection_change TNC_IMV_NotifyConnectionChangePointer + * @param receive_message TNC_IMV_ReceiveMessagePointer + * @param receive_message_long TNC_IMV_ReceiveMessageLongPointer + * @param solicit_recommendation TNC_IMV_SolicitRecommendationPointer + * @param batch_ending TNC_IMV_BatchEndingPointer + * @param terminate TNC_IMV_TerminatePointer + * @param provide_bind_function TNC_IMV_ProvideBindFunctionPointer + * @return instance of the imv_t interface + */ +imv_t* tnc_imv_create_from_functions(char *name, + TNC_IMV_InitializePointer initialize, + TNC_IMV_NotifyConnectionChangePointer notify_connection_change, + TNC_IMV_ReceiveMessagePointer receive_message, + TNC_IMV_ReceiveMessageLongPointer receive_message_long, + TNC_IMV_SolicitRecommendationPointer solicit_recommendation, + TNC_IMV_BatchEndingPointer batch_ending, + TNC_IMV_TerminatePointer terminate, + TNC_IMV_ProvideBindFunctionPointer provide_bind_function); + #endif /** TNC_IMV_H_ @}*/ diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c b/src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c index dd11c5009..36cdb7fbb 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c +++ b/src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c @@ -18,7 +18,7 @@ #include <tnc/imv/imv_manager.h> #include <tnc/tnccs/tnccs_manager.h> -#include <debug.h> +#include <utils/debug.h> /** * Called by the IMV to inform a TNCS about the set of message types the IMV diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c b/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c index 0985a47a8..b950e3119 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c +++ b/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c @@ -29,13 +29,13 @@ #include <fcntl.h> #include <daemon.h> -#include <utils/lexparser.h> -#include <debug.h> +#include <utils/debug.h> +#include <threading/rwlock.h> #include <threading/mutex.h> +#include <collections/linked_list.h> typedef struct private_tnc_imv_manager_t private_tnc_imv_manager_t; - /** * Private data of an imv_manager_t object. */ @@ -52,11 +52,21 @@ struct private_tnc_imv_manager_t { linked_list_t *imvs; /** + * Lock for IMV list + */ + rwlock_t *lock; + + /** * Next IMV ID to be assigned */ TNC_IMVID next_imv_id; /** + * Mutex to access next IMV ID + */ + mutex_t *id_mutex; + + /** * Policy defining how to derive final recommendation from individual ones */ recommendation_policy_t policy; @@ -66,27 +76,37 @@ METHOD(imv_manager_t, add, bool, private_tnc_imv_manager_t *this, imv_t *imv) { TNC_Version version; + TNC_IMVID imv_id; - /* Initialize the IMV module */ - imv->set_id(imv, this->next_imv_id); - if (imv->initialize(imv->get_id(imv), TNC_IFIMV_VERSION_1, - TNC_IFIMV_VERSION_1, &version) != TNC_RESULT_SUCCESS) + this->id_mutex->lock(this->id_mutex); + imv_id = this->next_imv_id++; + this->id_mutex->unlock(this->id_mutex); + + imv->set_id(imv, imv_id); + if (imv->initialize(imv_id, TNC_IFIMV_VERSION_1, + TNC_IFIMV_VERSION_1, &version) != TNC_RESULT_SUCCESS) { DBG1(DBG_TNC, "IMV \"%s\" failed to initialize", imv->get_name(imv)); return FALSE; } + this->lock->write_lock(this->lock); this->imvs->insert_last(this->imvs, imv); - this->next_imv_id++; + this->lock->unlock(this->lock); - if (imv->provide_bind_function(imv->get_id(imv), TNC_TNCS_BindFunction) - != TNC_RESULT_SUCCESS) + if (imv->provide_bind_function(imv->get_id(imv), + TNC_TNCS_BindFunction) != TNC_RESULT_SUCCESS) { - DBG1(DBG_TNC, "IMV \"%s\" could failed to obtain bind function", - imv->get_name(imv)); + if (imv->terminate) + { + imv->terminate(imv->get_id(imv)); + } + DBG1(DBG_TNC, "IMV \"%s\" failed to obtain bind function", + imv->get_name(imv)); + this->lock->write_lock(this->lock); this->imvs->remove_last(this->imvs, (void**)&imv); + this->lock->unlock(this->lock); return FALSE; } - return TRUE; } @@ -96,6 +116,7 @@ METHOD(imv_manager_t, remove_, imv_t*, enumerator_t *enumerator; imv_t *imv, *removed_imv = NULL; + this->lock->write_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { @@ -107,6 +128,7 @@ METHOD(imv_manager_t, remove_, imv_t*, } } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); return removed_imv; } @@ -119,18 +141,10 @@ METHOD(imv_manager_t, load, bool, imv = tnc_imv_create(name, path); if (!imv) { - free(name); - free(path); return FALSE; } if (!add(this, imv)) { - if (imv->terminate && - imv->terminate(imv->get_id(imv)) != TNC_RESULT_SUCCESS) - { - DBG1(DBG_TNC, "IMV \"%s\" not terminated successfully", - imv->get_name(imv)); - } imv->destroy(imv); return FALSE; } @@ -138,6 +152,37 @@ METHOD(imv_manager_t, load, bool, return TRUE; } +METHOD(imv_manager_t, load_from_functions, bool, + private_tnc_imv_manager_t *this, char *name, + TNC_IMV_InitializePointer initialize, + TNC_IMV_NotifyConnectionChangePointer notify_connection_change, + TNC_IMV_ReceiveMessagePointer receive_message, + TNC_IMV_ReceiveMessageLongPointer receive_message_long, + TNC_IMV_SolicitRecommendationPointer solicit_recommendation, + TNC_IMV_BatchEndingPointer batch_ending, + TNC_IMV_TerminatePointer terminate, + TNC_IMV_ProvideBindFunctionPointer provide_bind_function) +{ + imv_t *imv; + + imv = tnc_imv_create_from_functions(name, + initialize,notify_connection_change, + receive_message, receive_message_long, + solicit_recommendation, batch_ending, + terminate, provide_bind_function); + if (!imv) + { + return FALSE; + } + if (!add(this, imv)) + { + imv->destroy(imv); + return FALSE; + } + DBG1(DBG_TNC, "IMV %u \"%s\" loaded", imv->get_id(imv), name); + return TRUE; +} + METHOD(imv_manager_t, is_registered, bool, private_tnc_imv_manager_t *this, TNC_IMVID id) { @@ -145,6 +190,7 @@ METHOD(imv_manager_t, is_registered, bool, imv_t *imv; bool found = FALSE; + this->lock->read_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { @@ -155,6 +201,7 @@ METHOD(imv_manager_t, is_registered, bool, } } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); return found; } @@ -166,13 +213,16 @@ METHOD(imv_manager_t, reserve_id, bool, imv_t *imv; bool found = FALSE; + this->lock->read_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { - if (imv->get_id(imv)) + if (id == imv->get_id(imv)) { found = TRUE; + this->id_mutex->lock(this->id_mutex); *new_id = this->next_imv_id++; + this->id_mutex->unlock(this->id_mutex); imv->add_id(imv, *new_id); DBG2(DBG_TNC, "additional ID %u reserved for IMV with primary ID %u", *new_id, id); @@ -180,6 +230,7 @@ METHOD(imv_manager_t, reserve_id, bool, } } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); return found; } @@ -259,6 +310,7 @@ METHOD(imv_manager_t, notify_connection_change, void, enumerator_t *enumerator; imv_t *imv; + this->lock->read_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { @@ -268,6 +320,7 @@ METHOD(imv_manager_t, notify_connection_change, void, } } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); } METHOD(imv_manager_t, set_message_types, TNC_Result, @@ -279,6 +332,7 @@ METHOD(imv_manager_t, set_message_types, TNC_Result, imv_t *imv; TNC_Result result = TNC_RESULT_FATAL; + this->lock->read_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { @@ -290,6 +344,7 @@ METHOD(imv_manager_t, set_message_types, TNC_Result, } } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); return result; } @@ -303,6 +358,7 @@ METHOD(imv_manager_t, set_message_types_long, TNC_Result, imv_t *imv; TNC_Result result = TNC_RESULT_FATAL; + this->lock->read_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { @@ -315,6 +371,7 @@ METHOD(imv_manager_t, set_message_types_long, TNC_Result, } } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); return result; } @@ -324,12 +381,14 @@ METHOD(imv_manager_t, solicit_recommendation, void, enumerator_t *enumerator; imv_t *imv; + this->lock->read_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { imv->solicit_recommendation(imv->get_id(imv), id); } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); } METHOD(imv_manager_t, receive_message, void, @@ -350,11 +409,12 @@ METHOD(imv_manager_t, receive_message, void, msg_type = (msg_vid << 8) | msg_subtype; + this->lock->read_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { if (imv->type_supported(imv, msg_vid, msg_subtype) && - (!excl || (excl && imv->has_id(imv, dst_imv_id)) )) + (!excl || (excl && imv->has_id(imv, dst_imv_id)))) { if (imv->receive_message_long && src_imc_id) { @@ -376,6 +436,8 @@ METHOD(imv_manager_t, receive_message, void, } } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); + if (!type_supported) { DBG2(DBG_TNC, "message type 0x%06x/0x%08x not supported by any IMV", @@ -389,6 +451,7 @@ METHOD(imv_manager_t, batch_ending, void, enumerator_t *enumerator; imv_t *imv; + this->lock->read_lock(this->lock); enumerator = this->imvs->create_enumerator(this->imvs); while (enumerator->enumerate(enumerator, &imv)) { @@ -398,9 +461,9 @@ METHOD(imv_manager_t, batch_ending, void, } } enumerator->destroy(enumerator); + this->lock->unlock(this->lock); } - METHOD(imv_manager_t, destroy, void, private_tnc_imv_manager_t *this) { @@ -417,6 +480,8 @@ METHOD(imv_manager_t, destroy, void, imv->destroy(imv); } this->imvs->destroy(this->imvs); + this->lock->destroy(this->lock); + this->id_mutex->destroy(this->id_mutex); free(this); } @@ -433,6 +498,7 @@ imv_manager_t* tnc_imv_manager_create(void) .add = _add, .remove = _remove_, /* avoid name conflict with stdio.h */ .load = _load, + .load_from_functions = _load_from_functions, .is_registered = _is_registered, .reserve_id = _reserve_id, .get_recommendation_policy = _get_recommendation_policy, @@ -447,6 +513,8 @@ imv_manager_t* tnc_imv_manager_create(void) .destroy = _destroy, }, .imvs = linked_list_create(), + .lock = rwlock_create(RWLOCK_TYPE_DEFAULT), + .id_mutex = mutex_create(MUTEX_TYPE_DEFAULT), .next_imv_id = 1, ); diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.c b/src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.c index 396d5d854..b39d9cbc9 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.c +++ b/src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.c @@ -21,8 +21,8 @@ #include <tnc/imv/imv_manager.h> #include <tnc/imv/imv_recommendations.h> -#include <debug.h> -#include <utils/linked_list.h> +#include <utils/debug.h> +#include <collections/linked_list.h> typedef struct private_tnc_imv_recommendations_t private_tnc_imv_recommendations_t; typedef struct recommendation_entry_t recommendation_entry_t; diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.h b/src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.h index 6d65a2521..66d03b2f8 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.h +++ b/src/libcharon/plugins/tnc_imv/tnc_imv_recommendations.h @@ -23,7 +23,7 @@ #define TNC_IMV_RECOMMENDATIONS_H_ #include <tnc/imv/imv_recommendations.h> -#include <utils/linked_list.h> +#include <collections/linked_list.h> /** * Create an IMV empty recommendations instance |