netdb.h 3.2 KB

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