netdb.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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. #ifdef __USE_MISC
  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. extern int h_errno;
  46. #if defined(__UCLIBC_HAS_THREADS__)
  47. # define h_errno (*__h_errno_location ())
  48. #endif
  49. /* Function to get address of global `h_errno' variable. */
  50. extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
  51. #ifdef _LIBC
  52. # define __set_h_errno(x) (h_errno = (x))
  53. #endif
  54. /* Possible values left in `h_errno'. */
  55. #define NETDB_INTERNAL -1 /* See errno. */
  56. #define NETDB_SUCCESS 0 /* No problem. */
  57. #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
  58. #define TRY_AGAIN 2 /* Non-Authoritative Host not found,
  59. or SERVERFAIL. */
  60. #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
  61. NOTIMP. */
  62. #define NO_DATA 4 /* Valid name, no data record of requested
  63. type. */
  64. #define NO_ADDRESS NO_DATA /* No address, look for MX record. */
  65. #ifdef __USE_XOPEN2K
  66. /* Highest reserved Internet port number. */
  67. # define IPPORT_RESERVED 1024
  68. #endif
  69. #ifdef __USE_GNU
  70. /* Scope delimiter for getaddrinfo(), getnameinfo(). */
  71. # define SCOPE_DELIMITER '%'
  72. #endif
  73. /* Print error indicated by `h_errno' variable on standard error. STR
  74. if non-null is printed before the error string. */
  75. extern void herror (__const char *__str) __THROW;
  76. /* Return string associated with error ERR_NUM. */
  77. extern __const char *hstrerror (int __err_num) __THROW;
  78. /* Description of data base entry for a single host. */
  79. struct hostent
  80. {
  81. char *h_name; /* Official name of host. */
  82. char **h_aliases; /* Alias list. */
  83. int h_addrtype; /* Host address type. */
  84. int h_length; /* Length of address. */
  85. char **h_addr_list; /* List of addresses from name server. */
  86. #define h_addr h_addr_list[0] /* Address, for backward compatibility. */
  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. #if 0
  175. /* FIXME */
  176. #ifdef __USE_MISC
  177. /* Reentrant versions of the functions above. The additional
  178. arguments specify a buffer of BUFLEN starting at BUF. The last
  179. argument is a pointer to a variable which gets the value which
  180. would be stored in the global variable `herrno' by the
  181. non-reentrant functions.
  182. These functions are not part of POSIX and therefore no official
  183. cancellation point. But due to similarity with an POSIX interface
  184. or due to the implementation they are cancellation points and
  185. therefore not marked with __THROW. */
  186. extern int getnetent_r (struct netent *__restrict __result_buf,
  187. char *__restrict __buf, size_t __buflen,
  188. struct netent **__restrict __result,
  189. int *__restrict __h_errnop);
  190. extern int getnetbyaddr_r (uint32_t __net, int __type,
  191. struct netent *__restrict __result_buf,
  192. char *__restrict __buf, size_t __buflen,
  193. struct netent **__restrict __result,
  194. int *__restrict __h_errnop);
  195. extern int getnetbyname_r (__const char *__restrict __name,
  196. struct netent *__restrict __result_buf,
  197. char *__restrict __buf, size_t __buflen,
  198. struct netent **__restrict __result,
  199. int *__restrict __h_errnop);
  200. #endif /* misc */
  201. #endif
  202. /* Description of data base entry for a single service. */
  203. struct servent
  204. {
  205. char *s_name; /* Official service name. */
  206. char **s_aliases; /* Alias list. */
  207. int s_port; /* Port number. */
  208. char *s_proto; /* Protocol to use. */
  209. };
  210. /* Open service data base files and mark them as staying open even
  211. after a later search if STAY_OPEN is non-zero.
  212. This function is a possible cancellation point and therefore not
  213. marked with __THROW. */
  214. extern void setservent (int __stay_open);
  215. /* Close service data base files and clear `stay open' flag.
  216. This function is a possible cancellation point and therefore not
  217. marked with __THROW. */
  218. extern void endservent (void);
  219. /* Get next entry from service data base file. Open data base if
  220. necessary.
  221. This function is a possible cancellation point and therefore not
  222. marked with __THROW. */
  223. extern struct servent *getservent (void);
  224. /* Return entry from network data base for network with NAME and
  225. protocol PROTO.
  226. This function is a possible cancellation point and therefore not
  227. marked with __THROW. */
  228. extern struct servent *getservbyname (__const char *__name,
  229. __const char *__proto);
  230. /* Return entry from service data base which matches port PORT and
  231. protocol PROTO.
  232. This function is a possible cancellation point and therefore not
  233. marked with __THROW. */
  234. extern struct servent *getservbyport (int __port, __const char *__proto);
  235. #ifdef __USE_MISC
  236. /* Reentrant versions of the functions above. The additional
  237. arguments specify a buffer of BUFLEN starting at BUF.
  238. These functions are not part of POSIX and therefore no official
  239. cancellation point. But due to similarity with an POSIX interface
  240. or due to the implementation they are cancellation points and
  241. therefore not marked with __THROW. */
  242. extern int getservent_r (struct servent *__restrict __result_buf,
  243. char *__restrict __buf, size_t __buflen,
  244. struct servent **__restrict __result);
  245. extern int getservbyname_r (__const char *__restrict __name,
  246. __const char *__restrict __proto,
  247. struct servent *__restrict __result_buf,
  248. char *__restrict __buf, size_t __buflen,
  249. struct servent **__restrict __result);
  250. extern int getservbyport_r (int __port, __const char *__restrict __proto,
  251. struct servent *__restrict __result_buf,
  252. char *__restrict __buf, size_t __buflen,
  253. struct servent **__restrict __result);
  254. #endif /* misc */
  255. /* Description of data base entry for a single service. */
  256. struct protoent
  257. {
  258. char *p_name; /* Official protocol name. */
  259. char **p_aliases; /* Alias list. */
  260. int p_proto; /* Protocol number. */
  261. };
  262. /* Open protocol data base files and mark them as staying open even
  263. after a later search if STAY_OPEN is non-zero.
  264. This function is a possible cancellation point and therefore not
  265. marked with __THROW. */
  266. extern void setprotoent (int __stay_open);
  267. /* Close protocol data base files and clear `stay open' flag.
  268. This function is a possible cancellation point and therefore not
  269. marked with __THROW. */
  270. extern void endprotoent (void);
  271. /* Get next entry from protocol data base file. Open data base if
  272. necessary.
  273. This function is a possible cancellation point and therefore not
  274. marked with __THROW. */
  275. extern struct protoent *getprotoent (void);
  276. /* Return entry from protocol data base for network with NAME.
  277. This function is a possible cancellation point and therefore not
  278. marked with __THROW. */
  279. extern struct protoent *getprotobyname (__const char *__name);
  280. /* Return entry from protocol data base which number is PROTO.
  281. This function is a possible cancellation point and therefore not
  282. marked with __THROW. */
  283. extern struct protoent *getprotobynumber (int __proto);
  284. #ifdef __USE_MISC
  285. /* Reentrant versions of the functions above. The additional
  286. arguments specify a buffer of BUFLEN starting at BUF.
  287. These functions are not part of POSIX and therefore no official
  288. cancellation point. But due to similarity with an POSIX interface
  289. or due to the implementation they are cancellation points and
  290. therefore not marked with __THROW. */
  291. extern int getprotoent_r (struct protoent *__restrict __result_buf,
  292. char *__restrict __buf, size_t __buflen,
  293. struct protoent **__restrict __result);
  294. extern int getprotobyname_r (__const char *__restrict __name,
  295. struct protoent *__restrict __result_buf,
  296. char *__restrict __buf, size_t __buflen,
  297. struct protoent **__restrict __result);
  298. extern int getprotobynumber_r (int __proto,
  299. struct protoent *__restrict __result_buf,
  300. char *__restrict __buf, size_t __buflen,
  301. struct protoent **__restrict __result);
  302. #if defined(__UCLIBC_HAS_NETGROUP__)
  303. /* Establish network group NETGROUP for enumeration.
  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 int setnetgrent (__const char *__netgroup);
  309. /* Free all space allocated by previous `setnetgrent' call.
  310. This function is not part of POSIX and therefore no official
  311. cancellation point. But due to similarity with an POSIX interface
  312. or due to the implementation it is a cancellation point and
  313. therefore not marked with __THROW. */
  314. extern void endnetgrent (void);
  315. /* Get next member of netgroup established by last `setnetgrent' call
  316. and return pointers to elements in HOSTP, USERP, and DOMAINP.
  317. This function is not part of POSIX and therefore no official
  318. cancellation point. But due to similarity with an POSIX interface
  319. or due to the implementation it is a cancellation point and
  320. therefore not marked with __THROW. */
  321. extern int getnetgrent (char **__restrict __hostp,
  322. char **__restrict __userp,
  323. char **__restrict __domainp);
  324. /* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).
  325. This function is not part of POSIX and therefore no official
  326. cancellation point. But due to similarity with an POSIX interface
  327. or due to the implementation it is a cancellation point and
  328. therefore not marked with __THROW. */
  329. extern int innetgr (__const char *__netgroup, __const char *__host,
  330. __const char *__user, __const char *domain);
  331. /* Reentrant version of `getnetgrent' where result is placed in BUFFER.
  332. This function is not part of POSIX and therefore no official
  333. cancellation point. But due to similarity with an POSIX interface
  334. or due to the implementation it is a cancellation point and
  335. therefore not marked with __THROW. */
  336. extern int getnetgrent_r (char **__restrict __hostp,
  337. char **__restrict __userp,
  338. char **__restrict __domainp,
  339. char *__restrict __buffer, size_t __buflen);
  340. #endif /* UCLIBC_HAS_NETGROUP */
  341. #endif /* misc */
  342. #ifdef __USE_BSD
  343. /* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
  344. The local user is LOCUSER, on the remote machine the command is
  345. executed as REMUSER. In *FD2P the descriptor to the socket for the
  346. connection is returned. The caller must have the right to use a
  347. reserved port. When the function returns *AHOST contains the
  348. official host name.
  349. This function is not part of POSIX and therefore no official
  350. cancellation point. But due to similarity with an POSIX interface
  351. or due to the implementation it is a cancellation point and
  352. therefore not marked with __THROW. */
  353. extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
  354. __const char *__restrict __locuser,
  355. __const char *__restrict __remuser,
  356. __const char *__restrict __cmd, int *__restrict __fd2p);
  357. #if 0
  358. /* FIXME */
  359. /* This is the equivalent function where the protocol can be selected
  360. and which therefore can be used for IPv6.
  361. This function is not part of POSIX and therefore no official
  362. cancellation point. But due to similarity with an POSIX interface
  363. or due to the implementation it is a cancellation point and
  364. therefore not marked with __THROW. */
  365. extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
  366. __const char *__restrict __locuser,
  367. __const char *__restrict __remuser,
  368. __const char *__restrict __cmd, int *__restrict __fd2p,
  369. sa_family_t __af);
  370. #endif
  371. /* Call `rexecd' at port RPORT on remote machine *AHOST to execute
  372. CMD. The process runs at the remote machine using the ID of user
  373. NAME whose cleartext password is PASSWD. In *FD2P the descriptor
  374. to the socket for the connection is returned. When the function
  375. returns *AHOST contains the official host name.
  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 (char **__restrict __ahost, int __rport,
  381. __const char *__restrict __name,
  382. __const char *__restrict __pass,
  383. __const char *__restrict __cmd, int *__restrict __fd2p);
  384. /* This is the equivalent function where the protocol can be selected
  385. and which therefore can be used for IPv6.
  386. This function is not part of POSIX and therefore no official
  387. cancellation point. But due to similarity with an POSIX interface
  388. or due to the implementation it is a cancellation point and
  389. therefore not marked with __THROW. */
  390. extern int rexec_af (char **__restrict __ahost, int __rport,
  391. __const char *__restrict __name,
  392. __const char *__restrict __pass,
  393. __const char *__restrict __cmd, int *__restrict __fd2p,
  394. sa_family_t __af);
  395. /* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
  396. If SUSER is not zero the user tries to become superuser. Return 0 if
  397. it is possible.
  398. This function is not part of POSIX and therefore no official
  399. cancellation point. But due to similarity with an POSIX interface
  400. or due to the implementation it is a cancellation point and
  401. therefore not marked with __THROW. */
  402. extern int ruserok (__const char *__rhost, int __suser,
  403. __const char *__remuser, __const char *__locuser);
  404. #if 0
  405. /* FIXME */
  406. /* This is the equivalent function where the protocol can be selected
  407. and which therefore can be used for IPv6.
  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 ruserok_af (__const char *__rhost, int __suser,
  413. __const char *__remuser, __const char *__locuser,
  414. sa_family_t __af);
  415. #endif
  416. /* Try to allocate reserved port, returning a descriptor for a socket opened
  417. at this port or -1 if unsuccessful. The search for an available port
  418. will start at ALPORT and continues with lower numbers.
  419. This function is not part of POSIX and therefore no official
  420. cancellation point. But due to similarity with an POSIX interface
  421. or due to the implementation it is a cancellation point and
  422. therefore not marked with __THROW. */
  423. extern int rresvport (int *__alport);
  424. #if 0
  425. /* FIXME */
  426. /* This is the equivalent function where the protocol can be selected
  427. and which therefore can be used for IPv6.
  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 rresvport_af (int *__alport, sa_family_t __af);
  433. #endif
  434. #endif
  435. /* Extension from POSIX.1g. */
  436. #ifdef __USE_POSIX
  437. /* Structure to contain information about address of a service provider. */
  438. struct addrinfo
  439. {
  440. int ai_flags; /* Input flags. */
  441. int ai_family; /* Protocol family for socket. */
  442. int ai_socktype; /* Socket type. */
  443. int ai_protocol; /* Protocol for socket. */
  444. socklen_t ai_addrlen; /* Length of socket address. */
  445. struct sockaddr *ai_addr; /* Socket address for socket. */
  446. char *ai_canonname; /* Canonical name for service location. */
  447. struct addrinfo *ai_next; /* Pointer to next in list. */
  448. };
  449. /* Possible values for `ai_flags' field in `addrinfo' structure. */
  450. # define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
  451. # define AI_CANONNAME 0x0002 /* Request for canonical name. */
  452. # define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
  453. # define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
  454. # define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
  455. # define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
  456. returned address type.. */
  457. # ifdef __USE_GNU
  458. # define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded
  459. in the current locale's character set)
  460. before looking it up. */
  461. # define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
  462. # define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode
  463. code points. */
  464. # define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to
  465. STD3 rules. */
  466. # endif
  467. # define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
  468. /* Error values for `getaddrinfo' function. */
  469. # define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
  470. # define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
  471. # define EAI_AGAIN -3 /* Temporary failure in name resolution. */
  472. # define EAI_FAIL -4 /* Non-recoverable failure in name res. */
  473. # define EAI_NODATA -5 /* No address associated with NAME. */
  474. # define EAI_FAMILY -6 /* `ai_family' not supported. */
  475. # define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
  476. # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
  477. # define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
  478. # define EAI_MEMORY -10 /* Memory allocation failure. */
  479. # define EAI_SYSTEM -11 /* System error returned in `errno'. */
  480. # define EAI_OVERFLOW -12 /* Argument buffer overflow. */
  481. # ifdef __USE_GNU
  482. # define EAI_INPROGRESS -100 /* Processing request in progress. */
  483. # define EAI_CANCELED -101 /* Request canceled. */
  484. # define EAI_NOTCANCELED -102 /* Request not canceled. */
  485. # define EAI_ALLDONE -103 /* All requests done. */
  486. # define EAI_INTR -104 /* Interrupted by a signal. */
  487. # define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
  488. # endif
  489. # define NI_MAXHOST 1025
  490. # define NI_MAXSERV 32
  491. # define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
  492. # define NI_NUMERICSERV 2 /* Don't convert port number to name. */
  493. # define NI_NOFQDN 4 /* Only return nodename portion. */
  494. # define NI_NAMEREQD 8 /* Don't return numeric addresses. */
  495. # define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
  496. # ifdef __USE_GNU
  497. # define NI_IDN 32 /* Convert name from IDN format. */
  498. # define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode
  499. code points. */
  500. # define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to
  501. STD3 rules. */
  502. # endif
  503. /* Translate name of a service location and/or a service name to set of
  504. socket addresses.
  505. This function is a possible cancellation point and therefore not
  506. marked with __THROW. */
  507. extern int getaddrinfo (__const char *__restrict __name,
  508. __const char *__restrict __service,
  509. __const struct addrinfo *__restrict __req,
  510. struct addrinfo **__restrict __pai);
  511. /* Free `addrinfo' structure AI including associated storage. */
  512. extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
  513. /* Convert error return from getaddrinfo() to a string. */
  514. extern __const char *gai_strerror (int __ecode) __THROW;
  515. /* Translate a socket address to a location and service name.
  516. This function is a possible cancellation point and therefore not
  517. marked with __THROW. */
  518. extern int getnameinfo (__const struct sockaddr *__restrict __sa,
  519. socklen_t __salen, char *__restrict __host,
  520. socklen_t __hostlen, char *__restrict __serv,
  521. socklen_t __servlen, unsigned int __flags);
  522. #endif /* POSIX */
  523. __END_DECLS
  524. #endif /* netdb.h */