grpc 1.55.0 → 1.56.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (395) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +102 -68
  3. data/include/grpc/event_engine/event_engine.h +4 -3
  4. data/include/grpc/grpc_audit_logging.h +96 -0
  5. data/include/grpc/grpc_security.h +19 -0
  6. data/include/grpc/module.modulemap +2 -0
  7. data/include/grpc/support/json.h +218 -0
  8. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +5 -0
  9. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -0
  10. data/src/core/ext/filters/client_channel/channel_connectivity.cc +4 -4
  11. data/src/core/ext/filters/client_channel/client_channel.cc +86 -104
  12. data/src/core/ext/filters/client_channel/client_channel.h +6 -0
  13. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +19 -18
  14. data/src/core/ext/filters/client_channel/client_channel_internal.h +16 -21
  15. data/src/core/ext/filters/client_channel/config_selector.h +9 -24
  16. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +3 -0
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +5 -4
  18. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +455 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +54 -0
  20. data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +186 -0
  21. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +2 -7
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +53 -21
  23. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +23 -2
  24. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -6
  25. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +1 -9
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +16 -7
  27. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +18 -1
  28. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +12 -9
  29. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -4
  30. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +36 -13
  31. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +76 -6
  32. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +42 -40
  33. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +4 -10
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +52 -47
  35. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +1 -9
  36. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +14 -16
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +40 -43
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +7 -12
  39. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -19
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +35 -33
  41. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +29 -4
  42. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/service_config_helper.cc +1 -1
  43. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +28 -27
  44. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +163 -46
  45. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +16 -1
  46. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -0
  47. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +10 -40
  48. data/src/core/ext/filters/client_channel/subchannel.cc +10 -196
  49. data/src/core/ext/filters/client_channel/subchannel.h +3 -43
  50. data/src/core/ext/filters/http/message_compress/compression_filter.cc +5 -5
  51. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +100 -6
  52. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +6 -8
  53. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -3
  54. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +16 -1
  55. data/src/core/ext/transport/chttp2/transport/flow_control.cc +46 -95
  56. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +176 -0
  57. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +325 -0
  58. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +567 -543
  59. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +150 -9
  60. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +46 -32
  61. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +18 -5
  62. data/src/core/ext/transport/chttp2/transport/internal.h +1 -15
  63. data/src/core/ext/transport/chttp2/transport/parsing.cc +12 -12
  64. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +11 -2
  65. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -0
  66. data/src/core/ext/xds/certificate_provider_store.cc +4 -9
  67. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  68. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +30 -42
  69. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +14 -9
  70. data/src/core/ext/xds/xds_api.cc +9 -6
  71. data/src/core/ext/xds/xds_api.h +3 -2
  72. data/src/core/ext/xds/xds_audit_logger_registry.cc +122 -0
  73. data/src/core/ext/xds/xds_audit_logger_registry.h +68 -0
  74. data/src/core/ext/xds/xds_bootstrap_grpc.cc +21 -9
  75. data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -0
  76. data/src/core/ext/xds/xds_client.cc +5 -4
  77. data/src/core/ext/xds/xds_client_stats.h +1 -1
  78. data/src/core/ext/xds/xds_cluster.cc +20 -19
  79. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +11 -8
  80. data/src/core/ext/xds/xds_common_types.cc +3 -1
  81. data/src/core/ext/xds/xds_http_fault_filter.cc +16 -13
  82. data/src/core/ext/xds/xds_http_fault_filter.h +2 -1
  83. data/src/core/ext/xds/xds_http_filters.h +4 -2
  84. data/src/core/ext/xds/xds_http_rbac_filter.cc +154 -67
  85. data/src/core/ext/xds/xds_http_rbac_filter.h +2 -1
  86. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +15 -11
  87. data/src/core/ext/xds/xds_http_stateful_session_filter.h +2 -1
  88. data/src/core/ext/xds/xds_lb_policy_registry.cc +22 -16
  89. data/src/core/ext/xds/xds_listener.cc +1 -0
  90. data/src/core/ext/xds/xds_route_config.cc +40 -3
  91. data/src/core/ext/xds/xds_routing.cc +2 -2
  92. data/src/core/ext/xds/xds_transport_grpc.cc +3 -1
  93. data/src/core/lib/avl/avl.h +5 -0
  94. data/src/core/lib/backoff/random_early_detection.h +5 -0
  95. data/src/core/lib/channel/channel_args.cc +80 -22
  96. data/src/core/lib/channel/channel_args.h +34 -1
  97. data/src/core/lib/channel/channel_trace.cc +16 -12
  98. data/src/core/lib/channel/channelz.cc +159 -132
  99. data/src/core/lib/channel/channelz.h +42 -35
  100. data/src/core/lib/channel/channelz_registry.cc +23 -20
  101. data/src/core/lib/channel/connected_channel.cc +17 -6
  102. data/src/core/lib/channel/promise_based_filter.cc +0 -4
  103. data/src/core/lib/channel/promise_based_filter.h +2 -0
  104. data/src/core/lib/compression/compression_internal.cc +2 -5
  105. data/src/core/lib/config/config_vars.cc +20 -18
  106. data/src/core/lib/config/config_vars.h +4 -4
  107. data/src/core/lib/config/load_config.cc +13 -0
  108. data/src/core/lib/config/load_config.h +6 -0
  109. data/src/core/lib/debug/event_log.h +1 -1
  110. data/src/core/lib/debug/stats_data.h +1 -1
  111. data/src/core/lib/debug/trace.cc +24 -55
  112. data/src/core/lib/debug/trace.h +3 -1
  113. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +211 -0
  114. data/src/core/lib/event_engine/cf_engine/cf_engine.h +86 -0
  115. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +354 -0
  116. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +146 -0
  117. data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +79 -0
  118. data/src/core/lib/event_engine/default_event_engine.cc +13 -1
  119. data/src/core/lib/event_engine/default_event_engine_factory.cc +14 -2
  120. data/src/core/lib/event_engine/poller.h +2 -2
  121. data/src/core/lib/event_engine/posix.h +4 -0
  122. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
  123. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +7 -18
  124. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -0
  125. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +33 -19
  126. data/src/core/lib/event_engine/posix_engine/posix_engine.h +2 -1
  127. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +33 -4
  128. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +10 -8
  129. data/src/core/lib/event_engine/posix_engine/timer_manager.h +1 -1
  130. data/src/core/lib/event_engine/shim.cc +7 -1
  131. data/src/core/lib/event_engine/{thread_pool.cc → thread_pool/original_thread_pool.cc} +28 -25
  132. data/src/core/lib/event_engine/{thread_pool.h → thread_pool/original_thread_pool.h} +11 -15
  133. data/src/core/lib/event_engine/thread_pool/thread_pool.h +50 -0
  134. data/src/core/lib/event_engine/{executor/executor.h → thread_pool/thread_pool_factory.cc} +17 -15
  135. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +489 -0
  136. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +249 -0
  137. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +166 -0
  138. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +108 -0
  139. data/src/core/lib/event_engine/windows/iocp.cc +4 -3
  140. data/src/core/lib/event_engine/windows/iocp.h +3 -3
  141. data/src/core/lib/event_engine/windows/win_socket.cc +6 -6
  142. data/src/core/lib/event_engine/windows/win_socket.h +4 -4
  143. data/src/core/lib/event_engine/windows/windows_endpoint.cc +11 -10
  144. data/src/core/lib/event_engine/windows/windows_endpoint.h +3 -2
  145. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -17
  146. data/src/core/lib/event_engine/windows/windows_engine.h +6 -6
  147. data/src/core/lib/event_engine/windows/windows_listener.cc +3 -3
  148. data/src/core/lib/event_engine/windows/windows_listener.h +3 -2
  149. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +63 -0
  150. data/src/core/lib/event_engine/work_queue/basic_work_queue.h +71 -0
  151. data/src/core/lib/event_engine/work_queue/work_queue.h +62 -0
  152. data/src/core/lib/experiments/config.cc +38 -7
  153. data/src/core/lib/experiments/config.h +16 -0
  154. data/src/core/lib/experiments/experiments.cc +67 -20
  155. data/src/core/lib/experiments/experiments.h +27 -21
  156. data/src/core/lib/gpr/log_internal.h +55 -0
  157. data/src/core/lib/gprpp/crash.cc +10 -0
  158. data/src/core/lib/gprpp/crash.h +3 -0
  159. data/src/core/lib/gprpp/per_cpu.cc +33 -0
  160. data/src/core/lib/gprpp/per_cpu.h +29 -6
  161. data/src/core/lib/gprpp/time.cc +1 -0
  162. data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
  163. data/src/core/lib/iomgr/endpoint_cfstream.cc +10 -8
  164. data/src/core/lib/iomgr/ev_apple.cc +12 -12
  165. data/src/core/lib/iomgr/ev_epoll1_linux.cc +10 -3
  166. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +15 -1
  167. data/src/core/lib/iomgr/iocp_windows.cc +24 -3
  168. data/src/core/lib/iomgr/iocp_windows.h +11 -0
  169. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +1 -1
  170. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -2
  171. data/src/core/lib/iomgr/socket_windows.cc +61 -7
  172. data/src/core/lib/iomgr/socket_windows.h +9 -2
  173. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -3
  174. data/src/core/lib/iomgr/tcp_server_posix.cc +182 -119
  175. data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -1
  176. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +21 -0
  177. data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
  178. data/src/core/lib/json/json.h +2 -166
  179. data/src/core/lib/json/json_object_loader.cc +8 -9
  180. data/src/core/lib/json/json_object_loader.h +25 -18
  181. data/src/core/lib/json/json_reader.cc +13 -6
  182. data/src/core/lib/json/json_util.cc +6 -11
  183. data/src/core/lib/json/json_writer.cc +7 -8
  184. data/src/core/lib/load_balancing/lb_policy.h +13 -0
  185. data/src/core/lib/load_balancing/lb_policy_registry.cc +2 -1
  186. data/src/core/lib/matchers/matchers.cc +3 -4
  187. data/src/core/lib/matchers/matchers.h +2 -1
  188. data/src/core/lib/promise/activity.cc +5 -0
  189. data/src/core/lib/promise/activity.h +10 -0
  190. data/src/core/lib/promise/detail/promise_factory.h +1 -1
  191. data/src/core/lib/promise/party.cc +31 -13
  192. data/src/core/lib/promise/party.h +11 -2
  193. data/src/core/lib/promise/pipe.h +9 -2
  194. data/src/core/lib/promise/prioritized_race.h +95 -0
  195. data/src/core/lib/promise/sleep.cc +2 -1
  196. data/src/core/lib/resolver/server_address.cc +0 -8
  197. data/src/core/lib/resolver/server_address.h +0 -6
  198. data/src/core/lib/resource_quota/memory_quota.cc +7 -7
  199. data/src/core/lib/resource_quota/memory_quota.h +1 -2
  200. data/src/core/lib/security/authorization/audit_logging.cc +98 -0
  201. data/src/core/lib/security/authorization/audit_logging.h +73 -0
  202. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +47 -2
  203. data/src/core/lib/security/authorization/grpc_authorization_engine.h +18 -1
  204. data/src/core/lib/security/authorization/rbac_policy.cc +36 -4
  205. data/src/core/lib/security/authorization/rbac_policy.h +19 -2
  206. data/src/core/lib/security/authorization/stdout_logger.cc +75 -0
  207. data/src/core/lib/security/authorization/stdout_logger.h +61 -0
  208. data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +8 -4
  209. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +8 -18
  210. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +14 -8
  211. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +19 -12
  212. data/src/core/lib/security/credentials/external/external_account_credentials.cc +4 -2
  213. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +1 -0
  214. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
  215. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
  216. data/src/core/lib/security/credentials/jwt/json_token.cc +15 -14
  217. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -2
  218. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +1 -0
  219. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -0
  220. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +8 -0
  221. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +5 -1
  222. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -5
  223. data/src/core/lib/security/security_connector/ssl_utils.cc +2 -1
  224. data/src/core/lib/security/security_connector/ssl_utils.h +1 -1
  225. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +1 -1
  226. data/src/core/lib/security/util/json_util.cc +1 -0
  227. data/src/core/lib/service_config/service_config_call_data.h +49 -20
  228. data/src/core/lib/service_config/service_config_impl.cc +2 -1
  229. data/src/core/lib/surface/call.cc +38 -23
  230. data/src/core/lib/surface/completion_queue.cc +6 -2
  231. data/src/core/lib/surface/validate_metadata.cc +37 -22
  232. data/src/core/lib/surface/validate_metadata.h +13 -3
  233. data/src/core/lib/surface/version.cc +2 -2
  234. data/src/core/lib/transport/batch_builder.cc +15 -12
  235. data/src/core/lib/transport/batch_builder.h +39 -35
  236. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -2
  237. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
  238. data/src/core/tsi/ssl_transport_security.cc +5 -2
  239. data/src/core/tsi/ssl_transport_security.h +13 -1
  240. data/src/ruby/ext/grpc/extconf.rb +8 -9
  241. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  242. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  243. data/src/ruby/lib/grpc/version.rb +1 -1
  244. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +9 -8
  245. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +1 -1
  246. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +3 -3
  247. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +10 -6
  248. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +7 -4
  249. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +6 -4
  250. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -1
  251. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +5 -9
  252. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +4 -2
  253. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +31 -22
  254. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +29 -26
  255. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +8 -0
  256. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +189 -13
  257. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +62 -0
  258. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +31 -0
  259. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +6 -4
  260. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +795 -795
  261. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -5
  262. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +4 -0
  263. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +18 -6
  264. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +15 -7
  265. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +1 -1
  266. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +1 -1
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +3 -0
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +24 -24
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +1 -1
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +7 -7
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +74 -74
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +1 -2
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +11 -11
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +12 -12
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +14 -15
  277. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +1 -1
  278. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +10 -10
  279. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +23 -23
  280. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +13 -13
  281. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +1 -1
  282. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +2 -2
  283. data/third_party/boringssl-with-bazel/src/crypto/{hkdf → fipsmodule/hkdf}/hkdf.c +1 -1
  284. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +2 -10
  285. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +1 -4
  286. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +115 -133
  287. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +12 -14
  288. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +57 -47
  289. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -8
  290. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +27 -28
  291. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -23
  292. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +21 -16
  293. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +5 -288
  294. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +143 -83
  295. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +95 -183
  296. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +71 -0
  297. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +8 -0
  298. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +33 -0
  299. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +162 -6
  300. data/third_party/boringssl-with-bazel/src/crypto/internal.h +18 -0
  301. data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +18 -11
  302. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +6 -13
  303. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +18 -14
  304. data/third_party/boringssl-with-bazel/src/crypto/{refcount_lock.c → refcount_no_threads.c} +3 -13
  305. data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +89 -0
  306. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +77 -0
  307. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_crypt.c +568 -0
  308. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +62 -0
  309. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +218 -44
  310. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +35 -0
  311. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +588 -39
  312. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +27 -18
  313. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +1 -1
  314. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +17 -39
  315. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +39 -48
  316. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +0 -140
  317. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +72 -23
  318. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -14
  319. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +1 -1
  320. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  321. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +1 -1
  322. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +33 -46
  323. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +1 -0
  324. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +3 -5
  325. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +14 -46
  326. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -26
  327. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +17 -10
  328. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1 -1
  329. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +5 -7
  330. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +6 -4
  331. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +32 -1
  332. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +0 -4
  333. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +1 -4
  334. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +3 -3
  335. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +28 -0
  336. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +2 -11
  337. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -3
  338. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +91 -1
  339. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +5 -0
  340. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +149 -20
  341. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +4 -0
  342. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  343. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +8 -0
  344. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +774 -615
  345. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +42 -10
  346. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +11 -6
  347. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -4
  348. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +24 -16
  349. data/third_party/boringssl-with-bazel/src/ssl/internal.h +65 -18
  350. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +37 -18
  351. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +187 -193
  352. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +13 -129
  353. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +85 -10
  354. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +17 -4
  355. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +27 -19
  356. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1 -1
  357. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +5 -21
  358. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -2
  359. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_msvc.h +1281 -0
  360. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64_msvc.h +2002 -0
  361. data/third_party/cares/cares/include/ares.h +23 -1
  362. data/third_party/cares/cares/{src/lib → include}/ares_nameser.h +9 -7
  363. data/third_party/cares/cares/include/ares_rules.h +2 -2
  364. data/third_party/cares/cares/include/ares_version.h +3 -3
  365. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +266 -0
  366. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +240 -0
  367. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +49 -80
  368. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +37 -43
  369. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +12 -4
  370. data/third_party/cares/cares/src/lib/ares_data.c +16 -0
  371. data/third_party/cares/cares/src/lib/ares_data.h +7 -0
  372. data/third_party/cares/cares/src/lib/ares_destroy.c +8 -0
  373. data/third_party/cares/cares/src/lib/ares_expand_name.c +17 -6
  374. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +1 -0
  375. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +156 -78
  376. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +130 -326
  377. data/third_party/cares/cares/src/lib/ares_init.c +97 -485
  378. data/third_party/cares/cares/src/lib/ares_library_init.c +2 -89
  379. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +23 -142
  380. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +22 -142
  381. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +184 -0
  382. data/third_party/cares/cares/src/lib/ares_private.h +30 -16
  383. data/third_party/cares/cares/src/lib/ares_process.c +55 -16
  384. data/third_party/cares/cares/src/lib/ares_query.c +1 -35
  385. data/third_party/cares/cares/src/lib/ares_rand.c +279 -0
  386. data/third_party/cares/cares/src/lib/ares_send.c +5 -7
  387. data/third_party/cares/cares/src/lib/ares_strdup.c +12 -19
  388. data/third_party/cares/cares/src/lib/ares_strsplit.c +44 -128
  389. data/third_party/cares/cares/src/lib/ares_strsplit.h +9 -10
  390. data/third_party/cares/cares/src/lib/inet_net_pton.c +78 -116
  391. data/third_party/cares/cares/src/tools/ares_getopt.h +53 -0
  392. metadata +50 -12
  393. data/src/core/ext/filters/client_channel/health/health_check_client.cc +0 -175
  394. data/src/core/ext/filters/client_channel/health/health_check_client.h +0 -43
  395. data/third_party/cares/cares/src/lib/ares_library_init.h +0 -43
@@ -18,18 +18,10 @@
18
18
  #include "ares_setup.h"
19
19
 
20
20
  #include "ares.h"
21
- #include "ares_library_init.h"
22
21
  #include "ares_private.h"
23
22
 
24
23
  /* library-private global and unique instance vars */
25
24
 
26
- #ifdef USE_WINSOCK
27
- fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL;
28
- fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL;
29
- fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL;
30
- fpGetBestRoute2_t ares_fpGetBestRoute2 = ZERO_NULL;
31
- #endif
32
-
33
25
  #if defined(ANDROID) || defined(__ANDROID__)
34
26
  #include "ares_android.h"
35
27
  #endif
@@ -59,81 +51,8 @@ void *(*ares_malloc)(size_t size) = default_malloc;
59
51
  void *(*ares_realloc)(void *ptr, size_t size) = default_realloc;
60
52
  void (*ares_free)(void *ptr) = default_free;
61
53
 
62
- #ifdef USE_WINSOCK
63
- static HMODULE hnd_iphlpapi;
64
- static HMODULE hnd_advapi32;
65
- #endif
66
-
67
-
68
- static int ares_win32_init(void)
69
- {
70
- #ifdef USE_WINSOCK
71
-
72
- hnd_iphlpapi = 0;
73
- hnd_iphlpapi = LoadLibraryW(L"iphlpapi.dll");
74
- if (!hnd_iphlpapi)
75
- return ARES_ELOADIPHLPAPI;
76
-
77
- ares_fpGetNetworkParams = (fpGetNetworkParams_t)
78
- GetProcAddress(hnd_iphlpapi, "GetNetworkParams");
79
- if (!ares_fpGetNetworkParams)
80
- {
81
- FreeLibrary(hnd_iphlpapi);
82
- return ARES_EADDRGETNETWORKPARAMS;
83
- }
84
-
85
- ares_fpGetAdaptersAddresses = (fpGetAdaptersAddresses_t)
86
- GetProcAddress(hnd_iphlpapi, "GetAdaptersAddresses");
87
- if (!ares_fpGetAdaptersAddresses)
88
- {
89
- /* This can happen on clients before WinXP, I don't
90
- think it should be an error, unless we don't want to
91
- support Windows 2000 anymore */
92
- }
93
-
94
- ares_fpGetBestRoute2 = (fpGetBestRoute2_t)
95
- GetProcAddress(hnd_iphlpapi, "GetBestRoute2");
96
- if (!ares_fpGetBestRoute2)
97
- {
98
- /* This can happen on clients before Vista, I don't
99
- think it should be an error, unless we don't want to
100
- support Windows XP anymore */
101
- }
102
-
103
- /*
104
- * When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036,
105
- * also known as RtlGenRandom, which is the case for Windows versions prior
106
- * to WinXP then c-ares uses portable rand() function. Then don't error here.
107
- */
108
-
109
- hnd_advapi32 = 0;
110
- hnd_advapi32 = LoadLibraryW(L"advapi32.dll");
111
- if (hnd_advapi32)
112
- {
113
- ares_fpSystemFunction036 = (fpSystemFunction036_t)
114
- GetProcAddress(hnd_advapi32, "SystemFunction036");
115
- }
116
-
117
- #endif
118
- return ARES_SUCCESS;
119
- }
120
-
121
-
122
- static void ares_win32_cleanup(void)
123
- {
124
- #ifdef USE_WINSOCK
125
- if (hnd_advapi32)
126
- FreeLibrary(hnd_advapi32);
127
- if (hnd_iphlpapi)
128
- FreeLibrary(hnd_iphlpapi);
129
- #endif
130
- }
131
-
132
-
133
54
  int ares_library_init(int flags)
134
55
  {
135
- int res;
136
-
137
56
  if (ares_initialized)
138
57
  {
139
58
  ares_initialized++;
@@ -141,12 +60,7 @@ int ares_library_init(int flags)
141
60
  }
142
61
  ares_initialized++;
143
62
 
144
- if (flags & ARES_LIB_INIT_WIN32)
145
- {
146
- res = ares_win32_init();
147
- if (res != ARES_SUCCESS)
148
- return res; /* LCOV_EXCL_LINE: can't test Win32 init failure */
149
- }
63
+ /* NOTE: ARES_LIB_INIT_WIN32 flag no longer used */
150
64
 
151
65
  ares_init_flags = flags;
152
66
 
@@ -176,8 +90,7 @@ void ares_library_cleanup(void)
176
90
  if (ares_initialized)
177
91
  return;
178
92
 
179
- if (ares_init_flags & ARES_LIB_INIT_WIN32)
180
- ares_win32_cleanup();
93
+ /* NOTE: ARES_LIB_INIT_WIN32 flag no longer used */
181
94
 
182
95
  #if defined(ANDROID) || defined(__ANDROID__)
183
96
  ares_library_cleanup_android();
@@ -42,168 +42,49 @@
42
42
  #include "ares_private.h"
43
43
 
44
44
  int ares_parse_a_reply(const unsigned char *abuf, int alen,
45
- struct hostent **host,
46
- struct ares_addrttl *addrttls, int *naddrttls)
45
+ struct hostent **host, struct ares_addrttl *addrttls,
46
+ int *naddrttls)
47
47
  {
48
48
  struct ares_addrinfo ai;
49
- struct ares_addrinfo_node *next;
50
- struct ares_addrinfo_cname *next_cname;
51
- char **aliases = NULL;
52
49
  char *question_hostname = NULL;
53
- struct hostent *hostent = NULL;
54
- struct in_addr *addrs = NULL;
55
- int naliases = 0, naddrs = 0, alias = 0, i;
56
- int cname_ttl = INT_MAX;
57
50
  int status;
51
+ int req_naddrttls = 0;
58
52
 
59
- memset(&ai, 0, sizeof(ai));
60
-
61
- status = ares__parse_into_addrinfo2(abuf, alen, &question_hostname, &ai);
62
- if (status != ARES_SUCCESS)
63
- {
64
- ares_free(question_hostname);
65
-
66
- if (naddrttls)
67
- {
68
- *naddrttls = 0;
69
- }
70
-
71
- return status;
72
- }
73
-
74
- hostent = ares_malloc(sizeof(struct hostent));
75
- if (!hostent)
76
- {
77
- goto enomem;
78
- }
79
-
80
- next = ai.nodes;
81
- while (next)
82
- {
83
- if (next->ai_family == AF_INET)
84
- {
85
- ++naddrs;
86
- }
87
- next = next->ai_next;
88
- }
89
-
90
- next_cname = ai.cnames;
91
- while (next_cname)
92
- {
93
- if(next_cname->alias)
94
- ++naliases;
95
- next_cname = next_cname->next;
96
- }
97
-
98
- aliases = ares_malloc((naliases + 1) * sizeof(char *));
99
- if (!aliases)
100
- {
101
- goto enomem;
102
- }
103
-
104
- if (naliases)
105
- {
106
- next_cname = ai.cnames;
107
- while (next_cname)
108
- {
109
- if(next_cname->alias)
110
- aliases[alias++] = ares_strdup(next_cname->alias);
111
- if(next_cname->ttl < cname_ttl)
112
- cname_ttl = next_cname->ttl;
113
- next_cname = next_cname->next;
114
- }
115
- }
116
-
117
- aliases[alias] = NULL;
118
-
119
- hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *));
120
- if (!hostent->h_addr_list)
53
+ if (naddrttls)
121
54
  {
122
- goto enomem;
55
+ req_naddrttls = *naddrttls;
56
+ *naddrttls = 0;
123
57
  }
124
58
 
125
- for (i = 0; i < naddrs + 1; ++i)
126
- {
127
- hostent->h_addr_list[i] = NULL;
128
- }
59
+ memset(&ai, 0, sizeof(ai));
129
60
 
130
- if (ai.cnames)
61
+ status = ares__parse_into_addrinfo(abuf, alen, 0, 0, &ai);
62
+ if (status != ARES_SUCCESS && status != ARES_ENODATA)
131
63
  {
132
- hostent->h_name = ares_strdup(ai.cnames->name);
133
- ares_free(question_hostname);
64
+ goto fail;
134
65
  }
135
- else
136
- {
137
- hostent->h_name = question_hostname;
138
- }
139
-
140
- hostent->h_aliases = aliases;
141
- hostent->h_addrtype = AF_INET;
142
- hostent->h_length = sizeof(struct in_addr);
143
66
 
144
- if (naddrs)
67
+ if (host != NULL)
145
68
  {
146
- addrs = ares_malloc(naddrs * sizeof(struct in_addr));
147
- if (!addrs)
148
- {
149
- goto enomem;
150
- }
151
-
152
- i = 0;
153
- next = ai.nodes;
154
- while (next)
69
+ status = ares__addrinfo2hostent(&ai, AF_INET, host);
70
+ if (status != ARES_SUCCESS && status != ARES_ENODATA)
155
71
  {
156
- if (next->ai_family == AF_INET)
157
- {
158
- hostent->h_addr_list[i] = (char *)&addrs[i];
159
- memcpy(hostent->h_addr_list[i],
160
- &(CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr)->sin_addr),
161
- sizeof(struct in_addr));
162
- if (naddrttls && i < *naddrttls)
163
- {
164
- if (next->ai_ttl > cname_ttl)
165
- addrttls[i].ttl = cname_ttl;
166
- else
167
- addrttls[i].ttl = next->ai_ttl;
168
-
169
- memcpy(&addrttls[i].ipaddr,
170
- &(CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr)->sin_addr),
171
- sizeof(struct in_addr));
172
- }
173
- ++i;
174
- }
175
- next = next->ai_next;
176
- }
177
- if (i == 0)
178
- {
179
- ares_free(addrs);
72
+ goto fail;
180
73
  }
181
74
  }
182
75
 
183
- if (host)
184
- {
185
- *host = hostent;
186
- }
187
- else
188
- {
189
- ares_free_hostent(hostent);
190
- }
76
+ if (addrttls != NULL && req_naddrttls)
77
+ {
78
+ ares__addrinfo2addrttl(&ai, AF_INET, req_naddrttls, addrttls,
79
+ NULL, naddrttls);
80
+ }
191
81
 
192
- if (naddrttls)
193
- {
194
- /* Truncated to at most *naddrttls entries */
195
- *naddrttls = (naddrs > *naddrttls)?*naddrttls:naddrs;
196
- }
197
-
198
- ares__freeaddrinfo_cnames(ai.cnames);
199
- ares__freeaddrinfo_nodes(ai.nodes);
200
- return ARES_SUCCESS;
201
82
 
202
- enomem:
203
- ares_free(aliases);
204
- ares_free(hostent);
83
+ fail:
205
84
  ares__freeaddrinfo_cnames(ai.cnames);
206
85
  ares__freeaddrinfo_nodes(ai.nodes);
86
+ ares_free(ai.name);
207
87
  ares_free(question_hostname);
208
- return ARES_ENOMEM;
88
+
89
+ return status;
209
90
  }
@@ -48,165 +48,45 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
48
48
  int *naddrttls)
49
49
  {
50
50
  struct ares_addrinfo ai;
51
- struct ares_addrinfo_node *next;
52
- struct ares_addrinfo_cname *next_cname;
53
- char **aliases = NULL;
54
51
  char *question_hostname = NULL;
55
- struct hostent *hostent = NULL;
56
- struct ares_in6_addr *addrs = NULL;
57
- int naliases = 0, naddrs = 0, alias = 0, i;
58
- int cname_ttl = INT_MAX;
59
52
  int status;
53
+ int req_naddrttls = 0;
60
54
 
61
- memset(&ai, 0, sizeof(ai));
62
-
63
- status = ares__parse_into_addrinfo2(abuf, alen, &question_hostname, &ai);
64
- if (status != ARES_SUCCESS)
65
- {
66
- ares_free(question_hostname);
67
-
68
- if (naddrttls)
69
- {
70
- *naddrttls = 0;
71
- }
72
-
73
- return status;
74
- }
75
-
76
- hostent = ares_malloc(sizeof(struct hostent));
77
- if (!hostent)
78
- {
79
- goto enomem;
80
- }
81
-
82
- next = ai.nodes;
83
- while (next)
84
- {
85
- if(next->ai_family == AF_INET6)
86
- {
87
- ++naddrs;
88
- }
89
- next = next->ai_next;
90
- }
91
-
92
- next_cname = ai.cnames;
93
- while (next_cname)
94
- {
95
- if(next_cname->alias)
96
- ++naliases;
97
- next_cname = next_cname->next;
98
- }
99
-
100
- aliases = ares_malloc((naliases + 1) * sizeof(char *));
101
- if (!aliases)
102
- {
103
- goto enomem;
104
- }
105
-
106
- if (naliases)
107
- {
108
- next_cname = ai.cnames;
109
- while (next_cname)
110
- {
111
- if(next_cname->alias)
112
- aliases[alias++] = ares_strdup(next_cname->alias);
113
- if(next_cname->ttl < cname_ttl)
114
- cname_ttl = next_cname->ttl;
115
- next_cname = next_cname->next;
116
- }
117
- }
118
-
119
- aliases[alias] = NULL;
120
-
121
- hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *));
122
- if (!hostent->h_addr_list)
55
+ if (naddrttls)
123
56
  {
124
- goto enomem;
57
+ req_naddrttls = *naddrttls;
58
+ *naddrttls = 0;
125
59
  }
126
60
 
127
- for (i = 0; i < naddrs + 1; ++i)
128
- {
129
- hostent->h_addr_list[i] = NULL;
130
- }
61
+ memset(&ai, 0, sizeof(ai));
131
62
 
132
- if (ai.cnames)
133
- {
134
- hostent->h_name = ares_strdup(ai.cnames->name);
135
- ares_free(question_hostname);
136
- }
137
- else
63
+ status = ares__parse_into_addrinfo(abuf, alen, 0, 0, &ai);
64
+ if (status != ARES_SUCCESS && status != ARES_ENODATA)
138
65
  {
139
- hostent->h_name = question_hostname;
66
+ goto fail;
140
67
  }
141
68
 
142
- hostent->h_aliases = aliases;
143
- hostent->h_addrtype = AF_INET6;
144
- hostent->h_length = sizeof(struct ares_in6_addr);
145
-
146
- if (naddrs)
69
+ if (host != NULL)
147
70
  {
148
- addrs = ares_malloc(naddrs * sizeof(struct ares_in6_addr));
149
- if (!addrs)
150
- {
151
- goto enomem;
152
- }
153
-
154
- i = 0;
155
- next = ai.nodes;
156
- while (next)
157
- {
158
- if(next->ai_family == AF_INET6)
159
- {
160
- hostent->h_addr_list[i] = (char*)&addrs[i];
161
- memcpy(hostent->h_addr_list[i],
162
- &(CARES_INADDR_CAST(struct sockaddr_in6 *, next->ai_addr)->sin6_addr),
163
- sizeof(struct ares_in6_addr));
164
- if (naddrttls && i < *naddrttls)
165
- {
166
- if(next->ai_ttl > cname_ttl)
167
- addrttls[i].ttl = cname_ttl;
168
- else
169
- addrttls[i].ttl = next->ai_ttl;
170
-
171
- memcpy(&addrttls[i].ip6addr,
172
- &(CARES_INADDR_CAST(struct sockaddr_in6 *, next->ai_addr)->sin6_addr),
173
- sizeof(struct ares_in6_addr));
174
- }
175
- ++i;
176
- }
177
- next = next->ai_next;
178
- }
179
-
180
- if (i == 0)
71
+ status = ares__addrinfo2hostent(&ai, AF_INET6, host);
72
+ if (status != ARES_SUCCESS && status != ARES_ENODATA)
181
73
  {
182
- ares_free(addrs);
74
+ goto fail;
183
75
  }
184
76
  }
185
77
 
186
- if (host)
187
- {
188
- *host = hostent;
189
- }
190
- else
191
- {
192
- ares_free_hostent(hostent);
193
- }
78
+ if (addrttls != NULL && req_naddrttls)
79
+ {
80
+ ares__addrinfo2addrttl(&ai, AF_INET6, req_naddrttls, NULL,
81
+ addrttls, naddrttls);
82
+ }
194
83
 
195
- if (naddrttls)
196
- {
197
- /* Truncated to at most *naddrttls entries */
198
- *naddrttls = (naddrs > *naddrttls)?*naddrttls:naddrs;
199
- }
200
-
201
- ares__freeaddrinfo_cnames(ai.cnames);
202
- ares__freeaddrinfo_nodes(ai.nodes);
203
- return ARES_SUCCESS;
204
-
205
- enomem:
206
- ares_free(aliases);
207
- ares_free(hostent);
84
+ fail:
208
85
  ares__freeaddrinfo_cnames(ai.cnames);
209
86
  ares__freeaddrinfo_nodes(ai.nodes);
210
87
  ares_free(question_hostname);
211
- return ARES_ENOMEM;
88
+ ares_free(ai.name);
89
+
90
+ return status;
212
91
  }
92
+
@@ -0,0 +1,184 @@
1
+
2
+ /* Copyright 1998 by the Massachusetts Institute of Technology.
3
+ * Copyright (C) 2009 by Jakub Hrozek <jhrozek@redhat.com>
4
+ *
5
+ * Permission to use, copy, modify, and distribute this
6
+ * software and its documentation for any purpose and without
7
+ * fee is hereby granted, provided that the above copyright
8
+ * notice appear in all copies and that both that copyright
9
+ * notice and this permission notice appear in supporting
10
+ * documentation, and that the name of M.I.T. not be used in
11
+ * advertising or publicity pertaining to distribution of the
12
+ * software without specific, written prior permission.
13
+ * M.I.T. makes no representations about the suitability of
14
+ * this software for any purpose. It is provided "as is"
15
+ * without express or implied warranty.
16
+ */
17
+
18
+ #include "ares_setup.h"
19
+
20
+ #ifdef HAVE_NETINET_IN_H
21
+ # include <netinet/in.h>
22
+ #endif
23
+ #ifdef HAVE_NETDB_H
24
+ # include <netdb.h>
25
+ #endif
26
+ #ifdef HAVE_ARPA_INET_H
27
+ # include <arpa/inet.h>
28
+ #endif
29
+
30
+ #include "ares_nameser.h"
31
+
32
+ #include "ares.h"
33
+ #include "ares_dns.h"
34
+ #include "ares_data.h"
35
+ #include "ares_private.h"
36
+
37
+ /* AIX portability check */
38
+ #ifndef T_URI
39
+ # define T_URI 256 /* uri selection */
40
+ #endif
41
+
42
+ int
43
+ ares_parse_uri_reply (const unsigned char *abuf, int alen,
44
+ struct ares_uri_reply **uri_out)
45
+ {
46
+ unsigned int qdcount, ancount, i;
47
+ const unsigned char *aptr, *vptr;
48
+ int status, rr_type, rr_class, rr_len, rr_ttl;
49
+ long len;
50
+ char *uri_str = NULL, *rr_name = NULL;
51
+ struct ares_uri_reply *uri_head = NULL;
52
+ struct ares_uri_reply *uri_last = NULL;
53
+ struct ares_uri_reply *uri_curr;
54
+
55
+ /* Set *uri_out to NULL for all failure cases. */
56
+ *uri_out = NULL;
57
+
58
+ /* Give up if abuf doesn't have room for a header. */
59
+ if (alen < HFIXEDSZ){
60
+ return ARES_EBADRESP;
61
+ }
62
+
63
+ /* Fetch the question and answer count from the header. */
64
+ qdcount = DNS_HEADER_QDCOUNT (abuf);
65
+ ancount = DNS_HEADER_ANCOUNT (abuf);
66
+ if (qdcount != 1) {
67
+ return ARES_EBADRESP;
68
+ }
69
+ if (ancount == 0) {
70
+ return ARES_ENODATA;
71
+ }
72
+ /* Expand the name from the question, and skip past the question. */
73
+ aptr = abuf + HFIXEDSZ;
74
+
75
+ status = ares_expand_name (aptr, abuf, alen, &uri_str, &len);
76
+ if (status != ARES_SUCCESS){
77
+ return status;
78
+ }
79
+ if (aptr + len + QFIXEDSZ > abuf + alen)
80
+ {
81
+ ares_free (uri_str);
82
+ return ARES_EBADRESP;
83
+ }
84
+ aptr += len + QFIXEDSZ;
85
+
86
+ /* Examine each answer resource record (RR) in turn. */
87
+ for (i = 0; i < ancount; i++)
88
+ {
89
+ /* Decode the RR up to the data field. */
90
+ status = ares_expand_name (aptr, abuf, alen, &rr_name, &len);
91
+ if (status != ARES_SUCCESS)
92
+ {
93
+ break;
94
+ }
95
+ aptr += len;
96
+ if (aptr + RRFIXEDSZ > abuf + alen)
97
+ {
98
+ status = ARES_EBADRESP;
99
+ break;
100
+ }
101
+
102
+ rr_type = DNS_RR_TYPE (aptr);
103
+ rr_class = DNS_RR_CLASS (aptr);
104
+ rr_ttl = DNS_RR_TTL(aptr);
105
+ rr_len = DNS_RR_LEN (aptr);
106
+ aptr += RRFIXEDSZ;
107
+
108
+ if (aptr + rr_len > abuf + alen)
109
+ {
110
+ status = ARES_EBADRESP;
111
+ break;
112
+ }
113
+
114
+ /* Check if we are really looking at a URI record */
115
+ if (rr_class == C_IN && rr_type == T_URI)
116
+ {
117
+ /* parse the URI record itself */
118
+ if (rr_len < 5)
119
+ {
120
+ status = ARES_EBADRESP;
121
+ break;
122
+ }
123
+ /* Allocate storage for this URI answer appending it to the list */
124
+ uri_curr = ares_malloc_data(ARES_DATATYPE_URI_REPLY);
125
+ if (!uri_curr)
126
+ {
127
+ status = ARES_ENOMEM;
128
+ break;
129
+ }
130
+ if (uri_last)
131
+ {
132
+ uri_last->next = uri_curr;
133
+ }
134
+ else
135
+ {
136
+ uri_head = uri_curr;
137
+ }
138
+ uri_last = uri_curr;
139
+
140
+ vptr = aptr;
141
+ uri_curr->priority = DNS__16BIT(vptr);
142
+ vptr += sizeof(unsigned short);
143
+ uri_curr->weight = DNS__16BIT(vptr);
144
+ vptr += sizeof(unsigned short);
145
+ uri_curr->uri = (char *)ares_malloc(rr_len-3);
146
+ if (!uri_curr->uri)
147
+ {
148
+ status = ARES_ENOMEM;
149
+ break;
150
+ }
151
+ uri_curr->uri = strncpy(uri_curr->uri, (const char *)vptr, rr_len-4);
152
+ uri_curr->uri[rr_len-4]='\0';
153
+ uri_curr->ttl = rr_ttl;
154
+
155
+ if (status != ARES_SUCCESS)
156
+ break;
157
+ }
158
+
159
+ /* Don't lose memory in the next iteration */
160
+ ares_free (rr_name);
161
+ rr_name = NULL;
162
+
163
+ /* Move on to the next record */
164
+ aptr += rr_len;
165
+ }
166
+
167
+ if (uri_str)
168
+ ares_free (uri_str);
169
+ if (rr_name)
170
+ ares_free (rr_name);
171
+
172
+ /* clean up on error */
173
+ if (status != ARES_SUCCESS)
174
+ {
175
+ if (uri_head)
176
+ ares_free_data (uri_head);
177
+ return status;
178
+ }
179
+
180
+ /* everything looks fine, return the data */
181
+ *uri_out = uri_head;
182
+
183
+ return ARES_SUCCESS;
184
+ }