]>
git.ipfire.org Git - people/ms/strongswan.git/blob - src/charon/daemon.h
4 * @brief Interface of daemon_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
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>
44 * @defgroup charon charon
46 * @brief IKEv2 keying daemon.
48 * @section Architecture
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.
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 | +------+ +------------+ +------+
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.
101 * @defgroup config config
103 * Classes implementing configuration related things.
109 * @defgroup encoding encoding
111 * Classes used to encode and decode IKEv2 messages.
117 * @defgroup payloads payloads
119 * Classes representing specific IKEv2 payloads.
125 * @defgroup network network
127 * Classes for network relevant stuff.
133 * @defgroup queues queues
135 * Different kind of queues
136 * (thread save lists).
142 * @defgroup jobs jobs
144 * Jobs used in job queue and event queue.
152 * Security associations for IKE and IPSec,
153 * and some helper classes.
159 * @defgroup states states
161 * Varius states in which an IKE SA can be.
167 * @defgroup threads threads
169 * Threaded classes, which will do their job alone.
175 * Name of the daemon.
179 #define DAEMON_NAME "charon"
182 * @brief Number of threads in the thread pool.
184 * There are several other threads, this defines
185 * only the number of threads in thread_pool_t.
189 #define NUMBER_OF_WORKING_THREADS 4
192 * UDP Port on which the daemon will listen for incoming traffic.
196 #define IKEV2_UDP_PORT 500
199 * PID file, in which charon stores its process id
203 #define PID_FILE "/var/run/charon.pid"
206 * Configuration directory
210 #define CONFIG_DIR "/etc"
213 * Directory of IPsec relevant files
217 #define IPSEC_DIR CONFIG_DIR "/ipsec.d"
220 * Directory for private keys
224 #define PRIVATE_KEY_DIR IPSEC_DIR "/private"
227 * Directory for trusted certificates
231 #define CERTIFICATE_DIR IPSEC_DIR "/certs"
238 #define SECRETS_FILE CONFIG_DIR "/ipsec.secrets"
240 typedef struct daemon_t daemon_t
;
243 * @brief Main class of daemon, contains some globals.
249 * A socket_t instance.
254 * A send_queue_t instance.
256 send_queue_t
*send_queue
;
259 * A job_queue_t instance.
261 job_queue_t
*job_queue
;
264 * A event_queue_t instance.
266 event_queue_t
*event_queue
;
269 * A ike_sa_manager_t instance.
271 ike_sa_manager_t
*ike_sa_manager
;
274 * A configuration_t instance.
276 configuration_t
*configuration
;
279 * A connection_store_t instance.
281 connection_store_t
*connections
;
284 * A policy_store_t instance.
286 policy_store_t
*policies
;
289 * A credential_store_t instance.
291 credential_store_t
*credentials
;
299 * The Receiver-Thread.
301 receiver_t
*receiver
;
304 * The Scheduler-Thread.
306 scheduler_t
*scheduler
;
309 * The Thread pool managing the worker threads.
311 thread_pool_t
*thread_pool
;
314 * Kernel Interface to communicate with kernel
316 kernel_interface_t
*kernel_interface
;
319 * IPC interface, as whack in pluto
324 * @brief Shut down the daemon.
326 * @param this the daemon to kill
327 * @param reason describtion why it will be killed
329 void (*kill
) (daemon_t
*this, char *reason
);
333 * The one and only instance of the daemon.
335 extern daemon_t
*charon
;