Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / third_party / newlib-extras / netdb.h
blobad14f19f30e81c3058ba35ed91651aa551643b6e
1 /*-
2 * Copyright (c) 1980, 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * -
30 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
32 * Permission to use, copy, modify, and distribute this software for any
33 * purpose with or without fee is hereby granted, provided that the above
34 * copyright notice and this permission notice appear in all copies, and that
35 * the name of Digital Equipment Corporation not be used in advertising or
36 * publicity pertaining to distribution of the document or software without
37 * specific, written prior permission.
39 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
40 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
41 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
42 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
43 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
44 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
45 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 * SOFTWARE.
47 * -
48 * --Copyright--
52 * @(#)netdb.h 8.1 (Berkeley) 6/2/93
53 * From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $
54 * $FreeBSD: src/include/netdb.h,v 1.23 2002/03/23 17:24:53 imp Exp $
57 #ifndef _NETDB_H_
58 #define _NETDB_H_
60 #include <sys/cdefs.h>
61 #include <sys/types.h>
62 #include <machine/ansi.h>
63 #include <stdint.h>
64 #include <stdio.h>
66 #ifndef __socklen_t_defined
67 typedef unsigned int socklen_t;
68 #define __socklen_t_defined 1
69 #endif
71 #ifdef _BSD_SOCKLEN_T_
72 typedef _BSD_SOCKLEN_T_ socklen_t;
73 #undef _BSD_SOCKLEN_T_
74 #endif
76 #ifndef _PATH_HEQUIV
77 # define _PATH_HEQUIV "/etc/hosts.equiv"
78 #endif
79 #define _PATH_HOSTS "/etc/hosts"
80 #define _PATH_NETWORKS "/etc/networks"
81 #define _PATH_PROTOCOLS "/etc/protocols"
82 #define _PATH_SERVICES "/etc/services"
83 #define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
85 __BEGIN_DECLS
86 extern int *__h_errno_location(void);
87 __END_DECLS
89 #define h_errno (*(__h_errno_location()))
91 #define MAXALIASES 35
92 /* For now, only support one return address. */
93 #define MAXADDRS 2
95 * Structures returned by network data base library. All addresses are
96 * supplied in host order, and returned in network order (suitable for
97 * use in system calls).
99 struct hostent {
100 char *h_name; /* official name of host */
101 char **h_aliases; /* alias list */
102 int h_addrtype; /* host address type */
103 int h_length; /* length of address */
104 char **h_addr_list; /* list of addresses from name server */
105 char *h_addr; /* address, for backward compatibility */
106 /* private data, for re-entrancy */
107 char *__host_addrs[MAXADDRS];
108 char *__host_aliases[MAXALIASES];
109 unsigned int __host_addr[4];
113 * Assumption here is that a network number
114 * fits in an unsigned long -- probably a poor one.
116 struct netent {
117 char *n_name; /* official name of net */
118 char **n_aliases; /* alias list */
119 int n_addrtype; /* net address type */
120 unsigned long n_net; /* network # */
123 struct servent {
124 char *s_name; /* official service name */
125 char **s_aliases; /* alias list */
126 int s_port; /* port # */
127 char *s_proto; /* protocol to use */
130 struct protoent {
131 char *p_name; /* official protocol name */
132 char **p_aliases; /* alias list */
133 int p_proto; /* protocol # */
136 struct addrinfo {
137 int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
138 int ai_family; /* PF_xxx */
139 int ai_socktype; /* SOCK_xxx */
140 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
141 size_t ai_addrlen; /* length of ai_addr */
142 char *ai_canonname; /* canonical name for hostname */
143 struct sockaddr *ai_addr; /* binary address */
144 struct addrinfo *ai_next; /* next structure in linked list */
148 * Error return codes from gethostbyname() and gethostbyaddr()
149 * (left in extern int h_errno).
152 #define NETDB_INTERNAL -1 /* see errno */
153 #define NETDB_SUCCESS 0 /* no problem */
154 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
155 #define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */
156 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
157 #define NO_DATA 4 /* Valid name, no data record of requested type */
158 #define NO_ADDRESS NO_DATA /* no address, look for MX record */
161 * Error return codes from getaddrinfo()
163 /* Error values for `getaddrinfo' function. */
164 # define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
165 # define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
166 # define EAI_AGAIN -3 /* Temporary failure in name resolution. */
167 # define EAI_FAIL -4 /* Non-recoverable failure in name res. */
168 # define EAI_NODATA -5 /* No address associated with NAME. */
169 # define EAI_FAMILY -6 /* `ai_family' not supported. */
170 # define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
171 # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
172 # define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
173 # define EAI_MEMORY -10 /* Memory allocation failure. */
174 # define EAI_SYSTEM -11 /* System error returned in `errno'. */
175 # define EAI_OVERFLOW -12 /* Argument buffer overflow. */
176 # ifdef __USE_GNU
177 # define EAI_INPROGRESS -100 /* Processing request in progress. */
178 # define EAI_CANCELED -101 /* Request canceled. */
179 # define EAI_NOTCANCELED -102 /* Request not canceled. */
180 # define EAI_ALLDONE -103 /* All requests done. */
181 # define EAI_INTR -104 /* Interrupted by a signal. */
182 # define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
183 # endif
186 * Flag values for getaddrinfo()
188 #define AI_PASSIVE 0x00000001 /* get address to use bind() */
189 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */
190 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
191 #define AI_NUMERICSERV 0x00000008 /* don't use name resolution. */
192 /* valid flags for addrinfo */
193 #define AI_MASK \
194 (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ADDRCONFIG)
196 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
197 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
198 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
199 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
200 /* special recommended flags for getipnodebyname */
201 #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
204 * Constants for getnameinfo()
206 #define NI_MAXHOST 1025
207 #define NI_MAXSERV 32
210 * Flag values for getnameinfo()
212 #define NI_NOFQDN 0x00000001
213 #define NI_NUMERICHOST 0x00000002
214 #define NI_NAMEREQD 0x00000004
215 #define NI_NUMERICSERV 0x00000008
216 #define NI_DGRAM 0x00000010
217 #define NI_WITHSCOPEID 0x00000020
220 * Scope delimit character
222 #define SCOPE_DELIMITER '%'
224 __BEGIN_DECLS
225 void endhostent(void);
226 void endhostent_r(FILE **, int *);
227 void endnetent(void);
228 void endnetgrent(void);
229 void endprotoent(void);
230 void endservent(void);
231 void freehostent(struct hostent *);
232 struct hostent *gethostbyaddr(const void *, socklen_t, int);
233 struct hostent *gethostbyname(const char *);
234 struct hostent *gethostbyname2(const char *, int);
235 struct hostent *gethostent(void);
236 int gethostent_r(struct hostent *, char *, int, int *, FILE **);
237 struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
238 struct hostent *getipnodebyname(const char *, int, int, int *);
239 struct netent *getnetbyaddr(uint32_t, int);
240 struct netent *getnetbyname(const char *);
241 struct netent *getnetent(void);
242 int getnetgrent(char **, char **, char **);
243 struct protoent *getprotobyname(const char *);
244 struct protoent *getprotobynumber(int);
245 struct protoent *getprotoent(void);
246 struct servent *getservbyname(const char *, const char *);
247 struct servent *getservbyport(int, const char *);
248 struct servent *getservent(void);
249 void herror(const char *);
250 __const char *hstrerror(int);
251 int innetgr(const char *, const char *, const char *, const char *);
252 void sethostent(int);
253 void sethostent_r(int, FILE **, int *);
254 /* void sethostfile(const char *); */
255 void setnetent(int);
256 void setprotoent(int);
257 int getaddrinfo(const char *__restrict, const char *__restrict,
258 const struct addrinfo *__restrict,
259 struct addrinfo **__restrict);
260 int getnameinfo(const struct sockaddr *__restrict, socklen_t,
261 char *__restrict, socklen_t, char *__restrict,
262 socklen_t, unsigned int);
263 void freeaddrinfo(struct addrinfo *);
264 char *gai_strerror(int);
265 int setnetgrent(const char *);
266 void setservent(int);
269 * PRIVATE functions specific to the FreeBSD implementation
272 /* DO NOT USE THESE, THEY ARE SUBJECT TO CHANGE AND ARE NOT PORTABLE!!! */
273 void _sethosthtent(int);
274 void _sethosthtent_r(int, FILE **, int *);
275 void _endhosthtent(void);
276 void _endhosthtent_r(FILE **, int *);
277 void _sethostdnsent(int);
278 void _endhostdnsent(void);
279 void _setnethtent(int);
280 void _endnethtent(void);
281 void _setnetdnsent(int);
282 void _endnetdnsent(void);
283 struct hostent * _gethostbynisname(const char *, int);
284 struct hostent * _gethostbynisaddr(const char *, int, int);
285 void _map_v4v6_address(const char *, char *);
286 void _map_v4v6_hostent(struct hostent *, char **, int *);
287 __END_DECLS
289 #endif /* !_NETDB_H_ */