grpc 1.74.1 → 1.75.0.pre1

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 (368) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +83 -41
  3. data/include/grpc/credentials.h +7 -1
  4. data/src/core/call/client_call.cc +4 -4
  5. data/src/core/call/filter_fusion.h +1230 -0
  6. data/src/core/call/metadata.cc +22 -0
  7. data/src/core/call/metadata.h +24 -2
  8. data/src/core/channelz/channelz.cc +10 -17
  9. data/src/core/channelz/channelz.h +58 -19
  10. data/src/core/channelz/channelz_registry.cc +0 -162
  11. data/src/core/channelz/channelz_registry.h +14 -7
  12. data/src/core/channelz/property_list.cc +19 -23
  13. data/src/core/channelz/property_list.h +3 -1
  14. data/src/core/channelz/v2tov1/convert.cc +683 -0
  15. data/src/core/channelz/v2tov1/convert.h +58 -0
  16. data/src/core/channelz/v2tov1/legacy_api.cc +425 -0
  17. data/src/core/channelz/v2tov1/legacy_api.h +32 -0
  18. data/src/core/channelz/v2tov1/property_list.cc +118 -0
  19. data/src/core/channelz/v2tov1/property_list.h +52 -0
  20. data/src/core/client_channel/client_channel_filter.cc +5 -4
  21. data/src/core/client_channel/client_channel_filter.h +2 -2
  22. data/src/core/client_channel/client_channel_internal.h +2 -1
  23. data/src/core/client_channel/load_balanced_call_destination.cc +6 -5
  24. data/src/core/client_channel/subchannel.cc +14 -6
  25. data/src/core/client_channel/subchannel.h +2 -0
  26. data/src/core/config/core_configuration.cc +3 -1
  27. data/src/core/config/core_configuration.h +12 -0
  28. data/src/core/credentials/transport/alts/alts_credentials.cc +5 -0
  29. data/src/core/credentials/transport/alts/check_gcp_environment_windows.cc +2 -0
  30. data/src/core/credentials/transport/channel_creds_registry_init.cc +3 -1
  31. data/src/core/credentials/transport/ssl/ssl_credentials.cc +1 -1
  32. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +8 -3
  33. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -24
  34. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +19 -8
  35. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +96 -54
  36. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +15 -2
  37. data/src/core/credentials/transport/tls/spiffe_utils.cc +371 -0
  38. data/src/core/credentials/transport/tls/spiffe_utils.h +171 -0
  39. data/src/core/credentials/transport/tls/ssl_utils.cc +11 -10
  40. data/src/core/credentials/transport/tls/ssl_utils.h +4 -2
  41. data/src/core/credentials/transport/tls/tls_credentials.cc +2 -0
  42. data/src/core/credentials/transport/tls/tls_security_connector.cc +11 -26
  43. data/src/core/credentials/transport/tls/tls_security_connector.h +12 -12
  44. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -2
  45. data/src/core/ext/filters/http/client/http_client_filter.cc +3 -6
  46. data/src/core/ext/filters/http/client_authority_filter.cc +1 -2
  47. data/src/core/ext/filters/http/message_compress/compression_filter.cc +8 -8
  48. data/src/core/ext/filters/http/server/http_server_filter.cc +3 -6
  49. data/src/core/ext/filters/message_size/message_size_filter.cc +4 -4
  50. data/src/core/ext/filters/rbac/rbac_filter.cc +1 -1
  51. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -5
  52. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +3 -2
  53. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
  54. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
  55. data/src/core/ext/transport/chttp2/transport/frame.cc +89 -6
  56. data/src/core/ext/transport/chttp2/transport/frame.h +38 -0
  57. data/src/core/ext/transport/chttp2/transport/header_assembler.h +5 -14
  58. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -1
  59. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +294 -78
  60. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +128 -9
  61. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +11 -38
  62. data/src/core/ext/transport/chttp2/transport/http2_settings.h +52 -35
  63. data/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc +61 -0
  64. data/src/core/ext/transport/chttp2/transport/http2_settings_manager.h +142 -0
  65. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +81 -3
  66. data/src/core/ext/transport/chttp2/transport/http2_transport.h +12 -1
  67. data/src/core/ext/transport/chttp2/transport/message_assembler.h +2 -2
  68. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -1
  69. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +2 -1
  70. data/src/core/ext/transport/chttp2/transport/ping_promise.h +22 -5
  71. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +607 -0
  72. data/src/core/ext/transport/chttp2/transport/writable_streams.h +254 -0
  73. data/src/core/ext/transport/chttp2/transport/writing.cc +6 -4
  74. data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb.h +4959 -0
  75. data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.c +1111 -0
  76. data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.h +108 -0
  77. data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +142 -54
  78. data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +18 -14
  79. data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +2 -2
  80. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +716 -0
  81. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.h +227 -0
  82. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +86 -88
  83. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +2 -2
  84. data/src/core/filter/auth/auth_filters.h +2 -2
  85. data/src/core/filter/fused_filters.cc +154 -0
  86. data/src/core/handshaker/security/legacy_secure_endpoint.cc +1 -1
  87. data/src/core/handshaker/security/pipelined_secure_endpoint.cc +965 -0
  88. data/src/core/handshaker/security/secure_endpoint.cc +28 -13
  89. data/src/core/handshaker/security/secure_endpoint.h +8 -0
  90. data/src/core/lib/channel/promise_based_filter.cc +15 -25
  91. data/src/core/lib/channel/promise_based_filter.h +6 -5
  92. data/src/core/lib/event_engine/ares_resolver.h +3 -1
  93. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -5
  94. data/src/core/lib/event_engine/cf_engine/cf_engine.h +2 -1
  95. data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +263 -0
  96. data/src/core/lib/event_engine/cf_engine/cfsocket_listener.h +107 -0
  97. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +31 -3
  98. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +12 -0
  99. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +12 -10
  100. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +6 -4
  101. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +15 -14
  102. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -5
  103. data/src/core/lib/event_engine/posix_engine/event_poller.h +0 -8
  104. data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +11 -5
  105. data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +3 -2
  106. data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +1 -0
  107. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +4 -4
  108. data/src/core/lib/event_engine/posix_engine/lockfree_event.h +3 -4
  109. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +2 -2
  110. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +188 -199
  111. data/src/core/lib/event_engine/posix_engine/posix_engine.h +30 -45
  112. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +1 -1
  113. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +1 -1
  114. data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +2 -1
  115. data/src/core/lib/experiments/experiments.cc +120 -6
  116. data/src/core/lib/experiments/experiments.h +46 -3
  117. data/src/core/lib/iomgr/combiner.cc +1 -1
  118. data/src/core/lib/iomgr/exec_ctx.h +3 -9
  119. data/src/core/lib/iomgr/socket_mutator.cc +1 -1
  120. data/src/core/lib/iomgr/socket_utils_posix.cc +1 -1
  121. data/src/core/lib/iomgr/socket_utils_posix.h +1 -1
  122. data/src/core/lib/iomgr/tcp_client_posix.cc +1 -1
  123. data/src/core/lib/iomgr/tcp_posix.cc +3 -3
  124. data/src/core/lib/promise/activity.h +2 -2
  125. data/src/core/lib/promise/mpsc.cc +8 -8
  126. data/src/core/lib/promise/party.cc +7 -7
  127. data/src/core/lib/promise/party.h +4 -4
  128. data/src/core/lib/promise/poll.h +10 -0
  129. data/src/core/lib/resource_quota/memory_quota.cc +90 -3
  130. data/src/core/lib/resource_quota/memory_quota.h +20 -9
  131. data/src/core/lib/resource_quota/periodic_update.cc +14 -0
  132. data/src/core/lib/resource_quota/periodic_update.h +8 -0
  133. data/src/core/lib/resource_quota/resource_quota.cc +15 -4
  134. data/src/core/lib/resource_quota/resource_quota.h +3 -0
  135. data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -2
  136. data/src/core/lib/surface/call.cc +5 -5
  137. data/src/core/lib/surface/call.h +6 -5
  138. data/src/core/lib/surface/completion_queue.cc +2 -4
  139. data/src/core/lib/surface/filter_stack_call.cc +1 -1
  140. data/src/core/lib/surface/version.cc +2 -2
  141. data/src/core/lib/transport/promise_endpoint.cc +2 -2
  142. data/src/core/lib/transport/promise_endpoint.h +3 -3
  143. data/src/core/load_balancing/endpoint_list.cc +29 -2
  144. data/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +3 -3
  145. data/src/core/load_balancing/grpclb/client_load_reporting_filter.h +1 -1
  146. data/src/core/load_balancing/pick_first/pick_first.cc +12 -5
  147. data/src/core/load_balancing/xds/xds_cluster_impl.cc +5 -3
  148. data/src/core/net/socket_mutator.cc +19 -0
  149. data/src/core/net/socket_mutator.h +25 -0
  150. data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
  151. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +6 -1
  152. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +2 -1
  153. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +8 -5
  154. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
  155. data/src/core/resolver/xds/xds_dependency_manager.cc +1 -1
  156. data/src/core/server/server.cc +1 -1
  157. data/src/core/server/server_call_tracer_filter.cc +0 -66
  158. data/src/core/server/server_call_tracer_filter.h +64 -0
  159. data/src/core/server/server_config_selector_filter.cc +1 -1
  160. data/src/core/service_config/service_config_channel_arg_filter.cc +3 -60
  161. data/src/core/service_config/service_config_channel_arg_filter.h +82 -0
  162. data/src/core/telemetry/call_tracer.cc +20 -14
  163. data/src/core/telemetry/call_tracer.h +22 -17
  164. data/src/core/telemetry/metrics.h +8 -8
  165. data/src/core/telemetry/stats_data.cc +151 -151
  166. data/src/core/telemetry/stats_data.h +87 -87
  167. data/src/core/transport/auth_context.cc +20 -0
  168. data/src/core/transport/auth_context.h +4 -0
  169. data/src/core/transport/auth_context_comparator_registry.h +69 -0
  170. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -3
  171. data/src/core/tsi/ssl_transport_security.cc +202 -32
  172. data/src/core/tsi/ssl_transport_security.h +19 -10
  173. data/src/core/tsi/ssl_transport_security_utils.cc +21 -0
  174. data/src/core/tsi/ssl_transport_security_utils.h +4 -0
  175. data/src/core/util/http_client/httpcli_security_connector.cc +3 -1
  176. data/src/core/util/latent_see.cc +178 -146
  177. data/src/core/util/latent_see.h +245 -188
  178. data/src/core/util/single_set_ptr.h +5 -2
  179. data/src/core/util/useful.h +91 -0
  180. data/src/core/util/windows/directory_reader.cc +1 -0
  181. data/src/core/util/windows/thd.cc +1 -3
  182. data/src/core/util/work_serializer.cc +1 -1
  183. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +32 -5
  184. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +5 -0
  185. data/src/core/xds/grpc/xds_certificate_provider.cc +5 -6
  186. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
  187. data/src/ruby/lib/grpc/version.rb +1 -1
  188. data/third_party/cares/cares/include/ares.h +925 -460
  189. data/third_party/cares/cares/include/ares_dns.h +86 -71
  190. data/third_party/cares/cares/include/ares_dns_record.h +1118 -0
  191. data/third_party/cares/cares/include/ares_nameser.h +215 -189
  192. data/third_party/cares/cares/include/ares_version.h +37 -14
  193. data/third_party/cares/cares/src/lib/ares_addrinfo2hostent.c +305 -0
  194. data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +245 -0
  195. data/third_party/cares/cares/src/lib/ares_android.c +216 -164
  196. data/third_party/cares/cares/src/lib/ares_android.h +25 -14
  197. data/third_party/cares/cares/src/lib/ares_cancel.c +68 -44
  198. data/third_party/cares/cares/src/lib/ares_close_sockets.c +137 -0
  199. data/third_party/cares/cares/src/lib/ares_conn.c +511 -0
  200. data/third_party/cares/cares/src/lib/ares_conn.h +196 -0
  201. data/third_party/cares/cares/src/lib/ares_cookie.c +461 -0
  202. data/third_party/cares/cares/src/lib/ares_data.c +93 -181
  203. data/third_party/cares/cares/src/lib/ares_data.h +50 -39
  204. data/third_party/cares/cares/src/lib/ares_destroy.c +127 -89
  205. data/third_party/cares/cares/src/lib/ares_free_hostent.c +35 -24
  206. data/third_party/cares/cares/src/lib/ares_free_string.c +24 -16
  207. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +45 -38
  208. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +549 -663
  209. data/third_party/cares/cares/src/lib/ares_getenv.c +25 -15
  210. data/third_party/cares/cares/src/lib/ares_getenv.h +26 -18
  211. data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +163 -221
  212. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +222 -223
  213. data/third_party/cares/cares/src/lib/ares_getnameinfo.c +328 -338
  214. data/third_party/cares/cares/src/lib/ares_hosts_file.c +952 -0
  215. data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +25 -19
  216. data/third_party/cares/cares/src/lib/ares_init.c +425 -2091
  217. data/third_party/cares/cares/src/lib/ares_ipv6.h +63 -33
  218. data/third_party/cares/cares/src/lib/ares_library_init.c +110 -54
  219. data/third_party/cares/cares/src/lib/ares_metrics.c +261 -0
  220. data/third_party/cares/cares/src/lib/ares_options.c +418 -332
  221. data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +179 -0
  222. data/third_party/cares/cares/src/lib/ares_private.h +558 -356
  223. data/third_party/cares/cares/src/lib/ares_process.c +1224 -1369
  224. data/third_party/cares/cares/src/lib/ares_qcache.c +430 -0
  225. data/third_party/cares/cares/src/lib/ares_query.c +126 -121
  226. data/third_party/cares/cares/src/lib/ares_search.c +564 -262
  227. data/third_party/cares/cares/src/lib/ares_send.c +264 -93
  228. data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +588 -0
  229. data/third_party/cares/cares/src/lib/ares_setup.h +115 -111
  230. data/third_party/cares/cares/src/lib/ares_socket.c +425 -0
  231. data/third_party/cares/cares/src/lib/ares_socket.h +163 -0
  232. data/third_party/cares/cares/src/lib/ares_sortaddrinfo.c +447 -0
  233. data/third_party/cares/cares/src/lib/ares_strerror.c +83 -48
  234. data/third_party/cares/cares/src/lib/ares_sysconfig.c +639 -0
  235. data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +839 -0
  236. data/third_party/cares/cares/src/lib/ares_sysconfig_mac.c +373 -0
  237. data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +621 -0
  238. data/third_party/cares/cares/src/lib/ares_timeout.c +136 -73
  239. data/third_party/cares/cares/src/lib/ares_update_servers.c +1362 -0
  240. data/third_party/cares/cares/src/lib/ares_version.c +29 -4
  241. data/third_party/cares/cares/src/lib/config-dos.h +88 -89
  242. data/third_party/cares/cares/src/lib/config-win32.h +122 -77
  243. data/third_party/cares/cares/src/lib/dsa/ares_array.c +394 -0
  244. data/third_party/cares/cares/src/lib/dsa/ares_htable.c +447 -0
  245. data/third_party/cares/cares/src/lib/dsa/ares_htable.h +174 -0
  246. data/third_party/cares/cares/src/lib/dsa/ares_htable_asvp.c +224 -0
  247. data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +228 -0
  248. data/third_party/cares/cares/src/lib/dsa/ares_htable_strvp.c +210 -0
  249. data/third_party/cares/cares/src/lib/dsa/ares_htable_szvp.c +188 -0
  250. data/third_party/cares/cares/src/lib/dsa/ares_htable_vpstr.c +186 -0
  251. data/third_party/cares/cares/src/lib/dsa/ares_htable_vpvp.c +194 -0
  252. data/third_party/cares/cares/src/lib/dsa/ares_llist.c +382 -0
  253. data/third_party/cares/cares/src/lib/dsa/ares_slist.c +479 -0
  254. data/third_party/cares/cares/src/lib/dsa/ares_slist.h +207 -0
  255. data/third_party/cares/cares/src/lib/event/ares_event.h +191 -0
  256. data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +743 -0
  257. data/third_party/cares/cares/src/lib/event/ares_event_epoll.c +192 -0
  258. data/third_party/cares/cares/src/lib/event/ares_event_kqueue.c +248 -0
  259. data/third_party/cares/cares/src/lib/event/ares_event_poll.c +140 -0
  260. data/third_party/cares/cares/src/lib/event/ares_event_select.c +159 -0
  261. data/third_party/cares/cares/src/lib/event/ares_event_thread.c +567 -0
  262. data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +166 -0
  263. data/third_party/cares/cares/src/lib/event/ares_event_win32.c +978 -0
  264. data/third_party/cares/cares/src/lib/event/ares_event_win32.h +161 -0
  265. data/third_party/cares/cares/src/lib/include/ares_array.h +276 -0
  266. data/third_party/cares/cares/src/lib/include/ares_buf.h +732 -0
  267. data/third_party/cares/cares/src/lib/include/ares_htable_asvp.h +130 -0
  268. data/third_party/cares/cares/src/lib/include/ares_htable_dict.h +123 -0
  269. data/third_party/cares/cares/src/lib/include/ares_htable_strvp.h +130 -0
  270. data/third_party/cares/cares/src/lib/include/ares_htable_szvp.h +118 -0
  271. data/third_party/cares/cares/src/lib/include/ares_htable_vpstr.h +111 -0
  272. data/third_party/cares/cares/src/lib/include/ares_htable_vpvp.h +128 -0
  273. data/third_party/cares/cares/src/lib/include/ares_llist.h +239 -0
  274. data/third_party/cares/cares/src/lib/include/ares_mem.h +38 -0
  275. data/third_party/cares/cares/src/lib/include/ares_str.h +244 -0
  276. data/third_party/cares/cares/src/lib/inet_net_pton.c +202 -157
  277. data/third_party/cares/cares/src/lib/inet_ntop.c +87 -69
  278. data/third_party/cares/cares/src/lib/legacy/ares_create_query.c +78 -0
  279. data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +99 -0
  280. data/third_party/cares/cares/src/lib/legacy/ares_expand_string.c +107 -0
  281. data/third_party/cares/cares/src/lib/legacy/ares_fds.c +80 -0
  282. data/third_party/cares/cares/src/lib/legacy/ares_getsock.c +85 -0
  283. data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +107 -0
  284. data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
  285. data/third_party/cares/cares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
  286. data/third_party/cares/cares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
  287. data/third_party/cares/cares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
  288. data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
  289. data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
  290. data/third_party/cares/cares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
  291. data/third_party/cares/cares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
  292. data/third_party/cares/cares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
  293. data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
  294. data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +982 -0
  295. data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +307 -0
  296. data/third_party/cares/cares/src/lib/record/ares_dns_multistring.h +72 -0
  297. data/third_party/cares/cares/src/lib/record/ares_dns_name.c +673 -0
  298. data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +1329 -0
  299. data/third_party/cares/cares/src/lib/record/ares_dns_private.h +273 -0
  300. data/third_party/cares/cares/src/lib/record/ares_dns_record.c +1661 -0
  301. data/third_party/cares/cares/src/lib/record/ares_dns_write.c +1229 -0
  302. data/third_party/cares/cares/src/lib/str/ares_buf.c +1498 -0
  303. data/third_party/cares/cares/src/lib/str/ares_str.c +508 -0
  304. data/third_party/cares/cares/src/lib/str/ares_strsplit.c +90 -0
  305. data/third_party/cares/cares/src/lib/str/ares_strsplit.h +51 -0
  306. data/third_party/cares/cares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
  307. data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +628 -0
  308. data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +139 -0
  309. data/third_party/cares/cares/src/lib/util/ares_math.c +158 -0
  310. data/third_party/cares/cares/src/lib/util/ares_math.h +45 -0
  311. data/third_party/cares/cares/src/lib/util/ares_rand.c +389 -0
  312. data/third_party/cares/cares/src/lib/util/ares_rand.h +36 -0
  313. data/third_party/cares/cares/src/lib/util/ares_threads.c +614 -0
  314. data/third_party/cares/cares/src/lib/util/ares_threads.h +60 -0
  315. data/third_party/cares/cares/src/lib/util/ares_time.h +48 -0
  316. data/third_party/cares/cares/src/lib/util/ares_timeval.c +95 -0
  317. data/third_party/cares/cares/src/lib/util/ares_uri.c +1626 -0
  318. data/third_party/cares/cares/src/lib/util/ares_uri.h +252 -0
  319. data/third_party/cares/cares/src/lib/windows_port.c +16 -9
  320. metadata +121 -49
  321. data/src/core/util/ring_buffer.h +0 -122
  322. data/third_party/cares/cares/include/ares_rules.h +0 -125
  323. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +0 -266
  324. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +0 -240
  325. data/third_party/cares/cares/src/lib/ares__close_sockets.c +0 -61
  326. data/third_party/cares/cares/src/lib/ares__get_hostent.c +0 -260
  327. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +0 -229
  328. data/third_party/cares/cares/src/lib/ares__read_line.c +0 -73
  329. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +0 -258
  330. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +0 -507
  331. data/third_party/cares/cares/src/lib/ares__timeval.c +0 -111
  332. data/third_party/cares/cares/src/lib/ares_create_query.c +0 -197
  333. data/third_party/cares/cares/src/lib/ares_expand_name.c +0 -311
  334. data/third_party/cares/cares/src/lib/ares_expand_string.c +0 -67
  335. data/third_party/cares/cares/src/lib/ares_fds.c +0 -59
  336. data/third_party/cares/cares/src/lib/ares_getsock.c +0 -66
  337. data/third_party/cares/cares/src/lib/ares_iphlpapi.h +0 -221
  338. data/third_party/cares/cares/src/lib/ares_llist.c +0 -63
  339. data/third_party/cares/cares/src/lib/ares_llist.h +0 -39
  340. data/third_party/cares/cares/src/lib/ares_mkquery.c +0 -24
  341. data/third_party/cares/cares/src/lib/ares_nowarn.c +0 -260
  342. data/third_party/cares/cares/src/lib/ares_nowarn.h +0 -61
  343. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +0 -90
  344. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +0 -92
  345. data/third_party/cares/cares/src/lib/ares_parse_caa_reply.c +0 -199
  346. data/third_party/cares/cares/src/lib/ares_parse_mx_reply.c +0 -164
  347. data/third_party/cares/cares/src/lib/ares_parse_naptr_reply.c +0 -183
  348. data/third_party/cares/cares/src/lib/ares_parse_ns_reply.c +0 -177
  349. data/third_party/cares/cares/src/lib/ares_parse_ptr_reply.c +0 -228
  350. data/third_party/cares/cares/src/lib/ares_parse_soa_reply.c +0 -179
  351. data/third_party/cares/cares/src/lib/ares_parse_srv_reply.c +0 -168
  352. data/third_party/cares/cares/src/lib/ares_parse_txt_reply.c +0 -214
  353. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +0 -184
  354. data/third_party/cares/cares/src/lib/ares_platform.c +0 -11042
  355. data/third_party/cares/cares/src/lib/ares_platform.h +0 -43
  356. data/third_party/cares/cares/src/lib/ares_rand.c +0 -279
  357. data/third_party/cares/cares/src/lib/ares_strcasecmp.c +0 -66
  358. data/third_party/cares/cares/src/lib/ares_strcasecmp.h +0 -30
  359. data/third_party/cares/cares/src/lib/ares_strdup.c +0 -42
  360. data/third_party/cares/cares/src/lib/ares_strdup.h +0 -24
  361. data/third_party/cares/cares/src/lib/ares_strsplit.c +0 -94
  362. data/third_party/cares/cares/src/lib/ares_strsplit.h +0 -42
  363. data/third_party/cares/cares/src/lib/ares_writev.c +0 -79
  364. data/third_party/cares/cares/src/lib/ares_writev.h +0 -36
  365. data/third_party/cares/cares/src/lib/bitncmp.c +0 -59
  366. data/third_party/cares/cares/src/lib/bitncmp.h +0 -26
  367. data/third_party/cares/cares/src/lib/setup_once.h +0 -554
  368. data/third_party/cares/cares/src/tools/ares_getopt.h +0 -53
@@ -0,0 +1,128 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 2024 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__HTABLE_VPVP_H
27
+ #define __ARES__HTABLE_VPVP_H
28
+
29
+ /*! \addtogroup ares_htable_vpvp HashTable with void pointer Key and void
30
+ * pointer Value
31
+ *
32
+ * This data structure wraps the base ares_htable data structure in order to
33
+ * split the key and value data types as size_t and void pointer, respectively.
34
+ *
35
+ * Average time complexity:
36
+ * - Insert: O(1)
37
+ * - Search: O(1)
38
+ * - Delete: O(1)
39
+ *
40
+ * @{
41
+ */
42
+
43
+ struct ares_htable_vpvp;
44
+
45
+ /*! Opaque data type for size_t key, void pointer hash table implementation */
46
+ typedef struct ares_htable_vpvp ares_htable_vpvp_t;
47
+
48
+ /*! Callback to free key stored in hashtable
49
+ *
50
+ * \param[in] key user-supplied key
51
+ */
52
+ typedef void (*ares_htable_vpvp_key_free_t)(void *key);
53
+
54
+ /*! Callback to free value stored in hashtable
55
+ *
56
+ * \param[in] val user-supplied value
57
+ */
58
+ typedef void (*ares_htable_vpvp_val_free_t)(void *val);
59
+
60
+ /*! Destroy hashtable
61
+ *
62
+ * \param[in] htable Initialized hashtable
63
+ */
64
+ CARES_EXTERN void ares_htable_vpvp_destroy(ares_htable_vpvp_t *htable);
65
+
66
+ /*! Create size_t key, void pointer value hash table
67
+ *
68
+ * \param[in] key_free Optional. Call back to free user-supplied key. If
69
+ * NULL it is expected the caller will clean up any user
70
+ * supplied keys.
71
+ * \param[in] val_free Optional. Call back to free user-supplied value. If
72
+ * NULL it is expected the caller will clean up any user
73
+ * supplied values.
74
+ */
75
+ CARES_EXTERN ares_htable_vpvp_t *
76
+ ares_htable_vpvp_create(ares_htable_vpvp_key_free_t key_free,
77
+ ares_htable_vpvp_val_free_t val_free);
78
+
79
+ /*! Insert key/value into hash table
80
+ *
81
+ * \param[in] htable Initialized hash table
82
+ * \param[in] key key to associate with value
83
+ * \param[in] val value to store (takes ownership). May be NULL.
84
+ * \return ARES_TRUE on success, ARES_FALSE on failure or out of memory
85
+ */
86
+ CARES_EXTERN ares_bool_t ares_htable_vpvp_insert(ares_htable_vpvp_t *htable,
87
+ void *key, void *val);
88
+
89
+ /*! Retrieve value from hashtable based on key
90
+ *
91
+ * \param[in] htable Initialized hash table
92
+ * \param[in] key key to use to search
93
+ * \param[out] val Optional. Pointer to store value.
94
+ * \return ARES_TRUE on success, ARES_FALSE on failure
95
+ */
96
+ CARES_EXTERN ares_bool_t ares_htable_vpvp_get(const ares_htable_vpvp_t *htable,
97
+ const void *key, void **val);
98
+
99
+ /*! Retrieve value from hashtable directly as return value. Caveat to this
100
+ * function over ares_htable_vpvp_get() is that if a NULL value is stored
101
+ * you cannot determine if the key is not found or the value is NULL.
102
+ *
103
+ * \param[in] htable Initialized hash table
104
+ * \param[in] key key to use to search
105
+ * \return value associated with key in hashtable or NULL
106
+ */
107
+ CARES_EXTERN void *ares_htable_vpvp_get_direct(const ares_htable_vpvp_t *htable,
108
+ const void *key);
109
+
110
+ /*! Remove a value from the hashtable by key
111
+ *
112
+ * \param[in] htable Initialized hash table
113
+ * \param[in] key key to use to search
114
+ * \return ARES_TRUE if found, ARES_FALSE if not
115
+ */
116
+ CARES_EXTERN ares_bool_t ares_htable_vpvp_remove(ares_htable_vpvp_t *htable,
117
+ const void *key);
118
+
119
+ /*! Retrieve the number of keys stored in the hash table
120
+ *
121
+ * \param[in] htable Initialized hash table
122
+ * \return count
123
+ */
124
+ CARES_EXTERN size_t ares_htable_vpvp_num_keys(const ares_htable_vpvp_t *htable);
125
+
126
+ /*! @} */
127
+
128
+ #endif /* __ARES__HTABLE_VPVP_H */
@@ -0,0 +1,239 @@
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__LLIST_H
27
+ #define __ARES__LLIST_H
28
+
29
+ /*! \addtogroup ares_llist LinkedList Data Structure
30
+ *
31
+ * This is a doubly-linked list data structure.
32
+ *
33
+ * Average time complexity:
34
+ * - Insert: O(1) -- head or tail
35
+ * - Search: O(n)
36
+ * - Delete: O(1) -- delete assumes you hold a node pointer
37
+ *
38
+ * @{
39
+ */
40
+
41
+ struct ares_llist;
42
+
43
+ /*! Opaque data structure for linked list */
44
+ typedef struct ares_llist ares_llist_t;
45
+
46
+ struct ares_llist_node;
47
+
48
+ /*! Opaque data structure for a node in a linked list */
49
+ typedef struct ares_llist_node ares_llist_node_t;
50
+
51
+ /*! Callback to free user-defined node data
52
+ *
53
+ * \param[in] data user supplied data
54
+ */
55
+ typedef void (*ares_llist_destructor_t)(void *data);
56
+
57
+ /*! Create a linked list object
58
+ *
59
+ * \param[in] destruct Optional. Destructor to call on all removed nodes
60
+ * \return linked list object or NULL on out of memory
61
+ */
62
+ CARES_EXTERN ares_llist_t *ares_llist_create(ares_llist_destructor_t destruct);
63
+
64
+ /*! Replace destructor for linked list nodes. Typically this is used
65
+ * when wanting to disable the destructor by using NULL.
66
+ *
67
+ * \param[in] list Initialized linked list object
68
+ * \param[in] destruct replacement destructor, NULL is allowed
69
+ */
70
+ CARES_EXTERN void
71
+ ares_llist_replace_destructor(ares_llist_t *list,
72
+ ares_llist_destructor_t destruct);
73
+
74
+ /*! Insert value as the first node in the linked list
75
+ *
76
+ * \param[in] list Initialized linked list object
77
+ * \param[in] val user-supplied value.
78
+ * \return node object referencing place in list, or null if out of memory or
79
+ * misuse
80
+ */
81
+ CARES_EXTERN ares_llist_node_t *ares_llist_insert_first(ares_llist_t *list,
82
+ void *val);
83
+
84
+ /*! Insert value as the last node in the linked list
85
+ *
86
+ * \param[in] list Initialized linked list object
87
+ * \param[in] val user-supplied value.
88
+ * \return node object referencing place in list, or null if out of memory or
89
+ * misuse
90
+ */
91
+ CARES_EXTERN ares_llist_node_t *ares_llist_insert_last(ares_llist_t *list,
92
+ void *val);
93
+
94
+ /*! Insert value before specified node in the linked list
95
+ *
96
+ * \param[in] node node referenced to insert before
97
+ * \param[in] val user-supplied value.
98
+ * \return node object referencing place in list, or null if out of memory or
99
+ * misuse
100
+ */
101
+ CARES_EXTERN ares_llist_node_t *
102
+ ares_llist_insert_before(ares_llist_node_t *node, void *val);
103
+
104
+ /*! Insert value after specified node in the linked list
105
+ *
106
+ * \param[in] node node referenced to insert after
107
+ * \param[in] val user-supplied value.
108
+ * \return node object referencing place in list, or null if out of memory or
109
+ * misuse
110
+ */
111
+ CARES_EXTERN ares_llist_node_t *ares_llist_insert_after(ares_llist_node_t *node,
112
+ void *val);
113
+
114
+ /*! Obtain first node in list
115
+ *
116
+ * \param[in] list Initialized list object
117
+ * \return first node in list or NULL if none
118
+ */
119
+ CARES_EXTERN ares_llist_node_t *ares_llist_node_first(ares_llist_t *list);
120
+
121
+ /*! Obtain last node in list
122
+ *
123
+ * \param[in] list Initialized list object
124
+ * \return last node in list or NULL if none
125
+ */
126
+ CARES_EXTERN ares_llist_node_t *ares_llist_node_last(ares_llist_t *list);
127
+
128
+ /*! Obtain a node based on its index. This is an O(n) operation.
129
+ *
130
+ * \param[in] list Initialized list object
131
+ * \param[in] idx Index of node to retrieve
132
+ * \return node at index or NULL if invalid index
133
+ */
134
+ CARES_EXTERN ares_llist_node_t *ares_llist_node_idx(ares_llist_t *list,
135
+ size_t idx);
136
+
137
+ /*! Obtain next node in respect to specified node
138
+ *
139
+ * \param[in] node Node referenced
140
+ * \return node or NULL if none
141
+ */
142
+ CARES_EXTERN ares_llist_node_t *ares_llist_node_next(ares_llist_node_t *node);
143
+
144
+ /*! Obtain previous node in respect to specified node
145
+ *
146
+ * \param[in] node Node referenced
147
+ * \return node or NULL if none
148
+ */
149
+ CARES_EXTERN ares_llist_node_t *ares_llist_node_prev(ares_llist_node_t *node);
150
+
151
+
152
+ /*! Obtain value from node
153
+ *
154
+ * \param[in] node Node referenced
155
+ * \return user provided value from node
156
+ */
157
+ CARES_EXTERN void *ares_llist_node_val(ares_llist_node_t *node);
158
+
159
+ /*! Obtain the number of entries in the list
160
+ *
161
+ * \param[in] list Initialized list object
162
+ * \return count
163
+ */
164
+ CARES_EXTERN size_t ares_llist_len(const ares_llist_t *list);
165
+
166
+ /*! Clear all entries in the list, but don't destroy the list object.
167
+ *
168
+ * \param[in] list Initialized list object
169
+ */
170
+ CARES_EXTERN void ares_llist_clear(ares_llist_t *list);
171
+
172
+ /*! Obtain list object from referenced node
173
+ *
174
+ * \param[in] node Node referenced
175
+ * \return list object node belongs to
176
+ */
177
+ CARES_EXTERN ares_llist_t *ares_llist_node_parent(ares_llist_node_t *node);
178
+
179
+ /*! Obtain the first user-supplied value in the list
180
+ *
181
+ * \param[in] list Initialized list object
182
+ * \return first user supplied value or NULL if none
183
+ */
184
+ CARES_EXTERN void *ares_llist_first_val(ares_llist_t *list);
185
+
186
+ /*! Obtain the last user-supplied value in the list
187
+ *
188
+ * \param[in] list Initialized list object
189
+ * \return last user supplied value or NULL if none
190
+ */
191
+ CARES_EXTERN void *ares_llist_last_val(ares_llist_t *list);
192
+
193
+ /*! Take ownership of user-supplied value in list without calling destructor.
194
+ * Will unchain entry from list.
195
+ *
196
+ * \param[in] node Node referenced
197
+ * \return user supplied value
198
+ */
199
+ CARES_EXTERN void *ares_llist_node_claim(ares_llist_node_t *node);
200
+
201
+ /*! Replace user-supplied value for node
202
+ *
203
+ * \param[in] node Node referenced
204
+ * \param[in] val new user-supplied value
205
+ */
206
+ CARES_EXTERN void ares_llist_node_replace(ares_llist_node_t *node, void *val);
207
+
208
+ /*! Destroy the node, removing it from the list and calling destructor.
209
+ *
210
+ * \param[in] node Node referenced
211
+ */
212
+ CARES_EXTERN void ares_llist_node_destroy(ares_llist_node_t *node);
213
+
214
+ /*! Destroy the list object and all nodes in the list.
215
+ *
216
+ * \param[in] list Initialized list object
217
+ */
218
+ CARES_EXTERN void ares_llist_destroy(ares_llist_t *list);
219
+
220
+ /*! Detach node from the current list and re-attach it to the new list as the
221
+ * last entry.
222
+ *
223
+ * \param[in] node node to move
224
+ * \param[in] new_parent new list
225
+ */
226
+ CARES_EXTERN void ares_llist_node_mvparent_last(ares_llist_node_t *node,
227
+ ares_llist_t *new_parent);
228
+
229
+ /*! Detach node from the current list and re-attach it to the new list as the
230
+ * first entry.
231
+ *
232
+ * \param[in] node node to move
233
+ * \param[in] new_parent new list
234
+ */
235
+ CARES_EXTERN void ares_llist_node_mvparent_first(ares_llist_node_t *node,
236
+ ares_llist_t *new_parent);
237
+ /*! @} */
238
+
239
+ #endif /* __ARES__LLIST_H */
@@ -0,0 +1,38 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) The c-ares project and its contributors
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
+
27
+ #ifndef __ARES_MEM_H
28
+ #define __ARES_MEM_H
29
+
30
+ /* Memory management functions */
31
+ CARES_EXTERN void *ares_malloc(size_t size);
32
+ CARES_EXTERN void *ares_realloc(void *ptr, size_t size);
33
+ CARES_EXTERN void ares_free(void *ptr);
34
+ CARES_EXTERN void *ares_malloc_zero(size_t size);
35
+ CARES_EXTERN void *ares_realloc_zero(void *ptr, size_t orig_size,
36
+ size_t new_size);
37
+
38
+ #endif
@@ -0,0 +1,244 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 1998 Massachusetts Institute of Technology
4
+ * Copyright (c) The c-ares project and its contributors
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
+ #ifndef __ARES_STR_H
28
+ #define __ARES_STR_H
29
+
30
+ CARES_EXTERN char *ares_strdup(const char *s1);
31
+
32
+ /*! Scan up to maxlen bytes for the first NULL character and return
33
+ * its index, or maxlen if not found. The function only returns
34
+ * maxlen if the first maxlen bytes were not NULL characters; it
35
+ * makes no guarantee for what \c str[maxlen] (if defined) is, and
36
+ * does not access it. It is behaving like the POSIX \c strnlen()
37
+ * function, except that it returns 0 if the \p str pointer is \c
38
+ * NULL.
39
+ *
40
+ * \param[in] str The string to scan for the NULL character
41
+ * \param[in] maxlen The maximum number of bytes to scan
42
+ * \return Index of first NULL byte. Between 0 and maxlen (inclusive).
43
+ */
44
+ CARES_EXTERN size_t ares_strnlen(const char *str, size_t maxlen);
45
+
46
+ CARES_EXTERN size_t ares_strlen(const char *str);
47
+
48
+ /*! Copy string from source to destination with destination buffer size
49
+ * provided. The destination is guaranteed to be null terminated, if the
50
+ * provided buffer isn't large enough, only those bytes from the source that
51
+ * will fit will be copied.
52
+ *
53
+ * \param[out] dest Destination buffer
54
+ * \param[in] src Source to copy
55
+ * \param[in] dest_size Size of destination buffer
56
+ * \return String length. Will be at most dest_size-1
57
+ */
58
+ CARES_EXTERN size_t ares_strcpy(char *dest, const char *src, size_t dest_size);
59
+
60
+ CARES_EXTERN ares_bool_t ares_str_isnum(const char *str);
61
+ CARES_EXTERN ares_bool_t ares_str_isalnum(const char *str);
62
+
63
+ CARES_EXTERN void ares_str_ltrim(char *str);
64
+ CARES_EXTERN void ares_str_rtrim(char *str);
65
+ CARES_EXTERN void ares_str_trim(char *str);
66
+ CARES_EXTERN void ares_str_lower(char *str);
67
+
68
+ CARES_EXTERN unsigned char ares_tolower(unsigned char c);
69
+ CARES_EXTERN unsigned char *ares_memmem(const unsigned char *big,
70
+ size_t big_len,
71
+ const unsigned char *little,
72
+ size_t little_len);
73
+ CARES_EXTERN ares_bool_t ares_memeq(const unsigned char *ptr,
74
+ const unsigned char *val, size_t len);
75
+ CARES_EXTERN ares_bool_t ares_memeq_ci(const unsigned char *ptr,
76
+ const unsigned char *val, size_t len);
77
+ CARES_EXTERN ares_bool_t ares_is_hostname(const char *str);
78
+
79
+ /*! Validate the string provided is printable. The length specified must be
80
+ * at least the size of the buffer provided. If a NULL-terminator is hit
81
+ * before the length provided is hit, this will not be considered a valid
82
+ * printable string. This does not validate that the string is actually
83
+ * NULL terminated.
84
+ *
85
+ * \param[in] str Buffer containing string to evaluate.
86
+ * \param[in] len Number of characters to evaluate within provided buffer.
87
+ * If 0, will return TRUE since it did not hit an exception.
88
+ * \return ARES_TRUE if the entire string is printable, ARES_FALSE if not.
89
+ */
90
+ CARES_EXTERN ares_bool_t ares_str_isprint(const char *str, size_t len);
91
+
92
+ /* We only care about ASCII rules */
93
+ #define ares_isascii(x) (((unsigned char)x) <= 127)
94
+
95
+ #define ares_isdigit(x) (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9')
96
+
97
+ #define ares_isxdigit(x) \
98
+ (ares_isdigit(x) || \
99
+ (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'f') || \
100
+ (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'F'))
101
+
102
+ #define ares_isupper(x) (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'Z')
103
+
104
+ #define ares_islower(x) (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'z')
105
+
106
+ #define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
107
+
108
+ #define ares_isspace(x) \
109
+ (((unsigned char)(x)) == '\r' || ((unsigned char)(x)) == '\t' || \
110
+ ((unsigned char)(x)) == ' ' || ((unsigned char)(x)) == '\v' || \
111
+ ((unsigned char)(x)) == '\f' || ((unsigned char)(x)) == '\n')
112
+
113
+ #define ares_isprint(x) \
114
+ (((unsigned char)(x)) >= 0x20 && ((unsigned char)(x)) <= 0x7E)
115
+
116
+ /* Character set allowed by hostnames. This is to include the normal
117
+ * domain name character set plus:
118
+ * - underscores which are used in SRV records.
119
+ * - Forward slashes such as are used for classless in-addr.arpa
120
+ * delegation (CNAMEs)
121
+ * - Asterisks may be used for wildcard domains in CNAMEs as seen in the
122
+ * real world.
123
+ * While RFC 2181 section 11 does state not to do validation,
124
+ * that applies to servers, not clients. Vulnerabilities have been
125
+ * reported when this validation is not performed. Security is more
126
+ * important than edge-case compatibility (which is probably invalid
127
+ * anyhow).
128
+ * [A-Za-z0-9-*._/]
129
+ */
130
+ #define ares_is_hostnamech(x) \
131
+ (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
132
+ ((unsigned char)(x)) == '.' || ((unsigned char)(x)) == '_' || \
133
+ ((unsigned char)(x)) == '/' || ((unsigned char)(x)) == '*')
134
+
135
+
136
+ /*! Compare two strings (for sorting)
137
+ *
138
+ * Treats NULL and "" strings as equivalent
139
+ *
140
+ * \param[in] a First String
141
+ * \param[in] b Second String
142
+ * \return < 0 if First String less than Second String,
143
+ * 0 if First String equal to Second String,
144
+ * > 0 if First String greater than Second String
145
+ */
146
+ CARES_EXTERN int ares_strcmp(const char *a, const char *b);
147
+
148
+ /*! Compare two strings up to specified length (for sorting)
149
+ *
150
+ * Treats NULL and "" strings as equivalent
151
+ *
152
+ * \param[in] a First String
153
+ * \param[in] b Second String
154
+ * \param[in] n Length
155
+ * \return < 0 if First String less than Second String,
156
+ * 0 if First String equal to Second String,
157
+ * > 0 if First String greater than Second String
158
+ */
159
+ CARES_EXTERN int ares_strncmp(const char *a, const char *b, size_t n);
160
+
161
+
162
+ /*! Compare two strings in a case-insensitive manner (for sorting)
163
+ *
164
+ * Treats NULL and "" strings as equivalent
165
+ *
166
+ * \param[in] a First String
167
+ * \param[in] b Second String
168
+ * \return < 0 if First String less than Second String,
169
+ * 0 if First String equal to Second String,
170
+ * > 0 if First String greater than Second String
171
+ */
172
+ CARES_EXTERN int ares_strcasecmp(const char *a, const char *b);
173
+
174
+ /*! Compare two strings in a case-insensitive manner up to specified length
175
+ * (for sorting)
176
+ *
177
+ * Treats NULL and "" strings as equivalent
178
+ *
179
+ * \param[in] a First String
180
+ * \param[in] b Second String
181
+ * \param[in] n Length
182
+ * \return < 0 if First String less than Second String,
183
+ * 0 if First String equal to Second String,
184
+ * > 0 if First String greater than Second String
185
+ */
186
+ CARES_EXTERN int ares_strncasecmp(const char *a, const char *b, size_t n);
187
+
188
+ /*! Compare two strings for equality
189
+ *
190
+ * Treats NULL and "" strings as equivalent
191
+ *
192
+ * \param[in] a First String
193
+ * \param[in] b Second String
194
+ * \return ARES_TRUE on match, or ARES_FALSE if no match
195
+ */
196
+ CARES_EXTERN ares_bool_t ares_streq(const char *a, const char *b);
197
+
198
+ /*! Compare two strings for equality up to specified length
199
+ *
200
+ * Treats NULL and "" strings as equivalent
201
+ *
202
+ * \param[in] a First String
203
+ * \param[in] b Second String
204
+ * \param[in] n Length
205
+ * \return ARES_TRUE on match, or ARES_FALSE if no match
206
+ */
207
+ CARES_EXTERN ares_bool_t ares_streq_max(const char *a, const char *b, size_t n);
208
+
209
+ /*! Compare two strings for equality in a case insensitive manner
210
+ *
211
+ * Treats NULL and "" strings as equivalent
212
+ *
213
+ * \param[in] a First String
214
+ * \param[in] b Second String
215
+ * \return ARES_TRUE on match, or ARES_FALSE if no match
216
+ */
217
+ CARES_EXTERN ares_bool_t ares_strcaseeq(const char *a, const char *b);
218
+
219
+ /*! Compare two strings for equality up to specified length in a case
220
+ * insensitive manner
221
+ *
222
+ * Treats NULL and "" strings as equivalent
223
+ *
224
+ * \param[in] a First String
225
+ * \param[in] b Second String
226
+ * \param[in] n Length
227
+ * \return ARES_TRUE on match, or ARES_FALSE if no match
228
+ */
229
+ CARES_EXTERN ares_bool_t ares_strcaseeq_max(const char *a, const char *b,
230
+ size_t n);
231
+
232
+ /*! Free a C array, each element in the array will be freed by the provided
233
+ * free function. Both NULL-terminated arrays and known length arrays are
234
+ * supported.
235
+ *
236
+ * \param[in] arr Array to be freed.
237
+ * \param[in] nmembers Number of members in the array, or SIZE_MAX for
238
+ * NULL-terminated arrays
239
+ * \param[in] freefunc Function to call on each array member (e.g. ares_free)
240
+ */
241
+ CARES_EXTERN void ares_free_array(void *arr, size_t nmembers,
242
+ void (*freefunc)(void *));
243
+
244
+ #endif /* __ARES_STR_H */