aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/tnccs_20/tnccs_20.c
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2010-11-10 21:23:10 +0100
committerAndreas Steffen <andreas.steffen@strongswan.org>2010-11-10 21:23:37 +0100
commitcc5f7aa3d812bd016b706dbff7f70d03b5e60016 (patch)
tree5a596f523a1d227ab55075d51762cba62a7e8a50 /src/libcharon/plugins/tnccs_20/tnccs_20.c
parent30419567709c73a97eee5a8ce667d3b0584237fa (diff)
downloadstrongswan-cc5f7aa3d812bd016b706dbff7f70d03b5e60016.tar.bz2
strongswan-cc5f7aa3d812bd016b706dbff7f70d03b5e60016.tar.xz
implemented recommendation storage
Diffstat (limited to 'src/libcharon/plugins/tnccs_20/tnccs_20.c')
-rw-r--r--src/libcharon/plugins/tnccs_20/tnccs_20.c65
1 files changed, 61 insertions, 4 deletions
diff --git a/src/libcharon/plugins/tnccs_20/tnccs_20.c b/src/libcharon/plugins/tnccs_20/tnccs_20.c
index 158b5289b..075e08c31 100644
--- a/src/libcharon/plugins/tnccs_20/tnccs_20.c
+++ b/src/libcharon/plugins/tnccs_20/tnccs_20.c
@@ -18,11 +18,34 @@
#include <debug.h>
#include <daemon.h>
#include <tnc/tncif.h>
+#include <tnc/tncifimv_names.h>
#include <tnc/tnccs/tnccs.h>
+typedef struct recommendation_entry_t recommendation_entry_t;
typedef struct private_tnccs_20_t private_tnccs_20_t;
/**
+ * Recommendation entry
+ */
+struct recommendation_entry_t {
+
+ /**
+ * IMV ID
+ */
+ TNC_IMVID id;
+
+ /**
+ * Action Recommendation provided by IMV instance
+ */
+ TNC_IMV_Action_Recommendation rec;
+
+ /**
+ * Evaluation Result provided by IMV instance
+ */
+ TNC_IMV_Evaluation_Result eval;
+};
+
+/**
* Private data of a tnccs_20_t object.
*/
struct private_tnccs_20_t {
@@ -46,6 +69,11 @@ struct private_tnccs_20_t {
* Batch being constructed
*/
chunk_t batch;
+
+ /**
+ * Action Recommendations and Evaluations Results provided by IMVs
+ */
+ linked_list_t *recommendations;
};
METHOD(tnccs_t, send_message, void,
@@ -61,11 +89,38 @@ METHOD(tnccs_t, send_message, void,
}
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)
+ private_tnccs_20_t* this, TNC_IMVID id,
+ TNC_IMV_Action_Recommendation rec,
+ TNC_IMV_Evaluation_Result eval)
{
- DBG1(DBG_TNC, "TNCCS 2.0 provide recommendation");
+ enumerator_t *enumerator;
+ recommendation_entry_t *entry;
+ bool found = FALSE;
+
+ DBG2(DBG_TNC, "IMV %u provides recommendation '%N' and evaluation '%N'",
+ id, action_recommendation_names, rec, evaluation_result_names, eval);
+
+ enumerator = this->recommendations->create_enumerator(this->recommendations);
+ while (enumerator->enumerate(enumerator, &entry))
+ {
+ if (entry->id == id)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ if (!found)
+ {
+ entry = malloc_thing(recommendation_entry_t);
+ entry->id = id;
+ this->recommendations->insert_last(this->recommendations, entry);
+ }
+
+ /* Assign provided action recommendation and evaluation result */
+ entry->rec = rec;
+ entry->eval = eval;
}
METHOD(tls_t, process, status_t,
@@ -171,6 +226,7 @@ METHOD(tls_t, destroy, void,
private_tnccs_20_t *this)
{
charon->tnccs->remove_connection(charon->tnccs, this->connection_id);
+ this->recommendations->destroy_function(this->recommendations, free);
free(this->batch.ptr);
free(this);
}
@@ -193,6 +249,7 @@ tls_t *tnccs_20_create(bool is_server)
.destroy = _destroy,
},
.is_server = is_server,
+ .recommendations = linked_list_create(),
);
return &this->public;