netdb.h 27 KB

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