plugin-loader: Optionally use load option in each plugin section to load plugins
[strongswan.git] / src / libcharon / sa / trap_manager.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 trap_manager trap_manager
18 * @{ @ingroup sa
19 */
20
21 #ifndef TRAP_MANAGER_H_
22 #define TRAP_MANAGER_H_
23
24 #include <library.h>
25 #include <collections/enumerator.h>
26 #include <config/peer_cfg.h>
27
28 typedef struct trap_manager_t trap_manager_t;
29
30 /**
31 * Manage policies to create SAs from traffic.
32 */
33 struct trap_manager_t {
34
35 /**
36 * Install a policy as a trap.
37 *
38 * @param peer peer configuration to initiate on trap
39 * @param child child configuration to install as a trap
40 * @param reqid optional reqid to use
41 * @return reqid of installed CHILD_SA, 0 if failed
42 */
43 u_int32_t (*install)(trap_manager_t *this, peer_cfg_t *peer,
44 child_cfg_t *child, u_int32_t reqid);
45
46 /**
47 * Uninstall a trap policy.
48 *
49 * @param id reqid of CHILD_SA to uninstall, returned by install()
50 * @return TRUE if uninstalled successfully
51 */
52 bool (*uninstall)(trap_manager_t *this, u_int32_t reqid);
53
54 /**
55 * Create an enumerator over all installed traps.
56 *
57 * @return enumerator over (peer_cfg_t, child_sa_t)
58 */
59 enumerator_t* (*create_enumerator)(trap_manager_t *this);
60
61 /**
62 * Find the reqid of a child config installed as a trap.
63 *
64 * @param child CHILD_SA config to get the reqid for
65 * @return reqid of trap, 0 if not found
66 */
67 u_int32_t (*find_reqid)(trap_manager_t *this, child_cfg_t *child);
68
69 /**
70 * Acquire an SA triggered by an installed trap.
71 *
72 * @param reqid requid of the triggering CHILD_SA
73 * @param src source of the triggering packet
74 * @param dst destination of the triggering packet
75 */
76 void (*acquire)(trap_manager_t *this, u_int32_t reqid,
77 traffic_selector_t *src, traffic_selector_t *dst);
78
79 /**
80 * Clear any installed trap.
81 */
82 void (*flush)(trap_manager_t *this);
83
84 /**
85 * Destroy a trap_manager_t.
86 */
87 void (*destroy)(trap_manager_t *this);
88 };
89
90 /**
91 * Create a trap_manager instance.
92 */
93 trap_manager_t *trap_manager_create();
94
95 #endif /** TRAP_MANAGER_H_ @}*/