Moved data structures to new collections subfolder
[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 * @return reqid of installed CHILD_SA, 0 if failed
41 */
42 u_int32_t (*install)(trap_manager_t *this, peer_cfg_t *peer,
43 child_cfg_t *child);
44
45 /**
46 * Uninstall a trap policy.
47 *
48 * @param id reqid of CHILD_SA to uninstall, returned by install()
49 * @return TRUE if uninstalled successfully
50 */
51 bool (*uninstall)(trap_manager_t *this, u_int32_t reqid);
52
53 /**
54 * Create an enumerator over all installed traps.
55 *
56 * @return enumerator over (peer_cfg_t, child_sa_t)
57 */
58 enumerator_t* (*create_enumerator)(trap_manager_t *this);
59
60 /**
61 * Acquire an SA triggered by an installed trap.
62 *
63 * @param reqid requid of the triggering CHILD_SA
64 * @param src source of the triggering packet
65 * @param dst destination of the triggering packet
66 */
67 void (*acquire)(trap_manager_t *this, u_int32_t reqid,
68 traffic_selector_t *src, traffic_selector_t *dst);
69
70 /**
71 * Clear any installed trap.
72 */
73 void (*flush)(trap_manager_t *this);
74
75 /**
76 * Destroy a trap_manager_t.
77 */
78 void (*destroy)(trap_manager_t *this);
79 };
80
81 /**
82 * Create a trap_manager instance.
83 */
84 trap_manager_t *trap_manager_create();
85
86 #endif /** TRAP_MANAGER_H_ @}*/