1ff8c7c3b32725420b82c9127faa0f95feb78010
2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
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>.
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
17 * @defgroup listener listener
18 * @{ @ingroup listeners
24 typedef struct listener_t listener_t
;
29 * Listener interface, listens to events if registered to the bus.
34 * Log a debugging message.
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.
41 * @param group 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
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
);
53 * Hook called if a critical alert is risen.
55 * @param ike_sa IKE_SA associated to the alert, if any
56 * @param alert kind of alert
57 * @param ... alert specific argument list
58 " @return TRUE to stay registered, FALSE to unregister
60 bool (*alert
)(listener_t
*this, ike_sa_t
*ike_sa
,
61 alert_t alert
, va_list args
);
64 * Handle state changes in an IKE_SA.
66 * @param ike_sa IKE_SA which changes its state
67 * @param state new IKE_SA state this IKE_SA changes to
68 * @return TRUE to stay registered, FALSE to unregister
70 bool (*ike_state_change
)(listener_t
*this, ike_sa_t
*ike_sa
,
71 ike_sa_state_t state
);
74 * Handle state changes in a CHILD_SA.
76 * @param ike_sa IKE_SA containing the affected CHILD_SA
77 * @param child_sa CHILD_SA which changes its state
78 * @param state new CHILD_SA state this CHILD_SA changes to
79 * @return TRUE to stay registered, FALSE to unregister
81 bool (*child_state_change
)(listener_t
*this, ike_sa_t
*ike_sa
,
82 child_sa_t
*child_sa
, child_sa_state_t state
);
85 * Hook called for received/sent messages of an IKE_SA.
87 * @param ike_sa IKE_SA sending/receving a message
88 * @param message message object
89 * @param incoming TRUE for incoming messages, FALSE for outgoing
90 * @return TRUE to stay registered, FALSE to unregister
92 bool (*message
)(listener_t
*this, ike_sa_t
*ike_sa
, message_t
*message
,
96 * Hook called with IKE_SA key material.
98 * @param ike_sa IKE_SA this keymat belongs to
99 * @param dh diffie hellman shared secret
100 * @param nonce_i initiators nonce
101 * @param nonce_r responders nonce
102 * @param rekey IKE_SA we are rekeying, if any
103 * @return TRUE to stay registered, FALSE to unregister
105 bool (*ike_keys
)(listener_t
*this, ike_sa_t
*ike_sa
, diffie_hellman_t
*dh
,
106 chunk_t nonce_i
, chunk_t nonce_r
, ike_sa_t
*rekey
);
109 * Hook called with CHILD_SA key material.
111 * @param ike_sa IKE_SA the child sa belongs to
112 * @param child_sa CHILD_SA this keymat is used for
113 * @param dh diffie hellman shared secret
114 * @param nonce_i initiators nonce
115 * @param nonce_r responders nonce
116 * @return TRUE to stay registered, FALSE to unregister
118 bool (*child_keys
)(listener_t
*this, ike_sa_t
*ike_sa
, child_sa_t
*child_sa
,
119 diffie_hellman_t
*dh
, chunk_t nonce_i
, chunk_t nonce_r
);
122 * Hook called if an IKE_SA gets up or down.
124 * @param ike_sa IKE_SA coming up/going down
125 * @param up TRUE for an up event, FALSE for a down event
126 * @return TRUE to stay registered, FALSE to unregister
128 bool (*ike_updown
)(listener_t
*this, ike_sa_t
*ike_sa
, bool up
);
131 * Hook called when an IKE_SA gets rekeyed.
133 * @param old rekeyed IKE_SA getting obsolete
134 * @param new new IKE_SA replacing old
135 * @return TRUE to stay registered, FALSE to unregister
137 bool (*ike_rekey
)(listener_t
*this, ike_sa_t
*old
, ike_sa_t
*new);
140 * Hook called when a CHILD_SA gets up or down.
142 * @param ike_sa IKE_SA containing the handled CHILD_SA
143 * @param child_sa CHILD_SA coming up/going down
144 * @param up TRUE for an up event, FALSE for a down event
145 * @return TRUE to stay registered, FALSE to unregister
147 bool (*child_updown
)(listener_t
*this, ike_sa_t
*ike_sa
,
148 child_sa_t
*child_sa
, bool up
);
151 * Hook called when an CHILD_SA gets rekeyed.
153 * @param ike_sa IKE_SA containing the rekeyed CHILD_SA
154 * @param old rekeyed CHILD_SA getting obsolete
155 * @param new new CHILD_SA replacing old
156 * @return TRUE to stay registered, FALSE to unregister
158 bool (*child_rekey
)(listener_t
*this, ike_sa_t
*ike_sa
,
159 child_sa_t
*old
, child_sa_t
*new);
162 * Hook called to invoke additional authorization rules.
164 * An authorization hook gets invoked several times: After each
165 * authentication round, the hook gets invoked with with final = FALSE.
166 * After authentication is complete and the peer configuration is selected,
167 * it is invoked again, but with final = TRUE.
169 * @param ike_sa IKE_SA to authorize
170 * @param auth list of auth_cfg_t, done in peers authentication rounds
171 * @param final TRUE if this is the final hook invocation
172 * @param success set to TRUE to complete IKE_SA, FALSE abort
173 * @return TRUE to stay registered, FALSE to unregister
175 bool (*authorize
)(listener_t
*this, ike_sa_t
*ike_sa
, linked_list_t
*auth
,
176 bool final
, bool *success
);
179 #endif /** LISTENER_H_ @}*/