]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
moved imv_manager to libtnccs
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 20 Oct 2011 20:06:10 +0000 (22:06 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 24 Oct 2011 23:10:16 +0000 (01:10 +0200)
12 files changed:
src/libcharon/Makefile.am
src/libcharon/daemon.h
src/libcharon/plugins/tnc_imv/tnc_imv_plugin.c
src/libcharon/plugins/tnccs_11/tnccs_11.c
src/libcharon/plugins/tnccs_20/tnccs_20.c
src/libcharon/tnc/tnccs/tnccs_manager.c
src/libcharon/tnc/tnccs/tnccs_manager.h
src/libtnccs/Makefile.am
src/libtnccs/imv/imv.h [moved from src/libcharon/tnc/imv/imv.h with 100% similarity]
src/libtnccs/imv/imv_manager.h [moved from src/libcharon/tnc/imv/imv_manager.h with 99% similarity]
src/libtnccs/imv/imv_recommendations.c [moved from src/libcharon/tnc/imv/imv_recommendations.c with 100% similarity]
src/libtnccs/imv/imv_recommendations.h [moved from src/libcharon/tnc/imv/imv_recommendations.h with 100% similarity]

index 6ddf41c5317ea9317d4e6ae09f9b52523b5c8ac1..b51027ab4c75002ca21404465df7f62993199ae3 100644 (file)
@@ -87,8 +87,6 @@ sa/tasks/ike_reauth.c sa/tasks/ike_reauth.h \
 sa/tasks/ike_auth_lifetime.c sa/tasks/ike_auth_lifetime.h \
 sa/tasks/ike_vendor.c sa/tasks/ike_vendor.h \
 sa/tasks/task.c sa/tasks/task.h \
-tnc/imv/imv.h tnc/imv/imv_manager.h \
-tnc/imv/imv_recommendations.c tnc/imv/imv_recommendations.h \
 tnc/tnccs/tnccs.c tnc/tnccs/tnccs.h \
 tnc/tnccs/tnccs_manager.c tnc/tnccs/tnccs_manager.h
 
index 3230e7201866f7c6ea2264e2f1dc32979a031115..6bbaa4f58d2f716b6282b0e9ec389ce5feb2cc53 100644 (file)
@@ -152,7 +152,6 @@ typedef struct daemon_t daemon_t;
 #include <sa/shunt_manager.h>
 #include <config/backend_manager.h>
 #include <sa/authenticators/eap/eap_manager.h>
-#include <tnc/imv/imv_manager.h>
 #include <tnc/tnccs/tnccs_manager.h>
 
 #ifdef ME
@@ -240,11 +239,6 @@ struct daemon_t {
         */
        eap_manager_t *eap;
 
-       /**
-        * TNC IMV manager controlling Integrity Measurement Verifiers
-        */
-       imv_manager_t *imvs;
-
        /**
         * TNCCS manager to maintain registered TNCCS protocols
         */
index 45cf95c1b8cb89f11bb2f1d5e12e83203b95b0ff..bec151047aec74da7ce26054e01a5ab5ce91ffd6 100644 (file)
 #include <errno.h>
 #include <fcntl.h>
 
-#include <daemon.h>
 #include <utils/lexparser.h>
+#include <debug.h>
+
+typedef struct private_tnc_imv_plugin_t private_tnc_imv_plugin_t;
+
+/**
+ * Private data of a tnc_imv_plugin_t object.
+ */
+struct private_tnc_imv_plugin_t {
+
+       /**
+        * Public interface.
+        */
+       tnc_imv_plugin_t public;
+
+       /**
+        * TNC IMV manager controlling Integrity Measurement Verifiers
+        */
+       imv_manager_t *imvs;
+};
 
 /**
  * load IMVs from a configuration file
  */
-static bool load_imvs(char *filename)
+static bool load_imvs(private_tnc_imv_plugin_t *this, char *filename)
 {
        int fd, line_nr = 0;
        chunk_t src, line;
@@ -128,7 +146,7 @@ static bool load_imvs(char *filename)
                        free(path);
                        return FALSE;
                }
-               if (!charon->imvs->add(charon->imvs, imv))
+               if (!this->imvs->add(this->imvs, imv))
                {
                        if (imv->terminate &&
                                imv->terminate(imv->get_id(imv)) != TNC_RESULT_SUCCESS)
@@ -153,10 +171,21 @@ METHOD(plugin_t, get_name, char*,
        return "tnc-imv";
 }
 
+METHOD(plugin_t, get_features, int,
+       private_tnc_imv_plugin_t *this, plugin_feature_t *features[])
+{
+       static plugin_feature_t f[] = {
+               PLUGIN_PROVIDE(CUSTOM, "imv-manager"),
+       };
+       *features = f;
+       return countof(f);
+}
+
 METHOD(plugin_t, destroy, void,
        tnc_imv_plugin_t *this)
 {
-       charon->imvs->destroy(charon->imvs);
+       lib->set(lib, "imv-manager", NULL);
+       this->imvs->destroy(this->imvs);
        free(this);
 }
 
@@ -169,27 +198,26 @@ plugin_t *tnc_imv_plugin_create()
        tnc_imv_plugin_t *this;
 
        INIT(this,
-               .plugin = {
-                       .get_name = _get_name,
-                       .reload = (void*)return_false,
-                       .destroy = _destroy,
+               .public = {
+                       .plugin = {
+                               .get_name = _get_name,
+                               .get_features = _get_features,
+                               .destroy = _destroy,
+                       },
                },
+               .imvs = tnc_imv_manager_create(),
        );
 
-       tnc_config = lib->settings->get_str(lib->settings,
-                                       "charon.plugins.tnc-imv.tnc_config", "/etc/tnc_config");
-
-       /* Create IMV manager */
-       charon->imvs = tnc_imv_manager_create();
+       lib->set(lib, "imv-manager", this->imvs);
 
        /* Load IMVs and abort if not all instances initalize successfully */
-       if (!load_imvs(tnc_config))
+       tnc_config = lib->settings->get_str(lib->settings,
+                                       "charon.plugins.tnc-imv.tnc_config", "/etc/tnc_config");
+       if (!load_imvs(this, tnc_config))
        {
-               charon->imvs->destroy(charon->imvs);
-               charon->imvs = NULL;
-               free(this);
+               destroy(this);
                return NULL;
        }
-       return &this->plugin;
+       return &this->public.plugin;
 }
 
index c7f96731ee3c5b070443bbcdcd32b766cfbdf714..4000ae2beced77966dc57307f0ca19da78b6b43a 100644 (file)
@@ -99,6 +99,11 @@ struct private_tnccs_11_t {
         */
        imc_manager_t *imcs;
 
+       /**
+        * TNC IMV manager controlling Integrity Measurement Verifiers
+        */
+       imc_manager_t *imvs;
+
 };
 
 METHOD(tnccs_t, send_msg, TNC_Result,
@@ -181,7 +186,7 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
                        this->send_msg = TRUE;
                        if (this->is_server)
                        {
-                               charon->imvs->receive_message(charon->imvs,
+                               this->imvs->receive_message(this->imvs,
                                this->connection_id, msg_body.ptr, msg_body.len, msg_type);
                        }
                        else
@@ -343,7 +348,7 @@ METHOD(tls_t, process, status_t,
                this->send_msg = TRUE;
                if (this->is_server)
                {
-                       charon->imvs->batch_ending(charon->imvs, this->connection_id);
+                       this->imvs->batch_ending(this->imvs, this->connection_id);
                }
                else
                {
@@ -540,6 +545,7 @@ tls_t *tnccs_11_create(bool is_server)
                .is_server = is_server,
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
                .imcs = lib->get(lib, "imc-manager"),
+               .imvs = lib->get(lib, "imv-manager"),
        );
 
        return &this->public;
index c9e62e0931d2f15698f556e2075860727b6c7c3d..d3a560f6feacf9ce869944bd6c506665f6388e41 100644 (file)
@@ -99,6 +99,11 @@ struct private_tnccs_20_t {
         */
        imc_manager_t *imcs;
 
+       /**
+        * TNC IMV manager controlling Integrity Measurement Verifiers
+        */
+       imv_manager_t *imvs;
+
 };
 
 METHOD(tnccs_t, send_msg, TNC_Result,
@@ -198,7 +203,7 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
                        this->send_msg = TRUE;
                        if (this->is_server)
                        {
-                               charon->imvs->receive_message(charon->imvs,
+                               this->imvs->receive_message(this->imvs,
                                this->connection_id, msg_body.ptr, msg_body.len, msg_type);
                        }
                        else
@@ -447,7 +452,7 @@ METHOD(tls_t, process, status_t,
                this->send_msg = TRUE;
                if (this->is_server)
                {
-                       charon->imvs->batch_ending(charon->imvs, this->connection_id);
+                       this->imvs->batch_ending(this->imvs, this->connection_id);
                }
                else
                {
@@ -740,6 +745,7 @@ tls_t *tnccs_20_create(bool is_server)
                .state_machine = pb_tnc_state_machine_create(is_server),
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
                .imcs = lib->get(lib, "imc-manager"),
+               .imvs = lib->get(lib, "imv-manager"),
        );
 
        return &this->public;
index 0e4107eef40365952fa97e28f37e48567e1745cf..d230765098d63dd3bb3aa796a7c3c4686f8bc2db 100644 (file)
@@ -18,7 +18,7 @@
 #include "tnccs_manager.h"
 
 #include <imc/imc_manager.h>
-#include <tnc/imv/imv_recommendations.h>
+#include <imv/imv_manager.h>
 
 #include <debug.h>
 #include <daemon.h>
@@ -116,6 +116,11 @@ struct private_tnccs_manager_t {
         */
        imc_manager_t *imcs;
 
+       /**
+        * TNC IMV manager controlling Integrity Measurement Verifiers
+        */
+       imv_manager_t *imvs;
+
 };
 
 METHOD(tnccs_manager_t, add_method, void,
@@ -193,13 +198,17 @@ METHOD(tnccs_manager_t, create_connection, TNC_ConnectionID,
        if (recs)
        {
                /* we assume a TNC Server needing recommendations from IMVs */
-               if (!charon->imvs)
+               if (!this->imvs)
+               {
+                       this->imvs = lib->get(lib, "imv-manager");
+               }
+               if (!this->imvs)
                {
                        DBG1(DBG_TNC, "no IMV manager available!");
                        free(entry);
                        return 0;
                }
-               entry->recs = charon->imvs->create_recommendations(charon->imvs);
+               entry->recs = this->imvs->create_recommendations(this->imvs);
                *recs = entry->recs;
        }
        else
@@ -234,9 +243,9 @@ METHOD(tnccs_manager_t, remove_connection, void,
 
        if (is_server)
        {
-               if (charon->imvs)
+               if (this->imvs)
                {
-                       charon->imvs->notify_connection_change(charon->imvs, id,
+                       this->imvs->notify_connection_change(this->imvs, id,
                                                                                TNC_CONNECTION_STATE_DELETE);
                }
        }
@@ -511,6 +520,7 @@ tnccs_manager_t *tnccs_manager_create()
                        .protocol_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
                        .connection_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
                        .imcs = lib->get(lib, "imc-manager"),
+                       .imvs = lib->get(lib, "imv-manager"),
        );
 
        return &this->public;
index 5051d4bb3336d6df4ec961c9dfb9860f3e4ce901..3282192c50f9fe09c853290077feb85e029ceb50 100644 (file)
@@ -27,7 +27,7 @@ typedef struct tnccs_manager_t tnccs_manager_t;
 
 #include "tnccs.h"
 
-#include <tnc/imv/imv_recommendations.h>
+#include <imv/imv_recommendations.h>
 
 /**
  * The TNCCS manager manages all TNCCS implementations and creates instances.
index 0348144021df0240af0781ad6440bc2329475f28..e75d1bdbc228d0ea09b3f72e66642b333f6781d4 100644 (file)
@@ -6,5 +6,7 @@ ipseclib_LTLIBRARIES = libtnccs.la
 libtnccs_la_LIBADD = $(top_builddir)/src/libtncif/libtncif.la
 
 libtnccs_la_SOURCES = \
-       imc/imc.h imc/imc_manager.h
+       imc/imc.h imc/imc_manager.h \
+       imv/imv.h imv/imv_manager.h \
+       imv/imv_recommendations.h imv/imv_recommendations.c 
 
similarity index 99%
rename from src/libcharon/tnc/imv/imv_manager.h
rename to src/libtnccs/imv/imv_manager.h
index 97daedb134f72ebf3ab5a7a49fecdb350d310a41..bd10a69206bc911f3e85accc87d9f0eecaffbed6 100644 (file)
@@ -23,8 +23,6 @@
 
 typedef struct imv_manager_t imv_manager_t;
 
-#ifdef USE_TNC
-
 #include "imv.h"
 #include "imv_recommendations.h"
 
@@ -144,6 +142,4 @@ struct imv_manager_t {
        void (*destroy)(imv_manager_t *this);
 };
 
-#endif /* USE_TNC */
-
 #endif /** IMV_MANAGER_H_ @}*/