Add features support to tnccs plugins
This commit is contained in:
@@ -24,11 +24,22 @@ METHOD(plugin_t, get_name, char*,
|
|||||||
return "tnccs-11";
|
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,
|
METHOD(plugin_t, destroy, void,
|
||||||
tnccs_11_plugin_t *this)
|
tnccs_11_plugin_t *this)
|
||||||
{
|
{
|
||||||
charon->tnccs->remove_method(charon->tnccs,
|
|
||||||
(tnccs_constructor_t)tnccs_11_create);
|
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,14 +53,11 @@ plugin_t *tnccs_11_plugin_create()
|
|||||||
INIT(this,
|
INIT(this,
|
||||||
.plugin = {
|
.plugin = {
|
||||||
.get_name = _get_name,
|
.get_name = _get_name,
|
||||||
.reload = (void*)return_false,
|
.get_features = _get_features,
|
||||||
.destroy = _destroy,
|
.destroy = _destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
charon->tnccs->add_method(charon->tnccs, TNCCS_1_1,
|
|
||||||
(tnccs_constructor_t)tnccs_11_create);
|
|
||||||
|
|
||||||
return &this->plugin;
|
return &this->plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,22 @@ METHOD(plugin_t, get_name, char*,
|
|||||||
return "tnccs-20";
|
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,
|
METHOD(plugin_t, destroy, void,
|
||||||
tnccs_20_plugin_t *this)
|
tnccs_20_plugin_t *this)
|
||||||
{
|
{
|
||||||
charon->tnccs->remove_method(charon->tnccs,
|
|
||||||
(tnccs_constructor_t)tnccs_20_create);
|
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,14 +53,11 @@ plugin_t *tnccs_20_plugin_create()
|
|||||||
INIT(this,
|
INIT(this,
|
||||||
.plugin = {
|
.plugin = {
|
||||||
.get_name = _get_name,
|
.get_name = _get_name,
|
||||||
.reload = (void*)return_false,
|
.get_features = _get_features,
|
||||||
.destroy = _destroy,
|
.destroy = _destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
charon->tnccs->add_method(charon->tnccs, TNCCS_2_0,
|
|
||||||
(tnccs_constructor_t)tnccs_20_create);
|
|
||||||
|
|
||||||
return &this->plugin;
|
return &this->plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,24 @@ METHOD(plugin_t, get_name, char*,
|
|||||||
return "tnccs-dynamic";
|
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,
|
METHOD(plugin_t, destroy, void,
|
||||||
tnccs_dynamic_plugin_t *this)
|
tnccs_dynamic_plugin_t *this)
|
||||||
{
|
{
|
||||||
charon->tnccs->remove_method(charon->tnccs,
|
|
||||||
(tnccs_constructor_t)tnccs_dynamic_create);
|
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,14 +55,11 @@ plugin_t *tnccs_dynamic_plugin_create()
|
|||||||
INIT(this,
|
INIT(this,
|
||||||
.plugin = {
|
.plugin = {
|
||||||
.get_name = _get_name,
|
.get_name = _get_name,
|
||||||
.reload = (void*)return_false,
|
.get_features = _get_features,
|
||||||
.destroy = _destroy,
|
.destroy = _destroy,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
charon->tnccs->add_method(charon->tnccs, TNCCS_DYNAMIC,
|
|
||||||
(tnccs_constructor_t)tnccs_dynamic_create);
|
|
||||||
|
|
||||||
return &this->plugin;
|
return &this->plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,55 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define USE_TNC
|
||||||
|
|
||||||
#include "tnccs.h"
|
#include "tnccs.h"
|
||||||
|
|
||||||
|
#include <daemon.h>
|
||||||
|
|
||||||
|
|
||||||
ENUM(tnccs_type_names, TNCCS_UNKNOWN, TNCCS_2_0,
|
ENUM(tnccs_type_names, TNCCS_UNKNOWN, TNCCS_2_0,
|
||||||
"unknown TNCCS",
|
"unknown TNCCS",
|
||||||
"TNCCS 1.1",
|
"TNCCS 1.1",
|
||||||
"TNCCS SOH",
|
"TNCCS SOH",
|
||||||
"TNCCS 2.0",
|
"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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,13 +24,15 @@
|
|||||||
#ifndef TNCCS_H_
|
#ifndef TNCCS_H_
|
||||||
#define TNCCS_H_
|
#define TNCCS_H_
|
||||||
|
|
||||||
|
typedef struct tnccs_t tnccs_t;
|
||||||
|
typedef enum tnccs_type_t tnccs_type_t;
|
||||||
|
|
||||||
#include <tncif.h>
|
#include <tncif.h>
|
||||||
#include <tncifimc.h>
|
#include <tncifimc.h>
|
||||||
#include <tncifimv.h>
|
#include <tncifimv.h>
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
|
#include <plugins/plugin.h>
|
||||||
typedef enum tnccs_type_t tnccs_type_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of TNC Client/Server protocol
|
* Type of TNC Client/Server protocol
|
||||||
@@ -48,15 +50,27 @@ enum tnccs_type_t {
|
|||||||
*/
|
*/
|
||||||
extern enum_name_t *tnccs_type_names;
|
extern enum_name_t *tnccs_type_names;
|
||||||
|
|
||||||
typedef struct tnccs_t tnccs_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor definition for a pluggable TNCCS protocol implementation.
|
* Constructor definition for a pluggable TNCCS protocol implementation.
|
||||||
*
|
*
|
||||||
* @param is_server TRUE if TNC Server, FALSE if TNC Client
|
* @param is_server TRUE if TNC Server, FALSE if TNC Client
|
||||||
* @return implementation of the tnccs_t interface
|
* @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
|
* Callback function adding a message to a TNCCS batch
|
||||||
|
|||||||
Reference in New Issue
Block a user