1 |
1325 |
phoenix |
/* 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., 59 Temple Place, Suite 330, Boston, MA
|
17 |
|
|
02111-1307 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 _NETDB_H
|
24 |
|
|
#define _NETDB_H 1
|
25 |
|
|
|
26 |
|
|
#include <features.h>
|
27 |
|
|
|
28 |
|
|
#include <netinet/in.h>
|
29 |
|
|
#include <stdint.h>
|
30 |
|
|
#ifdef __USE_MISC
|
31 |
|
|
/* This is necessary to make this include file properly replace the
|
32 |
|
|
Sun version. */
|
33 |
|
|
# include <rpc/netdb.h>
|
34 |
|
|
#endif
|
35 |
|
|
|
36 |
|
|
#ifdef __USE_GNU
|
37 |
|
|
# define __need_sigevent_t
|
38 |
|
|
# include <bits/siginfo.h>
|
39 |
|
|
# define __need_timespec
|
40 |
|
|
# include <time.h>
|
41 |
|
|
#endif
|
42 |
|
|
|
43 |
|
|
#include <bits/netdb.h>
|
44 |
|
|
|
45 |
|
|
/* Absolute file name for network data base files. */
|
46 |
|
|
#define _PATH_HEQUIV "/etc/hosts.equiv"
|
47 |
|
|
#define _PATH_HOSTS "/etc/hosts"
|
48 |
|
|
#define _PATH_NETWORKS "/etc/networks"
|
49 |
|
|
#define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
|
50 |
|
|
#define _PATH_PROTOCOLS "/etc/protocols"
|
51 |
|
|
#define _PATH_SERVICES "/etc/services"
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
__BEGIN_DECLS
|
55 |
|
|
|
56 |
|
|
/* Error status for non-reentrant lookup functions. */
|
57 |
|
|
extern int h_errno;
|
58 |
|
|
|
59 |
|
|
/* Function to get address of global `h_errno' variable. */
|
60 |
|
|
extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
|
61 |
|
|
|
62 |
|
|
#ifdef _LIBC
|
63 |
|
|
# define __set_h_errno(x) (h_errno = (x))
|
64 |
|
|
#endif
|
65 |
|
|
|
66 |
|
|
#if defined __UCLIBC_HAS_THREADS__
|
67 |
|
|
/* Use a macro to access always the thread specific `h_errno' variable. */
|
68 |
|
|
# define h_errno (*__h_errno_location ())
|
69 |
|
|
#endif
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
/* Possible values left in `h_errno'. */
|
73 |
|
|
#define NETDB_INTERNAL -1 /* See errno. */
|
74 |
|
|
#define NETDB_SUCCESS 0 /* No problem. */
|
75 |
|
|
#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
|
76 |
|
|
#define TRY_AGAIN 2 /* Non-Authoritative Host not found,
|
77 |
|
|
or SERVERFAIL. */
|
78 |
|
|
#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
|
79 |
|
|
NOTIMP. */
|
80 |
|
|
#define NO_DATA 4 /* Valid name, no data record of requested
|
81 |
|
|
type. */
|
82 |
|
|
#define NO_ADDRESS NO_DATA /* No address, look for MX record. */
|
83 |
|
|
|
84 |
|
|
#ifdef __USE_XOPEN2K
|
85 |
|
|
/* Highest reserved Internet port number. */
|
86 |
|
|
# define IPPORT_RESERVED 1024
|
87 |
|
|
#endif
|
88 |
|
|
|
89 |
|
|
#ifdef __USE_GNU
|
90 |
|
|
/* Scope delimiter for getaddrinfo(), getnameinfo(). */
|
91 |
|
|
# define SCOPE_DELIMITER '%'
|
92 |
|
|
#endif
|
93 |
|
|
|
94 |
|
|
/* Print error indicated by `h_errno' variable on standard error. STR
|
95 |
|
|
if non-null is printed before the error string. */
|
96 |
|
|
extern void herror (__const char *__str) __THROW;
|
97 |
|
|
|
98 |
|
|
/* Return string associated with error ERR_NUM. */
|
99 |
|
|
extern __const char *hstrerror (int __err_num) __THROW;
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
/* Description of data base entry for a single host. */
|
104 |
|
|
struct hostent
|
105 |
|
|
{
|
106 |
|
|
char *h_name; /* Official name of host. */
|
107 |
|
|
char **h_aliases; /* Alias list. */
|
108 |
|
|
int h_addrtype; /* Host address type. */
|
109 |
|
|
int h_length; /* Length of address. */
|
110 |
|
|
char **h_addr_list; /* List of addresses from name server. */
|
111 |
|
|
#define h_addr h_addr_list[0] /* Address, for backward compatibility. */
|
112 |
|
|
};
|
113 |
|
|
|
114 |
|
|
/* Open host data base files and mark them as staying open even after
|
115 |
|
|
a later search if STAY_OPEN is non-zero. */
|
116 |
|
|
extern void sethostent (int __stay_open) __THROW;
|
117 |
|
|
|
118 |
|
|
/* Close host data base files and clear `stay open' flag. */
|
119 |
|
|
extern void endhostent (void) __THROW;
|
120 |
|
|
|
121 |
|
|
/* Get next entry from host data base file. Open data base if
|
122 |
|
|
necessary. */
|
123 |
|
|
extern struct hostent *gethostent (void) __THROW;
|
124 |
|
|
|
125 |
|
|
/* Return entry from host data base which address match ADDR with
|
126 |
|
|
length LEN and type TYPE. */
|
127 |
|
|
extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len,
|
128 |
|
|
int __type) __THROW;
|
129 |
|
|
|
130 |
|
|
/* Return entry from host data base for host with NAME. */
|
131 |
|
|
extern struct hostent *gethostbyname (__const char *__name) __THROW;
|
132 |
|
|
|
133 |
|
|
#ifdef __USE_MISC
|
134 |
|
|
/* Return entry from host data base for host with NAME. AF must be
|
135 |
|
|
set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
|
136 |
|
|
for IPv6. */
|
137 |
|
|
extern struct hostent *gethostbyname2 (__const char *__name, int __af) __THROW;
|
138 |
|
|
|
139 |
|
|
/* Reentrant versions of the functions above. The additional
|
140 |
|
|
arguments specify a buffer of BUFLEN starting at BUF. The last
|
141 |
|
|
argument is a pointer to a variable which gets the value which
|
142 |
|
|
would be stored in the global variable `herrno' by the
|
143 |
|
|
non-reentrant functions. */
|
144 |
|
|
extern int gethostent_r (struct hostent *__restrict __result_buf,
|
145 |
|
|
char *__restrict __buf, size_t __buflen,
|
146 |
|
|
struct hostent **__restrict __result,
|
147 |
|
|
int *__restrict __h_errnop) __THROW;
|
148 |
|
|
|
149 |
|
|
extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
|
150 |
|
|
int __type,
|
151 |
|
|
struct hostent *__restrict __result_buf,
|
152 |
|
|
char *__restrict __buf, size_t __buflen,
|
153 |
|
|
struct hostent **__restrict __result,
|
154 |
|
|
int *__restrict __h_errnop) __THROW;
|
155 |
|
|
|
156 |
|
|
extern int gethostbyname_r (__const char *__restrict __name,
|
157 |
|
|
struct hostent *__restrict __result_buf,
|
158 |
|
|
char *__restrict __buf, size_t __buflen,
|
159 |
|
|
struct hostent **__restrict __result,
|
160 |
|
|
int *__restrict __h_errnop) __THROW;
|
161 |
|
|
|
162 |
|
|
extern int gethostbyname2_r (__const char *__restrict __name, int __af,
|
163 |
|
|
struct hostent *__restrict __result_buf,
|
164 |
|
|
char *__restrict __buf, size_t __buflen,
|
165 |
|
|
struct hostent **__restrict __result,
|
166 |
|
|
int *__restrict __h_errnop) __THROW;
|
167 |
|
|
#endif /* misc */
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
/* Open network data base files and mark them as staying open even
|
171 |
|
|
after a later search if STAY_OPEN is non-zero. */
|
172 |
|
|
extern void setnetent (int __stay_open) __THROW;
|
173 |
|
|
|
174 |
|
|
/* Close network data base files and clear `stay open' flag. */
|
175 |
|
|
extern void endnetent (void) __THROW;
|
176 |
|
|
|
177 |
|
|
/* Get next entry from network data base file. Open data base if
|
178 |
|
|
necessary. */
|
179 |
|
|
extern struct netent *getnetent (void) __THROW;
|
180 |
|
|
|
181 |
|
|
/* Return entry from network data base which address match NET and
|
182 |
|
|
type TYPE. */
|
183 |
|
|
extern struct netent *getnetbyaddr (uint32_t __net, int __type)
|
184 |
|
|
__THROW;
|
185 |
|
|
|
186 |
|
|
/* Return entry from network data base for network with NAME. */
|
187 |
|
|
extern struct netent *getnetbyname (__const char *__name) __THROW;
|
188 |
|
|
|
189 |
|
|
#ifdef __USE_MISC
|
190 |
|
|
/* Reentrant versions of the functions above. The additional
|
191 |
|
|
arguments specify a buffer of BUFLEN starting at BUF. The last
|
192 |
|
|
argument is a pointer to a variable which gets the value which
|
193 |
|
|
would be stored in the global variable `herrno' by the
|
194 |
|
|
non-reentrant functions. */
|
195 |
|
|
extern int getnetent_r (struct netent *__restrict __result_buf,
|
196 |
|
|
char *__restrict __buf, size_t __buflen,
|
197 |
|
|
struct netent **__restrict __result,
|
198 |
|
|
int *__restrict __h_errnop) __THROW;
|
199 |
|
|
|
200 |
|
|
extern int getnetbyaddr_r (uint32_t __net, int __type,
|
201 |
|
|
struct netent *__restrict __result_buf,
|
202 |
|
|
char *__restrict __buf, size_t __buflen,
|
203 |
|
|
struct netent **__restrict __result,
|
204 |
|
|
int *__restrict __h_errnop) __THROW;
|
205 |
|
|
|
206 |
|
|
extern int getnetbyname_r (__const char *__restrict __name,
|
207 |
|
|
struct netent *__restrict __result_buf,
|
208 |
|
|
char *__restrict __buf, size_t __buflen,
|
209 |
|
|
struct netent **__restrict __result,
|
210 |
|
|
int *__restrict __h_errnop) __THROW;
|
211 |
|
|
#endif /* misc */
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
/* Description of data base entry for a single service. */
|
215 |
|
|
struct servent
|
216 |
|
|
{
|
217 |
|
|
char *s_name; /* Official service name. */
|
218 |
|
|
char **s_aliases; /* Alias list. */
|
219 |
|
|
int s_port; /* Port number. */
|
220 |
|
|
char *s_proto; /* Protocol to use. */
|
221 |
|
|
};
|
222 |
|
|
|
223 |
|
|
/* Open service data base files and mark them as staying open even
|
224 |
|
|
after a later search if STAY_OPEN is non-zero. */
|
225 |
|
|
extern void setservent (int __stay_open) __THROW;
|
226 |
|
|
|
227 |
|
|
/* Close service data base files and clear `stay open' flag. */
|
228 |
|
|
extern void endservent (void) __THROW;
|
229 |
|
|
|
230 |
|
|
/* Get next entry from service data base file. Open data base if
|
231 |
|
|
necessary. */
|
232 |
|
|
extern struct servent *getservent (void) __THROW;
|
233 |
|
|
|
234 |
|
|
/* Return entry from network data base for network with NAME and
|
235 |
|
|
protocol PROTO. */
|
236 |
|
|
extern struct servent *getservbyname (__const char *__name,
|
237 |
|
|
__const char *__proto) __THROW;
|
238 |
|
|
|
239 |
|
|
/* Return entry from service data base which matches port PORT and
|
240 |
|
|
protocol PROTO. */
|
241 |
|
|
extern struct servent *getservbyport (int __port, __const char *__proto)
|
242 |
|
|
__THROW;
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
#ifdef __USE_MISC
|
246 |
|
|
/* Reentrant versions of the functions above. The additional
|
247 |
|
|
arguments specify a buffer of BUFLEN starting at BUF. */
|
248 |
|
|
extern int getservent_r (struct servent *__restrict __result_buf,
|
249 |
|
|
char *__restrict __buf, size_t __buflen,
|
250 |
|
|
struct servent **__restrict __result) __THROW;
|
251 |
|
|
|
252 |
|
|
extern int getservbyname_r (__const char *__restrict __name,
|
253 |
|
|
__const char *__restrict __proto,
|
254 |
|
|
struct servent *__restrict __result_buf,
|
255 |
|
|
char *__restrict __buf, size_t __buflen,
|
256 |
|
|
struct servent **__restrict __result) __THROW;
|
257 |
|
|
|
258 |
|
|
extern int getservbyport_r (int __port, __const char *__restrict __proto,
|
259 |
|
|
struct servent *__restrict __result_buf,
|
260 |
|
|
char *__restrict __buf, size_t __buflen,
|
261 |
|
|
struct servent **__restrict __result) __THROW;
|
262 |
|
|
#endif /* misc */
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
/* Description of data base entry for a single service. */
|
266 |
|
|
struct protoent
|
267 |
|
|
{
|
268 |
|
|
char *p_name; /* Official protocol name. */
|
269 |
|
|
char **p_aliases; /* Alias list. */
|
270 |
|
|
int p_proto; /* Protocol number. */
|
271 |
|
|
};
|
272 |
|
|
|
273 |
|
|
/* Open protocol data base files and mark them as staying open even
|
274 |
|
|
after a later search if STAY_OPEN is non-zero. */
|
275 |
|
|
extern void setprotoent (int __stay_open) __THROW;
|
276 |
|
|
|
277 |
|
|
/* Close protocol data base files and clear `stay open' flag. */
|
278 |
|
|
extern void endprotoent (void) __THROW;
|
279 |
|
|
|
280 |
|
|
/* Get next entry from protocol data base file. Open data base if
|
281 |
|
|
necessary. */
|
282 |
|
|
extern struct protoent *getprotoent (void) __THROW;
|
283 |
|
|
|
284 |
|
|
/* Return entry from protocol data base for network with NAME. */
|
285 |
|
|
extern struct protoent *getprotobyname (__const char *__name) __THROW;
|
286 |
|
|
|
287 |
|
|
/* Return entry from protocol data base which number is PROTO. */
|
288 |
|
|
extern struct protoent *getprotobynumber (int __proto) __THROW;
|
289 |
|
|
|
290 |
|
|
|
291 |
|
|
#ifdef __USE_MISC
|
292 |
|
|
/* Reentrant versions of the functions above. The additional
|
293 |
|
|
arguments specify a buffer of BUFLEN starting at BUF. */
|
294 |
|
|
extern int getprotoent_r (struct protoent *__restrict __result_buf,
|
295 |
|
|
char *__restrict __buf, size_t __buflen,
|
296 |
|
|
struct protoent **__restrict __result) __THROW;
|
297 |
|
|
|
298 |
|
|
extern int getprotobyname_r (__const char *__restrict __name,
|
299 |
|
|
struct protoent *__restrict __result_buf,
|
300 |
|
|
char *__restrict __buf, size_t __buflen,
|
301 |
|
|
struct protoent **__restrict __result) __THROW;
|
302 |
|
|
|
303 |
|
|
extern int getprotobynumber_r (int __proto,
|
304 |
|
|
struct protoent *__restrict __result_buf,
|
305 |
|
|
char *__restrict __buf, size_t __buflen,
|
306 |
|
|
struct protoent **__restrict __result) __THROW;
|
307 |
|
|
#endif /* misc */
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
/* Establish network group NETGROUP for enumeration. */
|
311 |
|
|
extern int setnetgrent (__const char *__netgroup) __THROW;
|
312 |
|
|
|
313 |
|
|
/* Free all space allocated by previous `setnetgrent' call. */
|
314 |
|
|
extern void endnetgrent (void) __THROW;
|
315 |
|
|
|
316 |
|
|
/* Get next member of netgroup established by last `setnetgrent' call
|
317 |
|
|
and return pointers to elements in HOSTP, USERP, and DOMAINP. */
|
318 |
|
|
extern int getnetgrent (char **__restrict __hostp,
|
319 |
|
|
char **__restrict __userp,
|
320 |
|
|
char **__restrict __domainp) __THROW;
|
321 |
|
|
|
322 |
|
|
#ifdef __USE_MISC
|
323 |
|
|
/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN). */
|
324 |
|
|
extern int innetgr (__const char *__netgroup, __const char *__host,
|
325 |
|
|
__const char *__user, __const char *domain) __THROW;
|
326 |
|
|
|
327 |
|
|
/* Reentrant version of `getnetgrent' where result is placed in BUFFER. */
|
328 |
|
|
extern int getnetgrent_r (char **__restrict __hostp,
|
329 |
|
|
char **__restrict __userp,
|
330 |
|
|
char **__restrict __domainp,
|
331 |
|
|
char *__restrict __buffer, size_t __buflen) __THROW;
|
332 |
|
|
#endif /* misc */
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
#ifdef __USE_BSD
|
336 |
|
|
/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
|
337 |
|
|
The local user is LOCUSER, on the remote machine the command is
|
338 |
|
|
executed as REMUSER. In *FD2P the descriptor to the socket for the
|
339 |
|
|
connection is returned. The caller must have the right to use a
|
340 |
|
|
reserved port. When the function returns *AHOST contains the
|
341 |
|
|
official host name. */
|
342 |
|
|
extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
|
343 |
|
|
__const char *__restrict __locuser,
|
344 |
|
|
__const char *__restrict __remuser,
|
345 |
|
|
__const char *__restrict __cmd, int *__restrict __fd2p)
|
346 |
|
|
__THROW;
|
347 |
|
|
|
348 |
|
|
/* This is the equivalent function where the protocol can be selected
|
349 |
|
|
and which therefore can be used for IPv6. */
|
350 |
|
|
extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
|
351 |
|
|
__const char *__restrict __locuser,
|
352 |
|
|
__const char *__restrict __remuser,
|
353 |
|
|
__const char *__restrict __cmd, int *__restrict __fd2p,
|
354 |
|
|
sa_family_t __af) __THROW;
|
355 |
|
|
|
356 |
|
|
/* Call `rexecd' at port RPORT on remote machine *AHOST to execute
|
357 |
|
|
CMD. The process runs at the remote machine using the ID of user
|
358 |
|
|
NAME whose cleartext password is PASSWD. In *FD2P the descriptor
|
359 |
|
|
to the socket for the connection is returned. When the function
|
360 |
|
|
returns *AHOST contains the official host name. */
|
361 |
|
|
extern int rexec (char **__restrict __ahost, int __rport,
|
362 |
|
|
__const char *__restrict __name,
|
363 |
|
|
__const char *__restrict __pass,
|
364 |
|
|
__const char *__restrict __cmd, int *__restrict __fd2p)
|
365 |
|
|
__THROW;
|
366 |
|
|
|
367 |
|
|
/* This is the equivalent function where the protocol can be selected
|
368 |
|
|
and which therefore can be used for IPv6. */
|
369 |
|
|
extern int rexec_af (char **__restrict __ahost, int __rport,
|
370 |
|
|
__const char *__restrict __name,
|
371 |
|
|
__const char *__restrict __pass,
|
372 |
|
|
__const char *__restrict __cmd, int *__restrict __fd2p,
|
373 |
|
|
sa_family_t __af) __THROW;
|
374 |
|
|
|
375 |
|
|
/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
|
376 |
|
|
If SUSER is not zero the user tries to become superuser. Return 0 if
|
377 |
|
|
it is possible. */
|
378 |
|
|
extern int ruserok (__const char *__rhost, int __suser,
|
379 |
|
|
__const char *__remuser, __const char *__locuser) __THROW;
|
380 |
|
|
|
381 |
|
|
/* This is the equivalent function where the protocol can be selected
|
382 |
|
|
and which therefore can be used for IPv6. */
|
383 |
|
|
extern int ruserok_af (__const char *__rhost, int __suser,
|
384 |
|
|
__const char *__remuser, __const char *__locuser,
|
385 |
|
|
sa_family_t __af) __THROW;
|
386 |
|
|
|
387 |
|
|
/* Try to allocate reserved port, returning a descriptor for a socket opened
|
388 |
|
|
at this port or -1 if unsuccessful. The search for an available port
|
389 |
|
|
will start at ALPORT and continues with lower numbers. */
|
390 |
|
|
extern int rresvport (int *__alport) __THROW;
|
391 |
|
|
|
392 |
|
|
/* This is the equivalent function where the protocol can be selected
|
393 |
|
|
and which therefore can be used for IPv6. */
|
394 |
|
|
extern int rresvport_af (int *__alport, sa_family_t __af) __THROW;
|
395 |
|
|
#endif
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
/* Extension from POSIX.1g. */
|
399 |
|
|
#ifdef __USE_POSIX
|
400 |
|
|
/* Structure to contain information about address of a service provider. */
|
401 |
|
|
struct addrinfo
|
402 |
|
|
{
|
403 |
|
|
int ai_flags; /* Input flags. */
|
404 |
|
|
int ai_family; /* Protocol family for socket. */
|
405 |
|
|
int ai_socktype; /* Socket type. */
|
406 |
|
|
int ai_protocol; /* Protocol for socket. */
|
407 |
|
|
socklen_t ai_addrlen; /* Length of socket address. */
|
408 |
|
|
struct sockaddr *ai_addr; /* Socket address for socket. */
|
409 |
|
|
char *ai_canonname; /* Canonical name for service location. */
|
410 |
|
|
struct addrinfo *ai_next; /* Pointer to next in list. */
|
411 |
|
|
};
|
412 |
|
|
|
413 |
|
|
# ifdef __USE_GNU
|
414 |
|
|
/* Structure used as control block for asynchronous lookup. */
|
415 |
|
|
struct gaicb
|
416 |
|
|
{
|
417 |
|
|
const char *ar_name; /* Name to look up. */
|
418 |
|
|
const char *ar_service; /* Service name. */
|
419 |
|
|
const struct addrinfo *ar_request; /* Additional request specification. */
|
420 |
|
|
struct addrinfo *ar_result; /* Pointer to result. */
|
421 |
|
|
/* The following are internal elements. */
|
422 |
|
|
int __return;
|
423 |
|
|
int __unused[5];
|
424 |
|
|
};
|
425 |
|
|
|
426 |
|
|
/* Lookup mode. */
|
427 |
|
|
# define GAI_WAIT 0
|
428 |
|
|
# define GAI_NOWAIT 1
|
429 |
|
|
# endif
|
430 |
|
|
|
431 |
|
|
/* Possible values for `ai_flags' field in `addrinfo' structure. */
|
432 |
|
|
# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
|
433 |
|
|
# define AI_CANONNAME 0x0002 /* Request for canonical name. */
|
434 |
|
|
# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
|
435 |
|
|
|
436 |
|
|
/* Error values for `getaddrinfo' function. */
|
437 |
|
|
# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
|
438 |
|
|
# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
|
439 |
|
|
# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
|
440 |
|
|
# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
|
441 |
|
|
# define EAI_NODATA -5 /* No address associated with NAME. */
|
442 |
|
|
# define EAI_FAMILY -6 /* `ai_family' not supported. */
|
443 |
|
|
# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
|
444 |
|
|
# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
|
445 |
|
|
# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
|
446 |
|
|
# define EAI_MEMORY -10 /* Memory allocation failure. */
|
447 |
|
|
# define EAI_SYSTEM -11 /* System error returned in `errno'. */
|
448 |
|
|
# ifdef __USE_GNU
|
449 |
|
|
# define EAI_INPROGRESS -100 /* Processing request in progress. */
|
450 |
|
|
# define EAI_CANCELED -101 /* Request canceled. */
|
451 |
|
|
# define EAI_NOTCANCELED -102 /* Request not canceled. */
|
452 |
|
|
# define EAI_ALLDONE -103 /* All requests done. */
|
453 |
|
|
# define EAI_INTR -104 /* Interrupted by a signal. */
|
454 |
|
|
# endif
|
455 |
|
|
|
456 |
|
|
# define NI_MAXHOST 1025
|
457 |
|
|
# define NI_MAXSERV 32
|
458 |
|
|
|
459 |
|
|
# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
|
460 |
|
|
# define NI_NUMERICSERV 2 /* Don't convert port number to name. */
|
461 |
|
|
# define NI_NOFQDN 4 /* Only return nodename portion. */
|
462 |
|
|
# define NI_NAMEREQD 8 /* Don't return numeric addresses. */
|
463 |
|
|
# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
|
464 |
|
|
|
465 |
|
|
/* Translate name of a service location and/or a service name to set of
|
466 |
|
|
socket addresses. */
|
467 |
|
|
extern int getaddrinfo (__const char *__restrict __name,
|
468 |
|
|
__const char *__restrict __service,
|
469 |
|
|
__const struct addrinfo *__restrict __req,
|
470 |
|
|
struct addrinfo **__restrict __pai) __THROW;
|
471 |
|
|
|
472 |
|
|
/* Free `addrinfo' structure AI including associated storage. */
|
473 |
|
|
extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
|
474 |
|
|
|
475 |
|
|
/* Convert error return from getaddrinfo() to a string. */
|
476 |
|
|
extern __const char *gai_strerror (int __ecode) __THROW;
|
477 |
|
|
|
478 |
|
|
/* Translate a socket address to a location and service name. */
|
479 |
|
|
extern int getnameinfo (__const struct sockaddr *__restrict __sa,
|
480 |
|
|
socklen_t __salen, char *__restrict __host,
|
481 |
|
|
socklen_t __hostlen, char *__restrict __serv,
|
482 |
|
|
socklen_t __servlen, unsigned int __flags) __THROW;
|
483 |
|
|
|
484 |
|
|
# ifdef __USE_GNU
|
485 |
|
|
/* Enqueue ENT requests from the LIST. If MODE is GAI_WAIT wait until all
|
486 |
|
|
requests are handled. If WAIT is GAI_NOWAIT return immediately after
|
487 |
|
|
queueing the requests and signal completion according to SIG. */
|
488 |
|
|
extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict_arr],
|
489 |
|
|
int __ent, struct sigevent *__restrict __sig)
|
490 |
|
|
__THROW;
|
491 |
|
|
|
492 |
|
|
/* Suspend execution of the thread until at least one of the ENT requests
|
493 |
|
|
in LIST is handled. If TIMEOUT is not a null pointer it specifies the
|
494 |
|
|
longest time the function keeps waiting before returning with an error. */
|
495 |
|
|
extern int gai_suspend (__const struct gaicb *__const __list[], int __ent,
|
496 |
|
|
__const struct timespec *__timeout) __THROW;
|
497 |
|
|
|
498 |
|
|
/* Get the error status of the request REQ. */
|
499 |
|
|
extern int gai_error (struct gaicb *__req) __THROW;
|
500 |
|
|
|
501 |
|
|
/* Cancel the requests associated with GAICBP. */
|
502 |
|
|
extern int gai_cancel (struct gaicb *__gaicbp) __THROW;
|
503 |
|
|
# endif /* GNU */
|
504 |
|
|
#endif /* POSIX */
|
505 |
|
|
|
506 |
|
|
__END_DECLS
|
507 |
|
|
|
508 |
|
|
#endif /* netdb.h */
|