2 * Copyright (C) 2006-2007 Tobias Brunner
3 * Copyright (C) 2006 Daniel Roethlisberger
4 * Copyright (C) 2005-2008 Martin Willi
5 * Copyright (C) 2005 Jan Hutter
6 * Hochschule fuer Technik Rapperswil
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * @defgroup charon charon
27 * @defgroup listeners listeners
30 * @defgroup config config
33 * @defgroup control control
36 * @defgroup ccredentials credentials
40 * @ingroup ccredentials
42 * @defgroup encoding encoding
45 * @defgroup payloads payloads
48 * @defgroup kernel kernel
51 * @defgroup network network
54 * @defgroup cplugins plugins
57 * @defgroup processing processing
66 * @defgroup authenticators authenticators
70 * @ingroup authenticators
72 * @defgroup tasks tasks
78 * IKEv2 keying daemon.
80 * All IKEv2 stuff is handled in charon. It uses a newer and more flexible
81 * architecture than pluto. Charon uses a thread-pool (called processor),
82 * which allows parallel execution SA-management. All threads originate
83 * from the processor. Work is delegated to the processor by queueing jobs
87 +---------------------------------+ +----------------------------+
88 | controller | | config |
89 +---------------------------------+ +----------------------------+
93 +----------+ +-----------+ +------+ +----------+ +----+
94 | receiver | | | | | +------+ | CHILD_SA | | K |
95 +---+------+ | Scheduler | | IKE- | | IKE- |--+----------+ | e |
96 | | | | SA |--| SA | | CHILD_SA | | r |
97 +------+---+ +-----------+ | | +------+ +----------+ | n |
98 <->| socket | | | Man- | | e |
99 +------+---+ +-----------+ | ager | +------+ +----------+ | l |
100 | | | | | | IKE- |--| CHILD_SA | | - |
101 +---+------+ | Processor |---| |--| SA | +----------+ | I |
102 | sender | | | | | +------+ | f |
103 +----------+ +-----------+ +------+ +----+
107 +---------------------------------+ +----------------------------+
108 | Bus | | credentials |
109 +---------------------------------+ +----------------------------+
112 * The scheduler is responsible to execute timed events. Jobs may be queued to
113 * the scheduler to get executed at a defined time (e.g. rekeying). The
114 * scheduler does not execute the jobs itself, it queues them to the processor.
116 * The IKE_SA manager managers all IKE_SA. It further handles the
118 * Each IKE_SA must be checked out strictly and checked in again after use. The
119 * manager guarantees that only one thread may check out a single IKE_SA. This
120 * allows us to write the (complex) IKE_SAs routines non-threadsave.
121 * The IKE_SA contain the state and the logic of each IKE_SA and handle the
124 * The CHILD_SA contains state about a IPsec security association and manages
125 * them. An IKE_SA may have multiple CHILD_SAs. Communication to the kernel
126 * takes place here through the kernel interface.
128 * The kernel interface installs IPsec security associations, policies, routes
129 * and virtual addresses. It further provides methods to enumerate interfaces
130 * and may notify the daemon about state changes at lower layers.
132 * The bus receives signals from the different threads and relais them to interested
133 * listeners. Debugging signals, but also important state changes or error
134 * messages are sent over the bus.
135 * It's listeners are not only for logging, but also to track the state of an
138 * The controller, credential_manager, bus and backend_manager (config) are
139 * places where a plugin ca register itself to privide information or observe
140 * and control the daemon.
146 typedef struct daemon_t daemon_t
;
148 #include <network/sender.h>
149 #include <network/receiver.h>
150 #include <network/socket.h>
151 #include <processing/scheduler.h>
152 #include <processing/processor.h>
153 #include <kernel/kernel_interface.h>
154 #include <control/controller.h>
156 #include <bus/listeners/file_logger.h>
157 #include <bus/listeners/sys_logger.h>
158 #include <sa/ike_sa_manager.h>
159 #include <config/backend_manager.h>
160 #include <credentials/credential_manager.h>
161 #include <sa/authenticators/eap/eap_manager.h>
162 #include <plugins/plugin_loader.h>
165 #include <sa/connect_manager.h>
166 #include <sa/mediation_manager.h>
170 * Name of the daemon.
172 #define DAEMON_NAME "charon"
175 * Number of threads in the thread pool.
177 #define WORKER_THREADS 16
180 * UDP Port on which the daemon will listen for incoming traffic.
182 #define IKEV2_UDP_PORT 500
185 * UDP Port to which the daemon will float to if NAT is detected.
187 #define IKEV2_NATT_PORT 4500
190 * PID file, in which charon stores its process id
192 #define PID_FILE IPSEC_PIDDIR "/charon.pid"
196 * Main class of daemon, contains some globals.
201 * A socket_t instance.
206 * A ike_sa_manager_t instance.
208 ike_sa_manager_t
*ike_sa_manager
;
211 * Manager for the different configuration backends.
213 backend_manager_t
*backends
;
216 * Manager for the credential backends
218 credential_manager_t
*credentials
;
226 * The Receiver-Thread.
228 receiver_t
*receiver
;
231 * The Scheduler-Thread.
233 scheduler_t
*scheduler
;
236 * Job processing using a thread pool.
238 processor_t
*processor
;
248 plugin_loader_t
*plugins
;
251 * A bus listener logging to stdout
253 file_logger_t
*outlog
;
256 * A bus listener logging to syslog
258 sys_logger_t
*syslog
;
261 * A bus listener logging most important events
263 sys_logger_t
*authlog
;
266 * Kernel Interface to communicate with kernel
268 kernel_interface_t
*kernel_interface
;
271 * Controller to control the daemon
273 controller_t
*controller
;
276 * EAP manager to maintain registered EAP methods
284 connect_manager_t
*connect_manager
;
289 mediation_manager_t
*mediation_manager
;
293 * Shut down the daemon.
295 * @param reason describtion why it will be killed
297 void (*kill
) (daemon_t
*this, char *reason
);
301 * The one and only instance of the daemon.
303 extern daemon_t
*charon
;
305 #endif /*DAEMON_H_ @} */