refactored PA-TNC message handling by IMVs
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "imv_os_state.h"
|
||||
|
||||
#include <imv/imv_agent.h>
|
||||
#include <imv/imv_msg.h>
|
||||
#include <pa_tnc/pa_tnc_msg.h>
|
||||
#include <ietf/ietf_attr.h>
|
||||
#include <ietf/ietf_attr_attr_request.h>
|
||||
@@ -99,56 +100,30 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
|
||||
}
|
||||
}
|
||||
|
||||
static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
TNC_ConnectionID connection_id,
|
||||
TNC_UInt32 msg_flags,
|
||||
chunk_t msg,
|
||||
TNC_VendorID msg_vid,
|
||||
TNC_MessageSubtype msg_subtype,
|
||||
TNC_UInt32 src_imc_id,
|
||||
TNC_UInt32 dst_imv_id)
|
||||
static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
|
||||
{
|
||||
pa_tnc_msg_t *pa_tnc_msg;
|
||||
pa_tnc_attr_t *attr;
|
||||
pen_type_t type;
|
||||
linked_list_t *attr_list;
|
||||
imv_state_t *state;
|
||||
imv_msg_t *out_msg;
|
||||
imv_os_state_t *os_state;
|
||||
enumerator_t *enumerator;
|
||||
pa_tnc_attr_t *attr;
|
||||
pen_type_t type;
|
||||
TNC_Result result;
|
||||
chunk_t os_name = chunk_empty;
|
||||
chunk_t os_version = chunk_empty;
|
||||
bool fatal_error, assessment = FALSE;
|
||||
bool fatal_error = FALSE, assessment = FALSE;
|
||||
|
||||
if (!imv_os)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
/* get current IMV state */
|
||||
if (!imv_os->get_state(imv_os, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
os_state = (imv_os_state_t*)state;
|
||||
|
||||
/* parse received PA-TNC message and automatically handle any errors */
|
||||
result = imv_os->receive_message(imv_os, state, msg, msg_vid,
|
||||
msg_subtype, src_imc_id, dst_imv_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;
|
||||
}
|
||||
|
||||
/* preprocess any IETF standard error attributes */
|
||||
fatal_error = pa_tnc_msg->process_ietf_std_errors(pa_tnc_msg);
|
||||
out_msg = imv_msg_create_as_reply(in_msg);
|
||||
|
||||
/* analyze PA-TNC attributes */
|
||||
attr_list = linked_list_create();
|
||||
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
|
||||
enumerator = in_msg->create_attribute_enumerator(in_msg);
|
||||
while (enumerator->enumerate(enumerator, &attr))
|
||||
{
|
||||
type = attr->get_type(attr);
|
||||
@@ -251,6 +226,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
{
|
||||
char *product_info;
|
||||
|
||||
os_state = (imv_os_state_t*)state;
|
||||
os_state->set_info(os_state, os_name, os_version);
|
||||
product_info = os_state->get_info(os_state);
|
||||
|
||||
@@ -269,10 +245,9 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
product_info);
|
||||
attr = ietf_attr_attr_request_create(PEN_IETF,
|
||||
IETF_ATTR_INSTALLED_PACKAGES);
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
out_msg->add_attribute(out_msg, attr);
|
||||
}
|
||||
}
|
||||
pa_tnc_msg->destroy(pa_tnc_msg);
|
||||
|
||||
if (fatal_error)
|
||||
{
|
||||
@@ -284,15 +259,18 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
|
||||
if (assessment)
|
||||
{
|
||||
attr_list->destroy_offset(attr_list, offsetof(pa_tnc_attr_t, destroy));
|
||||
return imv_os->provide_recommendation(imv_os, connection_id, src_imc_id,
|
||||
PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM);
|
||||
result = out_msg->send_assessment(out_msg);
|
||||
out_msg->destroy(out_msg);
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return imv_os->provide_recommendation(imv_os, state);
|
||||
}
|
||||
|
||||
result = imv_os->send_message(imv_os, connection_id, TRUE, imv_id,
|
||||
src_imc_id, PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM,
|
||||
attr_list);
|
||||
attr_list->destroy(attr_list);
|
||||
/* send PA-TNC message with excl flag set */
|
||||
result = out_msg->send(out_msg, TRUE);
|
||||
out_msg->destroy(out_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -306,14 +284,25 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_MessageType msg_type)
|
||||
{
|
||||
TNC_VendorID msg_vid;
|
||||
TNC_MessageSubtype msg_subtype;
|
||||
imv_state_t *state;
|
||||
imv_msg_t *in_msg;
|
||||
TNC_Result result;
|
||||
|
||||
msg_vid = msg_type >> 8;
|
||||
msg_subtype = msg_type & TNC_SUBTYPE_ANY;
|
||||
if (!imv_os)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
if (!imv_os->get_state(imv_os, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
in_msg = imv_msg_create_from_data(imv_os, state, connection_id, msg_type,
|
||||
chunk_create(msg, msg_len));
|
||||
result = receive_message(state, in_msg);
|
||||
in_msg->destroy(in_msg);
|
||||
|
||||
return receive_message(imv_id, connection_id, 0, chunk_create(msg, msg_len),
|
||||
msg_vid, msg_subtype, 0, TNC_IMVID_ANY);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,9 +318,26 @@ TNC_Result TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_id,
|
||||
TNC_UInt32 src_imc_id,
|
||||
TNC_UInt32 dst_imv_id)
|
||||
{
|
||||
return receive_message(imv_id, connection_id, msg_flags,
|
||||
chunk_create(msg, msg_len), msg_vid, msg_subtype,
|
||||
src_imc_id, dst_imv_id);
|
||||
imv_state_t *state;
|
||||
imv_msg_t *in_msg;
|
||||
TNC_Result result;
|
||||
|
||||
if (!imv_os)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
if (!imv_os->get_state(imv_os, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
in_msg = imv_msg_create_from_long_data(imv_os, state, connection_id,
|
||||
src_imc_id, dst_imv_id, msg_vid, msg_subtype,
|
||||
chunk_create(msg, msg_len));
|
||||
result =receive_message(state, in_msg);
|
||||
in_msg->destroy(in_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,13 +346,18 @@ TNC_Result TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_id,
|
||||
TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
|
||||
TNC_ConnectionID connection_id)
|
||||
{
|
||||
imv_state_t *state;
|
||||
|
||||
if (!imv_os)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
return imv_os->provide_recommendation(imv_os, connection_id, TNC_IMCID_ANY,
|
||||
PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM);
|
||||
if (!imv_os->get_state(imv_os, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
return imv_os->provide_recommendation(imv_os, state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,8 +375,6 @@ TNC_Result TNC_IMV_BatchEnding(TNC_IMVID imv_id,
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
/* get current IMV state */
|
||||
if (!imv_os->get_state(imv_os, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
@@ -374,11 +383,12 @@ TNC_Result TNC_IMV_BatchEnding(TNC_IMVID imv_id,
|
||||
|
||||
if (os_state->get_info(os_state) == NULL)
|
||||
{
|
||||
imv_msg_t *out_msg;
|
||||
pa_tnc_attr_t *attr;
|
||||
linked_list_t *attr_list;
|
||||
ietf_attr_attr_request_t *attr_cast;
|
||||
|
||||
attr_list = linked_list_create();
|
||||
out_msg = imv_msg_create(imv_os, state, connection_id, imv_id,
|
||||
TNC_IMCID_ANY, msg_types[0]);
|
||||
attr = ietf_attr_attr_request_create(PEN_IETF,
|
||||
IETF_ATTR_PRODUCT_INFORMATION);
|
||||
attr_cast = (ietf_attr_attr_request_t*)attr;
|
||||
@@ -386,11 +396,11 @@ TNC_Result TNC_IMV_BatchEnding(TNC_IMVID imv_id,
|
||||
attr_cast->add(attr_cast, PEN_IETF, IETF_ATTR_OPERATIONAL_STATUS);
|
||||
attr_cast->add(attr_cast, PEN_IETF, IETF_ATTR_FORWARDING_ENABLED);
|
||||
attr_cast->add(attr_cast, PEN_IETF, IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED);
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
result = imv_os->send_message(imv_os, connection_id, FALSE, imv_id,
|
||||
TNC_IMCID_ANY, PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM,
|
||||
attr_list);
|
||||
attr_list->destroy(attr_list);
|
||||
out_msg->add_attribute(out_msg, attr);
|
||||
|
||||
/* send PA-TNC message with excl flag not set */
|
||||
result = out_msg->send(out_msg, FALSE);
|
||||
out_msg->destroy(out_msg);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "imv_scanner_state.h"
|
||||
|
||||
#include <imv/imv_agent.h>
|
||||
#include <imv/imv_msg.h>
|
||||
#include <pa_tnc/pa_tnc_msg.h>
|
||||
#include <ietf/ietf_attr.h>
|
||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||
@@ -176,50 +177,24 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
|
||||
}
|
||||
}
|
||||
|
||||
static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
TNC_ConnectionID connection_id,
|
||||
TNC_UInt32 msg_flags,
|
||||
chunk_t msg,
|
||||
TNC_VendorID msg_vid,
|
||||
TNC_MessageSubtype msg_subtype,
|
||||
TNC_UInt32 src_imc_id,
|
||||
TNC_UInt32 dst_imv_id)
|
||||
static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
|
||||
{
|
||||
pa_tnc_msg_t *pa_tnc_msg;
|
||||
imv_msg_t *out_msg;
|
||||
enumerator_t *enumerator;
|
||||
pa_tnc_attr_t *attr;
|
||||
pen_type_t type;
|
||||
imv_state_t *state;
|
||||
enumerator_t *enumerator;
|
||||
TNC_Result result;
|
||||
bool fatal_error;
|
||||
bool fatal_error = FALSE;
|
||||
|
||||
if (!imv_scanner)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
/* get current IMV state */
|
||||
if (!imv_scanner->get_state(imv_scanner, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
/* parse received PA-TNC message and automatically handle any errors */
|
||||
result = imv_scanner->receive_message(imv_scanner, state, msg, msg_vid,
|
||||
msg_subtype, src_imc_id, dst_imv_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;
|
||||
}
|
||||
|
||||
/* 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))
|
||||
{
|
||||
type = attr->get_type(attr);
|
||||
@@ -301,16 +276,22 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
pa_tnc_msg->destroy(pa_tnc_msg);
|
||||
|
||||
if (fatal_error)
|
||||
{
|
||||
state->set_recommendation(state,
|
||||
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
||||
TNC_IMV_EVALUATION_RESULT_ERROR);
|
||||
TNC_IMV_EVALUATION_RESULT_ERROR);
|
||||
}
|
||||
return imv_scanner->provide_recommendation(imv_scanner, connection_id,
|
||||
src_imc_id, PEN_ITA, PA_SUBTYPE_ITA_SCANNER);
|
||||
|
||||
out_msg = imv_msg_create_as_reply(in_msg);
|
||||
result = out_msg->send_assessment(out_msg);
|
||||
out_msg->destroy(out_msg);
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return imv_scanner->provide_recommendation(imv_scanner, state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,14 +303,26 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_MessageType msg_type)
|
||||
{
|
||||
TNC_VendorID msg_vid;
|
||||
TNC_MessageSubtype msg_subtype;
|
||||
imv_state_t *state;
|
||||
imv_msg_t *in_msg;
|
||||
TNC_Result result;
|
||||
|
||||
msg_vid = msg_type >> 8;
|
||||
msg_subtype = msg_type & TNC_SUBTYPE_ANY;
|
||||
if (!imv_scanner)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
if (!imv_scanner->get_state(imv_scanner, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
return receive_message(imv_id, connection_id, 0, chunk_create(msg, msg_len),
|
||||
msg_vid, msg_subtype, 0, TNC_IMVID_ANY);
|
||||
in_msg = imv_msg_create_from_data(imv_scanner, state, connection_id, msg_type,
|
||||
chunk_create(msg, msg_len));
|
||||
result = receive_message(state, in_msg);
|
||||
in_msg->destroy(in_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,9 +338,26 @@ TNC_Result TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_id,
|
||||
TNC_UInt32 src_imc_id,
|
||||
TNC_UInt32 dst_imv_id)
|
||||
{
|
||||
return receive_message(imv_id, connection_id, msg_flags,
|
||||
chunk_create(msg, msg_len), msg_vid, msg_subtype,
|
||||
src_imc_id, dst_imv_id);
|
||||
imv_state_t *state;
|
||||
imv_msg_t *in_msg;
|
||||
TNC_Result result;
|
||||
|
||||
if (!imv_scanner)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
if (!imv_scanner->get_state(imv_scanner, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
in_msg = imv_msg_create_from_long_data(imv_scanner, state, connection_id,
|
||||
src_imc_id, dst_imv_id, msg_vid, msg_subtype,
|
||||
chunk_create(msg, msg_len));
|
||||
result =receive_message(state, in_msg);
|
||||
in_msg->destroy(in_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,13 +366,18 @@ TNC_Result TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_id,
|
||||
TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
|
||||
TNC_ConnectionID connection_id)
|
||||
{
|
||||
imv_state_t *state;
|
||||
|
||||
if (!imv_scanner)
|
||||
{
|
||||
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,
|
||||
TNC_IMCID_ANY, PEN_ITA, PA_SUBTYPE_ITA_SCANNER);
|
||||
if (!imv_scanner->get_state(imv_scanner, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
return imv_scanner->provide_recommendation(imv_scanner, state);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "imv_test_state.h"
|
||||
|
||||
#include <imv/imv_agent.h>
|
||||
#include <imv/imv_msg.h>
|
||||
#include <pa_tnc/pa_tnc_msg.h>
|
||||
#include <ietf/ietf_attr.h>
|
||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||
@@ -92,59 +93,32 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
|
||||
}
|
||||
}
|
||||
|
||||
static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
TNC_ConnectionID connection_id,
|
||||
TNC_UInt32 msg_flags,
|
||||
chunk_t msg,
|
||||
TNC_VendorID msg_vid,
|
||||
TNC_MessageSubtype msg_subtype,
|
||||
TNC_UInt32 src_imc_id,
|
||||
TNC_UInt32 dst_imv_id)
|
||||
static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
|
||||
{
|
||||
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_msg_t *out_msg;
|
||||
imv_test_state_t *test_state;
|
||||
enumerator_t *enumerator;
|
||||
pa_tnc_attr_t *attr;
|
||||
pen_type_t attr_type;
|
||||
TNC_Result result;
|
||||
int rounds;
|
||||
bool fatal_error, received_command = FALSE, retry = FALSE;
|
||||
bool fatal_error = FALSE, received_command = FALSE, retry = FALSE;
|
||||
|
||||
if (!imv_test)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
/* get current IMV state */
|
||||
if (!imv_test->get_state(imv_test, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
test_state = (imv_test_state_t*)state;
|
||||
|
||||
/* parse received PA-TNC message and automatically handle any errors */
|
||||
result = imv_test->receive_message(imv_test, state, msg, msg_vid,
|
||||
msg_subtype, src_imc_id, dst_imv_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;
|
||||
}
|
||||
|
||||
/* preprocess any IETF standard error attributes */
|
||||
fatal_error = pa_tnc_msg->process_ietf_std_errors(pa_tnc_msg);
|
||||
|
||||
/* add any new IMC and set its number of rounds */
|
||||
rounds = lib->settings->get_int(lib->settings,
|
||||
"libimcv.plugins.imv-test.rounds", 0);
|
||||
test_state->add_imc(test_state, src_imc_id, rounds);
|
||||
test_state = (imv_test_state_t*)state;
|
||||
test_state->add_imc(test_state, in_msg->get_src_id(in_msg), rounds);
|
||||
|
||||
/* 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);
|
||||
@@ -202,41 +176,60 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
pa_tnc_msg->destroy(pa_tnc_msg);
|
||||
|
||||
if (fatal_error)
|
||||
{
|
||||
state->set_recommendation(state,
|
||||
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
||||
TNC_IMV_EVALUATION_RESULT_ERROR);
|
||||
return imv_test->provide_recommendation(imv_test, connection_id,
|
||||
src_imc_id, PEN_ITA, PA_SUBTYPE_ITA_TEST);
|
||||
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
||||
TNC_IMV_EVALUATION_RESULT_ERROR);
|
||||
out_msg = imv_msg_create_as_reply(in_msg);
|
||||
result = out_msg->send_assessment(out_msg);
|
||||
out_msg->destroy(out_msg);
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return imv_test->provide_recommendation(imv_test, state);
|
||||
}
|
||||
|
||||
/* request a handshake retry ? */
|
||||
if (retry)
|
||||
{
|
||||
test_state->set_rounds(test_state, rounds);
|
||||
return imv_test->request_handshake_retry(imv_id, connection_id,
|
||||
TNC_RETRY_REASON_IMV_SERIOUS_EVENT);
|
||||
return imv_test->request_handshake_retry(imv_test->get_id(imv_test),
|
||||
state->get_connection_id(state),
|
||||
TNC_RETRY_REASON_IMV_SERIOUS_EVENT);
|
||||
}
|
||||
|
||||
/* repeat the measurement ? */
|
||||
if (test_state->another_round(test_state, src_imc_id))
|
||||
if (test_state->another_round(test_state, in_msg->get_src_id(in_msg)))
|
||||
{
|
||||
attr_list = linked_list_create();
|
||||
out_msg = imv_msg_create_as_reply(in_msg);
|
||||
attr = ita_attr_command_create("repeat");
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
result = imv_test->send_message(imv_test, connection_id, TRUE, imv_id,
|
||||
src_imc_id, PEN_ITA, PA_SUBTYPE_ITA_TEST, attr_list);
|
||||
attr_list->destroy(attr_list);
|
||||
out_msg->add_attribute(out_msg, attr);
|
||||
|
||||
/* send PA-TNC message with excl flag set */
|
||||
result = out_msg->send(out_msg, TRUE);
|
||||
out_msg->destroy(out_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return received_command ? imv_test->provide_recommendation(imv_test,
|
||||
connection_id, src_imc_id, PEN_ITA, PA_SUBTYPE_ITA_TEST) :
|
||||
TNC_RESULT_SUCCESS;
|
||||
if (received_command)
|
||||
{
|
||||
out_msg = imv_msg_create_as_reply(in_msg);
|
||||
result = out_msg->send_assessment(out_msg);
|
||||
out_msg->destroy(out_msg);
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return imv_test->provide_recommendation(imv_test, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
return TNC_RESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,14 +241,25 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_MessageType msg_type)
|
||||
{
|
||||
TNC_VendorID msg_vid;
|
||||
TNC_MessageSubtype msg_subtype;
|
||||
imv_state_t *state;
|
||||
imv_msg_t *in_msg;
|
||||
TNC_Result result;
|
||||
|
||||
msg_vid = msg_type >> 8;
|
||||
msg_subtype = msg_type & TNC_SUBTYPE_ANY;
|
||||
if (!imv_test)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
if (!imv_test->get_state(imv_test, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
in_msg = imv_msg_create_from_data(imv_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(imv_id, connection_id, 0, chunk_create(msg, msg_len),
|
||||
msg_vid, msg_subtype, 0, TNC_IMVID_ANY);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,9 +275,26 @@ TNC_Result TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_id,
|
||||
TNC_UInt32 src_imc_id,
|
||||
TNC_UInt32 dst_imv_id)
|
||||
{
|
||||
return receive_message(imv_id, connection_id, msg_flags,
|
||||
chunk_create(msg, msg_len), msg_vid, msg_subtype,
|
||||
src_imc_id, dst_imv_id);
|
||||
imv_state_t *state;
|
||||
imv_msg_t *in_msg;
|
||||
TNC_Result result;
|
||||
|
||||
if (!imv_test)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
if (!imv_test->get_state(imv_test, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
in_msg = imv_msg_create_from_long_data(imv_test, state, connection_id,
|
||||
src_imc_id, dst_imv_id, msg_vid, msg_subtype,
|
||||
chunk_create(msg, msg_len));
|
||||
result =receive_message(state, in_msg);
|
||||
in_msg->destroy(in_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,13 +303,18 @@ TNC_Result TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_id,
|
||||
TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
|
||||
TNC_ConnectionID connection_id)
|
||||
{
|
||||
imv_state_t *state;
|
||||
|
||||
if (!imv_test)
|
||||
{
|
||||
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,
|
||||
TNC_IMCID_ANY, PEN_ITA, PA_SUBTYPE_ITA_TEST);
|
||||
if (!imv_test->get_state(imv_test, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
return imv_test->provide_recommendation(imv_test, state);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user