Request missing SWID tags in a directed PA-TNC message

This commit is contained in:
Andreas Steffen 2016-03-04 01:04:44 +01:00
parent 88ce12a927
commit f00f679af9
3 changed files with 47 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2015 Andreas Steffen
* Copyright (C) 2013-2016 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@ -213,7 +213,8 @@ static TNC_Result receive_msg(private_imv_swid_agent_t *this,
if (request_id == swid_state->get_request_id(swid_state))
{
swid_state->set_swid_inventory(swid_state, inventory);
swid_state->set_count(swid_state, tag_id_count, 0);
swid_state->set_count(swid_state, tag_id_count, 0,
in_msg->get_src_id(in_msg));
}
else
{
@ -251,7 +252,8 @@ static TNC_Result receive_msg(private_imv_swid_agent_t *this,
if (request_id == swid_state->get_request_id(swid_state))
{
swid_state->set_count(swid_state, 0, tag_count);
swid_state->set_count(swid_state, 0, tag_count,
in_msg->get_src_id(in_msg));
if (this->rest_api)
{
@ -387,7 +389,8 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
}
/* Create an empty out message - we might need it */
out_msg = imv_msg_create(this->agent, state, id, imv_id, TNC_IMCID_ANY,
out_msg = imv_msg_create(this->agent, state, id, imv_id,
swid_state->get_imc_id(swid_state),
msg_types[0]);
if (!imcv_db)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2014 Andreas Steffen
* Copyright (C) 2013-2016 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@ -122,6 +122,11 @@ struct private_imv_swid_state_t {
*/
uint32_t missing;
/**
* SWID IMC ID
*/
TNC_UInt32 imc_id;
/**
* Top level JSON object
*/
@ -326,10 +331,12 @@ METHOD(imv_swid_state_t, get_missing, uint32_t,
}
METHOD(imv_swid_state_t, set_count, void,
private_imv_swid_state_t *this, int tag_id_count, int tag_count)
private_imv_swid_state_t *this, int tag_id_count, int tag_count,
TNC_UInt32 imc_id)
{
this->tag_id_count += tag_id_count;
this->tag_count += tag_count;
this->imc_id = imc_id;
}
METHOD(imv_swid_state_t, get_count, void,
@ -345,6 +352,12 @@ METHOD(imv_swid_state_t, get_count, void,
}
}
METHOD(imv_swid_state_t, get_imc_id, TNC_UInt32,
private_imv_swid_state_t *this)
{
return this->imc_id;
}
/**
* Described in header.
*/
@ -384,12 +397,14 @@ imv_state_t *imv_swid_state_create(TNC_ConnectionID connection_id)
.get_missing = _get_missing,
.set_count = _set_count,
.get_count = _get_count,
.get_imc_id = _get_imc_id,
},
.state = TNC_CONNECTION_STATE_CREATE,
.rec = TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
.eval = TNC_IMV_EVALUATION_RESULT_DONT_KNOW,
.connection_id = connection_id,
.contracts = seg_contract_manager_create(),
.imc_id = TNC_IMCID_ANY,
.jobj = json_object_new_object(),
.jarray = json_object_new_array(),
);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2014 Andreas Steffen
* Copyright (C) 2013-2016 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@ -81,19 +81,19 @@ struct imv_swid_state_t {
*/
uint32_t (*get_request_id)(imv_swid_state_t *this);
/**
* Set or extend the SWID Tag ID inventory in the state
*
* @param inventory SWID Tags ID inventory to be added
*/
void (*set_swid_inventory)(imv_swid_state_t *this, swid_inventory_t *inventory);
/**
* Set or extend the SWID Tag ID inventory in the state
*
* @param inventory SWID Tags ID inventory to be added
*/
void (*set_swid_inventory)(imv_swid_state_t *this, swid_inventory_t *inventory);
/**
* Get the encoding of the complete SWID Tag ID inventory
*
* @return SWID Tags ID inventory as a JSON array
*/
json_object* (*get_swid_inventory)(imv_swid_state_t *this);
/**
* Get the encoding of the complete SWID Tag ID inventory
*
* @return SWID Tags ID inventory as a JSON array
*/
json_object* (*get_swid_inventory)(imv_swid_state_t *this);
/**
* Set the number of still missing SWID Tags or Tag IDs
@ -114,8 +114,10 @@ struct imv_swid_state_t {
*
* @param tag_id_count Number of received SWID Tag IDs
* @param tag_count Number of received SWID Tags
* @param imc_id SWID IMC ID
*/
void (*set_count)(imv_swid_state_t *this, int tag_id_count, int tag_count);
void (*set_count)(imv_swid_state_t *this, int tag_id_count, int tag_count,
TNC_UInt32 imc_id);
/**
* Set [or with multiple attributes increment] SWID Tag [ID] counters
@ -124,6 +126,13 @@ struct imv_swid_state_t {
* @param tag_count Number of received SWID Tags
*/
void (*get_count)(imv_swid_state_t *this, int *tag_id_count, int *tag_count);
/**
* Get SWID IMC ID
*
* @return SWID IMC ID
*/
TNC_UInt32 (*get_imc_id)(imv_swid_state_t *this);
};
/**