moved imc_manager to libtnccs

This commit is contained in:
Andreas Steffen
2011-10-25 01:10:16 +02:00
parent e4e96e5c67
commit f0fa002fd1
20 changed files with 166 additions and 73 deletions
+6 -2
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
+1 -1
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.
@@ -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);
@@ -15,8 +15,6 @@
#include "tnc_imc_manager.h"
#include <tnc/imc/imc_manager.h>
#include <tncifimc.h>
#include <debug.h>
@@ -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.
+50 -20
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;
}