* lib/getaddrinfo.h: Don't define unimplemented AI_* flags.
[pspp] / lib / getaddrinfo.h
1 /* Get address information.
2    Copyright (C) 1996-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3    Contributed by Simon Josefsson <simon@josefsson.org>.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
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 General Public License for more details.
14
15    You should have received a copy of the GNU 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.  */
18
19 #ifndef GETADDRINFO_H
20 # define GETADDRINFO_H
21
22 /* sys/socket.h in i386-unknown-freebsd4.10 and
23    powerpc-apple-darwin5.5 require sys/types.h, so include it first.
24    Then we'll also get 'socklen_t' and 'struct sockaddr' which are
25    used below. */
26 # include <sys/types.h>
27 /* Get all getaddrinfo related declarations, if available.  */
28 # include <sys/socket.h>
29 #ifdef HAVE_NETDB_H
30 # include <netdb.h>
31 #endif
32
33 # ifndef HAVE_STRUCT_ADDRINFO
34
35 /* Structure to contain information about address of a service provider.  */
36 struct addrinfo
37 {
38   int ai_flags;                 /* Input flags.  */
39   int ai_family;                /* Protocol family for socket.  */
40   int ai_socktype;              /* Socket type.  */
41   int ai_protocol;              /* Protocol for socket.  */
42   socklen_t ai_addrlen;         /* Length of socket address.  */
43   struct sockaddr *ai_addr;     /* Socket address for socket.  */
44   char *ai_canonname;           /* Canonical name for service location.  */
45   struct addrinfo *ai_next;     /* Pointer to next in list.  */
46 };
47 # endif
48
49 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
50 # ifndef AI_CANONNAME
51 #  define AI_CANONNAME   0x0002 /* Request for canonical name.  */
52 # endif
53 #ifndef AI_NUMERICSERV
54 #  define AI_NUMERICSERV 0x0400 /* Don't use name resolution.  */
55 # endif
56 #if 0
57 /* The commented out definitions below are not yet implemented in the
58    GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
59    cause conflicts on systems with a getaddrinfo() function which does not
60    define them.
61
62    If they are restored, be sure to protect the definitions with #ifndef.  */
63 #define AI_PASSIVE      0x0001  /* Socket address is intended for `bind'.  */
64 #define AI_NUMERICHOST  0x0004  /* Don't use name resolution.  */
65 #define AI_V4MAPPED     0x0008  /* IPv4 mapped addresses are acceptable.  */
66 #define AI_ALL          0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
67 #define AI_ADDRCONFIG   0x0020  /* Use configuration of this host to choose
68                                    returned address type..  */
69 #endif /* 0 */
70
71 /* Error values for `getaddrinfo' function.  */
72 # ifndef EAI_BADFLAGS
73 #  define EAI_BADFLAGS    -1    /* Invalid value for `ai_flags' field.  */
74 #  define EAI_NONAME      -2    /* NAME or SERVICE is unknown.  */
75 #  define EAI_AGAIN       -3    /* Temporary failure in name resolution.  */
76 #  define EAI_FAIL        -4    /* Non-recoverable failure in name res.  */
77 #  define EAI_NODATA      -5    /* No address associated with NAME.  */
78 #  define EAI_FAMILY      -6    /* `ai_family' not supported.  */
79 #  define EAI_SOCKTYPE    -7    /* `ai_socktype' not supported.  */
80 #  define EAI_SERVICE     -8    /* SERVICE not supported for `ai_socktype'.  */
81 #  define EAI_MEMORY      -10   /* Memory allocation failure.  */
82 #endif
83 #ifndef EAI_OVERFLOW
84 /* Not defined on mingw32. */
85 #  define EAI_OVERFLOW    -12   /* Argument buffer overflow.  */
86 #endif
87 # ifndef EAI_ADDRFAMILY
88 /* Not defined on mingw32. */
89 #  define EAI_ADDRFAMILY  -9    /* Address family for NAME not supported.  */
90 # endif
91 # ifndef EAI_SYSTEM
92 /* Not defined on mingw32. */
93 #  define EAI_SYSTEM      -11   /* System error returned in `errno'.  */
94 # endif
95
96 # ifdef __USE_GNU
97 #  ifndef EAI_INPROGRESS
98 #   define EAI_INPROGRESS       -100    /* Processing request in progress.  */
99 #   define EAI_CANCELED         -101    /* Request canceled.  */
100 #   define EAI_NOTCANCELED      -102    /* Request not canceled.  */
101 #   define EAI_ALLDONE          -103    /* All requests done.  */
102 #   define EAI_INTR             -104    /* Interrupted by a signal.  */
103 #   define EAI_IDN_ENCODE       -105    /* IDN encoding failed.  */
104 #  endif
105 # endif
106
107 # if !HAVE_DECL_GETADDRINFO
108 /* Translate name of a service location and/or a service name to set of
109    socket addresses.
110    For more details, see the POSIX:2001 specification
111    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
112 extern int getaddrinfo (const char *restrict nodename,
113                         const char *restrict servname,
114                         const struct addrinfo *restrict hints,
115                         struct addrinfo **restrict res);
116 # endif
117
118 # if !HAVE_DECL_FREEADDRINFO
119 /* Free `addrinfo' structure AI including associated storage.
120    For more details, see the POSIX:2001 specification
121    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
122 extern void freeaddrinfo (struct addrinfo *ai);
123 # endif
124
125 # if !HAVE_DECL_GAI_STRERROR
126 /* Convert error return from getaddrinfo() to a string.
127    For more details, see the POSIX:2001 specification
128    <http://www.opengroup.org/susv3xsh/gai_strerror.html>.  */
129 extern const char *gai_strerror (int ecode);
130 # endif
131
132 # if !HAVE_DECL_GETNAMEINFO
133 /* Convert socket address to printable node and service names.
134    For more details, see the POSIX:2001 specification
135    <http://www.opengroup.org/susv3xsh/getnameinfo.html>.  */
136 extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
137                        char *restrict node, socklen_t nodelen,
138                        char *restrict service, socklen_t servicelen,
139                        int flags);
140
141 # endif
142
143 /* Possible flags for getnameinfo.  */
144 # ifndef NI_NUMERICHOST
145 #  define NI_NUMERICHOST 1
146 # endif
147 # ifndef NI_NUMERICSERV
148 #  define NI_NUMERICSERV 2
149 # endif
150
151 #endif /* GETADDRINFO_H */