}
return FALSE;
case PB_STATE_SERVER_WORKING:
- if (!this->is_server && type == PB_BATCH_SDATA)
+ if (!this->is_server && (type == PB_BATCH_SDATA ||
+ type == PB_BATCH_SRETRY))
{
this->state = PB_STATE_CLIENT_WORKING;
break;
this->state = PB_STATE_DECIDED;
break;
}
- if ((this->is_server && type == PB_BATCH_CRETRY) ||
- (!this->is_server && type == PB_BATCH_SRETRY))
+ if (this->is_server && type == PB_BATCH_CRETRY)
{
break;
}
}
return FALSE;
case PB_STATE_SERVER_WORKING:
- if (this->is_server && type == PB_BATCH_SDATA)
+ if (this->is_server && (type == PB_BATCH_SDATA ||
+ type == PB_BATCH_SRETRY))
{
this->state = PB_STATE_CLIENT_WORKING;
break;
this->state = PB_STATE_DECIDED;
break;
}
- if (this->is_server && type == PB_BATCH_SRETRY)
+ if (!this->is_server && type == PB_BATCH_CRETRY)
{
break;
}
}
return FALSE;
case PB_STATE_CLIENT_WORKING:
- if (!this->is_server && type == PB_BATCH_CDATA)
+ if (!this->is_server && (type == PB_BATCH_CDATA ||
+ type == PB_BATCH_CRETRY))
{
this->state = PB_STATE_SERVER_WORKING;
break;
}
+ if (this->is_server && type == PB_BATCH_SRETRY)
+ {
+ break;
+ }
if (type == PB_BATCH_CLOSE)
{
this->state = PB_STATE_END;
*/
static void build_retry_batch(private_tnccs_20_t *this)
{
+ pb_tnc_batch_type_t batch_retry_type;
+
+ batch_retry_type = this->is_server ? PB_BATCH_SRETRY : PB_BATCH_CRETRY;
if (this->batch)
{
+ if (this->batch->get_type(this->batch) == batch_retry_type)
+ {
+ /* retry batch has already been created */
+ return;
+ }
DBG1(DBG_TNC, "cancelling PB-TNC %N batch",
pb_tnc_batch_type_names, this->batch->get_type(this->batch));
this->batch->destroy(this->batch);
}
- this->batch = pb_tnc_batch_create(this->is_server,
- this->is_server ? PB_BATCH_SRETRY : PB_BATCH_CRETRY);
+ this->batch = pb_tnc_batch_create(this->is_server, batch_retry_type);
}
METHOD(tls_t, process, status_t,
private_tnccs_20_t *this, void *buf, size_t *buflen, size_t *msglen)
{
status_t status;
+ pb_tnc_state_t state;
/* Initialize the connection */
if (!this->is_server && !this->connection_id)
charon->imcs->begin_handshake(charon->imcs, this->connection_id);
}
- if (this->is_server && this->fatal_error &&
- this->state_machine->get_state(this->state_machine) == PB_STATE_END)
+ state = this->state_machine->get_state(this->state_machine);
+
+ if (this->is_server && this->fatal_error && state == PB_STATE_END)
{
DBG1(DBG_TNC, "a fatal PB-TNC error occurred, terminating connection");
return FAILED;
if (this->request_handshake_retry)
{
- build_retry_batch(this);
+ if (state != PB_STATE_INIT)
+ {
+ build_retry_batch(this);
+ }
/* Reset the flag for the next handshake retry request */
this->request_handshake_retry = FALSE;
if (!this->batch)
{
- pb_tnc_state_t state;
-
- state = this->state_machine->get_state(this->state_machine);
if (this->is_server)
{
if (state == PB_STATE_SERVER_WORKING)