diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2013-02-07 13:27:27 +0100 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2013-02-07 13:27:27 +0100 |
commit | 7585facf05d927eb6df3929ce09ed5e60d905437 (patch) | |
tree | e4d14b4dc180db20356b6b01ce0112f3a2d7897e /src/libimcv/plugins/imc_test | |
parent | c1343b3278cdf99533b7902744d15969f9d6fdc1 (diff) | |
download | vyos-strongswan-7585facf05d927eb6df3929ce09ed5e60d905437.tar.gz vyos-strongswan-7585facf05d927eb6df3929ce09ed5e60d905437.zip |
Imported Upstream version 5.0.2
Diffstat (limited to 'src/libimcv/plugins/imc_test')
-rw-r--r-- | src/libimcv/plugins/imc_test/Makefile.in | 32 | ||||
-rw-r--r-- | src/libimcv/plugins/imc_test/imc_test.c | 186 | ||||
-rw-r--r-- | src/libimcv/plugins/imc_test/imc_test_state.c | 11 |
3 files changed, 116 insertions, 113 deletions
diff --git a/src/libimcv/plugins/imc_test/Makefile.in b/src/libimcv/plugins/imc_test/Makefile.in index 8e37e7e9e..51878adc0 100644 --- a/src/libimcv/plugins/imc_test/Makefile.in +++ b/src/libimcv/plugins/imc_test/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -73,6 +73,12 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(imcvdir)" LTLIBRARIES = $(imcv_LTLIBRARIES) imc_test_la_DEPENDENCIES = $(top_builddir)/src/libimcv/libimcv.la \ @@ -119,6 +125,7 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLIB = @DLLIB@ +DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -146,6 +153,7 @@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQLCFLAG = @MYSQLCFLAG@ MYSQLCONFIG = @MYSQLCONFIG@ @@ -173,6 +181,7 @@ RANLIB = @RANLIB@ RTLIB = @RTLIB@ RUBY = @RUBY@ RUBYINCLUDE = @RUBYINCLUDE@ +RUBYLIB = @RUBYLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -185,6 +194,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -238,7 +248,6 @@ libexecdir = @libexecdir@ linux_headers = @linux_headers@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ maemo_CFLAGS = @maemo_CFLAGS@ maemo_LIBS = @maemo_LIBS@ manager_plugins = @manager_plugins@ @@ -360,7 +369,7 @@ clean-imcvLTLIBRARIES: echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done -imc-test.la: $(imc_test_la_OBJECTS) $(imc_test_la_DEPENDENCIES) +imc-test.la: $(imc_test_la_OBJECTS) $(imc_test_la_DEPENDENCIES) $(EXTRA_imc_test_la_DEPENDENCIES) $(imc_test_la_LINK) -rpath $(imcvdir) $(imc_test_la_OBJECTS) $(imc_test_la_LIBADD) $(LIBS) mostlyclean-compile: @@ -498,10 +507,15 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff --git a/src/libimcv/plugins/imc_test/imc_test.c b/src/libimcv/plugins/imc_test/imc_test.c index ee8e5b206..c97d41628 100644 --- a/src/libimcv/plugins/imc_test/imc_test.c +++ b/src/libimcv/plugins/imc_test/imc_test.c @@ -16,10 +16,8 @@ #include "imc_test_state.h" #include <imc/imc_agent.h> -#include <pa_tnc/pa_tnc_msg.h> +#include <imc/imc_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> @@ -27,17 +25,18 @@ #include <tncif_pa_subtypes.h> #include <pen/pen.h> -#include <debug.h> +#include <utils/debug.h> /* IMC definitions */ static const char imc_name[] = "Test"; -#define IMC_VENDOR_ID PEN_ITA -#define IMC_SUBTYPE PA_SUBTYPE_ITA_TEST +static pen_type_t msg_types[] = { + { PEN_ITA, PA_SUBTYPE_ITA_TEST } +}; static imc_agent_t *imc_test; - + /** * see section 3.8.1 of TCG TNC IF-IMC Specification 1.3 */ @@ -51,7 +50,7 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id, DBG1(DBG_IMC, "IMC \"%s\" has already been initialized", imc_name); return TNC_RESULT_ALREADY_INITIALIZED; } - imc_test = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE, + imc_test = imc_agent_create(imc_name, msg_types, countof(msg_types), imc_id, actual_version); if (!imc_test) { @@ -182,36 +181,24 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id, } } -static TNC_Result send_message(imc_state_t *state, TNC_UInt32 src_imc_id, - TNC_UInt32 dst_imv_id) +static TNC_Result send_message(imc_state_t *state, imc_msg_t *out_msg) { imc_test_state_t *test_state; - 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); + out_msg->add_attribute(out_msg, attr); } attr = ita_attr_command_create(test_state->get_command(test_state)); attr->set_noskip_flag(attr, TRUE); - 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, attr_list); - attr_list->destroy(attr_list); + out_msg->add_attribute(out_msg, attr); - return result; + /* send PA-TNC message with the excl flag set */ + return out_msg->send(out_msg, TRUE); } /** @@ -221,6 +208,7 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id, TNC_ConnectionID connection_id) { imc_state_t *state; + imc_msg_t *out_msg; enumerator_t *enumerator; void *pointer; TNC_UInt32 additional_id; @@ -231,15 +219,16 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id, DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name); return TNC_RESULT_NOT_INITIALIZED; } - - /* get current IMC state */ if (!imc_test->get_state(imc_test, connection_id, &state)) { return TNC_RESULT_FATAL; } /* send PA message for primary IMC ID */ - result = send_message(state, imc_id, TNC_IMVID_ANY); + out_msg = imc_msg_create(imc_test, state, connection_id, imc_id, + TNC_IMVID_ANY, msg_types[0]); + result = send_message(state, out_msg); + out_msg->destroy(out_msg); /* Exit if there are no additional IMC IDs */ if (!imc_test->count_additional_ids(imc_test)) @@ -262,93 +251,60 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id, { /* interpret pointer as scalar value */ additional_id = (TNC_UInt32)pointer; - result = send_message(state, additional_id, TNC_IMVID_ANY); + out_msg = imc_msg_create(imc_test, state, connection_id, additional_id, + TNC_IMVID_ANY, msg_types[0]); + result = send_message(state, out_msg); + out_msg->destroy(out_msg); } enumerator->destroy(enumerator); return result; } -static TNC_Result receive_message(TNC_IMCID imc_id, - TNC_ConnectionID connection_id, - TNC_UInt32 msg_flags, - chunk_t msg, - TNC_VendorID msg_vid, - TNC_MessageSubtype msg_subtype, - TNC_UInt32 src_imv_id, - TNC_UInt32 dst_imc_id) +static TNC_Result receive_message(imc_state_t *state, imc_msg_t *in_msg) { - pa_tnc_msg_t *pa_tnc_msg; + imc_msg_t *out_msg; + enumerator_t *enumerator; 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) - { - DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name); - return TNC_RESULT_NOT_INITIALIZED; - } - - /* get current IMC state */ - if (!imc_test->get_state(imc_test, connection_id, &state)) - { - return TNC_RESULT_FATAL; - } - - /* parse received PA-TNC message and automatically handle any errors */ - result = imc_test->receive_message(imc_test, state, msg, msg_vid, - msg_subtype, src_imv_id, dst_imc_id, &pa_tnc_msg); - - /* no parsed PA-TNC attributes available if an error occurred */ - if (!pa_tnc_msg) + /* parse received PA-TNC message and handle local and remote errors */ + result = in_msg->receive(in_msg, &fatal_error); + if (result != TNC_RESULT_SUCCESS) { 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); + enumerator = in_msg->create_attribute_enumerator(in_msg); while (enumerator->enumerate(enumerator, &attr)) { attr_type = attr->get_type(attr); - if (attr_type.vendor_id == PEN_IETF) + if (attr_type.vendor_id != PEN_ITA) { - 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)); + continue; } - else if (attr_type.vendor_id == PEN_ITA) + if (attr_type.type == ITA_ATTR_COMMAND) { - if (attr_type.type == ITA_ATTR_COMMAND) - { - ita_attr_command_t *ita_attr; + 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_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)); - } + 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 (fatal_error) { @@ -356,8 +312,15 @@ static TNC_Result receive_message(TNC_IMCID imc_id, } /* 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); + if (state->get_result(state, in_msg->get_dst_id(in_msg), NULL)) + { + return TNC_RESULT_SUCCESS; + } + out_msg = imc_msg_create_as_reply(in_msg); + result = send_message(state, out_msg); + out_msg->destroy(out_msg); + + return result; } /** @@ -369,14 +332,26 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, TNC_UInt32 msg_len, TNC_MessageType msg_type) { - TNC_VendorID msg_vid; - TNC_MessageSubtype msg_subtype; + imc_state_t *state; + imc_msg_t *in_msg; + TNC_Result result; + + if (!imc_test) + { + DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name); + return TNC_RESULT_NOT_INITIALIZED; + } + if (!imc_test->get_state(imc_test, connection_id, &state)) + { + return TNC_RESULT_FATAL; + } - msg_vid = msg_type >> 8; - msg_subtype = msg_type & TNC_SUBTYPE_ANY; + in_msg = imc_msg_create_from_data(imc_test, state, connection_id, msg_type, + chunk_create(msg, msg_len)); + result = receive_message(state, in_msg); + in_msg->destroy(in_msg); - return receive_message(imc_id, connection_id, 0, chunk_create(msg, msg_len), - msg_vid, msg_subtype, 0, TNC_IMCID_ANY); + return result; } /** @@ -392,9 +367,26 @@ TNC_Result TNC_IMC_ReceiveMessageLong(TNC_IMCID imc_id, TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id) { - return receive_message(imc_id, connection_id, msg_flags, - chunk_create(msg, msg_len), msg_vid, msg_subtype, - src_imv_id, dst_imc_id); + imc_state_t *state; + imc_msg_t *in_msg; + TNC_Result result; + + if (!imc_test) + { + DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name); + return TNC_RESULT_NOT_INITIALIZED; + } + if (!imc_test->get_state(imc_test, connection_id, &state)) + { + return TNC_RESULT_FATAL; + } + in_msg = imc_msg_create_from_long_data(imc_test, state, connection_id, + src_imv_id, dst_imc_id, msg_vid, msg_subtype, + chunk_create(msg, msg_len)); + result =receive_message(state, in_msg); + in_msg->destroy(in_msg); + + return result; } /** diff --git a/src/libimcv/plugins/imc_test/imc_test_state.c b/src/libimcv/plugins/imc_test/imc_test_state.c index e70eb1492..e7beca0aa 100644 --- a/src/libimcv/plugins/imc_test/imc_test_state.c +++ b/src/libimcv/plugins/imc_test/imc_test_state.c @@ -17,8 +17,8 @@ #include <tncif_names.h> -#include <debug.h> -#include <utils/linked_list.h> +#include <utils/debug.h> +#include <collections/linked_list.h> typedef struct private_imc_test_state_t private_imc_test_state_t; typedef struct entry_t entry_t; @@ -82,7 +82,7 @@ struct private_imc_test_state_t { * Do a handshake retry */ bool handshake_retry; - + }; /** @@ -144,9 +144,6 @@ METHOD(imc_state_t, set_result, void, 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)) { @@ -283,7 +280,7 @@ imc_state_t *imc_test_state_create(TNC_ConnectionID connection_id, .first_handshake = TRUE, .handshake_retry = retry, ); - + return &this->public.interface; } |