5 have.h -- include headers which are known to exist
6 Copyright (C) 1998-2005 Ivo Timmermans
7 2003-2021 Guus Sliepen <guus@tinc-vpn.org>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
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 along
20 with this program; if not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #define _WIN32_WINNT 0x0600
27 #define WIN32_LEAN_AND_MEAN
28 #define _CRT_SECURE_NO_WARNINGS
29 #define _CRT_NONSTDC_NO_WARNINGS
32 #define __STDC_WANT_LIB_EXT1__ 1
50 #ifdef HAVE_STATIC_ASSERT
51 #define STATIC_ASSERT(expr, msg) _Static_assert((expr), msg)
53 #define STATIC_ASSERT(check, msg)
56 #ifdef HAVE_ATTR_PACKED
57 #define PACKED(...) __VA_ARGS__ __attribute__((__packed__))
60 #define PACKED(...) __pragma(pack(push, 1)) __VA_ARGS__ __pragma(pack(pop))
62 #warning Your compiler does not support __packed__. Use at your own risk.
66 #if defined(HAVE_ATTR_MALLOC_WITH_ARG)
67 #define ATTR_DEALLOCATOR(dealloc) __attribute__((__malloc__(dealloc)))
69 #define ATTR_DEALLOCATOR(dealloc)
72 #ifdef HAVE_ATTR_MALLOC
73 #define ATTR_MALLOC __attribute__((__malloc__))
78 #ifdef HAVE_ATTR_NONNULL
79 #define ATTR_NONNULL __attribute__((__nonnull__))
84 #ifdef HAVE_ATTR_WARN_UNUSED_RESULT
85 #define ATTR_WARN_UNUSED __attribute__((__warn_unused_result__))
87 #define ATTR_WARN_UNUSED
90 #ifdef HAVE_ATTR_FORMAT
91 #define ATTR_FORMAT(func, str, nonstr) __attribute__((format(func, str, nonstr)))
93 #define ATTR_FORMAT(func, str, nonstr)
98 #elif defined(HAVE_NETBSD)
99 #define alloca(size) __builtin_alloca(size)
107 #include <winsock2.h>
109 #include <ws2tcpip.h>
116 #endif // HAVE_WINDOWS
118 #ifdef HAVE_TERMIOS_H
122 #ifdef HAVE_INTTYPES_H
123 #include <inttypes.h>
126 /* Include system specific headers */
136 #ifdef HAVE_SYS_RANDOM_H
137 #include <sys/random.h>
140 #ifdef HAVE_SYS_TIME_H
141 #include <sys/time.h>
144 #ifdef HAVE_SYS_TYPES_H
145 #include <sys/types.h>
148 #ifdef HAVE_SYS_STAT_H
149 #include <sys/stat.h>
152 #ifdef HAVE_SYS_FILE_H
153 #include <sys/file.h>
156 #ifdef HAVE_SYS_MMAN_H
157 #include <sys/mman.h>
160 #ifdef HAVE_SYS_WAIT_H
161 #include <sys/wait.h>
164 #ifdef HAVE_SYS_IOCTL_H
165 #include <sys/ioctl.h>
168 #ifdef HAVE_SYS_PARAM_H
169 #include <sys/param.h>
172 #ifdef HAVE_SYS_RESOURCE_H
173 #include <sys/resource.h>
182 #elif defined(_MSC_VER)
186 /* SunOS really wants sys/socket.h BEFORE net/if.h,
187 and FreeBSD wants these lines below the rest. */
193 #ifdef HAVE_SYS_SOCKET_H
194 #include <sys/socket.h>
201 #ifdef HAVE_NET_IF_TYPES_H
202 #include <net/if_types.h>
205 #ifdef HAVE_NET_IF_TUN_H
206 #include <net/if_tun.h>
209 #ifdef HAVE_NET_TUN_IF_TUN_H
210 #include <net/tun/if_tun.h>
213 #ifdef HAVE_NET_IF_TAP_H
214 #include <net/if_tap.h>
217 #ifdef HAVE_NET_TAP_IF_TAP_H
218 #include <net/tap/if_tap.h>
221 #ifdef HAVE_NETINET_IN_SYSTM_H
222 #include <netinet/in_systm.h>
225 #ifdef HAVE_NETINET_IN_H
226 #include <netinet/in.h>
229 #ifdef HAVE_ARPA_INET_H
230 #include <arpa/inet.h>
233 #ifdef HAVE_NETINET_IP_H
234 #include <netinet/ip.h>
237 #ifdef HAVE_NETINET_TCP_H
238 #include <netinet/tcp.h>
241 #ifdef HAVE_NETINET_IN6_H
242 #include <netinet/in6.h>
245 #ifdef HAVE_NETINET_IP6_H
246 #include <netinet/ip6.h>
249 #ifdef HAVE_NET_ETHERNET_H
250 #include <net/ethernet.h>
253 #ifdef HAVE_NET_IF_ARP_H
254 #include <net/if_arp.h>
257 #ifdef HAVE_NETINET_IP_ICMP_H
258 #include <netinet/ip_icmp.h>
261 #ifdef HAVE_NETINET_ICMP6_H
262 #include <netinet/icmp6.h>
265 #ifdef HAVE_NETINET_IF_ETHER_H
266 #include <netinet/if_ether.h>
269 #ifdef HAVE_ARPA_NAMESER_H
270 #include <arpa/nameser.h>
277 #ifdef HAVE_LINUX_IF_TUN_H
278 #include <linux/if_tun.h>