moved imv_manager to libtnccs

This commit is contained in:
Andreas Steffen
2011-10-25 01:10:16 +02:00
parent f0fa002fd1
commit c008d2cc46
12 changed files with 81 additions and 41 deletions
-2
View File
@@ -87,8 +87,6 @@ sa/tasks/ike_reauth.c sa/tasks/ike_reauth.h \
sa/tasks/ike_auth_lifetime.c sa/tasks/ike_auth_lifetime.h \
sa/tasks/ike_vendor.c sa/tasks/ike_vendor.h \
sa/tasks/task.c sa/tasks/task.h \
tnc/imv/imv.h tnc/imv/imv_manager.h \
tnc/imv/imv_recommendations.c tnc/imv/imv_recommendations.h \
tnc/tnccs/tnccs.c tnc/tnccs/tnccs.h \
tnc/tnccs/tnccs_manager.c tnc/tnccs/tnccs_manager.h
-6
View File
@@ -152,7 +152,6 @@ typedef struct daemon_t daemon_t;
#include <sa/shunt_manager.h>
#include <config/backend_manager.h>
#include <sa/authenticators/eap/eap_manager.h>
#include <tnc/imv/imv_manager.h>
#include <tnc/tnccs/tnccs_manager.h>
#ifdef ME
@@ -240,11 +239,6 @@ struct daemon_t {
*/
eap_manager_t *eap;
/**
* TNC IMV manager controlling Integrity Measurement Verifiers
*/
imv_manager_t *imvs;
/**
* TNCCS manager to maintain registered TNCCS protocols
*/
+46 -18
View File
@@ -24,13 +24,31 @@
#include <errno.h>
#include <fcntl.h>
#include <daemon.h>
#include <utils/lexparser.h>
#include <debug.h>
typedef struct private_tnc_imv_plugin_t private_tnc_imv_plugin_t;
/**
* Private data of a tnc_imv_plugin_t object.
*/
struct private_tnc_imv_plugin_t {
/**
* Public interface.
*/
tnc_imv_plugin_t public;
/**
* TNC IMV manager controlling Integrity Measurement Verifiers
*/
imv_manager_t *imvs;
};
/**
* load IMVs from a configuration file
*/
static bool load_imvs(char *filename)
static bool load_imvs(private_tnc_imv_plugin_t *this, char *filename)
{
int fd, line_nr = 0;
chunk_t src, line;
@@ -128,7 +146,7 @@ static bool load_imvs(char *filename)
free(path);
return FALSE;
}
if (!charon->imvs->add(charon->imvs, imv))
if (!this->imvs->add(this->imvs, imv))
{
if (imv->terminate &&
imv->terminate(imv->get_id(imv)) != TNC_RESULT_SUCCESS)
@@ -153,10 +171,21 @@ METHOD(plugin_t, get_name, char*,
return "tnc-imv";
}
METHOD(plugin_t, get_features, int,
private_tnc_imv_plugin_t *this, plugin_feature_t *features[])
{
static plugin_feature_t f[] = {
PLUGIN_PROVIDE(CUSTOM, "imv-manager"),
};
*features = f;
return countof(f);
}
METHOD(plugin_t, destroy, void,
tnc_imv_plugin_t *this)
{
charon->imvs->destroy(charon->imvs);
lib->set(lib, "imv-manager", NULL);
this->imvs->destroy(this->imvs);
free(this);
}
@@ -169,27 +198,26 @@ plugin_t *tnc_imv_plugin_create()
tnc_imv_plugin_t *this;
INIT(this,
.plugin = {
.get_name = _get_name,
.reload = (void*)return_false,
.destroy = _destroy,
.public = {
.plugin = {
.get_name = _get_name,
.get_features = _get_features,
.destroy = _destroy,
},
},
.imvs = tnc_imv_manager_create(),
);
tnc_config = lib->settings->get_str(lib->settings,
"charon.plugins.tnc-imv.tnc_config", "/etc/tnc_config");
/* Create IMV manager */
charon->imvs = tnc_imv_manager_create();
lib->set(lib, "imv-manager", this->imvs);
/* Load IMVs and abort if not all instances initalize successfully */
if (!load_imvs(tnc_config))
tnc_config = lib->settings->get_str(lib->settings,
"charon.plugins.tnc-imv.tnc_config", "/etc/tnc_config");
if (!load_imvs(this, tnc_config))
{
charon->imvs->destroy(charon->imvs);
charon->imvs = NULL;
free(this);
destroy(this);
return NULL;
}
return &this->plugin;
return &this->public.plugin;
}
+8 -2
View File
@@ -99,6 +99,11 @@ struct private_tnccs_11_t {
*/
imc_manager_t *imcs;
/**
* TNC IMV manager controlling Integrity Measurement Verifiers
*/
imc_manager_t *imvs;
};
METHOD(tnccs_t, send_msg, TNC_Result,
@@ -181,7 +186,7 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
this->send_msg = TRUE;
if (this->is_server)
{
charon->imvs->receive_message(charon->imvs,
this->imvs->receive_message(this->imvs,
this->connection_id, msg_body.ptr, msg_body.len, msg_type);
}
else
@@ -343,7 +348,7 @@ METHOD(tls_t, process, status_t,
this->send_msg = TRUE;
if (this->is_server)
{
charon->imvs->batch_ending(charon->imvs, this->connection_id);
this->imvs->batch_ending(this->imvs, this->connection_id);
}
else
{
@@ -540,6 +545,7 @@ tls_t *tnccs_11_create(bool is_server)
.is_server = is_server,
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
.imcs = lib->get(lib, "imc-manager"),
.imvs = lib->get(lib, "imv-manager"),
);
return &this->public;
+8 -2
View File
@@ -99,6 +99,11 @@ struct private_tnccs_20_t {
*/
imc_manager_t *imcs;
/**
* TNC IMV manager controlling Integrity Measurement Verifiers
*/
imv_manager_t *imvs;
};
METHOD(tnccs_t, send_msg, TNC_Result,
@@ -198,7 +203,7 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
this->send_msg = TRUE;
if (this->is_server)
{
charon->imvs->receive_message(charon->imvs,
this->imvs->receive_message(this->imvs,
this->connection_id, msg_body.ptr, msg_body.len, msg_type);
}
else
@@ -447,7 +452,7 @@ METHOD(tls_t, process, status_t,
this->send_msg = TRUE;
if (this->is_server)
{
charon->imvs->batch_ending(charon->imvs, this->connection_id);
this->imvs->batch_ending(this->imvs, this->connection_id);
}
else
{
@@ -740,6 +745,7 @@ tls_t *tnccs_20_create(bool is_server)
.state_machine = pb_tnc_state_machine_create(is_server),
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
.imcs = lib->get(lib, "imc-manager"),
.imvs = lib->get(lib, "imv-manager"),
);
return &this->public;
+15 -5
View File
@@ -18,7 +18,7 @@
#include "tnccs_manager.h"
#include <imc/imc_manager.h>
#include <tnc/imv/imv_recommendations.h>
#include <imv/imv_manager.h>
#include <debug.h>
#include <daemon.h>
@@ -116,6 +116,11 @@ struct private_tnccs_manager_t {
*/
imc_manager_t *imcs;
/**
* TNC IMV manager controlling Integrity Measurement Verifiers
*/
imv_manager_t *imvs;
};
METHOD(tnccs_manager_t, add_method, void,
@@ -193,13 +198,17 @@ METHOD(tnccs_manager_t, create_connection, TNC_ConnectionID,
if (recs)
{
/* we assume a TNC Server needing recommendations from IMVs */
if (!charon->imvs)
if (!this->imvs)
{
this->imvs = lib->get(lib, "imv-manager");
}
if (!this->imvs)
{
DBG1(DBG_TNC, "no IMV manager available!");
free(entry);
return 0;
}
entry->recs = charon->imvs->create_recommendations(charon->imvs);
entry->recs = this->imvs->create_recommendations(this->imvs);
*recs = entry->recs;
}
else
@@ -234,9 +243,9 @@ METHOD(tnccs_manager_t, remove_connection, void,
if (is_server)
{
if (charon->imvs)
if (this->imvs)
{
charon->imvs->notify_connection_change(charon->imvs, id,
this->imvs->notify_connection_change(this->imvs, id,
TNC_CONNECTION_STATE_DELETE);
}
}
@@ -511,6 +520,7 @@ tnccs_manager_t *tnccs_manager_create()
.protocol_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
.connection_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
.imcs = lib->get(lib, "imc-manager"),
.imvs = lib->get(lib, "imv-manager"),
);
return &this->public;
+1 -1
View File
@@ -27,7 +27,7 @@ typedef struct tnccs_manager_t tnccs_manager_t;
#include "tnccs.h"
#include <tnc/imv/imv_recommendations.h>
#include <imv/imv_recommendations.h>
/**
* The TNCCS manager manages all TNCCS implementations and creates instances.
+3 -1
View File
@@ -6,5 +6,7 @@ ipseclib_LTLIBRARIES = libtnccs.la
libtnccs_la_LIBADD = $(top_builddir)/src/libtncif/libtncif.la
libtnccs_la_SOURCES = \
imc/imc.h imc/imc_manager.h
imc/imc.h imc/imc_manager.h \
imv/imv.h imv/imv_manager.h \
imv/imv_recommendations.h imv/imv_recommendations.c
@@ -23,8 +23,6 @@
typedef struct imv_manager_t imv_manager_t;
#ifdef USE_TNC
#include "imv.h"
#include "imv_recommendations.h"
@@ -144,6 +142,4 @@ struct imv_manager_t {
void (*destroy)(imv_manager_t *this);
};
#endif /* USE_TNC */
#endif /** IMV_MANAGER_H_ @}*/