refactored TNC framework
This commit is contained in:
@@ -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 = -rdynamic
|
||||
|
||||
@@ -9,7 +13,9 @@ if MONOLITHIC
|
||||
noinst_LTLIBRARIES = libstrongswan-eap-tnc.la
|
||||
else
|
||||
plugin_LTLIBRARIES = libstrongswan-eap-tnc.la
|
||||
libstrongswan_eap_tnc_la_LIBADD = $(top_builddir)/src/libtls/libtls.la
|
||||
libstrongswan_eap_tnc_la_LIBADD = \
|
||||
$(top_builddir)/src/libtls/libtls.la \
|
||||
$(top_builddir)/src/libtnccs/libtnccs.la
|
||||
endif
|
||||
|
||||
libstrongswan_eap_tnc_la_SOURCES = \
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
|
||||
#include "eap_tnc.h"
|
||||
|
||||
#include <tnc/tnc.h>
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
#include <tls_eap.h>
|
||||
#include <debug.h>
|
||||
|
||||
#define USE_TNC
|
||||
|
||||
#include <daemon.h>
|
||||
|
||||
typedef struct private_eap_tnc_t private_eap_tnc_t;
|
||||
|
||||
/**
|
||||
@@ -174,7 +172,7 @@ static eap_tnc_t *eap_tnc_create(identification_t *server,
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
tnccs = charon->tnccs->create_instance(charon->tnccs, type, is_server);
|
||||
tnccs = tnc->tnccs->create_instance(tnc->tnccs, type, is_server);
|
||||
this->tls_eap = tls_eap_create(EAP_TNC, (tls_t*)tnccs, frag_size,
|
||||
max_msg_count, include_length);
|
||||
if (!this->tls_eap)
|
||||
|
||||
@@ -31,9 +31,11 @@ METHOD(plugin_t, get_features, int,
|
||||
PLUGIN_CALLBACK(eap_method_register, eap_tnc_create_server),
|
||||
PLUGIN_PROVIDE(EAP_SERVER, EAP_TNC),
|
||||
PLUGIN_DEPENDS(EAP_SERVER, EAP_TTLS),
|
||||
PLUGIN_DEPENDS(CUSTOM, "tnccs-manager"),
|
||||
PLUGIN_CALLBACK(eap_method_register, eap_tnc_create_peer),
|
||||
PLUGIN_PROVIDE(EAP_PEER, EAP_TNC),
|
||||
PLUGIN_DEPENDS(EAP_PEER, EAP_TTLS),
|
||||
PLUGIN_DEPENDS(CUSTOM, "tnccs-manager"),
|
||||
};
|
||||
*features = f;
|
||||
return countof(f);
|
||||
|
||||
@@ -6,12 +6,15 @@ INCLUDES = \
|
||||
-I$(top_srcdir)/src/libtncif \
|
||||
-I$(top_srcdir)/src/libtnccs
|
||||
|
||||
AM_CFLAGS = -DUSE_TNC -rdynamic
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
if MONOLITHIC
|
||||
noinst_LTLIBRARIES = libstrongswan-tnc-imc.la
|
||||
else
|
||||
plugin_LTLIBRARIES = libstrongswan-tnc-imc.la
|
||||
libstrongswan_tnc_imc_la_LIBADD = \
|
||||
$(top_builddir)/src/libtncif/libtncif.la \
|
||||
$(top_builddir)/src/libtnccs/libtnccs.la
|
||||
endif
|
||||
|
||||
libstrongswan_tnc_imc_la_SOURCES = \
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef TNC_IMC_H_
|
||||
#define TNC_IMC_H_
|
||||
|
||||
#include <imc/imc.h>
|
||||
#include <tnc/imc/imc.h>
|
||||
|
||||
/**
|
||||
* Create an Integrity Measurement Collector.
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <imc/imc_manager.h>
|
||||
#include <tnc/tnc.h>
|
||||
#include <tnc/imc/imc_manager.h>
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <daemon.h>
|
||||
|
||||
#define TNC_IMVID_ANY 0xffff
|
||||
|
||||
@@ -28,15 +29,14 @@ TNC_Result TNC_TNCC_ReportMessageTypes(TNC_IMCID imc_id,
|
||||
TNC_MessageTypeList supported_types,
|
||||
TNC_UInt32 type_count)
|
||||
{
|
||||
imc_manager_t *imcs = lib->get(lib, "imc-manager");
|
||||
|
||||
if (!imcs->is_registered(imcs, imc_id))
|
||||
if (!tnc->imcs->is_registered(tnc->imcs, imc_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring ReportMessageTypes() from unregistered IMC %u",
|
||||
imc_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return imcs->set_message_types(imcs, imc_id, supported_types, type_count);
|
||||
return tnc->imcs->set_message_types(tnc->imcs, imc_id, supported_types,
|
||||
type_count);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,16 +46,14 @@ TNC_Result TNC_TNCC_RequestHandshakeRetry(TNC_IMCID imc_id,
|
||||
TNC_ConnectionID connection_id,
|
||||
TNC_RetryReason reason)
|
||||
{
|
||||
imc_manager_t *imcs = lib->get(lib, "imc-manager");
|
||||
|
||||
if (!imcs->is_registered(imcs, imc_id))
|
||||
if (!tnc->imcs->is_registered(tnc->imcs, imc_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring RequestHandshakeRetry() from unregistered IMC %u",
|
||||
imc_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->request_handshake_retry(charon->tnccs, TRUE, imc_id,
|
||||
connection_id, reason);
|
||||
return tnc->tnccs->request_handshake_retry(tnc->tnccs, TRUE, imc_id,
|
||||
connection_id, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,16 +65,14 @@ TNC_Result TNC_TNCC_SendMessage(TNC_IMCID imc_id,
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_MessageType msg_type)
|
||||
{
|
||||
imc_manager_t *imcs = lib->get(lib, "imc-manager");
|
||||
|
||||
if (!imcs->is_registered(imcs, imc_id))
|
||||
if (!tnc->imcs->is_registered(tnc->imcs, imc_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring SendMessage() from unregistered IMC %u",
|
||||
imc_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->send_message(charon->tnccs, imc_id, TNC_IMVID_ANY,
|
||||
connection_id, msg, msg_len, msg_type);
|
||||
return tnc->tnccs->send_message(tnc->tnccs, imc_id, TNC_IMVID_ANY,
|
||||
connection_id, msg, msg_len, msg_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,12 +14,20 @@
|
||||
*/
|
||||
|
||||
#include "tnc_imc_manager.h"
|
||||
#include "tnc_imc.h"
|
||||
|
||||
#include <tncifimc.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <library.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <utils/linked_list.h>
|
||||
#include <utils/lexparser.h>
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct private_tnc_imc_manager_t private_tnc_imc_manager_t;
|
||||
|
||||
@@ -93,6 +101,124 @@ METHOD(imc_manager_t, remove_, imc_t*,
|
||||
return removed_imc;
|
||||
}
|
||||
|
||||
METHOD(imc_manager_t, load_all, bool,
|
||||
private_tnc_imc_manager_t *this, char *filename)
|
||||
{
|
||||
int fd, line_nr = 0;
|
||||
chunk_t src, line;
|
||||
struct stat sb;
|
||||
void *addr;
|
||||
|
||||
DBG1(DBG_TNC, "loading IMCs from '%s'", filename);
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
DBG1(DBG_TNC, "opening configuration file '%s' failed: %s", filename,
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
if (fstat(fd, &sb) == -1)
|
||||
{
|
||||
DBG1(DBG_LIB, "getting file size of '%s' failed: %s", filename,
|
||||
strerror(errno));
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
addr = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
if (addr == MAP_FAILED)
|
||||
{
|
||||
DBG1(DBG_LIB, "mapping '%s' failed: %s", filename, strerror(errno));
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
src = chunk_create(addr, sb.st_size);
|
||||
|
||||
while (fetchline(&src, &line))
|
||||
{
|
||||
char *name, *path;
|
||||
chunk_t token;
|
||||
imc_t *imc;
|
||||
|
||||
line_nr++;
|
||||
|
||||
/* skip comments or empty lines */
|
||||
if (*line.ptr == '#' || !eat_whitespace(&line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* determine keyword */
|
||||
if (!extract_token(&token, ' ', &line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: keyword must be followed by a space",
|
||||
line_nr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* only interested in IMCs */
|
||||
if (!match("IMC", &token))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* advance to the IMC name and extract it */
|
||||
if (!extract_token(&token, '"', &line) ||
|
||||
!extract_token(&token, '"', &line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: IMC name must be set in double quotes",
|
||||
line_nr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* copy the IMC name */
|
||||
name = malloc(token.len + 1);
|
||||
memcpy(name, token.ptr, token.len);
|
||||
name[token.len] = '\0';
|
||||
|
||||
/* advance to the IMC path and extract it */
|
||||
if (!eat_whitespace(&line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: IMC path is missing", line_nr);
|
||||
free(name);
|
||||
return FALSE;
|
||||
}
|
||||
if (!extract_token(&token, ' ', &line))
|
||||
{
|
||||
token = line;
|
||||
}
|
||||
|
||||
/* copy the IMC path */
|
||||
path = malloc(token.len + 1);
|
||||
memcpy(path, token.ptr, token.len);
|
||||
path[token.len] = '\0';
|
||||
|
||||
/* load and register IMC instance */
|
||||
imc = tnc_imc_create(name, path);
|
||||
if (!imc)
|
||||
{
|
||||
free(name);
|
||||
free(path);
|
||||
return FALSE;
|
||||
}
|
||||
if (!add(this, imc))
|
||||
{
|
||||
if (imc->terminate &&
|
||||
imc->terminate(imc->get_id(imc)) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
DBG1(DBG_TNC, "IMC \"%s\" not terminated successfully",
|
||||
imc->get_name(imc));
|
||||
}
|
||||
imc->destroy(imc);
|
||||
return FALSE;
|
||||
}
|
||||
DBG1(DBG_TNC, "IMC %u \"%s\" loaded from '%s'", imc->get_id(imc),
|
||||
name, path);
|
||||
}
|
||||
munmap(addr, sb.st_size);
|
||||
close(fd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(imc_manager_t, is_registered, bool,
|
||||
private_tnc_imc_manager_t *this, TNC_IMCID id)
|
||||
{
|
||||
@@ -250,6 +376,7 @@ imc_manager_t* tnc_imc_manager_create(void)
|
||||
.public = {
|
||||
.add = _add,
|
||||
.remove = _remove_, /* avoid name conflict with stdio.h */
|
||||
.load_all = _load_all,
|
||||
.is_registered = _is_registered,
|
||||
.get_preferred_language = _get_preferred_language,
|
||||
.notify_connection_change = _notify_connection_change,
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef TNC_IMC_MANAGER_H_
|
||||
#define TNC_IMC_MANAGER_H_
|
||||
|
||||
#include <imc/imc_manager.h>
|
||||
#include <tnc/imc/imc_manager.h>
|
||||
|
||||
/**
|
||||
* Create an IMC manager instance.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Andreas Steffen
|
||||
* Copyright (C) 2010-2011 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -15,17 +15,8 @@
|
||||
|
||||
#include "tnc_imc_plugin.h"
|
||||
#include "tnc_imc_manager.h"
|
||||
#include "tnc_imc.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <utils/lexparser.h>
|
||||
#include <debug.h>
|
||||
#include <tnc/tnc.h>
|
||||
|
||||
typedef struct private_tnc_imc_plugin_t private_tnc_imc_plugin_t;
|
||||
|
||||
@@ -38,133 +29,8 @@ 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(private_tnc_imc_plugin_t *this, char *filename)
|
||||
{
|
||||
int fd, line_nr = 0;
|
||||
chunk_t src, line;
|
||||
struct stat sb;
|
||||
void *addr;
|
||||
|
||||
DBG1(DBG_TNC, "loading IMCs from '%s'", filename);
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
DBG1(DBG_TNC, "opening configuration file '%s' failed: %s", filename,
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
if (fstat(fd, &sb) == -1)
|
||||
{
|
||||
DBG1(DBG_LIB, "getting file size of '%s' failed: %s", filename,
|
||||
strerror(errno));
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
addr = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
if (addr == MAP_FAILED)
|
||||
{
|
||||
DBG1(DBG_LIB, "mapping '%s' failed: %s", filename, strerror(errno));
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
src = chunk_create(addr, sb.st_size);
|
||||
|
||||
while (fetchline(&src, &line))
|
||||
{
|
||||
char *name, *path;
|
||||
chunk_t token;
|
||||
imc_t *imc;
|
||||
|
||||
line_nr++;
|
||||
|
||||
/* skip comments or empty lines */
|
||||
if (*line.ptr == '#' || !eat_whitespace(&line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* determine keyword */
|
||||
if (!extract_token(&token, ' ', &line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: keyword must be followed by a space",
|
||||
line_nr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* only interested in IMCs */
|
||||
if (!match("IMC", &token))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* advance to the IMC name and extract it */
|
||||
if (!extract_token(&token, '"', &line) ||
|
||||
!extract_token(&token, '"', &line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: IMC name must be set in double quotes",
|
||||
line_nr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* copy the IMC name */
|
||||
name = malloc(token.len + 1);
|
||||
memcpy(name, token.ptr, token.len);
|
||||
name[token.len] = '\0';
|
||||
|
||||
/* advance to the IMC path and extract it */
|
||||
if (!eat_whitespace(&line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: IMC path is missing", line_nr);
|
||||
free(name);
|
||||
return FALSE;
|
||||
}
|
||||
if (!extract_token(&token, ' ', &line))
|
||||
{
|
||||
token = line;
|
||||
}
|
||||
|
||||
/* copy the IMC path */
|
||||
path = malloc(token.len + 1);
|
||||
memcpy(path, token.ptr, token.len);
|
||||
path[token.len] = '\0';
|
||||
|
||||
/* load and register IMC instance */
|
||||
imc = tnc_imc_create(name, path);
|
||||
if (!imc)
|
||||
{
|
||||
free(name);
|
||||
free(path);
|
||||
return FALSE;
|
||||
}
|
||||
if (!this->imcs->add(this->imcs, imc))
|
||||
{
|
||||
if (imc->terminate &&
|
||||
imc->terminate(imc->get_id(imc)) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
DBG1(DBG_TNC, "IMC \"%s\" not terminated successfully",
|
||||
imc->get_name(imc));
|
||||
}
|
||||
imc->destroy(imc);
|
||||
return FALSE;
|
||||
}
|
||||
DBG1(DBG_TNC, "IMC %u \"%s\" loaded from '%s'", imc->get_id(imc),
|
||||
name, path);
|
||||
}
|
||||
munmap(addr, sb.st_size);
|
||||
close(fd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
private_tnc_imc_plugin_t *this)
|
||||
{
|
||||
@@ -175,7 +41,9 @@ 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"),
|
||||
PLUGIN_CALLBACK(tnc_manager_register, tnc_imc_manager_create),
|
||||
PLUGIN_PROVIDE(CUSTOM, "imc-manager"),
|
||||
PLUGIN_DEPENDS(CUSTOM, "tnccs-manager"),
|
||||
};
|
||||
*features = f;
|
||||
return countof(f);
|
||||
@@ -184,8 +52,6 @@ METHOD(plugin_t, get_features, int,
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_tnc_imc_plugin_t *this)
|
||||
{
|
||||
lib->set(lib, "imc-manager", NULL);
|
||||
this->imcs->destroy(this->imcs);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -195,7 +61,6 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *tnc_imc_plugin_create(void)
|
||||
{
|
||||
private_tnc_imc_plugin_t *this;
|
||||
char *tnc_config;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -205,20 +70,8 @@ plugin_t *tnc_imc_plugin_create(void)
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.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(this, tnc_config))
|
||||
{
|
||||
destroy(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
|
||||
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
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
if MONOLITHIC
|
||||
noinst_LTLIBRARIES = libstrongswan-tnc-imv.la
|
||||
else
|
||||
plugin_LTLIBRARIES = libstrongswan-tnc-imv.la
|
||||
libstrongswan_tnc_imv_la_LIBADD = $(top_builddir)/src/libtncif/libtncif.la
|
||||
libstrongswan_tnc_imv_la_LIBADD = \
|
||||
$(top_builddir)/src/libtncif/libtncif.la \
|
||||
$(top_builddir)/src/libtnccs/libtnccs.la
|
||||
endif
|
||||
|
||||
libstrongswan_tnc_imv_la_SOURCES = \
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "tnc_imv.h"
|
||||
#include <tnc/tnc.h>
|
||||
#include <tnc/imv/imv_manager.h>
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <daemon.h>
|
||||
|
||||
#define TNC_IMCID_ANY 0xffff
|
||||
|
||||
@@ -28,14 +29,14 @@ TNC_Result TNC_TNCS_ReportMessageTypes(TNC_IMVID imv_id,
|
||||
TNC_MessageTypeList supported_types,
|
||||
TNC_UInt32 type_count)
|
||||
{
|
||||
if (!charon->imvs->is_registered(charon->imvs, imv_id))
|
||||
if (!tnc->imvs->is_registered(tnc->imvs, imv_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring ReportMessageTypes() from unregistered IMV %u",
|
||||
imv_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->imvs->set_message_types(charon->imvs, imv_id,
|
||||
supported_types, type_count);
|
||||
return tnc->imvs->set_message_types(tnc->imvs, imv_id, supported_types,
|
||||
type_count);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,14 +46,14 @@ TNC_Result TNC_TNCS_RequestHandshakeRetry(TNC_IMVID imv_id,
|
||||
TNC_ConnectionID connection_id,
|
||||
TNC_RetryReason reason)
|
||||
{
|
||||
if (!charon->imvs->is_registered(charon->imvs, imv_id))
|
||||
if (!tnc->imvs->is_registered(tnc->imvs, imv_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring RequestHandshakeRetry() from unregistered IMV %u",
|
||||
imv_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->request_handshake_retry(charon->tnccs, FALSE, imv_id,
|
||||
connection_id, reason);
|
||||
return tnc->tnccs->request_handshake_retry(tnc->tnccs, FALSE, imv_id,
|
||||
connection_id, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,14 +65,14 @@ TNC_Result TNC_TNCS_SendMessage(TNC_IMVID imv_id,
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_MessageType msg_type)
|
||||
{
|
||||
if (!charon->imvs->is_registered(charon->imvs, imv_id))
|
||||
if (!tnc->imvs->is_registered(tnc->imvs, imv_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring SendMessage() from unregistered IMV %u",
|
||||
imv_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->send_message(charon->tnccs, TNC_IMCID_ANY, imv_id,
|
||||
connection_id, msg, msg_len, msg_type);
|
||||
return tnc->tnccs->send_message(tnc->tnccs, TNC_IMCID_ANY, imv_id,
|
||||
connection_id, msg, msg_len, msg_type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,14 +84,14 @@ TNC_Result TNC_TNCS_ProvideRecommendation(TNC_IMVID imv_id,
|
||||
TNC_IMV_Action_Recommendation recommendation,
|
||||
TNC_IMV_Evaluation_Result evaluation)
|
||||
{
|
||||
if (!charon->imvs->is_registered(charon->imvs, imv_id))
|
||||
if (!tnc->imvs->is_registered(tnc->imvs, imv_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring ProvideRecommendation() from unregistered IMV %u",
|
||||
imv_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->provide_recommendation(charon->tnccs, imv_id,
|
||||
connection_id, recommendation, evaluation);
|
||||
return tnc->tnccs->provide_recommendation(tnc->tnccs, imv_id, connection_id,
|
||||
recommendation, evaluation);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,13 +105,13 @@ TNC_Result TNC_TNCS_GetAttribute(TNC_IMVID imv_id,
|
||||
TNC_BufferReference buffer,
|
||||
TNC_UInt32 *out_value_len)
|
||||
{
|
||||
if (!charon->imvs->is_registered(charon->imvs, imv_id))
|
||||
if (!tnc->imvs->is_registered(tnc->imvs, imv_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring GetAttribute() from unregistered IMV %u",
|
||||
imv_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->get_attribute(charon->tnccs, imv_id, connection_id,
|
||||
return tnc->tnccs->get_attribute(tnc->tnccs, imv_id, connection_id,
|
||||
attribute_id, buffer_len, buffer, out_value_len);
|
||||
}
|
||||
|
||||
@@ -124,14 +125,14 @@ TNC_Result TNC_TNCS_SetAttribute(TNC_IMVID imv_id,
|
||||
TNC_UInt32 buffer_len,
|
||||
TNC_BufferReference buffer)
|
||||
{
|
||||
if (!charon->imvs->is_registered(charon->imvs, imv_id))
|
||||
if (!tnc->imvs->is_registered(tnc->imvs, imv_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring SetAttribute() from unregistered IMV %u",
|
||||
imv_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->set_attribute(charon->tnccs, imv_id, connection_id,
|
||||
attribute_id, buffer_len, buffer);
|
||||
return tnc->tnccs->set_attribute(tnc->tnccs, imv_id, connection_id,
|
||||
attribute_id, buffer_len, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,15 +14,22 @@
|
||||
*/
|
||||
|
||||
#include "tnc_imv_manager.h"
|
||||
#include "tnc_imv.h"
|
||||
#include "tnc_imv_recommendations.h"
|
||||
|
||||
#include <tnc/imv/imv_manager.h>
|
||||
|
||||
#include <tncifimv.h>
|
||||
#include <tncif_names.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <daemon.h>
|
||||
#include <utils/lexparser.h>
|
||||
#include <debug.h>
|
||||
#include <threading/mutex.h>
|
||||
|
||||
typedef struct private_tnc_imv_manager_t private_tnc_imv_manager_t;
|
||||
@@ -103,6 +110,124 @@ METHOD(imv_manager_t, remove_, imv_t*,
|
||||
return removed_imv;
|
||||
}
|
||||
|
||||
METHOD(imv_manager_t, load_all, bool,
|
||||
private_tnc_imv_manager_t *this, char *filename)
|
||||
{
|
||||
int fd, line_nr = 0;
|
||||
chunk_t src, line;
|
||||
struct stat sb;
|
||||
void *addr;
|
||||
|
||||
DBG1(DBG_TNC, "loading IMVs from '%s'", filename);
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
DBG1(DBG_TNC, "opening configuration file '%s' failed: %s", filename,
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
if (fstat(fd, &sb) == -1)
|
||||
{
|
||||
DBG1(DBG_LIB, "getting file size of '%s' failed: %s", filename,
|
||||
strerror(errno));
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
addr = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
if (addr == MAP_FAILED)
|
||||
{
|
||||
DBG1(DBG_LIB, "mapping '%s' failed: %s", filename, strerror(errno));
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
src = chunk_create(addr, sb.st_size);
|
||||
|
||||
while (fetchline(&src, &line))
|
||||
{
|
||||
char *name, *path;
|
||||
chunk_t token;
|
||||
imv_t *imv;
|
||||
|
||||
line_nr++;
|
||||
|
||||
/* skip comments or empty lines */
|
||||
if (*line.ptr == '#' || !eat_whitespace(&line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* determine keyword */
|
||||
if (!extract_token(&token, ' ', &line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: keyword must be followed by a space",
|
||||
line_nr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* only interested in IMVs */
|
||||
if (!match("IMV", &token))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* advance to the IMV name and extract it */
|
||||
if (!extract_token(&token, '"', &line) ||
|
||||
!extract_token(&token, '"', &line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: IMV name must be set in double quotes",
|
||||
line_nr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* copy the IMV name */
|
||||
name = malloc(token.len + 1);
|
||||
memcpy(name, token.ptr, token.len);
|
||||
name[token.len] = '\0';
|
||||
|
||||
/* advance to the IMV path and extract it */
|
||||
if (!eat_whitespace(&line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: IMV path is missing", line_nr);
|
||||
free(name);
|
||||
return FALSE;
|
||||
}
|
||||
if (!extract_token(&token, ' ', &line))
|
||||
{
|
||||
token = line;
|
||||
}
|
||||
|
||||
/* copy the IMV path */
|
||||
path = malloc(token.len + 1);
|
||||
memcpy(path, token.ptr, token.len);
|
||||
path[token.len] = '\0';
|
||||
|
||||
/* load and register IMV instance */
|
||||
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;
|
||||
}
|
||||
DBG1(DBG_TNC, "IMV %u \"%s\" loaded from '%s'", imv->get_id(imv),
|
||||
name, path);
|
||||
}
|
||||
munmap(addr, sb.st_size);
|
||||
close(fd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(imv_manager_t, is_registered, bool,
|
||||
private_tnc_imv_manager_t *this, TNC_IMVID id)
|
||||
{
|
||||
@@ -291,6 +416,7 @@ METHOD(imv_manager_t, batch_ending, void,
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
|
||||
METHOD(imv_manager_t, destroy, void,
|
||||
private_tnc_imv_manager_t *this)
|
||||
{
|
||||
@@ -322,6 +448,7 @@ imv_manager_t* tnc_imv_manager_create(void)
|
||||
.public = {
|
||||
.add = _add,
|
||||
.remove = _remove_, /* avoid name conflict with stdio.h */
|
||||
.load_all = _load_all,
|
||||
.is_registered = _is_registered,
|
||||
.get_recommendation_policy = _get_recommendation_policy,
|
||||
.create_recommendations = _create_recommendations,
|
||||
@@ -336,6 +463,7 @@ imv_manager_t* tnc_imv_manager_create(void)
|
||||
.imvs = linked_list_create(),
|
||||
.next_imv_id = 1,
|
||||
);
|
||||
|
||||
policy = enum_from_name(recommendation_policy_names,
|
||||
lib->settings->get_str(lib->settings,
|
||||
"charon.plugins.tnc-imv.recommendation_policy", "default"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Andreas Steffen
|
||||
* Copyright (C) 2010-2011 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -15,17 +15,9 @@
|
||||
|
||||
#include "tnc_imv_plugin.h"
|
||||
#include "tnc_imv_manager.h"
|
||||
#include "tnc_imv.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <tnc/tnc.h>
|
||||
|
||||
#include <utils/lexparser.h>
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct private_tnc_imv_plugin_t private_tnc_imv_plugin_t;
|
||||
|
||||
@@ -39,131 +31,8 @@ struct private_tnc_imv_plugin_t {
|
||||
*/
|
||||
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(private_tnc_imv_plugin_t *this, char *filename)
|
||||
{
|
||||
int fd, line_nr = 0;
|
||||
chunk_t src, line;
|
||||
struct stat sb;
|
||||
void *addr;
|
||||
|
||||
DBG1(DBG_TNC, "loading IMVs from '%s'", filename);
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
DBG1(DBG_TNC, "opening configuration file '%s' failed: %s", filename,
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
if (fstat(fd, &sb) == -1)
|
||||
{
|
||||
DBG1(DBG_LIB, "getting file size of '%s' failed: %s", filename,
|
||||
strerror(errno));
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
addr = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
if (addr == MAP_FAILED)
|
||||
{
|
||||
DBG1(DBG_LIB, "mapping '%s' failed: %s", filename, strerror(errno));
|
||||
close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
src = chunk_create(addr, sb.st_size);
|
||||
|
||||
while (fetchline(&src, &line))
|
||||
{
|
||||
char *name, *path;
|
||||
chunk_t token;
|
||||
imv_t *imv;
|
||||
|
||||
line_nr++;
|
||||
|
||||
/* skip comments or empty lines */
|
||||
if (*line.ptr == '#' || !eat_whitespace(&line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* determine keyword */
|
||||
if (!extract_token(&token, ' ', &line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: keyword must be followed by a space",
|
||||
line_nr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* only interested in IMVs */
|
||||
if (!match("IMV", &token))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* advance to the IMV name and extract it */
|
||||
if (!extract_token(&token, '"', &line) ||
|
||||
!extract_token(&token, '"', &line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: IMV name must be set in double quotes",
|
||||
line_nr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* copy the IMV name */
|
||||
name = malloc(token.len + 1);
|
||||
memcpy(name, token.ptr, token.len);
|
||||
name[token.len] = '\0';
|
||||
|
||||
/* advance to the IMV path and extract it */
|
||||
if (!eat_whitespace(&line))
|
||||
{
|
||||
DBG1(DBG_TNC, "line %d: IMV path is missing", line_nr);
|
||||
free(name);
|
||||
return FALSE;
|
||||
}
|
||||
if (!extract_token(&token, ' ', &line))
|
||||
{
|
||||
token = line;
|
||||
}
|
||||
|
||||
/* copy the IMV path */
|
||||
path = malloc(token.len + 1);
|
||||
memcpy(path, token.ptr, token.len);
|
||||
path[token.len] = '\0';
|
||||
|
||||
/* load and register IMV instance */
|
||||
imv = tnc_imv_create(name, path);
|
||||
if (!imv)
|
||||
{
|
||||
free(name);
|
||||
free(path);
|
||||
return FALSE;
|
||||
}
|
||||
if (!this->imvs->add(this->imvs, 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;
|
||||
}
|
||||
DBG1(DBG_TNC, "IMV %u \"%s\" loaded from '%s'", imv->get_id(imv),
|
||||
name, path);
|
||||
}
|
||||
munmap(addr, sb.st_size);
|
||||
close(fd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
tnc_imv_plugin_t *this)
|
||||
@@ -175,17 +44,17 @@ 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"),
|
||||
PLUGIN_CALLBACK(tnc_manager_register, tnc_imv_manager_create),
|
||||
PLUGIN_PROVIDE(CUSTOM, "imv-manager"),
|
||||
PLUGIN_DEPENDS(CUSTOM, "tnccs-manager"),
|
||||
};
|
||||
*features = f;
|
||||
return countof(f);
|
||||
}
|
||||
|
||||
METHOD(plugin_t, destroy, void,
|
||||
tnc_imv_plugin_t *this)
|
||||
private_tnc_imv_plugin_t *this)
|
||||
{
|
||||
lib->set(lib, "imv-manager", NULL);
|
||||
this->imvs->destroy(this->imvs);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -194,8 +63,7 @@ METHOD(plugin_t, destroy, void,
|
||||
*/
|
||||
plugin_t *tnc_imv_plugin_create()
|
||||
{
|
||||
char *tnc_config;
|
||||
tnc_imv_plugin_t *this;
|
||||
private_tnc_imv_plugin_t *this;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -205,19 +73,8 @@ plugin_t *tnc_imv_plugin_create()
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.imvs = tnc_imv_manager_create(),
|
||||
);
|
||||
|
||||
lib->set(lib, "imv-manager", this->imvs);
|
||||
|
||||
/* Load IMVs and abort if not all instances initalize successfully */
|
||||
tnc_config = lib->settings->get_str(lib->settings,
|
||||
"charon.plugins.tnc-imv.tnc_config", "/etc/tnc_config");
|
||||
if (!load_imvs(this, tnc_config))
|
||||
{
|
||||
destroy(this);
|
||||
return NULL;
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,17 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <debug.h>
|
||||
#include <daemon.h>
|
||||
|
||||
#include <tncifimv.h>
|
||||
#include <tncif_names.h>
|
||||
|
||||
#include <tnc/tnc.h>
|
||||
#include <tnc/imv/imv.h>
|
||||
#include <tnc/imv/imv_manager.h>
|
||||
#include <tnc/imv/imv_recommendations.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <utils/linked_list.h>
|
||||
|
||||
typedef struct private_tnc_imv_recommendations_t private_tnc_imv_recommendations_t;
|
||||
typedef struct recommendation_entry_t recommendation_entry_t;
|
||||
|
||||
@@ -129,7 +131,7 @@ METHOD(recommendations_t, have_recommendation, bool,
|
||||
DBG1(DBG_TNC, "there are no IMVs to make a recommendation");
|
||||
return TRUE;
|
||||
}
|
||||
policy = charon->imvs->get_recommendation_policy(charon->imvs);
|
||||
policy = tnc->imvs->get_recommendation_policy(tnc->imvs);
|
||||
|
||||
enumerator = this->recs->create_enumerator(this->recs);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/src/libstrongswan \
|
||||
-I$(top_srcdir)/src/libtncif \
|
||||
-I$(top_srcdir)/src/libtnccs
|
||||
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
if MONOLITHIC
|
||||
noinst_LTLIBRARIES = libstrongswan-tnc-tnccs.la
|
||||
else
|
||||
plugin_LTLIBRARIES = libstrongswan-tnc-tnccs.la
|
||||
libstrongswan_tnc_tnccs_la_LIBADD = \
|
||||
$(top_builddir)/src/libtncif/libtncif.la \
|
||||
$(top_builddir)/src/libtnccs/libtnccs.la
|
||||
endif
|
||||
|
||||
libstrongswan_tnc_tnccs_la_SOURCES = \
|
||||
tnc_tnccs_plugin.h tnc_tnccs_plugin.c \
|
||||
tnc_tnccs_manager.h tnc_tnccs_manager.c
|
||||
|
||||
libstrongswan_tnc_tnccs_la_LDFLAGS = -module -avoid-version
|
||||
@@ -0,0 +1,507 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "tnc_tnccs_manager.h"
|
||||
|
||||
#include <tnc/tnc.h>
|
||||
#include <tnc/imv/imv_manager.h>
|
||||
#include <tnc/imc/imc_manager.h>
|
||||
#include <tnc/imv/imv_manager.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <utils/linked_list.h>
|
||||
#include <threading/rwlock.h>
|
||||
|
||||
typedef struct private_tnc_tnccs_manager_t private_tnc_tnccs_manager_t;
|
||||
typedef struct tnccs_entry_t tnccs_entry_t;
|
||||
typedef struct tnccs_connection_entry_t tnccs_connection_entry_t;
|
||||
|
||||
/**
|
||||
* TNCCS constructor entry
|
||||
*/
|
||||
struct tnccs_entry_t {
|
||||
|
||||
/**
|
||||
* TNCCS protocol type
|
||||
*/
|
||||
tnccs_type_t type;
|
||||
|
||||
/**
|
||||
* constructor function to create instance
|
||||
*/
|
||||
tnccs_constructor_t constructor;
|
||||
};
|
||||
|
||||
/**
|
||||
* TNCCS connection entry
|
||||
*/
|
||||
struct tnccs_connection_entry_t {
|
||||
|
||||
/**
|
||||
* TNCCS connection ID
|
||||
*/
|
||||
TNC_ConnectionID id;
|
||||
|
||||
/**
|
||||
* TNCCS instance
|
||||
*/
|
||||
tnccs_t *tnccs;
|
||||
|
||||
/**
|
||||
* TNCCS send message function
|
||||
*/
|
||||
tnccs_send_message_t send_message;
|
||||
|
||||
/**
|
||||
* TNCCS request handshake retry flag
|
||||
*/
|
||||
bool *request_handshake_retry;
|
||||
|
||||
/**
|
||||
* collection of IMV recommendations
|
||||
*/
|
||||
recommendations_t *recs;
|
||||
};
|
||||
|
||||
/**
|
||||
* private data of tnc_tnccs_manager
|
||||
*/
|
||||
struct private_tnc_tnccs_manager_t {
|
||||
|
||||
/**
|
||||
* public functions
|
||||
*/
|
||||
tnccs_manager_t public;
|
||||
|
||||
/**
|
||||
* list of TNCCS protocol entries
|
||||
*/
|
||||
linked_list_t *protocols;
|
||||
|
||||
/**
|
||||
* rwlock to lock the TNCCS protocol entries
|
||||
*/
|
||||
rwlock_t *protocol_lock;
|
||||
|
||||
/**
|
||||
* connection ID counter
|
||||
*/
|
||||
TNC_ConnectionID connection_id;
|
||||
|
||||
/**
|
||||
* list of TNCCS connection entries
|
||||
*/
|
||||
linked_list_t *connections;
|
||||
|
||||
/**
|
||||
* rwlock to lock TNCCS connection entries
|
||||
*/
|
||||
rwlock_t *connection_lock;
|
||||
|
||||
};
|
||||
|
||||
METHOD(tnccs_manager_t, add_method, void,
|
||||
private_tnc_tnccs_manager_t *this, tnccs_type_t type,
|
||||
tnccs_constructor_t constructor)
|
||||
{
|
||||
tnccs_entry_t *entry;
|
||||
|
||||
entry = malloc_thing(tnccs_entry_t);
|
||||
entry->type = type;
|
||||
entry->constructor = constructor;
|
||||
|
||||
this->protocol_lock->write_lock(this->protocol_lock);
|
||||
this->protocols->insert_last(this->protocols, entry);
|
||||
this->protocol_lock->unlock(this->protocol_lock);
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, remove_method, void,
|
||||
private_tnc_tnccs_manager_t *this, tnccs_constructor_t constructor)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
tnccs_entry_t *entry;
|
||||
|
||||
this->protocol_lock->write_lock(this->protocol_lock);
|
||||
enumerator = this->protocols->create_enumerator(this->protocols);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (constructor == entry->constructor)
|
||||
{
|
||||
this->protocols->remove_at(this->protocols, enumerator);
|
||||
free(entry);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->protocol_lock->unlock(this->protocol_lock);
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, create_instance, tnccs_t*,
|
||||
private_tnc_tnccs_manager_t *this, tnccs_type_t type, bool is_server)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
tnccs_entry_t *entry;
|
||||
tnccs_t *protocol = NULL;
|
||||
|
||||
this->protocol_lock->read_lock(this->protocol_lock);
|
||||
enumerator = this->protocols->create_enumerator(this->protocols);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (type == entry->type)
|
||||
{
|
||||
protocol = entry->constructor(is_server);
|
||||
if (protocol)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->protocol_lock->unlock(this->protocol_lock);
|
||||
|
||||
return protocol;
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, create_connection, TNC_ConnectionID,
|
||||
private_tnc_tnccs_manager_t *this, tnccs_t *tnccs,
|
||||
tnccs_send_message_t send_message, bool* request_handshake_retry,
|
||||
recommendations_t **recs)
|
||||
{
|
||||
tnccs_connection_entry_t *entry;
|
||||
|
||||
entry = malloc_thing(tnccs_connection_entry_t);
|
||||
entry->tnccs = tnccs;
|
||||
entry->send_message = send_message;
|
||||
entry->request_handshake_retry = request_handshake_retry;
|
||||
if (recs)
|
||||
{
|
||||
/* we assume a TNC Server needing recommendations from IMVs */
|
||||
if (!tnc->imvs)
|
||||
{
|
||||
DBG1(DBG_TNC, "no IMV manager available!");
|
||||
free(entry);
|
||||
return 0;
|
||||
}
|
||||
entry->recs = tnc->imvs->create_recommendations(tnc->imvs);
|
||||
*recs = entry->recs;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we assume a TNC Client */
|
||||
if (!tnc->imcs)
|
||||
{
|
||||
DBG1(DBG_TNC, "no IMC manager available!");
|
||||
free(entry);
|
||||
return 0;
|
||||
}
|
||||
entry->recs = NULL;
|
||||
}
|
||||
this->connection_lock->write_lock(this->connection_lock);
|
||||
entry->id = ++this->connection_id;
|
||||
this->connections->insert_last(this->connections, entry);
|
||||
this->connection_lock->unlock(this->connection_lock);
|
||||
|
||||
DBG1(DBG_TNC, "assigned TNCCS Connection ID %u", entry->id);
|
||||
return entry->id;
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, remove_connection, void,
|
||||
private_tnc_tnccs_manager_t *this, TNC_ConnectionID id, bool is_server)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
tnccs_connection_entry_t *entry;
|
||||
|
||||
if (is_server)
|
||||
{
|
||||
if (tnc->imvs)
|
||||
{
|
||||
tnc->imvs->notify_connection_change(tnc->imvs, id,
|
||||
TNC_CONNECTION_STATE_DELETE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tnc->imcs)
|
||||
{
|
||||
tnc->imcs->notify_connection_change(tnc->imcs, id,
|
||||
TNC_CONNECTION_STATE_DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
this->connection_lock->write_lock(this->connection_lock);
|
||||
enumerator = this->connections->create_enumerator(this->connections);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (id == entry->id)
|
||||
{
|
||||
this->connections->remove_at(this->connections, enumerator);
|
||||
if (entry->recs)
|
||||
{
|
||||
entry->recs->destroy(entry->recs);
|
||||
}
|
||||
free(entry);
|
||||
DBG1(DBG_TNC, "removed TNCCS Connection ID %u", id);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->connection_lock->unlock(this->connection_lock);
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, request_handshake_retry, TNC_Result,
|
||||
private_tnc_tnccs_manager_t *this, bool is_imc, TNC_UInt32 imcv_id,
|
||||
TNC_ConnectionID id,
|
||||
TNC_RetryReason reason)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
tnccs_connection_entry_t *entry;
|
||||
|
||||
if (id == TNC_CONNECTIONID_ANY)
|
||||
{
|
||||
DBG2(DBG_TNC, "%s %u requests handshake retry for all connections "
|
||||
"(reason: %u)", is_imc ? "IMC":"IMV", reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG2(DBG_TNC, "%s %u requests handshake retry for Connection ID %u "
|
||||
"(reason: %u)", is_imc ? "IMC":"IMV", imcv_id, id, reason);
|
||||
}
|
||||
this->connection_lock->read_lock(this->connection_lock);
|
||||
enumerator = this->connections->create_enumerator(this->connections);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (id == TNC_CONNECTIONID_ANY || id == entry->id)
|
||||
{
|
||||
*entry->request_handshake_retry = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->connection_lock->unlock(this->connection_lock);
|
||||
|
||||
return TNC_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, send_message, TNC_Result,
|
||||
private_tnc_tnccs_manager_t *this, TNC_IMCID imc_id, TNC_IMVID imv_id,
|
||||
TNC_ConnectionID id,
|
||||
TNC_BufferReference msg,
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_MessageType msg_type)
|
||||
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
tnccs_connection_entry_t *entry;
|
||||
tnccs_send_message_t send_message = NULL;
|
||||
tnccs_t *tnccs = NULL;
|
||||
TNC_VendorID msg_vid;
|
||||
TNC_MessageSubtype msg_subtype;
|
||||
|
||||
msg_vid = (msg_type >> 8) & TNC_VENDORID_ANY;
|
||||
msg_subtype = msg_type & TNC_SUBTYPE_ANY;
|
||||
|
||||
if (msg_vid == TNC_VENDORID_ANY || msg_subtype == TNC_SUBTYPE_ANY)
|
||||
{
|
||||
DBG1(DBG_TNC, "not sending message of invalid type 0x%08x", msg_type);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
this->connection_lock->read_lock(this->connection_lock);
|
||||
enumerator = this->connections->create_enumerator(this->connections);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (id == entry->id)
|
||||
{
|
||||
tnccs = entry->tnccs;
|
||||
send_message = entry->send_message;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->connection_lock->unlock(this->connection_lock);
|
||||
|
||||
if (tnccs && send_message)
|
||||
{
|
||||
return send_message(tnccs, imc_id, imv_id, msg, msg_len, msg_type);
|
||||
}
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, provide_recommendation, TNC_Result,
|
||||
private_tnc_tnccs_manager_t *this, TNC_IMVID imv_id,
|
||||
TNC_ConnectionID id,
|
||||
TNC_IMV_Action_Recommendation rec,
|
||||
TNC_IMV_Evaluation_Result eval)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
tnccs_connection_entry_t *entry;
|
||||
recommendations_t *recs = NULL;
|
||||
|
||||
this->connection_lock->read_lock(this->connection_lock);
|
||||
enumerator = this->connections->create_enumerator(this->connections);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (id == entry->id)
|
||||
{
|
||||
recs = entry->recs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->connection_lock->unlock(this->connection_lock);
|
||||
|
||||
if (recs)
|
||||
{
|
||||
recs->provide_recommendation(recs, imv_id, rec, eval);
|
||||
return TNC_RESULT_SUCCESS;
|
||||
}
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, get_attribute, TNC_Result,
|
||||
private_tnc_tnccs_manager_t *this, TNC_IMVID imv_id,
|
||||
TNC_ConnectionID id,
|
||||
TNC_AttributeID attribute_id,
|
||||
TNC_UInt32 buffer_len,
|
||||
TNC_BufferReference buffer,
|
||||
TNC_UInt32 *out_value_len)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
tnccs_connection_entry_t *entry;
|
||||
recommendations_t *recs = NULL;
|
||||
|
||||
if (id == TNC_CONNECTIONID_ANY ||
|
||||
attribute_id != TNC_ATTRIBUTEID_PREFERRED_LANGUAGE)
|
||||
{
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
this->connection_lock->read_lock(this->connection_lock);
|
||||
enumerator = this->connections->create_enumerator(this->connections);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (id == entry->id)
|
||||
{
|
||||
recs = entry->recs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->connection_lock->unlock(this->connection_lock);
|
||||
|
||||
if (recs)
|
||||
{
|
||||
chunk_t pref_lang;
|
||||
|
||||
pref_lang = recs->get_preferred_language(recs);
|
||||
if (pref_lang.len == 0)
|
||||
{
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
*out_value_len = pref_lang.len;
|
||||
if (buffer && buffer_len >= pref_lang.len)
|
||||
{
|
||||
memcpy(buffer, pref_lang.ptr, pref_lang.len);
|
||||
}
|
||||
return TNC_RESULT_SUCCESS;
|
||||
}
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, set_attribute, TNC_Result,
|
||||
private_tnc_tnccs_manager_t *this, TNC_IMVID imv_id,
|
||||
TNC_ConnectionID id,
|
||||
TNC_AttributeID attribute_id,
|
||||
TNC_UInt32 buffer_len,
|
||||
TNC_BufferReference buffer)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
tnccs_connection_entry_t *entry;
|
||||
recommendations_t *recs = NULL;
|
||||
|
||||
if (id == TNC_CONNECTIONID_ANY ||
|
||||
(attribute_id != TNC_ATTRIBUTEID_REASON_STRING &&
|
||||
attribute_id != TNC_ATTRIBUTEID_REASON_LANGUAGE))
|
||||
{
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
this->connection_lock->read_lock(this->connection_lock);
|
||||
enumerator = this->connections->create_enumerator(this->connections);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (id == entry->id)
|
||||
{
|
||||
recs = entry->recs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->connection_lock->unlock(this->connection_lock);
|
||||
|
||||
if (recs)
|
||||
{
|
||||
chunk_t attribute = { buffer, buffer_len };
|
||||
|
||||
if (attribute_id == TNC_ATTRIBUTEID_REASON_STRING)
|
||||
{
|
||||
return recs->set_reason_string(recs, imv_id, attribute);
|
||||
}
|
||||
else
|
||||
{
|
||||
return recs->set_reason_language(recs, imv_id, attribute);
|
||||
}
|
||||
}
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
METHOD(tnccs_manager_t, destroy, void,
|
||||
private_tnc_tnccs_manager_t *this)
|
||||
{
|
||||
this->protocols->destroy_function(this->protocols, free);
|
||||
this->protocol_lock->destroy(this->protocol_lock);
|
||||
this->connections->destroy_function(this->connections, free);
|
||||
this->connection_lock->destroy(this->connection_lock);
|
||||
free(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* See header
|
||||
*/
|
||||
tnccs_manager_t *tnc_tnccs_manager_create()
|
||||
{
|
||||
private_tnc_tnccs_manager_t *this;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.add_method = _add_method,
|
||||
.remove_method = _remove_method,
|
||||
.create_instance = _create_instance,
|
||||
.create_connection = _create_connection,
|
||||
.remove_connection = _remove_connection,
|
||||
.request_handshake_retry = _request_handshake_retry,
|
||||
.send_message = _send_message,
|
||||
.provide_recommendation = _provide_recommendation,
|
||||
.get_attribute = _get_attribute,
|
||||
.set_attribute = _set_attribute,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.protocols = linked_list_create(),
|
||||
.connections = linked_list_create(),
|
||||
.protocol_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
|
||||
.connection_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
|
||||
);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 tnc_tnccs_manager tnc_tnccs_manager
|
||||
* @{ @ingroup tnc_tnccs
|
||||
*/
|
||||
|
||||
#ifndef TNC_TNCCS_MANAGER_H_
|
||||
#define TNC_TNCCS_MANAGER_H_
|
||||
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
|
||||
/**
|
||||
* Create a TNCCS manager instance.
|
||||
*/
|
||||
tnccs_manager_t *tnc_tnccs_manager_create();
|
||||
|
||||
#endif /** TNC_TNCCS_MANAGER_H_ @}*/
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "tnc_tnccs_plugin.h"
|
||||
#include "tnc_tnccs_manager.h"
|
||||
|
||||
#include <tnc/tnc.h>
|
||||
|
||||
typedef struct private_tnc_tnccs_plugin_t private_tnc_tnccs_plugin_t;
|
||||
|
||||
/**
|
||||
* Private data of a tnc_tnccs_plugin_t object.
|
||||
*/
|
||||
struct private_tnc_tnccs_plugin_t {
|
||||
|
||||
/**
|
||||
* Public interface.
|
||||
*/
|
||||
tnc_tnccs_plugin_t public;
|
||||
|
||||
};
|
||||
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
private_tnc_tnccs_plugin_t *this)
|
||||
{
|
||||
return "tnc-tnccs";
|
||||
}
|
||||
|
||||
METHOD(plugin_t, get_features, int,
|
||||
private_tnc_tnccs_plugin_t *this, plugin_feature_t *features[])
|
||||
{
|
||||
static plugin_feature_t f[] = {
|
||||
PLUGIN_CALLBACK(tnc_manager_register, tnc_tnccs_manager_create),
|
||||
PLUGIN_PROVIDE(CUSTOM, "tnccs-manager"),
|
||||
};
|
||||
*features = f;
|
||||
return countof(f);
|
||||
}
|
||||
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_tnc_tnccs_plugin_t *this)
|
||||
{
|
||||
libtnccs_deinit();
|
||||
free(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* see header file
|
||||
*/
|
||||
plugin_t *tnc_tnccs_plugin_create(void)
|
||||
{
|
||||
private_tnc_tnccs_plugin_t *this;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.plugin = {
|
||||
.get_name = _get_name,
|
||||
.get_features = _get_features,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
libtnccs_init();
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 tnccs tnccs
|
||||
* @ingroup cplugins
|
||||
*
|
||||
* @defgroup tnc_tnccs_plugin tnc_tnccs_plugin
|
||||
* @{ @ingroup tnccs
|
||||
*/
|
||||
|
||||
#ifndef TNC_TNCCS_PLUGIN_H_
|
||||
#define TNC_TNCCS_PLUGIN_H_
|
||||
|
||||
#include <plugins/plugin.h>
|
||||
|
||||
typedef struct tnc_tnccs_plugin_t tnc_tnccs_plugin_t;
|
||||
|
||||
/**
|
||||
* TNCCS manager plugin
|
||||
*/
|
||||
struct tnc_tnccs_plugin_t {
|
||||
|
||||
/**
|
||||
* implements plugin interface
|
||||
*/
|
||||
plugin_t plugin;
|
||||
};
|
||||
|
||||
#endif /** TNC_TNCCS_PLUGIN_H_ @}*/
|
||||
@@ -8,7 +8,7 @@ INCLUDES = \
|
||||
-I$(top_srcdir)/src/libtnccs \
|
||||
${xml_CFLAGS}
|
||||
|
||||
AM_CFLAGS = -DUSE_TNC -rdynamic
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
libstrongswan_tnccs_11_la_LIBADD = ${xml_LIBS}
|
||||
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
#include "tnccs_batch.h"
|
||||
#include "messages/tnccs_error_msg.h"
|
||||
|
||||
#include <debug.h>
|
||||
#include <utils/linked_list.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
|
||||
#include <utils/linked_list.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
typedef struct private_tnccs_batch_t private_tnccs_batch_t;
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
#include "imc_imv_msg.h"
|
||||
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <utils/lexparser.h>
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct private_imc_imv_msg_t private_imc_imv_msg_t;
|
||||
|
||||
|
||||
@@ -25,12 +25,14 @@
|
||||
#include <tncif_names.h>
|
||||
#include <tncif_pa_subtypes.h>
|
||||
|
||||
#include <imc/imc_manager.h>
|
||||
#include <tnc/tnc.h>
|
||||
#include <tnc/imc/imc_manager.h>
|
||||
#include <tnc/imv/imv_manager.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
|
||||
#include <daemon.h>
|
||||
#include <debug.h>
|
||||
#include <threading/mutex.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
|
||||
typedef struct private_tnccs_11_t private_tnccs_11_t;
|
||||
|
||||
@@ -94,16 +96,6 @@ struct private_tnccs_11_t {
|
||||
*/
|
||||
recommendations_t *recs;
|
||||
|
||||
/**
|
||||
* TNC IMC manager controlling Integrity Measurement Collectors
|
||||
*/
|
||||
imc_manager_t *imcs;
|
||||
|
||||
/**
|
||||
* TNC IMV manager controlling Integrity Measurement Verifiers
|
||||
*/
|
||||
imc_manager_t *imvs;
|
||||
|
||||
};
|
||||
|
||||
METHOD(tnccs_t, send_msg, TNC_Result,
|
||||
@@ -186,12 +178,12 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
|
||||
this->send_msg = TRUE;
|
||||
if (this->is_server)
|
||||
{
|
||||
this->imvs->receive_message(this->imvs,
|
||||
tnc->imvs->receive_message(tnc->imvs,
|
||||
this->connection_id, msg_body.ptr, msg_body.len, msg_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->imcs->receive_message(this->imcs,
|
||||
tnc->imcs->receive_message(tnc->imcs,
|
||||
this->connection_id, msg_body.ptr, msg_body.len,msg_type);
|
||||
}
|
||||
this->send_msg = FALSE;
|
||||
@@ -225,8 +217,8 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
|
||||
default:
|
||||
state = TNC_CONNECTION_STATE_ACCESS_NONE;
|
||||
}
|
||||
this->imcs->notify_connection_change(this->imcs,
|
||||
this->connection_id, state);
|
||||
tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
|
||||
state);
|
||||
this->delete_state = TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -287,17 +279,17 @@ METHOD(tls_t, process, status_t,
|
||||
|
||||
if (this->is_server && !this->connection_id)
|
||||
{
|
||||
this->connection_id = charon->tnccs->create_connection(charon->tnccs,
|
||||
this->connection_id = tnc->tnccs->create_connection(tnc->tnccs,
|
||||
(tnccs_t*)this, _send_msg,
|
||||
&this->request_handshake_retry, &this->recs);
|
||||
if (!this->connection_id)
|
||||
{
|
||||
return FAILED;
|
||||
}
|
||||
charon->imvs->notify_connection_change(charon->imvs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_CREATE);
|
||||
charon->imvs->notify_connection_change(charon->imvs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
tnc->imvs->notify_connection_change(tnc->imvs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_CREATE);
|
||||
tnc->imvs->notify_connection_change(tnc->imvs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
}
|
||||
|
||||
data = chunk_create(buf, buflen);
|
||||
@@ -348,11 +340,11 @@ METHOD(tls_t, process, status_t,
|
||||
this->send_msg = TRUE;
|
||||
if (this->is_server)
|
||||
{
|
||||
this->imvs->batch_ending(this->imvs, this->connection_id);
|
||||
tnc->imvs->batch_ending(tnc->imvs, this->connection_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->imcs->batch_ending(this->imcs, this->connection_id);
|
||||
tnc->imcs->batch_ending(tnc->imcs, this->connection_id);
|
||||
}
|
||||
this->send_msg = FALSE;
|
||||
}
|
||||
@@ -375,7 +367,7 @@ static void check_and_build_recommendation(private_tnccs_11_t *this)
|
||||
|
||||
if (!this->recs->have_recommendation(this->recs, &rec, &eval))
|
||||
{
|
||||
charon->imvs->solicit_recommendation(charon->imvs, this->connection_id);
|
||||
tnc->imvs->solicit_recommendation(tnc->imvs, this->connection_id);
|
||||
}
|
||||
if (this->recs->have_recommendation(this->recs, &rec, &eval))
|
||||
{
|
||||
@@ -413,7 +405,7 @@ METHOD(tls_t, build, status_t,
|
||||
tnccs_msg_t *msg;
|
||||
char *pref_lang;
|
||||
|
||||
this->connection_id = charon->tnccs->create_connection(charon->tnccs,
|
||||
this->connection_id = tnc->tnccs->create_connection(tnc->tnccs,
|
||||
(tnccs_t*)this, _send_msg,
|
||||
&this->request_handshake_retry, NULL);
|
||||
if (!this->connection_id)
|
||||
@@ -422,19 +414,19 @@ METHOD(tls_t, build, status_t,
|
||||
}
|
||||
|
||||
/* Create TNCCS-PreferredLanguage message */
|
||||
pref_lang = this->imcs->get_preferred_language(this->imcs);
|
||||
pref_lang = tnc->imcs->get_preferred_language(tnc->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);
|
||||
|
||||
this->imcs->notify_connection_change(this->imcs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_CREATE);
|
||||
this->imcs->notify_connection_change(this->imcs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_CREATE);
|
||||
tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
this->send_msg = TRUE;
|
||||
this->imcs->begin_handshake(this->imcs, this->connection_id);
|
||||
tnc->imcs->begin_handshake(tnc->imcs, this->connection_id);
|
||||
this->send_msg = FALSE;
|
||||
}
|
||||
|
||||
@@ -501,7 +493,7 @@ METHOD(tls_t, is_complete, bool,
|
||||
|
||||
if (this->recs && this->recs->have_recommendation(this->recs, &rec, &eval))
|
||||
{
|
||||
return charon->imvs->enforce_recommendation(charon->imvs, rec, eval);
|
||||
return tnc->imvs->enforce_recommendation(tnc->imvs, rec, eval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -518,8 +510,8 @@ METHOD(tls_t, get_eap_msk, chunk_t,
|
||||
METHOD(tls_t, destroy, void,
|
||||
private_tnccs_11_t *this)
|
||||
{
|
||||
charon->tnccs->remove_connection(charon->tnccs, this->connection_id,
|
||||
this->is_server);
|
||||
tnc->tnccs->remove_connection(tnc->tnccs, this->connection_id,
|
||||
this->is_server);
|
||||
this->mutex->destroy(this->mutex);
|
||||
DESTROY_IF(this->batch);
|
||||
free(this);
|
||||
@@ -544,8 +536,6 @@ 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;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "tnccs_11_plugin.h"
|
||||
#include "tnccs_11.h"
|
||||
|
||||
#include <daemon.h>
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
tnccs_11_plugin_t *this)
|
||||
@@ -32,8 +32,7 @@ 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"),
|
||||
PLUGIN_DEPENDS(CUSTOM, "tnccs-manager"),
|
||||
};
|
||||
*features = f;
|
||||
return countof(f);
|
||||
|
||||
@@ -1,13 +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 \
|
||||
-I$(top_srcdir)/src/libtnccs
|
||||
|
||||
AM_CFLAGS = -DUSE_TNC -rdynamic
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
if MONOLITHIC
|
||||
noinst_LTLIBRARIES = libstrongswan-tnccs-20.la
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
#include "messages/pb_error_msg.h"
|
||||
#include "state_machine/pb_tnc_state_machine.h"
|
||||
|
||||
#include <debug.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
|
||||
#include <utils/linked_list.h>
|
||||
#include <bio/bio_writer.h>
|
||||
#include <bio/bio_reader.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
#include <pen/pen.h>
|
||||
#include <debug.h>
|
||||
|
||||
ENUM(pb_tnc_batch_type_names, PB_BATCH_CDATA, PB_BATCH_CLOSE,
|
||||
"CDATA",
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
|
||||
#include "pb_error_msg.h"
|
||||
|
||||
#include <debug.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
|
||||
#include <bio/bio_writer.h>
|
||||
#include <bio/bio_reader.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
#include <pen/pen.h>
|
||||
#include <debug.h>
|
||||
|
||||
ENUM(pb_tnc_error_code_names, PB_ERROR_UNEXPECTED_BATCH_TYPE,
|
||||
PB_ERROR_VERSION_NOT_SUPPORTED,
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
|
||||
#include "pb_pa_msg.h"
|
||||
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
|
||||
#include <bio/bio_writer.h>
|
||||
#include <bio/bio_reader.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
#include <pen/pen.h>
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
@@ -29,12 +29,13 @@
|
||||
#include <tncif_names.h>
|
||||
#include <tncif_pa_subtypes.h>
|
||||
|
||||
#include <imc/imc_manager.h>
|
||||
#include <tnc/tnc.h>
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
#include <tnc/imc/imc_manager.h>
|
||||
#include <tnc/imv/imv_manager.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <daemon.h>
|
||||
#include <threading/mutex.h>
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
#include <pen/pen.h>
|
||||
|
||||
typedef struct private_tnccs_20_t private_tnccs_20_t;
|
||||
@@ -94,16 +95,6 @@ struct private_tnccs_20_t {
|
||||
*/
|
||||
recommendations_t *recs;
|
||||
|
||||
/**
|
||||
* TNC IMC manager controlling Integrity Measurement Collectors
|
||||
*/
|
||||
imc_manager_t *imcs;
|
||||
|
||||
/**
|
||||
* TNC IMV manager controlling Integrity Measurement Verifiers
|
||||
*/
|
||||
imv_manager_t *imvs;
|
||||
|
||||
};
|
||||
|
||||
METHOD(tnccs_t, send_msg, TNC_Result,
|
||||
@@ -203,12 +194,12 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
|
||||
this->send_msg = TRUE;
|
||||
if (this->is_server)
|
||||
{
|
||||
this->imvs->receive_message(this->imvs,
|
||||
tnc->imvs->receive_message(tnc->imvs,
|
||||
this->connection_id, msg_body.ptr, msg_body.len, msg_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->imcs->receive_message(this->imcs,
|
||||
tnc->imcs->receive_message(tnc->imcs,
|
||||
this->connection_id, msg_body.ptr, msg_body.len,msg_type);
|
||||
}
|
||||
this->send_msg = FALSE;
|
||||
@@ -246,8 +237,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;
|
||||
}
|
||||
this->imcs->notify_connection_change(this->imcs,
|
||||
this->connection_id, state);
|
||||
tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
|
||||
state);
|
||||
break;
|
||||
}
|
||||
case PB_MSG_REMEDIATION_PARAMETERS:
|
||||
@@ -362,8 +353,8 @@ static void build_retry_batch(private_tnccs_20_t *this)
|
||||
}
|
||||
if (this->is_server)
|
||||
{
|
||||
charon->imvs->notify_connection_change(charon->imvs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
tnc->imvs->notify_connection_change(tnc->imvs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
}
|
||||
this->batch = pb_tnc_batch_create(this->is_server, batch_retry_type);
|
||||
}
|
||||
@@ -379,17 +370,17 @@ METHOD(tls_t, process, status_t,
|
||||
|
||||
if (this->is_server && !this->connection_id)
|
||||
{
|
||||
this->connection_id = charon->tnccs->create_connection(charon->tnccs,
|
||||
this->connection_id = tnc->tnccs->create_connection(tnc->tnccs,
|
||||
(tnccs_t*)this, _send_msg,
|
||||
&this->request_handshake_retry, &this->recs);
|
||||
if (!this->connection_id)
|
||||
{
|
||||
return FAILED;
|
||||
}
|
||||
charon->imvs->notify_connection_change(charon->imvs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_CREATE);
|
||||
charon->imvs->notify_connection_change(charon->imvs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
tnc->imvs->notify_connection_change(tnc->imvs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_CREATE);
|
||||
tnc->imvs->notify_connection_change(tnc->imvs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
}
|
||||
|
||||
data = chunk_create(buf, buflen);
|
||||
@@ -418,10 +409,10 @@ METHOD(tls_t, process, status_t,
|
||||
else if (batch_type == PB_BATCH_SRETRY)
|
||||
{
|
||||
/* Restart the measurements */
|
||||
this->imcs->notify_connection_change(this->imcs,
|
||||
tnc->imcs->notify_connection_change(tnc->imcs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
this->send_msg = TRUE;
|
||||
this->imcs->begin_handshake(this->imcs, this->connection_id);
|
||||
tnc->imcs->begin_handshake(tnc->imcs, this->connection_id);
|
||||
this->send_msg = FALSE;
|
||||
}
|
||||
|
||||
@@ -452,11 +443,11 @@ METHOD(tls_t, process, status_t,
|
||||
this->send_msg = TRUE;
|
||||
if (this->is_server)
|
||||
{
|
||||
this->imvs->batch_ending(this->imvs, this->connection_id);
|
||||
tnc->imvs->batch_ending(tnc->imvs, this->connection_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->imcs->batch_ending(this->imcs, this->connection_id);
|
||||
tnc->imcs->batch_ending(tnc->imcs, this->connection_id);
|
||||
}
|
||||
this->send_msg = FALSE;
|
||||
}
|
||||
@@ -509,7 +500,7 @@ static void check_and_build_recommendation(private_tnccs_20_t *this)
|
||||
|
||||
if (!this->recs->have_recommendation(this->recs, &rec, &eval))
|
||||
{
|
||||
charon->imvs->solicit_recommendation(charon->imvs, this->connection_id);
|
||||
tnc->imvs->solicit_recommendation(tnc->imvs, this->connection_id);
|
||||
}
|
||||
if (this->recs->have_recommendation(this->recs, &rec, &eval))
|
||||
{
|
||||
@@ -560,7 +551,7 @@ METHOD(tls_t, build, status_t,
|
||||
pb_tnc_msg_t *msg;
|
||||
char *pref_lang;
|
||||
|
||||
this->connection_id = charon->tnccs->create_connection(charon->tnccs,
|
||||
this->connection_id = tnc->tnccs->create_connection(tnc->tnccs,
|
||||
(tnccs_t*)this, _send_msg,
|
||||
&this->request_handshake_retry, NULL);
|
||||
if (!this->connection_id)
|
||||
@@ -569,7 +560,7 @@ METHOD(tls_t, build, status_t,
|
||||
}
|
||||
|
||||
/* Create PB-TNC Language Preference message */
|
||||
pref_lang = this->imcs->get_preferred_language(this->imcs);
|
||||
pref_lang = tnc->imcs->get_preferred_language(tnc->imcs);
|
||||
msg = pb_language_preference_msg_create(chunk_create(pref_lang,
|
||||
strlen(pref_lang)));
|
||||
this->mutex->lock(this->mutex);
|
||||
@@ -577,12 +568,12 @@ METHOD(tls_t, build, status_t,
|
||||
this->batch->add_msg(this->batch, msg);
|
||||
this->mutex->unlock(this->mutex);
|
||||
|
||||
this->imcs->notify_connection_change(this->imcs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_CREATE);
|
||||
this->imcs->notify_connection_change(this->imcs,
|
||||
this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_CREATE);
|
||||
tnc->imcs->notify_connection_change(tnc->imcs, this->connection_id,
|
||||
TNC_CONNECTION_STATE_HANDSHAKE);
|
||||
this->send_msg = TRUE;
|
||||
this->imcs->begin_handshake(this->imcs, this->connection_id);
|
||||
tnc->imcs->begin_handshake(tnc->imcs, this->connection_id);
|
||||
this->send_msg = FALSE;
|
||||
}
|
||||
|
||||
@@ -699,7 +690,7 @@ METHOD(tls_t, is_complete, bool,
|
||||
|
||||
if (this->recs && this->recs->have_recommendation(this->recs, &rec, &eval))
|
||||
{
|
||||
return charon->imvs->enforce_recommendation(charon->imvs, rec, eval);
|
||||
return tnc->imvs->enforce_recommendation(tnc->imvs, rec, eval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -716,8 +707,8 @@ METHOD(tls_t, get_eap_msk, chunk_t,
|
||||
METHOD(tls_t, destroy, void,
|
||||
private_tnccs_20_t *this)
|
||||
{
|
||||
charon->tnccs->remove_connection(charon->tnccs, this->connection_id,
|
||||
this->is_server);
|
||||
tnc->tnccs->remove_connection(tnc->tnccs, this->connection_id,
|
||||
this->is_server);
|
||||
this->state_machine->destroy(this->state_machine);
|
||||
this->mutex->destroy(this->mutex);
|
||||
DESTROY_IF(this->batch);
|
||||
@@ -744,8 +735,6 @@ 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"),
|
||||
.imvs = lib->get(lib, "imv-manager"),
|
||||
);
|
||||
|
||||
return &this->public;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "tnccs_20_plugin.h"
|
||||
#include "tnccs_20.h"
|
||||
|
||||
#include <daemon.h>
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
tnccs_20_plugin_t *this)
|
||||
@@ -32,8 +32,7 @@ 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"),
|
||||
PLUGIN_DEPENDS(CUSTOM, "tnccs-manager"),
|
||||
};
|
||||
*features = f;
|
||||
return countof(f);
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
|
||||
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/libtls \
|
||||
-I$(top_srcdir)/src/libtncif \
|
||||
-I$(top_srcdir)/src/libtnccs
|
||||
|
||||
AM_CFLAGS = -DUSE_TNC -rdynamic
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
if MONOLITHIC
|
||||
noinst_LTLIBRARIES = libstrongswan-tnccs-dynamic.la
|
||||
else
|
||||
plugin_LTLIBRARIES = libstrongswan-tnccs-dynamic.la
|
||||
libstrongswan_tnccs_dynamic_la_LIBADD = \
|
||||
$(top_builddir)/src/libtncif/libtncif.la \
|
||||
$(top_builddir)/src/libtnccs/libtnccs.la
|
||||
endif
|
||||
|
||||
libstrongswan_tnccs_dynamic_la_SOURCES = \
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
|
||||
#include "tnccs_dynamic.h"
|
||||
|
||||
#include <tnc/tnccs/tnccs.h>
|
||||
#include <daemon.h>
|
||||
#include <tnc/tnc.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct private_tnccs_dynamic_t private_tnccs_dynamic_t;
|
||||
|
||||
@@ -75,8 +76,7 @@ METHOD(tls_t, process, status_t,
|
||||
type = determine_tnccs_protocol(*(char*)buf);
|
||||
DBG1(DBG_TNC, "%N protocol detected dynamically",
|
||||
tnccs_type_names, type);
|
||||
this->tls = (tls_t*)charon->tnccs->create_instance(charon->tnccs,
|
||||
type, TRUE);
|
||||
this->tls = (tls_t*)tnc->tnccs->create_instance(tnc->tnccs, type, TRUE);
|
||||
if (!this->tls)
|
||||
{
|
||||
DBG1(DBG_TNC, "N% protocol not supported", tnccs_type_names, type);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "tnccs_dynamic_plugin.h"
|
||||
#include "tnccs_dynamic.h"
|
||||
|
||||
#include <daemon.h>
|
||||
#include <tnc/tnccs/tnccs_manager.h>
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
tnccs_dynamic_plugin_t *this)
|
||||
|
||||
Reference in New Issue
Block a user