PageRenderTime 52ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/include/netdb.h

https://gitlab.com/gsauthof/musl
C Header | 156 lines | 131 code | 24 blank | 1 comment | 8 complexity | db82b7573584b58463aa8979dd2f1a0e MD5 | raw file
  1. #ifndef _NETDB_H
  2. #define _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 AI_PASSIVE 0x01
  23. #define AI_CANONNAME 0x02
  24. #define AI_NUMERICHOST 0x04
  25. #define AI_V4MAPPED 0x08
  26. #define AI_ALL 0x10
  27. #define AI_ADDRCONFIG 0x20
  28. #define AI_NUMERICSERV 0x400
  29. #define NI_NUMERICHOST 0x01
  30. #define NI_NUMERICSERV 0x02
  31. #define NI_NOFQDN 0x04
  32. #define NI_NAMEREQD 0x08
  33. #define NI_DGRAM 0x10
  34. #define NI_NUMERICSCOPE 0x100
  35. #define EAI_BADFLAGS -1
  36. #define EAI_NONAME -2
  37. #define EAI_AGAIN -3
  38. #define EAI_FAIL -4
  39. #define EAI_FAMILY -6
  40. #define EAI_SOCKTYPE -7
  41. #define EAI_SERVICE -8
  42. #define EAI_MEMORY -10
  43. #define EAI_SYSTEM -11
  44. #define EAI_OVERFLOW -12
  45. int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
  46. void freeaddrinfo (struct addrinfo *);
  47. int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
  48. const char *gai_strerror(int);
  49. /* Legacy functions follow (marked OBsolete in SUS) */
  50. struct netent {
  51. char *n_name;
  52. char **n_aliases;
  53. int n_addrtype;
  54. uint32_t n_net;
  55. };
  56. struct hostent {
  57. char *h_name;
  58. char **h_aliases;
  59. int h_addrtype;
  60. int h_length;
  61. char **h_addr_list;
  62. };
  63. #define h_addr h_addr_list[0]
  64. struct servent {
  65. char *s_name;
  66. char **s_aliases;
  67. int s_port;
  68. char *s_proto;
  69. };
  70. struct protoent {
  71. char *p_name;
  72. char **p_aliases;
  73. int p_proto;
  74. };
  75. void sethostent (int);
  76. void endhostent (void);
  77. struct hostent *gethostent (void);
  78. void setnetent (int);
  79. void endnetent (void);
  80. struct netent *getnetent (void);
  81. struct netent *getnetbyaddr (uint32_t, int);
  82. struct netent *getnetbyname (const char *);
  83. void setservent (int);
  84. void endservent (void);
  85. struct servent *getservent (void);
  86. struct servent *getservbyname (const char *, const char *);
  87. struct servent *getservbyport (int, const char *);
  88. void setprotoent (int);
  89. void endprotoent (void);
  90. struct protoent *getprotoent (void);
  91. struct protoent *getprotobyname (const char *);
  92. struct protoent *getprotobynumber (int);
  93. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
  94. || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
  95. || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
  96. struct hostent *gethostbyname (const char *);
  97. struct hostent *gethostbyaddr (const void *, socklen_t, int);
  98. #ifdef __GNUC__
  99. __attribute__((const))
  100. #endif
  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 **, int *);
  116. int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
  117. int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
  118. #define EAI_NODATA -5
  119. #define EAI_ADDRFAMILY -9
  120. #define EAI_INPROGRESS -100
  121. #define EAI_CANCELED -101
  122. #define EAI_NOTCANCELED -102
  123. #define EAI_ALLDONE -103
  124. #define EAI_INTR -104
  125. #define EAI_IDN_ENCODE -105
  126. #define NI_MAXHOST 255
  127. #define NI_MAXSERV 32
  128. #endif
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif