netdb.h 27 KB

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