netdb.h 27 KB

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