2 * Copyright (C) 2006-2012 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 ikev1 ikev1
61 * @defgroup ikev2 ikev2
64 * @defgroup authenticators_v1 authenticators
67 * @defgroup authenticators_v2 authenticators
73 * @defgroup xauth xauth
76 * @defgroup tasks_v1 tasks
79 * @defgroup tasks_v2 tasks
82 * @addtogroup libcharon
85 * IKEv2 keying daemon.
87 * All IKEv2 stuff is handled in charon. It uses a newer and more flexible
88 * architecture than pluto. Charon uses a thread-pool (called processor),
89 * which allows parallel execution SA-management. All threads originate
90 * from the processor. Work is delegated to the processor by queueing jobs
94 +---------------------------------+ +----------------------------+
95 | controller | | config |
96 +---------------------------------+ +----------------------------+
100 +----------+ +-----------+ +------+ +----------+ +----+
101 | receiver | | | | | +------+ | CHILD_SA | | K |
102 +---+------+ | Scheduler | | IKE- | | IKE- |--+----------+ | e |
103 | | | | SA |--| SA | | CHILD_SA | | r |
104 +------+---+ +-----------+ | | +------+ +----------+ | n |
105 <->| socket | | | Man- | | e |
106 +------+---+ +-----------+ | ager | +------+ +----------+ | l |
107 | | | | | | IKE- |--| CHILD_SA | | - |
108 +---+------+ | Processor |---| |--| SA | +----------+ | I |
109 | sender | | | | | +------+ | f |
110 +----------+ +-----------+ +------+ +----+
114 +---------------------------------+ +----------------------------+
115 | Bus | | credentials |
116 +---------------------------------+ +----------------------------+
119 * The scheduler is responsible to execute timed events. Jobs may be queued to
120 * the scheduler to get executed at a defined time (e.g. rekeying). The
121 * scheduler does not execute the jobs itself, it queues them to the processor.
123 * The IKE_SA manager managers all IKE_SA. It further handles the
125 * Each IKE_SA must be checked out strictly and checked in again after use. The
126 * manager guarantees that only one thread may check out a single IKE_SA. This
127 * allows us to write the (complex) IKE_SAs routines non-threadsave.
128 * The IKE_SA contain the state and the logic of each IKE_SA and handle the
131 * The CHILD_SA contains state about a IPsec security association and manages
132 * them. An IKE_SA may have multiple CHILD_SAs. Communication to the kernel
133 * takes place here through the kernel interface.
135 * The kernel interface installs IPsec security associations, policies, routes
136 * and virtual addresses. It further provides methods to enumerate interfaces
137 * and may notify the daemon about state changes at lower layers.
139 * The bus receives signals from the different threads and relays them to
140 * interested listeners. Debugging signals, but also important state changes or
141 * error messages are sent over the bus.
142 * Its listeners are not only for logging, but also to track the state of an
145 * The controller, credential_manager, bus and backend_manager (config) are
146 * places where a plugin ca register itself to privide information or observe
147 * and control the daemon.
153 typedef struct daemon_t daemon_t
;
155 #include <network/sender.h>
156 #include <network/receiver.h>
157 #include <network/socket_manager.h>
158 #include <control/controller.h>
160 #include <bus/listeners/file_logger.h>
161 #include <bus/listeners/sys_logger.h>
162 #include <sa/ike_sa_manager.h>
163 #include <sa/trap_manager.h>
164 #include <sa/shunt_manager.h>
165 #include <config/backend_manager.h>
166 #include <sa/eap/eap_manager.h>
167 #include <sa/xauth/xauth_manager.h>
168 #include <utils/capabilities.h>
171 #include <sa/ikev2/connect_manager.h>
172 #include <sa/ikev2/mediation_manager.h>
176 * Number of threads in the thread pool, if not specified in config.
178 #define DEFAULT_THREADS 16
181 * UDP Port on which the daemon will listen for incoming traffic.
183 #define IKEV2_UDP_PORT 500
186 * UDP Port to which the daemon will float to if NAT is detected.
188 #define IKEV2_NATT_PORT 4500
191 * Main class of daemon, contains some globals.
196 * Socket manager instance
198 socket_manager_t
*socket
;
201 * A ike_sa_manager_t instance.
203 ike_sa_manager_t
*ike_sa_manager
;
206 * Manager for triggering policies, called traps
208 trap_manager_t
*traps
;
211 * Manager for shunt PASS|DROP policies
213 shunt_manager_t
*shunts
;
216 * Manager for the different configuration backends.
218 backend_manager_t
*backends
;
226 * The Receiver-Thread.
228 receiver_t
*receiver
;
236 * A list of installed file_logger_t's
238 linked_list_t
*file_loggers
;
241 * A list of installed sys_logger_t's
243 linked_list_t
*sys_loggers
;
246 * Controller to control the daemon
248 controller_t
*controller
;
251 * EAP manager to maintain registered EAP methods
256 * XAuth manager to maintain registered XAuth methods
258 xauth_manager_t
*xauth
;
264 connect_manager_t
*connect_manager
;
269 mediation_manager_t
*mediation_manager
;
273 * POSIX capability dropping
275 capabilities_t
*caps
;
278 * Name of the binary that uses the library (used for settings etc.)
283 * Initialize the daemon.
285 * @param plugins list of plugins to load
286 * @return TRUE, if successful
288 bool (*initialize
)(daemon_t
*this, char *plugins
);
291 * Starts the daemon, i.e. spawns the threads of the thread pool.
293 void (*start
)(daemon_t
*this);
298 * The one and only instance of the daemon.
300 * Set between libcharon_init() and libcharon_deinit() calls.
302 extern daemon_t
*charon
;
305 * Initialize libcharon and create the "charon" instance of daemon_t.
307 * This function initializes the bus, listeners can be registered before
308 * calling initialize().
310 * @param name name of the binary that uses the library
311 * @return FALSE if integrity check failed
313 bool libcharon_init(const char *name
);
316 * Deinitialize libcharon and destroy the "charon" instance of daemon_t.
318 void libcharon_deinit();
320 #endif /** DAEMON_H_ @}*/