moved imc_manager to libtnccs

laforge/swu
Andreas Steffen 2011-10-20 21:12:29 +02:00
parent e4e96e5c67
commit f0fa002fd1
20 changed files with 166 additions and 73 deletions

View 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

View File

@ -20,6 +20,10 @@ if USE_LIBTNCIF
SUBDIRS += libtncif
endif
if USE_TNCCS
SUBDIRS += libtnccs
endif
if USE_PTS
SUBDIRS += libpts
endif

View 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}\" \

View 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>
@ -241,11 +240,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
*/

View 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

View 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.

View 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);

View File

@ -15,8 +15,6 @@
#include "tnc_imc_manager.h"
#include <tnc/imc/imc_manager.h>
#include <tncifimc.h>
#include <debug.h>

View 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.

View File

@ -24,13 +24,31 @@
#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, destroy, void,
tnc_imc_plugin_t *this)
METHOD(plugin_t, get_features, int,
private_tnc_imc_plugin_t *this, plugin_feature_t *features[])
{
charon->imcs->destroy(charon->imcs);
static plugin_feature_t f[] = {
PLUGIN_PROVIDE(CUSTOM, "imc-manager"),
};
*features = f;
return countof(f);
}
METHOD(plugin_t, destroy, void,
private_tnc_imc_plugin_t *this)
{
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;
}

View 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 = \

View 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;

View 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);

View 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 = \

View 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;

View 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);

View 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;

10
src/libtnccs/Makefile.am Normal file
View File

@ -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

View File

@ -23,8 +23,6 @@
typedef struct imc_manager_t imc_manager_t;
#ifdef USE_TNC
#include "imc.h"
#include <library.h>
@ -123,6 +121,4 @@ struct imc_manager_t {
void (*destroy)(imc_manager_t *this);
};
#endif /* USE_TNC */
#endif /** IMC_MANAGER_H_ @}*/