2 * Copyright (C) 2006-2010 Tobias Brunner
3 * Copyright (C) 2005-2009 Martin Willi
4 * Copyright (C) 2006 Daniel Roethlisberger
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
20 * @defgroup libcharon libcharon
25 * @defgroup listeners listeners
28 * @defgroup config config
31 * @defgroup control control
34 * @defgroup encoding encoding
37 * @defgroup payloads payloads
40 * @defgroup ckernel kernel
43 * @defgroup network network
46 * @defgroup cplugins plugins
49 * @defgroup cprocessing processing
52 * @defgroup cjobs jobs
53 * @ingroup cprocessing
58 * @defgroup authenticators authenticators
62 * @ingroup authenticators
64 * @defgroup tasks tasks
70 * @addtogroup libcharon
73 * IKEv2 keying daemon.
75 * All IKEv2 stuff is handled in charon. It uses a newer and more flexible
76 * architecture than pluto. Charon uses a thread-pool (called processor),
77 * which allows parallel execution SA-management. All threads originate
78 * from the processor. Work is delegated to the processor by queueing jobs
82 +---------------------------------+ +----------------------------+
83 | controller | | config |
84 +---------------------------------+ +----------------------------+
88 +----------+ +-----------+ +------+ +----------+ +----+
89 | receiver | | | | | +------+ | CHILD_SA | | K |
90 +---+------+ | Scheduler | | IKE- | | IKE- |--+----------+ | e |
91 | | | | SA |--| SA | | CHILD_SA | | r |
92 +------+---+ +-----------+ | | +------+ +----------+ | n |
93 <->| socket | | | Man- | | e |
94 +------+---+ +-----------+ | ager | +------+ +----------+ | l |
95 | | | | | | IKE- |--| CHILD_SA | | - |
96 +---+------+ | Processor |---| |--| SA | +----------+ | I |
97 | sender | | | | | +------+ | f |
98 +----------+ +-----------+ +------+ +----+
102 +---------------------------------+ +----------------------------+
103 | Bus | | credentials |
104 +---------------------------------+ +----------------------------+
107 * The scheduler is responsible to execute timed events. Jobs may be queued to
108 * the scheduler to get executed at a defined time (e.g. rekeying). The
109 * scheduler does not execute the jobs itself, it queues them to the processor.
111 * The IKE_SA manager managers all IKE_SA. It further handles the
113 * Each IKE_SA must be checked out strictly and checked in again after use. The
114 * manager guarantees that only one thread may check out a single IKE_SA. This
115 * allows us to write the (complex) IKE_SAs routines non-threadsave.
116 * The IKE_SA contain the state and the logic of each IKE_SA and handle the
119 * The CHILD_SA contains state about a IPsec security association and manages
120 * them. An IKE_SA may have multiple CHILD_SAs. Communication to the kernel
121 * takes place here through the kernel interface.
123 * The kernel interface installs IPsec security associations, policies, routes
124 * and virtual addresses. It further provides methods to enumerate interfaces
125 * and may notify the daemon about state changes at lower layers.
127 * The bus receives signals from the different threads and relays them to
128 * interested listeners. Debugging signals, but also important state changes or
129 * error messages are sent over the bus.
130 * Its listeners are not only for logging, but also to track the state of an
133 * The controller, credential_manager, bus and backend_manager (config) are
134 * places where a plugin ca register itself to privide information or observe
135 * and control the daemon.
141 typedef struct daemon_t daemon_t
;
143 #include <network/sender.h>
144 #include <network/receiver.h>
145 #include <network/socket_manager.h>
146 #include <control/controller.h>
148 #include <bus/listeners/file_logger.h>
149 #include <bus/listeners/sys_logger.h>
150 #include <sa/ike_sa_manager.h>
151 #include <sa/trap_manager.h>
152 #include <sa/shunt_manager.h>
153 #include <config/backend_manager.h>
154 #include <sa/authenticators/eap/eap_manager.h>
155 #include <tnc/imc/imc_manager.h>
156 #include <tnc/imv/imv_manager.h>
157 #include <tnc/tnccs/tnccs_manager.h>
160 #include <sa/connect_manager.h>
161 #include <sa/mediation_manager.h>
165 * Number of threads in the thread pool, if not specified in config.
167 #define DEFAULT_THREADS 16
170 * UDP Port on which the daemon will listen for incoming traffic.
172 #define IKEV2_UDP_PORT 500
175 * UDP Port to which the daemon will float to if NAT is detected.
177 #define IKEV2_NATT_PORT 4500
180 * Main class of daemon, contains some globals.
185 * Socket manager instance
187 socket_manager_t
*socket
;
190 * A ike_sa_manager_t instance.
192 ike_sa_manager_t
*ike_sa_manager
;
195 * Manager for triggering policies, called traps
197 trap_manager_t
*traps
;
200 * Manager for shunt PASS|DROP policies
202 shunt_manager_t
*shunts
;
205 * Manager for the different configuration backends.
207 backend_manager_t
*backends
;
215 * The Receiver-Thread.
217 receiver_t
*receiver
;
225 * A list of installed file_logger_t's
227 linked_list_t
*file_loggers
;
230 * A list of installed sys_logger_t's
232 linked_list_t
*sys_loggers
;
235 * Controller to control the daemon
237 controller_t
*controller
;
240 * EAP manager to maintain registered EAP methods
245 * TNC IMC manager controlling Integrity Measurement Collectors
250 * TNC IMV manager controlling Integrity Measurement Verifiers
255 * TNCCS manager to maintain registered TNCCS protocols
257 tnccs_manager_t
*tnccs
;
263 connect_manager_t
*connect_manager
;
268 mediation_manager_t
*mediation_manager
;
272 * User ID the daemon will user after initialization
277 * Group ID the daemon will use after initialization
282 * Do not drop a given capability after initialization.
284 * Some plugins might need additional capabilites. They tell the daemon
285 * during plugin initialization which one they need, the daemon won't
288 void (*keep_cap
)(daemon_t
*this, u_int cap
);
291 * Drop all capabilities of the current process.
293 * Drops all capabalities, excect those exlcuded using keep_cap().
294 * This should be called after the initialization of the daemon because
295 * some plugins require the process to keep additional capabilities.
297 * @return TRUE if successful, FALSE otherwise
299 bool (*drop_capabilities
)(daemon_t
*this);
302 * Initialize the daemon.
304 bool (*initialize
)(daemon_t
*this);
307 * Starts the daemon, i.e. spawns the threads of the thread pool.
309 void (*start
)(daemon_t
*this);
314 * The one and only instance of the daemon.
316 * Set between libcharon_init() and libcharon_deinit() calls.
318 extern daemon_t
*charon
;
321 * Initialize libcharon and create the "charon" instance of daemon_t.
323 * This function initializes the bus, listeners can be registered before
324 * calling initialize().
326 * @return FALSE if integrity check failed
328 bool libcharon_init();
331 * Deinitialize libcharon and destroy the "charon" instance of daemon_t.
333 void libcharon_deinit();
335 #endif /** DAEMON_H_ @}*/