chunk_t batch;
/**
+ * Mutex locking the batch in construction
+ */
+ mutex_t *batch_mutex;
+
+ /**
* Action Recommendations and Evaluations Results provided by IMVs
*/
linked_list_t *recommendations;
TNC_UInt32 message_len,
TNC_MessageType message_type)
{
- chunk_t msg = { message, message_len },
- batch = this->batch;
+ chunk_t msg = { message, message_len };
DBG1(DBG_TNC, "TNCCS 2.0 send message");
- this->batch = chunk_cat("mc", batch, msg);
+ this->batch_mutex->lock(this->batch_mutex);
+ this->batch = chunk_cat("mc", this->batch, msg);
+ this->batch_mutex->unlock(this->batch_mutex);
}
METHOD(tnccs_t, provide_recommendation, void,
char *msg = this->is_server ? "tncs->tncc 2.0|" : "tncc->tncs 2.0|";
size_t len;
+ this->batch_mutex->lock(this->batch_mutex);
this->batch = chunk_cat("cm", chunk_create(msg, strlen(msg)), this->batch);
+ this->batch_mutex->unlock(this->batch_mutex);
if (!this->is_server && !this->connection_id)
{
charon->imcs->begin_handshake(charon->imcs, this->connection_id);
}
+ this->batch_mutex->lock(this->batch_mutex);
len = this->batch.len;
*msglen = len;
*buflen = len;
memcpy(buf, this->batch.ptr, len);
+ chunk_free(&this->batch);
+ this->batch_mutex->unlock(this->batch_mutex);
DBG1(DBG_TNC, "sending TNCCS Batch (%d bytes) for Connection ID %u",
len, this->connection_id);
DBG3(DBG_TNC, "%.*s", len, buf);
- chunk_free(&this->batch);
return ALREADY_DONE;
}
charon->tnccs->remove_connection(charon->tnccs, this->connection_id);
this->recommendations->destroy_function(this->recommendations, free);
this->recommendation_mutex->destroy(this->recommendation_mutex);
+ this->batch_mutex->destroy(this->batch_mutex);
free(this->batch.ptr);
free(this);
}
.is_server = is_server,
.recommendations = linked_list_create(),
.recommendation_mutex = mutex_create(MUTEX_TYPE_DEFAULT),
+ .batch_mutex = mutex_create(MUTEX_TYPE_DEFAULT),
);
return &this->public;