netdb.h 26 KB

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