1 /* Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, write to the Free 16 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 02110-1301 USA. */ 18 19 /* All data returned by the network data base library are supplied in 20 host order and returned in network order (suitable for use in 21 system calls). */ 22 23 #ifndef _COMPAT_NETDB_H 24 #define _COMPAT_NETDB_H 1 25 26 #include <config.h> 27 #include "owfs_config.h" 28 29 #ifdef HAVE_FEATURES_H 30 #include <features.h> 31 #endif 32 33 #ifndef __USE_GNU 34 #define __USE_GNU 35 #endif 36 37 /* Doesn't exist for Solaris, make a test for it later */ 38 /* #undef HAVE_SA_LEN */ 39 40 #ifndef __HAS_IPV6__ 41 #define __HAS_IPV6__ 0 42 #endif 43 #ifndef __USE_POSIX 44 #define __USE_POSIX 45 #endif 46 #ifndef __THROW 47 #define __THROW 48 #endif 49 50 #ifdef HAVE_SYS_TYPES_H 51 #include <sys/types.h> 52 #endif 53 54 #ifdef HAVE_SYS_SOCKET_H 55 #include <sys/socket.h> 56 #endif 57 58 #ifdef HAVE_NETINET_IN_H 59 #include <netinet/in.h> 60 #endif 61 62 #ifdef HAVE_STDINT_H 63 #include <stdint.h> 64 #endif 65 66 #ifdef __USE_MISC 67 /* This is necessary to make this include file properly replace the 68 Sun version. */ 69 # include <rpc/netdb.h> 70 #endif 71 72 #ifdef HAVE_BITS_NETDB_H 73 #include <bits/netdb.h> 74 #endif 75 76 /* Absolute file name for network data base files. */ 77 #define _PATH_HEQUIV "/etc/hosts.equiv" 78 #define _PATH_HOSTS "/etc/hosts" 79 #define _PATH_NETWORKS "/etc/networks" 80 #define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf" 81 #define _PATH_PROTOCOLS "/etc/protocols" 82 #define _PATH_SERVICES "/etc/services" 83 84 #ifndef __set_errno 85 #define __set_errno(x) (errno = (x)) 86 #endif 87 88 #ifndef __set_h_errno 89 #define __set_h_errno(x) (h_errno = (x)) 90 #endif 91 92 93 #ifndef HAVE_INET_NTOP 94 const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); 95 #endif 96 97 #ifndef HAVE_INET_PTON 98 int inet_pton(int af, const char *src, void *dst); 99 #endif 100 101 #ifndef HAVE_GETADDRINFO 102 103 /* Possible values left in `h_errno'. */ 104 #define NETDB_INTERNAL -1 /* See errno. */ 105 #define NETDB_SUCCESS 0 /* No problem. */ 106 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */ 107 #define TRY_AGAIN 2 /* Non-Authoritative Host not found, 108 or SERVERFAIL. */ 109 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, 110 NOTIMP. */ 111 #define NO_DATA 4 /* Valid name, no data record of requested 112 type. */ 113 #define NO_ADDRESS NO_DATA /* No address, look for MX record. */ 114 115 #ifdef __USE_XOPEN2K 116 /* Highest reserved Internet port number. */ 117 # define IPPORT_RESERVED 1024 118 #endif 119 120 121 #ifdef __USE_GNU 122 /* Scope delimiter for getaddrinfo(), getnameinfo(). */ 123 # define SCOPE_DELIMITER '%' 124 #endif 125 126 /* Extension from POSIX.1g. */ 127 #if defined(__USE_POSIX) && !defined(__CYGWIN__) 128 /* Structure to contain information about address of a service provider. */ 129 struct addrinfo { 130 int ai_flags; /* Input flags. */ 131 int ai_family; /* Protocol family for socket. */ 132 int ai_socktype; /* Socket type. */ 133 int ai_protocol; /* Protocol for socket. */ 134 socklen_t ai_addrlen; /* Length of socket address. */ 135 struct sockaddr *ai_addr; /* Socket address for socket. */ 136 char *ai_canonname; /* Canonical name for service location. */ 137 struct addrinfo *ai_next; /* Pointer to next in list. */ 138 }; 139 140 # ifdef __USE_GNU 141 /* Lookup mode. */ 142 # define GAI_WAIT 0 143 # define GAI_NOWAIT 1 144 # endif 145 146 /* Possible values for `ai_flags' field in `addrinfo' structure. */ 147 # define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ 148 # define AI_CANONNAME 0x0002 /* Request for canonical name. */ 149 # define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ 150 151 /* Error values for `getaddrinfo' function. */ 152 # define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ 153 # define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ 154 # define EAI_AGAIN -3 /* Temporary failure in name resolution. */ 155 # define EAI_FAIL -4 /* Non-recoverable failure in name res. */ 156 # define EAI_NODATA -5 /* No address associated with NAME. */ 157 # define EAI_FAMILY -6 /* `ai_family' not supported. */ 158 # define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ 159 # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ 160 # define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ 161 # define EAI_MEMORY -10 /* Memory allocation failure. */ 162 # define EAI_SYSTEM -11 /* System error returned in `errno'. */ 163 # ifdef __USE_GNU 164 # define EAI_INPROGRESS -100 /* Processing request in progress. */ 165 # define EAI_CANCELED -101 /* Request canceled. */ 166 # define EAI_NOTCANCELED -102 /* Request not canceled. */ 167 # define EAI_ALLDONE -103 /* All requests done. */ 168 # define EAI_INTR -104 /* Interrupted by a signal. */ 169 # endif 170 171 # define NI_MAXHOST 1025 172 # define NI_MAXSERV 32 173 174 # define NI_NUMERICHOST 1 /* Don't try to look up hostname. */ 175 # define NI_NUMERICSERV 2 /* Don't convert port number to name. */ 176 # define NI_NOFQDN 4 /* Only return nodename portion. */ 177 # define NI_NAMEREQD 8 /* Don't return numeric addresses. */ 178 # define NI_DGRAM 16 /* Look up UDP service rather than TCP. */ 179 180 /* Translate name of a service location and/or a service name to set of 181 socket addresses. */ 182 extern int getaddrinfo(__const char *__restrict __name, 183 __const char *__restrict __service, __const struct addrinfo *__restrict __req, struct addrinfo **__restrict __pai) __THROW; 184 185 /* Free `addrinfo' structure AI including associated storage. */ 186 extern void freeaddrinfo(struct addrinfo *__ai) __THROW; 187 188 /* Convert error return from getaddrinfo() to a string. */ 189 extern const char *gai_strerror(int __ecode) __THROW; 190 191 #endif /* HAVE_GETADDRINFO */ 192 193 #endif /* POSIX */ 194 195 #endif /* COMPAT_NETDB_H */ 196