return "tnccs-11";
}
+METHOD(plugin_t, get_features, int,
+ tnccs_11_plugin_t *this, plugin_feature_t *features[])
+{
+ static plugin_feature_t f[] = {
+ PLUGIN_CALLBACK(tnccs_method_register, tnccs_11_create),
+ PLUGIN_PROVIDE(CUSTOM, "tnccs-1.1"),
+ PLUGIN_DEPENDS(EAP_SERVER, EAP_TNC),
+ PLUGIN_DEPENDS(EAP_PEER, EAP_TNC),
+ };
+ *features = f;
+ return countof(f);
+}
+
METHOD(plugin_t, destroy, void,
tnccs_11_plugin_t *this)
{
- charon->tnccs->remove_method(charon->tnccs,
- (tnccs_constructor_t)tnccs_11_create);
free(this);
}
INIT(this,
.plugin = {
.get_name = _get_name,
- .reload = (void*)return_false,
+ .get_features = _get_features,
.destroy = _destroy,
},
);
- charon->tnccs->add_method(charon->tnccs, TNCCS_1_1,
- (tnccs_constructor_t)tnccs_11_create);
-
return &this->plugin;
}
return "tnccs-20";
}
+METHOD(plugin_t, get_features, int,
+ tnccs_20_plugin_t *this, plugin_feature_t *features[])
+{
+ static plugin_feature_t f[] = {
+ PLUGIN_CALLBACK(tnccs_method_register, tnccs_20_create),
+ PLUGIN_PROVIDE(CUSTOM, "tnccs-2.0"),
+ PLUGIN_DEPENDS(EAP_SERVER, EAP_TNC),
+ PLUGIN_DEPENDS(EAP_PEER, EAP_TNC),
+ };
+ *features = f;
+ return countof(f);
+}
+
METHOD(plugin_t, destroy, void,
tnccs_20_plugin_t *this)
{
- charon->tnccs->remove_method(charon->tnccs,
- (tnccs_constructor_t)tnccs_20_create);
free(this);
}
INIT(this,
.plugin = {
.get_name = _get_name,
- .reload = (void*)return_false,
+ .get_features = _get_features,
.destroy = _destroy,
},
);
- charon->tnccs->add_method(charon->tnccs, TNCCS_2_0,
- (tnccs_constructor_t)tnccs_20_create);
-
return &this->plugin;
}
return "tnccs-dynamic";
}
+METHOD(plugin_t, get_features, int,
+ tnccs_dynamic_plugin_t *this, plugin_feature_t *features[])
+{
+ static plugin_feature_t f[] = {
+ PLUGIN_CALLBACK(tnccs_method_register, tnccs_dynamic_create),
+ PLUGIN_PROVIDE(CUSTOM, "tnccs-dynamic"),
+ PLUGIN_DEPENDS(CUSTOM, "tnccs-1.1"),
+ PLUGIN_DEPENDS(CUSTOM, "tnccs-2.0"),
+ PLUGIN_DEPENDS(EAP_SERVER, EAP_TNC),
+ PLUGIN_DEPENDS(EAP_PEER, EAP_TNC),
+ };
+ *features = f;
+ return countof(f);
+}
+
METHOD(plugin_t, destroy, void,
tnccs_dynamic_plugin_t *this)
{
- charon->tnccs->remove_method(charon->tnccs,
- (tnccs_constructor_t)tnccs_dynamic_create);
free(this);
}
INIT(this,
.plugin = {
.get_name = _get_name,
- .reload = (void*)return_false,
+ .get_features = _get_features,
.destroy = _destroy,
},
);
- charon->tnccs->add_method(charon->tnccs, TNCCS_DYNAMIC,
- (tnccs_constructor_t)tnccs_dynamic_create);
-
return &this->plugin;
}
* for more details.
*/
+#define USE_TNC
+
#include "tnccs.h"
+#include <daemon.h>
+
+
ENUM(tnccs_type_names, TNCCS_UNKNOWN, TNCCS_2_0,
"unknown TNCCS",
"TNCCS 1.1",
"TNCCS SOH",
"TNCCS 2.0",
);
+
+/**
+ * See header
+ */
+bool tnccs_method_register(plugin_t *plugin, plugin_feature_t *feature,
+ bool reg, void *data)
+{
+ if (reg)
+ {
+ if (feature->type == FEATURE_CUSTOM)
+ {
+ tnccs_type_t type = TNCCS_UNKNOWN;
+
+ if (streq(feature->arg.custom, "tnccs-2.0"))
+ {
+ type = TNCCS_2_0;
+ }
+ else if (streq(feature->arg.custom, "tnccs-1.1"))
+ {
+ type = TNCCS_1_1;
+ }
+ else if (streq(feature->arg.custom, "tnccs-dynamic"))
+ {
+ type = TNCCS_DYNAMIC;
+ }
+ else
+ {
+ return FALSE;
+ }
+ charon->tnccs->add_method(charon->tnccs, type,
+ (tnccs_constructor_t)data);
+ }
+ }
+ else
+ {
+ charon->tnccs->remove_method(charon->tnccs, (tnccs_constructor_t)data);
+ }
+ return TRUE;
+}
#ifndef TNCCS_H_
#define TNCCS_H_
+typedef struct tnccs_t tnccs_t;
+typedef enum tnccs_type_t tnccs_type_t;
+
#include <tncif.h>
#include <tncifimc.h>
#include <tncifimv.h>
#include <library.h>
-
-typedef enum tnccs_type_t tnccs_type_t;
+#include <plugins/plugin.h>
/**
* Type of TNC Client/Server protocol
*/
extern enum_name_t *tnccs_type_names;
-typedef struct tnccs_t tnccs_t;
-
/**
* Constructor definition for a pluggable TNCCS protocol implementation.
*
* @param is_server TRUE if TNC Server, FALSE if TNC Client
* @return implementation of the tnccs_t interface
*/
-typedef tnccs_t* (*tnccs_constructor_t)(bool is_server);
+typedef tnccs_t *(*tnccs_constructor_t)(bool is_server);
+
+/**
+ * Helper function to (un-)register TNCCS methods from plugin features.
+ *
+ * This function is a plugin_feature_callback_t and can be used with the
+ * PLUGIN_CALLBACK macro to register a TNCCS method constructor.
+ *
+ * @param plugin plugin registering the TNCCS method constructor
+ * @param feature associated plugin feature
+ * @param reg TRUE to register, FALSE to unregister.
+ * @param data data passed to callback, a tnccs_constructor_t
+ */
+bool tnccs_method_register(plugin_t *plugin, plugin_feature_t *feature,
+ bool reg, void *data);
/**
* Callback function adding a message to a TNCCS batch