moved imc_manager to libtnccs
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 20 Oct 2011 19:12:29 +0000 (21:12 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 24 Oct 2011 23:10:16 +0000 (01:10 +0200)
22 files changed:
configure.in
src/Makefile.am
src/libcharon/Makefile.am
src/libcharon/daemon.h
src/libcharon/plugins/tnc_imc/Makefile.am
src/libcharon/plugins/tnc_imc/tnc_imc.h
src/libcharon/plugins/tnc_imc/tnc_imc_bind_function.c
src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
src/libcharon/plugins/tnc_imc/tnc_imc_manager.h
src/libcharon/plugins/tnc_imc/tnc_imc_plugin.c
src/libcharon/plugins/tnccs_11/Makefile.am
src/libcharon/plugins/tnccs_11/tnccs_11.c
src/libcharon/plugins/tnccs_11/tnccs_11_plugin.c
src/libcharon/plugins/tnccs_20/Makefile.am
src/libcharon/plugins/tnccs_20/tnccs_20.c
src/libcharon/plugins/tnccs_20/tnccs_20_plugin.c
src/libcharon/tnc/imc/imc.h [deleted file]
src/libcharon/tnc/imc/imc_manager.h [deleted file]
src/libcharon/tnc/tnccs/tnccs_manager.c
src/libtnccs/Makefile.am [new file with mode: 0644]
src/libtnccs/imc/imc.h [new file with mode: 0644]
src/libtnccs/imc/imc_manager.h [new file with mode: 0644]

index 516f5d9..c036962 100644 (file)
@@ -251,6 +251,10 @@ if test x$eap_tls = xtrue -o x$eap_ttls = xtrue -o x$eap_peap = xtrue; then
        tls=true;
 fi
 
+if test x$tnc_imc = xtrue -o x$tnc_imv = xtrue -o x$tnccs_11 = xtrue -o x$tnccs_11 = xtrue -o x$tnccs_dynamic = xtrue; then
+       tnccs=true;
+fi
+
 if test x$imc_test = xtrue -o x$imv_test = xtrue -o x$imc_scanner = xtrue -o x$imv_scanner = xtrue -o x$imc_attestation = xtrue -o x$imv_attestation = xtrue; then
        imcv=true;
 fi
@@ -1019,6 +1023,7 @@ AM_CONDITIONAL(USE_LIBCAP, test x$capabilities = xlibcap)
 AM_CONDITIONAL(USE_VSTR, test x$vstr = xtrue)
 AM_CONDITIONAL(USE_SIMAKA, test x$simaka = xtrue)
 AM_CONDITIONAL(USE_TLS, test x$tls = xtrue)
+AM_CONDITIONAL(USE_TNCCS, test x$tnccs = xtrue)
 AM_CONDITIONAL(USE_IMCV, test x$imcv = xtrue)
 AM_CONDITIONAL(USE_PTS, test x$pts = xtrue)
 AM_CONDITIONAL(MONOLITHIC, test x$monolithic = xtrue)
@@ -1097,6 +1102,7 @@ AC_OUTPUT(
        src/libsimaka/Makefile
        src/libtls/Makefile
        src/libtncif/Makefile
+       src/libtnccs/Makefile
        src/libpts/Makefile
        src/libimcv/Makefile
        src/libimcv/plugins/imc_test/Makefile
index 33e1b12..7f4651d 100644 (file)
@@ -20,6 +20,10 @@ if USE_LIBTNCIF
   SUBDIRS += libtncif
 endif
 
+if USE_TNCCS
+  SUBDIRS += libtnccs
+endif
+
 if USE_PTS
   SUBDIRS += libpts
 endif
index 371c787..6ddf41c 100644 (file)
@@ -87,7 +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/imc/imc.h tnc/imc/imc_manager.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 \
@@ -100,7 +99,8 @@ INCLUDES = \
        -I$(top_srcdir)/src/libstrongswan \
        -I$(top_srcdir)/src/libhydra \
        -I$(top_srcdir)/src/libcharon \
-       -I$(top_srcdir)/src/libtncif
+       -I$(top_srcdir)/src/libtncif \
+       -I$(top_srcdir)/src/libtnccs
 
 AM_CFLAGS = \
        -DIPSEC_DIR=\"${ipsecdir}\" \
index 0005cd1..3230e72 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/imc/imc_manager.h>
 #include <tnc/imv/imv_manager.h>
 #include <tnc/tnccs/tnccs_manager.h>
 
@@ -242,11 +241,6 @@ struct daemon_t {
        eap_manager_t *eap;
 
        /**
-        * TNC IMC manager controlling Integrity Measurement Collectors
-        */
-       imc_manager_t *imcs;
-
-       /**
         * TNC IMV manager controlling Integrity Measurement Verifiers
         */
        imv_manager_t *imvs;
index 35c9715..65c8781 100644 (file)
@@ -1,6 +1,10 @@
 
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
-       -I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libtncif
+INCLUDES = \
+       -I$(top_srcdir)/src/libstrongswan \
+       -I$(top_srcdir)/src/libhydra \
+       -I$(top_srcdir)/src/libcharon \
+       -I$(top_srcdir)/src/libtncif \
+       -I$(top_srcdir)/src/libtnccs
 
 AM_CFLAGS = -DUSE_TNC -rdynamic
 
index 10a67f9..2c5c67b 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TNC_IMC_H_
 #define TNC_IMC_H_
 
-#include <tnc/imc/imc.h>
+#include <imc/imc.h>
 
 /**
  * Create an Integrity Measurement Collector.
index 25a6a1c..9c023e6 100644 (file)
@@ -13,7 +13,7 @@
  * for more details.
  */
 
-#include "tnc_imc.h"
+#include <imc/imc_manager.h>
 
 #include <debug.h>
 #include <daemon.h>
@@ -28,14 +28,15 @@ TNC_Result TNC_TNCC_ReportMessageTypes(TNC_IMCID imc_id,
                                                                           TNC_MessageTypeList supported_types,
                                                                           TNC_UInt32 type_count)
 {
-       if (!charon->imcs->is_registered(charon->imcs, imc_id))
+       imc_manager_t *imcs = lib->get(lib, "imc-manager");
+
+       if (!imcs->is_registered(imcs, imc_id))
        {
                DBG1(DBG_TNC, "ignoring ReportMessageTypes() from unregistered IMC %u",
                                           imc_id);
                return TNC_RESULT_INVALID_PARAMETER;
        }
-       return charon->imcs->set_message_types(charon->imcs, imc_id,
-                                                                                  supported_types, type_count);
+       return imcs->set_message_types(imcs, imc_id, supported_types, type_count);
 }
 
 /**
@@ -45,7 +46,9 @@ TNC_Result TNC_TNCC_RequestHandshakeRetry(TNC_IMCID imc_id,
                                                                                  TNC_ConnectionID connection_id,
                                                                                  TNC_RetryReason reason)
 {
-       if (!charon->imcs->is_registered(charon->imcs, imc_id))
+       imc_manager_t *imcs = lib->get(lib, "imc-manager");
+
+       if (!imcs->is_registered(imcs, imc_id))
        {
                DBG1(DBG_TNC, "ignoring RequestHandshakeRetry() from unregistered IMC %u",
                                           imc_id);
@@ -64,7 +67,9 @@ TNC_Result TNC_TNCC_SendMessage(TNC_IMCID imc_id,
                                                                TNC_UInt32 msg_len,
                                                                TNC_MessageType msg_type)
 {
-       if (!charon->imcs->is_registered(charon->imcs, imc_id))
+       imc_manager_t *imcs = lib->get(lib, "imc-manager");
+
+       if (!imcs->is_registered(imcs, imc_id))
        {
                DBG1(DBG_TNC, "ignoring SendMessage() from unregistered IMC %u",
                                           imc_id);
index c8cc06e..0d0737c 100644 (file)
@@ -15,8 +15,6 @@
 
 #include "tnc_imc_manager.h"
 
-#include <tnc/imc/imc_manager.h>
-
 #include <tncifimc.h>
 
 #include <debug.h>
index ed49029..800ee39 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TNC_IMC_MANAGER_H_
 #define TNC_IMC_MANAGER_H_
 
-#include <tnc/imc/imc_manager.h>
+#include <imc/imc_manager.h>
 
 /**
  * Create an IMC manager instance.
index bc13b87..e785299 100644 (file)
 #include <errno.h>
 #include <fcntl.h>
 
-#include <daemon.h>
 #include <utils/lexparser.h>
+#include <debug.h>
+
+typedef struct private_tnc_imc_plugin_t private_tnc_imc_plugin_t;
+
+/**
+ * Private data of a tnc_imc_plugin_t object.
+ */
+struct private_tnc_imc_plugin_t {
+
+       /**
+        * Public interface.
+        */
+       tnc_imc_plugin_t public;
+
+       /**
+        * TNC IMC manager controlling Integrity Measurement Collectors
+        */
+       imc_manager_t *imcs;
+};
 
 /**
  * load IMCs from a configuration file
  */
-static bool load_imcs(char *filename)
+static bool load_imcs(private_tnc_imc_plugin_t *this, char *filename)
 {
        int fd, line_nr = 0;
        chunk_t src, line;
@@ -128,7 +146,7 @@ static bool load_imcs(char *filename)
                        free(path);
                        return FALSE;
                }
-               if (!charon->imcs->add(charon->imcs, imc))
+               if (!this->imcs->add(this->imcs, imc))
                {
                        if (imc->terminate &&
                                imc->terminate(imc->get_id(imc)) != TNC_RESULT_SUCCESS)
@@ -148,47 +166,59 @@ static bool load_imcs(char *filename)
 }
 
 METHOD(plugin_t, get_name, char*,
-       tnc_imc_plugin_t *this)
+       private_tnc_imc_plugin_t *this)
 {
        return "tnc-imc";
 }
 
+METHOD(plugin_t, get_features, int,
+       private_tnc_imc_plugin_t *this, plugin_feature_t *features[])
+{
+       static plugin_feature_t f[] = {
+               PLUGIN_PROVIDE(CUSTOM, "imc-manager"),
+       };
+       *features = f;
+       return countof(f);
+}
+
 METHOD(plugin_t, destroy, void,
-       tnc_imc_plugin_t *this)
+       private_tnc_imc_plugin_t *this)
 {
-       charon->imcs->destroy(charon->imcs);
+       lib->set(lib, "imc-manager", NULL);
+       this->imcs->destroy(this->imcs);
        free(this);
 }
 
 /*
  * see header file
  */
-plugin_t *tnc_imc_plugin_create()
+plugin_t *tnc_imc_plugin_create(void)
 {
+       private_tnc_imc_plugin_t *this;
        char *tnc_config;
-       tnc_imc_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,
+                       },
                },
+               .imcs = tnc_imc_manager_create(),
        );
 
-       /* Create IMC manager */
-       charon->imcs = tnc_imc_manager_create();
+       lib->set(lib, "imc-manager", this->imcs);
 
        /* Load IMCs and abort if not all instances initalize successfully */
        tnc_config = lib->settings->get_str(lib->settings,
                                        "charon.plugins.tnc-imc.tnc_config", "/etc/tnc_config");
-       if (!load_imcs(tnc_config))
+       if (!load_imcs(this, tnc_config))
        {
-               charon->imcs->destroy(charon->imcs);
-               charon->imcs = NULL;
-               free(this);
+               destroy(this);
                return NULL;
        }
-       return &this->plugin;
+
+       return &this->public.plugin;
 }
 
index 4b51a3c..782aeb0 100644 (file)
@@ -1,7 +1,12 @@
 
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
-       -I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libtls \
-       -I$(top_srcdir)/src/libtncif ${xml_CFLAGS}
+INCLUDES = \
+       -I$(top_srcdir)/src/libstrongswan \
+       -I$(top_srcdir)/src/libhydra \
+       -I$(top_srcdir)/src/libcharon \
+       -I$(top_srcdir)/src/libtls \
+       -I$(top_srcdir)/src/libtncif \
+       -I$(top_srcdir)/src/libtnccs \
+       ${xml_CFLAGS}
 
 AM_CFLAGS = -DUSE_TNC -rdynamic
 
@@ -11,7 +16,9 @@ if MONOLITHIC
 noinst_LTLIBRARIES = libstrongswan-tnccs-11.la
 else
 plugin_LTLIBRARIES = libstrongswan-tnccs-11.la
-libstrongswan_tnccs_11_la_LIBADD += $(top_builddir)/src/libtncif/libtncif.la
+libstrongswan_tnccs_11_la_LIBADD += \
+       $(top_builddir)/src/libtncif/libtncif.la \
+       $(top_builddir)/src/libtnccs/libtnccs.la
 endif
 
 libstrongswan_tnccs_11_la_SOURCES = \
index 53ac998..c7f9673 100644 (file)
@@ -25,6 +25,8 @@
 #include <tncif_names.h>
 #include <tncif_pa_subtypes.h>
 
+#include <imc/imc_manager.h>
+
 #include <daemon.h>
 #include <debug.h>
 #include <threading/mutex.h>
@@ -91,6 +93,12 @@ struct private_tnccs_11_t {
         * Set of IMV recommendations  (TNC Server only)
         */
        recommendations_t *recs;
+
+       /**
+        * TNC IMC manager controlling Integrity Measurement Collectors
+        */
+       imc_manager_t *imcs;
+
 };
 
 METHOD(tnccs_t, send_msg, TNC_Result,
@@ -178,7 +186,7 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
                        }
                        else
                        {
-                               charon->imcs->receive_message(charon->imcs,
+                               this->imcs->receive_message(this->imcs,
                                this->connection_id, msg_body.ptr, msg_body.len,msg_type);
                        }
                        this->send_msg = FALSE;
@@ -212,8 +220,8 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
                                default:
                                        state = TNC_CONNECTION_STATE_ACCESS_NONE;
                        }
-                       charon->imcs->notify_connection_change(charon->imcs,
-                                                                                                  this->connection_id, state);
+                       this->imcs->notify_connection_change(this->imcs,
+                                                                                                this->connection_id, state);
                        this->delete_state = TRUE;
                        break;
                }
@@ -339,7 +347,7 @@ METHOD(tls_t, process, status_t,
                }
                else
                {
-                       charon->imcs->batch_ending(charon->imcs, this->connection_id);
+                       this->imcs->batch_ending(this->imcs, this->connection_id);
                }
                this->send_msg = FALSE;
        }
@@ -409,19 +417,19 @@ METHOD(tls_t, build, status_t,
                }
 
                /* Create TNCCS-PreferredLanguage message */
-               pref_lang = charon->imcs->get_preferred_language(charon->imcs);
+               pref_lang = this->imcs->get_preferred_language(this->imcs);
                msg = tnccs_preferred_language_msg_create(pref_lang);
                this->mutex->lock(this->mutex);
                this->batch = tnccs_batch_create(this->is_server, ++this->batch_id);
                this->batch->add_msg(this->batch, msg);
                this->mutex->unlock(this->mutex);
 
-               charon->imcs->notify_connection_change(charon->imcs,
+               this->imcs->notify_connection_change(this->imcs,
                                                        this->connection_id, TNC_CONNECTION_STATE_CREATE);
-               charon->imcs->notify_connection_change(charon->imcs,
+               this->imcs->notify_connection_change(this->imcs,
                                                        this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
                this->send_msg = TRUE;
-               charon->imcs->begin_handshake(charon->imcs, this->connection_id);
+               this->imcs->begin_handshake(this->imcs, this->connection_id);
                this->send_msg = FALSE;
        }
 
@@ -531,6 +539,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"),
        );
 
        return &this->public;
index 9d227f0..c2c173e 100644 (file)
@@ -32,6 +32,8 @@ METHOD(plugin_t, get_features, int,
                        PLUGIN_PROVIDE(CUSTOM, "tnccs-1.1"),
                                PLUGIN_DEPENDS(EAP_SERVER, EAP_TNC),
                                PLUGIN_DEPENDS(EAP_PEER, EAP_TNC),
+                               PLUGIN_SDEPEND(CUSTOM, "imc-manager"),
+                               PLUGIN_SDEPEND(CUSTOM, "imv-manager"),
        };
        *features = f;
        return countof(f);
index ec34835..6e16485 100644 (file)
@@ -1,7 +1,11 @@
 
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
-       -I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libtls \
-       -I$(top_srcdir)/src/libtncif
+INCLUDES = \
+       -I$(top_srcdir)/src/libstrongswan \
+       -I$(top_srcdir)/src/libhydra \
+       -I$(top_srcdir)/src/libcharon \
+       -I$(top_srcdir)/src/libtls \
+       -I$(top_srcdir)/src/libtncif \
+       -I$(top_srcdir)/src/libtnccs
 
 AM_CFLAGS = -DUSE_TNC -rdynamic
 
@@ -9,7 +13,9 @@ if MONOLITHIC
 noinst_LTLIBRARIES = libstrongswan-tnccs-20.la
 else
 plugin_LTLIBRARIES = libstrongswan-tnccs-20.la
-libstrongswan_tnccs_20_la_LIBADD = $(top_builddir)/src/libtncif/libtncif.la
+libstrongswan_tnccs_20_la_LIBADD = \
+       $(top_builddir)/src/libtncif/libtncif.la \
+       $(top_builddir)/src/libtnccs/libtnccs.la
 endif
 
 libstrongswan_tnccs_20_la_SOURCES = \
index db1a4ba..c9e62e0 100644 (file)
@@ -29,6 +29,8 @@
 #include <tncif_names.h>
 #include <tncif_pa_subtypes.h>
 
+#include <imc/imc_manager.h>
+
 #include <debug.h>
 #include <daemon.h>
 #include <threading/mutex.h>
@@ -91,6 +93,12 @@ struct private_tnccs_20_t {
         * Set of IMV recommendations  (TNC Server only)
         */
        recommendations_t *recs;
+
+       /**
+        * TNC IMC manager controlling Integrity Measurement Collectors
+        */
+       imc_manager_t *imcs;
+
 };
 
 METHOD(tnccs_t, send_msg, TNC_Result,
@@ -195,7 +203,7 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
                        }
                        else
                        {
-                               charon->imcs->receive_message(charon->imcs,
+                               this->imcs->receive_message(this->imcs,
                                this->connection_id, msg_body.ptr, msg_body.len,msg_type);
                        }
                        this->send_msg = FALSE;
@@ -233,8 +241,8 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
                                case PB_REC_QUARANTINED:
                                        state = TNC_CONNECTION_STATE_ACCESS_ISOLATED;
                        }
-                       charon->imcs->notify_connection_change(charon->imcs,
-                                                                                                  this->connection_id, state);
+                       this->imcs->notify_connection_change(this->imcs,
+                                                                                                this->connection_id, state);
                        break;
                }
                case PB_MSG_REMEDIATION_PARAMETERS:
@@ -405,10 +413,10 @@ METHOD(tls_t, process, status_t,
                else if (batch_type == PB_BATCH_SRETRY)
                {
                        /* Restart the measurements */
-                       charon->imcs->notify_connection_change(charon->imcs,
+                       this->imcs->notify_connection_change(this->imcs,
                        this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
                        this->send_msg = TRUE;
-                       charon->imcs->begin_handshake(charon->imcs, this->connection_id);
+                       this->imcs->begin_handshake(this->imcs, this->connection_id);
                        this->send_msg = FALSE;
                }
 
@@ -443,7 +451,7 @@ METHOD(tls_t, process, status_t,
                }
                else
                {
-                       charon->imcs->batch_ending(charon->imcs, this->connection_id);
+                       this->imcs->batch_ending(this->imcs, this->connection_id);
                }
                this->send_msg = FALSE;
        }
@@ -556,7 +564,7 @@ METHOD(tls_t, build, status_t,
                }
 
                /* Create PB-TNC Language Preference message */
-               pref_lang = charon->imcs->get_preferred_language(charon->imcs);
+               pref_lang = this->imcs->get_preferred_language(this->imcs);
                msg = pb_language_preference_msg_create(chunk_create(pref_lang,
                                                                                                        strlen(pref_lang)));
                this->mutex->lock(this->mutex);
@@ -564,12 +572,12 @@ METHOD(tls_t, build, status_t,
                this->batch->add_msg(this->batch, msg);
                this->mutex->unlock(this->mutex);
 
-               charon->imcs->notify_connection_change(charon->imcs,
+               this->imcs->notify_connection_change(this->imcs,
                                                        this->connection_id, TNC_CONNECTION_STATE_CREATE);
-               charon->imcs->notify_connection_change(charon->imcs,
+               this->imcs->notify_connection_change(this->imcs,
                                                        this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
                this->send_msg = TRUE;
-               charon->imcs->begin_handshake(charon->imcs, this->connection_id);
+               this->imcs->begin_handshake(this->imcs, this->connection_id);
                this->send_msg = FALSE;
        }
 
@@ -731,6 +739,7 @@ tls_t *tnccs_20_create(bool is_server)
                .is_server = is_server,
                .state_machine = pb_tnc_state_machine_create(is_server),
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
+               .imcs = lib->get(lib, "imc-manager"),
        );
 
        return &this->public;
index a44c614..e06b41d 100644 (file)
@@ -32,6 +32,8 @@ METHOD(plugin_t, get_features, int,
                        PLUGIN_PROVIDE(CUSTOM, "tnccs-2.0"),
                                PLUGIN_DEPENDS(EAP_SERVER, EAP_TNC),
                                PLUGIN_DEPENDS(EAP_PEER, EAP_TNC),
+                               PLUGIN_SDEPEND(CUSTOM, "imc-manager"),
+                               PLUGIN_SDEPEND(CUSTOM, "imv-manager"),
        };
        *features = f;
        return countof(f);
diff --git a/src/libcharon/tnc/imc/imc.h b/src/libcharon/tnc/imc/imc.h
deleted file mode 100644 (file)
index ddedf71..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2010 Andreas Steffen
- * HSR 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 imc imc
- * @ingroup tnc
- *
- * @defgroup imct imc
- * @{ @ingroup imc
- */
-
-#ifndef IMC_H_
-#define IMC_H_
-
-#include <tncifimc.h>
-
-#include <library.h>
-
-typedef struct imc_t imc_t;
-
-/**
- * Controls a single Integrity Measurement Collector (IMC)
- */
-struct imc_t {
-
-       /**
-        * The TNC Client calls this function to initialize the IMC and agree on
-        * the API version number to be used. It also supplies the IMC ID, an IMC
-        * identifier that the IMC must use when calling TNC Client callback functions.
-        *
-        * @param imcID                         IMC ID assigned by TNCC
-        * @param minVersion            minimum API version supported by TNCC
-        * @param maxVersion            maximum API version supported by TNCC
-        * @param OutActualVersion      mutually supported API version number
-        * @return                                      TNC result code
-        */
-       TNC_Result (*initialize)(TNC_IMCID imcID,
-                                                        TNC_Version minVersion,
-                                                        TNC_Version maxVersion,
-                                                        TNC_Version *OutActualVersion);
-
-       /**
-        * The TNC Client calls this function to inform the IMC that the state of
-        * the network connection identified by connectionID has changed to newState.
-        *
-        * @param imcID                         IMC ID assigned by TNCC
-        * @param connectionID          network connection ID assigned by TNCC
-        * @param newState                      new network connection state
-        * @return                                      TNC result code
-        */
-       TNC_Result (*notify_connection_change)(TNC_IMCID imcID,
-                                                                                  TNC_ConnectionID connectionID,
-                                                                                  TNC_ConnectionState newState);
-
-       /**
-        * The TNC Client calls this function to indicate that an Integrity Check
-        * Handshake is beginning and solicit messages from IMCs for the first batch.
-        *
-        * @param imcID                         IMC ID assigned by TNCC
-        * @param connectionID          network connection ID assigned by TNCC
-        * @return                                      TNC result code
-        */
-       TNC_Result (*begin_handshake)(TNC_IMCID imcID,
-                                                                 TNC_ConnectionID connectionID);
-
-       /**
-        * The TNC Client calls this function to deliver a message to the IMC.
-        * The message is contained in the buffer referenced by message and contains
-        * the number of octets indicated by messageLength. The type of the message
-        * is indicated by messageType.
-        *
-        * @param imcID                         IMC ID assigned by TNCS
-        * @param connectionID          network connection ID assigned by TNCC
-        * @param message                       reference to buffer containing message
-        * @param messageLength         number of octets in message
-        * @param messageType           message type of message
-        * @return                                      TNC result code
-        */
-       TNC_Result (*receive_message)(TNC_IMCID imcID,
-                                                                 TNC_ConnectionID connectionID,
-                                                                 TNC_BufferReference message,
-                                                                 TNC_UInt32 messageLength,
-                                                                 TNC_MessageType messageType);
-
-       /**
-        * The TNC Client calls this function to notify IMCs that all IMV messages
-        * received in a batch have been delivered and this is the IMC’s last chance
-        * to send a message in the batch of IMC messages currently being collected.
-        *
-        * @param imcID                         IMC ID assigned by TNCC
-        * @param connectionID          network connection ID assigned by TNCC
-        * @return                                      TNC result code
-        */
-       TNC_Result (*batch_ending)(TNC_IMCID imcID,
-                                                          TNC_ConnectionID connectionID);
-
-       /**
-        * The TNC Client calls this function to close down the IMC when all work is
-        * complete or the IMC reports TNC_RESULT_FATAL.
-        *
-        * @param imcID                         IMC ID assigned by TNCC
-        * @return                                      TNC result code
-        */
-       TNC_Result (*terminate)(TNC_IMCID imcID);
-
-       /**
-        * IMVs implementing the UNIX/Linux Dynamic Linkage platform binding MUST
-        * define this additional function. The TNC Server MUST call the function
-        * immediately after calling TNC_IMV_Initialize to provide a pointer to the
-        * TNCS bind function. The IMV can then use the TNCS bind function to obtain
-        * pointers to any other TNCS functions.
-        *
-        * @param imcID                         IMC ID assigned by TNCC
-        * @param bindFunction          pointer to TNC_TNCC_BindFunction
-        * @return                                      TNC result code
-        */
-       TNC_Result (*provide_bind_function)(TNC_IMCID imcID,
-                                                                               TNC_TNCC_BindFunctionPointer bindFunction);
-
-       /**
-        * Sets the ID of an imc_t object.
-        *
-        * @param id                            IMC ID to be assigned
-        */
-       void (*set_id)(imc_t *this, TNC_IMCID id);
-
-       /**
-        * Returns the ID of an imc_t object.
-        *
-        * @return                                      assigned IMC ID
-        */
-       TNC_IMCID (*get_id)(imc_t *this);
-
-       /**
-        * Returns the name of an imc_t object.
-        *
-        * @return                                      name of IMC
-        */
-       char* (*get_name)(imc_t *this);
-
-       /**
-        * Sets the supported message types of an imc_t object.
-        *
-        * @param supported_types       list of messages type supported by IMC
-        * @param type_count            number of supported message types
-        */
-       void (*set_message_types)(imc_t *this, TNC_MessageTypeList supported_types,
-                                                                                  TNC_UInt32 type_count);
-
-       /**
-        * Check if the IMC supports a given message type.
-        *
-        * @param message_type          message type
-        * @return                                      TRUE if supported
-        */
-       bool (*type_supported)(imc_t *this, TNC_MessageType message_type);
-
-       /**
-        * Destroys an imc_t object.
-        */
-       void (*destroy)(imc_t *this);
-};
-
-#endif /** IMC_H_ @}*/
diff --git a/src/libcharon/tnc/imc/imc_manager.h b/src/libcharon/tnc/imc/imc_manager.h
deleted file mode 100644 (file)
index 11104b6..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2010 Andreas Steffen
- * HSR 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 imc_manager imc_manager
- * @{ @ingroup imc
- */
-
-#ifndef IMC_MANAGER_H_
-#define IMC_MANAGER_H_
-
-typedef struct imc_manager_t imc_manager_t;
-
-#ifdef USE_TNC
-
-#include "imc.h"
-
-#include <library.h>
-
-/**
- * The IMC manager controls all IMC instances.
- */
-struct imc_manager_t {
-
-       /**
-        * Add an IMC instance
-        *
-        * @param imc                           IMC instance
-        * @return                                      TRUE if initialization successful
-        */
-        bool (*add)(imc_manager_t *this, imc_t *imc);
-
-       /**
-        * Remove an IMC instance from the list and return it
-        *
-        * @param id                            ID of IMC instance
-        * @return                                      removed IMC instance
-        */
-       imc_t* (*remove)(imc_manager_t *this, TNC_IMCID id);
-
-       /**
-        * Check if an IMC with a given ID is registered with the IMC manager
-        *
-        * @param id                            ID of IMC instance
-        * @return                                      TRUE if registered
-        */
-       bool (*is_registered)(imc_manager_t *this, TNC_IMCID id);
-
-       /**
-        * Return the preferred language for recommendations
-        *
-        * @return                                      preferred language string
-        */
-       char* (*get_preferred_language)(imc_manager_t *this);
-
-       /**
-        * Notify all IMC instances
-        *
-        * @param state                 communicate the state a connection has reached
-        */
-       void (*notify_connection_change)(imc_manager_t *this,
-                                                                        TNC_ConnectionID id,
-                                                                        TNC_ConnectionState state);
-
-       /**
-        * Begin a handshake between the IMCs and a connection
-        *
-        * @param id                            connection ID
-        */
-       void (*begin_handshake)(imc_manager_t *this, TNC_ConnectionID id);
-
-       /**
-        * Sets the supported message types reported by a given IMC
-        *
-        * @param id                            ID of reporting IMC
-        * @param supported_types       list of messages type supported by IMC
-        * @param type_count            number of supported message types
-        * @return                                      TNC result code
-        */
-       TNC_Result (*set_message_types)(imc_manager_t *this,
-                                                                       TNC_IMCID id,
-                                                                       TNC_MessageTypeList supported_types,
-                                                                       TNC_UInt32 type_count);
-
-       /**
-        * Delivers a message to interested IMCs.
-        *
-        * @param connection_id         ID of connection over which message was received
-        * @param message                       message
-        * @param message_len           message length
-        * @param message_type          message type
-        */
-       void (*receive_message)(imc_manager_t *this,
-                                                       TNC_ConnectionID connection_id,
-                                                       TNC_BufferReference message,
-                                                       TNC_UInt32 message_len,
-                                                       TNC_MessageType message_type);
-
-       /**
-        * Notify all IMCs that all IMV messages received in a batch have been
-        * delivered and this is the IMCs last chance to send a message in the
-        * batch of IMC messages currently being collected.
-        *
-        * @param id                            connection ID
-        */
-       void (*batch_ending)(imc_manager_t *this, TNC_ConnectionID id);
-
-       /**
-        * Destroy an IMC manager and all its controlled instances.
-        */
-       void (*destroy)(imc_manager_t *this);
-};
-
-#endif /* USE_TNC */
-
-#endif /** IMC_MANAGER_H_ @}*/
index db72011..0e4107e 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "tnccs_manager.h"
 
+#include <imc/imc_manager.h>
 #include <tnc/imv/imv_recommendations.h>
 
 #include <debug.h>
@@ -110,6 +111,11 @@ struct private_tnccs_manager_t {
         */
        rwlock_t *connection_lock;
 
+       /**
+        * TNC IMC manager controlling Integrity Measurement Collectors
+        */
+       imc_manager_t *imcs;
+
 };
 
 METHOD(tnccs_manager_t, add_method, void,
@@ -199,7 +205,11 @@ METHOD(tnccs_manager_t, create_connection, TNC_ConnectionID,
        else
        {
                /* we assume a TNC Client */
-               if (!charon->imcs)
+               if (!this->imcs)
+               {
+                       this->imcs = lib->get(lib, "imc-manager");
+               }
+               if (!this->imcs)
                {
                        DBG1(DBG_TNC, "no IMC manager available!");
                        free(entry);
@@ -232,9 +242,9 @@ METHOD(tnccs_manager_t, remove_connection, void,
        }
        else
        {
-               if (charon->imcs)
+               if (this->imcs)
                {
-                       charon->imcs->notify_connection_change(charon->imcs, id,
+                       this->imcs->notify_connection_change(this->imcs, id,
                                                                                TNC_CONNECTION_STATE_DELETE);
                }
        }
@@ -500,6 +510,7 @@ tnccs_manager_t *tnccs_manager_create()
                        .connections = linked_list_create(),
                        .protocol_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
                        .connection_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
+                       .imcs = lib->get(lib, "imc-manager"),
        );
 
        return &this->public;
diff --git a/src/libtnccs/Makefile.am b/src/libtnccs/Makefile.am
new file mode 100644 (file)
index 0000000..0348144
--- /dev/null
@@ -0,0 +1,10 @@
+
+INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libtncif
+
+ipseclib_LTLIBRARIES = libtnccs.la
+
+libtnccs_la_LIBADD = $(top_builddir)/src/libtncif/libtncif.la
+
+libtnccs_la_SOURCES = \
+       imc/imc.h imc/imc_manager.h
+
diff --git a/src/libtnccs/imc/imc.h b/src/libtnccs/imc/imc.h
new file mode 100644 (file)
index 0000000..ddedf71
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2010 Andreas Steffen
+ * HSR 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 imc imc
+ * @ingroup tnc
+ *
+ * @defgroup imct imc
+ * @{ @ingroup imc
+ */
+
+#ifndef IMC_H_
+#define IMC_H_
+
+#include <tncifimc.h>
+
+#include <library.h>
+
+typedef struct imc_t imc_t;
+
+/**
+ * Controls a single Integrity Measurement Collector (IMC)
+ */
+struct imc_t {
+
+       /**
+        * The TNC Client calls this function to initialize the IMC and agree on
+        * the API version number to be used. It also supplies the IMC ID, an IMC
+        * identifier that the IMC must use when calling TNC Client callback functions.
+        *
+        * @param imcID                         IMC ID assigned by TNCC
+        * @param minVersion            minimum API version supported by TNCC
+        * @param maxVersion            maximum API version supported by TNCC
+        * @param OutActualVersion      mutually supported API version number
+        * @return                                      TNC result code
+        */
+       TNC_Result (*initialize)(TNC_IMCID imcID,
+                                                        TNC_Version minVersion,
+                                                        TNC_Version maxVersion,
+                                                        TNC_Version *OutActualVersion);
+
+       /**
+        * The TNC Client calls this function to inform the IMC that the state of
+        * the network connection identified by connectionID has changed to newState.
+        *
+        * @param imcID                         IMC ID assigned by TNCC
+        * @param connectionID          network connection ID assigned by TNCC
+        * @param newState                      new network connection state
+        * @return                                      TNC result code
+        */
+       TNC_Result (*notify_connection_change)(TNC_IMCID imcID,
+                                                                                  TNC_ConnectionID connectionID,
+                                                                                  TNC_ConnectionState newState);
+
+       /**
+        * The TNC Client calls this function to indicate that an Integrity Check
+        * Handshake is beginning and solicit messages from IMCs for the first batch.
+        *
+        * @param imcID                         IMC ID assigned by TNCC
+        * @param connectionID          network connection ID assigned by TNCC
+        * @return                                      TNC result code
+        */
+       TNC_Result (*begin_handshake)(TNC_IMCID imcID,
+                                                                 TNC_ConnectionID connectionID);
+
+       /**
+        * The TNC Client calls this function to deliver a message to the IMC.
+        * The message is contained in the buffer referenced by message and contains
+        * the number of octets indicated by messageLength. The type of the message
+        * is indicated by messageType.
+        *
+        * @param imcID                         IMC ID assigned by TNCS
+        * @param connectionID          network connection ID assigned by TNCC
+        * @param message                       reference to buffer containing message
+        * @param messageLength         number of octets in message
+        * @param messageType           message type of message
+        * @return                                      TNC result code
+        */
+       TNC_Result (*receive_message)(TNC_IMCID imcID,
+                                                                 TNC_ConnectionID connectionID,
+                                                                 TNC_BufferReference message,
+                                                                 TNC_UInt32 messageLength,
+                                                                 TNC_MessageType messageType);
+
+       /**
+        * The TNC Client calls this function to notify IMCs that all IMV messages
+        * received in a batch have been delivered and this is the IMC’s last chance
+        * to send a message in the batch of IMC messages currently being collected.
+        *
+        * @param imcID                         IMC ID assigned by TNCC
+        * @param connectionID          network connection ID assigned by TNCC
+        * @return                                      TNC result code
+        */
+       TNC_Result (*batch_ending)(TNC_IMCID imcID,
+                                                          TNC_ConnectionID connectionID);
+
+       /**
+        * The TNC Client calls this function to close down the IMC when all work is
+        * complete or the IMC reports TNC_RESULT_FATAL.
+        *
+        * @param imcID                         IMC ID assigned by TNCC
+        * @return                                      TNC result code
+        */
+       TNC_Result (*terminate)(TNC_IMCID imcID);
+
+       /**
+        * IMVs implementing the UNIX/Linux Dynamic Linkage platform binding MUST
+        * define this additional function. The TNC Server MUST call the function
+        * immediately after calling TNC_IMV_Initialize to provide a pointer to the
+        * TNCS bind function. The IMV can then use the TNCS bind function to obtain
+        * pointers to any other TNCS functions.
+        *
+        * @param imcID                         IMC ID assigned by TNCC
+        * @param bindFunction          pointer to TNC_TNCC_BindFunction
+        * @return                                      TNC result code
+        */
+       TNC_Result (*provide_bind_function)(TNC_IMCID imcID,
+                                                                               TNC_TNCC_BindFunctionPointer bindFunction);
+
+       /**
+        * Sets the ID of an imc_t object.
+        *
+        * @param id                            IMC ID to be assigned
+        */
+       void (*set_id)(imc_t *this, TNC_IMCID id);
+
+       /**
+        * Returns the ID of an imc_t object.
+        *
+        * @return                                      assigned IMC ID
+        */
+       TNC_IMCID (*get_id)(imc_t *this);
+
+       /**
+        * Returns the name of an imc_t object.
+        *
+        * @return                                      name of IMC
+        */
+       char* (*get_name)(imc_t *this);
+
+       /**
+        * Sets the supported message types of an imc_t object.
+        *
+        * @param supported_types       list of messages type supported by IMC
+        * @param type_count            number of supported message types
+        */
+       void (*set_message_types)(imc_t *this, TNC_MessageTypeList supported_types,
+                                                                                  TNC_UInt32 type_count);
+
+       /**
+        * Check if the IMC supports a given message type.
+        *
+        * @param message_type          message type
+        * @return                                      TRUE if supported
+        */
+       bool (*type_supported)(imc_t *this, TNC_MessageType message_type);
+
+       /**
+        * Destroys an imc_t object.
+        */
+       void (*destroy)(imc_t *this);
+};
+
+#endif /** IMC_H_ @}*/
diff --git a/src/libtnccs/imc/imc_manager.h b/src/libtnccs/imc/imc_manager.h
new file mode 100644 (file)
index 0000000..b475e0e
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2010 Andreas Steffen
+ * HSR 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 imc_manager imc_manager
+ * @{ @ingroup imc
+ */
+
+#ifndef IMC_MANAGER_H_
+#define IMC_MANAGER_H_
+
+typedef struct imc_manager_t imc_manager_t;
+
+#include "imc.h"
+
+#include <library.h>
+
+/**
+ * The IMC manager controls all IMC instances.
+ */
+struct imc_manager_t {
+
+       /**
+        * Add an IMC instance
+        *
+        * @param imc                           IMC instance
+        * @return                                      TRUE if initialization successful
+        */
+        bool (*add)(imc_manager_t *this, imc_t *imc);
+
+       /**
+        * Remove an IMC instance from the list and return it
+        *
+        * @param id                            ID of IMC instance
+        * @return                                      removed IMC instance
+        */
+       imc_t* (*remove)(imc_manager_t *this, TNC_IMCID id);
+
+       /**
+        * Check if an IMC with a given ID is registered with the IMC manager
+        *
+        * @param id                            ID of IMC instance
+        * @return                                      TRUE if registered
+        */
+       bool (*is_registered)(imc_manager_t *this, TNC_IMCID id);
+
+       /**
+        * Return the preferred language for recommendations
+        *
+        * @return                                      preferred language string
+        */
+       char* (*get_preferred_language)(imc_manager_t *this);
+
+       /**
+        * Notify all IMC instances
+        *
+        * @param state                 communicate the state a connection has reached
+        */
+       void (*notify_connection_change)(imc_manager_t *this,
+                                                                        TNC_ConnectionID id,
+                                                                        TNC_ConnectionState state);
+
+       /**
+        * Begin a handshake between the IMCs and a connection
+        *
+        * @param id                            connection ID
+        */
+       void (*begin_handshake)(imc_manager_t *this, TNC_ConnectionID id);
+
+       /**
+        * Sets the supported message types reported by a given IMC
+        *
+        * @param id                            ID of reporting IMC
+        * @param supported_types       list of messages type supported by IMC
+        * @param type_count            number of supported message types
+        * @return                                      TNC result code
+        */
+       TNC_Result (*set_message_types)(imc_manager_t *this,
+                                                                       TNC_IMCID id,
+                                                                       TNC_MessageTypeList supported_types,
+                                                                       TNC_UInt32 type_count);
+
+       /**
+        * Delivers a message to interested IMCs.
+        *
+        * @param connection_id         ID of connection over which message was received
+        * @param message                       message
+        * @param message_len           message length
+        * @param message_type          message type
+        */
+       void (*receive_message)(imc_manager_t *this,
+                                                       TNC_ConnectionID connection_id,
+                                                       TNC_BufferReference message,
+                                                       TNC_UInt32 message_len,
+                                                       TNC_MessageType message_type);
+
+       /**
+        * Notify all IMCs that all IMV messages received in a batch have been
+        * delivered and this is the IMCs last chance to send a message in the
+        * batch of IMC messages currently being collected.
+        *
+        * @param id                            connection ID
+        */
+       void (*batch_ending)(imc_manager_t *this, TNC_ConnectionID id);
+
+       /**
+        * Destroy an IMC manager and all its controlled instances.
+        */
+       void (*destroy)(imc_manager_t *this);
+};
+
+#endif /** IMC_MANAGER_H_ @}*/