1 1.1 christos /* A GNU-like <arpa/inet.h>. 2 1.1 christos 3 1.1.1.2 christos Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc. 4 1.1 christos 5 1.1.1.2 christos This file is free software: you can redistribute it and/or modify 6 1.1.1.2 christos it under the terms of the GNU Lesser General Public License as 7 1.1.1.2 christos published by the Free Software Foundation; either version 2.1 of the 8 1.1.1.2 christos License, or (at your option) any later version. 9 1.1 christos 10 1.1.1.2 christos This file is distributed in the hope that it will be useful, 11 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 12 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 1.1.1.2 christos GNU Lesser General Public License for more details. 14 1.1 christos 15 1.1.1.2 christos You should have received a copy of the GNU Lesser General Public License 16 1.1.1.2 christos along with this program. If not, see <https://www.gnu.org/licenses/>. */ 17 1.1 christos 18 1.1 christos #ifndef _@GUARD_PREFIX@_ARPA_INET_H 19 1.1 christos 20 1.1 christos #if __GNUC__ >= 3 21 1.1 christos @PRAGMA_SYSTEM_HEADER@ 22 1.1 christos #endif 23 1.1 christos @PRAGMA_COLUMNS@ 24 1.1 christos 25 1.1 christos #if @HAVE_FEATURES_H@ 26 1.1 christos # include <features.h> /* for __GLIBC__ */ 27 1.1 christos #endif 28 1.1 christos 29 1.1 christos /* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and 30 1.1 christos for pulling in winsock2.h etc. under MinGW. 31 1.1 christos But avoid namespace pollution on glibc systems. */ 32 1.1 christos #ifndef __GLIBC__ 33 1.1 christos # include <sys/socket.h> 34 1.1 christos #endif 35 1.1 christos 36 1.1 christos /* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>. 37 1.1 christos But avoid namespace pollution on glibc systems. */ 38 1.1 christos #if defined __TANDEM && !defined __GLIBC__ 39 1.1 christos # include <netdb.h> 40 1.1 christos #endif 41 1.1 christos 42 1.1 christos #if @HAVE_ARPA_INET_H@ 43 1.1 christos 44 1.1 christos /* The include_next requires a split double-inclusion guard. */ 45 1.1 christos # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@ 46 1.1 christos 47 1.1 christos #endif 48 1.1 christos 49 1.1 christos #ifndef _@GUARD_PREFIX@_ARPA_INET_H 50 1.1 christos #define _@GUARD_PREFIX@_ARPA_INET_H 51 1.1 christos 52 1.1 christos /* Get all possible declarations of inet_ntop() and inet_pton(). */ 53 1.1 christos #if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \ 54 1.1 christos && @HAVE_WS2TCPIP_H@ 55 1.1 christos # include <ws2tcpip.h> 56 1.1 christos #endif 57 1.1 christos 58 1.1 christos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 59 1.1 christos 60 1.1 christos /* The definition of _GL_ARG_NONNULL is copied here. */ 61 1.1 christos 62 1.1 christos /* The definition of _GL_WARN_ON_USE is copied here. */ 63 1.1 christos 64 1.1 christos 65 1.1 christos #if @GNULIB_INET_NTOP@ 66 1.1 christos /* Converts an internet address from internal format to a printable, 67 1.1 christos presentable format. 68 1.1 christos AF is an internet address family, such as AF_INET or AF_INET6. 69 1.1 christos SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr' 70 1.1 christos (for AF_INET6). 71 1.1 christos DST points to a buffer having room for CNT bytes. 72 1.1 christos The printable representation of the address (in numeric form, not 73 1.1 christos surrounded by [...], no reverse DNS is done) is placed in DST, and 74 1.1 christos DST is returned. If an error occurs, the return value is NULL and 75 1.1 christos errno is set. If CNT bytes are not sufficient to hold the result, 76 1.1 christos the return value is NULL and errno is set to ENOSPC. A good value 77 1.1 christos for CNT is 46. 78 1.1 christos 79 1.1 christos For more details, see the POSIX:2008 specification 80 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>. */ 81 1.1 christos # if @REPLACE_INET_NTOP@ 82 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 83 1.1 christos # undef inet_ntop 84 1.1 christos # define inet_ntop rpl_inet_ntop 85 1.1 christos # endif 86 1.1 christos _GL_FUNCDECL_RPL (inet_ntop, const char *, 87 1.1 christos (int af, const void *restrict src, 88 1.1 christos char *restrict dst, socklen_t cnt) 89 1.1 christos _GL_ARG_NONNULL ((2, 3))); 90 1.1 christos _GL_CXXALIAS_RPL (inet_ntop, const char *, 91 1.1 christos (int af, const void *restrict src, 92 1.1 christos char *restrict dst, socklen_t cnt)); 93 1.1 christos # else 94 1.1 christos # if !@HAVE_DECL_INET_NTOP@ 95 1.1 christos _GL_FUNCDECL_SYS (inet_ntop, const char *, 96 1.1 christos (int af, const void *restrict src, 97 1.1 christos char *restrict dst, socklen_t cnt) 98 1.1 christos _GL_ARG_NONNULL ((2, 3))); 99 1.1 christos # endif 100 1.1 christos /* Need to cast, because on NonStop Kernel, the fourth parameter is 101 1.1 christos size_t cnt. */ 102 1.1 christos _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *, 103 1.1 christos (int af, const void *restrict src, 104 1.1 christos char *restrict dst, socklen_t cnt)); 105 1.1 christos # endif 106 1.1 christos # if __GLIBC__ >= 2 107 1.1 christos _GL_CXXALIASWARN (inet_ntop); 108 1.1 christos # endif 109 1.1 christos #elif defined GNULIB_POSIXCHECK 110 1.1 christos # undef inet_ntop 111 1.1 christos # if HAVE_RAW_DECL_INET_NTOP 112 1.1 christos _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - " 113 1.1 christos "use gnulib module inet_ntop for portability"); 114 1.1 christos # endif 115 1.1 christos #endif 116 1.1 christos 117 1.1 christos #if @GNULIB_INET_PTON@ 118 1.1 christos # if @REPLACE_INET_PTON@ 119 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 120 1.1 christos # undef inet_pton 121 1.1 christos # define inet_pton rpl_inet_pton 122 1.1 christos # endif 123 1.1 christos _GL_FUNCDECL_RPL (inet_pton, int, 124 1.1 christos (int af, const char *restrict src, void *restrict dst) 125 1.1 christos _GL_ARG_NONNULL ((2, 3))); 126 1.1 christos _GL_CXXALIAS_RPL (inet_pton, int, 127 1.1 christos (int af, const char *restrict src, void *restrict dst)); 128 1.1 christos # else 129 1.1 christos # if !@HAVE_DECL_INET_PTON@ 130 1.1 christos _GL_FUNCDECL_SYS (inet_pton, int, 131 1.1 christos (int af, const char *restrict src, void *restrict dst) 132 1.1 christos _GL_ARG_NONNULL ((2, 3))); 133 1.1 christos # endif 134 1.1 christos _GL_CXXALIAS_SYS (inet_pton, int, 135 1.1 christos (int af, const char *restrict src, void *restrict dst)); 136 1.1 christos # endif 137 1.1 christos # if __GLIBC__ >= 2 138 1.1 christos _GL_CXXALIASWARN (inet_pton); 139 1.1 christos # endif 140 1.1 christos #elif defined GNULIB_POSIXCHECK 141 1.1 christos # undef inet_pton 142 1.1 christos # if HAVE_RAW_DECL_INET_PTON 143 1.1 christos _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - " 144 1.1 christos "use gnulib module inet_pton for portability"); 145 1.1 christos # endif 146 1.1 christos #endif 147 1.1 christos 148 1.1 christos 149 1.1 christos #endif /* _@GUARD_PREFIX@_ARPA_INET_H */ 150 1.1 christos #endif /* _@GUARD_PREFIX@_ARPA_INET_H */ 151