fea3a6997610026fa3093a3eeefb62de98c4da41
[strongswan.git] / src / charon / bus / listeners / listener.h
1 /*
2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup listener listener
18 * @{ @ingroup listeners
19 */
20
21 #ifndef LISTENER_H_
22 #define LISTENER_H_
23
24 typedef struct listener_t listener_t;
25
26 #include <bus/bus.h>
27
28 /**
29 * Listener interface, listens to events if registered to the bus.
30 */
31 struct listener_t {
32
33 /**
34 * Log a debugging message.
35 *
36 * The implementing signal function returns TRUE to stay registered
37 * to the bus, or FALSE to unregister itself.
38 * Calling bus_t.log() inside of a registered listener is possible,
39 * but the bus does not invoke listeners recursively.
40 *
41 * @param singal kind of the signal (up, down, rekeyed, ...)
42 * @param level verbosity level of the signal
43 * @param thread ID of the thread raised this signal
44 * @param ike_sa IKE_SA associated to the event
45 * @param format printf() style format string
46 * @param args vprintf() style va_list argument list
47 " @return TRUE to stay registered, FALSE to unregister
48 */
49 bool (*log) (listener_t *this, debug_t group, level_t level, int thread,
50 ike_sa_t *ike_sa, char* format, va_list args);
51
52 /**
53 * Handle state changes in an IKE_SA.
54 *
55 * @param ike_sa IKE_SA which changes its state
56 * @param state new IKE_SA state this IKE_SA changes to
57 * @return TRUE to stay registered, FALSE to unregister
58 */
59 bool (*ike_state_change)(listener_t *this, ike_sa_t *ike_sa,
60 ike_sa_state_t state);
61
62 /**
63 * Handle state changes in a CHILD_SA.
64 *
65 * @param ike_sa IKE_SA containing the affected CHILD_SA
66 * @param child_sa CHILD_SA which changes its state
67 * @param state new CHILD_SA state this CHILD_SA changes to
68 * @return TRUE to stay registered, FALSE to unregister
69 */
70 bool (*child_state_change)(listener_t *this, ike_sa_t *ike_sa,
71 child_sa_t *child_sa, child_sa_state_t state);
72
73 /**
74 * Hook called for received/sent messages of an IKE_SA.
75 *
76 * @param ike_sa IKE_SA sending/receving a message
77 * @param message message object
78 * @param incoming TRUE for incoming messages, FALSE for outgoing
79 * @return TRUE to stay registered, FALSE to unregister
80 */
81 bool (*message)(listener_t *this, ike_sa_t *ike_sa, message_t *message,
82 bool incoming);
83
84 /**
85 * Hook called with IKE_SA key material.
86 *
87 * @param ike_sa IKE_SA this keymat belongs to
88 * @param dh diffie hellman shared secret
89 * @param nonce_i initiators nonce
90 * @param nonce_r responders nonce
91 * @param rekey IKE_SA we are rekeying, if any
92 * @return TRUE to stay registered, FALSE to unregister
93 */
94 bool (*ike_keys)(listener_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
95 chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey);
96
97 /**
98 * Hook called with CHILD_SA key material.
99 *
100 * @param ike_sa IKE_SA the child sa belongs to
101 * @param child_sa CHILD_SA this keymat is used for
102 * @param dh diffie hellman shared secret
103 * @param nonce_i initiators nonce
104 * @param nonce_r responders nonce
105 * @return TRUE to stay registered, FALSE to unregister
106 */
107 bool (*child_keys)(listener_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
108 diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r);
109
110 /**
111 * Hook called to invoke additional authorization rules.
112 *
113 * An authorization hook gets invoked several times: After each
114 * authentication round, the hook gets invoked with with final = FALSE.
115 * After authentication is complete and the peer configuration is selected,
116 * it is invoked again, but with final = TRUE.
117 *
118 * @param ike_sa IKE_SA to authorize
119 * @param auth list of auth_cfg_t, done in peers authentication rounds
120 * @param final TRUE if this is the final hook invocation
121 * @param success set to TRUE to complete IKE_SA, FALSE abort
122 * @return TRUE to stay registered, FALSE to unregister
123 */
124 bool (*authorize)(listener_t *this, ike_sa_t *ike_sa, linked_list_t *auth,
125 bool final, bool *success);
126 };
127
128 #endif /* LISTENER_ @}*/