sys_ip_headers.h (4724B)
1 /* SPDX-License-Identifier: LGPL-2.1-or-later OR (GPL-2.0-or-later WITH eCos-exception-2.0) */ 2 /* 3 This file is part of GNU libmicrohttpd. 4 Copyright (C) 2024 Evgeny Grin (Karlson2k) 5 6 GNU libmicrohttpd is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) any later version. 10 11 GNU libmicrohttpd is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 Alternatively, you can redistribute GNU libmicrohttpd and/or 17 modify it under the terms of the GNU General Public License as 18 published by the Free Software Foundation; either version 2 of 19 the License, or (at your option) any later version, together 20 with the eCos exception, as follows: 21 22 As a special exception, if other files instantiate templates or 23 use macros or inline functions from this file, or you compile this 24 file and link it with other works to produce a work based on this 25 file, this file does not by itself cause the resulting work to be 26 covered by the GNU General Public License. However the source code 27 for this file must still be made available in accordance with 28 section (3) of the GNU General Public License v2. 29 30 This exception does not invalidate any other reasons why a work 31 based on this file might be covered by the GNU General Public 32 License. 33 34 You should have received copies of the GNU Lesser General Public 35 License and the GNU General Public License along with this library; 36 if not, see <https://www.gnu.org/licenses/>. 37 */ 38 39 /** 40 * @file src/mhd2/sys_ip_headers.h 41 * @brief The header for system headers related to TCP/IP 42 * @author Karlson2k (Evgeny Grin) 43 */ 44 45 #ifndef MHD_SYS_IP_HEADERS_H 46 #define MHD_SYS_IP_HEADERS_H 1 47 48 #include "mhd_sys_options.h" 49 50 #include "mhd_socket_type.h" 51 #include "sys_sockets_headers.h" 52 53 #ifdef MHD_SOCKETS_KIND_POSIX 54 # ifdef HAVE_INETLIB_H 55 # include <inetLib.h> 56 # endif /* HAVE_INETLIB_H */ 57 # ifdef HAVE_NETINET_IN_H 58 # include <netinet/in.h> 59 # endif /* HAVE_NETINET_IN_H */ 60 # ifdef HAVE_ARPA_INET_H 61 # include <arpa/inet.h> 62 # endif 63 # if ! defined(HAVE_NETINET_IN_H) && ! defined(HAVE_ARPA_INET_H) \ 64 && defined(HAVE_NETDB_H) 65 # include <netdb.h> 66 # endif 67 # ifdef HAVE_NETINET_TCP_H 68 # include <netinet/tcp.h> 69 # endif 70 #else 71 # include <ws2tcpip.h> 72 #endif 73 74 #if ! defined(HAVE_DCLR_IPV6_V6ONLY) && defined(IPV6_V6ONLY) 75 /* Mis-deteted by configure */ 76 # define HAVE_DCLR_IPV6_V6ONLY 1 77 #endif 78 79 #if ! defined(HAVE_DCLR_TCP_NODELAY) && defined(TCP_NODELAY) 80 /* Mis-deteted by configure */ 81 # define HAVE_DCLR_TCP_NODELAY 1 82 #endif 83 84 #if ! defined(HAVE_DCLR_TCP_FASTOPEN) && defined(TCP_FASTOPEN) 85 /* Mis-deteted by configure */ 86 # define HAVE_DCLR_TCP_FASTOPEN 1 87 #endif 88 89 #ifdef IPPROTO_TCP 90 # if defined(TCP_CORK) 91 /** 92 * Value of TCP_CORK or TCP_NOPUSH 93 */ 94 # define mhd_TCP_CORK_NOPUSH TCP_CORK 95 # elif defined(TCP_NOPUSH) 96 /** 97 * Value of TCP_CORK or TCP_NOPUSH 98 */ 99 # define mhd_TCP_CORK_NOPUSH TCP_NOPUSH 100 # endif /* TCP_NOPUSH */ 101 #endif /* IPPROTO_TCP */ 102 103 #ifdef mhd_TCP_CORK_NOPUSH 104 # ifdef __linux__ 105 /** 106 * Indicate that reset of TCP_CORK / TCP_NOPUSH push data to the network 107 */ 108 # define mhd_CORK_RESET_PUSH_DATA 1 109 /** 110 * Indicate that reset of TCP_CORK / TCP_NOPUSH push data to the network 111 * even if TCP_CORK/TCP_NOPUSH was in switched off state. 112 */ 113 # define mhd_CORK_RESET_PUSH_DATA_ALWAYS 1 114 #endif /* __linux__ */ 115 #if (defined(__FreeBSD__) && \ 116 ((__FreeBSD__ + 0) >= 5 || (__FreeBSD_version + 0) >= 450000)) || \ 117 (defined(__FreeBSD_kernel_version) && \ 118 (__FreeBSD_kernel_version + 0) >= 450000) 119 /* FreeBSD pushes data to the network with reset of TCP_NOPUSH 120 * starting from version 4.5. */ 121 /** 122 * Indicate that reset of TCP_CORK / TCP_NOPUSH push data to the network 123 */ 124 #define mhd_CORK_RESET_PUSH_DATA 1 125 #endif /* __FreeBSD_version >= 450000 */ 126 #ifdef __OpenBSD__ 127 /* OpenBSD took implementation from FreeBSD */ 128 /** 129 * Indicate that reset of TCP_CORK / TCP_NOPUSH push data to the network 130 */ 131 #define mhd_CORK_RESET_PUSH_DATA 1 132 #endif /* __OpenBSD__ */ 133 #endif /* MHD_TCP_CORK_NOPUSH */ 134 135 #ifdef __linux__ 136 /** 137 * Indicate that set of TCP_NODELAY push data to the network 138 */ 139 # define mhd_NODELAY_SET_PUSH_DATA 1 140 /** 141 * Indicate that set of TCP_NODELAY push data to the network even 142 * if TCP_DELAY was already set and regardless of TCP_CORK / TCP_NOPUSH state 143 */ 144 # define mhd_NODELAY_SET_PUSH_DATA_ALWAYS 1 145 #endif /* __linux__ */ 146 147 148 #endif /* ! MHD_SYS_IP_HEADERS_H */