Added kernel event handler stub.

This commit is contained in:
Tobias Brunner 2010-07-06 11:36:58 +02:00
parent f7f3d87ed7
commit 09ae31f13a
5 changed files with 120 additions and 0 deletions

View File

@ -40,6 +40,7 @@ encoding/payloads/transform_substructure.c encoding/payloads/transform_substruct
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 \
kernel/kernel_interface.c kernel/kernel_interface.h \
kernel/kernel_ipsec.c kernel/kernel_ipsec.h \
kernel/kernel_net.h \

View File

@ -38,6 +38,7 @@ encoding/payloads/transform_substructure.c encoding/payloads/transform_substruct
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 \
kernel/kernel_interface.c kernel/kernel_interface.h \
kernel/kernel_ipsec.c kernel/kernel_ipsec.h \
kernel/kernel_net.h \

View File

@ -34,6 +34,7 @@
#include <library.h>
#include <hydra.h>
#include <config/proposal.h>
#include <kernel/kernel_handler.h>
#ifndef LOG_AUTHPRIV /* not defined on OpenSolaris */
#define LOG_AUTHPRIV LOG_AUTH
@ -50,6 +51,11 @@ struct private_daemon_t {
*/
daemon_t public;
/**
* Handler for kernel events
*/
kernel_handler_t *kernel_handler;
/**
* capabilities to keep
*/
@ -111,6 +117,7 @@ static void destroy(private_daemon_t *this)
#endif /* CAPABILITIES_LIBCAP */
DESTROY_IF(this->public.traps);
DESTROY_IF(this->public.ike_sa_manager);
DESTROY_IF(this->kernel_handler);
DESTROY_IF(this->public.kernel_interface);
DESTROY_IF(this->public.scheduler);
DESTROY_IF(this->public.controller);
@ -364,6 +371,7 @@ METHOD(daemon_t, initialize, bool,
this->public.sim = sim_manager_create();
this->public.backends = backend_manager_create();
this->public.kernel_interface = kernel_interface_create();
this->kernel_handler = kernel_handler_create();
this->public.socket = socket_manager_create();
this->public.traps = trap_manager_create();

View File

@ -0,0 +1,60 @@
/*
* Copyright (C) 2010 Tobias Brunner
* Hochschule fuer Technik Rapperswil
*
* 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_handler.h"
#include <daemon.h>
typedef struct private_kernel_handler_t private_kernel_handler_t;
/**
* Private data of a kernel_handler_t object.
*/
struct private_kernel_handler_t {
/**
* Public part of kernel_handler_t object.
*/
kernel_handler_t public;
};
METHOD(kernel_handler_t, destroy, void,
private_kernel_handler_t *this)
{
charon->kernel_interface->remove_listener(charon->kernel_interface,
&this->public.listener);
free(this);
}
kernel_handler_t *kernel_handler_create()
{
private_kernel_handler_t *this;
INIT(this,
.public = {
.listener = {
.acquire = NULL,
},
.destroy = _destroy,
},
);
charon->kernel_interface->add_listener(charon->kernel_interface,
&this->public.listener);
return &this->public;
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2010 Tobias Brunner
* Hochschule fuer Technik Rapperswil
*
* 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.
*/
/**
* @defgroup kernel_handler kernel_handler
* @{ @ingroup kernel
*/
#ifndef KERNEL_HANDLER_H_
#define KERNEL_HANDLER_H_
typedef struct kernel_handler_t kernel_handler_t;
#include <kernel/kernel_listener.h>
/**
* Listens to and handles kernel events.
*/
struct kernel_handler_t {
/**
* Implements the kernel listener interface.
*/
kernel_listener_t listener;
/**
* Destroy this instance.
*/
void (*destroy)(kernel_handler_t *this);
};
/**
* Create an object of type kernel_handler_t.
*/
kernel_handler_t *kernel_handler_create();
#endif /** KERNEL_HANDLER_H_ @}*/