moved listener_t interface definition to a separate file
This commit is contained in:
parent
9d9cb65c8e
commit
a40cc76bc7
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
typedef enum debug_t debug_t;
|
typedef enum debug_t debug_t;
|
||||||
typedef enum level_t level_t;
|
typedef enum level_t level_t;
|
||||||
typedef struct listener_t listener_t;
|
|
||||||
typedef struct bus_t bus_t;
|
typedef struct bus_t bus_t;
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -31,6 +30,7 @@ typedef struct bus_t bus_t;
|
||||||
#include <sa/ike_sa.h>
|
#include <sa/ike_sa.h>
|
||||||
#include <sa/child_sa.h>
|
#include <sa/child_sa.h>
|
||||||
#include <processing/jobs/job.h>
|
#include <processing/jobs/job.h>
|
||||||
|
#include <bus/listeners/listener.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug message group.
|
* Debug message group.
|
||||||
|
@ -126,107 +126,6 @@ enum level_t {
|
||||||
# define DBG4(...) {}
|
# define DBG4(...) {}
|
||||||
#endif /* DBG4 */
|
#endif /* DBG4 */
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Listener interface, listens to events if registered to the bus.
|
|
||||||
*/
|
|
||||||
struct listener_t {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log a debugging message.
|
|
||||||
*
|
|
||||||
* The implementing signal function returns TRUE to stay registered
|
|
||||||
* to the bus, or FALSE to unregister itself.
|
|
||||||
* Calling bus_t.log() inside of a registered listener is possible,
|
|
||||||
* but the bus does not invoke listeners recursively.
|
|
||||||
*
|
|
||||||
* @param singal kind of the signal (up, down, rekeyed, ...)
|
|
||||||
* @param level verbosity level of the signal
|
|
||||||
* @param thread ID of the thread raised this signal
|
|
||||||
* @param ike_sa IKE_SA associated to the event
|
|
||||||
* @param format printf() style format string
|
|
||||||
* @param args vprintf() style va_list argument list
|
|
||||||
" @return TRUE to stay registered, FALSE to unregister
|
|
||||||
*/
|
|
||||||
bool (*log) (listener_t *this, debug_t group, level_t level, int thread,
|
|
||||||
ike_sa_t *ike_sa, char* format, va_list args);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle state changes in an IKE_SA.
|
|
||||||
*
|
|
||||||
* @param ike_sa IKE_SA which changes its state
|
|
||||||
* @param state new IKE_SA state this IKE_SA changes to
|
|
||||||
* @return TRUE to stay registered, FALSE to unregister
|
|
||||||
*/
|
|
||||||
bool (*ike_state_change)(listener_t *this, ike_sa_t *ike_sa,
|
|
||||||
ike_sa_state_t state);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle state changes in a CHILD_SA.
|
|
||||||
*
|
|
||||||
* @param ike_sa IKE_SA containing the affected CHILD_SA
|
|
||||||
* @param child_sa CHILD_SA which changes its state
|
|
||||||
* @param state new CHILD_SA state this CHILD_SA changes to
|
|
||||||
* @return TRUE to stay registered, FALSE to unregister
|
|
||||||
*/
|
|
||||||
bool (*child_state_change)(listener_t *this, ike_sa_t *ike_sa,
|
|
||||||
child_sa_t *child_sa, child_sa_state_t state);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook called for received/sent messages of an IKE_SA.
|
|
||||||
*
|
|
||||||
* @param ike_sa IKE_SA sending/receving a message
|
|
||||||
* @param message message object
|
|
||||||
* @param incoming TRUE for incoming messages, FALSE for outgoing
|
|
||||||
* @return TRUE to stay registered, FALSE to unregister
|
|
||||||
*/
|
|
||||||
bool (*message)(listener_t *this, ike_sa_t *ike_sa, message_t *message,
|
|
||||||
bool incoming);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook called with IKE_SA key material.
|
|
||||||
*
|
|
||||||
* @param ike_sa IKE_SA this keymat belongs to
|
|
||||||
* @param dh diffie hellman shared secret
|
|
||||||
* @param nonce_i initiators nonce
|
|
||||||
* @param nonce_r responders nonce
|
|
||||||
* @param rekey IKE_SA we are rekeying, if any
|
|
||||||
* @return TRUE to stay registered, FALSE to unregister
|
|
||||||
*/
|
|
||||||
bool (*ike_keys)(listener_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
|
|
||||||
chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook called with CHILD_SA key material.
|
|
||||||
*
|
|
||||||
* @param ike_sa IKE_SA the child sa belongs to
|
|
||||||
* @param child_sa CHILD_SA this keymat is used for
|
|
||||||
* @param dh diffie hellman shared secret
|
|
||||||
* @param nonce_i initiators nonce
|
|
||||||
* @param nonce_r responders nonce
|
|
||||||
* @return TRUE to stay registered, FALSE to unregister
|
|
||||||
*/
|
|
||||||
bool (*child_keys)(listener_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
|
|
||||||
diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook called to invoke additional authorization rules.
|
|
||||||
*
|
|
||||||
* An authorization hook gets invoked several times: After each
|
|
||||||
* authentication round, the hook gets invoked with with final = FALSE.
|
|
||||||
* After authentication is complete and the peer configuration is selected,
|
|
||||||
* it is invoked again, but with final = TRUE.
|
|
||||||
*
|
|
||||||
* @param ike_sa IKE_SA to authorize
|
|
||||||
* @param auth list of auth_cfg_t, done in peers authentication rounds
|
|
||||||
* @param final TRUE if this is the final hook invocation
|
|
||||||
* @param success set to TRUE to complete IKE_SA, FALSE abort
|
|
||||||
* @return TRUE to stay registered, FALSE to unregister
|
|
||||||
*/
|
|
||||||
bool (*authorize)(listener_t *this, ike_sa_t *ike_sa, linked_list_t *auth,
|
|
||||||
bool final, bool *success);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bus receives events and sends them to all registered listeners.
|
* The bus receives events and sends them to all registered listeners.
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
#ifndef FILE_LOGGER_H_
|
#ifndef FILE_LOGGER_H_
|
||||||
#define FILE_LOGGER_H_
|
#define FILE_LOGGER_H_
|
||||||
|
|
||||||
typedef struct file_logger_t file_logger_t;
|
#include <bus/listeners/listener.h>
|
||||||
|
|
||||||
#include <bus/bus.h>
|
typedef struct file_logger_t file_logger_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger to files which implements listener_t.
|
* Logger to files which implements listener_t.
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009 Martin Willi
|
||||||
|
* 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 listener listener
|
||||||
|
* @{ @ingroup listeners
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LISTENER_H_
|
||||||
|
#define LISTENER_H_
|
||||||
|
|
||||||
|
typedef struct listener_t listener_t;
|
||||||
|
|
||||||
|
#include <bus/bus.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener interface, listens to events if registered to the bus.
|
||||||
|
*/
|
||||||
|
struct listener_t {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a debugging message.
|
||||||
|
*
|
||||||
|
* The implementing signal function returns TRUE to stay registered
|
||||||
|
* to the bus, or FALSE to unregister itself.
|
||||||
|
* Calling bus_t.log() inside of a registered listener is possible,
|
||||||
|
* but the bus does not invoke listeners recursively.
|
||||||
|
*
|
||||||
|
* @param singal kind of the signal (up, down, rekeyed, ...)
|
||||||
|
* @param level verbosity level of the signal
|
||||||
|
* @param thread ID of the thread raised this signal
|
||||||
|
* @param ike_sa IKE_SA associated to the event
|
||||||
|
* @param format printf() style format string
|
||||||
|
* @param args vprintf() style va_list argument list
|
||||||
|
" @return TRUE to stay registered, FALSE to unregister
|
||||||
|
*/
|
||||||
|
bool (*log) (listener_t *this, debug_t group, level_t level, int thread,
|
||||||
|
ike_sa_t *ike_sa, char* format, va_list args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle state changes in an IKE_SA.
|
||||||
|
*
|
||||||
|
* @param ike_sa IKE_SA which changes its state
|
||||||
|
* @param state new IKE_SA state this IKE_SA changes to
|
||||||
|
* @return TRUE to stay registered, FALSE to unregister
|
||||||
|
*/
|
||||||
|
bool (*ike_state_change)(listener_t *this, ike_sa_t *ike_sa,
|
||||||
|
ike_sa_state_t state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle state changes in a CHILD_SA.
|
||||||
|
*
|
||||||
|
* @param ike_sa IKE_SA containing the affected CHILD_SA
|
||||||
|
* @param child_sa CHILD_SA which changes its state
|
||||||
|
* @param state new CHILD_SA state this CHILD_SA changes to
|
||||||
|
* @return TRUE to stay registered, FALSE to unregister
|
||||||
|
*/
|
||||||
|
bool (*child_state_change)(listener_t *this, ike_sa_t *ike_sa,
|
||||||
|
child_sa_t *child_sa, child_sa_state_t state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called for received/sent messages of an IKE_SA.
|
||||||
|
*
|
||||||
|
* @param ike_sa IKE_SA sending/receving a message
|
||||||
|
* @param message message object
|
||||||
|
* @param incoming TRUE for incoming messages, FALSE for outgoing
|
||||||
|
* @return TRUE to stay registered, FALSE to unregister
|
||||||
|
*/
|
||||||
|
bool (*message)(listener_t *this, ike_sa_t *ike_sa, message_t *message,
|
||||||
|
bool incoming);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called with IKE_SA key material.
|
||||||
|
*
|
||||||
|
* @param ike_sa IKE_SA this keymat belongs to
|
||||||
|
* @param dh diffie hellman shared secret
|
||||||
|
* @param nonce_i initiators nonce
|
||||||
|
* @param nonce_r responders nonce
|
||||||
|
* @param rekey IKE_SA we are rekeying, if any
|
||||||
|
* @return TRUE to stay registered, FALSE to unregister
|
||||||
|
*/
|
||||||
|
bool (*ike_keys)(listener_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
|
||||||
|
chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called with CHILD_SA key material.
|
||||||
|
*
|
||||||
|
* @param ike_sa IKE_SA the child sa belongs to
|
||||||
|
* @param child_sa CHILD_SA this keymat is used for
|
||||||
|
* @param dh diffie hellman shared secret
|
||||||
|
* @param nonce_i initiators nonce
|
||||||
|
* @param nonce_r responders nonce
|
||||||
|
* @return TRUE to stay registered, FALSE to unregister
|
||||||
|
*/
|
||||||
|
bool (*child_keys)(listener_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
|
||||||
|
diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called to invoke additional authorization rules.
|
||||||
|
*
|
||||||
|
* An authorization hook gets invoked several times: After each
|
||||||
|
* authentication round, the hook gets invoked with with final = FALSE.
|
||||||
|
* After authentication is complete and the peer configuration is selected,
|
||||||
|
* it is invoked again, but with final = TRUE.
|
||||||
|
*
|
||||||
|
* @param ike_sa IKE_SA to authorize
|
||||||
|
* @param auth list of auth_cfg_t, done in peers authentication rounds
|
||||||
|
* @param final TRUE if this is the final hook invocation
|
||||||
|
* @param success set to TRUE to complete IKE_SA, FALSE abort
|
||||||
|
* @return TRUE to stay registered, FALSE to unregister
|
||||||
|
*/
|
||||||
|
bool (*authorize)(listener_t *this, ike_sa_t *ike_sa, linked_list_t *auth,
|
||||||
|
bool final, bool *success);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* LISTENER_ @}*/
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include "sys_logger.h"
|
#include "sys_logger.h"
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,11 @@
|
||||||
#ifndef SYS_LOGGER_H_
|
#ifndef SYS_LOGGER_H_
|
||||||
#define SYS_LOGGER_H_
|
#define SYS_LOGGER_H_
|
||||||
|
|
||||||
typedef struct sys_logger_t sys_logger_t;
|
|
||||||
|
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
#include <bus/bus.h>
|
#include <bus/listeners/listener.h>
|
||||||
|
|
||||||
|
typedef struct sys_logger_t sys_logger_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger for syslog which implements listener_t.
|
* Logger for syslog which implements listener_t.
|
||||||
|
|
Loading…
Reference in New Issue