refactoring of change_state()

This commit is contained in:
Andreas Steffen
2011-06-23 19:52:30 +02:00
parent 315c554571
commit 7401269517
6 changed files with 37 additions and 23 deletions
+11 -13
View File
@@ -70,6 +70,7 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
{
imc_state_t *state;
imc_test_state_t *test_state;
TNC_Result result;
char *command;
bool retry;
@@ -89,15 +90,13 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
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 ? */
@@ -115,15 +114,13 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
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? */
@@ -135,7 +132,8 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
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);
}
}
+7 -6
View File
@@ -70,6 +70,7 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
{
imv_state_t *state;
imv_test_state_t *test_state;
TNC_Result result;
int rounds;
if (!imv_test)
@@ -85,14 +86,13 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
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 */
@@ -101,7 +101,8 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
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);
}
}