netdb.h 27 KB

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