]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libcharon/kernel/kernel_listener.h
b69bed66f444c737e91504050942f9702848274f
[thirdparty/strongswan.git] / src / libcharon / kernel / kernel_listener.h
1 /*
2 * Copyright (C) 2010 Tobias Brunner
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 kernel_listener kernel_listener
18 * @{ @ingroup kernel
19 */
20
21 #ifndef KERNEL_LISTENER_H_
22 #define KERNEL_LISTENER_H_
23
24 typedef struct kernel_listener_t kernel_listener_t;
25
26 #include <kernel/kernel_ipsec.h>
27 #include <selectors/traffic_selector.h>
28 #include <utils/host.h>
29
30 /**
31 * Interface for components interested in kernel events.
32 *
33 * All hooks are optional.
34 */
35 struct kernel_listener_t {
36
37 /**
38 * Hook called if an acquire event for a policy is received.
39 *
40 * @param reqid reqid of the policy to acquire
41 * @param src_ts source traffic selector
42 * @param dst_ts destination traffic selector
43 * @return TRUE to remain registered, FALSE to unregister
44 */
45 bool (*acquire)(kernel_listener_t *this, u_int32_t reqid,
46 traffic_selector_t *src_ts, traffic_selector_t *dst_ts);
47
48 /**
49 * Hook called if an exire event for an IPsec SA is received.
50 *
51 * @param reqid reqid of the expired SA
52 * @param protocol protocol of the expired SA
53 * @param spi spi of the expired SA
54 * @param hard TRUE if it is a hard expire, FALSE otherwise
55 * @return TRUE to remain registered, FALSE to unregister
56 */
57 bool (*expire)(kernel_listener_t *this, u_int32_t reqid,
58 protocol_id_t protocol, u_int32_t spi, bool hard);
59
60 /**
61 * Hook called if the NAT mappings of an IPsec SA changed.
62 *
63 * @param reqid reqid of the SA
64 * @param spi spi of the SA
65 * @param remote new remote host
66 * @return TRUE to remain registered, FALSE to unregister
67 */
68 bool (*mapping)(kernel_listener_t *this, u_int32_t reqid, u_int32_t spi,
69 host_t *remote);
70
71 /**
72 * Hook called if a migrate event for a policy is received.
73 *
74 * @param reqid reqid of the policy
75 * @param src_ts source traffic selector
76 * @param dst_ts destination traffic selector
77 * @param direction direction of the policy (in|out)
78 * @param local local host address to be used in the IKE_SA
79 * @param remote remote host address to be used in the IKE_SA
80 * @return TRUE to remain registered, FALSE to unregister
81 */
82 bool (*migrate)(kernel_listener_t *this, u_int32_t reqid,
83 traffic_selector_t *src_ts, traffic_selector_t *dst_ts,
84 policy_dir_t direction, host_t *local, host_t *remote);
85
86 /**
87 * Hook called if changes in the networking layer occured (interfaces
88 * up/down, routes added/deleted etc.).
89 *
90 * @param address TRUE if address list, FALSE if routing changed
91 * @return TRUE to remain registered, FALSE to unregister
92 */
93 bool (*roam)(kernel_listener_t *this, bool address);
94 };
95
96 #endif /** KERNEL_LISTENER_H_ @}*/