netdb.h 26 KB

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