]> git.ipfire.org Git - thirdparty/strongswan.git/blob - Source/charon/daemon.h
- renamed get_block_size of hasher
[thirdparty/strongswan.git] / Source / charon / daemon.h
1 /**
2 * @file daemon.h
3 *
4 * @brief Interface of daemon_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, 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 DAEMON_H_
24 #define DAEMON_H_
25
26 #include <threads/sender.h>
27 #include <threads/receiver.h>
28 #include <threads/scheduler.h>
29 #include <threads/kernel_interface.h>
30 #include <threads/thread_pool.h>
31 #include <threads/stroke_interface.h>
32 #include <network/socket.h>
33 #include <sa/ike_sa_manager.h>
34 #include <queues/send_queue.h>
35 #include <queues/job_queue.h>
36 #include <queues/event_queue.h>
37 #include <utils/logger_manager.h>
38 #include <config/configuration.h>
39 #include <config/connections/connection_store.h>
40 #include <config/policies/policy_store.h>
41 #include <config/credentials/credential_store.h>
42
43 /**
44 * @defgroup charon charon
45 *
46 * @brief IKEv2 keying daemon.
47 *
48 * @section Architecture
49 *
50 * All IKEv2 stuff is handled in charon. It uses a newer and more flexible
51 * architecture than pluto. Charon uses a thread-pool, which allows parallel
52 * execution SA-management. Beside the thread-pool, there are some special purpose
53 * threads which do their job for the common health of the daemon.
54 @verbatim
55 +------+
56 | E Q |
57 | v u |---+ +------+ +------+
58 | e e | | | | | IKE- |
59 | n u | +-----------+ | |--| SA |
60 | t e | | | | I M | +------+
61 +------------+ | - | | Scheduler | | K a |
62 | receiver | +------+ | | | E n | +------+
63 +----+-------+ +-----------+ | - a | | IKE- |
64 | | +------+ | | S g |--| SA |
65 +-------+--+ +-----| J Q |---+ +------------+ | A e | +------+
66 -| socket | | o u | | | | - r |
67 +-------+--+ | b e | | Thread- | | |
68 | | - u | | Pool | | |
69 +----+-------+ | e |------| |---| |
70 | sender | +------+ +------------+ +------+
71 +----+-------+
72 | +------+
73 | | S Q |
74 | | e u |
75 | | n e |
76 +------------| d u |
77 | - e |
78 +--+---+
79 @endverbatim
80 * The thread-pool is the heart of the architecture. It processes jobs from a
81 * (fully synchronized) job-queue. Mostly, a job is associated with a specific
82 * IKE SA. These IKE SAs are synchronized, only one thread can work one an IKE SA.
83 * This makes it unnecesary to use further synchronisation methods once a IKE SA
84 * is checked out. The (rather complex) synchronization of IKE SAs is completely
85 * done in the IKE SA manager.
86 * The sceduler is responsible for event firing. It waits until a event in the
87 * (fully synchronized) event-queue is ready for processing and pushes the event
88 * down to the job-queue. A thread form the pool will pick it up as quick as
89 * possible. Every thread can queue events or jobs. Furter, an event can place a
90 * packet in the send-queue. The sender thread waits for those packets and sends
91 * them over the wire, via the socket. The receiver does exactly the opposite of
92 * the sender. It waits on the socket, reads in packets an places them on the
93 * job-queue for further processing by a thread from the pool.
94 * There are even more threads, not drawn in the upper scheme. The stroke thread
95 * is responsible for reading and processessing commands from another process. The
96 * kernel interface thread handles communication from and to the kernel via a
97 * netlink socket. It waits for kernel events and processes them appropriately.
98 */
99
100 /**
101 * @defgroup config config
102 *
103 * Classes implementing configuration related things.
104 *
105 * @ingroup charon
106 */
107
108 /**
109 * @defgroup encoding encoding
110 *
111 * Classes used to encode and decode IKEv2 messages.
112 *
113 * @ingroup charon
114 */
115
116 /**
117 * @defgroup payloads payloads
118 *
119 * Classes representing specific IKEv2 payloads.
120 *
121 * @ingroup encoding
122 */
123
124 /**
125 * @defgroup network network
126 *
127 * Classes for network relevant stuff.
128 *
129 * @ingroup charon
130 */
131
132 /**
133 * @defgroup queues queues
134 *
135 * Different kind of queues
136 * (thread save lists).
137 *
138 * @ingroup charon
139 */
140
141 /**
142 * @defgroup jobs jobs
143 *
144 * Jobs used in job queue and event queue.
145 *
146 * @ingroup queues
147 */
148
149 /**
150 * @defgroup sa sa
151 *
152 * Security associations for IKE and IPSec,
153 * and some helper classes.
154 *
155 * @ingroup charon
156 */
157
158 /**
159 * @defgroup states states
160 *
161 * Varius states in which an IKE SA can be.
162 *
163 * @ingroup sa
164 */
165
166 /**
167 * @defgroup threads threads
168 *
169 * Threaded classes, which will do their job alone.
170 *
171 * @ingroup charon
172 */
173
174 /**
175 * Name of the daemon.
176 *
177 * @ingroup charon
178 */
179 #define DAEMON_NAME "charon"
180
181 /**
182 * @brief Number of threads in the thread pool.
183 *
184 * There are several other threads, this defines
185 * only the number of threads in thread_pool_t.
186 *
187 * @ingroup charon
188 */
189 #define NUMBER_OF_WORKING_THREADS 4
190
191 /**
192 * UDP Port on which the daemon will listen for incoming traffic.
193 *
194 * @ingroup charon
195 */
196 #define IKEV2_UDP_PORT 500
197
198 /**
199 * PID file, in which charon stores its process id
200 *
201 * @ingroup charon
202 */
203 #define PID_FILE "/var/run/charon.pid"
204
205 /**
206 * Directory of IPsec relevant files
207 *
208 * @ingroup charon
209 */
210 #define IPSEC_DIR "/etc/ipsec.d"
211
212 /**
213 * Directory for private keys
214 *
215 * @ingroup charon
216 */
217 #define PRIVATE_KEY_DIR IPSEC_DIR "/private"
218
219 /**
220 * Directory for trusted certificates
221 *
222 * @ingroup charon
223 */
224 #define CERTIFICATE_DIR IPSEC_DIR "/certs"
225
226
227 typedef struct daemon_t daemon_t;
228
229 /**
230 * @brief Main class of daemon, contains some globals.
231 *
232 * @ingroup charon
233 */
234 struct daemon_t {
235 /**
236 * A socket_t instance.
237 */
238 socket_t *socket;
239
240 /**
241 * A send_queue_t instance.
242 */
243 send_queue_t *send_queue;
244
245 /**
246 * A job_queue_t instance.
247 */
248 job_queue_t *job_queue;
249
250 /**
251 * A event_queue_t instance.
252 */
253 event_queue_t *event_queue;
254
255 /**
256 * A ike_sa_manager_t instance.
257 */
258 ike_sa_manager_t *ike_sa_manager;
259
260 /**
261 * A configuration_t instance.
262 */
263 configuration_t *configuration;
264
265 /**
266 * A connection_store_t instance.
267 */
268 connection_store_t *connections;
269
270 /**
271 * A policy_store_t instance.
272 */
273 policy_store_t *policies;
274
275 /**
276 * A credential_store_t instance.
277 */
278 credential_store_t *credentials;
279
280 /**
281 * The Sender-Thread.
282 */
283 sender_t *sender;
284
285 /**
286 * The Receiver-Thread.
287 */
288 receiver_t *receiver;
289
290 /**
291 * The Scheduler-Thread.
292 */
293 scheduler_t *scheduler;
294
295 /**
296 * The Thread pool managing the worker threads.
297 */
298 thread_pool_t *thread_pool;
299
300 /**
301 * Kernel Interface to communicate with kernel
302 */
303 kernel_interface_t *kernel_interface;
304
305 /**
306 * IPC interface, as whack in pluto
307 */
308 stroke_t *stroke;
309
310 /**
311 * @brief Shut down the daemon.
312 *
313 * @param this the daemon to kill
314 * @param reason describtion why it will be killed
315 */
316 void (*kill) (daemon_t *this, char *reason);
317 };
318
319 /**
320 * The one and only instance of the daemon.
321 */
322 extern daemon_t *charon;
323
324 #endif /*DAEMON_H_*/