Added socket plugin feature loading callback

This commit is contained in:
Martin Willi
2011-10-14 10:05:48 +02:00
parent 3b62d5bad8
commit 8b6881cfc5
3 changed files with 54 additions and 4 deletions
+3 -4
View File
@@ -39,10 +39,9 @@ encoding/payloads/ts_payload.c encoding/payloads/ts_payload.h \
encoding/payloads/unknown_payload.c encoding/payloads/unknown_payload.h \
encoding/payloads/vendor_id_payload.c encoding/payloads/vendor_id_payload.h \
kernel/kernel_handler.c kernel/kernel_handler.h \
network/packet.c network/packet.h \
network/receiver.c network/receiver.h \
network/sender.c network/sender.h \
network/socket_manager.c network/socket_manager.h network/socket.h \
network/receiver.c network/receiver.h network/sender.c network/sender.h \
network/packet.c network/packet.h network/socket.c network/socket.h \
network/socket_manager.c network/socket_manager.h \
processing/jobs/acquire_job.c processing/jobs/acquire_job.h \
processing/jobs/delete_child_sa_job.c processing/jobs/delete_child_sa_job.h \
processing/jobs/delete_ike_sa_job.c processing/jobs/delete_ike_sa_job.h \
+36
View File
@@ -0,0 +1,36 @@
/*
* 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 "socket.h"
#include <daemon.h>
/**
* See header
*/
bool socket_register(plugin_t *plugin, plugin_feature_t *feature,
bool reg, void *data)
{
if (reg)
{
charon->socket->add_socket(charon->socket, (socket_constructor_t)data);
}
else
{
charon->socket->remove_socket(charon->socket,
(socket_constructor_t)data);
}
return TRUE;
}
+15
View File
@@ -29,6 +29,7 @@ typedef struct socket_t socket_t;
#include <library.h>
#include <network/packet.h>
#include <utils/enumerator.h>
#include <plugins/plugin.h>
/**
* Constructor prototype for sockets.
@@ -72,4 +73,18 @@ struct socket_t {
void (*destroy) (socket_t *this);
};
/**
* Helper function to (un-)register socket interfaces from plugin features.
*
* This function is a plugin_feature_callback_t and can be used with the
* PLUGIN_CALLBACK macro to register an socket interface constructor.
*
* @param plugin plugin registering the socket interface
* @param feature associated plugin feature
* @param reg TRUE to register, FALSE to unregister
* @param data data passed to callback, a socket_constructor_t
*/
bool socket_register(plugin_t *plugin, plugin_feature_t *feature,
bool reg, void *data);
#endif /** SOCKET_H_ @}*/