3c1613a9108e53327cf2442e87d13d8e52724da4
[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 * @param this calling object
88 * @param peer_cfg peer_cfg to use for IKE_SA setup
89 * @param child_cfg child_cfg to set up CHILD_SA from
90 * @param cb logging callback
91 * @param param parameter to include in each call of cb
92 * @return
93 * - SUCCESS, if CHILD_SA established
94 * - FAILED, if setup failed
95 * - NEED_MORE, if callback returned FALSE
96 */
97 status_t (*initiate)(interface_manager_t *this,
98 peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
99 interface_manager_cb_t callback, void *param);
100
101 /**
102 * @brief Terminate an IKE_SA and all of its CHILD_SAs.
103 *
104 * @param this calling object
105 * @param unique_id unique id of the IKE_SA to terminate.
106 * @param cb logging callback
107 * @param param parameter to include in each call of cb
108 * @return
109 * - SUCCESS, if CHILD_SA terminated
110 * - NOT_FOUND, if no such CHILD_SA found
111 * - NEED_MORE, if callback returned FALSE
112 */
113 status_t (*terminate_ike)(interface_manager_t *this, u_int32_t unique_id,
114 interface_manager_cb_t callback, void *param);
115
116 /**
117 * @brief Terminate a CHILD_SA.
118 *
119 * @param this calling object
120 * @param reqid reqid of the CHILD_SA to terminate
121 * @param cb logging callback
122 * @param param parameter to include in each call of cb
123 * @return
124 * - SUCCESS, if CHILD_SA terminated
125 * - NOT_FOUND, if no such CHILD_SA found
126 * - NEED_MORE, if callback returned FALSE
127 */
128 status_t (*terminate_child)(interface_manager_t *this, u_int32_t reqid,
129 interface_manager_cb_t callback, void *param);
130
131 /**
132 * @brief Route a CHILD_SA (install triggering policies).
133 *
134 * @param this calling object
135 * @param peer_cfg peer_cfg to use for IKE_SA setup, if triggered
136 * @param child_cfg child_cfg to route
137 * @param cb logging callback
138 * @param param parameter to include in each call of cb
139 * @return
140 * - SUCCESS, if CHILD_SA routed
141 * - FAILED, if routing failed
142 * - NEED_MORE, if callback returned FALSE
143 */
144 status_t (*route)(interface_manager_t *this,
145 peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
146 interface_manager_cb_t callback, void *param);
147
148 /**
149 * @brief Unroute a routed CHILD_SA (uninstall triggering policies).
150 *
151 * Only the route is removed, not the CHILD_SAs the route triggered.
152 *
153 * @param this calling object
154 * @param reqid reqid of the CHILD_SA to unroute
155 * @param cb logging callback
156 * @param param parameter to include in each call of cb
157 * @return
158 * - SUCCESS, if CHILD_SA terminated
159 * - NOT_FOUND, if no such CHILD_SA routed
160 * - NEED_MORE, if callback returned FALSE
161 */
162 status_t (*unroute)(interface_manager_t *this, u_int32_t reqid,
163 interface_manager_cb_t callback, void *param);
164
165 /**
166 * @brief Destroy a interface_manager_t instance.
167 *
168 * @param this interface_manager_t objec to destroy
169 */
170 void (*destroy) (interface_manager_t *this);
171 };
172
173
174 /**
175 * @brief Creates a interface_manager instance and loads all interface modules.
176 *
177 * @return interface_manager_t object
178 *
179 * @ingroup control
180 */
181 interface_manager_t *interface_manager_create(void);
182
183 #endif /* INTERFACE_MANAGER_H_ */
184