diff options
author | Tobias Brunner <tobias@strongswan.org> | 2010-07-06 11:36:58 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2010-09-02 19:01:23 +0200 |
commit | 09ae31f13a65e4946d5e71ffd635af62b1695e1c (patch) | |
tree | 0b07adaefa92f328b924a8d770fba36bb3b6b1c7 /src/libcharon/kernel | |
parent | f7f3d87ed7206f8b5f8cdb2b2de6f3d657ca6426 (diff) | |
download | strongswan-09ae31f13a65e4946d5e71ffd635af62b1695e1c.tar.bz2 strongswan-09ae31f13a65e4946d5e71ffd635af62b1695e1c.tar.xz |
Added kernel event handler stub.
Diffstat (limited to 'src/libcharon/kernel')
-rw-r--r-- | src/libcharon/kernel/kernel_handler.c | 60 | ||||
-rw-r--r-- | src/libcharon/kernel/kernel_handler.h | 50 |
2 files changed, 110 insertions, 0 deletions
diff --git a/src/libcharon/kernel/kernel_handler.c b/src/libcharon/kernel/kernel_handler.c new file mode 100644 index 000000000..0e967fe5f --- /dev/null +++ b/src/libcharon/kernel/kernel_handler.c @@ -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; +} + diff --git a/src/libcharon/kernel/kernel_handler.h b/src/libcharon/kernel/kernel_handler.h new file mode 100644 index 000000000..f1fa0bdfc --- /dev/null +++ b/src/libcharon/kernel/kernel_handler.h @@ -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_ @}*/ |