libimcv: Reset of IMC state for new measurement cycle

This commit is contained in:
Andreas Steffen
2018-08-01 15:44:49 +02:00
parent 25973c0350
commit 731e043c8e
13 changed files with 101 additions and 58 deletions
+9 -1
View File
@@ -410,6 +410,7 @@ METHOD(imc_agent_t, change_state, TNC_Result,
imc_state_t **state_p)
{
imc_state_t *state;
TNC_ConnectionState old_state;
switch (new_state)
{
@@ -425,7 +426,7 @@ METHOD(imc_agent_t, change_state, TNC_Result,
this->id, this->name, connection_id);
return TNC_RESULT_FATAL;
}
state->change_state(state, new_state);
old_state = state->change_state(state, new_state);
DBG2(DBG_IMC, "IMC %u \"%s\" changed state of Connection ID %u to '%N'",
this->id, this->name, connection_id,
TNC_Connection_State_names, new_state);
@@ -433,6 +434,13 @@ METHOD(imc_agent_t, change_state, TNC_Result,
{
*state_p = state;
}
if (new_state == TNC_CONNECTION_STATE_HANDSHAKE &&
old_state != TNC_CONNECTION_STATE_CREATE)
{
state->reset(state);
DBG2(DBG_IMC, "IMC %u \"%s\" reset state of Connection ID %u",
this->id, this->name, connection_id);
}
break;
case TNC_CONNECTION_STATE_CREATE:
DBG1(DBG_IMC, "state '%N' should be handled by create_state()",
+8 -1
View File
@@ -92,8 +92,10 @@ struct imc_state_t {
* Change the connection state
*
* @param new_state new connection state
* @return old connection state
*/
void (*change_state)(imc_state_t *this, TNC_ConnectionState new_state);
TNC_ConnectionState (*change_state)(imc_state_t *this,
TNC_ConnectionState new_state);
/**
* Set the Assessment/Evaluation Result
@@ -114,6 +116,11 @@ struct imc_state_t {
bool (*get_result)(imc_state_t *this, TNC_IMCID id,
TNC_IMV_Evaluation_Result *result);
/**
* Resets the state for a new measurement cycle triggered by a SRETRY batch
*/
void (*reset)(imc_state_t *this);
/**
* Destroys an imc_state_t object
*/