visaljs 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +12 -4
  2. package/THIRD_PARTY_LICENSES +31 -1
  3. package/cli.js +3745 -890
  4. package/node/include/js_node.h +12 -1
  5. package/node/prelude/_http_common.js +29 -0
  6. package/node/prelude/async_hooks.js +50 -11
  7. package/node/prelude/child_process.js +31 -4
  8. package/node/prelude/console.js +311 -143
  9. package/node/prelude/crypto.js +6 -4
  10. package/node/prelude/dgram.js +1169 -0
  11. package/node/prelude/diagnostics_channel.js +3 -1
  12. package/node/prelude/dns.js +250 -45
  13. package/node/prelude/dns_promises.js +8 -2
  14. package/node/prelude/fs_promises.js +9 -1
  15. package/node/prelude/http.js +405 -94
  16. package/node/prelude/https.js +13 -4
  17. package/node/prelude/internal/console_class.js +7 -0
  18. package/node/prelude/internal/console_global.js +25 -0
  19. package/node/prelude/internal/crypto/key_encryption.js +217 -0
  20. package/node/prelude/internal/crypto/keys.js +161 -26
  21. package/node/prelude/internal/crypto/random.js +24 -0
  22. package/node/prelude/internal/crypto/util.js +2 -1
  23. package/node/prelude/internal/crypto_x509.js +161 -0
  24. package/node/prelude/internal/dns_classes.js +6 -0
  25. package/node/prelude/internal/dns_resolver.js +371 -0
  26. package/node/prelude/internal/errors.js +9 -0
  27. package/node/prelude/internal/events_on.js +82 -37
  28. package/node/prelude/internal/features.js +8 -4
  29. package/node/prelude/internal/fs_filehandle.js +10 -4
  30. package/node/prelude/internal/http_chars.ts +22 -0
  31. package/node/prelude/internal/perf_histogram.js +1 -1
  32. package/node/prelude/internal/process_more.js +32 -17
  33. package/node/prelude/internal/process_signals.js +8 -2
  34. package/node/prelude/internal/punycode.ts +163 -0
  35. package/node/prelude/internal/readline.js +648 -274
  36. package/node/prelude/internal/readline_editor.js +1240 -0
  37. package/node/prelude/internal/string_width.js +43 -0
  38. package/node/prelude/internal/tls/common.js +145 -33
  39. package/node/prelude/internal/tls/wrap.js +182 -49
  40. package/node/prelude/internal/tls/x509.js +4 -1
  41. package/node/prelude/internal/udp.js +177 -0
  42. package/node/prelude/net.js +30 -14
  43. package/node/prelude/os.js +24 -6
  44. package/node/prelude/perf_hooks.js +37 -2
  45. package/node/prelude/punycode.js +2 -130
  46. package/node/prelude/readline.js +113 -4
  47. package/node/prelude/readline_promises.js +56 -32
  48. package/node/prelude/tls.js +21 -4
  49. package/node/prelude/util.js +3 -16
  50. package/node/src/host_dns.c +623 -0
  51. package/node/src/host_http.c +12 -0
  52. package/node/src/host_net.c +46 -0
  53. package/node/src/host_os.c +1 -6
  54. package/node/src/host_sys.c +79 -0
  55. package/node/src/host_udp.c +418 -0
  56. package/node/third_party/c-ares/LICENSE.md +24 -0
  57. package/node/third_party/c-ares/config/darwin/ares_config.h +573 -0
  58. package/node/third_party/c-ares/config/freebsd/ares_config.h +573 -0
  59. package/node/third_party/c-ares/config/linux/ares_config.h +573 -0
  60. package/node/third_party/c-ares/config/openbsd/ares_config.h +583 -0
  61. package/node/third_party/c-ares/include/ares.h +1237 -0
  62. package/node/third_party/c-ares/include/ares_build.h +202 -0
  63. package/node/third_party/c-ares/include/ares_dns.h +127 -0
  64. package/node/third_party/c-ares/include/ares_dns_record.h +1119 -0
  65. package/node/third_party/c-ares/include/ares_nameser.h +510 -0
  66. package/node/third_party/c-ares/include/ares_version.h +47 -0
  67. package/node/third_party/c-ares/src/lib/ares_addrinfo2hostent.c +305 -0
  68. package/node/third_party/c-ares/src/lib/ares_addrinfo_localhost.c +245 -0
  69. package/node/third_party/c-ares/src/lib/ares_android.c +496 -0
  70. package/node/third_party/c-ares/src/lib/ares_android.h +38 -0
  71. package/node/third_party/c-ares/src/lib/ares_cancel.c +87 -0
  72. package/node/third_party/c-ares/src/lib/ares_close_sockets.c +137 -0
  73. package/node/third_party/c-ares/src/lib/ares_conn.c +511 -0
  74. package/node/third_party/c-ares/src/lib/ares_conn.h +202 -0
  75. package/node/third_party/c-ares/src/lib/ares_cookie.c +461 -0
  76. package/node/third_party/c-ares/src/lib/ares_data.c +168 -0
  77. package/node/third_party/c-ares/src/lib/ares_data.h +92 -0
  78. package/node/third_party/c-ares/src/lib/ares_destroy.c +159 -0
  79. package/node/third_party/c-ares/src/lib/ares_free_hostent.c +54 -0
  80. package/node/third_party/c-ares/src/lib/ares_free_string.c +33 -0
  81. package/node/third_party/c-ares/src/lib/ares_freeaddrinfo.c +67 -0
  82. package/node/third_party/c-ares/src/lib/ares_getaddrinfo.c +806 -0
  83. package/node/third_party/c-ares/src/lib/ares_getenv.c +38 -0
  84. package/node/third_party/c-ares/src/lib/ares_getenv.h +34 -0
  85. package/node/third_party/c-ares/src/lib/ares_gethostbyaddr.c +229 -0
  86. package/node/third_party/c-ares/src/lib/ares_gethostbyname.c +341 -0
  87. package/node/third_party/c-ares/src/lib/ares_getnameinfo.c +437 -0
  88. package/node/third_party/c-ares/src/lib/ares_hosts_file.c +960 -0
  89. package/node/third_party/c-ares/src/lib/ares_inet_net_pton.h +31 -0
  90. package/node/third_party/c-ares/src/lib/ares_init.c +631 -0
  91. package/node/third_party/c-ares/src/lib/ares_ipv6.h +115 -0
  92. package/node/third_party/c-ares/src/lib/ares_library_init.c +190 -0
  93. package/node/third_party/c-ares/src/lib/ares_metrics.c +261 -0
  94. package/node/third_party/c-ares/src/lib/ares_options.c +492 -0
  95. package/node/third_party/c-ares/src/lib/ares_parse_into_addrinfo.c +179 -0
  96. package/node/third_party/c-ares/src/lib/ares_private.h +648 -0
  97. package/node/third_party/c-ares/src/lib/ares_process.c +1649 -0
  98. package/node/third_party/c-ares/src/lib/ares_qcache.c +442 -0
  99. package/node/third_party/c-ares/src/lib/ares_query.c +151 -0
  100. package/node/third_party/c-ares/src/lib/ares_search.c +623 -0
  101. package/node/third_party/c-ares/src/lib/ares_send.c +300 -0
  102. package/node/third_party/c-ares/src/lib/ares_set_socket_functions.c +590 -0
  103. package/node/third_party/c-ares/src/lib/ares_setup.h +224 -0
  104. package/node/third_party/c-ares/src/lib/ares_socket.c +427 -0
  105. package/node/third_party/c-ares/src/lib/ares_socket.h +163 -0
  106. package/node/third_party/c-ares/src/lib/ares_sortaddrinfo.c +447 -0
  107. package/node/third_party/c-ares/src/lib/ares_strerror.c +91 -0
  108. package/node/third_party/c-ares/src/lib/ares_sysconfig.c +642 -0
  109. package/node/third_party/c-ares/src/lib/ares_sysconfig_files.c +851 -0
  110. package/node/third_party/c-ares/src/lib/ares_sysconfig_mac.c +373 -0
  111. package/node/third_party/c-ares/src/lib/ares_sysconfig_win.c +673 -0
  112. package/node/third_party/c-ares/src/lib/ares_timeout.c +162 -0
  113. package/node/third_party/c-ares/src/lib/ares_update_servers.c +1376 -0
  114. package/node/third_party/c-ares/src/lib/ares_version.c +36 -0
  115. package/node/third_party/c-ares/src/lib/config-dos.h +114 -0
  116. package/node/third_party/c-ares/src/lib/config-win32.h +396 -0
  117. package/node/third_party/c-ares/src/lib/dsa/ares_array.c +409 -0
  118. package/node/third_party/c-ares/src/lib/dsa/ares_htable.c +451 -0
  119. package/node/third_party/c-ares/src/lib/dsa/ares_htable.h +174 -0
  120. package/node/third_party/c-ares/src/lib/dsa/ares_htable_asvp.c +224 -0
  121. package/node/third_party/c-ares/src/lib/dsa/ares_htable_dict.c +230 -0
  122. package/node/third_party/c-ares/src/lib/dsa/ares_htable_strvp.c +210 -0
  123. package/node/third_party/c-ares/src/lib/dsa/ares_htable_szvp.c +188 -0
  124. package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpstr.c +186 -0
  125. package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpvp.c +194 -0
  126. package/node/third_party/c-ares/src/lib/dsa/ares_llist.c +385 -0
  127. package/node/third_party/c-ares/src/lib/dsa/ares_slist.c +479 -0
  128. package/node/third_party/c-ares/src/lib/dsa/ares_slist.h +207 -0
  129. package/node/third_party/c-ares/src/lib/event/ares_event.h +191 -0
  130. package/node/third_party/c-ares/src/lib/event/ares_event_configchg.c +746 -0
  131. package/node/third_party/c-ares/src/lib/event/ares_event_epoll.c +192 -0
  132. package/node/third_party/c-ares/src/lib/event/ares_event_kqueue.c +248 -0
  133. package/node/third_party/c-ares/src/lib/event/ares_event_poll.c +140 -0
  134. package/node/third_party/c-ares/src/lib/event/ares_event_select.c +159 -0
  135. package/node/third_party/c-ares/src/lib/event/ares_event_thread.c +575 -0
  136. package/node/third_party/c-ares/src/lib/event/ares_event_wake_pipe.c +172 -0
  137. package/node/third_party/c-ares/src/lib/event/ares_event_win32.c +981 -0
  138. package/node/third_party/c-ares/src/lib/event/ares_event_win32.h +161 -0
  139. package/node/third_party/c-ares/src/lib/include/ares_array.h +276 -0
  140. package/node/third_party/c-ares/src/lib/include/ares_buf.h +732 -0
  141. package/node/third_party/c-ares/src/lib/include/ares_htable_asvp.h +130 -0
  142. package/node/third_party/c-ares/src/lib/include/ares_htable_dict.h +123 -0
  143. package/node/third_party/c-ares/src/lib/include/ares_htable_strvp.h +130 -0
  144. package/node/third_party/c-ares/src/lib/include/ares_htable_szvp.h +118 -0
  145. package/node/third_party/c-ares/src/lib/include/ares_htable_vpstr.h +111 -0
  146. package/node/third_party/c-ares/src/lib/include/ares_htable_vpvp.h +128 -0
  147. package/node/third_party/c-ares/src/lib/include/ares_llist.h +239 -0
  148. package/node/third_party/c-ares/src/lib/include/ares_mem.h +41 -0
  149. package/node/third_party/c-ares/src/lib/include/ares_str.h +261 -0
  150. package/node/third_party/c-ares/src/lib/inet_net_pton.c +451 -0
  151. package/node/third_party/c-ares/src/lib/inet_ntop.c +219 -0
  152. package/node/third_party/c-ares/src/lib/legacy/ares_create_query.c +78 -0
  153. package/node/third_party/c-ares/src/lib/legacy/ares_expand_name.c +99 -0
  154. package/node/third_party/c-ares/src/lib/legacy/ares_expand_string.c +107 -0
  155. package/node/third_party/c-ares/src/lib/legacy/ares_fds.c +80 -0
  156. package/node/third_party/c-ares/src/lib/legacy/ares_getsock.c +85 -0
  157. package/node/third_party/c-ares/src/lib/legacy/ares_parse_a_reply.c +107 -0
  158. package/node/third_party/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
  159. package/node/third_party/c-ares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
  160. package/node/third_party/c-ares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
  161. package/node/third_party/c-ares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
  162. package/node/third_party/c-ares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
  163. package/node/third_party/c-ares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
  164. package/node/third_party/c-ares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
  165. package/node/third_party/c-ares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
  166. package/node/third_party/c-ares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
  167. package/node/third_party/c-ares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
  168. package/node/third_party/c-ares/src/lib/record/ares_dns_mapping.c +982 -0
  169. package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.c +309 -0
  170. package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.h +72 -0
  171. package/node/third_party/c-ares/src/lib/record/ares_dns_name.c +736 -0
  172. package/node/third_party/c-ares/src/lib/record/ares_dns_parse.c +1360 -0
  173. package/node/third_party/c-ares/src/lib/record/ares_dns_private.h +273 -0
  174. package/node/third_party/c-ares/src/lib/record/ares_dns_record.c +1701 -0
  175. package/node/third_party/c-ares/src/lib/record/ares_dns_write.c +1229 -0
  176. package/node/third_party/c-ares/src/lib/str/ares_buf.c +1510 -0
  177. package/node/third_party/c-ares/src/lib/str/ares_str.c +562 -0
  178. package/node/third_party/c-ares/src/lib/str/ares_strsplit.c +90 -0
  179. package/node/third_party/c-ares/src/lib/str/ares_strsplit.h +51 -0
  180. package/node/third_party/c-ares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
  181. package/node/third_party/c-ares/src/lib/util/ares_iface_ips.c +640 -0
  182. package/node/third_party/c-ares/src/lib/util/ares_iface_ips.h +140 -0
  183. package/node/third_party/c-ares/src/lib/util/ares_math.c +167 -0
  184. package/node/third_party/c-ares/src/lib/util/ares_math.h +58 -0
  185. package/node/third_party/c-ares/src/lib/util/ares_rand.c +389 -0
  186. package/node/third_party/c-ares/src/lib/util/ares_rand.h +36 -0
  187. package/node/third_party/c-ares/src/lib/util/ares_threads.c +613 -0
  188. package/node/third_party/c-ares/src/lib/util/ares_threads.h +60 -0
  189. package/node/third_party/c-ares/src/lib/util/ares_time.h +49 -0
  190. package/node/third_party/c-ares/src/lib/util/ares_timeval.c +95 -0
  191. package/node/third_party/c-ares/src/lib/util/ares_uri.c +1627 -0
  192. package/node/third_party/c-ares/src/lib/util/ares_uri.h +252 -0
  193. package/node/third_party/c-ares/src/lib/windows_port.c +29 -0
  194. package/package.json +1 -1
  195. package/prebuilt/darwin-arm64/cares-a6286c65ca9374a3.a +0 -0
  196. package/prebuilt/darwin-x64/cares-a6286c65ca9374a3.a +0 -0
  197. package/prebuilt/linux-arm64/cares-4ba05ac8e948af8e.a +0 -0
  198. package/prebuilt/linux-arm64-musl/cares-4ba05ac8e948af8e.a +0 -0
  199. package/prebuilt/linux-x64/cares-4ba05ac8e948af8e.a +0 -0
  200. package/prebuilt/linux-x64-musl/cares-4ba05ac8e948af8e.a +0 -0
  201. package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
  202. package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
  203. package/prebuilt/win32-x64/cares-49c9ec95162b912d.a +0 -0
  204. package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
  205. package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  206. package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
  207. package/runtime/include/js_buffer.h +185 -0
  208. package/runtime/include/js_builtins.h +58 -0
  209. package/runtime/include/js_crypto.h +11 -0
  210. package/runtime/include/js_exception.h +3 -0
  211. package/runtime/include/js_function.h +1 -1
  212. package/runtime/include/js_gc.h +13 -10
  213. package/runtime/include/js_jobs.h +2 -0
  214. package/runtime/include/js_object.h +79 -3
  215. package/runtime/include/js_ops.h +27 -0
  216. package/runtime/include/js_runtime.h +1 -0
  217. package/runtime/include/js_web.h +0 -3
  218. package/runtime/include/jscontext.h +8 -0
  219. package/runtime/src/builtins.c +17 -4
  220. package/runtime/src/crypto_internal.h +1 -0
  221. package/runtime/src/crypto_subtle.c +66 -7
  222. package/runtime/src/crypto_tls.c +265 -19
  223. package/runtime/src/function.c +37 -10
  224. package/runtime/src/gc.c +76 -93
  225. package/runtime/src/inspect.c +18 -1
  226. package/runtime/src/iterator.c +5 -1
  227. package/runtime/src/jobs.c +37 -22
  228. package/runtime/src/object.c +91 -8
  229. package/runtime/src/os.c +16 -6
  230. package/runtime/src/os.h +2 -0
  231. package/runtime/src/process.c +97 -10
  232. package/runtime/src/typedarray.c +23 -0
@@ -0,0 +1,1237 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) Massachusetts Institute of Technology
4
+ * Copyright (c) Daniel Stenberg
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice (including the next
14
+ * paragraph) shall be included in all copies or substantial portions of the
15
+ * Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *
25
+ * SPDX-License-Identifier: MIT
26
+ */
27
+
28
+ #ifndef ARES__H
29
+ #define ARES__H
30
+
31
+ #include "ares_version.h" /* c-ares version defines */
32
+ #include "ares_build.h" /* c-ares build definitions */
33
+
34
+ #if defined(_WIN32)
35
+ # ifndef WIN32_LEAN_AND_MEAN
36
+ # define WIN32_LEAN_AND_MEAN
37
+ # endif
38
+ #endif
39
+
40
+ #ifdef CARES_HAVE_SYS_TYPES_H
41
+ # include <sys/types.h>
42
+ #endif
43
+
44
+ #ifdef CARES_HAVE_SYS_SOCKET_H
45
+ # include <sys/socket.h>
46
+ #endif
47
+
48
+ #ifdef CARES_HAVE_SYS_SELECT_H
49
+ # include <sys/select.h>
50
+ #endif
51
+
52
+ #ifdef CARES_HAVE_WINSOCK2_H
53
+ # include <winsock2.h>
54
+ /* To aid with linking against a static c-ares build, lets tell the microsoft
55
+ * compiler to pull in needed dependencies */
56
+ # ifdef _MSC_VER
57
+ # pragma comment(lib, "ws2_32")
58
+ # pragma comment(lib, "advapi32")
59
+ # pragma comment(lib, "iphlpapi")
60
+ # endif
61
+ #endif
62
+
63
+ #ifdef CARES_HAVE_WS2TCPIP_H
64
+ # include <ws2tcpip.h>
65
+ #endif
66
+
67
+ #ifdef CARES_HAVE_WINDOWS_H
68
+ # include <windows.h>
69
+ #endif
70
+
71
+ /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
72
+ libc5-based Linux systems. Only include it on system that are known to
73
+ require it! */
74
+ #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
75
+ defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
76
+ defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \
77
+ defined(__QNX__) || defined(__MVS__) || defined(__HAIKU__)
78
+ # include <sys/select.h>
79
+ #endif
80
+
81
+ #if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
82
+ # include <sys/bsdskt.h>
83
+ #endif
84
+
85
+ #if !defined(_WIN32)
86
+ # include <netinet/in.h>
87
+ #endif
88
+
89
+ #ifdef WATT32
90
+ # include <tcp.h>
91
+ #endif
92
+
93
+ #if defined(ANDROID) || defined(__ANDROID__)
94
+ # include <jni.h>
95
+ #endif
96
+
97
+ typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
98
+ typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;
99
+
100
+ #ifdef __cplusplus
101
+ extern "C" {
102
+ #endif
103
+
104
+ /*
105
+ ** c-ares external API function linkage decorations.
106
+ */
107
+
108
+ #if defined(_WIN32) || defined(__CYGWIN__) || defined(__SYMBIAN32__)
109
+ # ifdef CARES_STATICLIB
110
+ # define CARES_EXTERN
111
+ # else
112
+ # ifdef CARES_BUILDING_LIBRARY
113
+ # define CARES_EXTERN __declspec(dllexport)
114
+ # else
115
+ # define CARES_EXTERN __declspec(dllimport)
116
+ # endif
117
+ # endif
118
+ #else
119
+ # if defined(__GNUC__) && __GNUC__ >= 4
120
+ # define CARES_EXTERN __attribute__((visibility("default")))
121
+ # elif defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 900
122
+ # define CARES_EXTERN __attribute__((visibility("default")))
123
+ # elif defined(__SUNPRO_C)
124
+ # define CARES_EXTERN _global
125
+ # else
126
+ # define CARES_EXTERN
127
+ # endif
128
+ #endif
129
+
130
+ #ifdef __GNUC__
131
+ # define CARES_GCC_VERSION \
132
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
133
+ #else
134
+ # define CARES_GCC_VERSION 0
135
+ #endif
136
+
137
+ #ifndef __has_attribute
138
+ # define __has_attribute(x) 0
139
+ #endif
140
+
141
+ #ifdef CARES_NO_DEPRECATED
142
+ # define CARES_DEPRECATED
143
+ # define CARES_DEPRECATED_FOR(f)
144
+ #else
145
+ # if CARES_GCC_VERSION >= 30200 || __has_attribute(__deprecated__)
146
+ # define CARES_DEPRECATED __attribute__((__deprecated__))
147
+ # else
148
+ # define CARES_DEPRECATED
149
+ # endif
150
+
151
+ # if CARES_GCC_VERSION >= 40500 || defined(__clang__)
152
+ # define CARES_DEPRECATED_FOR(f) \
153
+ __attribute__((deprecated("Use " #f " instead")))
154
+ # elif defined(_MSC_VER)
155
+ # define CARES_DEPRECATED_FOR(f) __declspec(deprecated("Use " #f " instead"))
156
+ # else
157
+ # define CARES_DEPRECATED_FOR(f) CARES_DEPRECATED
158
+ # endif
159
+ #endif
160
+
161
+ typedef enum {
162
+ ARES_SUCCESS = 0,
163
+
164
+ /* Server error codes (ARES_ENODATA indicates no relevant answer) */
165
+ ARES_ENODATA = 1,
166
+ ARES_EFORMERR = 2,
167
+ ARES_ESERVFAIL = 3,
168
+ ARES_ENOTFOUND = 4,
169
+ ARES_ENOTIMP = 5,
170
+ ARES_EREFUSED = 6,
171
+
172
+ /* Locally generated error codes */
173
+ ARES_EBADQUERY = 7,
174
+ ARES_EBADNAME = 8,
175
+ ARES_EBADFAMILY = 9,
176
+ ARES_EBADRESP = 10,
177
+ ARES_ECONNREFUSED = 11,
178
+ ARES_ETIMEOUT = 12,
179
+ ARES_EOF = 13,
180
+ ARES_EFILE = 14,
181
+ ARES_ENOMEM = 15,
182
+ ARES_EDESTRUCTION = 16,
183
+ ARES_EBADSTR = 17,
184
+
185
+ /* ares_getnameinfo error codes */
186
+ ARES_EBADFLAGS = 18,
187
+
188
+ /* ares_getaddrinfo error codes */
189
+ ARES_ENONAME = 19,
190
+ ARES_EBADHINTS = 20,
191
+
192
+ /* Uninitialized library error code */
193
+ ARES_ENOTINITIALIZED = 21, /* introduced in 1.7.0 */
194
+
195
+ /* ares_library_init error codes */
196
+ ARES_ELOADIPHLPAPI = 22, /* introduced in 1.7.0 */
197
+ ARES_EADDRGETNETWORKPARAMS = 23, /* introduced in 1.7.0 */
198
+
199
+ /* More error codes */
200
+ ARES_ECANCELLED = 24, /* introduced in 1.7.0 */
201
+
202
+ /* More ares_getaddrinfo error codes */
203
+ ARES_ESERVICE = 25, /* ares_getaddrinfo() was passed a text service name that
204
+ * is not recognized. introduced in 1.16.0 */
205
+
206
+ ARES_ENOSERVER = 26 /* No DNS servers were configured */
207
+ } ares_status_t;
208
+
209
+ typedef enum {
210
+ ARES_FALSE = 0,
211
+ ARES_TRUE = 1
212
+ } ares_bool_t;
213
+
214
+ /*! Values for ARES_OPT_EVENT_THREAD */
215
+ typedef enum {
216
+ /*! Default (best choice) event system */
217
+ ARES_EVSYS_DEFAULT = 0,
218
+ /*! Win32 IOCP/AFD_POLL event system */
219
+ ARES_EVSYS_WIN32 = 1,
220
+ /*! Linux epoll */
221
+ ARES_EVSYS_EPOLL = 2,
222
+ /*! BSD/MacOS kqueue */
223
+ ARES_EVSYS_KQUEUE = 3,
224
+ /*! POSIX poll() */
225
+ ARES_EVSYS_POLL = 4,
226
+ /*! last fallback on Unix-like systems, select() */
227
+ ARES_EVSYS_SELECT = 5
228
+ } ares_evsys_t;
229
+
230
+ /* Flag values */
231
+ #define ARES_FLAG_USEVC (1 << 0)
232
+ #define ARES_FLAG_PRIMARY (1 << 1)
233
+ #define ARES_FLAG_IGNTC (1 << 2)
234
+ #define ARES_FLAG_NORECURSE (1 << 3)
235
+ #define ARES_FLAG_STAYOPEN (1 << 4)
236
+ #define ARES_FLAG_NOSEARCH (1 << 5)
237
+ #define ARES_FLAG_NOALIASES (1 << 6)
238
+ #define ARES_FLAG_NOCHECKRESP (1 << 7)
239
+ #define ARES_FLAG_EDNS (1 << 8)
240
+ #define ARES_FLAG_NO_DFLT_SVR (1 << 9)
241
+ #define ARES_FLAG_DNS0x20 (1 << 10)
242
+
243
+ /* Option mask values */
244
+ #define ARES_OPT_FLAGS (1 << 0)
245
+ #define ARES_OPT_TIMEOUT (1 << 1)
246
+ #define ARES_OPT_TRIES (1 << 2)
247
+ #define ARES_OPT_NDOTS (1 << 3)
248
+ #define ARES_OPT_UDP_PORT (1 << 4)
249
+ #define ARES_OPT_TCP_PORT (1 << 5)
250
+ #define ARES_OPT_SERVERS (1 << 6)
251
+ #define ARES_OPT_DOMAINS (1 << 7)
252
+ #define ARES_OPT_LOOKUPS (1 << 8)
253
+ #define ARES_OPT_SOCK_STATE_CB (1 << 9)
254
+ #define ARES_OPT_SORTLIST (1 << 10)
255
+ #define ARES_OPT_SOCK_SNDBUF (1 << 11)
256
+ #define ARES_OPT_SOCK_RCVBUF (1 << 12)
257
+ #define ARES_OPT_TIMEOUTMS (1 << 13)
258
+ #define ARES_OPT_ROTATE (1 << 14)
259
+ #define ARES_OPT_EDNSPSZ (1 << 15)
260
+ #define ARES_OPT_NOROTATE (1 << 16)
261
+ #define ARES_OPT_RESOLVCONF (1 << 17)
262
+ #define ARES_OPT_HOSTS_FILE (1 << 18)
263
+ #define ARES_OPT_UDP_MAX_QUERIES (1 << 19)
264
+ #define ARES_OPT_MAXTIMEOUTMS (1 << 20)
265
+ #define ARES_OPT_QUERY_CACHE (1 << 21)
266
+ #define ARES_OPT_EVENT_THREAD (1 << 22)
267
+ #define ARES_OPT_SERVER_FAILOVER (1 << 23)
268
+
269
+ /* Nameinfo flag values */
270
+ #define ARES_NI_NOFQDN (1 << 0)
271
+ #define ARES_NI_NUMERICHOST (1 << 1)
272
+ #define ARES_NI_NAMEREQD (1 << 2)
273
+ #define ARES_NI_NUMERICSERV (1 << 3)
274
+ #define ARES_NI_DGRAM (1 << 4)
275
+ #define ARES_NI_TCP 0
276
+ #define ARES_NI_UDP ARES_NI_DGRAM
277
+ #define ARES_NI_SCTP (1 << 5)
278
+ #define ARES_NI_DCCP (1 << 6)
279
+ #define ARES_NI_NUMERICSCOPE (1 << 7)
280
+ #define ARES_NI_LOOKUPHOST (1 << 8)
281
+ #define ARES_NI_LOOKUPSERVICE (1 << 9)
282
+ /* Reserved for future use */
283
+ #define ARES_NI_IDN (1 << 10)
284
+ #define ARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11)
285
+ #define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
286
+
287
+ /* Addrinfo flag values */
288
+ #define ARES_AI_CANONNAME (1 << 0)
289
+ #define ARES_AI_NUMERICHOST (1 << 1)
290
+ #define ARES_AI_PASSIVE (1 << 2)
291
+ #define ARES_AI_NUMERICSERV (1 << 3)
292
+ #define ARES_AI_V4MAPPED (1 << 4)
293
+ #define ARES_AI_ALL (1 << 5)
294
+ #define ARES_AI_ADDRCONFIG (1 << 6)
295
+ #define ARES_AI_NOSORT (1 << 7)
296
+ #define ARES_AI_ENVHOSTS (1 << 8)
297
+ /* Reserved for future use */
298
+ #define ARES_AI_IDN (1 << 10)
299
+ #define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11)
300
+ #define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
301
+ #define ARES_AI_CANONIDN (1 << 13)
302
+
303
+ #define ARES_AI_MASK \
304
+ (ARES_AI_CANONNAME | ARES_AI_NUMERICHOST | ARES_AI_PASSIVE | \
305
+ ARES_AI_NUMERICSERV | ARES_AI_V4MAPPED | ARES_AI_ALL | ARES_AI_ADDRCONFIG)
306
+ #define ARES_GETSOCK_MAXNUM \
307
+ 16 /* ares_getsock() can return info about this \
308
+ many sockets */
309
+ #define ARES_GETSOCK_READABLE(bits, num) (bits & (1 << (num)))
310
+ #define ARES_GETSOCK_WRITABLE(bits, num) \
311
+ (bits & (1 << ((num) + ARES_GETSOCK_MAXNUM)))
312
+
313
+ /* c-ares library initialization flag values */
314
+ #define ARES_LIB_INIT_NONE (0)
315
+ #define ARES_LIB_INIT_WIN32 (1 << 0)
316
+ #define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32)
317
+
318
+ /* Server state callback flag values */
319
+ #define ARES_SERV_STATE_UDP (1 << 0) /* Query used UDP */
320
+ #define ARES_SERV_STATE_TCP (1 << 1) /* Query used TCP */
321
+
322
+ /*
323
+ * Typedef our socket type
324
+ */
325
+
326
+ #ifndef ares_socket_typedef
327
+ # if defined(_WIN32) && !defined(WATT32)
328
+ typedef SOCKET ares_socket_t;
329
+ # define ARES_SOCKET_BAD INVALID_SOCKET
330
+ # else
331
+ typedef int ares_socket_t;
332
+ # define ARES_SOCKET_BAD -1
333
+ # endif
334
+ # define ares_socket_typedef
335
+ #endif /* ares_socket_typedef */
336
+
337
+ typedef void (*ares_sock_state_cb)(void *data, ares_socket_t socket_fd,
338
+ int readable, int writable);
339
+
340
+ struct apattern;
341
+
342
+ /* Options controlling server failover behavior.
343
+ * The retry chance is the probability (1/N) by which we will retry a failed
344
+ * server instead of the best server when selecting a server to send queries
345
+ * to.
346
+ * The retry delay is the minimum time in milliseconds to wait between doing
347
+ * such retries (applied per-server).
348
+ */
349
+ struct ares_server_failover_options {
350
+ unsigned short retry_chance;
351
+ size_t retry_delay;
352
+ };
353
+
354
+ /* NOTE about the ares_options struct to users and developers.
355
+
356
+ This struct will remain looking like this. It will not be extended nor
357
+ shrunk in future releases, but all new options will be set by ares_set_*()
358
+ options instead of with the ares_init_options() function.
359
+
360
+ Eventually (in a galaxy far far away), all options will be settable by
361
+ ares_set_*() options and the ares_init_options() function will become
362
+ deprecated.
363
+
364
+ When new options are added to c-ares, they are not added to this
365
+ struct. And they are not "saved" with the ares_save_options() function but
366
+ instead we encourage the use of the ares_dup() function. Needless to say,
367
+ if you add config options to c-ares you need to make sure ares_dup()
368
+ duplicates this new option.
369
+
370
+ */
371
+ struct ares_options {
372
+ int flags;
373
+ int timeout; /* in seconds or milliseconds, depending on options */
374
+ int tries;
375
+ int ndots;
376
+ unsigned short udp_port; /* host byte order */
377
+ unsigned short tcp_port; /* host byte order */
378
+ int socket_send_buffer_size;
379
+ int socket_receive_buffer_size;
380
+ struct in_addr *servers;
381
+ int nservers;
382
+ char **domains;
383
+ int ndomains;
384
+ char *lookups;
385
+ ares_sock_state_cb sock_state_cb;
386
+ void *sock_state_cb_data;
387
+ struct apattern *sortlist;
388
+ int nsort;
389
+ int ednspsz;
390
+ char *resolvconf_path;
391
+ char *hosts_path;
392
+ int udp_max_queries;
393
+ int maxtimeout; /* in milliseconds */
394
+ unsigned int qcache_max_ttl; /* Maximum TTL for query cache, 0=disabled */
395
+ ares_evsys_t evsys;
396
+ struct ares_server_failover_options server_failover_opts;
397
+ };
398
+
399
+ struct hostent;
400
+ struct timeval;
401
+ struct sockaddr;
402
+ struct ares_channeldata;
403
+ struct ares_addrinfo;
404
+ struct ares_addrinfo_hints;
405
+
406
+ /* Legacy typedef, don't use, you can't specify "const" */
407
+ typedef struct ares_channeldata *ares_channel;
408
+
409
+ /* Current main channel typedef */
410
+ typedef struct ares_channeldata ares_channel_t;
411
+
412
+ /*
413
+ * NOTE: before c-ares 1.7.0 we would most often use the system in6_addr
414
+ * struct below when ares itself was built, but many apps would use this
415
+ * private version since the header checked a HAVE_* define for it. Starting
416
+ * with 1.7.0 we always declare and use our own to stop relying on the
417
+ * system's one.
418
+ */
419
+ struct ares_in6_addr {
420
+ union {
421
+ unsigned char _S6_u8[16];
422
+ } _S6_un;
423
+ };
424
+
425
+ struct ares_addr {
426
+ int family;
427
+
428
+ union {
429
+ struct in_addr addr4;
430
+ struct ares_in6_addr addr6;
431
+ } addr;
432
+ };
433
+
434
+ /* DNS record parser, writer, and helpers */
435
+ #include "ares_dns_record.h"
436
+
437
+ /* IMPORTANT: the pointer parameters below (abuf, hostent, node, service) are
438
+ * intentionally NOT const. Marking them const changes the function-pointer
439
+ * type and breaks API/ABI compatibility for existing C and (especially) C++
440
+ * applications that declare their callbacks with the historical non-const
441
+ * signature. This was tried in PR #1060 and reverted for that reason. These
442
+ * buffers are owned by c-ares and MUST be treated as read-only by the callback
443
+ * (do not modify or free them); that contract is documented in the man pages,
444
+ * not enforced via const, to preserve compatibility. Do not re-add const. */
445
+ typedef void (*ares_callback)(void *arg, int status, int timeouts,
446
+ unsigned char *abuf, int alen);
447
+
448
+ typedef void (*ares_callback_dnsrec)(void *arg, ares_status_t status,
449
+ size_t timeouts,
450
+ const ares_dns_record_t *dnsrec);
451
+
452
+ typedef void (*ares_host_callback)(void *arg, int status, int timeouts,
453
+ struct hostent *hostent);
454
+
455
+ typedef void (*ares_nameinfo_callback)(void *arg, int status, int timeouts,
456
+ char *node, char *service);
457
+
458
+ typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd, int type,
459
+ void *data);
460
+
461
+ typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd, int type,
462
+ void *data);
463
+
464
+ typedef void (*ares_addrinfo_callback)(void *arg, int status, int timeouts,
465
+ struct ares_addrinfo *res);
466
+
467
+ typedef void (*ares_server_state_callback)(const char *server_string,
468
+ ares_bool_t success, int flags,
469
+ void *data);
470
+
471
+ typedef void (*ares_pending_write_cb)(void *data);
472
+
473
+ CARES_EXTERN int ares_library_init(int flags);
474
+
475
+ CARES_EXTERN int ares_library_init_mem(int flags, void *(*amalloc)(size_t size),
476
+ void (*afree)(void *ptr),
477
+ void *(*arealloc)(void *ptr,
478
+ size_t size));
479
+
480
+ #if defined(ANDROID) || defined(__ANDROID__)
481
+ CARES_EXTERN void ares_library_init_jvm(JavaVM *jvm);
482
+ CARES_EXTERN int ares_library_init_android(jobject connectivity_manager);
483
+ CARES_EXTERN int ares_library_android_initialized(void);
484
+ #endif
485
+
486
+ #define CARES_HAVE_ARES_LIBRARY_INIT 1
487
+ #define CARES_HAVE_ARES_LIBRARY_CLEANUP 1
488
+
489
+ CARES_EXTERN int ares_library_initialized(void);
490
+
491
+ CARES_EXTERN void ares_library_cleanup(void);
492
+
493
+ CARES_EXTERN const char *ares_version(int *version);
494
+
495
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_init_options) int ares_init(
496
+ ares_channel_t **channelptr);
497
+
498
+ CARES_EXTERN int ares_init_options(ares_channel_t **channelptr,
499
+ const struct ares_options *options,
500
+ int optmask);
501
+
502
+ CARES_EXTERN int ares_save_options(const ares_channel_t *channel,
503
+ struct ares_options *options, int *optmask);
504
+
505
+ CARES_EXTERN void ares_destroy_options(struct ares_options *options);
506
+
507
+ CARES_EXTERN int ares_dup(ares_channel_t **dest, const ares_channel_t *src);
508
+
509
+ CARES_EXTERN ares_status_t ares_reinit(ares_channel_t *channel);
510
+
511
+ CARES_EXTERN void ares_destroy(ares_channel_t *channel);
512
+
513
+ CARES_EXTERN void ares_cancel(ares_channel_t *channel);
514
+
515
+ /* These next 3 configure local binding for the out-going socket
516
+ * connection. Use these to specify source IP and/or network device
517
+ * on multi-homed systems.
518
+ */
519
+ CARES_EXTERN void ares_set_local_ip4(ares_channel_t *channel,
520
+ unsigned int local_ip);
521
+
522
+ /* local_ip6 should be 16 bytes in length */
523
+ CARES_EXTERN void ares_set_local_ip6(ares_channel_t *channel,
524
+ const unsigned char *local_ip6);
525
+
526
+ /* local_dev_name should be null terminated. */
527
+ CARES_EXTERN void ares_set_local_dev(ares_channel_t *channel,
528
+ const char *local_dev_name);
529
+
530
+ CARES_EXTERN void ares_set_socket_callback(ares_channel_t *channel,
531
+ ares_sock_create_callback callback,
532
+ void *user_data);
533
+
534
+ CARES_EXTERN void ares_set_socket_configure_callback(
535
+ ares_channel_t *channel, ares_sock_config_callback callback, void *user_data);
536
+
537
+ CARES_EXTERN void
538
+ ares_set_server_state_callback(ares_channel_t *channel,
539
+ ares_server_state_callback callback,
540
+ void *user_data);
541
+
542
+ CARES_EXTERN void ares_set_pending_write_cb(ares_channel_t *channel,
543
+ ares_pending_write_cb callback,
544
+ void *user_data);
545
+
546
+ CARES_EXTERN void ares_process_pending_write(ares_channel_t *channel);
547
+
548
+ CARES_EXTERN int ares_set_sortlist(ares_channel_t *channel,
549
+ const char *sortstr);
550
+
551
+ CARES_EXTERN void ares_getaddrinfo(ares_channel_t *channel, const char *node,
552
+ const char *service,
553
+ const struct ares_addrinfo_hints *hints,
554
+ ares_addrinfo_callback callback, void *arg);
555
+
556
+ CARES_EXTERN void ares_freeaddrinfo(struct ares_addrinfo *ai);
557
+
558
+ /*
559
+ * Virtual function set to have user-managed socket IO.
560
+ * Note that all functions need to be defined, and when
561
+ * set, the library will not do any bind nor set any
562
+ * socket options, assuming the client handles these
563
+ * through either socket creation or the
564
+ * ares_sock_config_callback call.
565
+ */
566
+ struct iovec;
567
+
568
+ struct ares_socket_functions {
569
+ ares_socket_t (*asocket)(int, int, int, void *);
570
+ int (*aclose)(ares_socket_t, void *);
571
+ int (*aconnect)(ares_socket_t, const struct sockaddr *, ares_socklen_t,
572
+ void *);
573
+ ares_ssize_t (*arecvfrom)(ares_socket_t, void *, size_t, int,
574
+ struct sockaddr *, ares_socklen_t *, void *);
575
+ ares_ssize_t (*asendv)(ares_socket_t, const struct iovec *, int, void *);
576
+ };
577
+
578
+ CARES_EXTERN CARES_DEPRECATED_FOR(
579
+ ares_set_socket_functions_ex) void ares_set_socket_functions(ares_channel_t
580
+ *channel,
581
+ const struct
582
+ ares_socket_functions
583
+ *funcs,
584
+ void *user_data);
585
+
586
+ /*! Flags defining behavior of socket functions */
587
+ typedef enum {
588
+ /*! Strongly recommended to create sockets as non-blocking and set this
589
+ * flag */
590
+ ARES_SOCKFUNC_FLAG_NONBLOCKING = 1 << 0
591
+ } ares_sockfunc_flags_t;
592
+
593
+ /*! Socket options in request to asetsockopt() in struct
594
+ * ares_socket_functions_ex */
595
+ typedef enum {
596
+ /*! Set the send buffer size. Value is a pointer to an int. (SO_SNDBUF) */
597
+ ARES_SOCKET_OPT_SENDBUF_SIZE,
598
+ /*! Set the recv buffer size. Value is a pointer to an int. (SO_RCVBUF) */
599
+ ARES_SOCKET_OPT_RECVBUF_SIZE,
600
+ /*! Set the network interface to use as the source for communication.
601
+ * Value is a C string. (SO_BINDTODEVICE) */
602
+ ARES_SOCKET_OPT_BIND_DEVICE,
603
+ /*! Enable TCP Fast Open. Value is a pointer to an ares_bool_t. On some
604
+ * systems this could be a no-op if it is known it is on by default and
605
+ * return success. Other systems may be a no-op if known the system does
606
+ * not support the feature and returns failure with errno set to ENOSYS or
607
+ * WSASetLastError(WSAEOPNOTSUPP).
608
+ */
609
+ ARES_SOCKET_OPT_TCP_FASTOPEN
610
+ } ares_socket_opt_t;
611
+
612
+ /*! Flags for behavior during connect */
613
+ typedef enum {
614
+ /*! Connect using TCP Fast Open */
615
+ ARES_SOCKET_CONN_TCP_FASTOPEN = 1 << 0
616
+ } ares_socket_connect_flags_t;
617
+
618
+ /*! Flags for behavior during bind */
619
+ typedef enum {
620
+ /*! Bind is for a TCP connection */
621
+ ARES_SOCKET_BIND_TCP = 1 << 0,
622
+ /*! Bind is for a client connection, not server */
623
+ ARES_SOCKET_BIND_CLIENT = 1 << 1
624
+ } ares_socket_bind_flags_t;
625
+
626
+ /*! Socket functions to call rather than using OS-native functions */
627
+ struct ares_socket_functions_ex {
628
+ /*! ABI Version: must be "1" */
629
+ unsigned int version;
630
+
631
+ /*! Flags indicating behavior of the subsystem. One or more
632
+ * ares_sockfunc_flags_t */
633
+ unsigned int flags;
634
+
635
+ /*! REQUIRED. Create a new socket file descriptor. The file descriptor must
636
+ * be opened in non-blocking mode (so that reads and writes never block).
637
+ * Recommended other options would be to disable signals on write errors
638
+ * (SO_NOSIGPIPE), Disable the Nagle algorithm on SOCK_STREAM (TCP_NODELAY),
639
+ * and to automatically close file descriptors on exec (FD_CLOEXEC).
640
+ *
641
+ * \param[in] domain Socket domain. Valid values are AF_INET, AF_INET6.
642
+ * \param[in] type Socket type. Valid values are SOCK_STREAM (tcp) and
643
+ * SOCK_DGRAM (udp).
644
+ * \param[in] protocol In general this should be ignored, may be passed as
645
+ * 0 (use as default for type), or may be IPPROTO_UDP
646
+ * or IPPROTO_TCP.
647
+ * \param[in] user_data Pointer provided to ares_set_socket_functions_ex().
648
+ * \return ARES_SOCKET_BAD on error, or socket file descriptor on success.
649
+ * On error, it is expected to set errno (or WSASetLastError()) to an
650
+ * appropriate reason code such as EAFNOSUPPORT / WSAAFNOSUPPORT. */
651
+ ares_socket_t (*asocket)(int domain, int type, int protocol, void *user_data);
652
+
653
+ /*! REQUIRED. Close a socket file descriptor.
654
+ * \param[in] sock Socket file descriptor returned from asocket.
655
+ * \param[in] user_data Pointer provided to ares_set_socket_functions_ex().
656
+ * \return 0 on success. On failure, should set errno (or WSASetLastError)
657
+ * to an appropriate code such as EBADF / WSAEBADF */
658
+ int (*aclose)(ares_socket_t sock, void *user_data);
659
+
660
+
661
+ /*! REQUIRED. Set socket option. This shares a similar syntax to the BSD
662
+ * setsockopt() call, however we use our own options. The value is typically
663
+ * a pointer to the desired value and each option has its own data type it
664
+ * will express in the documentation.
665
+ *
666
+ * \param[in] sock Socket file descriptor returned from asocket.
667
+ * \param[in] opt Option to set.
668
+ * \param[in] val Pointer to value for option.
669
+ * \param[in] val_size Size of value.
670
+ * \param[in] user_data Pointer provided to
671
+ * ares_set_socket_functions_ex().
672
+ * \return Return 0 on success, otherwise -1 should be returned with an
673
+ * appropriate errno (or WSASetLastError()) set. If error is ENOSYS /
674
+ * WSAEOPNOTSUPP an error will not be propagated as it will take it
675
+ * to mean it is an intentional decision to not support the feature.
676
+ */
677
+ int (*asetsockopt)(ares_socket_t sock, ares_socket_opt_t opt, const void *val,
678
+ ares_socklen_t val_size, void *user_data);
679
+
680
+ /*! REQUIRED. Connect to the remote using the supplied address. For UDP
681
+ * sockets this will bind the file descriptor to only send and receive packets
682
+ * from the remote address provided.
683
+ *
684
+ * \param[in] sock Socket file descriptor returned from asocket.
685
+ * \param[in] address Address to connect to
686
+ * \param[in] address_len Size of address structure passed
687
+ * \param[in] flags One or more ares_socket_connect_flags_t
688
+ * \param[in] user_data Pointer provided to
689
+ * ares_set_socket_functions_ex().
690
+ * \return Return 0 upon successful establishement, otherwise -1 should be
691
+ * returned with an appropriate errno (or WSASetLastError()) set. It
692
+ * is generally expected that most TCP connections (not using TCP Fast Open)
693
+ * will return -1 with an error of EINPROGRESS / WSAEINPROGRESS due to the
694
+ * non-blocking nature of the connection. It is then the responsibility of
695
+ * the implementation to notify of writability on the socket to indicate the
696
+ * connection has succeeded (or readability on failure to retrieve the
697
+ * appropriate error).
698
+ */
699
+ int (*aconnect)(ares_socket_t sock, const struct sockaddr *address,
700
+ ares_socklen_t address_len, unsigned int flags,
701
+ void *user_data);
702
+
703
+ /*! REQUIRED. Attempt to read data from the remote.
704
+ *
705
+ * \param[in] sock Socket file descriptor returned from asocket.
706
+ * \param[in,out] buffer Allocated buffer to place data read from
707
+ * socket.
708
+ * \param[in] length Size of buffer
709
+ * \param[in] flags Unused, always 0.
710
+ * \param[in,out] address Buffer to hold address data was received from.
711
+ * May be NULL if address not desired.
712
+ * \param[in,out] address_len Input size of address buffer, output actual
713
+ * written size. Must be NULL if address is NULL.
714
+ * \param[in] user_data Pointer provided to
715
+ * ares_set_socket_functions_ex().
716
+ * \return -1 on error with appropriate errno (or WSASetLastError()) set,
717
+ * such as EWOULDBLOCK / EAGAIN / WSAEWOULDBLOCK, or ECONNRESET /
718
+ * WSAECONNRESET.
719
+ */
720
+ ares_ssize_t (*arecvfrom)(ares_socket_t sock, void *buffer, size_t length,
721
+ int flags, struct sockaddr *address,
722
+ ares_socklen_t *address_len, void *user_data);
723
+
724
+ /*! REQUIRED. Attempt to send data to the remote. Optional address may be
725
+ * specified which may be useful on unbound UDP sockets (though currently not
726
+ * used), and TCP FastOpen where the connection is delayed until first write.
727
+ *
728
+ * \param[in] sock Socket file descriptor returned from asocket.
729
+ * \param[in] buffer Containing data to place onto wire.
730
+ * \param[in] length Size of buffer
731
+ * \param[in] flags Flags for writing. Currently only used flag is
732
+ * MSG_NOSIGNAL if the host OS has such a flag. In
733
+ * general flags can be ignored.
734
+ * \param[in] address Buffer containing address to send data to. May
735
+ * be NULL.
736
+ * \param[in,out] address_len Size of address buffer. Must be 0 if address
737
+ * is NULL.
738
+ * \param[in] user_data Pointer provided to
739
+ * ares_set_socket_functions_ex().
740
+ * \return Number of bytes written. -1 on error with appropriate errno (or
741
+ * WSASetLastError()) set.
742
+ */
743
+ ares_ssize_t (*asendto)(ares_socket_t sock, const void *buffer, size_t length,
744
+ int flags, const struct sockaddr *address,
745
+ ares_socklen_t address_len, void *user_data);
746
+
747
+ /*! Optional. Retrieve the local address of the socket.
748
+ *
749
+ * \param[in] sock Socket file descriptor returned from asocket
750
+ * \param[in,out] address Buffer to hold address
751
+ * \param[in,out] address_len Size of address buffer on input, written size
752
+ * on output.
753
+ * \param[in] user_data Pointer provided to
754
+ * ares_set_socket_functions_ex().
755
+ * \return 0 on success. -1 on error with an appropriate errno (or
756
+ * WSASetLastError()) set.
757
+ */
758
+ int (*agetsockname)(ares_socket_t sock, struct sockaddr *address,
759
+ ares_socklen_t *address_len, void *user_data);
760
+
761
+ /*! Optional. Bind the socket to an address. This can be used for client
762
+ * connections to bind the source address for packets before connect, or
763
+ * for server connections to bind to an address and port before listening.
764
+ * Currently c-ares only supports client connections.
765
+ *
766
+ * \param[in] sock Socket file descriptor returned from asocket
767
+ * \param[in] flags ares_socket_bind_flags_t flags.
768
+ * \param[in] address Buffer containing address.
769
+ * \param[in] address_len Size of address buffer.
770
+ * \param[in] user_data Pointer provided to
771
+ * ares_set_socket_functions_ex().
772
+ * \return 0 on success. -1 on error with an appropriate errno (or
773
+ * WSASetLastError()) set.
774
+ */
775
+ int (*abind)(ares_socket_t sock, unsigned int flags,
776
+ const struct sockaddr *address, socklen_t address_len,
777
+ void *user_data);
778
+
779
+ /* Optional. Convert an interface name into the interface index. If this
780
+ * callback is not specified, then IPv6 Link-Local DNS servers cannot be used.
781
+ *
782
+ * \param[in] ifname Interface Name as NULL-terminated string.
783
+ * \param[in] user_data Pointer provided to
784
+ * ares_set_socket_functions_ex().
785
+ * \return 0 on failure, otherwise interface index.
786
+ */
787
+ unsigned int (*aif_nametoindex)(const char *ifname, void *user_data);
788
+
789
+ /* Optional. Convert an interface index into the interface name. If this
790
+ * callback is not specified, then IPv6 Link-Local DNS servers cannot be used.
791
+ *
792
+ * \param[in] ifindex Interface index, must be > 0
793
+ * \param[in] ifname_buf Buffer to hold interface name. Must be at least
794
+ * IFNAMSIZ in length or 32 bytes if IFNAMSIZ isn't
795
+ * defined.
796
+ * \param[in] ifname_buf_len Size of ifname_buf for verification.
797
+ * \param[in] user_data Pointer provided to
798
+ * ares_set_socket_functions_ex().
799
+ * \return NULL on failure, otherwise pointer to provided ifname_buf
800
+ */
801
+ const char *(*aif_indextoname)(unsigned int ifindex, char *ifname_buf,
802
+ size_t ifname_buf_len, void *user_data);
803
+ };
804
+
805
+ /*! Override the native socket functions for the OS with the provided set.
806
+ * An optional user data thunk may be specified which will be passed to
807
+ * each registered callback. Replaces ares_set_socket_functions().
808
+ *
809
+ * \param[in] channel An initialized c-ares channel.
810
+ * \param[in] funcs Structure registering the implementations for the
811
+ * various functions. See the structure definition.
812
+ * This will be duplicated and does not need to exist
813
+ * past the life of this call.
814
+ * \param[in] user_data User data thunk which will be passed to each call of
815
+ * the registered callbacks.
816
+ * \return ARES_SUCCESS on success, or another error code such as ARES_EFORMERR
817
+ * on misuse.
818
+ */
819
+ CARES_EXTERN ares_status_t ares_set_socket_functions_ex(
820
+ ares_channel_t *channel, const struct ares_socket_functions_ex *funcs,
821
+ void *user_data);
822
+
823
+
824
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_send_dnsrec) void ares_send(
825
+ ares_channel_t *channel, const unsigned char *qbuf, int qlen,
826
+ ares_callback callback, void *arg);
827
+
828
+ /*! Send a DNS query as an ares_dns_record_t with a callback containing the
829
+ * parsed DNS record.
830
+ *
831
+ * \param[in] channel Pointer to channel on which queries will be sent.
832
+ * \param[in] dnsrec DNS Record to send
833
+ * \param[in] callback Callback function invoked on completion or failure of
834
+ * the query sequence.
835
+ * \param[in] arg Additional argument passed to the callback function.
836
+ * \param[out] qid Query ID
837
+ * \return One of the c-ares status codes.
838
+ */
839
+ CARES_EXTERN ares_status_t ares_send_dnsrec(ares_channel_t *channel,
840
+ const ares_dns_record_t *dnsrec,
841
+ ares_callback_dnsrec callback,
842
+ void *arg, unsigned short *qid);
843
+
844
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_query_dnsrec) void ares_query(
845
+ ares_channel_t *channel, const char *name, int dnsclass, int type,
846
+ ares_callback callback, void *arg);
847
+
848
+ /*! Perform a DNS query with a callback containing the parsed DNS record.
849
+ *
850
+ * \param[in] channel Pointer to channel on which queries will be sent.
851
+ * \param[in] name Query name
852
+ * \param[in] dnsclass DNS Class
853
+ * \param[in] type DNS Record Type
854
+ * \param[in] callback Callback function invoked on completion or failure of
855
+ * the query sequence.
856
+ * \param[in] arg Additional argument passed to the callback function.
857
+ * \param[out] qid Query ID
858
+ * \return One of the c-ares status codes.
859
+ */
860
+ CARES_EXTERN ares_status_t ares_query_dnsrec(ares_channel_t *channel,
861
+ const char *name,
862
+ ares_dns_class_t dnsclass,
863
+ ares_dns_rec_type_t type,
864
+ ares_callback_dnsrec callback,
865
+ void *arg, unsigned short *qid);
866
+
867
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_search_dnsrec) void ares_search(
868
+ ares_channel_t *channel, const char *name, int dnsclass, int type,
869
+ ares_callback callback, void *arg);
870
+
871
+ /*! Search for a complete DNS message.
872
+ *
873
+ * \param[in] channel Pointer to channel on which queries will be sent.
874
+ * \param[in] dnsrec Pointer to initialized and filled DNS record object.
875
+ * \param[in] callback Callback function invoked on completion or failure of
876
+ * the query sequence.
877
+ * \param[in] arg Additional argument passed to the callback function.
878
+ * \return One of the c-ares status codes. In all cases, except
879
+ * ARES_EFORMERR due to misuse, this error code will also be sent
880
+ * to the provided callback.
881
+ */
882
+ CARES_EXTERN ares_status_t ares_search_dnsrec(ares_channel_t *channel,
883
+ const ares_dns_record_t *dnsrec,
884
+ ares_callback_dnsrec callback,
885
+ void *arg);
886
+
887
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_getaddrinfo) void ares_gethostbyname(
888
+ ares_channel_t *channel, const char *name, int family,
889
+ ares_host_callback callback, void *arg);
890
+
891
+ CARES_EXTERN int ares_gethostbyname_file(ares_channel_t *channel,
892
+ const char *name, int family,
893
+ struct hostent **host);
894
+
895
+ CARES_EXTERN void ares_gethostbyaddr(ares_channel_t *channel, const void *addr,
896
+ int addrlen, int family,
897
+ ares_host_callback callback, void *arg);
898
+
899
+ CARES_EXTERN void ares_getnameinfo(ares_channel_t *channel,
900
+ const struct sockaddr *sa,
901
+ ares_socklen_t salen, int flags,
902
+ ares_nameinfo_callback callback, void *arg);
903
+
904
+ CARES_EXTERN CARES_DEPRECATED_FOR(
905
+ ARES_OPT_EVENT_THREAD or
906
+ ARES_OPT_SOCK_STATE_CB) int ares_fds(const ares_channel_t *channel,
907
+ fd_set *read_fds, fd_set *write_fds);
908
+
909
+ CARES_EXTERN CARES_DEPRECATED_FOR(
910
+ ARES_OPT_EVENT_THREAD or
911
+ ARES_OPT_SOCK_STATE_CB) int ares_getsock(const ares_channel_t *channel,
912
+ ares_socket_t *socks, int numsocks);
913
+
914
+ CARES_EXTERN struct timeval *ares_timeout(const ares_channel_t *channel,
915
+ struct timeval *maxtv,
916
+ struct timeval *tv);
917
+
918
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_process_fds) void ares_process(
919
+ ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds);
920
+
921
+ /*! Events used by ares_fd_events_t */
922
+ typedef enum {
923
+ ARES_FD_EVENT_NONE = 0, /*!< No events */
924
+ ARES_FD_EVENT_READ = 1 << 0, /*!< Read event (including disconnect/error) */
925
+ ARES_FD_EVENT_WRITE = 1 << 1 /*!< Write event */
926
+ } ares_fd_eventflag_t;
927
+
928
+ /*! Type holding a file descriptor and mask of events, used by
929
+ * ares_process_fds() */
930
+ typedef struct {
931
+ ares_socket_t fd; /*!< File descriptor */
932
+ unsigned int events; /*!< Mask of ares_fd_eventflag_t */
933
+ } ares_fd_events_t;
934
+
935
+ /*! Flags used by ares_process_fds() */
936
+ typedef enum {
937
+ ARES_PROCESS_FLAG_NONE = 0, /*!< No flag value */
938
+ ARES_PROCESS_FLAG_SKIP_NON_FD = 1 << 0 /*!< skip any processing unrelated to
939
+ * the file descriptor events passed
940
+ * in */
941
+ } ares_process_flag_t;
942
+
943
+ /*! Process events on multiple file descriptors based on the event mask
944
+ * associated with each file descriptor. Recommended over calling
945
+ * ares_process_fd() multiple times since it would trigger additional logic
946
+ * such as timeout processing on each call.
947
+ *
948
+ * \param[in] channel Initialized ares channel
949
+ * \param[in] events Array of file descriptors with events. May be NULL if
950
+ * no events, but may have timeouts to process.
951
+ * \param[in] nevents Number of elements in the events array. May be 0 if
952
+ * no events, but may have timeouts to process.
953
+ * \param[in] flags Flags to alter behavior of the process command.
954
+ * \return ARES_ENOMEM on out of memory, ARES_EFORMERR on misuse,
955
+ * otherwise ARES_SUCCESS
956
+ */
957
+ CARES_EXTERN ares_status_t ares_process_fds(ares_channel_t *channel,
958
+ const ares_fd_events_t *events,
959
+ size_t nevents, unsigned int flags);
960
+
961
+ CARES_EXTERN void ares_process_fd(ares_channel_t *channel,
962
+ ares_socket_t read_fd,
963
+ ares_socket_t write_fd);
964
+
965
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_record_create) int ares_create_query(
966
+ const char *name, int dnsclass, int type, unsigned short id, int rd,
967
+ unsigned char **buf, int *buflen, int max_udp_size);
968
+
969
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_record_create) int ares_mkquery(
970
+ const char *name, int dnsclass, int type, unsigned short id, int rd,
971
+ unsigned char **buf, int *buflen);
972
+
973
+ CARES_EXTERN int ares_expand_name(const unsigned char *encoded,
974
+ const unsigned char *abuf, int alen, char **s,
975
+ long *enclen);
976
+
977
+ CARES_EXTERN int ares_expand_string(const unsigned char *encoded,
978
+ const unsigned char *abuf, int alen,
979
+ unsigned char **s, long *enclen);
980
+
981
+ struct ares_addrttl {
982
+ struct in_addr ipaddr;
983
+ int ttl;
984
+ };
985
+
986
+ struct ares_addr6ttl {
987
+ struct ares_in6_addr ip6addr;
988
+ int ttl;
989
+ };
990
+
991
+ struct ares_caa_reply {
992
+ struct ares_caa_reply *next;
993
+ int critical;
994
+ unsigned char *property;
995
+ size_t plength; /* plength excludes null termination */
996
+ unsigned char *value;
997
+ size_t length; /* length excludes null termination */
998
+ };
999
+
1000
+ struct ares_srv_reply {
1001
+ struct ares_srv_reply *next;
1002
+ char *host;
1003
+ unsigned short priority;
1004
+ unsigned short weight;
1005
+ unsigned short port;
1006
+ };
1007
+
1008
+ struct ares_mx_reply {
1009
+ struct ares_mx_reply *next;
1010
+ char *host;
1011
+ unsigned short priority;
1012
+ };
1013
+
1014
+ struct ares_txt_reply {
1015
+ struct ares_txt_reply *next;
1016
+ unsigned char *txt;
1017
+ size_t length; /* length excludes null termination */
1018
+ };
1019
+
1020
+ /* NOTE: This structure is a superset of ares_txt_reply
1021
+ */
1022
+ struct ares_txt_ext {
1023
+ struct ares_txt_ext *next;
1024
+ unsigned char *txt;
1025
+ size_t length;
1026
+ /* 1 - if start of new record
1027
+ * 0 - if a chunk in the same record */
1028
+ unsigned char record_start;
1029
+ };
1030
+
1031
+ struct ares_naptr_reply {
1032
+ struct ares_naptr_reply *next;
1033
+ unsigned char *flags;
1034
+ unsigned char *service;
1035
+ unsigned char *regexp;
1036
+ char *replacement;
1037
+ unsigned short order;
1038
+ unsigned short preference;
1039
+ };
1040
+
1041
+ struct ares_soa_reply {
1042
+ char *nsname;
1043
+ char *hostmaster;
1044
+ unsigned int serial;
1045
+ unsigned int refresh;
1046
+ unsigned int retry;
1047
+ unsigned int expire;
1048
+ unsigned int minttl;
1049
+ };
1050
+
1051
+ struct ares_uri_reply {
1052
+ struct ares_uri_reply *next;
1053
+ unsigned short priority;
1054
+ unsigned short weight;
1055
+ char *uri;
1056
+ int ttl;
1057
+ };
1058
+
1059
+ /*
1060
+ * Similar to addrinfo, but with extra ttl and missing canonname.
1061
+ */
1062
+ struct ares_addrinfo_node {
1063
+ int ai_ttl;
1064
+ int ai_flags;
1065
+ int ai_family;
1066
+ int ai_socktype;
1067
+ int ai_protocol;
1068
+ ares_socklen_t ai_addrlen;
1069
+ struct sockaddr *ai_addr;
1070
+ struct ares_addrinfo_node *ai_next;
1071
+ };
1072
+
1073
+ /*
1074
+ * alias - label of the resource record.
1075
+ * name - value (canonical name) of the resource record.
1076
+ * See RFC2181 10.1.1. CNAME terminology.
1077
+ */
1078
+ struct ares_addrinfo_cname {
1079
+ int ttl;
1080
+ char *alias;
1081
+ char *name;
1082
+ struct ares_addrinfo_cname *next;
1083
+ };
1084
+
1085
+ struct ares_addrinfo {
1086
+ struct ares_addrinfo_cname *cnames;
1087
+ struct ares_addrinfo_node *nodes;
1088
+ char *name;
1089
+ };
1090
+
1091
+ struct ares_addrinfo_hints {
1092
+ int ai_flags;
1093
+ int ai_family;
1094
+ int ai_socktype;
1095
+ int ai_protocol;
1096
+ };
1097
+
1098
+ /*
1099
+ ** Parse the buffer, starting at *abuf and of length alen bytes, previously
1100
+ ** obtained from an ares_search call. Put the results in *host, if nonnull.
1101
+ ** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
1102
+ ** their TTLs in that array, and set *naddrttls to the number of addresses
1103
+ ** so written.
1104
+ */
1105
+
1106
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_a_reply(
1107
+ const unsigned char *abuf, int alen, struct hostent **host,
1108
+ struct ares_addrttl *addrttls, int *naddrttls);
1109
+
1110
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_aaaa_reply(
1111
+ const unsigned char *abuf, int alen, struct hostent **host,
1112
+ struct ares_addr6ttl *addrttls, int *naddrttls);
1113
+
1114
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_caa_reply(
1115
+ const unsigned char *abuf, int alen, struct ares_caa_reply **caa_out);
1116
+
1117
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_ptr_reply(
1118
+ const unsigned char *abuf, int alen, const void *addr, int addrlen,
1119
+ int family, struct hostent **host);
1120
+
1121
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_ns_reply(
1122
+ const unsigned char *abuf, int alen, struct hostent **host);
1123
+
1124
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_srv_reply(
1125
+ const unsigned char *abuf, int alen, struct ares_srv_reply **srv_out);
1126
+
1127
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_mx_reply(
1128
+ const unsigned char *abuf, int alen, struct ares_mx_reply **mx_out);
1129
+
1130
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_txt_reply(
1131
+ const unsigned char *abuf, int alen, struct ares_txt_reply **txt_out);
1132
+
1133
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_txt_reply_ext(
1134
+ const unsigned char *abuf, int alen, struct ares_txt_ext **txt_out);
1135
+
1136
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_naptr_reply(
1137
+ const unsigned char *abuf, int alen, struct ares_naptr_reply **naptr_out);
1138
+
1139
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_soa_reply(
1140
+ const unsigned char *abuf, int alen, struct ares_soa_reply **soa_out);
1141
+
1142
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_dns_parse) int ares_parse_uri_reply(
1143
+ const unsigned char *abuf, int alen, struct ares_uri_reply **uri_out);
1144
+
1145
+ CARES_EXTERN void ares_free_string(void *str);
1146
+
1147
+ CARES_EXTERN void ares_free_hostent(struct hostent *host);
1148
+
1149
+ CARES_EXTERN void ares_free_data(void *dataptr);
1150
+
1151
+ CARES_EXTERN const char *ares_strerror(int code);
1152
+
1153
+ struct ares_addr_node {
1154
+ struct ares_addr_node *next;
1155
+ int family;
1156
+
1157
+ union {
1158
+ struct in_addr addr4;
1159
+ struct ares_in6_addr addr6;
1160
+ } addr;
1161
+ };
1162
+
1163
+ struct ares_addr_port_node {
1164
+ struct ares_addr_port_node *next;
1165
+ int family;
1166
+
1167
+ union {
1168
+ struct in_addr addr4;
1169
+ struct ares_in6_addr addr6;
1170
+ } addr;
1171
+
1172
+ int udp_port;
1173
+ int tcp_port;
1174
+ };
1175
+
1176
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_set_servers_csv) int ares_set_servers(
1177
+ ares_channel_t *channel, const struct ares_addr_node *servers);
1178
+
1179
+ CARES_EXTERN
1180
+ CARES_DEPRECATED_FOR(ares_set_servers_ports_csv)
1181
+ int ares_set_servers_ports(ares_channel_t *channel,
1182
+ const struct ares_addr_port_node *servers);
1183
+
1184
+ /* Incoming string format: host[:port][,host[:port]]... */
1185
+ CARES_EXTERN int ares_set_servers_csv(ares_channel_t *channel,
1186
+ const char *servers);
1187
+ CARES_EXTERN int ares_set_servers_ports_csv(ares_channel_t *channel,
1188
+ const char *servers);
1189
+ CARES_EXTERN char *ares_get_servers_csv(const ares_channel_t *channel);
1190
+
1191
+ CARES_EXTERN CARES_DEPRECATED_FOR(ares_get_servers_csv) int ares_get_servers(
1192
+ const ares_channel_t *channel, struct ares_addr_node **servers);
1193
+
1194
+ CARES_EXTERN
1195
+ CARES_DEPRECATED_FOR(ares_get_servers_csv)
1196
+ int ares_get_servers_ports(const ares_channel_t *channel,
1197
+ struct ares_addr_port_node **servers);
1198
+
1199
+ CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
1200
+ ares_socklen_t size);
1201
+
1202
+ CARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst);
1203
+
1204
+ /*! Whether or not the c-ares library was built with threadsafety
1205
+ *
1206
+ * \return ARES_TRUE if built with threadsafety, ARES_FALSE if not
1207
+ */
1208
+ CARES_EXTERN ares_bool_t ares_threadsafety(void);
1209
+
1210
+
1211
+ /*! Block until notified that there are no longer any queries in queue, or
1212
+ * the specified timeout has expired.
1213
+ *
1214
+ * \param[in] channel Initialized ares channel
1215
+ * \param[in] timeout_ms Number of milliseconds to wait for the queue to be
1216
+ * empty. -1 for Infinite.
1217
+ * \return ARES_ENOTIMP if not built with threading support, ARES_ETIMEOUT
1218
+ * if requested timeout expires, ARES_SUCCESS when queue is empty.
1219
+ */
1220
+ CARES_EXTERN ares_status_t ares_queue_wait_empty(ares_channel_t *channel,
1221
+ int timeout_ms);
1222
+
1223
+
1224
+ /*! Retrieve the total number of active queries pending answers from servers.
1225
+ * Some c-ares requests may spawn multiple queries, such as ares_getaddrinfo()
1226
+ * when using AF_UNSPEC, which will be reflected in this number.
1227
+ *
1228
+ * \param[in] channel Initialized ares channel
1229
+ * \return Number of active queries to servers
1230
+ */
1231
+ CARES_EXTERN size_t ares_queue_active_queries(const ares_channel_t *channel);
1232
+
1233
+ #ifdef __cplusplus
1234
+ }
1235
+ #endif
1236
+
1237
+ #endif /* ARES__H */