1
/* Provide a netdb.h header file for systems lacking it (read: MinGW).
2
Copyright (C) 2008 Free Software Foundation, Inc.
3
Written by Simon Josefsson.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation; either version 2.1, or (at your option)
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public License
16
along with this program; if not, write to the Free Software Foundation,
17
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
/* This file is supposed to be used on platforms that lack <netdb.h>.
20
It is intended to provide definitions and prototypes needed by an
28
@PRAGMA_SYSTEM_HEADER@
31
/* The include_next requires a split double-inclusion guard. */
32
# @INCLUDE_NEXT@ @NEXT_NETDB_H@
39
#if @HAVE_NETDB_H@ && HAVE_STRUCT_ADDRINFO
41
/* Declarations for a platform that has <netdb.h>. */
45
/* Get netdb.h definitions such as struct hostent for MinGW. */
46
#include <sys/socket.h>
48
/* Declarations for a platform that lacks <netdb.h>, or where it is
51
#if @GNULIB_GETADDRINFO@
53
# ifndef HAVE_STRUCT_ADDRINFO
55
/* Structure to contain information about address of a service provider. */
58
int ai_flags; /* Input flags. */
59
int ai_family; /* Protocol family for socket. */
60
int ai_socktype; /* Socket type. */
61
int ai_protocol; /* Protocol for socket. */
62
socklen_t ai_addrlen; /* Length of socket address. */
63
struct sockaddr *ai_addr; /* Socket address for socket. */
64
char *ai_canonname; /* Canonical name for service location. */
65
struct addrinfo *ai_next; /* Pointer to next in list. */
69
/* Possible values for `ai_flags' field in `addrinfo' structure. */
71
# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
74
# define AI_CANONNAME 0x0002 /* Request for canonical name. */
76
# ifndef AI_NUMERICSERV
77
# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
81
/* The commented out definitions below are not yet implemented in the
82
GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
83
cause conflicts on systems with a getaddrinfo() function which does not
86
If they are restored, be sure to protect the definitions with #ifndef. */
87
# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
88
# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
89
# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
90
# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
91
returned address type.. */
94
/* Error values for `getaddrinfo' function. */
96
# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
97
# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
98
# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
99
# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
100
# define EAI_NODATA -5 /* No address associated with NAME. */
101
# define EAI_FAMILY -6 /* `ai_family' not supported. */
102
# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
103
# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
104
# define EAI_MEMORY -10 /* Memory allocation failure. */
107
/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least
108
FreeBSD, which does define EAI_BADFLAGS) have removed the definition
109
in favor of EAI_NONAME. */
110
# if !defined EAI_NODATA && defined EAI_NONAME
111
# define EAI_NODATA EAI_NONAME
114
# ifndef EAI_OVERFLOW
115
/* Not defined on mingw32. */
116
# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
118
# ifndef EAI_ADDRFAMILY
119
/* Not defined on mingw32. */
120
# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
123
/* Not defined on mingw32. */
124
# define EAI_SYSTEM -11 /* System error returned in `errno'. */
128
/* The commented out definitions below are not yet implemented in the
129
GNULIB getaddrinfo() replacement, so are not yet needed.
131
If they are restored, be sure to protect the definitions with #ifndef. */
132
# ifndef EAI_INPROGRESS
133
# define EAI_INPROGRESS -100 /* Processing request in progress. */
134
# define EAI_CANCELED -101 /* Request canceled. */
135
# define EAI_NOTCANCELED -102 /* Request not canceled. */
136
# define EAI_ALLDONE -103 /* All requests done. */
137
# define EAI_INTR -104 /* Interrupted by a signal. */
138
# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
142
# if !HAVE_DECL_GETADDRINFO
143
/* Translate name of a service location and/or a service name to set of
145
For more details, see the POSIX:2001 specification
146
<http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
147
extern int getaddrinfo (const char *restrict nodename,
148
const char *restrict servname,
149
const struct addrinfo *restrict hints,
150
struct addrinfo **restrict res);
153
# if !HAVE_DECL_FREEADDRINFO
154
/* Free `addrinfo' structure AI including associated storage.
155
For more details, see the POSIX:2001 specification
156
<http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
157
extern void freeaddrinfo (struct addrinfo *ai);
160
# if !HAVE_DECL_GAI_STRERROR
161
/* Convert error return from getaddrinfo() to a string.
162
For more details, see the POSIX:2001 specification
163
<http://www.opengroup.org/susv3xsh/gai_strerror.html>. */
164
extern const char *gai_strerror (int ecode);
167
# if !HAVE_DECL_GETNAMEINFO
168
/* Convert socket address to printable node and service names.
169
For more details, see the POSIX:2001 specification
170
<http://www.opengroup.org/susv3xsh/getnameinfo.html>. */
171
extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
172
char *restrict node, socklen_t nodelen,
173
char *restrict service, socklen_t servicelen,
177
/* Possible flags for getnameinfo. */
178
# ifndef NI_NUMERICHOST
179
# define NI_NUMERICHOST 1
181
# ifndef NI_NUMERICSERV
182
# define NI_NUMERICSERV 2
185
#endif /* @GNULIB_GETADDRINFO@ */
187
#endif /* HAVE_NETDB_H */
189
#endif /* _GL_NETDB_H */
190
#endif /* _GL_NETDB_H */