summaryrefslogtreecommitdiff
path: root/src/libimcv/plugins
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-01-02 14:18:20 +0100
committerYves-Alexis Perez <corsac@debian.org>2013-01-02 14:18:20 +0100
commitc1343b3278cdf99533b7902744d15969f9d6fdc1 (patch)
treed5ed3dc5677a59260ec41cd39bb284d3e94c91b3 /src/libimcv/plugins
parentb34738ed08c2227300d554b139e2495ca5da97d6 (diff)
downloadvyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.tar.gz
vyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.zip
Imported Upstream version 5.0.1
Diffstat (limited to 'src/libimcv/plugins')
-rw-r--r--src/libimcv/plugins/imc_scanner/Makefile.in14
-rw-r--r--src/libimcv/plugins/imc_scanner/imc_scanner.c67
-rw-r--r--src/libimcv/plugins/imc_scanner/imc_scanner_state.c51
-rw-r--r--src/libimcv/plugins/imc_test/Makefile.in14
-rw-r--r--src/libimcv/plugins/imc_test/imc_test.c103
-rw-r--r--src/libimcv/plugins/imc_test/imc_test_state.c117
-rw-r--r--src/libimcv/plugins/imc_test/imc_test_state.h16
-rw-r--r--src/libimcv/plugins/imv_scanner/Makefile.in14
-rw-r--r--src/libimcv/plugins/imv_scanner/imv_scanner.c17
-rw-r--r--src/libimcv/plugins/imv_scanner/imv_scanner_state.c22
-rw-r--r--src/libimcv/plugins/imv_test/Makefile.in14
-rw-r--r--src/libimcv/plugins/imv_test/imv_test.c46
-rw-r--r--src/libimcv/plugins/imv_test/imv_test_state.c22
13 files changed, 437 insertions, 80 deletions
diff --git a/src/libimcv/plugins/imc_scanner/Makefile.in b/src/libimcv/plugins/imc_scanner/Makefile.in
index 497d317d5..d06798170 100644
--- a/src/libimcv/plugins/imc_scanner/Makefile.in
+++ b/src/libimcv/plugins/imc_scanner/Makefile.in
@@ -49,6 +49,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -81,7 +82,7 @@ imc_scanner_la_OBJECTS = $(am_imc_scanner_la_OBJECTS)
imc_scanner_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(imc_scanner_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -107,6 +108,7 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+BFDLIB = @BFDLIB@
BTLIB = @BTLIB@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
@@ -201,11 +203,14 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
c_plugins = @c_plugins@
+charon_natt_port = @charon_natt_port@
+charon_plugins = @charon_plugins@
+charon_udp_port = @charon_udp_port@
clearsilver_LIBS = @clearsilver_LIBS@
datadir = @datadir@
datarootdir = @datarootdir@
dbusservicedir = @dbusservicedir@
-default_pkcs11 = @default_pkcs11@
+dev_headers = @dev_headers@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
@@ -222,11 +227,12 @@ imcvdir = @imcvdir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
+ipsec_script = @ipsec_script@
+ipsec_script_upper = @ipsec_script_upper@
ipsecdir = @ipsecdir@
ipsecgroup = @ipsecgroup@
ipseclibdir = @ipseclibdir@
ipsecuser = @ipsecuser@
-libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
libexecdir = @libexecdir@
linux_headers = @linux_headers@
@@ -242,6 +248,7 @@ mkdir_p = @mkdir_p@
nm_CFLAGS = @nm_CFLAGS@
nm_LIBS = @nm_LIBS@
nm_ca_dir = @nm_ca_dir@
+nm_plugins = @nm_plugins@
oldincludedir = @oldincludedir@
openac_plugins = @openac_plugins@
p_plugins = @p_plugins@
@@ -251,7 +258,6 @@ pdfdir = @pdfdir@
piddir = @piddir@
pki_plugins = @pki_plugins@
plugindir = @plugindir@
-pluto_plugins = @pluto_plugins@
pool_plugins = @pool_plugins@
prefix = @prefix@
program_transform_name = @program_transform_name@
diff --git a/src/libimcv/plugins/imc_scanner/imc_scanner.c b/src/libimcv/plugins/imc_scanner/imc_scanner.c
index b24c39c3a..34c9359fe 100644
--- a/src/libimcv/plugins/imc_scanner/imc_scanner.c
+++ b/src/libimcv/plugins/imc_scanner/imc_scanner.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 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
@@ -19,8 +20,8 @@
#include <ietf/ietf_attr.h>
#include <ietf/ietf_attr_pa_tnc_error.h>
#include <ietf/ietf_attr_port_filter.h>
+#include <ietf/ietf_attr_assess_result.h>
-#include <tncif_names.h>
#include <tncif_pa_subtypes.h>
#include <pen/pen.h>
@@ -37,7 +38,7 @@ static const char imc_name[] = "Scanner";
#define IMC_SUBTYPE PA_SUBTYPE_ITA_SCANNER
static imc_agent_t *imc_scanner;
-
+
/**
* see section 3.8.1 of TCG TNC IF-IMC Specification 1.3
*/
@@ -84,6 +85,15 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
case TNC_CONNECTION_STATE_CREATE:
state = imc_scanner_state_create(connection_id);
return imc_scanner->create_state(imc_scanner, state);
+ case TNC_CONNECTION_STATE_HANDSHAKE:
+ if (imc_scanner->change_state(imc_scanner, connection_id, new_state,
+ &state) != TNC_RESULT_SUCCESS)
+ {
+ return TNC_RESULT_FATAL;
+ }
+ state->set_result(state, imc_id,
+ TNC_IMV_EVALUATION_RESULT_DONT_KNOW);
+ return TNC_RESULT_SUCCESS;
case TNC_CONNECTION_STATE_DELETE:
return imc_scanner->delete_state(imc_scanner, connection_id);
default:
@@ -123,7 +133,7 @@ static bool do_netstat(ietf_attr_port_filter_t *attr)
enumerator_t *enumerator;
bool allowed, found = FALSE;
- DBG2(DBG_IMC, "%.*s", strlen(buf)-1, buf);
+ DBG2(DBG_IMC, "%.*s", (int)(strlen(buf)-1), buf);
if (n++ < 2)
{
@@ -199,7 +209,7 @@ static bool do_netstat(ietf_attr_port_filter_t *attr)
}
}
enumerator->destroy(enumerator);
-
+
/* Skip the duplicate port entry */
if (found)
{
@@ -221,7 +231,7 @@ end:
static TNC_Result send_message(TNC_ConnectionID connection_id)
{
- pa_tnc_msg_t *msg;
+ linked_list_t *attr_list;
pa_tnc_attr_t *attr;
ietf_attr_port_filter_t *attr_port_filter;
TNC_Result result;
@@ -234,12 +244,11 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
attr->destroy(attr);
return TNC_RESULT_FATAL;
}
- msg = pa_tnc_msg_create();
- msg->add_attribute(msg, attr);
- msg->build(msg);
+ attr_list = linked_list_create();
+ attr_list->insert_last(attr_list, attr);
result = imc_scanner->send_message(imc_scanner, connection_id, FALSE, 0,
- TNC_IMVID_ANY, msg->get_encoding(msg));
- msg->destroy(msg);
+ TNC_IMVID_ANY, attr_list);
+ attr_list->destroy(attr_list);
return result;
}
@@ -268,8 +277,12 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
TNC_UInt32 dst_imc_id)
{
pa_tnc_msg_t *pa_tnc_msg;
+ pa_tnc_attr_t *attr;
+ pen_type_t attr_type;
imc_state_t *state;
+ enumerator_t *enumerator;
TNC_Result result;
+ TNC_UInt32 target_imc_id;
bool fatal_error;
if (!imc_scanner)
@@ -284,7 +297,7 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
return TNC_RESULT_FATAL;
}
- /* parse received PA-TNC message and automatically handle any errors */
+ /* parse received PA-TNC message and automatically handle any errors */
result = imc_scanner->receive_message(imc_scanner, state, msg, msg_vid,
msg_subtype, src_imv_id, dst_imc_id, &pa_tnc_msg);
@@ -293,17 +306,43 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
{
return result;
}
+ target_imc_id = (dst_imc_id == TNC_IMCID_ANY) ? imc_id : dst_imc_id;
/* preprocess any IETF standard error attributes */
fatal_error = pa_tnc_msg->process_ietf_std_errors(pa_tnc_msg);
+
+ /* analyze PA-TNC attributes */
+ enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
+ while (enumerator->enumerate(enumerator, &attr))
+ {
+ attr_type = attr->get_type(attr);
+
+ if (attr_type.vendor_id == PEN_IETF &&
+ attr_type.type == IETF_ATTR_ASSESSMENT_RESULT)
+ {
+ ietf_attr_assess_result_t *ietf_attr;
+
+ ietf_attr = (ietf_attr_assess_result_t*)attr;
+ state->set_result(state, target_imc_id,
+ ietf_attr->get_result(ietf_attr));
+ }
+ }
+ enumerator->destroy(enumerator);
pa_tnc_msg->destroy(pa_tnc_msg);
- /* if no error occurred then always return the same response */
- return fatal_error ? TNC_RESULT_FATAL : send_message(connection_id);
+ if (fatal_error)
+ {
+ return TNC_RESULT_FATAL;
+ }
+
+ /* if no assessment result is known then repeat the measurement */
+ return state->get_result(state, target_imc_id, NULL) ?
+ TNC_RESULT_SUCCESS : send_message(connection_id);
}
/**
* see section 3.8.4 of TCG TNC IF-IMC Specification 1.3
+
*/
TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
TNC_ConnectionID connection_id,
diff --git a/src/libimcv/plugins/imc_scanner/imc_scanner_state.c b/src/libimcv/plugins/imc_scanner/imc_scanner_state.c
index 563105548..991b24a73 100644
--- a/src/libimcv/plugins/imc_scanner/imc_scanner_state.c
+++ b/src/libimcv/plugins/imc_scanner/imc_scanner_state.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 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
@@ -14,6 +15,8 @@
#include "imc_scanner_state.h"
+#include <tncif_names.h>
+
#include <debug.h>
typedef struct private_imc_scanner_state_t private_imc_scanner_state_t;
@@ -39,6 +42,11 @@ struct private_imc_scanner_state_t {
TNC_ConnectionState state;
/**
+ * Assessment/Evaluation Result
+ */
+ TNC_IMV_Evaluation_Result result;
+
+ /**
* Does the TNCCS connection support long message types?
*/
bool has_long;
@@ -48,6 +56,10 @@ struct private_imc_scanner_state_t {
*/
bool has_excl;
+ /**
+ * Maximum PA-TNC message size for this TNCCS connection
+ */
+ u_int32_t max_msg_len;
};
METHOD(imc_state_t, get_connection_id, TNC_ConnectionID,
@@ -75,12 +87,44 @@ METHOD(imc_state_t, set_flags, void,
this->has_excl = has_excl;
}
+METHOD(imc_state_t, set_max_msg_len, void,
+ private_imc_scanner_state_t *this, u_int32_t max_msg_len)
+{
+ this->max_msg_len = max_msg_len;
+}
+
+METHOD(imc_state_t, get_max_msg_len, u_int32_t,
+ private_imc_scanner_state_t *this)
+{
+ return this->max_msg_len;
+}
+
METHOD(imc_state_t, change_state, void,
private_imc_scanner_state_t *this, TNC_ConnectionState new_state)
{
this->state = new_state;
}
+METHOD(imc_state_t, set_result, void,
+ private_imc_scanner_state_t *this, TNC_IMCID id,
+ TNC_IMV_Evaluation_Result result)
+{
+ DBG1(DBG_IMC, "set assessment result for IMC %u to '%N'",
+ id, TNC_IMV_Evaluation_Result_names, result);
+ this->result = result;
+}
+
+METHOD(imc_state_t, get_result, bool,
+ private_imc_scanner_state_t *this, TNC_IMCID id,
+ TNC_IMV_Evaluation_Result *result)
+{
+ if (result)
+ {
+ *result = this->result;
+ }
+ return this->result != TNC_IMV_EVALUATION_RESULT_DONT_KNOW;
+}
+
METHOD(imc_state_t, destroy, void,
private_imc_scanner_state_t *this)
{
@@ -101,11 +145,16 @@ imc_state_t *imc_scanner_state_create(TNC_ConnectionID connection_id)
.has_long = _has_long,
.has_excl = _has_excl,
.set_flags = _set_flags,
+ .set_max_msg_len = _set_max_msg_len,
+ .get_max_msg_len = _get_max_msg_len,
.change_state = _change_state,
+ .set_result = _set_result,
+ .get_result = _get_result,
.destroy = _destroy,
},
},
.state = TNC_CONNECTION_STATE_CREATE,
+ .result = TNC_IMV_EVALUATION_RESULT_DONT_KNOW,
.connection_id = connection_id,
);
diff --git a/src/libimcv/plugins/imc_test/Makefile.in b/src/libimcv/plugins/imc_test/Makefile.in
index b4e3f8ae0..8e37e7e9e 100644
--- a/src/libimcv/plugins/imc_test/Makefile.in
+++ b/src/libimcv/plugins/imc_test/Makefile.in
@@ -49,6 +49,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -81,7 +82,7 @@ imc_test_la_OBJECTS = $(am_imc_test_la_OBJECTS)
imc_test_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(imc_test_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -107,6 +108,7 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+BFDLIB = @BFDLIB@
BTLIB = @BTLIB@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
@@ -201,11 +203,14 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
c_plugins = @c_plugins@
+charon_natt_port = @charon_natt_port@
+charon_plugins = @charon_plugins@
+charon_udp_port = @charon_udp_port@
clearsilver_LIBS = @clearsilver_LIBS@
datadir = @datadir@
datarootdir = @datarootdir@
dbusservicedir = @dbusservicedir@
-default_pkcs11 = @default_pkcs11@
+dev_headers = @dev_headers@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
@@ -222,11 +227,12 @@ imcvdir = @imcvdir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
+ipsec_script = @ipsec_script@
+ipsec_script_upper = @ipsec_script_upper@
ipsecdir = @ipsecdir@
ipsecgroup = @ipsecgroup@
ipseclibdir = @ipseclibdir@
ipsecuser = @ipsecuser@
-libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
libexecdir = @libexecdir@
linux_headers = @linux_headers@
@@ -242,6 +248,7 @@ mkdir_p = @mkdir_p@
nm_CFLAGS = @nm_CFLAGS@
nm_LIBS = @nm_LIBS@
nm_ca_dir = @nm_ca_dir@
+nm_plugins = @nm_plugins@
oldincludedir = @oldincludedir@
openac_plugins = @openac_plugins@
p_plugins = @p_plugins@
@@ -251,7 +258,6 @@ pdfdir = @pdfdir@
piddir = @piddir@
pki_plugins = @pki_plugins@
plugindir = @plugindir@
-pluto_plugins = @pluto_plugins@
pool_plugins = @pool_plugins@
prefix = @prefix@
program_transform_name = @program_transform_name@
diff --git a/src/libimcv/plugins/imc_test/imc_test.c b/src/libimcv/plugins/imc_test/imc_test.c
index fe005ed4a..ee8e5b206 100644
--- a/src/libimcv/plugins/imc_test/imc_test.c
+++ b/src/libimcv/plugins/imc_test/imc_test.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 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
@@ -18,10 +19,11 @@
#include <pa_tnc/pa_tnc_msg.h>
#include <ietf/ietf_attr.h>
#include <ietf/ietf_attr_pa_tnc_error.h>
+#include <ietf/ietf_attr_assess_result.h>
#include <ita/ita_attr.h>
#include <ita/ita_attr_command.h>
+#include <ita/ita_attr_dummy.h>
-#include <tncif_names.h>
#include <tncif_pa_subtypes.h>
#include <pen/pen.h>
@@ -73,9 +75,12 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
imc_state_t *state;
imc_test_state_t *test_state;
TNC_Result result;
+ TNC_UInt32 additional_id;
char *command;
bool retry;
- int additional_ids;
+ void *pointer;
+ enumerator_t *enumerator;
+ int dummy_size, additional_ids;
if (!imc_test)
{
@@ -88,9 +93,12 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
case TNC_CONNECTION_STATE_CREATE:
command = lib->settings->get_str(lib->settings,
"libimcv.plugins.imc-test.command", "none");
+ dummy_size = lib->settings->get_int(lib->settings,
+ "libimcv.plugins.imc-test.dummy_size", 0);
retry = lib->settings->get_bool(lib->settings,
"libimcv.plugins.imc-test.retry", FALSE);
- state = imc_test_state_create(connection_id, command, retry);
+ state = imc_test_state_create(connection_id, command, dummy_size,
+ retry);
result = imc_test->create_state(imc_test, state);
if (result != TNC_RESULT_SUCCESS)
@@ -124,6 +132,26 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
test_state->get_command(test_state));
test_state->set_command(test_state, command);
}
+
+ state->set_result(state, imc_id, TNC_IMV_EVALUATION_RESULT_DONT_KNOW);
+
+ /* Exit if there are no additional IMC IDs */
+ if (!imc_test->count_additional_ids(imc_test))
+ {
+ return result;
+ }
+
+ enumerator = imc_test->create_id_enumerator(imc_test);
+ while (enumerator->enumerate(enumerator, &pointer))
+ {
+ /* interpret pointer as scalar value */
+ additional_id = (TNC_UInt32)pointer;
+
+ state->set_result(state, additional_id,
+ TNC_IMV_EVALUATION_RESULT_DONT_KNOW);
+ }
+ enumerator->destroy(enumerator);
+
return TNC_RESULT_SUCCESS;
case TNC_CONNECTION_STATE_DELETE:
@@ -158,23 +186,30 @@ static TNC_Result send_message(imc_state_t *state, TNC_UInt32 src_imc_id,
TNC_UInt32 dst_imv_id)
{
imc_test_state_t *test_state;
- pa_tnc_msg_t *msg;
+ linked_list_t *attr_list;
pa_tnc_attr_t *attr;
bool excl;
TNC_ConnectionID connection_id;
TNC_Result result;
+ attr_list = linked_list_create();
connection_id = state->get_connection_id(state);
test_state = (imc_test_state_t*)state;
+
+ if (test_state->get_dummy_size(test_state))
+ {
+ attr = ita_attr_dummy_create(test_state->get_dummy_size(test_state));
+ attr->set_noskip_flag(attr, TRUE);
+ attr_list->insert_last(attr_list, attr);
+ }
attr = ita_attr_command_create(test_state->get_command(test_state));
attr->set_noskip_flag(attr, TRUE);
- msg = pa_tnc_msg_create();
- msg->add_attribute(msg, attr);
- msg->build(msg);
+ attr_list->insert_last(attr_list, attr);
+
excl = dst_imv_id != TNC_IMVID_ANY;
result = imc_test->send_message(imc_test, connection_id, excl, src_imc_id,
- dst_imv_id, msg->get_encoding(msg));
- msg->destroy(msg);
+ dst_imv_id, attr_list);
+ attr_list->destroy(attr_list);
return result;
}
@@ -245,9 +280,11 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
{
pa_tnc_msg_t *pa_tnc_msg;
pa_tnc_attr_t *attr;
+ pen_type_t attr_type;
imc_state_t *state;
enumerator_t *enumerator;
TNC_Result result;
+ TNC_UInt32 target_imc_id;
bool fatal_error = FALSE;
if (!imc_test)
@@ -271,6 +308,7 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
{
return result;
}
+ target_imc_id = (dst_imc_id == TNC_IMCID_ANY) ? imc_id : dst_imc_id;
/* preprocess any IETF standard error attributes */
fatal_error = pa_tnc_msg->process_ietf_std_errors(pa_tnc_msg);
@@ -279,22 +317,47 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) == PEN_ITA &&
- attr->get_type(attr) == ITA_ATTR_COMMAND)
+ attr_type = attr->get_type(attr);
+
+ if (attr_type.vendor_id == PEN_IETF)
{
- ita_attr_command_t *ita_attr;
- char *command;
-
- ita_attr = (ita_attr_command_t*)attr;
- command = ita_attr->get_command(ita_attr);
+ ietf_attr_assess_result_t *ietf_attr;
+
+ ietf_attr = (ietf_attr_assess_result_t*)attr;
+ state->set_result(state, target_imc_id,
+ ietf_attr->get_result(ietf_attr));
+ }
+ else if (attr_type.vendor_id == PEN_ITA)
+ {
+ if (attr_type.type == ITA_ATTR_COMMAND)
+ {
+ ita_attr_command_t *ita_attr;
+
+ ita_attr = (ita_attr_command_t*)attr;
+ DBG1(DBG_IMC, "received command '%s'",
+ ita_attr->get_command(ita_attr));
+ }
+ else if (attr_type.type == ITA_ATTR_DUMMY)
+ {
+ ita_attr_dummy_t *ita_attr;
+
+ ita_attr = (ita_attr_dummy_t*)attr;
+ DBG1(DBG_IMC, "received dummy attribute value (%d bytes)",
+ ita_attr->get_size(ita_attr));
+ }
}
}
enumerator->destroy(enumerator);
pa_tnc_msg->destroy(pa_tnc_msg);
- /* if no error occurred then always return the same response */
- return fatal_error ? TNC_RESULT_FATAL :
- send_message(state, dst_imc_id, src_imv_id);
+ if (fatal_error)
+ {
+ return TNC_RESULT_FATAL;
+ }
+
+ /* if no assessment result is known then repeat the measurement */
+ return state->get_result(state, target_imc_id, NULL) ?
+ TNC_RESULT_SUCCESS : send_message(state, dst_imc_id, src_imv_id);
}
/**
diff --git a/src/libimcv/plugins/imc_test/imc_test_state.c b/src/libimcv/plugins/imc_test/imc_test_state.c
index 2adfd7d64..e70eb1492 100644
--- a/src/libimcv/plugins/imc_test/imc_test_state.c
+++ b/src/libimcv/plugins/imc_test/imc_test_state.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 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
@@ -14,10 +15,13 @@
#include "imc_test_state.h"
+#include <tncif_names.h>
+
#include <debug.h>
#include <utils/linked_list.h>
typedef struct private_imc_test_state_t private_imc_test_state_t;
+typedef struct entry_t entry_t;
/**
* Private data of an imc_test_state_t object.
@@ -40,6 +44,11 @@ struct private_imc_test_state_t {
TNC_ConnectionState state;
/**
+ * Assessment/Evaluation Results for all IMC IDs
+ */
+ linked_list_t *results;
+
+ /**
* Does the TNCCS connection support long message types?
*/
bool has_long;
@@ -50,11 +59,21 @@ struct private_imc_test_state_t {
bool has_excl;
/**
+ * Maximum PA-TNC message size for this TNCCS connection
+ */
+ u_int32_t max_msg_len;
+
+ /**
* Command to transmit to IMV
*/
char *command;
/**
+ * Size of the dummy attribute value to transmit to IMV
+ */
+ int dummy_size;
+
+ /**
* Is it the first handshake?
*/
bool first_handshake;
@@ -66,6 +85,14 @@ struct private_imc_test_state_t {
};
+/**
+ * Stores the Assessment/Evaluation Result for a given IMC ID
+ */
+struct entry_t {
+ TNC_IMCID id;
+ TNC_IMV_Evaluation_Result result;
+};
+
METHOD(imc_state_t, get_connection_id, TNC_ConnectionID,
private_imc_test_state_t *this)
{
@@ -91,15 +118,86 @@ METHOD(imc_state_t, set_flags, void,
this->has_excl = has_excl;
}
+METHOD(imc_state_t, set_max_msg_len, void,
+ private_imc_test_state_t *this, u_int32_t max_msg_len)
+{
+ this->max_msg_len = max_msg_len;
+}
+
+METHOD(imc_state_t, get_max_msg_len, u_int32_t,
+ private_imc_test_state_t *this)
+{
+ return this->max_msg_len;
+}
+
METHOD(imc_state_t, change_state, void,
private_imc_test_state_t *this, TNC_ConnectionState new_state)
{
this->state = new_state;
}
+METHOD(imc_state_t, set_result, void,
+ private_imc_test_state_t *this, TNC_IMCID id,
+ TNC_IMV_Evaluation_Result result)
+{
+ enumerator_t *enumerator;
+ entry_t *entry;
+ bool found = FALSE;
+
+ DBG1(DBG_IMC, "set assessment result for IMC %u to '%N'",
+ id, TNC_IMV_Evaluation_Result_names, result);
+
+ enumerator = this->results->create_enumerator(this->results);
+ while (enumerator->enumerate(enumerator, &entry))
+ {
+ if (entry->id == id)
+ {
+ entry->result = result;
+ found = TRUE;
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ if (!found)
+ {
+ entry = malloc_thing(entry_t);
+ entry->id = id;
+ entry->result = result;
+ this->results->insert_last(this->results, entry);
+ }
+}
+
+METHOD(imc_state_t, get_result, bool,
+ private_imc_test_state_t *this, TNC_IMCID id,
+ TNC_IMV_Evaluation_Result *result)
+{
+ enumerator_t *enumerator;
+ entry_t *entry;
+ TNC_IMV_Evaluation_Result eval = TNC_IMV_EVALUATION_RESULT_DONT_KNOW;
+
+ enumerator = this->results->create_enumerator(this->results);
+ while (enumerator->enumerate(enumerator, &entry))
+ {
+ if (entry->id == id)
+ {
+ eval = entry->result;
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ if (result)
+ {
+ *result = eval;
+ }
+ return eval != TNC_IMV_EVALUATION_RESULT_DONT_KNOW;
+}
+
METHOD(imc_state_t, destroy, void,
private_imc_test_state_t *this)
{
+ this->results->destroy_function(this->results, free);
free(this->command);
free(this);
}
@@ -120,6 +218,13 @@ METHOD(imc_test_state_t, set_command, void,
free(old_command);
}
+METHOD(imc_test_state_t, get_dummy_size, int,
+ private_imc_test_state_t *this)
+{
+ return this->dummy_size;
+}
+
+
METHOD(imc_test_state_t, is_first_handshake, bool,
private_imc_test_state_t *this)
{
@@ -146,7 +251,7 @@ METHOD(imc_test_state_t, do_handshake_retry, bool,
* Described in header.
*/
imc_state_t *imc_test_state_create(TNC_ConnectionID connection_id,
- char *command, bool retry)
+ char *command, int dummy_size, bool retry)
{
private_imc_test_state_t *this;
@@ -157,17 +262,24 @@ imc_state_t *imc_test_state_create(TNC_ConnectionID connection_id,
.has_long = _has_long,
.has_excl = _has_excl,
.set_flags = _set_flags,
+ .set_max_msg_len = _set_max_msg_len,
+ .get_max_msg_len = _get_max_msg_len,
.change_state = _change_state,
+ .set_result = _set_result,
+ .get_result = _get_result,
.destroy = _destroy,
},
.get_command = _get_command,
.set_command = _set_command,
+ .get_dummy_size = _get_dummy_size,
.is_first_handshake = _is_first_handshake,
.do_handshake_retry = _do_handshake_retry,
},
.state = TNC_CONNECTION_STATE_CREATE,
+ .results = linked_list_create(),
.connection_id = connection_id,
.command = strdup(command),
+ .dummy_size = dummy_size,
.first_handshake = TRUE,
.handshake_retry = retry,
);
@@ -175,4 +287,3 @@ imc_state_t *imc_test_state_create(TNC_ConnectionID connection_id,
return &this->public.interface;
}
-
diff --git a/src/libimcv/plugins/imc_test/imc_test_state.h b/src/libimcv/plugins/imc_test/imc_test_state.h
index d9160df94..402fd14b3 100644
--- a/src/libimcv/plugins/imc_test/imc_test_state.h
+++ b/src/libimcv/plugins/imc_test/imc_test_state.h
@@ -52,6 +52,13 @@ struct imc_test_state_t {
void (*set_command)(imc_test_state_t *this, char *command);
/**
+ * get the value size of a dummy attribute to send to IMV
+ *
+ * @return size of the dummy attribute value to send to IMV
+ */
+ int (*get_dummy_size)(imc_test_state_t *this);
+
+ /**
* Test and reset the first handshake flag
*
* @return TRUE if first handshake
@@ -70,11 +77,12 @@ struct imc_test_state_t {
/**
* Create an imc_test_state_t instance
*
- * @param id connection ID
- * @param command command to send to IMV
- * @param retry TRUE if a handshake retry should be done
+ * @param id connection ID
+ * @param command command to send to IMV
+ * @param dummy_size size of the dummy attribute to send (only if > 0)
+ * @param retry TRUE if a handshake retry should be done
*/
imc_state_t* imc_test_state_create(TNC_ConnectionID id, char* command,
- bool retry);
+ int dummy_size, bool retry);
#endif /** IMC_TEST_STATE_H_ @}*/
diff --git a/src/libimcv/plugins/imv_scanner/Makefile.in b/src/libimcv/plugins/imv_scanner/Makefile.in
index 63602c707..126a42c93 100644
--- a/src/libimcv/plugins/imv_scanner/Makefile.in
+++ b/src/libimcv/plugins/imv_scanner/Makefile.in
@@ -49,6 +49,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -81,7 +82,7 @@ imv_scanner_la_OBJECTS = $(am_imv_scanner_la_OBJECTS)
imv_scanner_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(imv_scanner_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -107,6 +108,7 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+BFDLIB = @BFDLIB@
BTLIB = @BTLIB@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
@@ -201,11 +203,14 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
c_plugins = @c_plugins@
+charon_natt_port = @charon_natt_port@
+charon_plugins = @charon_plugins@
+charon_udp_port = @charon_udp_port@
clearsilver_LIBS = @clearsilver_LIBS@
datadir = @datadir@
datarootdir = @datarootdir@
dbusservicedir = @dbusservicedir@
-default_pkcs11 = @default_pkcs11@
+dev_headers = @dev_headers@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
@@ -222,11 +227,12 @@ imcvdir = @imcvdir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
+ipsec_script = @ipsec_script@
+ipsec_script_upper = @ipsec_script_upper@
ipsecdir = @ipsecdir@
ipsecgroup = @ipsecgroup@
ipseclibdir = @ipseclibdir@
ipsecuser = @ipsecuser@
-libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
libexecdir = @libexecdir@
linux_headers = @linux_headers@
@@ -242,6 +248,7 @@ mkdir_p = @mkdir_p@
nm_CFLAGS = @nm_CFLAGS@
nm_LIBS = @nm_LIBS@
nm_ca_dir = @nm_ca_dir@
+nm_plugins = @nm_plugins@
oldincludedir = @oldincludedir@
openac_plugins = @openac_plugins@
p_plugins = @p_plugins@
@@ -251,7 +258,6 @@ pdfdir = @pdfdir@
piddir = @piddir@
pki_plugins = @pki_plugins@
plugindir = @plugindir@
-pluto_plugins = @pluto_plugins@
pool_plugins = @pool_plugins@
prefix = @prefix@
program_transform_name = @program_transform_name@
diff --git a/src/libimcv/plugins/imv_scanner/imv_scanner.c b/src/libimcv/plugins/imv_scanner/imv_scanner.c
index dba3fd632..1352397c6 100644
--- a/src/libimcv/plugins/imv_scanner/imv_scanner.c
+++ b/src/libimcv/plugins/imv_scanner/imv_scanner.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 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
@@ -186,6 +187,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
{
pa_tnc_msg_t *pa_tnc_msg;
pa_tnc_attr_t *attr;
+ pen_type_t type;
imv_state_t *state;
enumerator_t *enumerator;
TNC_Result result;
@@ -220,8 +222,9 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) == PEN_IETF &&
- attr->get_type(attr) == IETF_ATTR_PORT_FILTER)
+ type = attr->get_type(attr);
+
+ if (type.vendor_id == PEN_IETF && type.type == IETF_ATTR_PORT_FILTER)
{
ietf_attr_port_filter_t *attr_port_filter;
enumerator_t *enumerator;
@@ -305,10 +308,9 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
state->set_recommendation(state,
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
TNC_IMV_EVALUATION_RESULT_ERROR);
- return imv_scanner->provide_recommendation(imv_scanner, connection_id);
}
-
- return imv_scanner->provide_recommendation(imv_scanner, connection_id);
+ return imv_scanner->provide_recommendation(imv_scanner, connection_id,
+ src_imc_id);
}
/**
@@ -359,7 +361,8 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
return TNC_RESULT_NOT_INITIALIZED;
}
- return imv_scanner->provide_recommendation(imv_scanner, connection_id);
+ return imv_scanner->provide_recommendation(imv_scanner, connection_id,
+ TNC_IMCID_ANY);
}
/**
diff --git a/src/libimcv/plugins/imv_scanner/imv_scanner_state.c b/src/libimcv/plugins/imv_scanner/imv_scanner_state.c
index 422cb980d..fecc84e70 100644
--- a/src/libimcv/plugins/imv_scanner/imv_scanner_state.c
+++ b/src/libimcv/plugins/imv_scanner/imv_scanner_state.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 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
@@ -50,6 +51,11 @@ struct private_imv_scanner_state_t {
bool has_excl;
/**
+ * Maximum PA-TNC message size for this TNCCS connection
+ */
+ u_int32_t max_msg_len;
+
+ /**
* IMV action recommendation
*/
TNC_IMV_Action_Recommendation rec;
@@ -115,6 +121,18 @@ METHOD(imv_state_t, set_flags, void,
this->has_excl = has_excl;
}
+METHOD(imv_state_t, set_max_msg_len, void,
+ private_imv_scanner_state_t *this, u_int32_t max_msg_len)
+{
+ this->max_msg_len = max_msg_len;
+}
+
+METHOD(imv_state_t, get_max_msg_len, u_int32_t,
+ private_imv_scanner_state_t *this)
+{
+ return this->max_msg_len;
+}
+
METHOD(imv_state_t, change_state, void,
private_imv_scanner_state_t *this, TNC_ConnectionState new_state)
{
@@ -223,6 +241,8 @@ imv_state_t *imv_scanner_state_create(TNC_ConnectionID connection_id)
.has_long = _has_long,
.has_excl = _has_excl,
.set_flags = _set_flags,
+ .set_max_msg_len = _set_max_msg_len,
+ .get_max_msg_len = _get_max_msg_len,
.change_state = _change_state,
.get_recommendation = _get_recommendation,
.set_recommendation = _set_recommendation,
diff --git a/src/libimcv/plugins/imv_test/Makefile.in b/src/libimcv/plugins/imv_test/Makefile.in
index e51ad9afd..e395f8187 100644
--- a/src/libimcv/plugins/imv_test/Makefile.in
+++ b/src/libimcv/plugins/imv_test/Makefile.in
@@ -49,6 +49,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -81,7 +82,7 @@ imv_test_la_OBJECTS = $(am_imv_test_la_OBJECTS)
imv_test_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(imv_test_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -107,6 +108,7 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+BFDLIB = @BFDLIB@
BTLIB = @BTLIB@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
@@ -201,11 +203,14 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
c_plugins = @c_plugins@
+charon_natt_port = @charon_natt_port@
+charon_plugins = @charon_plugins@
+charon_udp_port = @charon_udp_port@
clearsilver_LIBS = @clearsilver_LIBS@
datadir = @datadir@
datarootdir = @datarootdir@
dbusservicedir = @dbusservicedir@
-default_pkcs11 = @default_pkcs11@
+dev_headers = @dev_headers@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
@@ -222,11 +227,12 @@ imcvdir = @imcvdir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
+ipsec_script = @ipsec_script@
+ipsec_script_upper = @ipsec_script_upper@
ipsecdir = @ipsecdir@
ipsecgroup = @ipsecgroup@
ipseclibdir = @ipseclibdir@
ipsecuser = @ipsecuser@
-libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
libexecdir = @libexecdir@
linux_headers = @linux_headers@
@@ -242,6 +248,7 @@ mkdir_p = @mkdir_p@
nm_CFLAGS = @nm_CFLAGS@
nm_LIBS = @nm_LIBS@
nm_ca_dir = @nm_ca_dir@
+nm_plugins = @nm_plugins@
oldincludedir = @oldincludedir@
openac_plugins = @openac_plugins@
p_plugins = @p_plugins@
@@ -251,7 +258,6 @@ pdfdir = @pdfdir@
piddir = @piddir@
pki_plugins = @pki_plugins@
plugindir = @plugindir@
-pluto_plugins = @pluto_plugins@
pool_plugins = @pool_plugins@
prefix = @prefix@
program_transform_name = @program_transform_name@
diff --git a/src/libimcv/plugins/imv_test/imv_test.c b/src/libimcv/plugins/imv_test/imv_test.c
index 0afd81aec..5ea82e97c 100644
--- a/src/libimcv/plugins/imv_test/imv_test.c
+++ b/src/libimcv/plugins/imv_test/imv_test.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 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
@@ -20,6 +21,7 @@
#include <ietf/ietf_attr_pa_tnc_error.h>
#include <ita/ita_attr.h>
#include <ita/ita_attr_command.h>
+#include <ita/ita_attr_dummy.h>
#include <tncif_names.h>
#include <tncif_pa_subtypes.h>
@@ -101,12 +103,14 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
{
pa_tnc_msg_t *pa_tnc_msg;
pa_tnc_attr_t *attr;
+ pen_type_t attr_type;
+ linked_list_t *attr_list;
imv_state_t *state;
imv_test_state_t *test_state;
enumerator_t *enumerator;
TNC_Result result;
int rounds;
- bool fatal_error, retry = FALSE;
+ bool fatal_error, received_command = FALSE, retry = FALSE;
if (!imv_test)
{
@@ -143,12 +147,18 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) == PEN_ITA &&
- attr->get_type(attr) == ITA_ATTR_COMMAND)
+ attr_type = attr->get_type(attr);
+
+ if (attr_type.vendor_id != PEN_ITA)
+ {
+ continue;
+ }
+ if (attr_type.type == ITA_ATTR_COMMAND)
{
ita_attr_command_t *ita_attr;
char *command;
+ received_command = TRUE;
ita_attr = (ita_attr_command_t*)attr;
command = ita_attr->get_command(ita_attr);
@@ -181,7 +191,15 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
TNC_IMV_EVALUATION_RESULT_ERROR);
}
- }
+ }
+ else if (attr_type.type == ITA_ATTR_DUMMY)
+ {
+ ita_attr_dummy_t *ita_attr;
+
+ ita_attr = (ita_attr_dummy_t*)attr;
+ DBG1(DBG_IMV, "received dummy attribute value (%d bytes)",
+ ita_attr->get_size(ita_attr));
+ }
}
enumerator->destroy(enumerator);
pa_tnc_msg->destroy(pa_tnc_msg);
@@ -191,7 +209,8 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
state->set_recommendation(state,
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
TNC_IMV_EVALUATION_RESULT_ERROR);
- return imv_test->provide_recommendation(imv_test, connection_id);
+ return imv_test->provide_recommendation(imv_test, connection_id,
+ src_imc_id);
}
/* request a handshake retry ? */
@@ -205,18 +224,18 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
/* repeat the measurement ? */
if (test_state->another_round(test_state, src_imc_id))
{
+ attr_list = linked_list_create();
attr = ita_attr_command_create("repeat");
- pa_tnc_msg = pa_tnc_msg_create();
- pa_tnc_msg->add_attribute(pa_tnc_msg, attr);
- pa_tnc_msg->build(pa_tnc_msg);
+ attr_list->insert_last(attr_list, attr);
result = imv_test->send_message(imv_test, connection_id, TRUE, imv_id,
- src_imc_id, pa_tnc_msg->get_encoding(pa_tnc_msg));
- pa_tnc_msg->destroy(pa_tnc_msg);
+ src_imc_id, attr_list);
+ attr_list->destroy(attr_list);
return result;
}
- return imv_test->provide_recommendation(imv_test, connection_id);
+ return received_command ? imv_test->provide_recommendation(imv_test,
+ connection_id, src_imc_id) : TNC_RESULT_SUCCESS;
}
/**
@@ -267,7 +286,8 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
return TNC_RESULT_NOT_INITIALIZED;
}
- return imv_test->provide_recommendation(imv_test, connection_id);
+ return imv_test->provide_recommendation(imv_test, connection_id,
+ TNC_IMCID_ANY);
}
/**
diff --git a/src/libimcv/plugins/imv_test/imv_test_state.c b/src/libimcv/plugins/imv_test/imv_test_state.c
index 530090af7..67f22c062 100644
--- a/src/libimcv/plugins/imv_test/imv_test_state.c
+++ b/src/libimcv/plugins/imv_test/imv_test_state.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 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
@@ -51,6 +52,11 @@ struct private_imv_test_state_t {
bool has_excl;
/**
+ * Maximum PA-TNC message size for this TNCCS connection
+ */
+ u_int32_t max_msg_len;
+
+ /**
* IMV action recommendation
*/
TNC_IMV_Action_Recommendation rec;
@@ -122,6 +128,18 @@ METHOD(imv_state_t, set_flags, void,
this->has_excl = has_excl;
}
+METHOD(imv_state_t, set_max_msg_len, void,
+ private_imv_test_state_t *this, u_int32_t max_msg_len)
+{
+ this->max_msg_len = max_msg_len;
+}
+
+METHOD(imv_state_t, get_max_msg_len, u_int32_t,
+ private_imv_test_state_t *this)
+{
+ return this->max_msg_len;
+}
+
METHOD(imv_state_t, change_state, void,
private_imv_test_state_t *this, TNC_ConnectionState new_state)
{
@@ -274,6 +292,8 @@ imv_state_t *imv_test_state_create(TNC_ConnectionID connection_id)
.has_long = _has_long,
.has_excl = _has_excl,
.set_flags = _set_flags,
+ .set_max_msg_len = _set_max_msg_len,
+ .get_max_msg_len = _get_max_msg_len,
.change_state = _change_state,
.get_recommendation = _get_recommendation,
.set_recommendation = _set_recommendation,