2 * Copyright (C) 2010 Tobias Brunner
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 kernel_listener kernel_listener
21 #ifndef KERNEL_LISTENER_H_
22 #define KERNEL_LISTENER_H_
24 typedef struct kernel_listener_t kernel_listener_t
;
26 #include <kernel/kernel_ipsec.h>
27 #include <selectors/traffic_selector.h>
28 #include <utils/host.h>
31 * Interface for components interested in kernel events.
33 * All hooks are optional.
35 struct kernel_listener_t
{
38 * Hook called if an acquire event for a policy is received.
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
45 bool (*acquire
)(kernel_listener_t
*this, u_int32_t reqid
,
46 traffic_selector_t
*src_ts
, traffic_selector_t
*dst_ts
);
49 * Hook called if an exire event for an IPsec SA is received.
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
57 bool (*expire
)(kernel_listener_t
*this, u_int32_t reqid
,
58 protocol_id_t protocol
, u_int32_t spi
, bool hard
);
61 * Hook called if the NAT mappings of an IPsec SA changed.
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
68 bool (*mapping
)(kernel_listener_t
*this, u_int32_t reqid
, u_int32_t spi
,
72 * Hook called if a migrate event for a policy is received.
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
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
);
87 * Hook called if changes in the networking layer occured (interfaces
88 * up/down, routes added/deleted etc.).
90 * @param address TRUE if address list, FALSE if routing changed
91 * @return TRUE to remain registered, FALSE to unregister
93 bool (*roam
)(kernel_listener_t
*this, bool address
);
96 #endif /** KERNEL_LISTENER_H_ @}*/