- code cleaned up
[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/prime_pool.h>
30 #include <threads/thread_pool.h>
31 #include <network/socket.h>
32 #include <sa/ike_sa_manager.h>
33 #include <queues/send_queue.h>
34 #include <queues/job_queue.h>
35 #include <queues/event_queue.h>
36 #include <utils/logger_manager.h>
37 #include <config/configuration_manager.h>
38
39 /**
40 * Name of the daemon.
41 */
42 #define DAEMON_NAME "charon"
43
44 /**
45 * @brief Number of threads in the thread pool.
46 *
47 * There are several other threads, this defines
48 * only the number of threads in thread_pool_t.
49 */
50 #define NUMBER_OF_WORKING_THREADS 4
51
52 /**
53 * UDP Port on which the daemon will listen for incoming traffic.
54 */
55 #define IKEV2_UDP_PORT 500
56
57 /**
58 * @brief First retransmit timeout in milliseconds.
59 *
60 * Timeout value is increasing in each retransmit round.
61 */
62 #define RETRANSMIT_TIMEOUT 3000
63
64 /**
65 * Timeout in milliseconds after that a half open IKE_SA gets deleted.
66 */
67 #define HALF_OPEN_IKE_SA_TIMEOUT 30000
68
69 /**
70 * @brief Max retransmit count.
71 *
72 * 0 for infinite. The max time a half open IKE_SA is alive is set by
73 * RETRANSMIT_TIMEOUT.
74 */
75 #define MAX_RETRANSMIT_COUNT 0
76
77
78 /**
79 * Max number of primes to precompute per prime type.
80 */
81 #define PRIME_PRE_COMPUTATION_LIMIT 5
82
83 /**
84 * @brief Default loglevel for every logger context.
85 *
86 * This is the maximum allowed level for ever context, the definiton
87 * of the context may be less verbose.
88 */
89 #define DEFAULT_LOGLEVEL CONTROL | ERROR
90
91
92 typedef struct daemon_t daemon_t;
93
94 /**
95 * @brief Main class of daemon, contains some globals.
96 */
97 struct daemon_t {
98 /**
99 * A socket_t instance.
100 */
101 socket_t *socket;
102
103 /**
104 * A send_queue_t instance.
105 */
106
107 send_queue_t *send_queue;
108
109 /**
110 * A job_queue_t instance.
111 */
112 job_queue_t *job_queue;
113
114 /**
115 * A event_queue_t instance.
116 */
117 event_queue_t *event_queue;
118
119 /**
120 * A logger_manager_t instance.
121 */
122 logger_manager_t *logger_manager;
123
124 /**
125 * A ike_sa_manager_t instance.
126 */
127 ike_sa_manager_t *ike_sa_manager;
128
129 /**
130 * A configuration_manager_t instance.
131 */
132 configuration_manager_t *configuration_manager;
133
134 /**
135 * The Sender-Thread.
136 */
137 sender_t *sender;
138
139 /**
140 * The Receiver-Thread.
141 */
142 receiver_t *receiver;
143
144 /**
145 * The Scheduler-Thread.
146 */
147 scheduler_t *scheduler;
148
149 /**
150 * The Thread pool managing the worker threads.
151 */
152 thread_pool_t *thread_pool;
153
154 /**
155 * Low-priority thread which generates primes.
156 */
157 prime_pool_t *prime_pool;
158
159 /**
160 * @brief Shut down the daemon.
161 *
162 * @param this the daemon to kill
163 * @param reason describition why it will be killed
164 */
165 void (*kill) (daemon_t *this, char *reason);
166 };
167
168 /**
169 * One and only instance of the daemon.
170 */
171 extern daemon_t *charon;
172
173 #endif /*DAEMON_H_*/