Added kernel_ipsec/net plugin feature loading callbacks
This commit is contained in:
@@ -8,7 +8,7 @@ attributes/attribute_manager.c attributes/attribute_manager.h \
|
||||
attributes/mem_pool.c attributes/mem_pool.h \
|
||||
kernel/kernel_interface.c kernel/kernel_interface.h \
|
||||
kernel/kernel_ipsec.c kernel/kernel_ipsec.h \
|
||||
kernel/kernel_net.h \
|
||||
kernel/kernel_net.c kernel/kernel_net.h \
|
||||
kernel/kernel_listener.h
|
||||
|
||||
libhydra_la_LIBADD =
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "kernel_ipsec.h"
|
||||
|
||||
#include <hydra.h>
|
||||
|
||||
ENUM(ipsec_mode_names, MODE_TRANSPORT, MODE_DROP,
|
||||
"TRANSPORT",
|
||||
"TUNNEL",
|
||||
@@ -37,3 +39,21 @@ ENUM(ipcomp_transform_names, IPCOMP_NONE, IPCOMP_LZJH,
|
||||
"IPCOMP_LZJH"
|
||||
);
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
bool kernel_ipsec_register(plugin_t *plugin, plugin_feature_t *feature,
|
||||
bool reg, void *data)
|
||||
{
|
||||
if (reg)
|
||||
{
|
||||
hydra->kernel_interface->add_ipsec_interface(hydra->kernel_interface,
|
||||
(kernel_ipsec_constructor_t)data);
|
||||
}
|
||||
else
|
||||
{
|
||||
hydra->kernel_interface->remove_ipsec_interface(hydra->kernel_interface,
|
||||
(kernel_ipsec_constructor_t)data);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef struct mark_t mark_t;
|
||||
#include <utils/host.h>
|
||||
#include <crypto/prf_plus.h>
|
||||
#include <selectors/traffic_selector.h>
|
||||
#include <plugins/plugin.h>
|
||||
|
||||
/**
|
||||
* Mode of an IPsec SA.
|
||||
@@ -386,4 +387,18 @@ struct kernel_ipsec_t {
|
||||
void (*destroy) (kernel_ipsec_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to (un-)register IPsec kernel interfaces from plugin features.
|
||||
*
|
||||
* This function is a plugin_feature_callback_t and can be used with the
|
||||
* PLUGIN_CALLBACK macro to register an IPsec kernel interface constructor.
|
||||
*
|
||||
* @param plugin plugin registering the kernel interface
|
||||
* @param feature associated plugin feature
|
||||
* @param reg TRUE to register, FALSE to unregister
|
||||
* @param data data passed to callback, an kernel_ipsec_constructor_t
|
||||
*/
|
||||
bool kernel_ipsec_register(plugin_t *plugin, plugin_feature_t *feature,
|
||||
bool reg, void *data);
|
||||
|
||||
#endif /** KERNEL_IPSEC_H_ @}*/
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Martin Willi
|
||||
* Copyright (C) 2011 revosec AG
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "kernel_net.h"
|
||||
|
||||
#include <hydra.h>
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
bool kernel_net_register(plugin_t *plugin, plugin_feature_t *feature,
|
||||
bool reg, void *data)
|
||||
{
|
||||
if (reg)
|
||||
{
|
||||
hydra->kernel_interface->add_net_interface(hydra->kernel_interface,
|
||||
(kernel_net_constructor_t)data);
|
||||
}
|
||||
else
|
||||
{
|
||||
hydra->kernel_interface->remove_net_interface(hydra->kernel_interface,
|
||||
(kernel_net_constructor_t)data);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -26,6 +26,7 @@ typedef struct kernel_net_t kernel_net_t;
|
||||
|
||||
#include <utils/enumerator.h>
|
||||
#include <utils/host.h>
|
||||
#include <plugins/plugin.h>
|
||||
|
||||
/**
|
||||
* Interface to the network subsystem of the kernel.
|
||||
@@ -142,4 +143,18 @@ struct kernel_net_t {
|
||||
void (*destroy) (kernel_net_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to (un-)register net kernel interfaces from plugin features.
|
||||
*
|
||||
* This function is a plugin_feature_callback_t and can be used with the
|
||||
* PLUGIN_CALLBACK macro to register an net kernel interface constructor.
|
||||
*
|
||||
* @param plugin plugin registering the kernel interface
|
||||
* @param feature associated plugin feature
|
||||
* @param reg TRUE to register, FALSE to unregister
|
||||
* @param data data passed to callback, an kernel_net_constructor_t
|
||||
*/
|
||||
bool kernel_net_register(plugin_t *plugin, plugin_feature_t *feature,
|
||||
bool reg, void *data);
|
||||
|
||||
#endif /** KERNEL_NET_H_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user