06a5fe6c426f73b82fa5987ddbb71e209db13de9
[strongswan.git] / src / charon / control / interface_manager.h
1 /**
2 * @file interface_manager.h
3 *
4 * @brief Interface of interface_manager_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef INTERFACE_MANAGER_H_
24 #define INTERFACE_MANAGER_H_
25
26 #include <bus/bus.h>
27
28 /**
29 * callback to log things triggered by interface_manager.
30 *
31 * @param param echoed parameter supplied when function invoked
32 * @param signal type of signal
33 * @param level verbosity level if log
34 * @param ike_sa associated IKE_SA, if any
35 * @param format printf like format string
36 * @param args list of arguments to use for format
37 * @return FALSE to return from invoked function
38 * @ingroup control
39 */
40 typedef bool(*interface_manager_cb_t)(void* param, signal_t signal, level_t level,
41 ike_sa_t* ike_sa, char* format, va_list args);
42
43 typedef struct interface_manager_t interface_manager_t;
44
45 /**
46 * @brief The interface_manager loads control interfaces and has helper methods.
47 *
48 * One job of the interface manager is to load pluggable control interface
49 * modules, implemented as interface_t.
50 * @verbatim
51
52 +---------+ +------------+ +--------------+ |
53 | | | |<----- +--------------+ | |
54 | daemon |<-----| interface- | +--------------+ |-+ <==|==> IPC
55 | core | | manager |<----| interfaces |-+ |
56 | |<-----| | +--------------+ |
57 | | | | |
58 +---------+ +------------+ |
59
60 @endverbatim
61 * The manager does not really use the interfaces, instead, the interface
62 * use the manager to fullfill their tasks (initiating, terminating, ...).
63 * The interface_manager starts actions by creating jobs. It then tries to
64 * evaluate the result of the operation by listening on the bus.
65 *
66 * @b Constructors:
67 * - interface_manager_create()
68 *
69 * @ingroup control
70 */
71 struct interface_manager_t {
72
73 /**
74 * @brief Create an iterator for all IKE_SAs.
75 *
76 * The iterator blocks the IKE_SA manager until it gets destroyed. Do
77 * not call another interface/manager method while the iterator is alive.
78 *
79 * @param this calling object
80 * @return iterator, locks IKE_SA manager until destroyed
81 */
82 iterator_t* (*create_ike_sa_iterator)(interface_manager_t *this);
83
84 /**
85 * @brief Initiate a CHILD_SA, and if required, an IKE_SA.
86 *
87 * The inititate() function is synchronous and thus blocks until the
88 * IKE_SA is established or failed. Because of this, the initiate() function
89 * contains a thread cancellation point.
90 *
91 * @param this calling object
92 * @param peer_cfg peer_cfg to use for IKE_SA setup
93 * @param child_cfg child_cfg to set up CHILD_SA from
94 * @param cb logging callback
95 * @param param parameter to include in each call of cb
96 * @return
97 * - SUCCESS, if CHILD_SA established
98 * - FAILED, if setup failed
99 * - NEED_MORE, if callback returned FALSE
100 */
101 status_t (*initiate)(interface_manager_t *this,
102 peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
103 interface_manager_cb_t callback, void *param);
104
105 /**
106 * @brief Terminate an IKE_SA and all of its CHILD_SAs.
107 *
108 * The terminate() function is synchronous and thus blocks until the
109 * IKE_SA is properly deleted, or the delete timed out.
110 * The terminate() function contains a thread cancellation point.
111 *
112 * @param this calling object
113 * @param unique_id unique id of the IKE_SA to terminate.
114 * @param cb logging callback
115 * @param param parameter to include in each call of cb
116 * @return
117 * - SUCCESS, if CHILD_SA terminated
118 * - NOT_FOUND, if no such CHILD_SA found
119 * - NEED_MORE, if callback returned FALSE
120 */
121 status_t (*terminate_ike)(interface_manager_t *this, u_int32_t unique_id,
122 interface_manager_cb_t callback, void *param);
123
124 /**
125 * @brief Terminate a CHILD_SA.
126 *
127 * @param this calling object
128 * @param reqid reqid of the CHILD_SA to terminate
129 * @param cb logging callback
130 * @param param parameter to include in each call of cb
131 * @return
132 * - SUCCESS, if CHILD_SA terminated
133 * - NOT_FOUND, if no such CHILD_SA found
134 * - NEED_MORE, if callback returned FALSE
135 */
136 status_t (*terminate_child)(interface_manager_t *this, u_int32_t reqid,
137 interface_manager_cb_t callback, void *param);
138
139 /**
140 * @brief Route a CHILD_SA (install triggering policies).
141 *
142 * @param this calling object
143 * @param peer_cfg peer_cfg to use for IKE_SA setup, if triggered
144 * @param child_cfg child_cfg to route
145 * @param cb logging callback
146 * @param param parameter to include in each call of cb
147 * @return
148 * - SUCCESS, if CHILD_SA routed
149 * - FAILED, if routing failed
150 * - NEED_MORE, if callback returned FALSE
151 */
152 status_t (*route)(interface_manager_t *this,
153 peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
154 interface_manager_cb_t callback, void *param);
155
156 /**
157 * @brief Unroute a routed CHILD_SA (uninstall triggering policies).
158 *
159 * Only the route is removed, not the CHILD_SAs the route triggered.
160 *
161 * @param this calling object
162 * @param reqid reqid of the CHILD_SA to unroute
163 * @param cb logging callback
164 * @param param parameter to include in each call of cb
165 * @return
166 * - SUCCESS, if CHILD_SA terminated
167 * - NOT_FOUND, if no such CHILD_SA routed
168 * - NEED_MORE, if callback returned FALSE
169 */
170 status_t (*unroute)(interface_manager_t *this, u_int32_t reqid,
171 interface_manager_cb_t callback, void *param);
172
173 /**
174 * @brief Destroy a interface_manager_t instance.
175 *
176 * @param this interface_manager_t objec to destroy
177 */
178 void (*destroy) (interface_manager_t *this);
179 };
180
181
182 /**
183 * @brief Creates a interface_manager instance and loads all interface modules.
184 *
185 * @return interface_manager_t object
186 *
187 * @ingroup control
188 */
189 interface_manager_t *interface_manager_create(void);
190
191 #endif /* INTERFACE_MANAGER_H_ */
192