grpc 1.73.0 → 1.75.0
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.
- checksums.yaml +4 -4
- data/Makefile +116 -53
- data/include/grpc/create_channel_from_endpoint.h +54 -0
- data/include/grpc/credentials.h +18 -6
- data/include/grpc/event_engine/event_engine.h +74 -17
- data/include/grpc/grpc_posix.h +20 -1
- data/include/grpc/impl/channel_arg_names.h +2 -4
- data/include/grpc/module.modulemap +1 -0
- data/include/grpc/support/json.h +24 -0
- data/src/core/call/client_call.cc +4 -4
- data/src/core/call/filter_fusion.h +1230 -0
- data/src/core/call/interception_chain.h +7 -11
- data/src/core/call/metadata.cc +22 -0
- data/src/core/call/metadata.h +24 -2
- data/src/core/channelz/channel_trace.cc +213 -115
- data/src/core/channelz/channel_trace.h +380 -86
- data/src/core/channelz/channelz.cc +274 -192
- data/src/core/channelz/channelz.h +224 -72
- data/src/core/channelz/channelz_registry.cc +2 -163
- data/src/core/channelz/channelz_registry.h +37 -6
- data/src/core/channelz/property_list.cc +353 -0
- data/src/core/channelz/property_list.h +204 -0
- data/src/core/channelz/v2tov1/convert.cc +683 -0
- data/src/core/channelz/v2tov1/convert.h +58 -0
- data/src/core/channelz/v2tov1/legacy_api.cc +425 -0
- data/src/core/channelz/v2tov1/legacy_api.h +32 -0
- data/src/core/channelz/v2tov1/property_list.cc +118 -0
- data/src/core/channelz/v2tov1/property_list.h +52 -0
- data/src/core/channelz/ztrace_collector.h +3 -2
- data/src/core/client_channel/backup_poller.cc +17 -2
- data/src/core/client_channel/client_channel.cc +17 -28
- data/src/core/client_channel/client_channel_filter.cc +24 -33
- data/src/core/client_channel/client_channel_filter.h +2 -2
- data/src/core/client_channel/client_channel_internal.h +2 -1
- data/src/core/client_channel/config_selector.h +8 -2
- data/src/core/client_channel/dynamic_filters.cc +5 -6
- data/src/core/client_channel/dynamic_filters.h +1 -1
- data/src/core/client_channel/global_subchannel_pool.cc +4 -1
- data/src/core/client_channel/load_balanced_call_destination.cc +6 -5
- data/src/core/client_channel/retry_filter.cc +21 -27
- data/src/core/client_channel/retry_filter.h +10 -7
- data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -5
- data/src/core/client_channel/retry_filter_legacy_call_data.h +1 -1
- data/src/core/client_channel/retry_interceptor.cc +30 -44
- data/src/core/client_channel/retry_interceptor.h +18 -17
- data/src/core/client_channel/retry_throttle.cc +46 -61
- data/src/core/client_channel/retry_throttle.h +17 -39
- data/src/core/client_channel/subchannel.cc +57 -25
- data/src/core/client_channel/subchannel.h +10 -0
- data/src/core/config/config_vars.cc +2 -0
- data/src/core/config/core_configuration.cc +4 -1
- data/src/core/config/core_configuration.h +23 -0
- data/src/core/credentials/call/call_creds_registry.h +125 -0
- data/src/core/credentials/call/call_creds_registry_init.cc +91 -0
- data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +6 -48
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +86 -0
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h +74 -0
- data/src/core/credentials/call/jwt_util.cc +70 -0
- data/src/core/credentials/call/jwt_util.h +32 -0
- data/src/core/credentials/transport/alts/alts_credentials.cc +5 -0
- data/src/core/credentials/transport/alts/check_gcp_environment_windows.cc +2 -0
- data/src/core/credentials/transport/channel_creds_registry_init.cc +4 -2
- data/src/core/credentials/transport/google_default/google_default_credentials.cc +72 -4
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +1 -2
- data/src/core/credentials/transport/ssl/ssl_security_connector.cc +8 -3
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -24
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +19 -8
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +96 -54
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +15 -2
- data/src/core/credentials/transport/tls/load_system_roots_supported.cc +1 -0
- data/src/core/credentials/transport/tls/spiffe_utils.cc +371 -0
- data/src/core/credentials/transport/tls/spiffe_utils.h +171 -0
- data/src/core/credentials/transport/tls/ssl_utils.cc +11 -10
- data/src/core/credentials/transport/tls/ssl_utils.h +4 -2
- data/src/core/credentials/transport/tls/tls_credentials.cc +2 -0
- data/src/core/credentials/transport/tls/tls_security_connector.cc +11 -26
- data/src/core/credentials/transport/tls/tls_security_connector.h +12 -12
- data/src/core/credentials/transport/xds/xds_credentials.cc +0 -3
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -2
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +8 -8
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +16 -16
- data/src/core/ext/filters/http/client/http_client_filter.cc +3 -6
- data/src/core/ext/filters/http/client_authority_filter.cc +3 -6
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +8 -8
- data/src/core/ext/filters/http/message_compress/compression_filter.h +25 -22
- data/src/core/ext/filters/http/server/http_server_filter.cc +3 -6
- data/src/core/ext/filters/http/server/http_server_filter.h +12 -11
- data/src/core/ext/filters/message_size/message_size_filter.cc +4 -4
- data/src/core/ext/filters/rbac/rbac_filter.cc +1 -1
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -5
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +120 -35
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +165 -117
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +0 -3
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +1239 -3514
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1008 -1486
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +23 -17
- data/src/core/ext/transport/chttp2/transport/frame.cc +99 -6
- data/src/core/ext/transport/chttp2/transport/frame.h +40 -2
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/header_assembler.h +290 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +11 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +12 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +1233 -0
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +712 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +11 -38
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +65 -51
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc +61 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.h +142 -0
- data/{third_party/abseil-cpp/absl/strings/cord_buffer.cc → src/core/ext/transport/chttp2/transport/http2_stats_collector.cc} +14 -14
- data/src/core/ext/transport/chttp2/transport/http2_stats_collector.h +33 -0
- data/src/core/ext/transport/chttp2/transport/http2_status.h +6 -1
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +121 -0
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +76 -0
- data/src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h +0 -29
- data/src/core/ext/transport/chttp2/transport/internal.h +18 -8
- data/src/core/ext/transport/chttp2/transport/keepalive.cc +105 -0
- data/src/core/ext/transport/chttp2/transport/keepalive.h +138 -0
- data/src/core/ext/transport/chttp2/transport/message_assembler.h +185 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/ping_callbacks.h +19 -0
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +152 -0
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +197 -0
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +5 -9
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +11 -0
- data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +607 -0
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +39 -1
- data/src/core/ext/transport/chttp2/transport/transport_common.cc +19 -0
- data/src/core/ext/transport/chttp2/transport/transport_common.h +27 -0
- data/src/core/ext/transport/chttp2/transport/writable_streams.h +254 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +41 -13
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb.h +4959 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.c +1111 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.h +108 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb.h +571 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb_minitable.c +120 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb_minitable.h +36 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb.h +1272 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb_minitable.c +312 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb_minitable.h +50 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +1072 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +230 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +44 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +716 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.h +227 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/promise.upbdefs.c +175 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/promise.upbdefs.h +82 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +133 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +67 -0
- data/src/core/filter/auth/auth_filters.h +2 -27
- data/src/core/filter/auth/client_auth_filter.cc +0 -118
- data/src/core/filter/filter_args.h +9 -23
- data/src/core/filter/fused_filters.cc +154 -0
- data/src/core/handshaker/handshaker.cc +23 -14
- data/src/core/handshaker/handshaker.h +3 -0
- data/src/core/handshaker/http_connect/http_connect_handshaker.cc +3 -1
- data/src/core/handshaker/security/legacy_secure_endpoint.cc +7 -6
- data/src/core/handshaker/security/pipelined_secure_endpoint.cc +965 -0
- data/src/core/handshaker/security/secure_endpoint.cc +98 -38
- data/src/core/handshaker/security/secure_endpoint.h +8 -0
- data/src/core/handshaker/security/security_handshaker.cc +4 -1
- data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +7 -1
- data/src/core/lib/channel/channel_args.cc +15 -0
- data/src/core/lib/channel/channel_args.h +3 -0
- data/src/core/lib/channel/channel_stack.cc +22 -23
- data/src/core/lib/channel/channel_stack.h +9 -7
- data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -1
- data/src/core/lib/channel/channel_stack_builder_impl.h +2 -7
- data/src/core/lib/channel/promise_based_filter.cc +15 -25
- data/src/core/lib/channel/promise_based_filter.h +11 -10
- data/src/core/lib/debug/trace_impl.h +0 -1
- data/src/core/lib/event_engine/ares_resolver.cc +165 -46
- data/src/core/lib/event_engine/ares_resolver.h +51 -3
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +12 -6
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +2 -4
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +263 -0
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.h +107 -0
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +31 -3
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +14 -6
- data/src/core/lib/event_engine/endpoint_channel_arg_wrapper.cc +40 -0
- data/src/core/lib/event_engine/endpoint_channel_arg_wrapper.h +60 -0
- data/src/core/lib/event_engine/event_engine.cc +7 -0
- data/src/core/lib/event_engine/extensions/channelz.h +10 -6
- data/src/core/lib/event_engine/grpc_polled_fd.h +5 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +139 -169
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +17 -19
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +90 -131
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +13 -13
- data/src/core/lib/event_engine/posix_engine/event_poller.h +18 -23
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +11 -23
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +3 -2
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +124 -0
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.h +243 -0
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +30 -19
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.cc +6 -2
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.h +6 -1
- data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +4 -4
- data/src/core/lib/event_engine/posix_engine/lockfree_event.h +3 -4
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +147 -94
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -19
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +435 -229
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +78 -50
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +46 -38
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +6 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +32 -142
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h +6 -5
- data/src/core/lib/event_engine/posix_engine/posix_interface.h +211 -0
- data/src/core/lib/event_engine/posix_engine/posix_interface_posix.cc +1083 -0
- data/src/core/lib/event_engine/posix_engine/posix_interface_windows.cc +281 -0
- data/src/core/lib/event_engine/posix_engine/posix_write_event_sink.cc +154 -0
- data/src/core/lib/event_engine/posix_engine/posix_write_event_sink.h +174 -0
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -719
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +11 -171
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +33 -22
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +13 -11
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +117 -151
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +26 -94
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc +26 -25
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h +6 -2
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc +36 -62
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h +6 -2
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h +7 -6
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc +12 -6
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h +3 -1
- data/src/core/lib/event_engine/shim.cc +9 -0
- data/src/core/lib/event_engine/shim.h +3 -0
- data/src/core/lib/event_engine/thread_pool/thread_pool.h +7 -3
- data/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +0 -17
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +4 -2
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +3 -2
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +6 -1
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h +4 -0
- data/src/core/lib/event_engine/windows/windows_endpoint.h +2 -6
- data/src/core/lib/event_engine/windows/windows_engine.cc +0 -1
- data/src/core/lib/event_engine/windows/windows_engine.h +1 -3
- data/src/core/lib/event_engine/windows/windows_listener.cc +14 -2
- data/src/core/lib/experiments/experiments.cc +165 -99
- data/src/core/lib/experiments/experiments.h +65 -52
- data/src/core/lib/iomgr/combiner.cc +1 -1
- data/src/core/lib/iomgr/endpoint.cc +4 -3
- data/src/core/lib/iomgr/endpoint.h +7 -4
- data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +7 -2
- data/src/core/lib/iomgr/ev_poll_posix.cc +7 -2
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +4 -6
- data/src/core/lib/iomgr/exec_ctx.h +3 -9
- data/src/core/lib/iomgr/socket_mutator.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +1 -1
- data/src/core/lib/iomgr/tcp_client_posix.cc +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +15 -9
- data/src/core/lib/iomgr/tcp_windows.cc +3 -2
- data/src/core/lib/promise/activity.h +3 -2
- data/src/core/lib/promise/arena_promise.h +23 -7
- data/src/core/lib/promise/detail/promise_factory.h +10 -0
- data/src/core/lib/promise/detail/promise_like.h +118 -11
- data/src/core/lib/promise/detail/promise_variant.h +50 -0
- data/src/core/lib/promise/detail/seq_state.h +687 -548
- data/src/core/lib/promise/if.h +20 -0
- data/src/core/lib/promise/inter_activity_latch.h +147 -0
- data/src/core/lib/promise/inter_activity_mutex.h +547 -0
- data/src/core/lib/promise/loop.h +65 -3
- data/src/core/lib/promise/map.h +24 -0
- data/src/core/lib/promise/match_promise.h +103 -0
- data/src/core/lib/promise/mpsc.cc +425 -0
- data/src/core/lib/promise/mpsc.h +490 -0
- data/src/core/lib/promise/party.cc +55 -6
- data/src/core/lib/promise/party.h +68 -3
- data/src/core/lib/promise/poll.h +10 -0
- data/src/core/lib/promise/race.h +31 -0
- data/src/core/lib/promise/seq.h +4 -1
- data/src/core/lib/promise/status_flag.h +7 -0
- data/src/core/lib/promise/try_seq.h +4 -1
- data/src/core/lib/promise/wait_set.cc +28 -0
- data/src/core/lib/promise/wait_set.h +86 -0
- data/src/core/lib/resource_quota/arena.h +19 -0
- data/src/core/lib/resource_quota/memory_quota.cc +90 -3
- data/src/core/lib/resource_quota/memory_quota.h +20 -9
- data/src/core/lib/resource_quota/periodic_update.cc +14 -0
- data/src/core/lib/resource_quota/periodic_update.h +8 -0
- data/src/core/lib/resource_quota/resource_quota.cc +15 -4
- data/src/core/lib/resource_quota/resource_quota.h +3 -0
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -2
- data/src/core/lib/slice/slice.h +5 -0
- data/src/core/lib/surface/call.cc +5 -5
- data/src/core/lib/surface/call.h +6 -5
- data/src/core/lib/surface/channel_create.cc +88 -13
- data/src/core/lib/surface/channel_create.h +4 -0
- data/src/core/lib/surface/channel_init.cc +164 -47
- data/src/core/lib/surface/channel_init.h +64 -1
- data/src/core/lib/surface/completion_queue.cc +2 -4
- data/src/core/lib/surface/filter_stack_call.cc +19 -10
- data/src/core/lib/surface/init.cc +6 -15
- data/src/core/lib/surface/legacy_channel.cc +3 -5
- data/src/core/lib/surface/legacy_channel.h +3 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.cc +110 -0
- data/src/core/lib/transport/promise_endpoint.h +307 -0
- data/src/core/load_balancing/child_policy_handler.cc +2 -4
- data/src/core/load_balancing/delegating_helper.h +2 -3
- data/src/core/load_balancing/endpoint_list.cc +29 -2
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +3 -3
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.h +1 -1
- data/src/core/load_balancing/health_check_client.cc +1 -5
- data/src/core/load_balancing/lb_policy.h +1 -3
- data/src/core/load_balancing/oob_backend_metric.cc +1 -5
- data/src/core/load_balancing/pick_first/pick_first.cc +15 -5
- data/src/core/load_balancing/xds/cds.cc +10 -1
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +5 -3
- data/src/core/net/socket_mutator.cc +19 -0
- data/src/core/net/socket_mutator.h +25 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +6 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +2 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +8 -5
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
- data/src/core/resolver/xds/xds_config.cc +6 -3
- data/src/core/resolver/xds/xds_config.h +9 -4
- data/src/core/resolver/xds/xds_dependency_manager.cc +22 -7
- data/src/core/resolver/xds/xds_dependency_manager.h +2 -1
- data/src/core/resolver/xds/xds_resolver.cc +31 -11
- data/src/core/server/server.cc +84 -13
- data/src/core/server/server.h +21 -2
- data/src/core/server/server_call_tracer_filter.cc +0 -66
- data/src/core/server/server_call_tracer_filter.h +64 -0
- data/src/core/server/server_config_selector_filter.cc +1 -1
- data/src/core/server/xds_server_config_fetcher.cc +63 -25
- data/src/core/service_config/service_config.h +1 -1
- data/src/core/service_config/service_config_channel_arg_filter.cc +3 -60
- data/src/core/service_config/service_config_channel_arg_filter.h +82 -0
- data/src/core/service_config/service_config_impl.h +1 -1
- data/src/core/telemetry/call_tracer.cc +20 -14
- data/src/core/telemetry/call_tracer.h +22 -17
- data/src/core/telemetry/context_list_entry.cc +38 -0
- data/src/core/telemetry/context_list_entry.h +42 -12
- data/src/core/telemetry/metrics.h +8 -8
- data/src/core/telemetry/stats_data.cc +369 -343
- data/src/core/telemetry/stats_data.h +341 -244
- data/src/core/telemetry/tcp_tracer.h +1 -1
- data/src/core/transport/auth_context.cc +20 -0
- data/src/core/transport/auth_context.h +4 -0
- data/src/core/transport/auth_context_comparator_registry.h +69 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -3
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +11 -3
- data/src/core/tsi/fake_transport_security.cc +17 -0
- data/src/core/tsi/ssl_transport_security.cc +205 -32
- data/src/core/tsi/ssl_transport_security.h +19 -10
- data/src/core/tsi/ssl_transport_security_utils.cc +21 -0
- data/src/core/tsi/ssl_transport_security_utils.h +4 -0
- data/src/core/tsi/transport_security_grpc.cc +8 -0
- data/src/core/tsi/transport_security_grpc.h +15 -0
- data/src/core/util/backoff.cc +1 -5
- data/src/core/util/backoff.h +1 -0
- data/src/core/util/down_cast.h +1 -1
- data/src/core/util/function_signature.h +15 -1
- data/src/core/util/http_client/httpcli.cc +12 -5
- data/src/core/util/http_client/httpcli.h +4 -1
- data/src/core/util/http_client/httpcli_security_connector.cc +3 -1
- data/src/core/util/latent_see.cc +178 -146
- data/src/core/util/latent_see.h +249 -189
- data/src/core/util/log.cc +4 -0
- data/src/core/util/memory_usage.h +268 -0
- data/src/core/util/per_cpu.cc +2 -0
- data/src/core/util/per_cpu.h +7 -0
- data/src/core/util/shared_bit_gen.h +20 -0
- data/src/core/util/single_set_ptr.h +7 -4
- data/src/core/util/upb_utils.h +42 -0
- data/src/core/util/uri.cc +3 -2
- data/src/core/util/useful.h +144 -2
- data/src/core/util/wait_for_single_owner.cc +31 -0
- data/src/core/util/wait_for_single_owner.h +24 -0
- data/src/core/util/windows/directory_reader.cc +1 -0
- data/src/core/util/windows/thd.cc +1 -3
- data/src/core/util/work_serializer.cc +1 -1
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +32 -5
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +5 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc.h +5 -0
- data/src/core/xds/grpc/xds_certificate_provider.cc +5 -6
- data/src/core/xds/grpc/xds_client_grpc.cc +6 -2
- data/src/core/xds/grpc/xds_common_types_parser.cc +138 -50
- data/src/core/xds/grpc/xds_common_types_parser.h +12 -0
- data/src/core/xds/grpc/xds_http_filter.h +7 -0
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +22 -0
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -0
- data/src/core/xds/grpc/xds_route_config_parser.cc +15 -38
- data/src/core/xds/grpc/xds_server_grpc.cc +63 -13
- data/src/core/xds/grpc/xds_server_grpc.h +10 -2
- data/src/core/xds/grpc/xds_server_grpc_interface.h +4 -0
- data/src/core/xds/grpc/xds_transport_grpc.cc +18 -0
- data/src/core/xds/xds_client/xds_bootstrap.h +2 -0
- data/src/core/xds/xds_client/xds_client.cc +26 -5
- data/src/ruby/ext/grpc/extconf.rb +2 -0
- data/src/ruby/ext/grpc/rb_call.c +1 -8
- data/src/ruby/ext/grpc/rb_channel.c +70 -557
- data/src/ruby/ext/grpc/rb_channel.h +0 -3
- data/src/ruby/ext/grpc/rb_completion_queue.c +26 -14
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -7
- data/src/ruby/ext/grpc/rb_grpc.c +9 -5
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +2 -2
- data/src/ruby/ext/grpc/rb_loader.c +0 -4
- data/src/ruby/ext/grpc/rb_server.c +31 -50
- data/src/ruby/lib/grpc/generic/client_stub.rb +4 -4
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/core_spec.rb +22 -0
- data/src/ruby/spec/generic/active_call_spec.rb +1 -1
- data/third_party/abseil-cpp/absl/algorithm/container.h +2 -19
- data/third_party/abseil-cpp/absl/base/attributes.h +76 -7
- data/third_party/abseil-cpp/absl/base/call_once.h +11 -12
- data/third_party/abseil-cpp/absl/base/config.h +20 -129
- data/third_party/abseil-cpp/absl/base/{internal/fast_type_id.h → fast_type_id.h} +11 -16
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +0 -5
- data/third_party/abseil-cpp/absl/base/internal/cycleclock_config.h +7 -7
- data/third_party/abseil-cpp/absl/base/internal/endian.h +34 -38
- data/third_party/abseil-cpp/absl/base/internal/iterator_traits.h +71 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +6 -5
- data/third_party/abseil-cpp/absl/base/internal/{nullability_impl.h → nullability_deprecated.h} +45 -8
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +0 -9
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +3 -13
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +6 -6
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +8 -3
- data/third_party/abseil-cpp/absl/base/no_destructor.h +11 -32
- data/third_party/abseil-cpp/absl/base/nullability.h +84 -72
- data/third_party/abseil-cpp/absl/base/options.h +3 -80
- data/third_party/abseil-cpp/absl/base/policy_checks.h +7 -7
- data/third_party/abseil-cpp/absl/cleanup/cleanup.h +1 -3
- data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -4
- data/third_party/abseil-cpp/absl/container/btree_map.h +4 -2
- data/third_party/abseil-cpp/absl/container/btree_set.h +4 -2
- data/third_party/abseil-cpp/absl/container/fixed_array.h +7 -14
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +5 -0
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +6 -1
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +8 -5
- data/third_party/abseil-cpp/absl/container/internal/btree.h +132 -29
- data/third_party/abseil-cpp/absl/container/internal/btree_container.h +175 -71
- data/third_party/abseil-cpp/absl/container/internal/common.h +43 -0
- data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -2
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +9 -10
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +1 -8
- data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +0 -4
- data/third_party/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +527 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +20 -4
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +31 -12
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +2 -7
- data/third_party/abseil-cpp/absl/container/internal/layout.h +26 -42
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +199 -68
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +1354 -183
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +881 -1424
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set_resize_impl.h +80 -0
- data/third_party/abseil-cpp/absl/crc/crc32c.cc +0 -4
- data/third_party/abseil-cpp/absl/crc/crc32c.h +7 -5
- data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +0 -22
- data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +45 -74
- data/third_party/abseil-cpp/absl/debugging/internal/addresses.h +57 -0
- data/third_party/abseil-cpp/absl/debugging/internal/decode_rust_punycode.cc +1 -1
- data/third_party/abseil-cpp/absl/debugging/internal/decode_rust_punycode.h +5 -5
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +8 -35
- data/third_party/abseil-cpp/absl/debugging/internal/demangle_rust.cc +16 -16
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +40 -37
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +16 -7
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +14 -5
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +10 -4
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +27 -16
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +13 -4
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +4 -3
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +15 -28
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +19 -9
- data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +144 -27
- data/third_party/abseil-cpp/absl/debugging/stacktrace.h +73 -5
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +19 -9
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +3 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +25 -6
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +2 -2
- data/third_party/abseil-cpp/absl/flags/flag.h +4 -3
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +2 -2
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +2 -1
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +7 -6
- data/third_party/abseil-cpp/absl/flags/internal/registry.h +4 -3
- data/third_party/abseil-cpp/absl/flags/reflection.cc +2 -3
- data/third_party/abseil-cpp/absl/functional/any_invocable.h +8 -10
- data/third_party/abseil-cpp/absl/functional/function_ref.h +2 -9
- data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +110 -226
- data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +10 -12
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +2 -5
- data/third_party/abseil-cpp/absl/hash/hash.h +18 -0
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +1 -5
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -61
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +25 -68
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.h +2 -6
- data/third_party/abseil-cpp/absl/hash/internal/weakly_mixed_integer.h +38 -0
- data/third_party/abseil-cpp/absl/log/check.h +2 -1
- data/third_party/abseil-cpp/absl/log/globals.h +4 -5
- data/third_party/abseil-cpp/absl/log/internal/append_truncated.h +28 -0
- data/third_party/abseil-cpp/absl/log/internal/check_op.cc +22 -22
- data/third_party/abseil-cpp/absl/log/internal/check_op.h +65 -62
- data/third_party/abseil-cpp/absl/log/internal/conditions.cc +5 -3
- data/third_party/abseil-cpp/absl/log/internal/conditions.h +7 -2
- data/third_party/abseil-cpp/absl/log/internal/log_message.cc +85 -43
- data/third_party/abseil-cpp/absl/log/internal/log_message.h +84 -59
- data/third_party/abseil-cpp/absl/log/internal/nullstream.h +1 -0
- data/third_party/abseil-cpp/absl/log/internal/proto.cc +3 -2
- data/third_party/abseil-cpp/absl/log/internal/proto.h +3 -3
- data/third_party/abseil-cpp/absl/log/internal/strip.h +4 -12
- data/third_party/abseil-cpp/absl/log/internal/vlog_config.h +8 -6
- data/third_party/abseil-cpp/absl/log/internal/voidify.h +10 -4
- data/third_party/abseil-cpp/absl/log/log.h +48 -35
- data/third_party/abseil-cpp/absl/log/log_sink_registry.h +2 -2
- data/third_party/abseil-cpp/absl/meta/type_traits.h +46 -175
- data/third_party/abseil-cpp/absl/numeric/bits.h +68 -2
- data/third_party/abseil-cpp/absl/numeric/int128.cc +0 -52
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +7 -3
- data/third_party/abseil-cpp/absl/profiling/internal/exponential_biased.cc +1 -1
- data/third_party/abseil-cpp/absl/random/bit_gen_ref.h +10 -11
- data/third_party/abseil-cpp/absl/random/distributions.h +6 -8
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +5 -6
- data/third_party/abseil-cpp/absl/random/internal/{pool_urbg.cc → entropy_pool.cc} +22 -90
- data/third_party/abseil-cpp/absl/random/internal/entropy_pool.h +35 -0
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +5 -6
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +1 -1
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +20 -12
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +5 -5
- data/third_party/abseil-cpp/absl/random/random.h +88 -53
- data/third_party/abseil-cpp/absl/random/seed_sequences.cc +6 -2
- data/third_party/abseil-cpp/absl/status/internal/status_internal.cc +3 -4
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +3 -4
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -3
- data/third_party/abseil-cpp/absl/status/status.cc +4 -8
- data/third_party/abseil-cpp/absl/status/status.h +8 -8
- data/third_party/abseil-cpp/absl/status/status_payload_printer.h +2 -2
- data/third_party/abseil-cpp/absl/status/statusor.cc +2 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +6 -6
- data/third_party/abseil-cpp/absl/strings/ascii.cc +9 -9
- data/third_party/abseil-cpp/absl/strings/ascii.h +18 -18
- data/third_party/abseil-cpp/absl/strings/charconv.cc +21 -22
- data/third_party/abseil-cpp/absl/strings/charconv.h +5 -5
- data/third_party/abseil-cpp/absl/strings/cord.cc +54 -58
- data/third_party/abseil-cpp/absl/strings/cord.h +94 -83
- data/third_party/abseil-cpp/absl/strings/cord_analysis.cc +11 -11
- data/third_party/abseil-cpp/absl/strings/cord_analysis.h +3 -3
- data/third_party/abseil-cpp/absl/strings/escaping.cc +130 -149
- data/third_party/abseil-cpp/absl/strings/escaping.h +9 -10
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +6 -8
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +0 -4
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +0 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +7 -63
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +1 -11
- data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +0 -22
- data/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc +5 -3
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +4 -2
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +3 -3
- data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +0 -5
- data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +96 -1
- data/third_party/abseil-cpp/absl/strings/internal/utf8.h +15 -1
- data/third_party/abseil-cpp/absl/strings/numbers.cc +53 -32
- data/third_party/abseil-cpp/absl/strings/numbers.h +87 -58
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +6 -7
- data/third_party/abseil-cpp/absl/strings/str_cat.h +32 -32
- data/third_party/abseil-cpp/absl/strings/str_format.h +18 -18
- data/third_party/abseil-cpp/absl/strings/str_replace.cc +3 -3
- data/third_party/abseil-cpp/absl/strings/str_replace.h +6 -6
- data/third_party/abseil-cpp/absl/strings/string_view.cc +4 -9
- data/third_party/abseil-cpp/absl/strings/string_view.h +27 -32
- data/third_party/abseil-cpp/absl/strings/strip.h +4 -4
- data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -4
- data/third_party/abseil-cpp/absl/strings/substitute.h +66 -64
- data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc +0 -5
- data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +1 -1
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +97 -69
- data/third_party/abseil-cpp/absl/synchronization/notification.h +1 -1
- data/third_party/abseil-cpp/absl/time/civil_time.cc +1 -0
- data/third_party/abseil-cpp/absl/time/duration.cc +12 -7
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +90 -111
- data/third_party/abseil-cpp/absl/time/time.h +20 -15
- data/third_party/abseil-cpp/absl/types/optional.h +7 -747
- data/third_party/abseil-cpp/absl/types/span.h +13 -11
- data/third_party/abseil-cpp/absl/types/variant.h +5 -784
- data/third_party/abseil-cpp/absl/utility/utility.h +10 -185
- data/third_party/cares/cares/include/ares.h +925 -460
- data/third_party/cares/cares/include/ares_dns.h +86 -71
- data/third_party/cares/cares/include/ares_dns_record.h +1118 -0
- data/third_party/cares/cares/include/ares_nameser.h +215 -189
- data/third_party/cares/cares/include/ares_version.h +37 -14
- data/third_party/cares/cares/src/lib/ares_addrinfo2hostent.c +305 -0
- data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +245 -0
- data/third_party/cares/cares/src/lib/ares_android.c +216 -164
- data/third_party/cares/cares/src/lib/ares_android.h +25 -14
- data/third_party/cares/cares/src/lib/ares_cancel.c +68 -44
- data/third_party/cares/cares/src/lib/ares_close_sockets.c +137 -0
- data/third_party/cares/cares/src/lib/ares_conn.c +511 -0
- data/third_party/cares/cares/src/lib/ares_conn.h +196 -0
- data/third_party/cares/cares/src/lib/ares_cookie.c +461 -0
- data/third_party/cares/cares/src/lib/ares_data.c +93 -181
- data/third_party/cares/cares/src/lib/ares_data.h +50 -39
- data/third_party/cares/cares/src/lib/ares_destroy.c +127 -89
- data/third_party/cares/cares/src/lib/ares_free_hostent.c +35 -24
- data/third_party/cares/cares/src/lib/ares_free_string.c +24 -16
- data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +45 -38
- data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +549 -663
- data/third_party/cares/cares/src/lib/ares_getenv.c +25 -15
- data/third_party/cares/cares/src/lib/ares_getenv.h +26 -18
- data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +163 -221
- data/third_party/cares/cares/src/lib/ares_gethostbyname.c +222 -223
- data/third_party/cares/cares/src/lib/ares_getnameinfo.c +328 -338
- data/third_party/cares/cares/src/lib/ares_hosts_file.c +952 -0
- data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +25 -19
- data/third_party/cares/cares/src/lib/ares_init.c +425 -2091
- data/third_party/cares/cares/src/lib/ares_ipv6.h +63 -33
- data/third_party/cares/cares/src/lib/ares_library_init.c +110 -54
- data/third_party/cares/cares/src/lib/ares_metrics.c +261 -0
- data/third_party/cares/cares/src/lib/ares_options.c +418 -332
- data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +179 -0
- data/third_party/cares/cares/src/lib/ares_private.h +558 -356
- data/third_party/cares/cares/src/lib/ares_process.c +1224 -1369
- data/third_party/cares/cares/src/lib/ares_qcache.c +430 -0
- data/third_party/cares/cares/src/lib/ares_query.c +126 -121
- data/third_party/cares/cares/src/lib/ares_search.c +564 -262
- data/third_party/cares/cares/src/lib/ares_send.c +264 -93
- data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +588 -0
- data/third_party/cares/cares/src/lib/ares_setup.h +115 -111
- data/third_party/cares/cares/src/lib/ares_socket.c +425 -0
- data/third_party/cares/cares/src/lib/ares_socket.h +163 -0
- data/third_party/cares/cares/src/lib/ares_sortaddrinfo.c +447 -0
- data/third_party/cares/cares/src/lib/ares_strerror.c +83 -48
- data/third_party/cares/cares/src/lib/ares_sysconfig.c +639 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +839 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_mac.c +373 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +621 -0
- data/third_party/cares/cares/src/lib/ares_timeout.c +136 -73
- data/third_party/cares/cares/src/lib/ares_update_servers.c +1362 -0
- data/third_party/cares/cares/src/lib/ares_version.c +29 -4
- data/third_party/cares/cares/src/lib/config-dos.h +88 -89
- data/third_party/cares/cares/src/lib/config-win32.h +122 -77
- data/third_party/cares/cares/src/lib/dsa/ares_array.c +394 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.c +447 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.h +174 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_asvp.c +224 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +228 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_strvp.c +210 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_szvp.c +188 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpstr.c +186 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpvp.c +194 -0
- data/third_party/cares/cares/src/lib/dsa/ares_llist.c +382 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.c +479 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.h +207 -0
- data/third_party/cares/cares/src/lib/event/ares_event.h +191 -0
- data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +743 -0
- data/third_party/cares/cares/src/lib/event/ares_event_epoll.c +192 -0
- data/third_party/cares/cares/src/lib/event/ares_event_kqueue.c +248 -0
- data/third_party/cares/cares/src/lib/event/ares_event_poll.c +140 -0
- data/third_party/cares/cares/src/lib/event/ares_event_select.c +159 -0
- data/third_party/cares/cares/src/lib/event/ares_event_thread.c +567 -0
- data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +166 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.c +978 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.h +161 -0
- data/third_party/cares/cares/src/lib/include/ares_array.h +276 -0
- data/third_party/cares/cares/src/lib/include/ares_buf.h +732 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_asvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_dict.h +123 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_strvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_szvp.h +118 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpstr.h +111 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpvp.h +128 -0
- data/third_party/cares/cares/src/lib/include/ares_llist.h +239 -0
- data/third_party/cares/cares/src/lib/include/ares_mem.h +38 -0
- data/third_party/cares/cares/src/lib/include/ares_str.h +244 -0
- data/third_party/cares/cares/src/lib/inet_net_pton.c +202 -157
- data/third_party/cares/cares/src/lib/inet_ntop.c +87 -69
- data/third_party/cares/cares/src/lib/legacy/ares_create_query.c +78 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +99 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_string.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_fds.c +80 -0
- data/third_party/cares/cares/src/lib/legacy/ares_getsock.c +85 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +982 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +307 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.h +72 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_name.c +673 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +1329 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_private.h +273 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_record.c +1661 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_write.c +1229 -0
- data/third_party/cares/cares/src/lib/str/ares_buf.c +1498 -0
- data/third_party/cares/cares/src/lib/str/ares_str.c +508 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.c +90 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.h +51 -0
- data/third_party/cares/cares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +628 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +139 -0
- data/third_party/cares/cares/src/lib/util/ares_math.c +158 -0
- data/third_party/cares/cares/src/lib/util/ares_math.h +45 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.c +389 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.h +36 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.c +614 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.h +60 -0
- data/third_party/cares/cares/src/lib/util/ares_time.h +48 -0
- data/third_party/cares/cares/src/lib/util/ares_timeval.c +95 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.c +1626 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.h +252 -0
- data/third_party/cares/cares/src/lib/windows_port.c +16 -9
- metadata +192 -68
- data/src/core/lib/event_engine/forkable.cc +0 -105
- data/src/core/lib/event_engine/forkable.h +0 -67
- data/src/core/lib/iomgr/python_util.h +0 -46
- data/src/core/util/ring_buffer.h +0 -122
- data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +0 -108
- data/third_party/abseil-cpp/absl/base/internal/invoke.h +0 -241
- data/third_party/abseil-cpp/absl/log/log_entry.cc +0 -41
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +0 -131
- data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +0 -66
- data/third_party/abseil-cpp/absl/types/bad_optional_access.h +0 -78
- data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +0 -82
- data/third_party/abseil-cpp/absl/types/bad_variant_access.h +0 -82
- data/third_party/abseil-cpp/absl/types/internal/optional.h +0 -352
- data/third_party/abseil-cpp/absl/types/internal/variant.h +0 -1622
- data/third_party/cares/cares/include/ares_rules.h +0 -125
- data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +0 -266
- data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +0 -240
- data/third_party/cares/cares/src/lib/ares__close_sockets.c +0 -61
- data/third_party/cares/cares/src/lib/ares__get_hostent.c +0 -260
- data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +0 -229
- data/third_party/cares/cares/src/lib/ares__read_line.c +0 -73
- data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +0 -258
- data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +0 -507
- data/third_party/cares/cares/src/lib/ares__timeval.c +0 -111
- data/third_party/cares/cares/src/lib/ares_create_query.c +0 -197
- data/third_party/cares/cares/src/lib/ares_expand_name.c +0 -311
- data/third_party/cares/cares/src/lib/ares_expand_string.c +0 -67
- data/third_party/cares/cares/src/lib/ares_fds.c +0 -59
- data/third_party/cares/cares/src/lib/ares_getsock.c +0 -66
- data/third_party/cares/cares/src/lib/ares_iphlpapi.h +0 -221
- data/third_party/cares/cares/src/lib/ares_llist.c +0 -63
- data/third_party/cares/cares/src/lib/ares_llist.h +0 -39
- data/third_party/cares/cares/src/lib/ares_mkquery.c +0 -24
- data/third_party/cares/cares/src/lib/ares_nowarn.c +0 -260
- data/third_party/cares/cares/src/lib/ares_nowarn.h +0 -61
- data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +0 -90
- data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +0 -92
- data/third_party/cares/cares/src/lib/ares_parse_caa_reply.c +0 -199
- data/third_party/cares/cares/src/lib/ares_parse_mx_reply.c +0 -164
- data/third_party/cares/cares/src/lib/ares_parse_naptr_reply.c +0 -183
- data/third_party/cares/cares/src/lib/ares_parse_ns_reply.c +0 -177
- data/third_party/cares/cares/src/lib/ares_parse_ptr_reply.c +0 -228
- data/third_party/cares/cares/src/lib/ares_parse_soa_reply.c +0 -179
- data/third_party/cares/cares/src/lib/ares_parse_srv_reply.c +0 -168
- data/third_party/cares/cares/src/lib/ares_parse_txt_reply.c +0 -214
- data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +0 -184
- data/third_party/cares/cares/src/lib/ares_platform.c +0 -11042
- data/third_party/cares/cares/src/lib/ares_platform.h +0 -43
- data/third_party/cares/cares/src/lib/ares_rand.c +0 -279
- data/third_party/cares/cares/src/lib/ares_strcasecmp.c +0 -66
- data/third_party/cares/cares/src/lib/ares_strcasecmp.h +0 -30
- data/third_party/cares/cares/src/lib/ares_strdup.c +0 -42
- data/third_party/cares/cares/src/lib/ares_strdup.h +0 -24
- data/third_party/cares/cares/src/lib/ares_strsplit.c +0 -94
- data/third_party/cares/cares/src/lib/ares_strsplit.h +0 -42
- data/third_party/cares/cares/src/lib/ares_writev.c +0 -79
- data/third_party/cares/cares/src/lib/ares_writev.h +0 -36
- data/third_party/cares/cares/src/lib/bitncmp.c +0 -59
- data/third_party/cares/cares/src/lib/bitncmp.h +0 -26
- data/third_party/cares/cares/src/lib/setup_once.h +0 -554
- data/third_party/cares/cares/src/tools/ares_getopt.h +0 -53
@@ -0,0 +1,1229 @@
|
|
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
|
+
#include "ares_private.h"
|
27
|
+
#include <limits.h>
|
28
|
+
#ifdef HAVE_STDINT_H
|
29
|
+
# include <stdint.h>
|
30
|
+
#endif
|
31
|
+
|
32
|
+
|
33
|
+
static ares_status_t ares_dns_write_header(const ares_dns_record_t *dnsrec,
|
34
|
+
ares_buf_t *buf)
|
35
|
+
{
|
36
|
+
unsigned short u16;
|
37
|
+
unsigned short opcode;
|
38
|
+
unsigned short rcode;
|
39
|
+
|
40
|
+
ares_status_t status;
|
41
|
+
|
42
|
+
/* ID */
|
43
|
+
status = ares_buf_append_be16(buf, dnsrec->id);
|
44
|
+
if (status != ARES_SUCCESS) {
|
45
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
46
|
+
}
|
47
|
+
|
48
|
+
/* Flags */
|
49
|
+
u16 = 0;
|
50
|
+
|
51
|
+
/* QR */
|
52
|
+
if (dnsrec->flags & ARES_FLAG_QR) {
|
53
|
+
u16 |= 0x8000;
|
54
|
+
}
|
55
|
+
|
56
|
+
/* OPCODE */
|
57
|
+
opcode = (unsigned short)(dnsrec->opcode & 0xF);
|
58
|
+
opcode <<= 11;
|
59
|
+
u16 |= opcode;
|
60
|
+
|
61
|
+
/* AA */
|
62
|
+
if (dnsrec->flags & ARES_FLAG_AA) {
|
63
|
+
u16 |= 0x400;
|
64
|
+
}
|
65
|
+
|
66
|
+
/* TC */
|
67
|
+
if (dnsrec->flags & ARES_FLAG_TC) {
|
68
|
+
u16 |= 0x200;
|
69
|
+
}
|
70
|
+
|
71
|
+
/* RD */
|
72
|
+
if (dnsrec->flags & ARES_FLAG_RD) {
|
73
|
+
u16 |= 0x100;
|
74
|
+
}
|
75
|
+
|
76
|
+
/* RA */
|
77
|
+
if (dnsrec->flags & ARES_FLAG_RA) {
|
78
|
+
u16 |= 0x80;
|
79
|
+
}
|
80
|
+
|
81
|
+
/* Z -- unused */
|
82
|
+
|
83
|
+
/* AD */
|
84
|
+
if (dnsrec->flags & ARES_FLAG_AD) {
|
85
|
+
u16 |= 0x20;
|
86
|
+
}
|
87
|
+
|
88
|
+
/* CD */
|
89
|
+
if (dnsrec->flags & ARES_FLAG_CD) {
|
90
|
+
u16 |= 0x10;
|
91
|
+
}
|
92
|
+
|
93
|
+
/* RCODE */
|
94
|
+
if (dnsrec->rcode > 15 && ares_dns_get_opt_rr_const(dnsrec) == NULL) {
|
95
|
+
/* Must have OPT RR in order to write extended error codes */
|
96
|
+
rcode = ARES_RCODE_SERVFAIL;
|
97
|
+
} else {
|
98
|
+
rcode = (unsigned short)(dnsrec->rcode & 0xF);
|
99
|
+
}
|
100
|
+
u16 |= rcode;
|
101
|
+
|
102
|
+
status = ares_buf_append_be16(buf, u16);
|
103
|
+
if (status != ARES_SUCCESS) {
|
104
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
105
|
+
}
|
106
|
+
|
107
|
+
/* QDCOUNT */
|
108
|
+
status = ares_buf_append_be16(
|
109
|
+
buf, (unsigned short)ares_dns_record_query_cnt(dnsrec));
|
110
|
+
if (status != ARES_SUCCESS) {
|
111
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
112
|
+
}
|
113
|
+
|
114
|
+
/* ANCOUNT */
|
115
|
+
status = ares_buf_append_be16(
|
116
|
+
buf, (unsigned short)ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER));
|
117
|
+
if (status != ARES_SUCCESS) {
|
118
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
119
|
+
}
|
120
|
+
|
121
|
+
/* NSCOUNT */
|
122
|
+
status = ares_buf_append_be16(buf, (unsigned short)ares_dns_record_rr_cnt(
|
123
|
+
dnsrec, ARES_SECTION_AUTHORITY));
|
124
|
+
if (status != ARES_SUCCESS) {
|
125
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
126
|
+
}
|
127
|
+
|
128
|
+
/* ARCOUNT */
|
129
|
+
status = ares_buf_append_be16(buf, (unsigned short)ares_dns_record_rr_cnt(
|
130
|
+
dnsrec, ARES_SECTION_ADDITIONAL));
|
131
|
+
if (status != ARES_SUCCESS) {
|
132
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
133
|
+
}
|
134
|
+
|
135
|
+
return ARES_SUCCESS;
|
136
|
+
}
|
137
|
+
|
138
|
+
static ares_status_t ares_dns_write_questions(const ares_dns_record_t *dnsrec,
|
139
|
+
ares_llist_t **namelist,
|
140
|
+
ares_buf_t *buf)
|
141
|
+
{
|
142
|
+
size_t i;
|
143
|
+
|
144
|
+
for (i = 0; i < ares_dns_record_query_cnt(dnsrec); i++) {
|
145
|
+
ares_status_t status;
|
146
|
+
const char *name = NULL;
|
147
|
+
ares_dns_rec_type_t qtype;
|
148
|
+
ares_dns_class_t qclass;
|
149
|
+
|
150
|
+
status = ares_dns_record_query_get(dnsrec, i, &name, &qtype, &qclass);
|
151
|
+
if (status != ARES_SUCCESS) {
|
152
|
+
return status;
|
153
|
+
}
|
154
|
+
|
155
|
+
/* Name */
|
156
|
+
status = ares_dns_name_write(buf, namelist, ARES_TRUE, name);
|
157
|
+
if (status != ARES_SUCCESS) {
|
158
|
+
return status;
|
159
|
+
}
|
160
|
+
|
161
|
+
/* Type */
|
162
|
+
status = ares_buf_append_be16(buf, (unsigned short)qtype);
|
163
|
+
if (status != ARES_SUCCESS) {
|
164
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
165
|
+
}
|
166
|
+
|
167
|
+
/* Class */
|
168
|
+
status = ares_buf_append_be16(buf, (unsigned short)qclass);
|
169
|
+
if (status != ARES_SUCCESS) {
|
170
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
return ARES_SUCCESS;
|
175
|
+
}
|
176
|
+
|
177
|
+
static ares_status_t ares_dns_write_rr_name(ares_buf_t *buf,
|
178
|
+
const ares_dns_rr_t *rr,
|
179
|
+
ares_llist_t **namelist,
|
180
|
+
ares_bool_t validate_hostname,
|
181
|
+
ares_dns_rr_key_t key)
|
182
|
+
{
|
183
|
+
const char *name;
|
184
|
+
|
185
|
+
name = ares_dns_rr_get_str(rr, key);
|
186
|
+
if (name == NULL) {
|
187
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
188
|
+
}
|
189
|
+
|
190
|
+
return ares_dns_name_write(buf, namelist, validate_hostname, name);
|
191
|
+
}
|
192
|
+
|
193
|
+
static ares_status_t ares_dns_write_rr_str(ares_buf_t *buf,
|
194
|
+
const ares_dns_rr_t *rr,
|
195
|
+
ares_dns_rr_key_t key)
|
196
|
+
{
|
197
|
+
const char *str;
|
198
|
+
size_t len;
|
199
|
+
ares_status_t status;
|
200
|
+
|
201
|
+
str = ares_dns_rr_get_str(rr, key);
|
202
|
+
if (str == NULL) {
|
203
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
204
|
+
}
|
205
|
+
|
206
|
+
len = ares_strlen(str);
|
207
|
+
if (len > 255) {
|
208
|
+
return ARES_EFORMERR;
|
209
|
+
}
|
210
|
+
|
211
|
+
/* Write 1 byte length */
|
212
|
+
status = ares_buf_append_byte(buf, (unsigned char)(len & 0xFF));
|
213
|
+
if (status != ARES_SUCCESS) {
|
214
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
215
|
+
}
|
216
|
+
|
217
|
+
if (len == 0) {
|
218
|
+
return ARES_SUCCESS;
|
219
|
+
}
|
220
|
+
|
221
|
+
/* Write string */
|
222
|
+
return ares_buf_append(buf, (const unsigned char *)str, len);
|
223
|
+
}
|
224
|
+
|
225
|
+
static ares_status_t ares_dns_write_binstr(ares_buf_t *buf,
|
226
|
+
const unsigned char *bin,
|
227
|
+
size_t bin_len)
|
228
|
+
{
|
229
|
+
const unsigned char *ptr;
|
230
|
+
size_t ptr_len;
|
231
|
+
ares_status_t status;
|
232
|
+
|
233
|
+
/* split into possible multiple 255-byte or less length strings */
|
234
|
+
ptr = bin;
|
235
|
+
ptr_len = bin_len;
|
236
|
+
do {
|
237
|
+
size_t len = ptr_len;
|
238
|
+
if (len > 255) {
|
239
|
+
len = 255;
|
240
|
+
}
|
241
|
+
|
242
|
+
/* Length */
|
243
|
+
status = ares_buf_append_byte(buf, (unsigned char)(len & 0xFF));
|
244
|
+
if (status != ARES_SUCCESS) {
|
245
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
246
|
+
}
|
247
|
+
|
248
|
+
/* String */
|
249
|
+
if (len) {
|
250
|
+
status = ares_buf_append(buf, ptr, len);
|
251
|
+
if (status != ARES_SUCCESS) {
|
252
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
ptr += len;
|
257
|
+
ptr_len -= len;
|
258
|
+
} while (ptr_len > 0);
|
259
|
+
|
260
|
+
return ARES_SUCCESS;
|
261
|
+
}
|
262
|
+
|
263
|
+
static ares_status_t ares_dns_write_rr_abin(ares_buf_t *buf,
|
264
|
+
const ares_dns_rr_t *rr,
|
265
|
+
ares_dns_rr_key_t key)
|
266
|
+
{
|
267
|
+
ares_status_t status = ARES_EFORMERR;
|
268
|
+
size_t i;
|
269
|
+
size_t cnt = ares_dns_rr_get_abin_cnt(rr, key);
|
270
|
+
|
271
|
+
if (cnt == 0) {
|
272
|
+
return ARES_EFORMERR;
|
273
|
+
}
|
274
|
+
|
275
|
+
for (i = 0; i < cnt; i++) {
|
276
|
+
const unsigned char *bin;
|
277
|
+
size_t bin_len;
|
278
|
+
|
279
|
+
bin = ares_dns_rr_get_abin(rr, key, i, &bin_len);
|
280
|
+
|
281
|
+
status = ares_dns_write_binstr(buf, bin, bin_len);
|
282
|
+
if (status != ARES_SUCCESS) {
|
283
|
+
break;
|
284
|
+
}
|
285
|
+
}
|
286
|
+
|
287
|
+
return status;
|
288
|
+
}
|
289
|
+
|
290
|
+
static ares_status_t ares_dns_write_rr_be32(ares_buf_t *buf,
|
291
|
+
const ares_dns_rr_t *rr,
|
292
|
+
ares_dns_rr_key_t key)
|
293
|
+
{
|
294
|
+
if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U32) {
|
295
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
296
|
+
}
|
297
|
+
return ares_buf_append_be32(buf, ares_dns_rr_get_u32(rr, key));
|
298
|
+
}
|
299
|
+
|
300
|
+
static ares_status_t ares_dns_write_rr_be16(ares_buf_t *buf,
|
301
|
+
const ares_dns_rr_t *rr,
|
302
|
+
ares_dns_rr_key_t key)
|
303
|
+
{
|
304
|
+
if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U16) {
|
305
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
306
|
+
}
|
307
|
+
return ares_buf_append_be16(buf, ares_dns_rr_get_u16(rr, key));
|
308
|
+
}
|
309
|
+
|
310
|
+
static ares_status_t ares_dns_write_rr_u8(ares_buf_t *buf,
|
311
|
+
const ares_dns_rr_t *rr,
|
312
|
+
ares_dns_rr_key_t key)
|
313
|
+
{
|
314
|
+
if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U8) {
|
315
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
316
|
+
}
|
317
|
+
return ares_buf_append_byte(buf, ares_dns_rr_get_u8(rr, key));
|
318
|
+
}
|
319
|
+
|
320
|
+
static ares_status_t ares_dns_write_rr_a(ares_buf_t *buf,
|
321
|
+
const ares_dns_rr_t *rr,
|
322
|
+
ares_llist_t **namelist)
|
323
|
+
{
|
324
|
+
const struct in_addr *addr;
|
325
|
+
(void)namelist;
|
326
|
+
|
327
|
+
addr = ares_dns_rr_get_addr(rr, ARES_RR_A_ADDR);
|
328
|
+
if (addr == NULL) {
|
329
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
330
|
+
}
|
331
|
+
|
332
|
+
return ares_buf_append(buf, (const unsigned char *)addr, sizeof(*addr));
|
333
|
+
}
|
334
|
+
|
335
|
+
static ares_status_t ares_dns_write_rr_ns(ares_buf_t *buf,
|
336
|
+
const ares_dns_rr_t *rr,
|
337
|
+
ares_llist_t **namelist)
|
338
|
+
{
|
339
|
+
return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
|
340
|
+
ARES_RR_NS_NSDNAME);
|
341
|
+
}
|
342
|
+
|
343
|
+
static ares_status_t ares_dns_write_rr_cname(ares_buf_t *buf,
|
344
|
+
const ares_dns_rr_t *rr,
|
345
|
+
ares_llist_t **namelist)
|
346
|
+
{
|
347
|
+
return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
|
348
|
+
ARES_RR_CNAME_CNAME);
|
349
|
+
}
|
350
|
+
|
351
|
+
static ares_status_t ares_dns_write_rr_soa(ares_buf_t *buf,
|
352
|
+
const ares_dns_rr_t *rr,
|
353
|
+
ares_llist_t **namelist)
|
354
|
+
{
|
355
|
+
ares_status_t status;
|
356
|
+
|
357
|
+
/* MNAME */
|
358
|
+
status =
|
359
|
+
ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_SOA_MNAME);
|
360
|
+
if (status != ARES_SUCCESS) {
|
361
|
+
return status;
|
362
|
+
}
|
363
|
+
|
364
|
+
/* RNAME */
|
365
|
+
status =
|
366
|
+
ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_SOA_RNAME);
|
367
|
+
if (status != ARES_SUCCESS) {
|
368
|
+
return status;
|
369
|
+
}
|
370
|
+
|
371
|
+
/* SERIAL */
|
372
|
+
status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_SERIAL);
|
373
|
+
if (status != ARES_SUCCESS) {
|
374
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
375
|
+
}
|
376
|
+
|
377
|
+
/* REFRESH */
|
378
|
+
status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_REFRESH);
|
379
|
+
if (status != ARES_SUCCESS) {
|
380
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
381
|
+
}
|
382
|
+
|
383
|
+
/* RETRY */
|
384
|
+
status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_RETRY);
|
385
|
+
if (status != ARES_SUCCESS) {
|
386
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
387
|
+
}
|
388
|
+
|
389
|
+
/* EXPIRE */
|
390
|
+
status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_EXPIRE);
|
391
|
+
if (status != ARES_SUCCESS) {
|
392
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
393
|
+
}
|
394
|
+
|
395
|
+
/* MINIMUM */
|
396
|
+
return ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_MINIMUM);
|
397
|
+
}
|
398
|
+
|
399
|
+
static ares_status_t ares_dns_write_rr_ptr(ares_buf_t *buf,
|
400
|
+
const ares_dns_rr_t *rr,
|
401
|
+
ares_llist_t **namelist)
|
402
|
+
{
|
403
|
+
return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
|
404
|
+
ARES_RR_PTR_DNAME);
|
405
|
+
}
|
406
|
+
|
407
|
+
static ares_status_t ares_dns_write_rr_hinfo(ares_buf_t *buf,
|
408
|
+
const ares_dns_rr_t *rr,
|
409
|
+
ares_llist_t **namelist)
|
410
|
+
{
|
411
|
+
ares_status_t status;
|
412
|
+
|
413
|
+
(void)namelist;
|
414
|
+
|
415
|
+
/* CPU */
|
416
|
+
status = ares_dns_write_rr_str(buf, rr, ARES_RR_HINFO_CPU);
|
417
|
+
if (status != ARES_SUCCESS) {
|
418
|
+
return status;
|
419
|
+
}
|
420
|
+
|
421
|
+
/* OS */
|
422
|
+
return ares_dns_write_rr_str(buf, rr, ARES_RR_HINFO_OS);
|
423
|
+
}
|
424
|
+
|
425
|
+
static ares_status_t ares_dns_write_rr_mx(ares_buf_t *buf,
|
426
|
+
const ares_dns_rr_t *rr,
|
427
|
+
ares_llist_t **namelist)
|
428
|
+
{
|
429
|
+
ares_status_t status;
|
430
|
+
|
431
|
+
/* PREFERENCE */
|
432
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_MX_PREFERENCE);
|
433
|
+
if (status != ARES_SUCCESS) {
|
434
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
435
|
+
}
|
436
|
+
|
437
|
+
/* EXCHANGE */
|
438
|
+
return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
|
439
|
+
ARES_RR_MX_EXCHANGE);
|
440
|
+
}
|
441
|
+
|
442
|
+
static ares_status_t ares_dns_write_rr_txt(ares_buf_t *buf,
|
443
|
+
const ares_dns_rr_t *rr,
|
444
|
+
ares_llist_t **namelist)
|
445
|
+
{
|
446
|
+
(void)namelist;
|
447
|
+
return ares_dns_write_rr_abin(buf, rr, ARES_RR_TXT_DATA);
|
448
|
+
}
|
449
|
+
|
450
|
+
static ares_status_t ares_dns_write_rr_sig(ares_buf_t *buf,
|
451
|
+
const ares_dns_rr_t *rr,
|
452
|
+
ares_llist_t **namelist)
|
453
|
+
{
|
454
|
+
ares_status_t status;
|
455
|
+
const unsigned char *data;
|
456
|
+
size_t len = 0;
|
457
|
+
|
458
|
+
(void)namelist;
|
459
|
+
|
460
|
+
/* TYPE COVERED */
|
461
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SIG_TYPE_COVERED);
|
462
|
+
if (status != ARES_SUCCESS) {
|
463
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
464
|
+
}
|
465
|
+
|
466
|
+
/* ALGORITHM */
|
467
|
+
status = ares_dns_write_rr_u8(buf, rr, ARES_RR_SIG_ALGORITHM);
|
468
|
+
if (status != ARES_SUCCESS) {
|
469
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
470
|
+
}
|
471
|
+
|
472
|
+
/* LABELS */
|
473
|
+
status = ares_dns_write_rr_u8(buf, rr, ARES_RR_SIG_LABELS);
|
474
|
+
if (status != ARES_SUCCESS) {
|
475
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
476
|
+
}
|
477
|
+
|
478
|
+
/* ORIGINAL TTL */
|
479
|
+
status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_ORIGINAL_TTL);
|
480
|
+
if (status != ARES_SUCCESS) {
|
481
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
482
|
+
}
|
483
|
+
|
484
|
+
/* EXPIRATION */
|
485
|
+
status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_EXPIRATION);
|
486
|
+
if (status != ARES_SUCCESS) {
|
487
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
488
|
+
}
|
489
|
+
|
490
|
+
/* INCEPTION */
|
491
|
+
status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_INCEPTION);
|
492
|
+
if (status != ARES_SUCCESS) {
|
493
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
494
|
+
}
|
495
|
+
|
496
|
+
/* KEY TAG */
|
497
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SIG_KEY_TAG);
|
498
|
+
if (status != ARES_SUCCESS) {
|
499
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
500
|
+
}
|
501
|
+
|
502
|
+
/* SIGNERS NAME */
|
503
|
+
status = ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
|
504
|
+
ARES_RR_SIG_SIGNERS_NAME);
|
505
|
+
if (status != ARES_SUCCESS) {
|
506
|
+
return status;
|
507
|
+
}
|
508
|
+
|
509
|
+
/* SIGNATURE -- binary, rest of buffer, required to be non-zero length */
|
510
|
+
data = ares_dns_rr_get_bin(rr, ARES_RR_SIG_SIGNATURE, &len);
|
511
|
+
if (data == NULL || len == 0) {
|
512
|
+
return ARES_EFORMERR;
|
513
|
+
}
|
514
|
+
|
515
|
+
return ares_buf_append(buf, data, len);
|
516
|
+
}
|
517
|
+
|
518
|
+
static ares_status_t ares_dns_write_rr_aaaa(ares_buf_t *buf,
|
519
|
+
const ares_dns_rr_t *rr,
|
520
|
+
ares_llist_t **namelist)
|
521
|
+
{
|
522
|
+
const struct ares_in6_addr *addr;
|
523
|
+
(void)namelist;
|
524
|
+
|
525
|
+
addr = ares_dns_rr_get_addr6(rr, ARES_RR_AAAA_ADDR);
|
526
|
+
if (addr == NULL) {
|
527
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
528
|
+
}
|
529
|
+
|
530
|
+
return ares_buf_append(buf, (const unsigned char *)addr, sizeof(*addr));
|
531
|
+
}
|
532
|
+
|
533
|
+
static ares_status_t ares_dns_write_rr_srv(ares_buf_t *buf,
|
534
|
+
const ares_dns_rr_t *rr,
|
535
|
+
ares_llist_t **namelist)
|
536
|
+
{
|
537
|
+
ares_status_t status;
|
538
|
+
|
539
|
+
/* PRIORITY */
|
540
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_PRIORITY);
|
541
|
+
if (status != ARES_SUCCESS) {
|
542
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
543
|
+
}
|
544
|
+
|
545
|
+
/* WEIGHT */
|
546
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_WEIGHT);
|
547
|
+
if (status != ARES_SUCCESS) {
|
548
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
549
|
+
}
|
550
|
+
|
551
|
+
/* PORT */
|
552
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_PORT);
|
553
|
+
if (status != ARES_SUCCESS) {
|
554
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
555
|
+
}
|
556
|
+
|
557
|
+
/* TARGET */
|
558
|
+
return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
|
559
|
+
ARES_RR_SRV_TARGET);
|
560
|
+
}
|
561
|
+
|
562
|
+
static ares_status_t ares_dns_write_rr_naptr(ares_buf_t *buf,
|
563
|
+
const ares_dns_rr_t *rr,
|
564
|
+
ares_llist_t **namelist)
|
565
|
+
{
|
566
|
+
ares_status_t status;
|
567
|
+
|
568
|
+
/* ORDER */
|
569
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_NAPTR_ORDER);
|
570
|
+
if (status != ARES_SUCCESS) {
|
571
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
572
|
+
}
|
573
|
+
|
574
|
+
/* PREFERENCE */
|
575
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_NAPTR_PREFERENCE);
|
576
|
+
if (status != ARES_SUCCESS) {
|
577
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
578
|
+
}
|
579
|
+
|
580
|
+
/* FLAGS */
|
581
|
+
status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_FLAGS);
|
582
|
+
if (status != ARES_SUCCESS) {
|
583
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
584
|
+
}
|
585
|
+
|
586
|
+
/* SERVICES */
|
587
|
+
status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_SERVICES);
|
588
|
+
if (status != ARES_SUCCESS) {
|
589
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
590
|
+
}
|
591
|
+
|
592
|
+
/* REGEXP */
|
593
|
+
status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_REGEXP);
|
594
|
+
if (status != ARES_SUCCESS) {
|
595
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
596
|
+
}
|
597
|
+
|
598
|
+
/* REPLACEMENT */
|
599
|
+
return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
|
600
|
+
ARES_RR_NAPTR_REPLACEMENT);
|
601
|
+
}
|
602
|
+
|
603
|
+
static ares_status_t ares_dns_write_rr_opt(ares_buf_t *buf,
|
604
|
+
const ares_dns_rr_t *rr,
|
605
|
+
ares_llist_t **namelist)
|
606
|
+
{
|
607
|
+
size_t len = ares_buf_len(buf);
|
608
|
+
ares_status_t status;
|
609
|
+
unsigned int ttl = 0;
|
610
|
+
size_t i;
|
611
|
+
unsigned short rcode = (unsigned short)((rr->parent->rcode >> 4) & 0xFF);
|
612
|
+
|
613
|
+
(void)namelist;
|
614
|
+
|
615
|
+
/* Coverity reports on this even though its not possible when taken
|
616
|
+
* into context */
|
617
|
+
if (len == 0) {
|
618
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
619
|
+
}
|
620
|
+
|
621
|
+
/* We need to go back and overwrite the class and ttl that were emitted as
|
622
|
+
* the OPT record overloads them for its own use (yes, very strange!) */
|
623
|
+
status = ares_buf_set_length(buf, len - 2 /* RDLENGTH */
|
624
|
+
- 4 /* TTL */
|
625
|
+
- 2 /* CLASS */);
|
626
|
+
if (status != ARES_SUCCESS) {
|
627
|
+
return status;
|
628
|
+
}
|
629
|
+
|
630
|
+
/* Class -> UDP Size */
|
631
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_OPT_UDP_SIZE);
|
632
|
+
if (status != ARES_SUCCESS) {
|
633
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
634
|
+
}
|
635
|
+
|
636
|
+
/* TTL -> rcode (u8) << 24 | version (u8) << 16 | flags (u16) */
|
637
|
+
ttl |= (unsigned int)rcode << 24;
|
638
|
+
ttl |= (unsigned int)ares_dns_rr_get_u8(rr, ARES_RR_OPT_VERSION) << 16;
|
639
|
+
ttl |= (unsigned int)ares_dns_rr_get_u16(rr, ARES_RR_OPT_FLAGS);
|
640
|
+
|
641
|
+
status = ares_buf_append_be32(buf, ttl);
|
642
|
+
if (status != ARES_SUCCESS) {
|
643
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
644
|
+
}
|
645
|
+
|
646
|
+
/* Now go back to real end */
|
647
|
+
status = ares_buf_set_length(buf, len);
|
648
|
+
if (status != ARES_SUCCESS) {
|
649
|
+
return status;
|
650
|
+
}
|
651
|
+
|
652
|
+
/* Append Options */
|
653
|
+
for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_OPT_OPTIONS); i++) {
|
654
|
+
unsigned short opt;
|
655
|
+
size_t val_len;
|
656
|
+
const unsigned char *val;
|
657
|
+
|
658
|
+
opt = ares_dns_rr_get_opt(rr, ARES_RR_OPT_OPTIONS, i, &val, &val_len);
|
659
|
+
|
660
|
+
/* BE16 option */
|
661
|
+
status = ares_buf_append_be16(buf, opt);
|
662
|
+
if (status != ARES_SUCCESS) {
|
663
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
664
|
+
}
|
665
|
+
|
666
|
+
/* BE16 length */
|
667
|
+
status = ares_buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF));
|
668
|
+
if (status != ARES_SUCCESS) {
|
669
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
670
|
+
}
|
671
|
+
|
672
|
+
/* Value */
|
673
|
+
if (val && val_len) {
|
674
|
+
status = ares_buf_append(buf, val, val_len);
|
675
|
+
if (status != ARES_SUCCESS) {
|
676
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
677
|
+
}
|
678
|
+
}
|
679
|
+
}
|
680
|
+
|
681
|
+
return ARES_SUCCESS;
|
682
|
+
}
|
683
|
+
|
684
|
+
static ares_status_t ares_dns_write_rr_tlsa(ares_buf_t *buf,
|
685
|
+
const ares_dns_rr_t *rr,
|
686
|
+
ares_llist_t **namelist)
|
687
|
+
{
|
688
|
+
ares_status_t status;
|
689
|
+
const unsigned char *data;
|
690
|
+
size_t len = 0;
|
691
|
+
|
692
|
+
(void)namelist;
|
693
|
+
|
694
|
+
/* CERT_USAGE */
|
695
|
+
status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_CERT_USAGE);
|
696
|
+
if (status != ARES_SUCCESS) {
|
697
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
698
|
+
}
|
699
|
+
|
700
|
+
/* SELECTOR */
|
701
|
+
status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_SELECTOR);
|
702
|
+
if (status != ARES_SUCCESS) {
|
703
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
704
|
+
}
|
705
|
+
|
706
|
+
/* MATCH */
|
707
|
+
status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_MATCH);
|
708
|
+
if (status != ARES_SUCCESS) {
|
709
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
710
|
+
}
|
711
|
+
|
712
|
+
/* DATA -- binary, rest of buffer, required to be non-zero length */
|
713
|
+
data = ares_dns_rr_get_bin(rr, ARES_RR_TLSA_DATA, &len);
|
714
|
+
if (data == NULL || len == 0) {
|
715
|
+
return ARES_EFORMERR;
|
716
|
+
}
|
717
|
+
|
718
|
+
return ares_buf_append(buf, data, len);
|
719
|
+
}
|
720
|
+
|
721
|
+
static ares_status_t ares_dns_write_rr_svcb(ares_buf_t *buf,
|
722
|
+
const ares_dns_rr_t *rr,
|
723
|
+
ares_llist_t **namelist)
|
724
|
+
{
|
725
|
+
ares_status_t status;
|
726
|
+
size_t i;
|
727
|
+
|
728
|
+
/* PRIORITY */
|
729
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SVCB_PRIORITY);
|
730
|
+
if (status != ARES_SUCCESS) {
|
731
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
732
|
+
}
|
733
|
+
|
734
|
+
/* TARGET */
|
735
|
+
status =
|
736
|
+
ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_SVCB_TARGET);
|
737
|
+
if (status != ARES_SUCCESS) {
|
738
|
+
return status;
|
739
|
+
}
|
740
|
+
|
741
|
+
/* Append Params */
|
742
|
+
for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_SVCB_PARAMS); i++) {
|
743
|
+
unsigned short opt;
|
744
|
+
size_t val_len;
|
745
|
+
const unsigned char *val;
|
746
|
+
|
747
|
+
opt = ares_dns_rr_get_opt(rr, ARES_RR_SVCB_PARAMS, i, &val, &val_len);
|
748
|
+
|
749
|
+
/* BE16 option */
|
750
|
+
status = ares_buf_append_be16(buf, opt);
|
751
|
+
if (status != ARES_SUCCESS) {
|
752
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
753
|
+
}
|
754
|
+
|
755
|
+
/* BE16 length */
|
756
|
+
status = ares_buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF));
|
757
|
+
if (status != ARES_SUCCESS) {
|
758
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
759
|
+
}
|
760
|
+
|
761
|
+
/* Value */
|
762
|
+
if (val && val_len) {
|
763
|
+
status = ares_buf_append(buf, val, val_len);
|
764
|
+
if (status != ARES_SUCCESS) {
|
765
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
766
|
+
}
|
767
|
+
}
|
768
|
+
}
|
769
|
+
return ARES_SUCCESS;
|
770
|
+
}
|
771
|
+
|
772
|
+
static ares_status_t ares_dns_write_rr_https(ares_buf_t *buf,
|
773
|
+
const ares_dns_rr_t *rr,
|
774
|
+
ares_llist_t **namelist)
|
775
|
+
{
|
776
|
+
ares_status_t status;
|
777
|
+
size_t i;
|
778
|
+
|
779
|
+
/* PRIORITY */
|
780
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_HTTPS_PRIORITY);
|
781
|
+
if (status != ARES_SUCCESS) {
|
782
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
783
|
+
}
|
784
|
+
|
785
|
+
/* TARGET */
|
786
|
+
status =
|
787
|
+
ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_HTTPS_TARGET);
|
788
|
+
if (status != ARES_SUCCESS) {
|
789
|
+
return status;
|
790
|
+
}
|
791
|
+
|
792
|
+
/* Append Params */
|
793
|
+
for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_HTTPS_PARAMS); i++) {
|
794
|
+
unsigned short opt;
|
795
|
+
size_t val_len;
|
796
|
+
const unsigned char *val;
|
797
|
+
|
798
|
+
opt = ares_dns_rr_get_opt(rr, ARES_RR_HTTPS_PARAMS, i, &val, &val_len);
|
799
|
+
|
800
|
+
/* BE16 option */
|
801
|
+
status = ares_buf_append_be16(buf, opt);
|
802
|
+
if (status != ARES_SUCCESS) {
|
803
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
804
|
+
}
|
805
|
+
|
806
|
+
/* BE16 length */
|
807
|
+
status = ares_buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF));
|
808
|
+
if (status != ARES_SUCCESS) {
|
809
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
810
|
+
}
|
811
|
+
|
812
|
+
/* Value */
|
813
|
+
if (val && val_len) {
|
814
|
+
status = ares_buf_append(buf, val, val_len);
|
815
|
+
if (status != ARES_SUCCESS) {
|
816
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
817
|
+
}
|
818
|
+
}
|
819
|
+
}
|
820
|
+
return ARES_SUCCESS;
|
821
|
+
}
|
822
|
+
|
823
|
+
static ares_status_t ares_dns_write_rr_uri(ares_buf_t *buf,
|
824
|
+
const ares_dns_rr_t *rr,
|
825
|
+
ares_llist_t **namelist)
|
826
|
+
{
|
827
|
+
ares_status_t status;
|
828
|
+
const char *target;
|
829
|
+
|
830
|
+
(void)namelist;
|
831
|
+
|
832
|
+
/* PRIORITY */
|
833
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_URI_PRIORITY);
|
834
|
+
if (status != ARES_SUCCESS) {
|
835
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
836
|
+
}
|
837
|
+
|
838
|
+
/* WEIGHT */
|
839
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_URI_WEIGHT);
|
840
|
+
if (status != ARES_SUCCESS) {
|
841
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
842
|
+
}
|
843
|
+
|
844
|
+
/* TARGET -- not in DNS string format, rest of buffer, required to be
|
845
|
+
* non-zero length */
|
846
|
+
target = ares_dns_rr_get_str(rr, ARES_RR_URI_TARGET);
|
847
|
+
if (target == NULL || ares_strlen(target) == 0) {
|
848
|
+
return ARES_EFORMERR;
|
849
|
+
}
|
850
|
+
|
851
|
+
return ares_buf_append(buf, (const unsigned char *)target,
|
852
|
+
ares_strlen(target));
|
853
|
+
}
|
854
|
+
|
855
|
+
static ares_status_t ares_dns_write_rr_caa(ares_buf_t *buf,
|
856
|
+
const ares_dns_rr_t *rr,
|
857
|
+
ares_llist_t **namelist)
|
858
|
+
{
|
859
|
+
const unsigned char *data = NULL;
|
860
|
+
size_t data_len = 0;
|
861
|
+
ares_status_t status;
|
862
|
+
|
863
|
+
(void)namelist;
|
864
|
+
|
865
|
+
/* CRITICAL */
|
866
|
+
status = ares_dns_write_rr_u8(buf, rr, ARES_RR_CAA_CRITICAL);
|
867
|
+
if (status != ARES_SUCCESS) {
|
868
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
869
|
+
}
|
870
|
+
|
871
|
+
/* Tag */
|
872
|
+
status = ares_dns_write_rr_str(buf, rr, ARES_RR_CAA_TAG);
|
873
|
+
if (status != ARES_SUCCESS) {
|
874
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
875
|
+
}
|
876
|
+
|
877
|
+
/* Value - binary! (remaining buffer */
|
878
|
+
data = ares_dns_rr_get_bin(rr, ARES_RR_CAA_VALUE, &data_len);
|
879
|
+
if (data == NULL || data_len == 0) {
|
880
|
+
return ARES_EFORMERR;
|
881
|
+
}
|
882
|
+
|
883
|
+
return ares_buf_append(buf, data, data_len);
|
884
|
+
}
|
885
|
+
|
886
|
+
static ares_status_t ares_dns_write_rr_raw_rr(ares_buf_t *buf,
|
887
|
+
const ares_dns_rr_t *rr,
|
888
|
+
ares_llist_t **namelist)
|
889
|
+
{
|
890
|
+
size_t len = ares_buf_len(buf);
|
891
|
+
ares_status_t status;
|
892
|
+
const unsigned char *data = NULL;
|
893
|
+
size_t data_len = 0;
|
894
|
+
|
895
|
+
(void)namelist;
|
896
|
+
|
897
|
+
/* Coverity reports on this even though its not possible when taken
|
898
|
+
* into context */
|
899
|
+
if (len == 0) {
|
900
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
901
|
+
}
|
902
|
+
|
903
|
+
/* We need to go back and overwrite the type that was emitted by the parent
|
904
|
+
* function */
|
905
|
+
status = ares_buf_set_length(buf, len - 2 /* RDLENGTH */
|
906
|
+
- 4 /* TTL */
|
907
|
+
- 2 /* CLASS */
|
908
|
+
- 2 /* TYPE */);
|
909
|
+
if (status != ARES_SUCCESS) {
|
910
|
+
return status;
|
911
|
+
}
|
912
|
+
|
913
|
+
status = ares_dns_write_rr_be16(buf, rr, ARES_RR_RAW_RR_TYPE);
|
914
|
+
if (status != ARES_SUCCESS) {
|
915
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
916
|
+
}
|
917
|
+
|
918
|
+
/* Now go back to real end */
|
919
|
+
status = ares_buf_set_length(buf, len);
|
920
|
+
if (status != ARES_SUCCESS) {
|
921
|
+
return status;
|
922
|
+
}
|
923
|
+
|
924
|
+
/* Output raw data */
|
925
|
+
data = ares_dns_rr_get_bin(rr, ARES_RR_RAW_RR_DATA, &data_len);
|
926
|
+
if (data == NULL) {
|
927
|
+
return ARES_EFORMERR;
|
928
|
+
}
|
929
|
+
|
930
|
+
if (data_len == 0) {
|
931
|
+
return ARES_SUCCESS;
|
932
|
+
}
|
933
|
+
|
934
|
+
return ares_buf_append(buf, data, data_len);
|
935
|
+
}
|
936
|
+
|
937
|
+
static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec,
|
938
|
+
ares_llist_t **namelist,
|
939
|
+
ares_dns_section_t section,
|
940
|
+
ares_buf_t *buf)
|
941
|
+
{
|
942
|
+
size_t i;
|
943
|
+
|
944
|
+
for (i = 0; i < ares_dns_record_rr_cnt(dnsrec, section); i++) {
|
945
|
+
const ares_dns_rr_t *rr;
|
946
|
+
ares_dns_rec_type_t type;
|
947
|
+
ares_bool_t allow_compress;
|
948
|
+
ares_llist_t **namelistptr = NULL;
|
949
|
+
size_t pos_len;
|
950
|
+
ares_status_t status;
|
951
|
+
size_t rdlength;
|
952
|
+
size_t end_length;
|
953
|
+
unsigned int ttl;
|
954
|
+
|
955
|
+
rr = ares_dns_record_rr_get_const(dnsrec, section, i);
|
956
|
+
if (rr == NULL) {
|
957
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
958
|
+
}
|
959
|
+
|
960
|
+
type = ares_dns_rr_get_type(rr);
|
961
|
+
allow_compress = ares_dns_rec_allow_name_comp(type);
|
962
|
+
if (allow_compress) {
|
963
|
+
namelistptr = namelist;
|
964
|
+
}
|
965
|
+
|
966
|
+
/* Name */
|
967
|
+
status =
|
968
|
+
ares_dns_name_write(buf, namelist, ARES_TRUE, ares_dns_rr_get_name(rr));
|
969
|
+
if (status != ARES_SUCCESS) {
|
970
|
+
return status;
|
971
|
+
}
|
972
|
+
|
973
|
+
/* Type */
|
974
|
+
status = ares_buf_append_be16(buf, (unsigned short)type);
|
975
|
+
if (status != ARES_SUCCESS) {
|
976
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
977
|
+
}
|
978
|
+
|
979
|
+
/* Class */
|
980
|
+
status =
|
981
|
+
ares_buf_append_be16(buf, (unsigned short)ares_dns_rr_get_class(rr));
|
982
|
+
if (status != ARES_SUCCESS) {
|
983
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
984
|
+
}
|
985
|
+
|
986
|
+
/* TTL */
|
987
|
+
ttl = ares_dns_rr_get_ttl(rr);
|
988
|
+
if (rr->parent->ttl_decrement > ttl) {
|
989
|
+
ttl = 0;
|
990
|
+
} else {
|
991
|
+
ttl -= rr->parent->ttl_decrement;
|
992
|
+
}
|
993
|
+
status = ares_buf_append_be32(buf, ttl);
|
994
|
+
if (status != ARES_SUCCESS) {
|
995
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
996
|
+
}
|
997
|
+
|
998
|
+
/* Length */
|
999
|
+
pos_len = ares_buf_len(buf); /* Save to write real length later */
|
1000
|
+
status = ares_buf_append_be16(buf, 0);
|
1001
|
+
if (status != ARES_SUCCESS) {
|
1002
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
/* Data */
|
1006
|
+
switch (type) {
|
1007
|
+
case ARES_REC_TYPE_A:
|
1008
|
+
status = ares_dns_write_rr_a(buf, rr, namelistptr);
|
1009
|
+
break;
|
1010
|
+
case ARES_REC_TYPE_NS:
|
1011
|
+
status = ares_dns_write_rr_ns(buf, rr, namelistptr);
|
1012
|
+
break;
|
1013
|
+
case ARES_REC_TYPE_CNAME:
|
1014
|
+
status = ares_dns_write_rr_cname(buf, rr, namelistptr);
|
1015
|
+
break;
|
1016
|
+
case ARES_REC_TYPE_SOA:
|
1017
|
+
status = ares_dns_write_rr_soa(buf, rr, namelistptr);
|
1018
|
+
break;
|
1019
|
+
case ARES_REC_TYPE_PTR:
|
1020
|
+
status = ares_dns_write_rr_ptr(buf, rr, namelistptr);
|
1021
|
+
break;
|
1022
|
+
case ARES_REC_TYPE_HINFO:
|
1023
|
+
status = ares_dns_write_rr_hinfo(buf, rr, namelistptr);
|
1024
|
+
break;
|
1025
|
+
case ARES_REC_TYPE_MX:
|
1026
|
+
status = ares_dns_write_rr_mx(buf, rr, namelistptr);
|
1027
|
+
break;
|
1028
|
+
case ARES_REC_TYPE_TXT:
|
1029
|
+
status = ares_dns_write_rr_txt(buf, rr, namelistptr);
|
1030
|
+
break;
|
1031
|
+
case ARES_REC_TYPE_SIG:
|
1032
|
+
status = ares_dns_write_rr_sig(buf, rr, namelistptr);
|
1033
|
+
break;
|
1034
|
+
case ARES_REC_TYPE_AAAA:
|
1035
|
+
status = ares_dns_write_rr_aaaa(buf, rr, namelistptr);
|
1036
|
+
break;
|
1037
|
+
case ARES_REC_TYPE_SRV:
|
1038
|
+
status = ares_dns_write_rr_srv(buf, rr, namelistptr);
|
1039
|
+
break;
|
1040
|
+
case ARES_REC_TYPE_NAPTR:
|
1041
|
+
status = ares_dns_write_rr_naptr(buf, rr, namelistptr);
|
1042
|
+
break;
|
1043
|
+
case ARES_REC_TYPE_ANY:
|
1044
|
+
status = ARES_EFORMERR;
|
1045
|
+
break;
|
1046
|
+
case ARES_REC_TYPE_OPT:
|
1047
|
+
status = ares_dns_write_rr_opt(buf, rr, namelistptr);
|
1048
|
+
break;
|
1049
|
+
case ARES_REC_TYPE_TLSA:
|
1050
|
+
status = ares_dns_write_rr_tlsa(buf, rr, namelistptr);
|
1051
|
+
break;
|
1052
|
+
case ARES_REC_TYPE_SVCB:
|
1053
|
+
status = ares_dns_write_rr_svcb(buf, rr, namelistptr);
|
1054
|
+
break;
|
1055
|
+
case ARES_REC_TYPE_HTTPS:
|
1056
|
+
status = ares_dns_write_rr_https(buf, rr, namelistptr);
|
1057
|
+
break;
|
1058
|
+
case ARES_REC_TYPE_URI:
|
1059
|
+
status = ares_dns_write_rr_uri(buf, rr, namelistptr);
|
1060
|
+
break;
|
1061
|
+
case ARES_REC_TYPE_CAA:
|
1062
|
+
status = ares_dns_write_rr_caa(buf, rr, namelistptr);
|
1063
|
+
break;
|
1064
|
+
case ARES_REC_TYPE_RAW_RR:
|
1065
|
+
status = ares_dns_write_rr_raw_rr(buf, rr, namelistptr);
|
1066
|
+
break;
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
if (status != ARES_SUCCESS) {
|
1070
|
+
return status;
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
/* Back off write pointer, write real length, then go back to proper
|
1074
|
+
* position */
|
1075
|
+
end_length = ares_buf_len(buf);
|
1076
|
+
rdlength = end_length - pos_len - 2;
|
1077
|
+
|
1078
|
+
status = ares_buf_set_length(buf, pos_len);
|
1079
|
+
if (status != ARES_SUCCESS) {
|
1080
|
+
return status;
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
status = ares_buf_append_be16(buf, (unsigned short)(rdlength & 0xFFFF));
|
1084
|
+
if (status != ARES_SUCCESS) {
|
1085
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
status = ares_buf_set_length(buf, end_length);
|
1089
|
+
if (status != ARES_SUCCESS) {
|
1090
|
+
return status;
|
1091
|
+
}
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
return ARES_SUCCESS;
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
ares_status_t ares_dns_write_buf(const ares_dns_record_t *dnsrec,
|
1098
|
+
ares_buf_t *buf)
|
1099
|
+
{
|
1100
|
+
ares_llist_t *namelist = NULL;
|
1101
|
+
size_t orig_len;
|
1102
|
+
ares_status_t status;
|
1103
|
+
|
1104
|
+
if (dnsrec == NULL || buf == NULL) {
|
1105
|
+
return ARES_EFORMERR;
|
1106
|
+
}
|
1107
|
+
|
1108
|
+
orig_len = ares_buf_len(buf);
|
1109
|
+
|
1110
|
+
status = ares_dns_write_header(dnsrec, buf);
|
1111
|
+
if (status != ARES_SUCCESS) {
|
1112
|
+
goto done;
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
status = ares_dns_write_questions(dnsrec, &namelist, buf);
|
1116
|
+
if (status != ARES_SUCCESS) {
|
1117
|
+
goto done;
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_ANSWER, buf);
|
1121
|
+
if (status != ARES_SUCCESS) {
|
1122
|
+
goto done;
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_AUTHORITY, buf);
|
1126
|
+
if (status != ARES_SUCCESS) {
|
1127
|
+
goto done;
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_ADDITIONAL, buf);
|
1131
|
+
if (status != ARES_SUCCESS) {
|
1132
|
+
goto done;
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
done:
|
1136
|
+
ares_llist_destroy(namelist);
|
1137
|
+
if (status != ARES_SUCCESS) {
|
1138
|
+
ares_buf_set_length(buf, orig_len);
|
1139
|
+
}
|
1140
|
+
|
1141
|
+
return status;
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
ares_status_t ares_dns_write_buf_tcp(const ares_dns_record_t *dnsrec,
|
1145
|
+
ares_buf_t *buf)
|
1146
|
+
{
|
1147
|
+
ares_status_t status;
|
1148
|
+
size_t orig_len;
|
1149
|
+
size_t msg_len;
|
1150
|
+
size_t len;
|
1151
|
+
|
1152
|
+
if (dnsrec == NULL || buf == NULL) {
|
1153
|
+
return ARES_EFORMERR;
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
orig_len = ares_buf_len(buf);
|
1157
|
+
|
1158
|
+
/* Write placeholder for length */
|
1159
|
+
status = ares_buf_append_be16(buf, 0);
|
1160
|
+
if (status != ARES_SUCCESS) {
|
1161
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
1162
|
+
}
|
1163
|
+
|
1164
|
+
/* Write message */
|
1165
|
+
status = ares_dns_write_buf(dnsrec, buf);
|
1166
|
+
if (status != ARES_SUCCESS) {
|
1167
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
len = ares_buf_len(buf);
|
1171
|
+
msg_len = len - orig_len - 2;
|
1172
|
+
if (msg_len > 65535) {
|
1173
|
+
status = ARES_EBADQUERY;
|
1174
|
+
goto done;
|
1175
|
+
}
|
1176
|
+
|
1177
|
+
/* Now we need to overwrite the length, so we jump back to the original
|
1178
|
+
* message length, overwrite the section and jump back */
|
1179
|
+
ares_buf_set_length(buf, orig_len);
|
1180
|
+
status = ares_buf_append_be16(buf, (unsigned short)(msg_len & 0xFFFF));
|
1181
|
+
if (status != ARES_SUCCESS) {
|
1182
|
+
goto done; /* LCOV_EXCL_LINE: UntestablePath */
|
1183
|
+
}
|
1184
|
+
ares_buf_set_length(buf, len);
|
1185
|
+
|
1186
|
+
done:
|
1187
|
+
if (status != ARES_SUCCESS) {
|
1188
|
+
ares_buf_set_length(buf, orig_len);
|
1189
|
+
}
|
1190
|
+
return status;
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec,
|
1194
|
+
unsigned char **buf, size_t *buf_len)
|
1195
|
+
{
|
1196
|
+
ares_buf_t *b = NULL;
|
1197
|
+
ares_status_t status;
|
1198
|
+
|
1199
|
+
if (buf == NULL || buf_len == NULL || dnsrec == NULL) {
|
1200
|
+
return ARES_EFORMERR;
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
*buf = NULL;
|
1204
|
+
*buf_len = 0;
|
1205
|
+
|
1206
|
+
b = ares_buf_create();
|
1207
|
+
if (b == NULL) {
|
1208
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
status = ares_dns_write_buf(dnsrec, b);
|
1212
|
+
|
1213
|
+
if (status != ARES_SUCCESS) {
|
1214
|
+
ares_buf_destroy(b);
|
1215
|
+
return status;
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
*buf = ares_buf_finish_bin(b, buf_len);
|
1219
|
+
return status;
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
void ares_dns_record_ttl_decrement(ares_dns_record_t *dnsrec,
|
1223
|
+
unsigned int ttl_decrement)
|
1224
|
+
{
|
1225
|
+
if (dnsrec == NULL) {
|
1226
|
+
return;
|
1227
|
+
}
|
1228
|
+
dnsrec->ttl_decrement = ttl_decrement;
|
1229
|
+
}
|