/zircon/third_party/ulib/musl/include/netdb.h

https://github.com/vsrinivas/fuchsia · C Header · 155 lines · 132 code · 22 blank · 1 comment · 8 complexity · e0c29166b15e6369b73968800d9c16a4 MD5 · raw file

  1. #ifndef SYSROOT_NETDB_H_
  2. #define SYSROOT_NETDB_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #include <netinet/in.h>
  8. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  9. #define __NEED_size_t
  10. #include <bits/alltypes.h>
  11. #endif
  12. struct addrinfo {
  13. int ai_flags;
  14. int ai_family;
  15. int ai_socktype;
  16. int ai_protocol;
  17. socklen_t ai_addrlen;
  18. struct sockaddr* ai_addr;
  19. char* ai_canonname;
  20. struct addrinfo* ai_next;
  21. };
  22. #define IPPORT_RESERVED 1024
  23. #define AI_PASSIVE 0x01
  24. #define AI_CANONNAME 0x02
  25. #define AI_NUMERICHOST 0x04
  26. #define AI_V4MAPPED 0x08
  27. #define AI_ALL 0x10
  28. #define AI_ADDRCONFIG 0x20
  29. #define AI_NUMERICSERV 0x400
  30. #define NI_NUMERICHOST 0x01
  31. #define NI_NUMERICSERV 0x02
  32. #define NI_NOFQDN 0x04
  33. #define NI_NAMEREQD 0x08
  34. #define NI_DGRAM 0x10
  35. #define NI_NUMERICSCOPE 0x100
  36. #define EAI_BADFLAGS -1
  37. #define EAI_NONAME -2
  38. #define EAI_AGAIN -3
  39. #define EAI_FAIL -4
  40. #define EAI_FAMILY -6
  41. #define EAI_SOCKTYPE -7
  42. #define EAI_SERVICE -8
  43. #define EAI_MEMORY -10
  44. #define EAI_SYSTEM -11
  45. #define EAI_OVERFLOW -12
  46. int getaddrinfo(const char* __restrict, const char* __restrict, const struct addrinfo* __restrict,
  47. struct addrinfo** __restrict);
  48. void freeaddrinfo(struct addrinfo*);
  49. int getnameinfo(const struct sockaddr* __restrict, socklen_t, char* __restrict, socklen_t,
  50. char* __restrict, socklen_t, int);
  51. const char* gai_strerror(int);
  52. /* Legacy functions follow (marked OBsolete in SUS) */
  53. struct netent {
  54. char* n_name;
  55. char** n_aliases;
  56. int n_addrtype;
  57. uint32_t n_net;
  58. };
  59. struct hostent {
  60. char* h_name;
  61. char** h_aliases;
  62. int h_addrtype;
  63. int h_length;
  64. char** h_addr_list;
  65. };
  66. #define h_addr h_addr_list[0]
  67. struct servent {
  68. char* s_name;
  69. char** s_aliases;
  70. int s_port;
  71. char* s_proto;
  72. };
  73. struct protoent {
  74. char* p_name;
  75. char** p_aliases;
  76. int p_proto;
  77. };
  78. void sethostent(int);
  79. void endhostent(void);
  80. struct hostent* gethostent(void);
  81. void setnetent(int);
  82. void endnetent(void);
  83. struct netent* getnetent(void);
  84. struct netent* getnetbyaddr(uint32_t, int);
  85. struct netent* getnetbyname(const char*);
  86. void setservent(int);
  87. void endservent(void);
  88. struct servent* getservent(void);
  89. struct servent* getservbyname(const char*, const char*);
  90. struct servent* getservbyport(int, const char*);
  91. void setprotoent(int);
  92. void endprotoent(void);
  93. struct protoent* getprotoent(void);
  94. struct protoent* getprotobyname(const char*);
  95. struct protoent* getprotobynumber(int);
  96. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) || \
  97. (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE + 0 < 200809L) || \
  98. (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE + 0 < 700)
  99. struct hostent* gethostbyname(const char*);
  100. struct hostent* gethostbyaddr(const void*, socklen_t, int);
  101. int* __h_errno_location(void);
  102. #define h_errno (*__h_errno_location())
  103. #define HOST_NOT_FOUND 1
  104. #define TRY_AGAIN 2
  105. #define NO_RECOVERY 3
  106. #define NO_DATA 4
  107. #define NO_ADDRESS NO_DATA
  108. #endif
  109. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  110. void herror(const char*);
  111. const char* hstrerror(int);
  112. int gethostbyname_r(const char*, struct hostent*, char*, size_t, struct hostent**, int*);
  113. int gethostbyname2_r(const char*, int, struct hostent*, char*, size_t, struct hostent**, int*);
  114. struct hostent* gethostbyname2(const char*, int);
  115. int gethostbyaddr_r(const void*, socklen_t, int, struct hostent*, char*, size_t, struct hostent**,
  116. int*);
  117. int getservbyport_r(int, const char*, struct servent*, char*, size_t, struct servent**);
  118. int getservbyname_r(const char*, const char*, struct servent*, char*, size_t, struct servent**);
  119. #define EAI_NODATA -5
  120. #define EAI_ADDRFAMILY -9
  121. #define EAI_INPROGRESS -100
  122. #define EAI_CANCELED -101
  123. #define EAI_NOTCANCELED -102
  124. #define EAI_ALLDONE -103
  125. #define EAI_INTR -104
  126. #define EAI_IDN_ENCODE -105
  127. #define NI_MAXHOST 255
  128. #define NI_MAXSERV 32
  129. #endif
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133. #endif // SYSROOT_NETDB_H_