aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-07-08 09:00:02 +0200
committerMartin Willi <martin@strongswan.org>2009-07-09 15:25:14 +0200
commita40cc76bc72a4d09405be6c03d19dc1bf184bdcd (patch)
tree88d5f6cd9a432460e612fb7cbafb5d9ea758f684 /src/charon
parent9d9cb65c8e80f4254573e1a237c6ee0354f52fe0 (diff)
downloadstrongswan-a40cc76bc72a4d09405be6c03d19dc1bf184bdcd.tar.bz2
strongswan-a40cc76bc72a4d09405be6c03d19dc1bf184bdcd.tar.xz
moved listener_t interface definition to a separate file
Diffstat (limited to 'src/charon')
-rw-r--r--src/charon/bus/bus.h103
-rw-r--r--src/charon/bus/listeners/file_logger.h4
-rw-r--r--src/charon/bus/listeners/listener.h128
-rw-r--r--src/charon/bus/listeners/sys_logger.c1
-rw-r--r--src/charon/bus/listeners/sys_logger.h6
5 files changed, 134 insertions, 108 deletions
diff --git a/src/charon/bus/bus.h b/src/charon/bus/bus.h
index 5faea088f..4fe6522da 100644
--- a/src/charon/bus/bus.h
+++ b/src/charon/bus/bus.h
@@ -23,7 +23,6 @@
typedef enum debug_t debug_t;
typedef enum level_t level_t;
-typedef struct listener_t listener_t;
typedef struct bus_t bus_t;
#include <stdarg.h>
@@ -31,6 +30,7 @@ typedef struct bus_t bus_t;
#include <sa/ike_sa.h>
#include <sa/child_sa.h>
#include <processing/jobs/job.h>
+#include <bus/listeners/listener.h>
/**
* Debug message group.
@@ -126,107 +126,6 @@ enum level_t {
# define 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.
*
diff --git a/src/charon/bus/listeners/file_logger.h b/src/charon/bus/listeners/file_logger.h
index 7282224a5..a69374f23 100644
--- a/src/charon/bus/listeners/file_logger.h
+++ b/src/charon/bus/listeners/file_logger.h
@@ -21,9 +21,9 @@
#ifndef 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.
diff --git a/src/charon/bus/listeners/listener.h b/src/charon/bus/listeners/listener.h
new file mode 100644
index 000000000..fea3a6997
--- /dev/null
+++ b/src/charon/bus/listeners/listener.h
@@ -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_ @}*/
diff --git a/src/charon/bus/listeners/sys_logger.c b/src/charon/bus/listeners/sys_logger.c
index 5bcf28f24..0b579ce92 100644
--- a/src/charon/bus/listeners/sys_logger.c
+++ b/src/charon/bus/listeners/sys_logger.c
@@ -15,7 +15,6 @@
#include <stdio.h>
#include <string.h>
-#include <pthread.h>
#include "sys_logger.h"
diff --git a/src/charon/bus/listeners/sys_logger.h b/src/charon/bus/listeners/sys_logger.h
index 6eda096a9..3ed0f02fa 100644
--- a/src/charon/bus/listeners/sys_logger.h
+++ b/src/charon/bus/listeners/sys_logger.h
@@ -21,11 +21,11 @@
#ifndef SYS_LOGGER_H_
#define SYS_LOGGER_H_
-typedef struct sys_logger_t sys_logger_t;
-
#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.