METHOD(imc_agent_t, change_state, TNC_Result,
private_imc_agent_t *this, TNC_ConnectionID connection_id,
- TNC_ConnectionState new_state)
+ TNC_ConnectionState new_state,
+ imc_state_t **state_p)
{
imc_state_t *state;
case TNC_CONNECTION_STATE_ACCESS_ISOLATED:
case TNC_CONNECTION_STATE_ACCESS_NONE:
state = find_connection(this, connection_id);
+
if (!state)
{
DBG1(DBG_IMC, "IMC %u \"%s\" has no state for Connection ID %u",
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);
+ if (state_p)
+ {
+ *state_p = state;
+ }
break;
case TNC_CONNECTION_STATE_CREATE:
DBG1(DBG_IMC, "state '%N' should be handled by create_state()",
*
* @param connection_id network connection ID assigned by TNCS
* @param new_state new state of TNCCS connection
+ * @param state_p internal IMC state instance [optional argument]
* @return TNC result code
*/
TNC_Result (*change_state)(imc_agent_t *this,
TNC_ConnectionID connection_id,
- TNC_ConnectionState new_state);
+ TNC_ConnectionState new_state,
+ imc_state_t **state_p);
/**
* Get the IMC state for a TNCCS connection instance
METHOD(imv_agent_t, change_state, TNC_Result,
private_imv_agent_t *this, TNC_ConnectionID connection_id,
- TNC_ConnectionState new_state)
+ TNC_ConnectionState new_state,
+ imv_state_t **state_p)
{
imv_state_t *state;
DBG2(DBG_IMV, "IMV %u \"%s\" changed state of Connection ID %u to '%N'",
this->id, this->name, connection_id,
TNC_Connection_State_names, new_state);
+ if (state_p)
+ {
+ *state_p = state;
+ }
break;
case TNC_CONNECTION_STATE_CREATE:
DBG1(DBG_IMV, "state '%N' should be handled by create_state()",
*
* @param connection_id network connection ID assigned by TNCS
* @param new_state new state of TNCCS connection
+ * @param state_p internal IMV state instance [optional argument]
* @return TNC result code
*/
TNC_Result (*change_state)(imv_agent_t *this,
TNC_ConnectionID connection_id,
- TNC_ConnectionState new_state);
+ TNC_ConnectionState new_state,
+ imv_state_t **state_p);
/**
* Get the IMV state for a TNCCS connection instance
{
imc_state_t *state;
imc_test_state_t *test_state;
+ TNC_Result result;
char *command;
bool retry;
return imc_test->create_state(imc_test, state);
case TNC_CONNECTION_STATE_HANDSHAKE:
- /* get current IMC state and update it */
- if (!imc_test->get_state(imc_test, connection_id, &state))
+ /* get updated IMC state */
+ result = imc_test->change_state(imc_test, connection_id,
+ new_state, &state);
+ if (result != TNC_RESULT_SUCCESS)
{
return TNC_RESULT_FATAL;
}
- state->change_state(state, new_state);
- DBG2(DBG_IMC, "IMC %u \"%s\" changed state of Connection ID %u to '%N'",
- imc_id, imc_name, connection_id,
- TNC_Connection_State_names, new_state);
test_state = (imc_test_state_t*)state;
/* is it the first handshake or a retry ? */
case TNC_CONNECTION_STATE_ACCESS_ISOLATED:
case TNC_CONNECTION_STATE_ACCESS_NONE:
- /* get current IMC state and update it */
- if (!imc_test->get_state(imc_test, connection_id, &state))
+ /* get updated IMC state */
+ result = imc_test->change_state(imc_test, connection_id,
+ new_state, &state);
+ if (result != TNC_RESULT_SUCCESS)
{
return TNC_RESULT_FATAL;
}
- state->change_state(state, new_state);
- DBG2(DBG_IMC, "IMC %u \"%s\" changed state of Connection ID %u to '%N'",
- imc_id, imc_name, connection_id,
- TNC_Connection_State_names, new_state);
test_state = (imc_test_state_t*)state;
/* do a handshake retry? */
return TNC_RESULT_SUCCESS;
default:
- return imc_test->change_state(imc_test, connection_id, new_state);
+ return imc_test->change_state(imc_test, connection_id,
+ new_state, NULL);
}
}
{
imv_state_t *state;
imv_test_state_t *test_state;
+ TNC_Result result;
int rounds;
if (!imv_test)
case TNC_CONNECTION_STATE_DELETE:
return imv_test->delete_state(imv_test, connection_id);
case TNC_CONNECTION_STATE_HANDSHAKE:
- if (!imv_test->get_state(imv_test, connection_id, &state))
+ /* get updated IMV state */
+ result = imv_test->change_state(imv_test, connection_id,
+ new_state, &state);
+ if (result != TNC_RESULT_SUCCESS)
{
return TNC_RESULT_FATAL;
}
- state->change_state(state, new_state);
- DBG2(DBG_IMV, "IMV %u \"%s\" changed state of Connection ID %u to '%N'",
- imv_id, imv_name, connection_id,
- TNC_Connection_State_names, new_state);
test_state = (imv_test_state_t*)state;
/* set the number of measurement rounds */
test_state->set_rounds(test_state, rounds);
return TNC_RESULT_SUCCESS;
default:
- return imv_test->change_state(imv_test, connection_id, new_state);
+ return imv_test->change_state(imv_test, connection_id,
+ new_state, NULL);
}
}