TNC_IMV_Evaluation_Result evaluation)
{
DBG2(DBG_TNC,"TNCS_ProvideRecommendation %u %u", imv_id, connection_id);
- return TNC_RESULT_SUCCESS;
+ return charon->tnccs->provide_recommendation(charon->tnccs, imv_id,
+ connection_id, recommendation, evaluation);
}
/**
this->batch = chunk_cat("mc", batch, msg);
}
+METHOD(tnccs_t, provide_recommendation, void,
+ private_tnccs_20_t* this, TNC_IMVID imv_id,
+ TNC_IMV_Action_Recommendation recommendation,
+ TNC_IMV_Evaluation_Result evaluation)
+{
+ DBG1(DBG_TNC, "TNCCS 2.0 provide recommendation");
+}
+
METHOD(tls_t, process, status_t,
private_tnccs_20_t *this, void *buf, size_t buflen)
{
if (this->is_server && !this->connection_id)
{
this->connection_id = charon->tnccs->create_connection(charon->tnccs,
- (tnccs_t*)this, _send_message);
+ (tnccs_t*)this,
+ _send_message, _provide_recommendation);
charon->imvs->notify_connection_change(charon->imvs,
this->connection_id, TNC_CONNECTION_STATE_CREATE);
}
if (!this->is_server && !this->connection_id)
{
this->connection_id = charon->tnccs->create_connection(charon->tnccs,
- (tnccs_t*)this, _send_message);
+ (tnccs_t*)this, _send_message, NULL);
charon->imcs->notify_connection_change(charon->imcs,
this->connection_id, TNC_CONNECTION_STATE_CREATE);
charon->imcs->notify_connection_change(charon->imcs,
#define TNCCS_H_
#include <tnc/tncif.h>
+#include <tnc/tncifimv.h>
#include <library.h>
typedef enum tnccs_type_t tnccs_type_t;
/**
* Callback function adding a message to a TNCCS batch
*
- * @param message message to be added
- * @param message_len message length
- * @param message_type message type
+ * @param message message to be added
+ * @param message_len message length
+ * @param message_type message type
*/
typedef void (*tnccs_send_message_t)(tnccs_t* tncss,
TNC_BufferReference message,
TNC_UInt32 message_len,
TNC_MessageType message_type);
+
+/**
+ * Callback function delivering an IMV Action Recommendation and
+ * IMV Evaluation Result to the TNCS
+ *
+ * @param imv_id ID of the IMV providing the recommendation
+ * @param recommendation action recommendation
+ * @param evaluation evaluation result
+ */
+typedef void (*tnccs_provide_recommendation_t)(tnccs_t* tncss,
+ TNC_IMVID imv_id,
+ TNC_IMV_Action_Recommendation recommendation,
+ TNC_IMV_Evaluation_Result evaluation);
+
#endif /** TNCCS_H_ @}*/
*
*/
tnccs_send_message_t send_message;
+
+ /** TNCS provide recommendation function
+ *
+ */
+ tnccs_provide_recommendation_t provide_recommendation;
};
/**
{
enumerator_t *enumerator;
tnccs_connection_entry_t *entry;
- tnccs_send_message_t send_message;
+ tnccs_send_message_t send_message = NULL;
tnccs_t *tnccs = NULL;
this->lock->write_lock(this->lock);
enumerator->destroy(enumerator);
this->lock->unlock(this->lock);
- if (tnccs)
+ if (tnccs && send_message)
{
send_message(tnccs, message, message_len, message_type);
return TNC_RESULT_SUCCESS;
return TNC_RESULT_FATAL;
}
+METHOD(tnccs_manager_t, provide_recommendation, TNC_Result,
+ private_tnccs_manager_t *this, TNC_IMVID imv_id,
+ TNC_ConnectionID id,
+ TNC_IMV_Action_Recommendation recommendation,
+ TNC_IMV_Evaluation_Result evaluation)
+{
+ enumerator_t *enumerator;
+ tnccs_connection_entry_t *entry;
+ tnccs_provide_recommendation_t provide_recommendation = NULL;
+ tnccs_t *tnccs = NULL;
+
+ this->lock->write_lock(this->lock);
+ enumerator = this->connections->create_enumerator(this->connections);
+ while (enumerator->enumerate(enumerator, &entry))
+ {
+ if (id == entry->id)
+ {
+ tnccs = entry->tnccs;
+ provide_recommendation = entry->provide_recommendation;
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
+
+ if (tnccs && provide_recommendation)
+ {
+ provide_recommendation(tnccs, imv_id, recommendation, evaluation);
+ return TNC_RESULT_SUCCESS;
+ }
+ return TNC_RESULT_FATAL;
+}
+
METHOD(tnccs_manager_t, destroy, void,
private_tnccs_manager_t *this)
{
.create_connection = _create_connection,
.remove_connection = _remove_connection,
.send_message = _send_message,
+ .provide_recommendation = _provide_recommendation,
.destroy = _destroy,
},
.protocols = linked_list_create(),
bool is_server);
/**
- * Create a TNCCS connection and assign a unique connection ID
+ * Create a TNCCS connection and assign a unique connection ID as well as
+ * callback functions for adding a message to a TNCCS batch and delivering
+ * an IMV recommendation, respectively
*
- * @param tnccs TNCCS connection instance
- * @param send_message callback function adding a message to a TNCCS batch
- * @return assigned connection ID
+ * @param tnccs TNCCS connection instance
+ * @param send_message TNCCS callback function
+ * @param provide_recommendation TNCS callback function
+ * @return assigned connection ID
*/
TNC_ConnectionID (*create_connection)(tnccs_manager_t *this, tnccs_t *tnccs,
- tnccs_send_message_t send_message);
+ tnccs_send_message_t send_message,
+ tnccs_provide_recommendation_t provide_recommendation);
/**
* Remove a TNCCS connection using its connection ID.
TNC_MessageType message_type);
/**
+ * Deliver an IMV Action Recommendation and IMV Evaluation Result to the TNCS
+ *
+ * @param imv_id ID of the IMV providing the recommendation
+ * @param connection_id target connection ID
+ * @param recommendation action recommendation
+ * @param evaluation evaluation result
+ */
+ TNC_Result (*provide_recommendation)(tnccs_manager_t *this,
+ TNC_IMVID imv_id,
+ TNC_ConnectionID connection_id,
+ TNC_IMV_Action_Recommendation recommendation,
+ TNC_IMV_Evaluation_Result evaluation);
+
+ /**
* Destroy a tnccs_manager instance.
*/
void (*destroy)(tnccs_manager_t *this);