visaljs 0.0.10 → 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 (221) hide show
  1. package/README.md +12 -4
  2. package/THIRD_PARTY_LICENSES +31 -1
  3. package/cli.js +962 -68
  4. package/node/include/js_node.h +11 -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 +395 -86
  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/perf_histogram.js +1 -1
  31. package/node/prelude/internal/process_more.js +32 -17
  32. package/node/prelude/internal/process_signals.js +8 -2
  33. package/node/prelude/internal/punycode.ts +163 -0
  34. package/node/prelude/internal/readline.js +648 -274
  35. package/node/prelude/internal/readline_editor.js +1240 -0
  36. package/node/prelude/internal/string_width.js +43 -0
  37. package/node/prelude/internal/tls/common.js +145 -33
  38. package/node/prelude/internal/tls/wrap.js +182 -49
  39. package/node/prelude/internal/tls/x509.js +4 -1
  40. package/node/prelude/internal/udp.js +177 -0
  41. package/node/prelude/net.js +13 -1
  42. package/node/prelude/os.js +24 -6
  43. package/node/prelude/perf_hooks.js +37 -2
  44. package/node/prelude/punycode.js +2 -130
  45. package/node/prelude/readline.js +113 -4
  46. package/node/prelude/readline_promises.js +56 -32
  47. package/node/prelude/tls.js +21 -4
  48. package/node/prelude/util.js +3 -16
  49. package/node/src/host_dns.c +623 -0
  50. package/node/src/host_http.c +12 -0
  51. package/node/src/host_net.c +46 -0
  52. package/node/src/host_os.c +1 -6
  53. package/node/src/host_sys.c +70 -0
  54. package/node/src/host_udp.c +418 -0
  55. package/node/third_party/c-ares/LICENSE.md +24 -0
  56. package/node/third_party/c-ares/config/darwin/ares_config.h +573 -0
  57. package/node/third_party/c-ares/config/freebsd/ares_config.h +573 -0
  58. package/node/third_party/c-ares/config/linux/ares_config.h +573 -0
  59. package/node/third_party/c-ares/config/openbsd/ares_config.h +583 -0
  60. package/node/third_party/c-ares/include/ares.h +1237 -0
  61. package/node/third_party/c-ares/include/ares_build.h +202 -0
  62. package/node/third_party/c-ares/include/ares_dns.h +127 -0
  63. package/node/third_party/c-ares/include/ares_dns_record.h +1119 -0
  64. package/node/third_party/c-ares/include/ares_nameser.h +510 -0
  65. package/node/third_party/c-ares/include/ares_version.h +47 -0
  66. package/node/third_party/c-ares/src/lib/ares_addrinfo2hostent.c +305 -0
  67. package/node/third_party/c-ares/src/lib/ares_addrinfo_localhost.c +245 -0
  68. package/node/third_party/c-ares/src/lib/ares_android.c +496 -0
  69. package/node/third_party/c-ares/src/lib/ares_android.h +38 -0
  70. package/node/third_party/c-ares/src/lib/ares_cancel.c +87 -0
  71. package/node/third_party/c-ares/src/lib/ares_close_sockets.c +137 -0
  72. package/node/third_party/c-ares/src/lib/ares_conn.c +511 -0
  73. package/node/third_party/c-ares/src/lib/ares_conn.h +202 -0
  74. package/node/third_party/c-ares/src/lib/ares_cookie.c +461 -0
  75. package/node/third_party/c-ares/src/lib/ares_data.c +168 -0
  76. package/node/third_party/c-ares/src/lib/ares_data.h +92 -0
  77. package/node/third_party/c-ares/src/lib/ares_destroy.c +159 -0
  78. package/node/third_party/c-ares/src/lib/ares_free_hostent.c +54 -0
  79. package/node/third_party/c-ares/src/lib/ares_free_string.c +33 -0
  80. package/node/third_party/c-ares/src/lib/ares_freeaddrinfo.c +67 -0
  81. package/node/third_party/c-ares/src/lib/ares_getaddrinfo.c +806 -0
  82. package/node/third_party/c-ares/src/lib/ares_getenv.c +38 -0
  83. package/node/third_party/c-ares/src/lib/ares_getenv.h +34 -0
  84. package/node/third_party/c-ares/src/lib/ares_gethostbyaddr.c +229 -0
  85. package/node/third_party/c-ares/src/lib/ares_gethostbyname.c +341 -0
  86. package/node/third_party/c-ares/src/lib/ares_getnameinfo.c +437 -0
  87. package/node/third_party/c-ares/src/lib/ares_hosts_file.c +960 -0
  88. package/node/third_party/c-ares/src/lib/ares_inet_net_pton.h +31 -0
  89. package/node/third_party/c-ares/src/lib/ares_init.c +631 -0
  90. package/node/third_party/c-ares/src/lib/ares_ipv6.h +115 -0
  91. package/node/third_party/c-ares/src/lib/ares_library_init.c +190 -0
  92. package/node/third_party/c-ares/src/lib/ares_metrics.c +261 -0
  93. package/node/third_party/c-ares/src/lib/ares_options.c +492 -0
  94. package/node/third_party/c-ares/src/lib/ares_parse_into_addrinfo.c +179 -0
  95. package/node/third_party/c-ares/src/lib/ares_private.h +648 -0
  96. package/node/third_party/c-ares/src/lib/ares_process.c +1649 -0
  97. package/node/third_party/c-ares/src/lib/ares_qcache.c +442 -0
  98. package/node/third_party/c-ares/src/lib/ares_query.c +151 -0
  99. package/node/third_party/c-ares/src/lib/ares_search.c +623 -0
  100. package/node/third_party/c-ares/src/lib/ares_send.c +300 -0
  101. package/node/third_party/c-ares/src/lib/ares_set_socket_functions.c +590 -0
  102. package/node/third_party/c-ares/src/lib/ares_setup.h +224 -0
  103. package/node/third_party/c-ares/src/lib/ares_socket.c +427 -0
  104. package/node/third_party/c-ares/src/lib/ares_socket.h +163 -0
  105. package/node/third_party/c-ares/src/lib/ares_sortaddrinfo.c +447 -0
  106. package/node/third_party/c-ares/src/lib/ares_strerror.c +91 -0
  107. package/node/third_party/c-ares/src/lib/ares_sysconfig.c +642 -0
  108. package/node/third_party/c-ares/src/lib/ares_sysconfig_files.c +851 -0
  109. package/node/third_party/c-ares/src/lib/ares_sysconfig_mac.c +373 -0
  110. package/node/third_party/c-ares/src/lib/ares_sysconfig_win.c +673 -0
  111. package/node/third_party/c-ares/src/lib/ares_timeout.c +162 -0
  112. package/node/third_party/c-ares/src/lib/ares_update_servers.c +1376 -0
  113. package/node/third_party/c-ares/src/lib/ares_version.c +36 -0
  114. package/node/third_party/c-ares/src/lib/config-dos.h +114 -0
  115. package/node/third_party/c-ares/src/lib/config-win32.h +396 -0
  116. package/node/third_party/c-ares/src/lib/dsa/ares_array.c +409 -0
  117. package/node/third_party/c-ares/src/lib/dsa/ares_htable.c +451 -0
  118. package/node/third_party/c-ares/src/lib/dsa/ares_htable.h +174 -0
  119. package/node/third_party/c-ares/src/lib/dsa/ares_htable_asvp.c +224 -0
  120. package/node/third_party/c-ares/src/lib/dsa/ares_htable_dict.c +230 -0
  121. package/node/third_party/c-ares/src/lib/dsa/ares_htable_strvp.c +210 -0
  122. package/node/third_party/c-ares/src/lib/dsa/ares_htable_szvp.c +188 -0
  123. package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpstr.c +186 -0
  124. package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpvp.c +194 -0
  125. package/node/third_party/c-ares/src/lib/dsa/ares_llist.c +385 -0
  126. package/node/third_party/c-ares/src/lib/dsa/ares_slist.c +479 -0
  127. package/node/third_party/c-ares/src/lib/dsa/ares_slist.h +207 -0
  128. package/node/third_party/c-ares/src/lib/event/ares_event.h +191 -0
  129. package/node/third_party/c-ares/src/lib/event/ares_event_configchg.c +746 -0
  130. package/node/third_party/c-ares/src/lib/event/ares_event_epoll.c +192 -0
  131. package/node/third_party/c-ares/src/lib/event/ares_event_kqueue.c +248 -0
  132. package/node/third_party/c-ares/src/lib/event/ares_event_poll.c +140 -0
  133. package/node/third_party/c-ares/src/lib/event/ares_event_select.c +159 -0
  134. package/node/third_party/c-ares/src/lib/event/ares_event_thread.c +575 -0
  135. package/node/third_party/c-ares/src/lib/event/ares_event_wake_pipe.c +172 -0
  136. package/node/third_party/c-ares/src/lib/event/ares_event_win32.c +981 -0
  137. package/node/third_party/c-ares/src/lib/event/ares_event_win32.h +161 -0
  138. package/node/third_party/c-ares/src/lib/include/ares_array.h +276 -0
  139. package/node/third_party/c-ares/src/lib/include/ares_buf.h +732 -0
  140. package/node/third_party/c-ares/src/lib/include/ares_htable_asvp.h +130 -0
  141. package/node/third_party/c-ares/src/lib/include/ares_htable_dict.h +123 -0
  142. package/node/third_party/c-ares/src/lib/include/ares_htable_strvp.h +130 -0
  143. package/node/third_party/c-ares/src/lib/include/ares_htable_szvp.h +118 -0
  144. package/node/third_party/c-ares/src/lib/include/ares_htable_vpstr.h +111 -0
  145. package/node/third_party/c-ares/src/lib/include/ares_htable_vpvp.h +128 -0
  146. package/node/third_party/c-ares/src/lib/include/ares_llist.h +239 -0
  147. package/node/third_party/c-ares/src/lib/include/ares_mem.h +41 -0
  148. package/node/third_party/c-ares/src/lib/include/ares_str.h +261 -0
  149. package/node/third_party/c-ares/src/lib/inet_net_pton.c +451 -0
  150. package/node/third_party/c-ares/src/lib/inet_ntop.c +219 -0
  151. package/node/third_party/c-ares/src/lib/legacy/ares_create_query.c +78 -0
  152. package/node/third_party/c-ares/src/lib/legacy/ares_expand_name.c +99 -0
  153. package/node/third_party/c-ares/src/lib/legacy/ares_expand_string.c +107 -0
  154. package/node/third_party/c-ares/src/lib/legacy/ares_fds.c +80 -0
  155. package/node/third_party/c-ares/src/lib/legacy/ares_getsock.c +85 -0
  156. package/node/third_party/c-ares/src/lib/legacy/ares_parse_a_reply.c +107 -0
  157. package/node/third_party/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
  158. package/node/third_party/c-ares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
  159. package/node/third_party/c-ares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
  160. package/node/third_party/c-ares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
  161. package/node/third_party/c-ares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
  162. package/node/third_party/c-ares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
  163. package/node/third_party/c-ares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
  164. package/node/third_party/c-ares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
  165. package/node/third_party/c-ares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
  166. package/node/third_party/c-ares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
  167. package/node/third_party/c-ares/src/lib/record/ares_dns_mapping.c +982 -0
  168. package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.c +309 -0
  169. package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.h +72 -0
  170. package/node/third_party/c-ares/src/lib/record/ares_dns_name.c +736 -0
  171. package/node/third_party/c-ares/src/lib/record/ares_dns_parse.c +1360 -0
  172. package/node/third_party/c-ares/src/lib/record/ares_dns_private.h +273 -0
  173. package/node/third_party/c-ares/src/lib/record/ares_dns_record.c +1701 -0
  174. package/node/third_party/c-ares/src/lib/record/ares_dns_write.c +1229 -0
  175. package/node/third_party/c-ares/src/lib/str/ares_buf.c +1510 -0
  176. package/node/third_party/c-ares/src/lib/str/ares_str.c +562 -0
  177. package/node/third_party/c-ares/src/lib/str/ares_strsplit.c +90 -0
  178. package/node/third_party/c-ares/src/lib/str/ares_strsplit.h +51 -0
  179. package/node/third_party/c-ares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
  180. package/node/third_party/c-ares/src/lib/util/ares_iface_ips.c +640 -0
  181. package/node/third_party/c-ares/src/lib/util/ares_iface_ips.h +140 -0
  182. package/node/third_party/c-ares/src/lib/util/ares_math.c +167 -0
  183. package/node/third_party/c-ares/src/lib/util/ares_math.h +58 -0
  184. package/node/third_party/c-ares/src/lib/util/ares_rand.c +389 -0
  185. package/node/third_party/c-ares/src/lib/util/ares_rand.h +36 -0
  186. package/node/third_party/c-ares/src/lib/util/ares_threads.c +613 -0
  187. package/node/third_party/c-ares/src/lib/util/ares_threads.h +60 -0
  188. package/node/third_party/c-ares/src/lib/util/ares_time.h +49 -0
  189. package/node/third_party/c-ares/src/lib/util/ares_timeval.c +95 -0
  190. package/node/third_party/c-ares/src/lib/util/ares_uri.c +1627 -0
  191. package/node/third_party/c-ares/src/lib/util/ares_uri.h +252 -0
  192. package/node/third_party/c-ares/src/lib/windows_port.c +29 -0
  193. package/package.json +1 -1
  194. package/prebuilt/darwin-arm64/cares-a6286c65ca9374a3.a +0 -0
  195. package/prebuilt/darwin-x64/cares-a6286c65ca9374a3.a +0 -0
  196. package/prebuilt/linux-arm64/cares-4ba05ac8e948af8e.a +0 -0
  197. package/prebuilt/linux-arm64-musl/cares-4ba05ac8e948af8e.a +0 -0
  198. package/prebuilt/linux-x64/cares-4ba05ac8e948af8e.a +0 -0
  199. package/prebuilt/linux-x64-musl/cares-4ba05ac8e948af8e.a +0 -0
  200. package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
  201. package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
  202. package/prebuilt/win32-x64/cares-49c9ec95162b912d.a +0 -0
  203. package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
  204. package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  205. package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
  206. package/runtime/include/js_builtins.h +5 -0
  207. package/runtime/include/js_crypto.h +11 -0
  208. package/runtime/include/js_gc.h +13 -10
  209. package/runtime/include/js_jobs.h +2 -0
  210. package/runtime/include/js_object.h +58 -0
  211. package/runtime/include/jscontext.h +1 -0
  212. package/runtime/src/crypto_internal.h +1 -0
  213. package/runtime/src/crypto_subtle.c +66 -7
  214. package/runtime/src/crypto_tls.c +265 -19
  215. package/runtime/src/gc.c +73 -92
  216. package/runtime/src/inspect.c +18 -1
  217. package/runtime/src/jobs.c +37 -22
  218. package/runtime/src/object.c +49 -2
  219. package/runtime/src/os.c +16 -6
  220. package/runtime/src/os.h +2 -0
  221. package/runtime/src/process.c +97 -10
@@ -0,0 +1,1119 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 2023 Brad House
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice (including the next
13
+ * paragraph) shall be included in all copies or substantial portions of the
14
+ * Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ *
24
+ * SPDX-License-Identifier: MIT
25
+ */
26
+ #ifndef __ARES_DNS_RECORD_H
27
+ #define __ARES_DNS_RECORD_H
28
+
29
+ /* Include ares.h, not this file directly */
30
+
31
+ #ifdef __cplusplus
32
+ extern "C" {
33
+ #endif
34
+
35
+ /*! \addtogroup ares_dns_record DNS Record Handling
36
+ *
37
+ * This is a set of functions to create and manipulate DNS records.
38
+ *
39
+ * @{
40
+ */
41
+
42
+ /*! DNS Record types handled by c-ares. Some record types may only be valid
43
+ * on requests (e.g. ARES_REC_TYPE_ANY), and some may only be valid on
44
+ * responses */
45
+ typedef enum {
46
+ ARES_REC_TYPE_A = 1, /*!< Host address. */
47
+ ARES_REC_TYPE_NS = 2, /*!< Authoritative server. */
48
+ ARES_REC_TYPE_CNAME = 5, /*!< Canonical name. */
49
+ ARES_REC_TYPE_SOA = 6, /*!< Start of authority zone. */
50
+ ARES_REC_TYPE_PTR = 12, /*!< Domain name pointer. */
51
+ ARES_REC_TYPE_HINFO = 13, /*!< Host information. */
52
+ ARES_REC_TYPE_MX = 15, /*!< Mail routing information. */
53
+ ARES_REC_TYPE_TXT = 16, /*!< Text strings. */
54
+ ARES_REC_TYPE_SIG = 24, /*!< RFC 2535 / RFC 2931. SIG Record */
55
+ ARES_REC_TYPE_AAAA = 28, /*!< RFC 3596. Ip6 Address. */
56
+ ARES_REC_TYPE_SRV = 33, /*!< RFC 2782. Server Selection. */
57
+ ARES_REC_TYPE_NAPTR = 35, /*!< RFC 3403. Naming Authority Pointer */
58
+ ARES_REC_TYPE_OPT = 41, /*!< RFC 6891. EDNS0 option (meta-RR) */
59
+
60
+ ARES_REC_TYPE_TLSA = 52, /*!< RFC 6698. DNS-Based Authentication of Named
61
+ * Entities (DANE) Transport Layer Security
62
+ * (TLS) Protocol: TLSA */
63
+ ARES_REC_TYPE_SVCB = 64, /*!< RFC 9460. General Purpose Service Binding */
64
+ ARES_REC_TYPE_HTTPS = 65, /*!< RFC 9460. Service Binding type for use with
65
+ * HTTPS */
66
+ ARES_REC_TYPE_ANY = 255, /*!< Wildcard match. Not response RR. */
67
+ ARES_REC_TYPE_URI = 256, /*!< RFC 7553. Uniform Resource Identifier */
68
+ ARES_REC_TYPE_CAA = 257, /*!< RFC 6844. Certification Authority
69
+ * Authorization. */
70
+ ARES_REC_TYPE_RAW_RR = 65536 /*!< Used as an indicator that the RR record
71
+ * is not parsed, but provided in wire
72
+ * format */
73
+ } ares_dns_rec_type_t;
74
+
75
+ /*! DNS Classes for requests and responses. */
76
+ typedef enum {
77
+ ARES_CLASS_IN = 1, /*!< Internet */
78
+ ARES_CLASS_CHAOS = 3, /*!< CHAOS */
79
+ ARES_CLASS_HESIOD = 4, /*!< Hesiod [Dyer 87] */
80
+ ARES_CLASS_HESOID = 4, /*!< typo from older c-ares version for Hesiod */
81
+ ARES_CLASS_NONE = 254, /*!< RFC 2136 */
82
+ ARES_CLASS_ANY = 255 /*!< Any class (requests only) */
83
+ } ares_dns_class_t;
84
+
85
+ /*! DNS RR Section type */
86
+ typedef enum {
87
+ ARES_SECTION_ANSWER = 1, /*!< Answer section */
88
+ ARES_SECTION_AUTHORITY = 2, /*!< Authority section */
89
+ ARES_SECTION_ADDITIONAL = 3 /*!< Additional information section */
90
+ } ares_dns_section_t;
91
+
92
+ /*! DNS Header opcodes */
93
+ typedef enum {
94
+ ARES_OPCODE_QUERY = 0, /*!< Standard query */
95
+ ARES_OPCODE_IQUERY = 1, /*!< Inverse query. Obsolete. */
96
+ ARES_OPCODE_STATUS = 2, /*!< Name server status query */
97
+ ARES_OPCODE_NOTIFY = 4, /*!< Zone change notification (RFC 1996) */
98
+ ARES_OPCODE_UPDATE = 5 /*!< Zone update message (RFC2136) */
99
+ } ares_dns_opcode_t;
100
+
101
+ /*! DNS Header flags */
102
+ typedef enum {
103
+ ARES_FLAG_QR = 1 << 0, /*!< QR. If set, is a response */
104
+ ARES_FLAG_AA = 1 << 1, /*!< Authoritative Answer. If set, is authoritative */
105
+ ARES_FLAG_TC = 1 << 2, /*!< Truncation. If set, is truncated response */
106
+ ARES_FLAG_RD = 1 << 3, /*!< Recursion Desired. If set, recursion is desired */
107
+ ARES_FLAG_RA = 1 << 4, /*!< Recursion Available. If set, server supports
108
+ * recursion */
109
+ ARES_FLAG_AD = 1 << 5, /*!< RFC 2065. Authentic Data bit indicates in a
110
+ * response that the data included has been verified by
111
+ * the server providing it */
112
+ ARES_FLAG_CD = 1 << 6 /*!< RFC 2065. Checking Disabled bit indicates in a
113
+ * query that non-verified data is acceptable to the
114
+ * resolver sending the query. */
115
+ } ares_dns_flags_t;
116
+
117
+ /*! DNS Response Codes from server */
118
+ typedef enum {
119
+ ARES_RCODE_NOERROR = 0, /*!< Success */
120
+ ARES_RCODE_FORMERR = 1, /*!< Format error. The name server was unable
121
+ * to interpret the query. */
122
+ ARES_RCODE_SERVFAIL = 2, /*!< Server Failure. The name server was
123
+ * unable to process this query due to a
124
+ * problem with the nameserver */
125
+ ARES_RCODE_NXDOMAIN = 3, /*!< Name Error. Meaningful only for
126
+ * responses from an authoritative name
127
+ * server, this code signifies that the
128
+ * domain name referenced in the query does
129
+ * not exist. */
130
+ ARES_RCODE_NOTIMP = 4, /*!< Not implemented. The name server does
131
+ * not support the requested kind of
132
+ * query */
133
+ ARES_RCODE_REFUSED = 5, /*!< Refused. The name server refuses to
134
+ * perform the specified operation for
135
+ * policy reasons. */
136
+ ARES_RCODE_YXDOMAIN = 6, /*!< RFC 2136. Some name that ought not to
137
+ * exist, does exist. */
138
+ ARES_RCODE_YXRRSET = 7, /*!< RFC 2136. Some RRset that ought to not
139
+ * exist, does exist. */
140
+ ARES_RCODE_NXRRSET = 8, /*!< RFC 2136. Some RRset that ought to exist,
141
+ * does not exist. */
142
+ ARES_RCODE_NOTAUTH = 9, /*!< RFC 2136. The server is not authoritative
143
+ * for the zone named in the Zone section.
144
+ */
145
+ ARES_RCODE_NOTZONE = 10, /*!< RFC 2136. A name used in the Prerequisite
146
+ * or Update Section is not within the zone
147
+ * denoted by the Zone Section. */
148
+ ARES_RCODE_DSOTYPEI = 11, /*!< RFC 8409. DSO-TYPE Not implemented */
149
+ ARES_RCODE_BADSIG = 16, /*!< RFC 8945. TSIG Signature Failure */
150
+ ARES_RCODE_BADKEY = 17, /*!< RFC 8945. Key not recognized. */
151
+ ARES_RCODE_BADTIME = 18, /*!< RFC 8945. Signature out of time window. */
152
+ ARES_RCODE_BADMODE = 19, /*!< RFC 2930. Bad TKEY Mode */
153
+ ARES_RCODE_BADNAME = 20, /*!< RFC 2930. Duplicate Key Name */
154
+ ARES_RCODE_BADALG = 21, /*!< RFC 2930. Algorithm not supported */
155
+ ARES_RCODE_BADTRUNC = 22, /*!< RFC 8945. Bad Truncation */
156
+ ARES_RCODE_BADCOOKIE = 23 /*!< RFC 7873. Bad/missing Server Cookie */
157
+ } ares_dns_rcode_t;
158
+
159
+ /*! Data types used */
160
+ typedef enum {
161
+ ARES_DATATYPE_INADDR = 1, /*!< struct in_addr * type */
162
+ ARES_DATATYPE_INADDR6 = 2, /*!< struct ares_in6_addr * type */
163
+ ARES_DATATYPE_U8 = 3, /*!< 8bit unsigned integer */
164
+ ARES_DATATYPE_U16 = 4, /*!< 16bit unsigned integer */
165
+ ARES_DATATYPE_U32 = 5, /*!< 32bit unsigned integer */
166
+ ARES_DATATYPE_NAME = 6, /*!< Null-terminated string of a domain name */
167
+ ARES_DATATYPE_STR = 7, /*!< Null-terminated string */
168
+ ARES_DATATYPE_BIN = 8, /*!< Binary data */
169
+ ARES_DATATYPE_BINP = 9, /*!< Officially defined as binary data, but likely
170
+ * printable. Guaranteed to have a NULL
171
+ * terminator for convenience (not included in
172
+ * length) */
173
+ ARES_DATATYPE_OPT = 10, /*!< Array of options. 16bit identifier, BIN
174
+ * data. */
175
+ ARES_DATATYPE_ABINP = 11 /*!< Array of binary data, likely printable.
176
+ * Guaranteed to have a NULL terminator for
177
+ * convenience (not included in length) */
178
+ } ares_dns_datatype_t;
179
+
180
+ /*! Keys used for all RR Types. We take the record type and multiply by 100
181
+ * to ensure we have a proper offset between keys so we can keep these sorted
182
+ */
183
+ typedef enum {
184
+ /*! A Record. Address. Datatype: INADDR */
185
+ ARES_RR_A_ADDR = (ARES_REC_TYPE_A * 100) + 1,
186
+ /*! NS Record. Name. Datatype: NAME */
187
+ ARES_RR_NS_NSDNAME = (ARES_REC_TYPE_NS * 100) + 1,
188
+ /*! CNAME Record. CName. Datatype: NAME */
189
+ ARES_RR_CNAME_CNAME = (ARES_REC_TYPE_CNAME * 100) + 1,
190
+ /*! SOA Record. MNAME, Primary Source of Data. Datatype: NAME */
191
+ ARES_RR_SOA_MNAME = (ARES_REC_TYPE_SOA * 100) + 1,
192
+ /*! SOA Record. RNAME, Mailbox of person responsible. Datatype: NAME */
193
+ ARES_RR_SOA_RNAME = (ARES_REC_TYPE_SOA * 100) + 2,
194
+ /*! SOA Record. Serial, version. Datatype: U32 */
195
+ ARES_RR_SOA_SERIAL = (ARES_REC_TYPE_SOA * 100) + 3,
196
+ /*! SOA Record. Refresh, zone refersh interval. Datatype: U32 */
197
+ ARES_RR_SOA_REFRESH = (ARES_REC_TYPE_SOA * 100) + 4,
198
+ /*! SOA Record. Retry, failed refresh retry interval. Datatype: U32 */
199
+ ARES_RR_SOA_RETRY = (ARES_REC_TYPE_SOA * 100) + 5,
200
+ /*! SOA Record. Expire, upper limit on authority. Datatype: U32 */
201
+ ARES_RR_SOA_EXPIRE = (ARES_REC_TYPE_SOA * 100) + 6,
202
+ /*! SOA Record. Minimum, RR TTL. Datatype: U32 */
203
+ ARES_RR_SOA_MINIMUM = (ARES_REC_TYPE_SOA * 100) + 7,
204
+ /*! PTR Record. DNAME, pointer domain. Datatype: NAME */
205
+ ARES_RR_PTR_DNAME = (ARES_REC_TYPE_PTR * 100) + 1,
206
+ /*! HINFO Record. CPU. Datatype: STR */
207
+ ARES_RR_HINFO_CPU = (ARES_REC_TYPE_HINFO * 100) + 1,
208
+ /*! HINFO Record. OS. Datatype: STR */
209
+ ARES_RR_HINFO_OS = (ARES_REC_TYPE_HINFO * 100) + 2,
210
+ /*! MX Record. Preference. Datatype: U16 */
211
+ ARES_RR_MX_PREFERENCE = (ARES_REC_TYPE_MX * 100) + 1,
212
+ /*! MX Record. Exchange, domain. Datatype: NAME */
213
+ ARES_RR_MX_EXCHANGE = (ARES_REC_TYPE_MX * 100) + 2,
214
+ /*! TXT Record. Data. Datatype: ABINP */
215
+ ARES_RR_TXT_DATA = (ARES_REC_TYPE_TXT * 100) + 1,
216
+ /*! SIG Record. Type Covered. Datatype: U16 */
217
+ ARES_RR_SIG_TYPE_COVERED = (ARES_REC_TYPE_SIG * 100) + 1,
218
+ /*! SIG Record. Algorithm. Datatype: U8 */
219
+ ARES_RR_SIG_ALGORITHM = (ARES_REC_TYPE_SIG * 100) + 2,
220
+ /*! SIG Record. Labels. Datatype: U8 */
221
+ ARES_RR_SIG_LABELS = (ARES_REC_TYPE_SIG * 100) + 3,
222
+ /*! SIG Record. Original TTL. Datatype: U32 */
223
+ ARES_RR_SIG_ORIGINAL_TTL = (ARES_REC_TYPE_SIG * 100) + 4,
224
+ /*! SIG Record. Signature Expiration. Datatype: U32 */
225
+ ARES_RR_SIG_EXPIRATION = (ARES_REC_TYPE_SIG * 100) + 5,
226
+ /*! SIG Record. Signature Inception. Datatype: U32 */
227
+ ARES_RR_SIG_INCEPTION = (ARES_REC_TYPE_SIG * 100) + 6,
228
+ /*! SIG Record. Key Tag. Datatype: U16 */
229
+ ARES_RR_SIG_KEY_TAG = (ARES_REC_TYPE_SIG * 100) + 7,
230
+ /*! SIG Record. Signers Name. Datatype: NAME */
231
+ ARES_RR_SIG_SIGNERS_NAME = (ARES_REC_TYPE_SIG * 100) + 8,
232
+ /*! SIG Record. Signature. Datatype: BIN */
233
+ ARES_RR_SIG_SIGNATURE = (ARES_REC_TYPE_SIG * 100) + 9,
234
+ /*! AAAA Record. Address. Datatype: INADDR6 */
235
+ ARES_RR_AAAA_ADDR = (ARES_REC_TYPE_AAAA * 100) + 1,
236
+ /*! SRV Record. Priority. Datatype: U16 */
237
+ ARES_RR_SRV_PRIORITY = (ARES_REC_TYPE_SRV * 100) + 2,
238
+ /*! SRV Record. Weight. Datatype: U16 */
239
+ ARES_RR_SRV_WEIGHT = (ARES_REC_TYPE_SRV * 100) + 3,
240
+ /*! SRV Record. Port. Datatype: U16 */
241
+ ARES_RR_SRV_PORT = (ARES_REC_TYPE_SRV * 100) + 4,
242
+ /*! SRV Record. Target domain. Datatype: NAME */
243
+ ARES_RR_SRV_TARGET = (ARES_REC_TYPE_SRV * 100) + 5,
244
+ /*! NAPTR Record. Order. Datatype: U16 */
245
+ ARES_RR_NAPTR_ORDER = (ARES_REC_TYPE_NAPTR * 100) + 1,
246
+ /*! NAPTR Record. Preference. Datatype: U16 */
247
+ ARES_RR_NAPTR_PREFERENCE = (ARES_REC_TYPE_NAPTR * 100) + 2,
248
+ /*! NAPTR Record. Flags. Datatype: STR */
249
+ ARES_RR_NAPTR_FLAGS = (ARES_REC_TYPE_NAPTR * 100) + 3,
250
+ /*! NAPTR Record. Services. Datatype: STR */
251
+ ARES_RR_NAPTR_SERVICES = (ARES_REC_TYPE_NAPTR * 100) + 4,
252
+ /*! NAPTR Record. Regexp. Datatype: STR */
253
+ ARES_RR_NAPTR_REGEXP = (ARES_REC_TYPE_NAPTR * 100) + 5,
254
+ /*! NAPTR Record. Replacement. Datatype: NAME */
255
+ ARES_RR_NAPTR_REPLACEMENT = (ARES_REC_TYPE_NAPTR * 100) + 6,
256
+ /*! OPT Record. UDP Size. Datatype: U16 */
257
+ ARES_RR_OPT_UDP_SIZE = (ARES_REC_TYPE_OPT * 100) + 1,
258
+ /*! OPT Record. Version. Datatype: U8 */
259
+ ARES_RR_OPT_VERSION = (ARES_REC_TYPE_OPT * 100) + 3,
260
+ /*! OPT Record. Flags. Datatype: U16 */
261
+ ARES_RR_OPT_FLAGS = (ARES_REC_TYPE_OPT * 100) + 4,
262
+ /*! OPT Record. Options. Datatype: OPT */
263
+ ARES_RR_OPT_OPTIONS = (ARES_REC_TYPE_OPT * 100) + 5,
264
+ /*! TLSA Record. Certificate Usage. Datatype: U8 */
265
+ ARES_RR_TLSA_CERT_USAGE = (ARES_REC_TYPE_TLSA * 100) + 1,
266
+ /*! TLSA Record. Selector. Datatype: U8 */
267
+ ARES_RR_TLSA_SELECTOR = (ARES_REC_TYPE_TLSA * 100) + 2,
268
+ /*! TLSA Record. Matching Type. Datatype: U8 */
269
+ ARES_RR_TLSA_MATCH = (ARES_REC_TYPE_TLSA * 100) + 3,
270
+ /*! TLSA Record. Certificate Association Data. Datatype: BIN */
271
+ ARES_RR_TLSA_DATA = (ARES_REC_TYPE_TLSA * 100) + 4,
272
+ /*! SVCB Record. SvcPriority. Datatype: U16 */
273
+ ARES_RR_SVCB_PRIORITY = (ARES_REC_TYPE_SVCB * 100) + 1,
274
+ /*! SVCB Record. TargetName. Datatype: NAME */
275
+ ARES_RR_SVCB_TARGET = (ARES_REC_TYPE_SVCB * 100) + 2,
276
+ /*! SVCB Record. SvcParams. Datatype: OPT */
277
+ ARES_RR_SVCB_PARAMS = (ARES_REC_TYPE_SVCB * 100) + 3,
278
+ /*! HTTPS Record. SvcPriority. Datatype: U16 */
279
+ ARES_RR_HTTPS_PRIORITY = (ARES_REC_TYPE_HTTPS * 100) + 1,
280
+ /*! HTTPS Record. TargetName. Datatype: NAME */
281
+ ARES_RR_HTTPS_TARGET = (ARES_REC_TYPE_HTTPS * 100) + 2,
282
+ /*! HTTPS Record. SvcParams. Datatype: OPT */
283
+ ARES_RR_HTTPS_PARAMS = (ARES_REC_TYPE_HTTPS * 100) + 3,
284
+ /*! URI Record. Priority. Datatype: U16 */
285
+ ARES_RR_URI_PRIORITY = (ARES_REC_TYPE_URI * 100) + 1,
286
+ /*! URI Record. Weight. Datatype: U16 */
287
+ ARES_RR_URI_WEIGHT = (ARES_REC_TYPE_URI * 100) + 2,
288
+ /*! URI Record. Target domain. Datatype: NAME */
289
+ ARES_RR_URI_TARGET = (ARES_REC_TYPE_URI * 100) + 3,
290
+ /*! CAA Record. Critical flag. Datatype: U8 */
291
+ ARES_RR_CAA_CRITICAL = (ARES_REC_TYPE_CAA * 100) + 1,
292
+ /*! CAA Record. Tag/Property. Datatype: STR */
293
+ ARES_RR_CAA_TAG = (ARES_REC_TYPE_CAA * 100) + 2,
294
+ /*! CAA Record. Value. Datatype: BINP */
295
+ ARES_RR_CAA_VALUE = (ARES_REC_TYPE_CAA * 100) + 3,
296
+ /*! RAW Record. RR Type. Datatype: U16 */
297
+ ARES_RR_RAW_RR_TYPE = (ARES_REC_TYPE_RAW_RR * 100) + 1,
298
+ /*! RAW Record. RR Data. Datatype: BIN */
299
+ ARES_RR_RAW_RR_DATA = (ARES_REC_TYPE_RAW_RR * 100) + 2
300
+ } ares_dns_rr_key_t;
301
+
302
+ /*! TLSA Record ARES_RR_TLSA_CERT_USAGE known values */
303
+ typedef enum {
304
+ /*! Certificate Usage 0. CA Constraint. */
305
+ ARES_TLSA_USAGE_CA = 0,
306
+ /*! Certificate Usage 1. Service Certificate Constraint. */
307
+ ARES_TLSA_USAGE_SERVICE = 1,
308
+ /*! Certificate Usage 2. Trust Anchor Assertion. */
309
+ ARES_TLSA_USAGE_TRUSTANCHOR = 2,
310
+ /*! Certificate Usage 3. Domain-issued certificate. */
311
+ ARES_TLSA_USAGE_DOMAIN = 3
312
+ } ares_tlsa_usage_t;
313
+
314
+ /*! TLSA Record ARES_RR_TLSA_SELECTOR known values */
315
+ typedef enum {
316
+ /*! Full Certificate */
317
+ ARES_TLSA_SELECTOR_FULL = 0,
318
+ /*! DER-encoded SubjectPublicKeyInfo */
319
+ ARES_TLSA_SELECTOR_SUBJPUBKEYINFO = 1
320
+ } ares_tlsa_selector_t;
321
+
322
+ /*! TLSA Record ARES_RR_TLSA_MATCH known values */
323
+ typedef enum {
324
+ /*! Exact match */
325
+ ARES_TLSA_MATCH_EXACT = 0,
326
+ /*! Sha256 match */
327
+ ARES_TLSA_MATCH_SHA256 = 1,
328
+ /*! Sha512 match */
329
+ ARES_TLSA_MATCH_SHA512 = 2
330
+ } ares_tlsa_match_t;
331
+
332
+ /*! SVCB (and HTTPS) RR known parameters */
333
+ typedef enum {
334
+ /*! Mandatory keys in this RR (RFC 9460 Section 8) */
335
+ ARES_SVCB_PARAM_MANDATORY = 0,
336
+ /*! Additional supported protocols (RFC 9460 Section 7.1) */
337
+ ARES_SVCB_PARAM_ALPN = 1,
338
+ /*! No support for default protocol (RFC 9460 Section 7.1) */
339
+ ARES_SVCB_PARAM_NO_DEFAULT_ALPN = 2,
340
+ /*! Port for alternative endpoint (RFC 9460 Section 7.2) */
341
+ ARES_SVCB_PARAM_PORT = 3,
342
+ /*! IPv4 address hints (RFC 9460 Section 7.3) */
343
+ ARES_SVCB_PARAM_IPV4HINT = 4,
344
+ /*! RESERVED (held for Encrypted ClientHello) */
345
+ ARES_SVCB_PARAM_ECH = 5,
346
+ /*! IPv6 address hints (RFC 9460 Section 7.3) */
347
+ ARES_SVCB_PARAM_IPV6HINT = 6
348
+ } ares_svcb_param_t;
349
+
350
+ /*! OPT RR known parameters */
351
+ typedef enum {
352
+ /*! RFC 8764. Apple's DNS Long-Lived Queries Protocol */
353
+ ARES_OPT_PARAM_LLQ = 1,
354
+ /*! http://files.dns-sd.org/draft-sekar-dns-ul.txt: Update Lease */
355
+ ARES_OPT_PARAM_UL = 2,
356
+ /*! RFC 5001. Name Server Identification */
357
+ ARES_OPT_PARAM_NSID = 3,
358
+ /*! RFC 6975. DNSSEC Algorithm Understood */
359
+ ARES_OPT_PARAM_DAU = 5,
360
+ /*! RFC 6975. DS Hash Understood */
361
+ ARES_OPT_PARAM_DHU = 6,
362
+ /*! RFC 6975. NSEC3 Hash Understood */
363
+ ARES_OPT_PARAM_N3U = 7,
364
+ /*! RFC 7871. Client Subnet */
365
+ ARES_OPT_PARAM_EDNS_CLIENT_SUBNET = 8,
366
+ /*! RFC 7314. Expire Timer */
367
+ ARES_OPT_PARAM_EDNS_EXPIRE = 9,
368
+ /*! RFC 7873. Client and Server Cookies */
369
+ ARES_OPT_PARAM_COOKIE = 10,
370
+ /*! RFC 7828. TCP Keepalive timeout */
371
+ ARES_OPT_PARAM_EDNS_TCP_KEEPALIVE = 11,
372
+ /*! RFC 7830. Padding */
373
+ ARES_OPT_PARAM_PADDING = 12,
374
+ /*! RFC 7901. Chain query requests */
375
+ ARES_OPT_PARAM_CHAIN = 13,
376
+ /*! RFC 8145. Signaling Trust Anchor Knowledge in DNSSEC */
377
+ ARES_OPT_PARAM_EDNS_KEY_TAG = 14,
378
+ /*! RFC 8914. Extended ERROR code and message */
379
+ ARES_OPT_PARAM_EXTENDED_DNS_ERROR = 15
380
+ } ares_opt_param_t;
381
+
382
+ /*! Data type for option records for keys like ARES_RR_OPT_OPTIONS and
383
+ * ARES_RR_HTTPS_PARAMS returned by ares_dns_opt_get_datatype() */
384
+ typedef enum {
385
+ /*! No value allowed for this option */
386
+ ARES_OPT_DATATYPE_NONE = 1,
387
+ /*! List of strings, each prefixed with a single octet representing the length
388
+ */
389
+ ARES_OPT_DATATYPE_STR_LIST = 2,
390
+ /*! List of 8bit integers, concatenated */
391
+ ARES_OPT_DATATYPE_U8_LIST = 3,
392
+ /*! 16bit integer in network byte order */
393
+ ARES_OPT_DATATYPE_U16 = 4,
394
+ /*! list of 16bit integer in network byte order, concatenated. */
395
+ ARES_OPT_DATATYPE_U16_LIST = 5,
396
+ /*! 32bit integer in network byte order */
397
+ ARES_OPT_DATATYPE_U32 = 6,
398
+ /*! list 32bit integer in network byte order, concatenated */
399
+ ARES_OPT_DATATYPE_U32_LIST = 7,
400
+ /*! List of ipv4 addresses in network byte order, concatenated */
401
+ ARES_OPT_DATATYPE_INADDR4_LIST = 8,
402
+ /*! List of ipv6 addresses in network byte order, concatenated */
403
+ ARES_OPT_DATATYPE_INADDR6_LIST = 9,
404
+ /*! Binary Data */
405
+ ARES_OPT_DATATYPE_BIN = 10,
406
+ /*! DNS Domain Name Format */
407
+ ARES_OPT_DATATYPE_NAME = 11
408
+ } ares_dns_opt_datatype_t;
409
+
410
+ /*! Data type for flags to ares_dns_parse() */
411
+ typedef enum {
412
+ /*! Parse Answers from RFC 1035 that allow name compression as RAW */
413
+ ARES_DNS_PARSE_AN_BASE_RAW = 1 << 0,
414
+ /*! Parse Authority from RFC 1035 that allow name compression as RAW */
415
+ ARES_DNS_PARSE_NS_BASE_RAW = 1 << 1,
416
+ /*! Parse Additional from RFC 1035 that allow name compression as RAW */
417
+ ARES_DNS_PARSE_AR_BASE_RAW = 1 << 2,
418
+ /*! Parse Answers from later RFCs (no name compression) RAW */
419
+ ARES_DNS_PARSE_AN_EXT_RAW = 1 << 3,
420
+ /*! Parse Authority from later RFCs (no name compression) as RAW */
421
+ ARES_DNS_PARSE_NS_EXT_RAW = 1 << 4,
422
+ /*! Parse Additional from later RFCs (no name compression) as RAW */
423
+ ARES_DNS_PARSE_AR_EXT_RAW = 1 << 5
424
+ } ares_dns_parse_flags_t;
425
+
426
+ /*! String representation of DNS Record Type
427
+ *
428
+ * \param[in] type DNS Record Type
429
+ * \return string
430
+ */
431
+ CARES_EXTERN const char *ares_dns_rec_type_tostr(ares_dns_rec_type_t type);
432
+
433
+ /*! String representation of DNS Class
434
+ *
435
+ * \param[in] qclass DNS Class
436
+ * \return string
437
+ */
438
+ CARES_EXTERN const char *ares_dns_class_tostr(ares_dns_class_t qclass);
439
+
440
+ /*! String representation of DNS OpCode
441
+ *
442
+ * \param[in] opcode DNS OpCode
443
+ * \return string
444
+ */
445
+ CARES_EXTERN const char *ares_dns_opcode_tostr(ares_dns_opcode_t opcode);
446
+
447
+ /*! String representation of DNS Resource Record Parameter
448
+ *
449
+ * \param[in] key DNS Resource Record parameter
450
+ * \return string
451
+ */
452
+ CARES_EXTERN const char *ares_dns_rr_key_tostr(ares_dns_rr_key_t key);
453
+
454
+ /*! String representation of DNS Resource Record section
455
+ *
456
+ * \param[in] section Section
457
+ * \return string
458
+ */
459
+ CARES_EXTERN const char *ares_dns_section_tostr(ares_dns_section_t section);
460
+
461
+ /*! Convert DNS class name as string to ares_dns_class_t
462
+ *
463
+ * \param[out] qclass Pointer passed by reference to write class
464
+ * \param[in] str String to convert
465
+ * \return ARES_TRUE on success
466
+ */
467
+ CARES_EXTERN ares_bool_t ares_dns_class_fromstr(ares_dns_class_t *qclass,
468
+ const char *str);
469
+
470
+ /*! Convert DNS record type as string to ares_dns_rec_type_t
471
+ *
472
+ * \param[out] qtype Pointer passed by reference to write record type
473
+ * \param[in] str String to convert
474
+ * \return ARES_TRUE on success
475
+ */
476
+ CARES_EXTERN ares_bool_t ares_dns_rec_type_fromstr(ares_dns_rec_type_t *qtype,
477
+ const char *str);
478
+
479
+
480
+ /*! Convert DNS response code as string to from ares_dns_rcode_t
481
+ *
482
+ * \param[in] rcode Response code to convert
483
+ * \return ARES_TRUE on success
484
+ */
485
+ CARES_EXTERN const char *ares_dns_rcode_tostr(ares_dns_rcode_t rcode);
486
+
487
+ /*! Convert any valid ip address (ipv4 or ipv6) into struct ares_addr and
488
+ * return the starting pointer of the network byte order address and the
489
+ * length of the address (4 or 16).
490
+ *
491
+ * \param[in] ipaddr ASCII string form of the ip address
492
+ * \param[in,out] addr Must set "family" member to one of AF_UNSPEC,
493
+ * AF_INET, AF_INET6 on input.
494
+ * \param[out] out_len Length of binary form address
495
+ * \return Pointer to start of binary address or NULL on error.
496
+ */
497
+ CARES_EXTERN const void *ares_dns_pton(const char *ipaddr,
498
+ struct ares_addr *addr, size_t *out_len);
499
+
500
+ /*! Convert an ip address into the PTR format for in-addr.arpa or in6.arpa
501
+ *
502
+ * \param[in] addr properly filled address structure
503
+ * \return String representing PTR, use ares_free_string() to free
504
+ */
505
+ CARES_EXTERN char *ares_dns_addr_to_ptr(const struct ares_addr *addr);
506
+
507
+
508
+ /*! The options/parameters extensions to some RRs can be somewhat opaque, this
509
+ * is a helper to return the best match for a datatype for interpreting the
510
+ * option record.
511
+ *
512
+ * \param[in] key Key associated with options/parameters
513
+ * \param[in] opt Option Key/Parameter
514
+ * \return Datatype
515
+ */
516
+ CARES_EXTERN ares_dns_opt_datatype_t
517
+ ares_dns_opt_get_datatype(ares_dns_rr_key_t key, unsigned short opt);
518
+
519
+ /*! The options/parameters extensions to some RRs can be somewhat opaque, this
520
+ * is a helper to return the name if the option is known.
521
+ *
522
+ * \param[in] key Key associated with options/parameters
523
+ * \param[in] opt Option Key/Parameter
524
+ * \return name, or NULL if not known.
525
+ */
526
+ CARES_EXTERN const char *ares_dns_opt_get_name(ares_dns_rr_key_t key,
527
+ unsigned short opt);
528
+
529
+
530
+ /*! Retrieve a list of Resource Record keys that can be set or retrieved for
531
+ * the Resource record type.
532
+ *
533
+ * \param[in] type Record Type
534
+ * \param[out] cnt Number of keys returned
535
+ * \return array of keys associated with Resource Record
536
+ */
537
+ CARES_EXTERN const ares_dns_rr_key_t *
538
+ ares_dns_rr_get_keys(ares_dns_rec_type_t type, size_t *cnt);
539
+
540
+ /*! Retrieve the datatype associated with a Resource Record key.
541
+ *
542
+ * \param[in] key Resource Record Key
543
+ * \return datatype
544
+ */
545
+ CARES_EXTERN ares_dns_datatype_t
546
+ ares_dns_rr_key_datatype(ares_dns_rr_key_t key);
547
+
548
+ /*! Retrieve the DNS Resource Record type associated with a Resource Record key.
549
+ *
550
+ * \param[in] key Resource Record Key
551
+ * \return DNS Resource Record Type
552
+ */
553
+ CARES_EXTERN ares_dns_rec_type_t
554
+ ares_dns_rr_key_to_rec_type(ares_dns_rr_key_t key);
555
+
556
+ /*! Opaque data type representing a DNS RR (Resource Record) */
557
+ struct ares_dns_rr;
558
+
559
+ /*! Typedef for opaque data type representing a DNS RR (Resource Record) */
560
+ typedef struct ares_dns_rr ares_dns_rr_t;
561
+
562
+ /*! Opaque data type representing a DNS Query Data QD Packet */
563
+ struct ares_dns_qd;
564
+
565
+ /*! Typedef for opaque data type representing a DNS Query Data QD Packet */
566
+ typedef struct ares_dns_qd ares_dns_qd_t;
567
+
568
+ /*! Opaque data type representing a DNS Packet */
569
+ struct ares_dns_record;
570
+
571
+ /*! Typedef for opaque data type representing a DNS Packet */
572
+ typedef struct ares_dns_record ares_dns_record_t;
573
+
574
+
575
+ /*! Create a new DNS record object
576
+ *
577
+ * \param[out] dnsrec Pointer passed by reference for a newly allocated
578
+ * record object. Must be ares_dns_record_destroy()'d by
579
+ * caller.
580
+ * \param[in] id DNS Query ID. If structuring a new query to be sent
581
+ * with ares_send(), this value should be zero.
582
+ * \param[in] flags DNS Flags from \ares_dns_flags_t
583
+ * \param[in] opcode DNS OpCode (typically ARES_OPCODE_QUERY)
584
+ * \param[in] rcode DNS RCode
585
+ * \return ARES_SUCCESS on success
586
+ */
587
+ CARES_EXTERN ares_status_t ares_dns_record_create(ares_dns_record_t **dnsrec,
588
+ unsigned short id,
589
+ unsigned short flags,
590
+ ares_dns_opcode_t opcode,
591
+ ares_dns_rcode_t rcode);
592
+
593
+ /*! Destroy a DNS record object
594
+ *
595
+ * \param[in] dnsrec Initialized record object
596
+ */
597
+ CARES_EXTERN void ares_dns_record_destroy(ares_dns_record_t *dnsrec);
598
+
599
+ /*! Get the DNS Query ID
600
+ *
601
+ * \param[in] dnsrec Initialized record object
602
+ * \return DNS query id
603
+ */
604
+ CARES_EXTERN unsigned short
605
+ ares_dns_record_get_id(const ares_dns_record_t *dnsrec);
606
+
607
+ /*! Overwrite the DNS query id
608
+ *
609
+ * \param[in] dnsrec Initialized record object
610
+ * \param[in] id DNS query id
611
+ * \return ARES_TRUE on success, ARES_FALSE on usage error
612
+ */
613
+ CARES_EXTERN ares_bool_t ares_dns_record_set_id(ares_dns_record_t *dnsrec,
614
+ unsigned short id);
615
+
616
+ /*! Get the DNS Record Flags
617
+ *
618
+ * \param[in] dnsrec Initialized record object
619
+ * \return One or more \ares_dns_flags_t
620
+ */
621
+ CARES_EXTERN unsigned short
622
+ ares_dns_record_get_flags(const ares_dns_record_t *dnsrec);
623
+
624
+ /*! Get the DNS Record OpCode
625
+ *
626
+ * \param[in] dnsrec Initialized record object
627
+ * \return opcode
628
+ */
629
+ CARES_EXTERN ares_dns_opcode_t
630
+ ares_dns_record_get_opcode(const ares_dns_record_t *dnsrec);
631
+
632
+ /*! Get the DNS Record RCode
633
+ *
634
+ * \param[in] dnsrec Initialized record object
635
+ * \return rcode
636
+ */
637
+ CARES_EXTERN ares_dns_rcode_t
638
+ ares_dns_record_get_rcode(const ares_dns_record_t *dnsrec);
639
+
640
+ /*! Add a query to the DNS Record. Typically a record will have only 1
641
+ * query. Most DNS servers will reject queries with more than 1 question.
642
+ *
643
+ * \param[in] dnsrec Initialized record object
644
+ * \param[in] name Name/Hostname of request
645
+ * \param[in] qtype Type of query
646
+ * \param[in] qclass Class of query (typically ARES_CLASS_IN)
647
+ * \return ARES_SUCCESS on success
648
+ */
649
+ CARES_EXTERN ares_status_t ares_dns_record_query_add(ares_dns_record_t *dnsrec,
650
+ const char *name,
651
+ ares_dns_rec_type_t qtype,
652
+ ares_dns_class_t qclass);
653
+
654
+ /*! Replace the question name with a new name. This may be used when performing
655
+ * a search with aliases.
656
+ *
657
+ * Note that this will invalidate the name pointer returned from
658
+ * ares_dns_record_query_get().
659
+ *
660
+ * \param[in] dnsrec Initialized record object
661
+ * \param[in] idx Index of question (typically 0)
662
+ * \param[in] name Name to use as replacement.
663
+ * \return ARES_SUCCESS on success
664
+ */
665
+ CARES_EXTERN ares_status_t ares_dns_record_query_set_name(
666
+ ares_dns_record_t *dnsrec, size_t idx, const char *name);
667
+
668
+
669
+ /*! Replace the question type with a different type. This may be used when
670
+ * needing to query more than one address class (e.g. A and AAAA)
671
+ *
672
+ * \param[in] dnsrec Initialized record object
673
+ * \param[in] idx Index of question (typically 0)
674
+ * \param[in] qtype Record Type to use as replacement.
675
+ * \return ARES_SUCCESS on success
676
+ */
677
+ CARES_EXTERN ares_status_t ares_dns_record_query_set_type(
678
+ ares_dns_record_t *dnsrec, size_t idx, ares_dns_rec_type_t qtype);
679
+
680
+ /*! Get the count of queries in the DNS Record
681
+ *
682
+ * \param[in] dnsrec Initialized record object
683
+ * \return count of queries
684
+ */
685
+ CARES_EXTERN size_t ares_dns_record_query_cnt(const ares_dns_record_t *dnsrec);
686
+
687
+ /*! Get the data about the query at the provided index.
688
+ *
689
+ * \param[in] dnsrec Initialized record object
690
+ * \param[in] idx Index of query
691
+ * \param[out] name Optional. Returns name, may pass NULL if not desired.
692
+ * This pointer will be invalided by any call to
693
+ * ares_dns_record_query_set_name().
694
+ * \param[out] qtype Optional. Returns record type, may pass NULL.
695
+ * \param[out] qclass Optional. Returns class, may pass NULL.
696
+ * \return ARES_SUCCESS on success
697
+ */
698
+ CARES_EXTERN ares_status_t ares_dns_record_query_get(
699
+ const ares_dns_record_t *dnsrec, size_t idx, const char **name,
700
+ ares_dns_rec_type_t *qtype, ares_dns_class_t *qclass);
701
+
702
+ /*! Get the count of Resource Records in the provided section
703
+ *
704
+ * \param[in] dnsrec Initialized record object
705
+ * \param[in] sect Section. ARES_SECTION_ANSWER is most used.
706
+ * \return count of resource records.
707
+ */
708
+ CARES_EXTERN size_t ares_dns_record_rr_cnt(const ares_dns_record_t *dnsrec,
709
+ ares_dns_section_t sect);
710
+
711
+
712
+ /*! Add a Resource Record to the DNS Record.
713
+ *
714
+ * \param[out] rr_out Pointer to created resource record. This pointer
715
+ * is owned by the DNS record itself, this is just made
716
+ * available to facilitate adding RR-specific fields.
717
+ * \param[in] dnsrec Initialized record object
718
+ * \param[in] sect Section to add resource record to
719
+ * \param[in] name Resource Record name/hostname
720
+ * \param[in] type Record Type
721
+ * \param[in] rclass Class
722
+ * \param[in] ttl TTL
723
+ * \return ARES_SUCCESS on success
724
+ */
725
+ CARES_EXTERN ares_status_t ares_dns_record_rr_add(
726
+ ares_dns_rr_t **rr_out, ares_dns_record_t *dnsrec, ares_dns_section_t sect,
727
+ const char *name, ares_dns_rec_type_t type, ares_dns_class_t rclass,
728
+ unsigned int ttl);
729
+
730
+ /*! Fetch a writable resource record based on the section and index.
731
+ *
732
+ * \param[in] dnsrec Initialized record object
733
+ * \param[in] sect Section for resource record
734
+ * \param[in] idx Index of resource record in section
735
+ * \return NULL on misuse, otherwise a writable pointer to the resource record
736
+ */
737
+ CARES_EXTERN ares_dns_rr_t *ares_dns_record_rr_get(ares_dns_record_t *dnsrec,
738
+ ares_dns_section_t sect,
739
+ size_t idx);
740
+
741
+ /*! Fetch a non-writeable resource record based on the section and index.
742
+ *
743
+ * \param[in] dnsrec Initialized record object
744
+ * \param[in] sect Section for resource record
745
+ * \param[in] idx Index of resource record in section
746
+ * \return NULL on misuse, otherwise a const pointer to the resource record
747
+ */
748
+ CARES_EXTERN const ares_dns_rr_t *
749
+ ares_dns_record_rr_get_const(const ares_dns_record_t *dnsrec,
750
+ ares_dns_section_t sect, size_t idx);
751
+
752
+
753
+ /*! Remove the resource record based on the section and index
754
+ *
755
+ * \param[in] dnsrec Initialized record object
756
+ * \param[in] sect Section for resource record
757
+ * \param[in] idx Index of resource record in section
758
+ * \return ARES_SUCCESS on success, otherwise an error code.
759
+ */
760
+ CARES_EXTERN ares_status_t ares_dns_record_rr_del(ares_dns_record_t *dnsrec,
761
+ ares_dns_section_t sect,
762
+ size_t idx);
763
+
764
+
765
+ /*! Retrieve the resource record Name/Hostname
766
+ *
767
+ * \param[in] rr Pointer to resource record
768
+ * \return Name
769
+ */
770
+ CARES_EXTERN const char *ares_dns_rr_get_name(const ares_dns_rr_t *rr);
771
+
772
+ /*! Retrieve the resource record type
773
+ *
774
+ * \param[in] rr Pointer to resource record
775
+ * \return type
776
+ */
777
+ CARES_EXTERN ares_dns_rec_type_t ares_dns_rr_get_type(const ares_dns_rr_t *rr);
778
+
779
+ /*! Retrieve the resource record class
780
+ *
781
+ * \param[in] rr Pointer to resource record
782
+ * \return class
783
+ */
784
+ CARES_EXTERN ares_dns_class_t ares_dns_rr_get_class(const ares_dns_rr_t *rr);
785
+
786
+ /*! Retrieve the resource record TTL
787
+ *
788
+ * \param[in] rr Pointer to resource record
789
+ * \return TTL
790
+ */
791
+ CARES_EXTERN unsigned int ares_dns_rr_get_ttl(const ares_dns_rr_t *rr);
792
+
793
+ /*! Set ipv4 address data type for specified resource record and key. Can
794
+ * only be used on keys with datatype ARES_DATATYPE_INADDR
795
+ *
796
+ * \param[in] dns_rr Pointer to resource record
797
+ * \param[in] key DNS Resource Record Key
798
+ * \param[in] addr Pointer to ipv4 address to use.
799
+ * \return ARES_SUCCESS on success
800
+ */
801
+ CARES_EXTERN ares_status_t ares_dns_rr_set_addr(ares_dns_rr_t *dns_rr,
802
+ ares_dns_rr_key_t key,
803
+ const struct in_addr *addr);
804
+
805
+ /*! Set ipv6 address data type for specified resource record and key. Can
806
+ * only be used on keys with datatype ARES_DATATYPE_INADDR6
807
+ *
808
+ * \param[in] dns_rr Pointer to resource record
809
+ * \param[in] key DNS Resource Record Key
810
+ * \param[in] addr Pointer to ipv6 address to use.
811
+ * \return ARES_SUCCESS on success
812
+ */
813
+ CARES_EXTERN ares_status_t
814
+ ares_dns_rr_set_addr6(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key,
815
+ const struct ares_in6_addr *addr);
816
+
817
+ /*! Set string data for specified resource record and key. Can
818
+ * only be used on keys with datatype ARES_DATATYPE_STR or ARES_DATATYPE_NAME.
819
+ *
820
+ * \param[in] dns_rr Pointer to resource record
821
+ * \param[in] key DNS Resource Record Key
822
+ * \param[in] val Pointer to string to set.
823
+ * \return ARES_SUCCESS on success
824
+ */
825
+ CARES_EXTERN ares_status_t ares_dns_rr_set_str(ares_dns_rr_t *dns_rr,
826
+ ares_dns_rr_key_t key,
827
+ const char *val);
828
+
829
+ /*! Set 8bit unsigned integer for specified resource record and key. Can
830
+ * only be used on keys with datatype ARES_DATATYPE_U8
831
+ *
832
+ * \param[in] dns_rr Pointer to resource record
833
+ * \param[in] key DNS Resource Record Key
834
+ * \param[in] val 8bit unsigned integer
835
+ * \return ARES_SUCCESS on success
836
+ */
837
+ CARES_EXTERN ares_status_t ares_dns_rr_set_u8(ares_dns_rr_t *dns_rr,
838
+ ares_dns_rr_key_t key,
839
+ unsigned char val);
840
+
841
+ /*! Set 16bit unsigned integer for specified resource record and key. Can
842
+ * only be used on keys with datatype ARES_DATATYPE_U16
843
+ *
844
+ * \param[in] dns_rr Pointer to resource record
845
+ * \param[in] key DNS Resource Record Key
846
+ * \param[in] val 16bit unsigned integer
847
+ * \return ARES_SUCCESS on success
848
+ */
849
+ CARES_EXTERN ares_status_t ares_dns_rr_set_u16(ares_dns_rr_t *dns_rr,
850
+ ares_dns_rr_key_t key,
851
+ unsigned short val);
852
+
853
+ /*! Set 32bit unsigned integer for specified resource record and key. Can
854
+ * only be used on keys with datatype ARES_DATATYPE_U32
855
+ *
856
+ * \param[in] dns_rr Pointer to resource record
857
+ * \param[in] key DNS Resource Record Key
858
+ * \param[in] val 32bit unsigned integer
859
+ * \return ARES_SUCCESS on success
860
+ */
861
+ CARES_EXTERN ares_status_t ares_dns_rr_set_u32(ares_dns_rr_t *dns_rr,
862
+ ares_dns_rr_key_t key,
863
+ unsigned int val);
864
+
865
+ /*! Set binary (BIN or BINP) data for specified resource record and key. Can
866
+ * only be used on keys with datatype ARES_DATATYPE_BIN or ARES_DATATYPE_BINP.
867
+ *
868
+ * \param[in] dns_rr Pointer to resource record
869
+ * \param[in] key DNS Resource Record Key
870
+ * \param[in] val Pointer to binary data.
871
+ * \param[in] len Length of binary data
872
+ * \return ARES_SUCCESS on success
873
+ */
874
+ CARES_EXTERN ares_status_t ares_dns_rr_set_bin(ares_dns_rr_t *dns_rr,
875
+ ares_dns_rr_key_t key,
876
+ const unsigned char *val,
877
+ size_t len);
878
+
879
+ /*! Add binary array value (ABINP) data for specified resource record and key.
880
+ * Can only be used on keys with datatype ARES_DATATYPE_ABINP. The value will
881
+ * Be added as the last element in the array.
882
+ *
883
+ * \param[in] dns_rr Pointer to resource record
884
+ * \param[in] key DNS Resource Record Key
885
+ * \param[in] val Pointer to binary data.
886
+ * \param[in] len Length of binary data
887
+ * \return ARES_SUCCESS on success
888
+ */
889
+ CARES_EXTERN ares_status_t ares_dns_rr_add_abin(ares_dns_rr_t *dns_rr,
890
+ ares_dns_rr_key_t key,
891
+ const unsigned char *val,
892
+ size_t len);
893
+
894
+ /*! Delete binary array value (ABINP) data for specified resource record and
895
+ * key by specified index. Can only be used on keys with datatype
896
+ * ARES_DATATYPE_ABINP. The value at the index will be deleted.
897
+ *
898
+ * \param[in] dns_rr Pointer to resource record
899
+ * \param[in] key DNS Resource Record Key
900
+ * \param[in] idx Index to delete
901
+ * \return ARES_SUCCESS on success
902
+ */
903
+ CARES_EXTERN ares_status_t ares_dns_rr_del_abin(ares_dns_rr_t *dns_rr,
904
+ ares_dns_rr_key_t key,
905
+ size_t idx);
906
+
907
+ /*! Set the option for the RR
908
+ *
909
+ * \param[in] dns_rr Pointer to resource record
910
+ * \param[in] key DNS Resource Record Key
911
+ * \param[in] opt Option record key id.
912
+ * \param[out] val Optional. Value to associate with option.
913
+ * \param[out] val_len Length of value passed.
914
+ * \return ARES_SUCCESS on success
915
+ */
916
+ CARES_EXTERN ares_status_t ares_dns_rr_set_opt(ares_dns_rr_t *dns_rr,
917
+ ares_dns_rr_key_t key,
918
+ unsigned short opt,
919
+ const unsigned char *val,
920
+ size_t val_len);
921
+
922
+ /*! Delete the option for the RR by id
923
+ *
924
+ * \param[in] dns_rr Pointer to resource record
925
+ * \param[in] key DNS Resource Record Key
926
+ * \param[in] opt Option record key id.
927
+ * \return ARES_SUCCESS if removed, ARES_ENOTFOUND if not found
928
+ */
929
+ CARES_EXTERN ares_status_t ares_dns_rr_del_opt_byid(ares_dns_rr_t *dns_rr,
930
+ ares_dns_rr_key_t key,
931
+ unsigned short opt);
932
+
933
+ /*! Retrieve a pointer to the ipv4 address. Can only be used on keys with
934
+ * datatype ARES_DATATYPE_INADDR.
935
+ *
936
+ * \param[in] dns_rr Pointer to resource record
937
+ * \param[in] key DNS Resource Record Key
938
+ * \return pointer to ipv4 address or NULL on error
939
+ */
940
+ CARES_EXTERN const struct in_addr *
941
+ ares_dns_rr_get_addr(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key);
942
+
943
+ /*! Retrieve a pointer to the ipv6 address. Can only be used on keys with
944
+ * datatype ARES_DATATYPE_INADDR6.
945
+ *
946
+ * \param[in] dns_rr Pointer to resource record
947
+ * \param[in] key DNS Resource Record Key
948
+ * \return pointer to ipv6 address or NULL on error
949
+ */
950
+ CARES_EXTERN const struct ares_in6_addr *
951
+ ares_dns_rr_get_addr6(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key);
952
+
953
+ /*! Retrieve a pointer to the string. Can only be used on keys with
954
+ * datatype ARES_DATATYPE_STR and ARES_DATATYPE_NAME.
955
+ *
956
+ * \param[in] dns_rr Pointer to resource record
957
+ * \param[in] key DNS Resource Record Key
958
+ * \return pointer string or NULL on error
959
+ */
960
+ CARES_EXTERN const char *ares_dns_rr_get_str(const ares_dns_rr_t *dns_rr,
961
+ ares_dns_rr_key_t key);
962
+
963
+ /*! Retrieve an 8bit unsigned integer. Can only be used on keys with
964
+ * datatype ARES_DATATYPE_U8.
965
+ *
966
+ * \param[in] dns_rr Pointer to resource record
967
+ * \param[in] key DNS Resource Record Key
968
+ * \return 8bit unsigned integer
969
+ */
970
+ CARES_EXTERN unsigned char ares_dns_rr_get_u8(const ares_dns_rr_t *dns_rr,
971
+ ares_dns_rr_key_t key);
972
+
973
+ /*! Retrieve an 16bit unsigned integer. Can only be used on keys with
974
+ * datatype ARES_DATATYPE_U16.
975
+ *
976
+ * \param[in] dns_rr Pointer to resource record
977
+ * \param[in] key DNS Resource Record Key
978
+ * \return 16bit unsigned integer
979
+ */
980
+ CARES_EXTERN unsigned short ares_dns_rr_get_u16(const ares_dns_rr_t *dns_rr,
981
+ ares_dns_rr_key_t key);
982
+
983
+ /*! Retrieve an 32bit unsigned integer. Can only be used on keys with
984
+ * datatype ARES_DATATYPE_U32.
985
+ *
986
+ * \param[in] dns_rr Pointer to resource record
987
+ * \param[in] key DNS Resource Record Key
988
+ * \return 32bit unsigned integer
989
+ */
990
+ CARES_EXTERN unsigned int ares_dns_rr_get_u32(const ares_dns_rr_t *dns_rr,
991
+ ares_dns_rr_key_t key);
992
+
993
+ /*! Retrieve a pointer to the binary data. Can only be used on keys with
994
+ * datatype ARES_DATATYPE_BIN, ARES_DATATYPE_BINP, or ARES_DATATYPE_ABINP.
995
+ * If BINP or ABINP, the data is guaranteed to have a NULL terminator which
996
+ * is NOT included in the length.
997
+ *
998
+ * \param[in] dns_rr Pointer to resource record
999
+ * \param[in] key DNS Resource Record Key
1000
+ * \param[out] len Length of binary data returned
1001
+ * \return pointer binary data or NULL on error
1002
+ */
1003
+ CARES_EXTERN const unsigned char *
1004
+ ares_dns_rr_get_bin(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key,
1005
+ size_t *len);
1006
+
1007
+ /*! Retrieve the count of the array of stored binary values. Can only be used on
1008
+ * keys with datatype ARES_DATATYPE_ABINP.
1009
+ *
1010
+ * \param[in] dns_rr Pointer to resource record
1011
+ * \param[in] key DNS Resource Record Key
1012
+ * \return count of values
1013
+ */
1014
+ CARES_EXTERN size_t ares_dns_rr_get_abin_cnt(const ares_dns_rr_t *dns_rr,
1015
+ ares_dns_rr_key_t key);
1016
+
1017
+ /*! Retrieve a pointer to the binary array data from the specified index. Can
1018
+ * only be used on keys with datatype ARES_DATATYPE_ABINP. If ABINP, the data
1019
+ * is guaranteed to have a NULL terminator which is NOT included in the length.
1020
+ * If want all array membersconcatenated, may use ares_dns_rr_get_bin()
1021
+ * instead.
1022
+ *
1023
+ * \param[in] dns_rr Pointer to resource record
1024
+ * \param[in] key DNS Resource Record Key
1025
+ * \param[in] idx Index of value to retrieve
1026
+ * \param[out] len Length of binary data returned
1027
+ * \return pointer binary data or NULL on error
1028
+ */
1029
+ CARES_EXTERN const unsigned char *
1030
+ ares_dns_rr_get_abin(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key,
1031
+ size_t idx, size_t *len);
1032
+
1033
+
1034
+ /*! Retrieve the number of options stored for the RR.
1035
+ *
1036
+ * \param[in] dns_rr Pointer to resource record
1037
+ * \param[in] key DNS Resource Record Key
1038
+ * \return count, or 0 if none.
1039
+ */
1040
+ CARES_EXTERN size_t ares_dns_rr_get_opt_cnt(const ares_dns_rr_t *dns_rr,
1041
+ ares_dns_rr_key_t key);
1042
+
1043
+ /*! Retrieve the option for the RR by index.
1044
+ *
1045
+ * \param[in] dns_rr Pointer to resource record
1046
+ * \param[in] key DNS Resource Record Key
1047
+ * \param[in] idx Index of option record
1048
+ * \param[out] val Optional. Pointer passed by reference to hold value.
1049
+ * Options may not have values. Value if returned is
1050
+ * guaranteed to be NULL terminated, however in most
1051
+ * cases it is not printable.
1052
+ * \param[out] val_len Optional. Pointer passed by reference to hold value
1053
+ * length.
1054
+ * \return option key/id on success, 65535 on misuse.
1055
+ */
1056
+ CARES_EXTERN unsigned short
1057
+ ares_dns_rr_get_opt(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key,
1058
+ size_t idx, const unsigned char **val, size_t *val_len);
1059
+
1060
+ /*! Retrieve the option for the RR by the option key/id.
1061
+ *
1062
+ * \param[in] dns_rr Pointer to resource record
1063
+ * \param[in] key DNS Resource Record Key
1064
+ * \param[in] opt Option record key id (this is not the index).
1065
+ * \param[out] val Optional. Pointer passed by reference to hold value.
1066
+ * Options may not have values. Value if returned is
1067
+ * guaranteed to be NULL terminated, however in most cases
1068
+ * it is not printable.
1069
+ * \param[out] val_len Optional. Pointer passed by reference to hold value
1070
+ * length.
1071
+ * \return ARES_TRUE on success, ARES_FALSE on misuse.
1072
+ */
1073
+ CARES_EXTERN ares_bool_t ares_dns_rr_get_opt_byid(const ares_dns_rr_t *dns_rr,
1074
+ ares_dns_rr_key_t key,
1075
+ unsigned short opt,
1076
+ const unsigned char **val,
1077
+ size_t *val_len);
1078
+
1079
+ /*! Parse a complete DNS message.
1080
+ *
1081
+ * \param[in] buf pointer to bytes to be parsed
1082
+ * \param[in] buf_len Length of buf provided
1083
+ * \param[in] flags Flags dictating how the message should be parsed.
1084
+ * \param[out] dnsrec Pointer passed by reference for a new DNS record object
1085
+ * that must be ares_dns_record_destroy()'d by caller.
1086
+ * \return ARES_SUCCESS on success
1087
+ */
1088
+ CARES_EXTERN ares_status_t ares_dns_parse(const unsigned char *buf,
1089
+ size_t buf_len, unsigned int flags,
1090
+ ares_dns_record_t **dnsrec);
1091
+
1092
+ /*! Write a complete DNS message
1093
+ *
1094
+ * \param[in] dnsrec Pointer to initialized and filled DNS record object.
1095
+ * \param[out] buf Pointer passed by reference to be filled in with with
1096
+ * DNS message. Must be ares_free_string()'d by caller.
1097
+ * \param[out] buf_len Length of returned buffer containing DNS message.
1098
+ * \return ARES_SUCCESS on success
1099
+ */
1100
+ CARES_EXTERN ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec,
1101
+ unsigned char **buf, size_t *buf_len);
1102
+
1103
+
1104
+ /*! Duplicate a complete DNS message. This does not copy internal members
1105
+ * (such as the ttl decrement capability).
1106
+ *
1107
+ * \param[in] dnsrec Pointer to initialized and filled DNS record object.
1108
+ * \return duplicated DNS record object, or NULL on out of memory.
1109
+ */
1110
+ CARES_EXTERN ares_dns_record_t *
1111
+ ares_dns_record_duplicate(const ares_dns_record_t *dnsrec);
1112
+
1113
+ /*! @} */
1114
+
1115
+ #ifdef __cplusplus
1116
+ }
1117
+ #endif
1118
+
1119
+ #endif /* __ARES_DNS_RECORD_H */