1 /** @file 2 3 Platform specific defines and includes, this is to make the build 4 more portable. 5 6 @section license License 7 8 Licensed to the Apache Software Foundation (ASF) under one 9 or more contributor license agreements. See the NOTICE file 10 distributed with this work for additional information 11 regarding copyright ownership. The ASF licenses this file 12 to you under the Apache License, Version 2.0 (the 13 "License"); you may not use this file except in compliance 14 with the License. You may obtain a copy of the License at 15 16 http://www.apache.org/licenses/LICENSE-2.0 17 18 Unless required by applicable law or agreed to in writing, software 19 distributed under the License is distributed on an "AS IS" BASIS, 20 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 See the License for the specific language governing permissions and 22 limitations under the License. 23 */ 24 25 #pragma once 26 27 #include "tscore/ink_config.h" 28 29 // Gnu C++ doesn't define __STDC__ == 0 as needed to 30 // have ip_hl be defined. 31 #if defined(__GNUC__) && !defined(__STDC__) 32 #define __STDC__ 0 33 #endif 34 35 #include <fcntl.h> 36 #include <limits.h> // NOLINT(modernize-deprecated-headers) 37 #include <assert.h> // NOLINT(modernize-deprecated-headers) 38 #include <time.h> // NOLINT(modernize-deprecated-headers) 39 #include <sys/time.h> 40 #include <sys/uio.h> 41 #include <sys/file.h> 42 #include <sys/resource.h> 43 #include <errno.h> // NOLINT(modernize-deprecated-headers) 44 #include <syslog.h> 45 #include <pwd.h> 46 #include <poll.h> 47 #include <dirent.h> 48 49 #include <sys/ipc.h> 50 #include <sys/shm.h> 51 #include <sys/sem.h> 52 53 #include <sys/param.h> 54 #include <sys/un.h> 55 56 #include <sys/socket.h> 57 #include <sys/mman.h> 58 #include <sys/wait.h> 59 60 struct ifafilt; 61 #include <net/if.h> 62 63 #ifdef HAVE_STDLIB_H 64 #include <stdlib.h> // NOLINT(modernize-deprecated-headers) 65 #endif 66 #include <ctype.h> // NOLINT(modernize-deprecated-headers) 67 #ifdef HAVE_STRING_H 68 #include <string.h> // NOLINT(modernize-deprecated-headers) 69 #endif 70 #ifdef HAVE_STRINGS_H 71 #include <strings.h> 72 #endif 73 #ifdef HAVE_SYS_TYPES_H 74 #include <sys/types.h> 75 #endif 76 #ifdef HAVE_SYS_STAT_H 77 #include <sys/stat.h> 78 #endif 79 #ifdef HAVE_UNISTD_H 80 #include <unistd.h> 81 #endif 82 #ifdef HAVE_NETINET_IN_H 83 #include <netinet/in.h> 84 #endif 85 #ifdef HAVE_NETINET_IN_SYSTM_H 86 #include <netinet/in_systm.h> 87 #endif 88 #ifdef HAVE_NETINET_TCP_H 89 #include <netinet/tcp.h> 90 #endif 91 #ifdef HAVE_NETINET_IP_H 92 #include <netinet/ip.h> 93 #endif 94 #ifdef HAVE_NETINET_IP_ICMP_H 95 #include <netinet/ip_icmp.h> 96 #endif 97 #ifdef HAVE_NETDB_H 98 #include <netdb.h> 99 #endif 100 #ifdef HAVE_ARPA_INET_H 101 #include <arpa/inet.h> 102 #endif 103 #ifdef HAVE_ARPA_NAMESER_H 104 #include <arpa/nameser.h> 105 #endif 106 #ifdef HAVE_ARPA_NAMESER_COMPAT_H 107 #include <arpa/nameser_compat.h> 108 #endif 109 110 #include <signal.h> // NOLINT(modernize-deprecated-headers) 111 #ifdef HAVE_SIGINFO_H 112 #include <siginfo.h> 113 #endif 114 115 #if TS_USE_EPOLL 116 #include <sys/epoll.h> 117 #endif 118 #if TS_USE_KQUEUE 119 #include <sys/event.h> 120 #endif 121 #if TS_USE_PORT 122 #include <port.h> 123 #endif 124 125 #ifdef HAVE_VALUES_H 126 #include <values.h> 127 #endif 128 #ifdef HAVE_ALLOCA_H 129 #include <alloca.h> 130 #endif 131 132 #ifdef HAVE_CPIO_H 133 #include <cpio.h> 134 #if defined(MAGIC) 135 #undef MAGIC 136 #endif 137 #endif 138 139 #ifdef HAVE_STROPTS_H 140 #include <stropts.h> 141 #endif 142 143 #include "ink_endian.h" 144 145 #ifdef HAVE_SYS_IOCTL_H 146 #include <sys/ioctl.h> 147 #endif 148 #ifdef HAVE_SYS_SOCKIO_H 149 #include <sys/sockio.h> 150 #endif 151 152 #if defined(linux) 153 typedef unsigned int in_addr_t; 154 #endif 155 156 #ifdef HAVE_SYS_SYSINFO_H 157 #include <sys/sysinfo.h> 158 #endif 159 160 #if defined(darwin) || defined(freebsd) 161 #ifdef HAVE_SYS_SYSCTL_H 162 #include <sys/sysctl.h> 163 #endif 164 #endif 165 166 #ifdef HAVE_SYS_SYSTEMINFO_H 167 #include <sys/systeminfo.h> 168 #endif 169 170 #ifdef HAVE_DLFCN_H 171 #include <dlfcn.h> 172 #endif 173 174 #ifdef HAVE_FLOAT_H 175 #include <float.h> // NOLINT(modernize-deprecated-headers) 176 #endif 177 178 #ifdef HAVE_SYS_SYSMACROS_H 179 #include <sys/sysmacros.h> 180 #endif 181 182 #ifdef HAVE_SYS_PRCTL_H 183 #include <sys/prctl.h> 184 #endif 185 186 // Unconditionally included headers that depend on conditionally included ones. 187 #include <resolv.h> // Must go after the netinet includes for FreeBSD 188 189 #ifndef PATH_NAME_MAX 190 #define PATH_NAME_MAX \ 191 4096 // instead of PATH_MAX which is inconsistent 192 // on various OSs (linux-4096,osx/bsd-1024, 193 // windows-260,etc) 194 #endif 195 196 // This is a little bit of a hack for now, until MPTCP has landed upstream in Linux land. 197 #ifndef MPTCP_ENABLED 198 #if defined(linux) 199 #define MPTCP_ENABLED 42 200 #else 201 #define MPTCP_ENABLED 0 202 #endif 203 #endif 204