]> git.ipfire.org Git - thirdparty/glibc.git/blame - resolv/netdb.h
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / resolv / netdb.h
CommitLineData
04277e02 1 /* Copyright (C) 1996-2019 Free Software Foundation, Inc.
23396375 2 This file is part of the GNU C Library.
3d61b63c 3
41bdb6e2
AJ
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
23396375 6 License as published by the Free Software Foundation; either
41bdb6e2 7 version 2.1 of the License, or (at your option) any later version.
23396375 8
41bdb6e2
AJ
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.
23396375 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
23396375
UD
17
18/* All data returned by the network data base library are supplied in
19 host order and returned in network order (suitable for use in
20 system calls). */
21
22#ifndef _NETDB_H
23396375 23#define _NETDB_H 1
5107cf1d 24
23396375
UD
25#include <features.h>
26
ccd4b479 27#include <netinet/in.h>
17680430 28#include <bits/stdint-uintn.h>
597df647
AS
29#ifdef __USE_MISC
30/* This is necessary to make this include file properly replace the
31 Sun version. */
32# include <rpc/netdb.h>
33#endif
9b48fa9b 34
2ace5721 35#ifdef __USE_GNU
a992f506 36# include <bits/types/sigevent_t.h>
05b68e14 37# include <bits/types/struct_timespec.h>
2ace5721
UD
38#endif
39
9b48fa9b
UD
40#include <bits/netdb.h>
41
23396375 42/* Absolute file name for network data base files. */
5f0e6fc7
RM
43#define _PATH_HEQUIV "/etc/hosts.equiv"
44#define _PATH_HOSTS "/etc/hosts"
45#define _PATH_NETWORKS "/etc/networks"
46#define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
47#define _PATH_PROTOCOLS "/etc/protocols"
48#define _PATH_SERVICES "/etc/services"
28f540f4 49
23396375
UD
50
51__BEGIN_DECLS
52
52e2ea9a 53#if defined __USE_MISC || !defined __USE_XOPEN2K8
ed4d0184
RM
54/* Error status for non-reentrant lookup functions.
55 We use a macro to access always the thread-specific `h_errno' variable. */
63ee8410 56# define h_errno (*__h_errno_location ())
3d61b63c 57
ba1ffaa1 58/* Function to get address of global `h_errno' variable. */
c1422e5b 59extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
edf5b2d7 60
ba1ffaa1 61
23396375 62/* Possible values left in `h_errno'. */
63ee8410
UD
63# define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
64# define TRY_AGAIN 2 /* Non-Authoritative Host not found,
23396375 65 or SERVERFAIL. */
63ee8410 66# define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
23396375 67 NOTIMP. */
63ee8410 68# define NO_DATA 4 /* Valid name, no data record of requested
23396375 69 type. */
505cf2c0 70#endif
acd7f096 71#ifdef __USE_MISC
a53d3f82
UD
72# define NETDB_INTERNAL -1 /* See errno. */
73# define NETDB_SUCCESS 0 /* No problem. */
74# define NO_ADDRESS NO_DATA /* No address, look for MX record. */
75#endif
23396375 76
8ca89318 77#if defined __USE_XOPEN2K || defined __USE_XOPEN_EXTENDED
ccd4b479
UD
78/* Highest reserved Internet port number. */
79# define IPPORT_RESERVED 1024
80#endif
81
c0bc5f7b
UD
82#ifdef __USE_GNU
83/* Scope delimiter for getaddrinfo(), getnameinfo(). */
84# define SCOPE_DELIMITER '%'
85#endif
86
52e2ea9a 87#ifdef __USE_MISC
23396375
UD
88/* Print error indicated by `h_errno' variable on standard error. STR
89 if non-null is printed before the error string. */
a784e502 90extern void herror (const char *__str) __THROW;
23396375
UD
91
92/* Return string associated with error ERR_NUM. */
a784e502 93extern const char *hstrerror (int __err_num) __THROW;
a53d3f82 94#endif
28f540f4 95
23396375
UD
96
97/* Description of data base entry for a single host. */
98struct hostent
99{
100 char *h_name; /* Official name of host. */
101 char **h_aliases; /* Alias list. */
102 int h_addrtype; /* Host address type. */
ccd4b479 103 int h_length; /* Length of address. */
23396375 104 char **h_addr_list; /* List of addresses from name server. */
acd7f096 105#ifdef __USE_MISC
a53d3f82
UD
106# define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
107#endif
28f540f4
RM
108};
109
23396375 110/* Open host data base files and mark them as staying open even after
2c008571 111 a later search if STAY_OPEN is non-zero.
23396375 112
2c008571
UD
113 This function is a possible cancellation point and therefore not
114 marked with __THROW. */
115extern void sethostent (int __stay_open);
116
117/* Close host data base files and clear `stay open' flag.
118
119 This function is a possible cancellation point and therefore not
120 marked with __THROW. */
121extern void endhostent (void);
23396375
UD
122
123/* Get next entry from host data base file. Open data base if
2c008571
UD
124 necessary.
125
126 This function is a possible cancellation point and therefore not
127 marked with __THROW. */
128extern struct hostent *gethostent (void);
23396375
UD
129
130/* Return entry from host data base which address match ADDR with
2c008571
UD
131 length LEN and type TYPE.
132
133 This function is a possible cancellation point and therefore not
134 marked with __THROW. */
a784e502 135extern struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len,
2c008571 136 int __type);
23396375 137
2c008571
UD
138/* Return entry from host data base for host with NAME.
139
140 This function is a possible cancellation point and therefore not
141 marked with __THROW. */
a784e502 142extern struct hostent *gethostbyname (const char *__name);
23396375 143
ad483238 144#ifdef __USE_MISC
23396375 145/* Return entry from host data base for host with NAME. AF must be
4bca4c17 146 set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
2c008571
UD
147 for IPv6.
148
149 This function is not part of POSIX and therefore no official
150 cancellation point. But due to similarity with an POSIX interface
151 or due to the implementation it is a cancellation point and
152 therefore not marked with __THROW. */
a784e502 153extern struct hostent *gethostbyname2 (const char *__name, int __af);
c132cb59 154
23396375
UD
155/* Reentrant versions of the functions above. The additional
156 arguments specify a buffer of BUFLEN starting at BUF. The last
157 argument is a pointer to a variable which gets the value which
158 would be stored in the global variable `herrno' by the
2c008571
UD
159 non-reentrant functions.
160
161 These functions are not part of POSIX and therefore no official
162 cancellation point. But due to similarity with an POSIX interface
163 or due to the implementation they are cancellation points and
164 therefore not marked with __THROW. */
c1422e5b
UD
165extern int gethostent_r (struct hostent *__restrict __result_buf,
166 char *__restrict __buf, size_t __buflen,
167 struct hostent **__restrict __result,
2c008571 168 int *__restrict __h_errnop);
c1422e5b 169
a784e502 170extern int gethostbyaddr_r (const void *__restrict __addr, __socklen_t __len,
c1422e5b
UD
171 int __type,
172 struct hostent *__restrict __result_buf,
173 char *__restrict __buf, size_t __buflen,
174 struct hostent **__restrict __result,
2c008571 175 int *__restrict __h_errnop);
c1422e5b 176
a784e502 177extern int gethostbyname_r (const char *__restrict __name,
c1422e5b
UD
178 struct hostent *__restrict __result_buf,
179 char *__restrict __buf, size_t __buflen,
180 struct hostent **__restrict __result,
2c008571 181 int *__restrict __h_errnop);
c1422e5b 182
a784e502 183extern int gethostbyname2_r (const char *__restrict __name, int __af,
c1422e5b
UD
184 struct hostent *__restrict __result_buf,
185 char *__restrict __buf, size_t __buflen,
186 struct hostent **__restrict __result,
2c008571 187 int *__restrict __h_errnop);
19361cb7 188#endif /* misc */
23396375
UD
189
190
23396375 191/* Open network data base files and mark them as staying open even
2c008571 192 after a later search if STAY_OPEN is non-zero.
23396375 193
2c008571
UD
194 This function is a possible cancellation point and therefore not
195 marked with __THROW. */
196extern void setnetent (int __stay_open);
197
198/* Close network data base files and clear `stay open' flag.
199
200 This function is a possible cancellation point and therefore not
201 marked with __THROW. */
202extern void endnetent (void);
23396375
UD
203
204/* Get next entry from network data base file. Open data base if
2c008571
UD
205 necessary.
206
207 This function is a possible cancellation point and therefore not
208 marked with __THROW. */
209extern struct netent *getnetent (void);
23396375
UD
210
211/* Return entry from network data base which address match NET and
2c008571 212 type TYPE.
23396375 213
2c008571
UD
214 This function is a possible cancellation point and therefore not
215 marked with __THROW. */
216extern struct netent *getnetbyaddr (uint32_t __net, int __type);
217
218/* Return entry from network data base for network with NAME.
219
220 This function is a possible cancellation point and therefore not
221 marked with __THROW. */
a784e502 222extern struct netent *getnetbyname (const char *__name);
23396375 223
19361cb7 224#ifdef __USE_MISC
23396375
UD
225/* Reentrant versions of the functions above. The additional
226 arguments specify a buffer of BUFLEN starting at BUF. The last
227 argument is a pointer to a variable which gets the value which
228 would be stored in the global variable `herrno' by the
2c008571
UD
229 non-reentrant functions.
230
231 These functions are not part of POSIX and therefore no official
232 cancellation point. But due to similarity with an POSIX interface
233 or due to the implementation they are cancellation points and
234 therefore not marked with __THROW. */
c1422e5b
UD
235extern int getnetent_r (struct netent *__restrict __result_buf,
236 char *__restrict __buf, size_t __buflen,
237 struct netent **__restrict __result,
2c008571 238 int *__restrict __h_errnop);
c1422e5b 239
9b48fa9b 240extern int getnetbyaddr_r (uint32_t __net, int __type,
c1422e5b
UD
241 struct netent *__restrict __result_buf,
242 char *__restrict __buf, size_t __buflen,
243 struct netent **__restrict __result,
2c008571 244 int *__restrict __h_errnop);
c1422e5b 245
a784e502 246extern int getnetbyname_r (const char *__restrict __name,
c1422e5b
UD
247 struct netent *__restrict __result_buf,
248 char *__restrict __buf, size_t __buflen,
249 struct netent **__restrict __result,
2c008571 250 int *__restrict __h_errnop);
19361cb7 251#endif /* misc */
23396375
UD
252
253
254/* Description of data base entry for a single service. */
255struct servent
256{
257 char *s_name; /* Official service name. */
258 char **s_aliases; /* Alias list. */
259 int s_port; /* Port number. */
260 char *s_proto; /* Protocol to use. */
28f540f4
RM
261};
262
23396375 263/* Open service data base files and mark them as staying open even
2c008571 264 after a later search if STAY_OPEN is non-zero.
28f540f4 265
2c008571
UD
266 This function is a possible cancellation point and therefore not
267 marked with __THROW. */
268extern void setservent (int __stay_open);
269
270/* Close service data base files and clear `stay open' flag.
271
272 This function is a possible cancellation point and therefore not
273 marked with __THROW. */
274extern void endservent (void);
28f540f4 275
23396375 276/* Get next entry from service data base file. Open data base if
2c008571
UD
277 necessary.
278
279 This function is a possible cancellation point and therefore not
280 marked with __THROW. */
281extern struct servent *getservent (void);
28f540f4 282
23396375 283/* Return entry from network data base for network with NAME and
2c008571
UD
284 protocol PROTO.
285
286 This function is a possible cancellation point and therefore not
287 marked with __THROW. */
a784e502 288extern struct servent *getservbyname (const char *__name, const char *__proto);
23396375
UD
289
290/* Return entry from service data base which matches port PORT and
2c008571
UD
291 protocol PROTO.
292
293 This function is a possible cancellation point and therefore not
294 marked with __THROW. */
a784e502 295extern struct servent *getservbyport (int __port, const char *__proto);
23396375
UD
296
297
19361cb7 298#ifdef __USE_MISC
23396375 299/* Reentrant versions of the functions above. The additional
2c008571
UD
300 arguments specify a buffer of BUFLEN starting at BUF.
301
302 These functions are not part of POSIX and therefore no official
303 cancellation point. But due to similarity with an POSIX interface
304 or due to the implementation they are cancellation points and
305 therefore not marked with __THROW. */
c1422e5b
UD
306extern int getservent_r (struct servent *__restrict __result_buf,
307 char *__restrict __buf, size_t __buflen,
2c008571 308 struct servent **__restrict __result);
c1422e5b 309
a784e502
UD
310extern int getservbyname_r (const char *__restrict __name,
311 const char *__restrict __proto,
c1422e5b
UD
312 struct servent *__restrict __result_buf,
313 char *__restrict __buf, size_t __buflen,
2c008571 314 struct servent **__restrict __result);
c1422e5b 315
a784e502 316extern int getservbyport_r (int __port, const char *__restrict __proto,
c1422e5b
UD
317 struct servent *__restrict __result_buf,
318 char *__restrict __buf, size_t __buflen,
2c008571 319 struct servent **__restrict __result);
19361cb7 320#endif /* misc */
23396375
UD
321
322
323/* Description of data base entry for a single service. */
324struct protoent
325{
326 char *p_name; /* Official protocol name. */
327 char **p_aliases; /* Alias list. */
328 int p_proto; /* Protocol number. */
3d61b63c 329};
3d61b63c 330
23396375 331/* Open protocol data base files and mark them as staying open even
2c008571 332 after a later search if STAY_OPEN is non-zero.
23396375 333
2c008571
UD
334 This function is a possible cancellation point and therefore not
335 marked with __THROW. */
336extern void setprotoent (int __stay_open);
337
338/* Close protocol data base files and clear `stay open' flag.
339
340 This function is a possible cancellation point and therefore not
341 marked with __THROW. */
342extern void endprotoent (void);
23396375
UD
343
344/* Get next entry from protocol data base file. Open data base if
2c008571
UD
345 necessary.
346
347 This function is a possible cancellation point and therefore not
348 marked with __THROW. */
349extern struct protoent *getprotoent (void);
23396375 350
2c008571 351/* Return entry from protocol data base for network with NAME.
23396375 352
2c008571
UD
353 This function is a possible cancellation point and therefore not
354 marked with __THROW. */
a784e502 355extern struct protoent *getprotobyname (const char *__name);
2c008571
UD
356
357/* Return entry from protocol data base which number is PROTO.
358
359 This function is a possible cancellation point and therefore not
360 marked with __THROW. */
361extern struct protoent *getprotobynumber (int __proto);
23396375
UD
362
363
19361cb7 364#ifdef __USE_MISC
23396375 365/* Reentrant versions of the functions above. The additional
2c008571
UD
366 arguments specify a buffer of BUFLEN starting at BUF.
367
368 These functions are not part of POSIX and therefore no official
369 cancellation point. But due to similarity with an POSIX interface
370 or due to the implementation they are cancellation points and
371 therefore not marked with __THROW. */
c1422e5b
UD
372extern int getprotoent_r (struct protoent *__restrict __result_buf,
373 char *__restrict __buf, size_t __buflen,
2c008571 374 struct protoent **__restrict __result);
a6ff34d7 375
a784e502 376extern int getprotobyname_r (const char *__restrict __name,
c1422e5b
UD
377 struct protoent *__restrict __result_buf,
378 char *__restrict __buf, size_t __buflen,
2c008571 379 struct protoent **__restrict __result);
a6ff34d7 380
c1422e5b
UD
381extern int getprotobynumber_r (int __proto,
382 struct protoent *__restrict __result_buf,
383 char *__restrict __buf, size_t __buflen,
2c008571
UD
384 struct protoent **__restrict __result);
385
386
387/* Establish network group NETGROUP for enumeration.
23396375 388
2c008571
UD
389 This function is not part of POSIX and therefore no official
390 cancellation point. But due to similarity with an POSIX interface
391 or due to the implementation it is a cancellation point and
392 therefore not marked with __THROW. */
a784e502 393extern int setnetgrent (const char *__netgroup);
23396375 394
2c008571 395/* Free all space allocated by previous `setnetgrent' call.
a68b0d31 396
2c008571
UD
397 This function is not part of POSIX and therefore no official
398 cancellation point. But due to similarity with an POSIX interface
399 or due to the implementation it is a cancellation point and
400 therefore not marked with __THROW. */
401extern void endnetgrent (void);
a68b0d31
UD
402
403/* Get next member of netgroup established by last `setnetgrent' call
2c008571
UD
404 and return pointers to elements in HOSTP, USERP, and DOMAINP.
405
406 This function is not part of POSIX and therefore no official
407 cancellation point. But due to similarity with an POSIX interface
408 or due to the implementation it is a cancellation point and
409 therefore not marked with __THROW. */
c1422e5b
UD
410extern int getnetgrent (char **__restrict __hostp,
411 char **__restrict __userp,
2c008571 412 char **__restrict __domainp);
a68b0d31 413
2c008571
UD
414
415/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).
416
417 This function is not part of POSIX and therefore no official
418 cancellation point. But due to similarity with an POSIX interface
419 or due to the implementation it is a cancellation point and
420 therefore not marked with __THROW. */
a784e502
UD
421extern int innetgr (const char *__netgroup, const char *__host,
422 const char *__user, const char *__domain);
2c008571
UD
423
424/* Reentrant version of `getnetgrent' where result is placed in BUFFER.
a68b0d31 425
2c008571
UD
426 This function is not part of POSIX and therefore no official
427 cancellation point. But due to similarity with an POSIX interface
428 or due to the implementation it is a cancellation point and
429 therefore not marked with __THROW. */
c1422e5b
UD
430extern int getnetgrent_r (char **__restrict __hostp,
431 char **__restrict __userp,
432 char **__restrict __domainp,
2c008571 433 char *__restrict __buffer, size_t __buflen);
19361cb7 434#endif /* misc */
a68b0d31 435
46ec036d 436
498afc54 437#ifdef __USE_MISC
e7fd8a39
UD
438/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
439 The local user is LOCUSER, on the remote machine the command is
440 executed as REMUSER. In *FD2P the descriptor to the socket for the
441 connection is returned. The caller must have the right to use a
442 reserved port. When the function returns *AHOST contains the
2c008571
UD
443 official host name.
444
445 This function is not part of POSIX and therefore no official
446 cancellation point. But due to similarity with an POSIX interface
447 or due to the implementation it is a cancellation point and
448 therefore not marked with __THROW. */
c1422e5b 449extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
a784e502
UD
450 const char *__restrict __locuser,
451 const char *__restrict __remuser,
452 const char *__restrict __cmd, int *__restrict __fd2p);
e7fd8a39 453
2d29aba9 454/* This is the equivalent function where the protocol can be selected
2c008571
UD
455 and which therefore can be used for IPv6.
456
457 This function is not part of POSIX and therefore no official
458 cancellation point. But due to similarity with an POSIX interface
459 or due to the implementation it is a cancellation point and
460 therefore not marked with __THROW. */
2d29aba9 461extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
a784e502
UD
462 const char *__restrict __locuser,
463 const char *__restrict __remuser,
464 const char *__restrict __cmd, int *__restrict __fd2p,
2c008571 465 sa_family_t __af);
2d29aba9 466
e7fd8a39
UD
467/* Call `rexecd' at port RPORT on remote machine *AHOST to execute
468 CMD. The process runs at the remote machine using the ID of user
469 NAME whose cleartext password is PASSWD. In *FD2P the descriptor
470 to the socket for the connection is returned. When the function
2c008571
UD
471 returns *AHOST contains the official host name.
472
473 This function is not part of POSIX and therefore no official
474 cancellation point. But due to similarity with an POSIX interface
475 or due to the implementation it is a cancellation point and
476 therefore not marked with __THROW. */
c1422e5b 477extern int rexec (char **__restrict __ahost, int __rport,
a784e502
UD
478 const char *__restrict __name,
479 const char *__restrict __pass,
480 const char *__restrict __cmd, int *__restrict __fd2p);
e7fd8a39 481
2d29aba9 482/* This is the equivalent function where the protocol can be selected
2c008571
UD
483 and which therefore can be used for IPv6.
484
485 This function is not part of POSIX and therefore no official
486 cancellation point. But due to similarity with an POSIX interface
487 or due to the implementation it is a cancellation point and
488 therefore not marked with __THROW. */
2d29aba9 489extern int rexec_af (char **__restrict __ahost, int __rport,
a784e502
UD
490 const char *__restrict __name,
491 const char *__restrict __pass,
492 const char *__restrict __cmd, int *__restrict __fd2p,
2c008571 493 sa_family_t __af);
2d29aba9 494
e7fd8a39
UD
495/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
496 If SUSER is not zero the user tries to become superuser. Return 0 if
2c008571
UD
497 it is possible.
498
499 This function is not part of POSIX and therefore no official
500 cancellation point. But due to similarity with an POSIX interface
501 or due to the implementation it is a cancellation point and
502 therefore not marked with __THROW. */
a784e502
UD
503extern int ruserok (const char *__rhost, int __suser,
504 const char *__remuser, const char *__locuser);
e7fd8a39 505
2d29aba9 506/* This is the equivalent function where the protocol can be selected
2c008571
UD
507 and which therefore can be used for IPv6.
508
509 This function is not part of POSIX and therefore no official
510 cancellation point. But due to similarity with an POSIX interface
511 or due to the implementation it is a cancellation point and
512 therefore not marked with __THROW. */
a784e502
UD
513extern int ruserok_af (const char *__rhost, int __suser,
514 const char *__remuser, const char *__locuser,
2c008571 515 sa_family_t __af);
2d29aba9 516
2cd96708
UD
517/* Check whether user REMUSER on system indicated by IPv4 address
518 RADDR is allowed to login as LOCUSER. Non-IPv4 (e.g., IPv6) are
519 not supported. If SUSER is not zero the user tries to become
520 superuser. Return 0 if it is possible.
521
522 This function is not part of POSIX and therefore no official
523 cancellation point. But due to similarity with an POSIX interface
524 or due to the implementation it is a cancellation point and
525 therefore not marked with __THROW. */
526extern int iruserok (uint32_t __raddr, int __suser,
a784e502 527 const char *__remuser, const char *__locuser);
2cd96708
UD
528
529/* This is the equivalent function where the pfamiliy if the address
530 pointed to by RADDR is determined by the value of AF. It therefore
531 can be used for IPv6
532
533 This function is not part of POSIX and therefore no official
534 cancellation point. But due to similarity with an POSIX interface
535 or due to the implementation it is a cancellation point and
536 therefore not marked with __THROW. */
a784e502
UD
537extern int iruserok_af (const void *__raddr, int __suser,
538 const char *__remuser, const char *__locuser,
2cd96708
UD
539 sa_family_t __af);
540
e7fd8a39
UD
541/* Try to allocate reserved port, returning a descriptor for a socket opened
542 at this port or -1 if unsuccessful. The search for an available port
2c008571
UD
543 will start at ALPORT and continues with lower numbers.
544
545 This function is not part of POSIX and therefore no official
546 cancellation point. But due to similarity with an POSIX interface
547 or due to the implementation it is a cancellation point and
548 therefore not marked with __THROW. */
549extern int rresvport (int *__alport);
2d29aba9
UD
550
551/* This is the equivalent function where the protocol can be selected
2c008571
UD
552 and which therefore can be used for IPv6.
553
554 This function is not part of POSIX and therefore no official
555 cancellation point. But due to similarity with an POSIX interface
556 or due to the implementation it is a cancellation point and
557 therefore not marked with __THROW. */
558extern int rresvport_af (int *__alport, sa_family_t __af);
e7fd8a39
UD
559#endif
560
561
8737be80
JM
562/* Extension from POSIX.1:2001. */
563#ifdef __USE_XOPEN2K
46ec036d
UD
564/* Structure to contain information about address of a service provider. */
565struct addrinfo
566{
567 int ai_flags; /* Input flags. */
568 int ai_family; /* Protocol family for socket. */
569 int ai_socktype; /* Socket type. */
570 int ai_protocol; /* Protocol for socket. */
ad483238 571 socklen_t ai_addrlen; /* Length of socket address. */
46ec036d
UD
572 struct sockaddr *ai_addr; /* Socket address for socket. */
573 char *ai_canonname; /* Canonical name for service location. */
574 struct addrinfo *ai_next; /* Pointer to next in list. */
575};
576
2ace5721
UD
577# ifdef __USE_GNU
578/* Structure used as control block for asynchronous lookup. */
579struct gaicb
580{
581 const char *ar_name; /* Name to look up. */
582 const char *ar_service; /* Service name. */
583 const struct addrinfo *ar_request; /* Additional request specification. */
584 struct addrinfo *ar_result; /* Pointer to result. */
585 /* The following are internal elements. */
586 int __return;
d1d9eaf4 587 int __glibc_reserved[5];
2ace5721
UD
588};
589
590/* Lookup mode. */
591# define GAI_WAIT 0
592# define GAI_NOWAIT 1
593# endif
594
46ec036d 595/* Possible values for `ai_flags' field in `addrinfo' structure. */
8114530a
UD
596# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
597# define AI_CANONNAME 0x0002 /* Request for canonical name. */
598# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
925c3c5c
UD
599# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
600# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
601# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
602 returned address type.. */
e2fd3cbe
UD
603# ifdef __USE_GNU
604# define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded
605 in the current locale's character set)
606 before looking it up. */
de079fee 607# define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
7f9f1ecb
FW
608# define AI_IDN_ALLOW_UNASSIGNED \
609 __glibc_macro_warning ("AI_IDN_ALLOW_UNASSIGNED is deprecated") 0x0100
610# define AI_IDN_USE_STD3_ASCII_RULES \
611 __glibc_macro_warning ("AI_IDN_USE_STD3_ASCII_RULES is deprecated") 0x0200
e2fd3cbe 612# endif
76b82be4 613# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
46ec036d
UD
614
615/* Error values for `getaddrinfo' function. */
2ace5721
UD
616# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
617# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
618# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
619# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
2ace5721
UD
620# define EAI_FAMILY -6 /* `ai_family' not supported. */
621# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
622# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
2ace5721
UD
623# define EAI_MEMORY -10 /* Memory allocation failure. */
624# define EAI_SYSTEM -11 /* System error returned in `errno'. */
d0b23069 625# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
2ace5721 626# ifdef __USE_GNU
a53d3f82
UD
627# define EAI_NODATA -5 /* No address associated with NAME. */
628# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
2ace5721
UD
629# define EAI_INPROGRESS -100 /* Processing request in progress. */
630# define EAI_CANCELED -101 /* Request canceled. */
631# define EAI_NOTCANCELED -102 /* Request not canceled. */
632# define EAI_ALLDONE -103 /* All requests done. */
633# define EAI_INTR -104 /* Interrupted by a signal. */
e2fd3cbe 634# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
2ace5721 635# endif
dfd2257a 636
c9136393 637# ifdef __USE_MISC
a53d3f82
UD
638# define NI_MAXHOST 1025
639# define NI_MAXSERV 32
640# endif
dfd2257a 641
4bca4c17
UD
642# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
643# define NI_NUMERICSERV 2 /* Don't convert port number to name. */
644# define NI_NOFQDN 4 /* Only return nodename portion. */
645# define NI_NAMEREQD 8 /* Don't return numeric addresses. */
646# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
d0b23069
UD
647# ifdef __USE_GNU
648# define NI_IDN 32 /* Convert name from IDN format. */
7f9f1ecb
FW
649# define NI_IDN_ALLOW_UNASSIGNED \
650 __glibc_macro_warning ("NI_IDN_ALLOW_UNASSIGNED is deprecated") 64
651# define NI_IDN_USE_STD3_ASCII_RULES \
652 __glibc_macro_warning ("NI_IDN_USE_STD3_ASCII_RULES is deprecated") 128
d0b23069 653# endif
46ec036d
UD
654
655/* Translate name of a service location and/or a service name to set of
2c008571
UD
656 socket addresses.
657
658 This function is a possible cancellation point and therefore not
659 marked with __THROW. */
a784e502
UD
660extern int getaddrinfo (const char *__restrict __name,
661 const char *__restrict __service,
662 const struct addrinfo *__restrict __req,
2c008571 663 struct addrinfo **__restrict __pai);
46ec036d
UD
664
665/* Free `addrinfo' structure AI including associated storage. */
c1422e5b 666extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
0d8733c4
UD
667
668/* Convert error return from getaddrinfo() to a string. */
a784e502 669extern const char *gai_strerror (int __ecode) __THROW;
0d8733c4 670
2c008571
UD
671/* Translate a socket address to a location and service name.
672
673 This function is a possible cancellation point and therefore not
674 marked with __THROW. */
a784e502 675extern int getnameinfo (const struct sockaddr *__restrict __sa,
c1422e5b 676 socklen_t __salen, char *__restrict __host,
e10b8512 677 socklen_t __hostlen, char *__restrict __serv,
e4ecafe0 678 socklen_t __servlen, int __flags);
2c008571 679#endif /* POSIX */
0d8733c4 680
2c008571 681#ifdef __USE_GNU
2ace5721
UD
682/* Enqueue ENT requests from the LIST. If MODE is GAI_WAIT wait until all
683 requests are handled. If WAIT is GAI_NOWAIT return immediately after
2c008571
UD
684 queueing the requests and signal completion according to SIG.
685
686 This function is not part of POSIX and therefore no official
687 cancellation point. But due to similarity with an POSIX interface
688 or due to the implementation it is a cancellation point and
689 therefore not marked with __THROW. */
2ace5721 690extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict_arr],
2c008571 691 int __ent, struct sigevent *__restrict __sig);
2ace5721
UD
692
693/* Suspend execution of the thread until at least one of the ENT requests
694 in LIST is handled. If TIMEOUT is not a null pointer it specifies the
2c008571
UD
695 longest time the function keeps waiting before returning with an error.
696
697 This function is not part of POSIX and therefore no official
698 cancellation point. But due to similarity with an POSIX interface
699 or due to the implementation it is a cancellation point and
700 therefore not marked with __THROW. */
a784e502
UD
701extern int gai_suspend (const struct gaicb *const __list[], int __ent,
702 const struct timespec *__timeout);
2ace5721
UD
703
704/* Get the error status of the request REQ. */
705extern int gai_error (struct gaicb *__req) __THROW;
706
707/* Cancel the requests associated with GAICBP. */
708extern int gai_cancel (struct gaicb *__gaicbp) __THROW;
2c008571 709#endif /* GNU */
46ec036d 710
23396375
UD
711__END_DECLS
712
713#endif /* netdb.h */