netdb.h 27 KB

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