1
0

netdb.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #ifndef __NETDB_H__
  10. #define __NETDB_H__
  11. #ifndef _BSD_EXTENSION
  12. This header file is an extension to ANSI/POSIX
  13. #endif
  14. #pragma lib "/$M/lib/ape/libbsd.a"
  15. /*-
  16. * Copyright (c) 1980, 1983, 1988 Regents of the University of California.
  17. * All rights reserved.
  18. *
  19. * Redistribution and use in source and binary forms are permitted
  20. * provided that: (1) source distributions retain this entire copyright
  21. * notice and comment, and (2) distributions including binaries display
  22. * the following acknowledgement: ``This product includes software
  23. * developed by the University of California, Berkeley and its contributors''
  24. * in the documentation or other materials provided with the distribution
  25. * and in all advertising materials mentioning features or use of this
  26. * software. Neither the name of the University nor the names of its
  27. * contributors may be used to endorse or promote products derived
  28. * from this software without specific prior written permission.
  29. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  30. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  31. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  32. *
  33. * @(#)netdb.h 5.11 (Berkeley) 5/21/90
  34. */
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /*
  39. * Structures returned by network data base library. All addresses are
  40. * supplied in host order, and returned in network order (suitable for
  41. * use in system calls).
  42. */
  43. struct hostent {
  44. char *h_name; /* official name of host */
  45. char **h_aliases; /* alias list */
  46. int h_addrtype; /* host address type */
  47. int h_length; /* length of address */
  48. char **h_addr_list; /* list of addresses from name server */
  49. #define h_addr h_addr_list[0] /* address, for backward compatiblity */
  50. };
  51. /*
  52. * Assumption here is that a network number
  53. * fits in 32 bits -- probably a poor one.
  54. */
  55. struct netent {
  56. char *n_name; /* official name of net */
  57. char **n_aliases; /* alias list */
  58. int n_addrtype; /* net address type */
  59. unsigned long n_net; /* network # */
  60. };
  61. struct servent {
  62. char *s_name; /* official service name */
  63. char **s_aliases; /* alias list */
  64. int s_port; /* port # */
  65. char *s_proto; /* protocol to use */
  66. };
  67. struct protoent {
  68. char *p_name; /* official protocol name */
  69. char **p_aliases; /* alias list */
  70. int p_proto; /* protocol # */
  71. };
  72. /* from 4.0 RPCSRC */
  73. struct rpcent {
  74. char *r_name; /* name of server for this rpc program */
  75. char **r_aliases; /* alias list */
  76. int r_number; /* rpc program number */
  77. };
  78. extern struct hostent *gethostbyname(const char *),
  79. *gethostbyaddr(const void *, int, int),
  80. *gethostent(void);
  81. extern struct netent *getnetbyname(const char *),
  82. *getnetbyaddr(int32_t, int),
  83. *getnetent(void);
  84. extern struct servent *getservbyname(const char *, const char *),
  85. *getservbyport(int, const char *),
  86. *getservent(void);
  87. extern struct protoent *getprotobyname(const char *),
  88. *getprotobynumber(int),
  89. *getprotoent(void);
  90. extern struct rpcent *getrpcbyname(const char *),
  91. *getrpcbynumber(int),
  92. *getrpcent(void);
  93. extern void sethostent(int), endhostent(void),
  94. setnetent(int), endnetent(void),
  95. setservent(int), endservent(void),
  96. setprotoent(int), endprotoent(void),
  97. setrpcent(int), endrpcent(void);
  98. /*
  99. * Error return codes from gethostbyname() and gethostbyaddr()
  100. * (left in extern int h_errno).
  101. */
  102. extern int h_errno;
  103. extern void herror(const char *);
  104. extern char *hstrerror(int);
  105. #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
  106. #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
  107. #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  108. #define NO_DATA 4 /* Valid name, no data record of requested type */
  109. #define NO_ADDRESS NO_DATA /* no address, look for MX record */
  110. #define __HOST_SVC_NOT_AVAIL 99 /* libc internal use only */
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif /* !__NETDB_H__ */