PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/cares/dares/Ares.d

http://gool.googlecode.com/
D | 220 lines | 188 code | 32 blank | 0 comment | 0 complexity | 29b9eb0b4f9fcbf020d9e147cf2d5ed5 MD5 | raw file
  1. module dares.Ares;
  2. import dares.Types;
  3. enum {
  4. ARES_SUCCESS = 0,
  5. ARES_ENODATA = 1,
  6. ARES_EFORMERR = 2,
  7. ARES_ESERVFAIL = 3,
  8. ARES_ENOTFOUND = 4,
  9. ARES_ENOTIMP = 5,
  10. ARES_EREFUSED = 6,
  11. ARES_EBADQUERY = 7,
  12. ARES_EBADNAME = 8,
  13. ARES_EBADFAMILY = 9,
  14. ARES_EBADRESP = 10,
  15. ARES_ECONNREFUSED = 11,
  16. ARES_ETIMEOUT = 12,
  17. ARES_EOF = 13,
  18. ARES_EFILE = 14,
  19. ARES_ENOMEM = 15,
  20. ARES_EDESTRUCTION = 16,
  21. ARES_EBADSTR = 17,
  22. ARES_EBADFLAGS = 18,
  23. ARES_ENONAME = 19,
  24. ARES_EBADHINTS = 20,
  25. ARES_ENOTINITIALIZED = 21,
  26. ARES_ELOADIPHLPAPI = 22,
  27. ARES_EADDRGETNETWORKPARAMS = 23,
  28. ARES_ECANCELLED = 24,
  29. ARES_FLAG_USEVC = 1 << 0,
  30. ARES_FLAG_PRIMARY = 1 << 1,
  31. ARES_FLAG_IGNTC = 1 << 2,
  32. ARES_FLAG_NORECURSE = 1 << 3,
  33. ARES_FLAG_STAYOPEN = 1 << 4,
  34. ARES_FLAG_NOSEARCH = 1 << 5,
  35. ARES_FLAG_NOALIASES = 1 << 6,
  36. ARES_FLAG_NOCHECKRESP = 1 << 7,
  37. ARES_OPT_FLAGS = 1 << 0,
  38. ARES_OPT_TIMEOUT = 1 << 1,
  39. ARES_OPT_TRIES = 1 << 2,
  40. ARES_OPT_NDOTS = 1 << 3,
  41. ARES_OPT_UDP_PORT = 1 << 4,
  42. ARES_OPT_TCP_PORT = 1 << 5,
  43. ARES_OPT_SERVERS = 1 << 6,
  44. ARES_OPT_DOMAINS = 1 << 7,
  45. ARES_OPT_LOOKUPS = 1 << 8,
  46. ARES_OPT_SOCK_STATE_CB = 1 << 9,
  47. ARES_OPT_SORTLIST = 1 << 10,
  48. ARES_OPT_SOCK_SNDBUF = 1 << 11,
  49. ARES_OPT_SOCK_RCVBUF = 1 << 12,
  50. ARES_OPT_TIMEOUTMS = 1 << 13,
  51. ARES_OPT_ROTATE = 1 << 14,
  52. ARES_NI_NOFQDN = 1 << 0,
  53. ARES_NI_NUMERICHOST = 1 << 1,
  54. ARES_NI_NAMEREQD = 1 << 2,
  55. ARES_NI_NUMERICSERV = 1 << 3,
  56. ARES_NI_DGRAM = 1 << 4,
  57. ARES_NI_TCP = 0,
  58. ARES_NI_UDP =ARES_NI_DGRAM,
  59. ARES_NI_SCTP = 1 << 5,
  60. ARES_NI_DCCP = 1 << 6,
  61. ARES_NI_NUMERICSCOPE = 1 << 7,
  62. ARES_NI_LOOKUPHOST = 1 << 8,
  63. ARES_NI_LOOKUPSERVICE = 1 << 9,
  64. ARES_NI_IDN = 1 << 10,
  65. ARES_NI_IDN_ALLOW_UNASSIGNED = 1 << 11,
  66. ARES_NI_IDN_USE_STD3_ASCII_RULES = 1 << 12,
  67. ARES_AI_CANONNAME = 1 << 0,
  68. ARES_AI_NUMERICHOST = 1 << 1,
  69. ARES_AI_PASSIVE = 1 << 2,
  70. ARES_AI_NUMERICSERV = 1 << 3,
  71. ARES_AI_V4MAPPED = 1 << 4,
  72. ARES_AI_ALL = 1 << 5,
  73. ARES_AI_ADDRCONFIG = 1 << 6,
  74. ARES_AI_IDN = 1 << 10,
  75. ARES_AI_IDN_ALLOW_UNASSIGNED = 1 << 11,
  76. ARES_AI_IDN_USE_STD3_ASCII_RULES = 1 << 12,
  77. ARES_AI_CANONIDN = 1 << 13,
  78. ARES_GETSOCK_MAXNUM = 16 ,
  79. ARES_LIB_INIT_NONE = 0 ,
  80. ARES_LIB_INIT_WIN32 = 1 << 0 ,
  81. }
  82. const ARES_SOCKET_BAD = -1 ;
  83. alias ARES_LIB_INIT_WIN32 ARES_LIB_INIT_ALL;
  84. extern(C) :
  85. alias void function(void*, ares_socket_t, c_int,c_int) ares_sock_state_cb;
  86. alias void function(void *, c_int, c_int, ubyte*, c_int) ares_callback;
  87. alias void function(void *, c_int, c_int, hostent*) ares_host_callback;
  88. alias void function(void *, c_int, c_int, char*, char*) ares_nameinfo_callback;
  89. alias c_int function(ares_socket_t, c_int, void*) ares_sock_create_callback;
  90. struct in_addr {
  91. ubyte[4] _S6_u8;
  92. }
  93. struct ares_in6_addr {
  94. union {
  95. ubyte[16] _S6_u8;
  96. }
  97. }
  98. struct ares_addrttl {
  99. in_addr ipaddr;
  100. c_int ttl;
  101. }
  102. struct ares_addr6ttl {
  103. ares_in6_addr ip6addr;
  104. c_int ttl;
  105. }
  106. struct ares_srv_reply {
  107. ares_srv_reply * next;
  108. char* host;
  109. c_ushort priority;
  110. c_ushort weight;
  111. c_ushort port;
  112. }
  113. struct ares_mx_reply {
  114. ares_mx_reply* next;
  115. char* host;
  116. c_ushort priority;
  117. };
  118. struct ares_txt_reply {
  119. ares_txt_reply* next;
  120. ubyte* txt;
  121. size_t length;
  122. }
  123. struct ares_options {
  124. c_int flags;
  125. c_int timeout;
  126. c_int tries;
  127. c_int ndots;
  128. c_ushort udp_port;
  129. c_ushort tcp_port;
  130. c_int socket_send_buffer_size;
  131. c_int socket_receive_buffer_size;
  132. in_addr* servers;
  133. c_int nservers;
  134. char** domains;
  135. c_int ndomains;
  136. char* lookups;
  137. ares_sock_state_cb sock_state_cb;
  138. void* sock_state_cb_data;
  139. apattern* sortlist;
  140. c_int nsort;
  141. }
  142. struct ares_addr_node {
  143. ares_addr_node* next;
  144. c_int family;
  145. union {
  146. in_addr addr4 ;
  147. ares_in6_addr addr6 ;
  148. } //addr;
  149. }
  150. c_int ares_library_init(c_int flags);
  151. void ares_library_cleanup();
  152. char *ares_version(c_int*);
  153. c_int ares_init(ares_channel *channelptr);
  154. c_int ares_init_options(ares_channel *channelptr, ares_options *options, c_int optmask);
  155. c_int ares_save_options(ares_channel channel, ares_options *options, c_int *optmask);
  156. void ares_destroy_options(ares_options *options);
  157. c_int ares_dup(ares_channel *dest, ares_channel src);
  158. void ares_destroy(ares_channel channel);
  159. void ares_cancel(ares_channel channel);
  160. void ares_set_socket_callback(ares_channel channel, ares_sock_create_callback callback, void *user_data);
  161. void ares_send(ares_channel channel, ubyte *qbuf, c_int qlen, ares_callback callback, void *arg);
  162. void ares_query(ares_channel channel, char *name, c_int dnsclass, c_int type, ares_callback callback, void *arg);
  163. void ares_search(ares_channel channel, char *name, c_int dnsclass, c_int type, ares_callback callback, void *arg);
  164. void ares_gethostbyname(ares_channel channel, char *name, c_int family, ares_host_callback callback, void *arg);
  165. c_int ares_gethostbyname_file(ares_channel channel, char *name, c_int family, hostent **host);
  166. void ares_gethostbyaddr(ares_channel channel, void *addr, c_int addrlen, c_int family, ares_host_callback callback, void *arg);
  167. void ares_getnameinfo(ares_channel channel, sockaddr *sa, ares_socklen_t salen, c_int flags, ares_nameinfo_callback callback, void *arg);
  168. c_int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
  169. c_int ares_getsock(ares_channel channel, ares_socket_t *socks, c_int numsocks);
  170. timeval *ares_timeout(ares_channel channel, timeval *maxtv, timeval *tv);
  171. void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
  172. void ares_process_fd(ares_channel channel, ares_socket_t read_fd, ares_socket_t write_fd);
  173. c_int ares_mkquery( char *name, c_int dnsclass, c_int type, c_ushort id, c_int rd, ubyte **buf, c_int *buflen);
  174. c_int ares_expand_name( ubyte *encoded, ubyte *abuf, c_int alen, char **s, c_long *enclen);
  175. c_int ares_expand_string( ubyte *encoded, ubyte *abuf, c_int alen, ubyte **s, c_long *enclen);
  176. c_int ares_parse_a_reply( ubyte *abuf, c_int alen, hostent **host, ares_addrttl *addrttls, c_int *naddrttls);
  177. c_int ares_parse_aaaa_reply( ubyte *abuf, c_int alen, hostent **host, ares_addr6ttl *addrttls, c_int *naddrttls);
  178. c_int ares_parse_ptr_reply( ubyte *abuf, c_int alen, void *addr, c_int addrlen, c_int family, hostent **host);
  179. c_int ares_parse_ns_reply( ubyte *abuf, c_int alen, hostent **host);
  180. c_int ares_parse_srv_reply( ubyte* abuf, c_int alen, ares_srv_reply** srv_out);
  181. c_int ares_parse_mx_reply( ubyte* abuf, c_int alen, ares_mx_reply** mx_out);
  182. c_int ares_parse_txt_reply( ubyte* abuf, c_int alen, ares_txt_reply** txt_out);
  183. void ares_free_string(void *str);
  184. void ares_free_hostent( hostent *host);
  185. void ares_free_data(void*dataptr);
  186. char *ares_strerror(c_int code);
  187. c_int ares_set_servers(ares_channel channel, ares_addr_node *servers);
  188. c_int ares_get_servers(ares_channel channel, ares_addr_node **servers);