introduced sending of standard IETF Assessment Result PA-TNC attribute by IMVs
This commit is contained in:
@@ -19,11 +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>
|
||||
@@ -75,8 +75,11 @@ 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;
|
||||
void *pointer;
|
||||
enumerator_t *enumerator;
|
||||
int dummy_size, additional_ids;
|
||||
|
||||
if (!imc_test)
|
||||
@@ -129,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:
|
||||
@@ -294,33 +317,45 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
|
||||
{
|
||||
attr_type = attr->get_type(attr);
|
||||
|
||||
if (attr_type.vendor_id != PEN_ITA)
|
||||
if (attr_type.vendor_id == PEN_IETF)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (attr_type.type == ITA_ATTR_COMMAND)
|
||||
{
|
||||
ita_attr_command_t *ita_attr;
|
||||
ietf_attr_assess_result_t *ietf_attr;
|
||||
|
||||
ita_attr = (ita_attr_command_t*)attr;
|
||||
DBG1(DBG_IMC, "received command '%s'",
|
||||
ita_attr->get_command(ita_attr));
|
||||
ietf_attr = (ietf_attr_assess_result_t*)attr;
|
||||
state->set_result(state, dst_imc_id,
|
||||
ietf_attr->get_result(ietf_attr));
|
||||
}
|
||||
else if (attr_type.type == ITA_ATTR_DUMMY)
|
||||
else if (attr_type.vendor_id == PEN_ITA)
|
||||
{
|
||||
ita_attr_dummy_t *ita_attr;
|
||||
if (attr_type.type == ITA_ATTR_COMMAND)
|
||||
{
|
||||
ita_attr_command_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_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, dst_imc_id, NULL) ?
|
||||
TNC_RESULT_SUCCESS : send_message(state, dst_imc_id, src_imv_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,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 +43,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?
|
||||
*/
|
||||
@@ -77,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)
|
||||
{
|
||||
@@ -120,9 +136,68 @@ METHOD(imc_state_t, change_state, void,
|
||||
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);
|
||||
}
|
||||
@@ -190,6 +265,8 @@ imc_state_t *imc_test_state_create(TNC_ConnectionID connection_id,
|
||||
.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,
|
||||
@@ -199,6 +276,7 @@ imc_state_t *imc_test_state_create(TNC_ConnectionID connection_id,
|
||||
.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,
|
||||
|
||||
Reference in New Issue
Block a user