changed cipher option default value to aes-ctr
[anytun.git] / openvpn / syshead.h
bloba2f1a8620bad9b95de0a4963d247ef4af6df3076
1 /*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
8 * Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program (see the file COPYING included with this
21 * distribution); if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef SYSHEAD_H
26 #define SYSHEAD_H
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
30 #endif
32 #ifdef HAVE_SYS_WAIT_H
33 # include <sys/wait.h>
34 #endif
36 #ifndef WIN32
37 #ifndef WEXITSTATUS
38 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
39 #endif
40 #ifndef WIFEXITED
41 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
42 #endif
43 #endif
45 #ifdef TIME_WITH_SYS_TIME
46 # include <sys/time.h>
47 # include <time.h>
48 #else
49 # ifdef HAVE_SYS_TIME_H
50 # include <sys/time.h>
51 # else
52 # include <time.h>
53 # endif
54 #endif
56 #ifdef HAVE_SYS_SOCKET_H
57 #include <sys/socket.h>
58 #endif
60 #ifdef HAVE_SYS_IOCTL_H
61 #include <sys/ioctl.h>
62 #endif
64 #ifdef HAVE_SYS_STAT_H
65 #include <sys/stat.h>
66 #endif
68 #ifdef HAVE_FCNTL_H
69 #include <fcntl.h>
70 #endif
72 #ifdef HAVE_SYS_FILE_H
73 #include <sys/file.h>
74 #endif
76 #ifdef HAVE_STDLIB_H
77 #include <stdlib.h>
78 #endif
80 #ifdef HAVE_STDINT_H
81 #include <stdint.h>
82 #endif
84 #ifdef HAVE_STDARG_H
85 #include <stdarg.h>
86 #endif
88 #ifdef HAVE_UNISTD_H
89 #include <unistd.h>
90 #endif
92 #ifdef HAVE_SIGNAL_H
93 #include <signal.h>
94 #endif
96 #ifdef HAVE_STDIO_H
97 #include <stdio.h>
98 #endif
100 #ifdef HAVE_CTYPE_H
101 #include <ctype.h>
102 #endif
104 #ifdef HAVE_ERRNO_H
105 #include <errno.h>
106 #endif
108 #ifdef HAVE_SYSLOG_H
109 #include <syslog.h>
110 #endif
112 #ifdef HAVE_PWD_H
113 #include <pwd.h>
114 #endif
116 #ifdef HAVE_GRP_H
117 #include <grp.h>
118 #endif
120 #ifdef USE_LIBDL
121 #include <dlfcn.h>
122 #endif
124 #ifdef HAVE_NETDB_H
125 #include <netdb.h>
126 #endif
128 #ifdef HAVE_NETINET_IN_H
129 #include <netinet/in.h>
130 #endif
132 #ifdef HAVE_SYS_POLL_H
133 #include <sys/poll.h>
134 #endif
136 #ifdef HAVE_SYS_EPOLL_H
137 #include <sys/epoll.h>
138 #endif
140 #ifdef TARGET_SOLARIS
141 #ifdef HAVE_STRINGS_H
142 #include <strings.h>
143 #endif
144 #else
145 #ifdef HAVE_STRING_H
146 #include <string.h>
147 #endif
148 #endif
150 #ifdef HAVE_ARPA_INET_H
151 #include <arpa/inet.h>
152 #endif
154 #ifdef HAVE_NET_IF_H
155 #include <net/if.h>
156 #endif
158 #ifdef TARGET_LINUX
160 #if defined(HAVE_NETINET_IF_ETHER_H)
161 #include <netinet/if_ether.h>
162 #endif
164 #ifdef HAVE_LINUX_IF_TUN_H
165 #include <linux/if_tun.h>
166 #endif
168 #ifdef HAVE_NETINET_IP_H
169 #include <netinet/ip.h>
170 #endif
172 #ifdef HAVE_LINUX_SOCKIOS_H
173 #include <linux/sockios.h>
174 #endif
176 #ifdef HAVE_LINUX_TYPES_H
177 #include <linux/types.h>
178 #endif
180 #ifdef HAVE_LINUX_ERRQUEUE_H
181 #include <linux/errqueue.h>
182 #endif
184 #endif /* TARGET_LINUX */
186 #ifdef TARGET_SOLARIS
188 #ifdef HAVE_STROPTS_H
189 #include <stropts.h>
190 #undef S_ERROR
191 #endif
193 #ifdef HAVE_NET_IF_TUN_H
194 #include <net/if_tun.h>
195 #endif
197 #ifdef HAVE_SYS_SOCKIO_H
198 #include <sys/sockio.h>
199 #endif
201 #ifdef HAVE_NETINET_IN_SYSTM_H
202 #include <netinet/in_systm.h>
203 #endif
205 #ifdef HAVE_NETINET_IP_H
206 #include <netinet/ip.h>
207 #endif
209 #ifdef HAVE_NETINET_TCP_H
210 #include <netinet/tcp.h>
211 #endif
213 #endif /* TARGET_SOLARIS */
215 #ifdef TARGET_OPENBSD
217 #ifdef HAVE_SYS_UIO_H
218 #include <sys/uio.h>
219 #endif
221 #ifdef HAVE_NETINET_IN_SYSTM_H
222 #include <netinet/in_systm.h>
223 #endif
225 #ifdef HAVE_NETINET_IP_H
226 #include <netinet/ip.h>
227 #endif
229 #ifdef HAVE_NET_IF_TUN_H
230 #include <net/if_tun.h>
231 #endif
233 #endif /* TARGET_OPENBSD */
235 #ifdef TARGET_FREEBSD
237 #ifdef HAVE_SYS_UIO_H
238 #include <sys/uio.h>
239 #endif
241 #ifdef HAVE_NETINET_IN_SYSTM_H
242 #include <netinet/in_systm.h>
243 #endif
245 #ifdef HAVE_NETINET_IP_H
246 #include <netinet/ip.h>
247 #endif
249 #ifdef HAVE_NET_IF_TUN_H
250 #include <net/if_tun.h>
251 #endif
253 #endif /* TARGET_FREEBSD */
255 #ifdef TARGET_NETBSD
257 #ifdef HAVE_NET_IF_TUN_H
258 #include <net/if_tun.h>
259 #endif
261 #endif /* TARGET_NETBSD */
263 #ifdef WIN32
264 #include <iphlpapi.h>
265 #endif
267 #ifdef HAVE_SYS_MMAN_H
268 #ifdef TARGET_DARWIN
269 #define _P1003_1B_VISIBLE
270 #endif /* TARGET_DARWIN */
271 #include <sys/mman.h>
272 #endif
275 * Pedantic mode is meant to accomplish lint-style program checking,
276 * not to build a working executable.
278 #ifdef __STRICT_ANSI__
279 # define PEDANTIC 1
280 # undef HAVE_CPP_VARARG_MACRO_GCC
281 # undef HAVE_CPP_VARARG_MACRO_ISO
282 # undef EMPTY_ARRAY_SIZE
283 # define EMPTY_ARRAY_SIZE 1
284 # undef inline
285 # define inline
286 #else
287 # define PEDANTIC 0
288 #endif
291 * Do we have the capability to support the --passtos option?
293 #if defined(IPPROTO_IP) && defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
294 #define PASSTOS_CAPABILITY 1
295 #else
296 #define PASSTOS_CAPABILITY 0
297 #endif
300 * Do we have the capability to report extended socket errors?
302 #if defined(HAVE_LINUX_TYPES_H) && defined(HAVE_LINUX_ERRQUEUE_H) && defined(HAVE_SOCK_EXTENDED_ERR) && defined(HAVE_MSGHDR) && defined(HAVE_CMSGHDR) && defined(CMSG_FIRSTHDR) && defined(CMSG_NXTHDR) && defined(IP_RECVERR) && defined(MSG_ERRQUEUE) && defined(SOL_IP) && defined(HAVE_IOVEC)
303 #define EXTENDED_SOCKET_ERROR_CAPABILITY 1
304 #else
305 #define EXTENDED_SOCKET_ERROR_CAPABILITY 0
306 #endif
309 * Disable ESEC
311 #if 0
312 #undef EXTENDED_SOCKET_ERROR_CAPABILITY
313 #define EXTENDED_SOCKET_ERROR_CAPABILITY 0
314 #endif
317 * Do we have a syslog capability?
319 #if defined(HAVE_OPENLOG) && defined(HAVE_SYSLOG)
320 #define SYSLOG_CAPABILITY 1
321 #else
322 #define SYSLOG_CAPABILITY 0
323 #endif
326 * Does this OS draw a distinction between binary and ascii files?
328 #ifndef O_BINARY
329 #define O_BINARY 0
330 #endif
333 * Directory separation char
335 #ifdef WIN32
336 #define OS_SPECIFIC_DIRSEP '\\'
337 #else
338 #define OS_SPECIFIC_DIRSEP '/'
339 #endif
342 * Define a boolean value based
343 * on Win32 status.
345 #ifdef WIN32
346 #define WIN32_0_1 1
347 #else
348 #define WIN32_0_1 0
349 #endif
352 * Our socket descriptor type.
354 #ifdef WIN32
355 #define SOCKET_UNDEFINED (INVALID_SOCKET)
356 typedef SOCKET socket_descriptor_t;
357 #else
358 #define SOCKET_UNDEFINED (-1)
359 typedef int socket_descriptor_t;
360 #endif
362 static inline int
363 socket_defined (const socket_descriptor_t sd)
365 return sd != SOCKET_UNDEFINED;
369 * Should statistics counters be 64 bits?
371 #define USE_64_BIT_COUNTERS
374 * Do we have point-to-multipoint capability?
377 #if defined(ENABLE_CLIENT_SERVER) && defined(USE_CRYPTO) && defined(USE_SSL) && defined(HAVE_GETTIMEOFDAY)
378 #define P2MP 1
379 #else
380 #define P2MP 0
381 #endif
383 #if P2MP && !defined(ENABLE_CLIENT_ONLY)
384 #define P2MP_SERVER 1
385 #else
386 #define P2MP_SERVER 0
387 #endif
390 * Do we have a plug-in capability?
392 #if defined(USE_LIBDL) || defined(USE_LOAD_LIBRARY)
393 #define ENABLE_PLUGIN
394 #endif
397 * Do we have pthread capability?
399 #ifdef USE_PTHREAD
400 #if defined(USE_CRYPTO) && defined(USE_SSL) && P2MP
401 #include <pthread.h>
402 #else
403 #undef USE_PTHREAD
404 #endif
405 #endif
408 * Pthread support is currently experimental (and quite unfinished).
410 #if 1 /* JYFIXME -- if defined, disable pthread */
411 #undef USE_PTHREAD
412 #endif
415 * Should we include OCC (options consistency check) code?
417 #ifndef ENABLE_SMALL
418 #define ENABLE_OCC
419 #endif
422 * Should we include NTLM proxy functionality
424 #if defined(USE_CRYPTO) && defined(ENABLE_HTTP_PROXY)
425 #define NTLM 1
426 #else
427 #define NTLM 0
428 #endif
431 * Is poll available on this platform?
433 #if defined(HAVE_POLL) && defined(HAVE_SYS_POLL_H)
434 #define POLL 1
435 #else
436 #define POLL 0
437 #endif
440 * Is epoll available on this platform?
442 #if defined(HAVE_EPOLL_CREATE) && defined(HAVE_SYS_EPOLL_H)
443 #define EPOLL 1
444 #else
445 #define EPOLL 0
446 #endif
448 /* Disable EPOLL */
449 #if 0
450 #undef EPOLL
451 #define EPOLL 0
452 #endif
454 #endif