grpc 1.40.0 → 1.41.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +27 -36
- data/include/grpc/byte_buffer.h +1 -1
- data/include/grpc/byte_buffer_reader.h +1 -1
- data/include/grpc/event_engine/endpoint_config.h +6 -11
- data/include/grpc/event_engine/event_engine.h +63 -58
- data/include/grpc/event_engine/port.h +1 -3
- data/include/grpc/event_engine/slice_allocator.h +6 -1
- data/include/grpc/fork.h +1 -1
- data/include/grpc/grpc.h +10 -4
- data/include/grpc/grpc_posix.h +5 -2
- data/include/grpc/impl/codegen/atm.h +5 -3
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +2 -0
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +2 -0
- data/include/grpc/impl/codegen/byte_buffer.h +2 -0
- data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -0
- data/include/grpc/impl/codegen/compression_types.h +2 -0
- data/include/grpc/impl/codegen/connectivity_state.h +2 -0
- data/include/grpc/impl/codegen/fork.h +2 -0
- data/include/grpc/impl/codegen/gpr_slice.h +2 -0
- data/include/grpc/impl/codegen/gpr_types.h +2 -0
- data/include/grpc/impl/codegen/grpc_types.h +4 -5
- data/include/grpc/impl/codegen/log.h +2 -0
- data/include/grpc/impl/codegen/port_platform.h +26 -22
- data/include/grpc/impl/codegen/propagation_bits.h +2 -0
- data/include/grpc/impl/codegen/slice.h +2 -0
- data/include/grpc/impl/codegen/status.h +2 -0
- data/include/grpc/impl/codegen/sync.h +8 -5
- data/include/grpc/impl/codegen/sync_abseil.h +2 -0
- data/include/grpc/impl/codegen/sync_custom.h +2 -0
- data/include/grpc/impl/codegen/sync_generic.h +3 -0
- data/include/grpc/impl/codegen/sync_posix.h +4 -2
- data/include/grpc/impl/codegen/sync_windows.h +2 -0
- data/include/grpc/slice.h +1 -1
- data/include/grpc/status.h +1 -1
- data/include/grpc/support/atm.h +1 -1
- data/include/grpc/support/atm_gcc_atomic.h +1 -1
- data/include/grpc/support/atm_gcc_sync.h +1 -1
- data/include/grpc/support/atm_windows.h +1 -1
- data/include/grpc/support/log.h +1 -1
- data/include/grpc/support/port_platform.h +1 -1
- data/include/grpc/support/sync.h +1 -1
- data/include/grpc/support/sync_abseil.h +1 -1
- data/include/grpc/support/sync_custom.h +1 -1
- data/include/grpc/support/sync_generic.h +1 -1
- data/include/grpc/support/sync_posix.h +1 -1
- data/include/grpc/support/sync_windows.h +1 -1
- data/include/grpc/support/time.h +2 -2
- data/src/core/ext/filters/census/grpc_context.cc +1 -0
- data/src/core/ext/filters/client_channel/backend_metric.cc +0 -1
- data/src/core/ext/filters/client_channel/backup_poller.h +1 -0
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +1 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +24 -52
- data/src/core/ext/filters/client_channel/client_channel.h +3 -3
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +6 -5
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -0
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +8 -1
- data/src/core/ext/filters/client_channel/config_selector.cc +1 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +7 -6
- data/src/core/ext/filters/client_channel/health/health_check_client.h +4 -3
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +8 -7
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +10 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +2 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +14 -23
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +1 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +2 -8
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +15 -18
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +10 -7
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -8
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +2 -3
- data/src/core/ext/filters/client_channel/lb_policy.h +11 -44
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -7
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +2 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +6 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +14 -19
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +5 -5
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -8
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +2 -3
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +36 -30
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +8 -6
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -13
- data/src/core/ext/filters/http/client/http_client_filter.cc +3 -2
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -1
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -1
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +7 -8
- data/src/core/ext/filters/http/server/http_server_filter.cc +5 -3
- data/src/core/ext/filters/message_size/message_size_filter.cc +9 -13
- data/src/core/ext/transport/chttp2/alpn/alpn.cc +2 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +29 -12
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +2 -0
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +2 -3
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +10 -6
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +2 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +60 -37
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +0 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +12 -6
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +5 -9
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +3 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -1
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +2 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +24 -30
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +4 -1
- data/src/core/ext/transport/chttp2/transport/context_list.h +1 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +39 -23
- data/src/core/ext/transport/chttp2/transport/flow_control.h +9 -3
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +7 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +3 -5
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +36 -5
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +12 -7
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -0
- data/src/core/ext/transport/chttp2/transport/hpack_constants.h +41 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +272 -666
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +236 -70
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +107 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +86 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +69 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +776 -1037
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +48 -169
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +159 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +130 -0
- data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +46 -0
- data/src/core/ext/transport/chttp2/transport/hpack_utils.h +30 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +20 -30
- data/src/core/ext/transport/chttp2/transport/popularity_count.h +60 -0
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/varint.cc +7 -3
- data/src/core/ext/transport/chttp2/transport/varint.h +39 -28
- data/src/core/ext/transport/chttp2/transport/writing.cc +32 -28
- data/src/core/ext/transport/inproc/inproc_transport.cc +6 -4
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +96 -96
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +221 -89
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +1 -1
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +48 -48
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +151 -61
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +99 -99
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +171 -69
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +15 -15
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +126 -127
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +229 -101
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +23 -23
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +28 -28
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +71 -29
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +82 -82
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +201 -81
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +24 -24
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +62 -62
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +131 -53
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +51 -51
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +81 -33
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +62 -62
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +141 -57
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +16 -16
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +57 -22
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +174 -17
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +32 -32
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +37 -37
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +61 -25
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +40 -40
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +71 -29
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +30 -30
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +81 -33
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +41 -29
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +141 -43
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +46 -43
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +88 -29
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +18 -18
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +281 -277
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +569 -248
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +10 -10
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +13 -13
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +23 -23
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +115 -116
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +191 -77
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +1 -1
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +46 -32
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +118 -34
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +12 -12
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +44 -42
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +108 -55
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +42 -42
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +61 -25
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +28 -28
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +41 -17
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +9 -8
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +25 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +10 -10
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +11 -11
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +15 -15
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +71 -29
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +19 -19
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/type/v3/http.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/type/v3/http.upb.h +1 -1
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +10 -10
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +11 -5
- data/src/core/ext/upb-generated/google/api/annotations.upb.c +1 -1
- data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -1
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +58 -58
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +111 -45
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +68 -68
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +121 -49
- data/src/core/ext/upb-generated/google/api/http.upb.c +18 -18
- data/src/core/ext/upb-generated/google/api/http.upb.h +31 -13
- data/src/core/ext/upb-generated/google/protobuf/any.upb.c +4 -4
- data/src/core/ext/upb-generated/google/protobuf/any.upb.h +11 -5
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +153 -153
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +271 -109
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +4 -4
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +11 -5
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +2 -2
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +11 -5
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +15 -15
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +31 -13
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +4 -4
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +11 -5
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +19 -19
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +91 -37
- data/src/core/ext/upb-generated/google/rpc/status.upb.c +5 -5
- data/src/core/ext/upb-generated/google/rpc/status.upb.h +11 -5
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +12 -12
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +11 -5
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +60 -60
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +101 -41
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +7 -7
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +21 -9
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +5 -5
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +21 -9
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +31 -31
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +91 -37
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +8 -8
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +31 -13
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +4 -4
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +11 -5
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +1 -1
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +1 -1
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +4 -4
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +11 -5
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +3 -3
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +11 -5
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +13 -13
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +11 -5
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +4 -4
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +11 -5
- data/src/core/ext/upb-generated/validate/validate.upb.c +220 -220
- data/src/core/ext/upb-generated/validate/validate.upb.h +231 -93
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +3 -3
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +11 -5
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +8 -8
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +21 -9
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +6 -6
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +11 -5
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +5 -5
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +11 -5
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +11 -11
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +21 -9
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +6 -6
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +11 -5
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +384 -382
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +94 -63
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +30 -19
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +791 -780
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +96 -100
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +133 -115
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +178 -173
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +14 -13
- data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +103 -103
- data/src/core/ext/xds/certificate_provider_registry.cc +2 -2
- data/src/core/ext/xds/xds_api.cc +788 -910
- data/src/core/ext/xds/xds_api.h +16 -33
- data/src/core/ext/xds/xds_bootstrap.cc +27 -52
- data/src/core/ext/xds/xds_client.cc +69 -30
- data/src/core/ext/xds/xds_client_stats.cc +16 -15
- data/src/core/ext/xds/xds_client_stats.h +6 -6
- data/src/core/ext/xds/xds_http_fault_filter.cc +4 -3
- data/src/core/ext/xds/xds_http_fault_filter.h +3 -2
- data/src/core/ext/xds/xds_http_filters.cc +1 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +10 -10
- data/src/core/lib/address_utils/parse_address.cc +4 -8
- data/src/core/lib/address_utils/sockaddr_utils.cc +2 -2
- data/src/core/lib/channel/channel_args.cc +2 -1
- data/src/core/lib/channel/channel_stack.cc +5 -3
- data/src/core/lib/channel/channel_stack_builder.cc +1 -11
- data/src/core/lib/channel/channel_stack_builder.h +0 -8
- data/src/core/lib/channel/channel_trace.cc +4 -3
- data/src/core/lib/channel/channel_trace.h +1 -0
- data/src/core/lib/channel/channelz.cc +40 -36
- data/src/core/lib/channel/channelz.h +27 -27
- data/src/core/lib/channel/channelz_registry.cc +7 -6
- data/src/core/lib/channel/connected_channel.cc +1 -0
- data/src/core/lib/channel/handshaker.cc +2 -1
- data/src/core/lib/channel/handshaker.h +1 -2
- data/src/core/lib/channel/handshaker_factory.h +10 -2
- data/src/core/lib/channel/handshaker_registry.cc +15 -70
- data/src/core/lib/channel/handshaker_registry.h +29 -12
- data/src/core/lib/channel/status_util.h +2 -2
- data/src/core/lib/compression/algorithm_metadata.h +1 -0
- data/src/core/lib/compression/compression_args.cc +2 -1
- data/src/core/lib/compression/compression_internal.cc +2 -4
- data/src/core/lib/compression/message_compress.cc +2 -2
- data/src/core/lib/compression/stream_compression.cc +2 -1
- data/src/core/lib/compression/stream_compression.h +2 -1
- data/src/core/lib/compression/stream_compression_gzip.cc +2 -1
- data/src/core/lib/compression/stream_compression_identity.cc +2 -1
- data/src/core/lib/config/core_configuration.cc +54 -0
- data/src/core/lib/config/core_configuration.h +108 -0
- data/src/core/lib/debug/stats.h +1 -0
- data/src/core/lib/debug/stats_data.cc +2 -1
- data/src/core/lib/debug/stats_data.h +1 -0
- data/src/core/lib/debug/trace.cc +1 -0
- data/src/core/lib/debug/trace.h +2 -1
- data/src/core/lib/event_engine/endpoint_config.cc +0 -1
- data/src/core/lib/event_engine/event_engine.cc +3 -3
- data/src/core/lib/event_engine/sockaddr.cc +3 -3
- data/src/core/lib/gpr/alloc.cc +4 -3
- data/src/core/lib/gpr/env_linux.cc +1 -2
- data/src/core/lib/gpr/env_posix.cc +2 -3
- data/src/core/lib/gpr/log.cc +3 -3
- data/src/core/lib/gpr/log_android.cc +3 -2
- data/src/core/lib/gpr/log_linux.cc +7 -4
- data/src/core/lib/gpr/log_posix.cc +6 -3
- data/src/core/lib/gpr/string.h +2 -2
- data/src/core/lib/gpr/sync.cc +2 -2
- data/src/core/lib/gpr/sync_abseil.cc +7 -6
- data/src/core/lib/gpr/sync_posix.cc +3 -3
- data/src/core/lib/gpr/time.cc +3 -2
- data/src/core/lib/gpr/time_windows.cc +3 -2
- data/src/core/lib/gpr/tls.h +120 -41
- data/src/core/lib/gpr/tmpfile_posix.cc +1 -2
- data/src/core/lib/gprpp/arena.cc +2 -1
- data/src/core/lib/gprpp/arena.h +5 -5
- data/src/core/lib/gprpp/atomic_utils.h +47 -0
- data/src/core/lib/gprpp/bitset.h +166 -0
- data/src/core/lib/gprpp/construct_destruct.h +39 -0
- data/src/core/lib/gprpp/dual_ref_counted.h +25 -26
- data/src/core/lib/gprpp/fork.cc +14 -12
- data/src/core/lib/gprpp/fork.h +4 -4
- data/src/core/lib/gprpp/global_config.h +1 -2
- data/src/core/lib/gprpp/global_config_env.cc +7 -7
- data/src/core/lib/gprpp/global_config_generic.h +2 -2
- data/src/core/lib/gprpp/manual_constructor.h +8 -5
- data/src/core/lib/gprpp/match.h +73 -0
- data/src/core/lib/gprpp/memory.h +3 -3
- data/src/core/lib/gprpp/mpscq.cc +7 -7
- data/src/core/lib/gprpp/mpscq.h +6 -5
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/overload.h +59 -0
- data/src/core/lib/gprpp/ref_counted.h +18 -18
- data/src/core/lib/gprpp/status_helper.cc +4 -4
- data/src/core/lib/gprpp/sync.h +3 -1
- data/src/core/lib/gprpp/thd_posix.cc +5 -5
- data/src/core/lib/gprpp/thd_windows.cc +4 -11
- data/src/core/lib/gprpp/time_util.cc +2 -2
- data/src/core/lib/gprpp/time_util.h +2 -2
- data/src/core/lib/http/format_request.cc +1 -0
- data/src/core/lib/http/format_request.h +1 -0
- data/src/core/lib/http/httpcli.cc +9 -9
- data/src/core/lib/http/httpcli.h +3 -0
- data/src/core/lib/http/httpcli_security_connector.cc +5 -8
- data/src/core/lib/http/parser.h +1 -0
- data/src/core/lib/iomgr/buffer_list.cc +2 -1
- data/src/core/lib/iomgr/buffer_list.h +1 -2
- data/src/core/lib/iomgr/call_combiner.cc +1 -0
- data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
- data/src/core/lib/iomgr/combiner.cc +3 -2
- data/src/core/lib/iomgr/combiner.h +1 -0
- data/src/core/lib/iomgr/dualstack_socket_posix.cc +1 -0
- data/src/core/lib/iomgr/endpoint.cc +0 -4
- data/src/core/lib/iomgr/endpoint.h +1 -3
- data/src/core/lib/iomgr/endpoint_cfstream.cc +9 -20
- data/src/core/lib/iomgr/endpoint_cfstream.h +1 -1
- data/src/core/lib/iomgr/endpoint_pair.h +1 -0
- data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +1 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +15 -11
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +17 -9
- data/src/core/lib/iomgr/error.h +23 -9
- data/src/core/lib/iomgr/error_cfstream.cc +2 -2
- data/src/core/lib/iomgr/error_internal.h +1 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +14 -22
- data/src/core/lib/iomgr/ev_epollex_linux.cc +15 -22
- data/src/core/lib/iomgr/ev_poll_posix.cc +13 -25
- data/src/core/lib/iomgr/ev_posix.cc +1 -2
- data/src/core/lib/iomgr/event_engine/endpoint.cc +3 -22
- data/src/core/lib/iomgr/event_engine/endpoint.h +1 -2
- data/src/core/lib/iomgr/event_engine/iomgr.cc +17 -18
- data/src/core/lib/iomgr/event_engine/iomgr.h +20 -2
- data/src/core/lib/iomgr/event_engine/resolver.cc +2 -1
- data/src/core/lib/iomgr/event_engine/tcp.cc +53 -24
- data/src/core/lib/iomgr/exec_ctx.cc +3 -4
- data/src/core/lib/iomgr/exec_ctx.h +11 -19
- data/src/core/lib/iomgr/executor/mpmcqueue.cc +10 -9
- data/src/core/lib/iomgr/executor/mpmcqueue.h +4 -3
- data/src/core/lib/iomgr/executor/threadpool.cc +2 -2
- data/src/core/lib/iomgr/executor/threadpool.h +2 -1
- data/src/core/lib/iomgr/executor.cc +5 -6
- data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +2 -2
- data/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc +2 -2
- data/src/core/lib/iomgr/internal_errqueue.cc +3 -2
- data/src/core/lib/iomgr/iocp_windows.cc +1 -0
- data/src/core/lib/iomgr/iomgr.h +2 -2
- data/src/core/lib/iomgr/iomgr_custom.cc +2 -2
- data/src/core/lib/iomgr/iomgr_custom.h +2 -2
- data/src/core/lib/iomgr/iomgr_internal.cc +2 -1
- data/src/core/lib/iomgr/iomgr_windows.cc +1 -2
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +4 -4
- data/src/core/lib/iomgr/polling_entity.cc +2 -2
- data/src/core/lib/iomgr/pollset_custom.cc +3 -4
- data/src/core/lib/iomgr/pollset_custom.h +2 -2
- data/src/core/lib/iomgr/pollset_set_custom.cc +1 -2
- data/src/core/lib/iomgr/pollset_set_windows.cc +1 -0
- data/src/core/lib/iomgr/port.h +0 -5
- data/src/core/lib/iomgr/python_util.h +1 -0
- data/src/core/lib/iomgr/resolve_address.cc +2 -1
- data/src/core/lib/iomgr/resolve_address.h +0 -4
- data/src/core/lib/iomgr/resolve_address_custom.cc +4 -4
- data/src/core/lib/iomgr/resolve_address_custom.h +0 -1
- data/src/core/lib/iomgr/resolve_address_posix.cc +2 -4
- data/src/core/lib/iomgr/resolve_address_windows.cc +6 -8
- data/src/core/lib/iomgr/resource_quota.cc +127 -42
- data/src/core/lib/iomgr/resource_quota.h +66 -17
- data/src/core/lib/iomgr/sockaddr.h +1 -1
- data/src/core/lib/iomgr/socket_factory_posix.cc +3 -3
- data/src/core/lib/iomgr/socket_factory_posix.h +1 -0
- data/src/core/lib/iomgr/socket_mutator.h +2 -2
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +3 -3
- data/src/core/lib/iomgr/socket_utils_linux.cc +4 -4
- data/src/core/lib/iomgr/socket_utils_posix.cc +2 -2
- data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
- data/src/core/lib/iomgr/socket_utils_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_client.cc +4 -2
- data/src/core/lib/iomgr/tcp_client.h +4 -0
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +9 -19
- data/src/core/lib/iomgr/tcp_client_custom.cc +9 -17
- data/src/core/lib/iomgr/tcp_client_posix.cc +24 -9
- data/src/core/lib/iomgr/tcp_client_posix.h +5 -2
- data/src/core/lib/iomgr/tcp_client_windows.cc +14 -6
- data/src/core/lib/iomgr/tcp_custom.cc +11 -23
- data/src/core/lib/iomgr/tcp_custom.h +2 -1
- data/src/core/lib/iomgr/tcp_posix.cc +29 -59
- data/src/core/lib/iomgr/tcp_posix.h +11 -12
- data/src/core/lib/iomgr/tcp_server.cc +6 -4
- data/src/core/lib/iomgr/tcp_server.h +12 -9
- data/src/core/lib/iomgr/tcp_server_custom.cc +15 -33
- data/src/core/lib/iomgr/tcp_server_posix.cc +20 -13
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +3 -4
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +13 -9
- data/src/core/lib/iomgr/tcp_windows.cc +6 -25
- data/src/core/lib/iomgr/tcp_windows.h +2 -1
- data/src/core/lib/iomgr/timer.cc +1 -0
- data/src/core/lib/iomgr/timer.h +1 -2
- data/src/core/lib/iomgr/timer_custom.cc +2 -2
- data/src/core/lib/iomgr/timer_generic.cc +8 -38
- data/src/core/lib/iomgr/timer_generic.h +1 -0
- data/src/core/lib/iomgr/timer_heap.cc +1 -2
- data/src/core/lib/iomgr/udp_server.cc +1 -2
- data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -5
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -3
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -3
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -0
- data/src/core/lib/iomgr/work_serializer.cc +4 -4
- data/src/core/lib/iomgr/work_serializer.h +1 -1
- data/src/core/lib/json/json_reader.cc +9 -17
- data/src/core/lib/json/json_util.h +18 -26
- data/src/core/lib/matchers/matchers.h +0 -1
- data/src/core/lib/profiling/basic_timers.cc +8 -6
- data/src/core/lib/profiling/stap_timers.cc +2 -2
- data/src/core/lib/security/authorization/authorization_policy_provider.h +5 -4
- data/src/core/lib/security/authorization/evaluate_args.cc +2 -0
- data/src/core/lib/security/authorization/sdk_server_authz_filter.cc +159 -0
- data/src/core/lib/security/authorization/sdk_server_authz_filter.h +67 -0
- data/src/core/lib/security/context/security_context.cc +7 -6
- data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +2 -2
- data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
- data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +2 -2
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +4 -3
- data/src/core/lib/security/credentials/credentials.cc +6 -6
- data/src/core/lib/security/credentials/credentials.h +1 -1
- data/src/core/lib/security/credentials/credentials_metadata.cc +2 -3
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +13 -26
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +1 -2
- data/src/core/lib/security/credentials/external/aws_request_signer.cc +3 -3
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +13 -22
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -4
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +1 -2
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +55 -3
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -1
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/json_token.h +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +31 -14
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -3
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +0 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +3 -7
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -4
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +4 -4
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +0 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +3 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +10 -6
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +2 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -5
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +2 -2
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +4 -6
- data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +1 -0
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +3 -3
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -7
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +1 -2
- data/src/core/lib/security/security_connector/ssl_utils.cc +2 -3
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +9 -14
- data/src/core/lib/security/transport/auth_filters.h +1 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +4 -6
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -14
- data/src/core/lib/security/transport/secure_endpoint.h +1 -0
- data/src/core/lib/security/transport/security_handshaker.cc +5 -4
- data/src/core/lib/security/transport/security_handshaker.h +2 -1
- data/src/core/lib/security/util/json_util.cc +6 -8
- data/src/core/lib/slice/percent_encoding.cc +73 -30
- data/src/core/lib/slice/percent_encoding.h +29 -28
- data/src/core/lib/slice/slice.cc +2 -3
- data/src/core/lib/slice/slice_buffer.cc +1 -2
- data/src/core/lib/slice/slice_intern.cc +2 -3
- data/src/core/lib/slice/slice_internal.h +2 -2
- data/src/core/lib/surface/api_trace.cc +2 -1
- data/src/core/lib/surface/api_trace.h +1 -0
- data/src/core/lib/surface/byte_buffer_reader.cc +1 -1
- data/src/core/lib/surface/call.cc +9 -8
- data/src/core/lib/surface/call.h +3 -3
- data/src/core/lib/surface/call_details.cc +2 -2
- data/src/core/lib/surface/call_log_batch.cc +2 -2
- data/src/core/lib/surface/channel.cc +22 -9
- data/src/core/lib/surface/channel.h +14 -2
- data/src/core/lib/surface/channel_ping.cc +1 -2
- data/src/core/lib/surface/channel_stack_type.cc +2 -1
- data/src/core/lib/surface/completion_queue.cc +54 -64
- data/src/core/lib/surface/completion_queue_factory.cc +2 -1
- data/src/core/lib/surface/completion_queue_factory.h +1 -0
- data/src/core/lib/surface/event_string.cc +1 -0
- data/src/core/lib/surface/init.cc +4 -9
- data/src/core/lib/surface/init.h +0 -1
- data/src/core/lib/surface/init_secure.cc +23 -4
- data/src/core/lib/surface/lame_client.cc +6 -5
- data/src/core/lib/surface/metadata_array.cc +2 -2
- data/src/core/lib/surface/server.cc +17 -33
- data/src/core/lib/surface/server.h +11 -13
- data/src/core/lib/surface/validate_metadata.cc +44 -16
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.h +1 -0
- data/src/core/lib/transport/connectivity_state.cc +8 -5
- data/src/core/lib/transport/connectivity_state.h +2 -2
- data/src/core/lib/transport/error_utils.cc +1 -0
- data/src/core/lib/transport/metadata.cc +10 -10
- data/src/core/lib/transport/metadata.h +13 -11
- data/src/core/lib/transport/metadata_batch.h +8 -0
- data/src/core/lib/transport/transport_op_string.cc +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.cc +14 -0
- data/src/core/tsi/alts/crypt/aes_gcm.cc +3 -2
- data/src/core/tsi/alts/crypt/gsec.h +2 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -2
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +2 -3
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +2 -2
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +4 -3
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +2 -2
- data/src/core/tsi/ssl_transport_security.cc +11 -9
- data/src/core/tsi/ssl_transport_security.h +3 -1
- data/src/core/tsi/transport_security.cc +3 -3
- data/src/core/tsi/transport_security_grpc.h +1 -0
- data/src/ruby/ext/grpc/extconf.rb +1 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +2 -1
- data/src/ruby/ext/grpc/rb_call.c +5 -5
- data/src/ruby/ext/grpc/rb_call_credentials.c +5 -5
- data/src/ruby/ext/grpc/rb_channel.c +10 -8
- data/src/ruby/ext/grpc/rb_channel_args.c +2 -2
- data/src/ruby/ext/grpc/rb_channel_credentials.c +4 -4
- data/src/ruby/ext/grpc/rb_channel_credentials.h +1 -0
- data/src/ruby/ext/grpc/rb_completion_queue.c +3 -2
- data/src/ruby/ext/grpc/rb_compression_options.c +5 -4
- data/src/ruby/ext/grpc/rb_event_thread.c +4 -4
- data/src/ruby/ext/grpc/rb_grpc.c +5 -4
- data/src/ruby/ext/grpc/rb_grpc.h +1 -0
- data/src/ruby/ext/grpc/rb_server.c +6 -5
- data/src/ruby/ext/grpc/rb_server_credentials.c +3 -3
- data/src/ruby/ext/grpc/rb_server_credentials.h +1 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +8 -5
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +3 -1
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +6 -5
- data/src/ruby/ext/grpc/rb_xds_server_credentials.h +3 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/boringssl-with-bazel/err_data.c +294 -292
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +52 -47
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utf8.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{asn1_locl.h → internal.h} +20 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/time_support.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +14 -3
- data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +5 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +5 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +5 -9
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +4 -6
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +34 -0
- data/third_party/boringssl-with-bazel/src/crypto/hrss/hrss.c +219 -121
- data/third_party/boringssl-with-bazel/src/crypto/hrss/internal.h +9 -2
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +23 -2
- data/third_party/boringssl-with-bazel/src/crypto/lhash/internal.h +253 -0
- data/third_party/boringssl-with-bazel/src/crypto/lhash/lhash.c +28 -23
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +7 -3
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pool/pool.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/fuchsia.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c +15 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +45 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +4 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +10 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +6 -23
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +25 -22
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +9 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +160 -74
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +0 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +8 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +3 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +6 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +25 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/hrss.h +14 -12
- data/third_party/boringssl-with-bazel/src/include/openssl/lhash.h +4 -205
- data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +3 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +5 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +58 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +184 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -5
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +9 -16
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +44 -2
- data/third_party/boringssl-with-bazel/src/ssl/{t1_lib.cc → extensions.cc} +24 -11
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +9 -0
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +75 -68
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +17 -9
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +25 -6
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +1 -2
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +11 -5
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +0 -49
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +121 -65
- data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +14 -6
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +9 -11
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +2 -2
- data/third_party/upb/upb/decode.c +129 -60
- data/third_party/upb/upb/decode.h +32 -4
- data/third_party/upb/upb/decode_fast.c +513 -500
- data/third_party/upb/upb/decode_fast.h +27 -0
- data/third_party/upb/upb/{decode.int.h → decode_internal.h} +38 -8
- data/third_party/upb/upb/def.c +171 -181
- data/third_party/upb/upb/def.h +41 -19
- data/third_party/upb/upb/def.hpp +29 -0
- data/third_party/upb/upb/encode.c +49 -16
- data/third_party/upb/upb/encode.h +29 -2
- data/third_party/upb/upb/msg.c +169 -28
- data/third_party/upb/upb/msg.h +75 -580
- data/third_party/upb/upb/msg_internal.h +687 -0
- data/third_party/upb/upb/port_def.inc +85 -24
- data/third_party/upb/upb/port_undef.inc +38 -1
- data/third_party/upb/upb/reflection.c +29 -37
- data/third_party/upb/upb/reflection.h +36 -8
- data/third_party/upb/upb/reflection.hpp +37 -0
- data/third_party/upb/upb/table.c +211 -86
- data/third_party/upb/upb/{table.int.h → table_internal.h} +56 -180
- data/third_party/upb/upb/text_encode.c +32 -4
- data/third_party/upb/upb/text_encode.h +26 -0
- data/third_party/upb/upb/upb.c +59 -8
- data/third_party/upb/upb/upb.h +36 -6
- data/third_party/upb/upb/upb.hpp +24 -0
- data/third_party/upb/upb/upb_internal.h +58 -0
- metadata +58 -56
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +0 -179
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +0 -38
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +0 -243
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +0 -148
- data/src/core/lib/gpr/tls_gcc.h +0 -52
- data/src/core/lib/gpr/tls_msvc.h +0 -54
- data/src/core/lib/gpr/tls_pthread.cc +0 -30
- data/src/core/lib/gpr/tls_pthread.h +0 -56
- data/src/core/lib/gpr/tls_stdcpp.h +0 -48
- data/src/core/lib/gprpp/atomic.h +0 -104
- data/src/core/lib/iomgr/endpoint_pair_uv.cc +0 -40
- data/src/core/lib/iomgr/iomgr_uv.cc +0 -43
- data/src/core/lib/iomgr/pollset_uv.cc +0 -95
- data/src/core/lib/iomgr/pollset_uv.h +0 -36
- data/src/core/lib/iomgr/sockaddr_custom.h +0 -54
- data/src/core/lib/iomgr/socket_utils_uv.cc +0 -49
- data/src/core/lib/iomgr/tcp_uv.cc +0 -421
- data/src/core/lib/iomgr/timer_uv.cc +0 -66
- data/third_party/upb/third_party/wyhash/wyhash.h +0 -145
- data/third_party/upb/upb/upb.int.h +0 -29
@@ -19,7 +19,6 @@
|
|
19
19
|
#include <grpc/support/port_platform.h>
|
20
20
|
|
21
21
|
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
|
22
|
-
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
23
22
|
|
24
23
|
#include <assert.h>
|
25
24
|
#include <stddef.h>
|
@@ -32,8 +31,10 @@
|
|
32
31
|
#include <grpc/support/log.h>
|
33
32
|
|
34
33
|
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
|
34
|
+
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
35
35
|
#include "src/core/lib/debug/stats.h"
|
36
36
|
#include "src/core/lib/gpr/string.h"
|
37
|
+
#include "src/core/lib/gprpp/match.h"
|
37
38
|
#include "src/core/lib/profiling/timers.h"
|
38
39
|
#include "src/core/lib/slice/slice_internal.h"
|
39
40
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
@@ -52,20 +53,6 @@ namespace grpc_core {
|
|
52
53
|
|
53
54
|
DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser(false, "chttp2_hpack_parser");
|
54
55
|
|
55
|
-
/* How parsing works:
|
56
|
-
|
57
|
-
The parser object keeps track of a function pointer which represents the
|
58
|
-
current parse state.
|
59
|
-
|
60
|
-
Each time new bytes are presented, we call into the current state, which
|
61
|
-
recursively parses until all bytes in the given chunk are exhausted.
|
62
|
-
|
63
|
-
The parse state that terminates then saves its function pointer to be the
|
64
|
-
current state so that it can resume when more bytes are available.
|
65
|
-
|
66
|
-
It's expected that most optimizing compilers will turn this code into
|
67
|
-
a set of indirect jumps, and so not waste stack space. */
|
68
|
-
|
69
56
|
/* state table for huffman decoding: given a state, gives an index/16 into
|
70
57
|
next_sub_tbl. Taking that index and adding the value of the nibble being
|
71
58
|
considered returns the next state.
|
@@ -464,1121 +451,877 @@ struct Base64InverseTable {
|
|
464
451
|
static GRPC_HPACK_CONSTEXPR_VALUE Base64InverseTable kBase64InverseTable;
|
465
452
|
} // namespace
|
466
453
|
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
454
|
+
// Input tracks the current byte through the input data and provides it
|
455
|
+
// via a simple stream interface.
|
456
|
+
class HPackParser::Input {
|
457
|
+
public:
|
458
|
+
Input(grpc_slice_refcount* current_slice_refcount, const uint8_t* begin,
|
459
|
+
const uint8_t* end)
|
460
|
+
: current_slice_refcount_(current_slice_refcount),
|
461
|
+
begin_(begin),
|
462
|
+
end_(end),
|
463
|
+
frontier_(begin) {}
|
464
|
+
|
465
|
+
// If input is backed by a slice, retrieve its refcount. If not, return
|
466
|
+
// nullptr.
|
467
|
+
grpc_slice_refcount* slice_refcount() { return current_slice_refcount_; }
|
468
|
+
|
469
|
+
// Have we reached the end of input?
|
470
|
+
bool end_of_stream() const { return begin_ == end_; }
|
471
|
+
// How many bytes until end of input
|
472
|
+
size_t remaining() const { return end_ - begin_; }
|
473
|
+
// Current position, as a pointer
|
474
|
+
const uint8_t* cur_ptr() const { return begin_; }
|
475
|
+
// End position, as a pointer
|
476
|
+
const uint8_t* end_ptr() const { return end_; }
|
477
|
+
// Move read position forward by n, unchecked
|
478
|
+
void Advance(size_t n) { begin_ += n; }
|
479
|
+
|
480
|
+
// Retrieve the current character, or nullopt if end of stream
|
481
|
+
// Do not advance
|
482
|
+
absl::optional<uint8_t> peek() const {
|
483
|
+
if (end_of_stream()) {
|
484
|
+
return {};
|
485
|
+
}
|
486
|
+
return *begin_;
|
479
487
|
}
|
480
|
-
gpr_log(
|
481
|
-
GPR_INFO,
|
482
|
-
"Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
|
483
|
-
k, v, GRPC_MDELEM_IS_INTERNED(md), GRPC_MDELEM_STORAGE(md),
|
484
|
-
grpc_slice_is_interned(GRPC_MDKEY(md)),
|
485
|
-
grpc_slice_is_interned(GRPC_MDVALUE(md)));
|
486
|
-
gpr_free(k);
|
487
|
-
gpr_free(v);
|
488
|
-
}
|
489
488
|
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
GPR_DEBUG_ASSERT(GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_INTERNED ||
|
498
|
-
GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC);
|
499
|
-
grpc_error_handle err = grpc_chttp2_hptbl_add(&table_, md);
|
500
|
-
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err;
|
489
|
+
// Retrieve and advance past the current character, or return nullopt if end
|
490
|
+
// of stream
|
491
|
+
absl::optional<uint8_t> Next() {
|
492
|
+
if (end_of_stream()) {
|
493
|
+
return UnexpectedEOF(absl::optional<uint8_t>());
|
494
|
+
}
|
495
|
+
return *begin_++;
|
501
496
|
}
|
502
|
-
return sink_(md);
|
503
|
-
}
|
504
497
|
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
498
|
+
// Helper to parse a varint delta on top of value, return nullopt on failure
|
499
|
+
// (setting error)
|
500
|
+
absl::optional<uint32_t> ParseVarint(uint32_t value) {
|
501
|
+
// TODO(ctiller): break out a variant of this when we know there are at
|
502
|
+
// least 5 bytes in input_
|
503
|
+
auto cur = Next();
|
504
|
+
if (!cur) return {};
|
505
|
+
value += *cur & 0x7f;
|
506
|
+
if ((*cur & 0x80) == 0) return value;
|
507
|
+
|
508
|
+
cur = Next();
|
509
|
+
if (!cur) return {};
|
510
|
+
value += (*cur & 0x7f) << 7;
|
511
|
+
if ((*cur & 0x80) == 0) return value;
|
512
|
+
|
513
|
+
cur = Next();
|
514
|
+
if (!cur) return {};
|
515
|
+
value += (*cur & 0x7f) << 14;
|
516
|
+
if ((*cur & 0x80) == 0) return value;
|
517
|
+
|
518
|
+
cur = Next();
|
519
|
+
if (!cur) return {};
|
520
|
+
value += (*cur & 0x7f) << 21;
|
521
|
+
if ((*cur & 0x80) == 0) return value;
|
522
|
+
|
523
|
+
cur = Next();
|
524
|
+
if (!cur) return {};
|
525
|
+
uint32_t c = (*cur) & 0x7f;
|
526
|
+
// We might overflow here, so we need to be a little careful about the
|
527
|
+
// addition
|
528
|
+
if (c > 0xf) return ParseVarintOutOfRange(value, *cur);
|
529
|
+
const uint32_t add = c << 28;
|
530
|
+
if (add > 0xffffffffu - value) {
|
531
|
+
return ParseVarintOutOfRange(value, *cur);
|
532
|
+
}
|
533
|
+
value += add;
|
534
|
+
if ((*cur & 0x80) == 0) return value;
|
535
|
+
|
536
|
+
// Spec weirdness: we can add an infinite stream of 0x80 at the end of a
|
537
|
+
// varint and still end up with a correctly encoded varint.
|
538
|
+
do {
|
539
|
+
cur = Next();
|
540
|
+
if (!cur.has_value()) return {};
|
541
|
+
} while (*cur == 0x80);
|
542
|
+
|
543
|
+
// BUT... the last byte needs to be 0x00 or we'll overflow dramatically!
|
544
|
+
if (*cur == 0) return value;
|
545
|
+
return ParseVarintOutOfRange(value, *cur);
|
514
546
|
}
|
515
|
-
data_.copied.length = 0;
|
516
|
-
return s;
|
517
|
-
}
|
518
547
|
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
548
|
+
// Prefix for a string
|
549
|
+
struct StringPrefix {
|
550
|
+
// Number of bytes in input for string
|
551
|
+
uint32_t length;
|
552
|
+
// Is it huffman compressed
|
553
|
+
bool huff;
|
554
|
+
};
|
555
|
+
|
556
|
+
// Parse a string prefix
|
557
|
+
absl::optional<StringPrefix> ParseStringPrefix() {
|
558
|
+
auto cur = Next();
|
559
|
+
if (!cur.has_value()) return {};
|
560
|
+
// Huffman if the top bit is 1
|
561
|
+
const bool huff = (*cur & 0x80) != 0;
|
562
|
+
// String length
|
563
|
+
uint32_t strlen = (*cur & 0x7f);
|
564
|
+
if (strlen == 0x7f) {
|
565
|
+
// all ones ==> varint string length
|
566
|
+
auto v = ParseVarint(0x7f);
|
567
|
+
if (!v.has_value()) return {};
|
568
|
+
strlen = *v;
|
569
|
+
}
|
570
|
+
return StringPrefix{strlen, huff};
|
528
571
|
}
|
529
|
-
data_.copied.length = 0;
|
530
|
-
return s;
|
531
|
-
}
|
532
572
|
|
533
|
-
|
534
|
-
|
535
|
-
state_ = *next_state_++;
|
536
|
-
return (this->*state_)(cur, end);
|
537
|
-
}
|
573
|
+
// Check if we saw an EOF.. must be verified before looking at TakeError
|
574
|
+
bool eof_error() const { return eof_error_; }
|
538
575
|
|
539
|
-
|
540
|
-
|
541
|
-
grpc_error_handle
|
542
|
-
|
543
|
-
|
544
|
-
state_ = &HPackParser::parse_begin;
|
545
|
-
return GRPC_ERROR_NONE;
|
576
|
+
// Extract the parse error, leaving the current error as NONE.
|
577
|
+
grpc_error_handle TakeError() {
|
578
|
+
grpc_error_handle out = error_;
|
579
|
+
error_ = GRPC_ERROR_NONE;
|
580
|
+
return out;
|
546
581
|
}
|
547
582
|
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
case 0: // literal key
|
558
|
-
return parse_lithdr_notidx_v(cur, end);
|
559
|
-
case 0xf: // varint encoded key index
|
560
|
-
return parse_lithdr_notidx_x(cur, end);
|
561
|
-
default: // inline encoded key index
|
562
|
-
return parse_lithdr_notidx(cur, end);
|
563
|
-
}
|
564
|
-
// Literal header never indexed.
|
565
|
-
// First byte format: 0001xxxx
|
566
|
-
// Where xxxx:
|
567
|
-
// 0000 - literal key
|
568
|
-
// 1111 - indexed key, varint encoded index
|
569
|
-
// other - indexed key, inline encoded index
|
570
|
-
case 1:
|
571
|
-
switch (*cur & 0xf) {
|
572
|
-
case 0: // literal key
|
573
|
-
return parse_lithdr_nvridx_v(cur, end);
|
574
|
-
case 0xf: // varint encoded key index
|
575
|
-
return parse_lithdr_nvridx_x(cur, end);
|
576
|
-
default: // inline encoded key index
|
577
|
-
return parse_lithdr_nvridx(cur, end);
|
578
|
-
}
|
579
|
-
// Update max table size.
|
580
|
-
// First byte format: 001xxxxx
|
581
|
-
// Where xxxxx:
|
582
|
-
// 11111 - max size is varint encoded
|
583
|
-
// other - max size is stored inline
|
584
|
-
case 2:
|
585
|
-
// inline encoded max table size
|
586
|
-
return parse_max_tbl_size(cur, end);
|
587
|
-
case 3:
|
588
|
-
if (*cur == 0x3f) {
|
589
|
-
// varint encoded max table size
|
590
|
-
return parse_max_tbl_size_x(cur, end);
|
591
|
-
} else {
|
592
|
-
// inline encoded max table size
|
593
|
-
return parse_max_tbl_size(cur, end);
|
594
|
-
}
|
595
|
-
// Literal header with incremental indexing.
|
596
|
-
// First byte format: 01xxxxxx
|
597
|
-
// Where xxxxxx:
|
598
|
-
// 000000 - literal key
|
599
|
-
// 111111 - indexed key, varint encoded index
|
600
|
-
// other - indexed key, inline encoded index
|
601
|
-
case 4:
|
602
|
-
if (*cur == 0x40) {
|
603
|
-
// literal key
|
604
|
-
return parse_lithdr_incidx_v(cur, end);
|
605
|
-
}
|
606
|
-
ABSL_FALLTHROUGH_INTENDED;
|
607
|
-
case 5:
|
608
|
-
case 6:
|
609
|
-
// inline encoded key index
|
610
|
-
return parse_lithdr_incidx(cur, end);
|
611
|
-
case 7:
|
612
|
-
if (*cur == 0x7f) {
|
613
|
-
// varint encoded key index
|
614
|
-
return parse_lithdr_incidx_x(cur, end);
|
615
|
-
} else {
|
616
|
-
// inline encoded key index
|
617
|
-
return parse_lithdr_incidx(cur, end);
|
618
|
-
}
|
619
|
-
// Indexed Header Field Representation
|
620
|
-
// First byte format: 1xxxxxxx
|
621
|
-
// Where xxxxxxx:
|
622
|
-
// 0000000 - illegal
|
623
|
-
// 1111111 - varint encoded field index
|
624
|
-
// other - inline encoded field index
|
625
|
-
case 8:
|
626
|
-
if (*cur == 0x80) {
|
627
|
-
// illegal value.
|
628
|
-
return parse_illegal_op(cur, end);
|
629
|
-
}
|
630
|
-
ABSL_FALLTHROUGH_INTENDED;
|
631
|
-
case 9:
|
632
|
-
case 10:
|
633
|
-
case 11:
|
634
|
-
case 12:
|
635
|
-
case 13:
|
636
|
-
case 14:
|
637
|
-
// inline encoded field index
|
638
|
-
return parse_indexed_field(cur, end);
|
639
|
-
case 15:
|
640
|
-
if (*cur == 0xff) {
|
641
|
-
// varint encoded field index
|
642
|
-
return parse_indexed_field_x(cur, end);
|
643
|
-
} else {
|
644
|
-
// inline encoded field index
|
645
|
-
return parse_indexed_field(cur, end);
|
646
|
-
}
|
583
|
+
// Set the current error - allows the rest of the code not to need to pass
|
584
|
+
// around StatusOr<> which would be prohibitive here.
|
585
|
+
GPR_ATTRIBUTE_NOINLINE void SetError(grpc_error_handle error) {
|
586
|
+
if (error_ != GRPC_ERROR_NONE || eof_error_) {
|
587
|
+
GRPC_ERROR_UNREF(error);
|
588
|
+
return;
|
589
|
+
}
|
590
|
+
error_ = error;
|
591
|
+
begin_ = end_;
|
647
592
|
}
|
648
|
-
GPR_UNREACHABLE_CODE(abort());
|
649
|
-
}
|
650
593
|
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
return
|
594
|
+
// If no error is set, set it to the value produced by error_factory.
|
595
|
+
// Return return_value unchanged.
|
596
|
+
template <typename F, typename T>
|
597
|
+
GPR_ATTRIBUTE_NOINLINE T MaybeSetErrorAndReturn(F error_factory,
|
598
|
+
T return_value) {
|
599
|
+
if (error_ != GRPC_ERROR_NONE || eof_error_) return return_value;
|
600
|
+
error_ = error_factory();
|
601
|
+
begin_ = end_;
|
602
|
+
return return_value;
|
657
603
|
}
|
658
604
|
|
659
|
-
return (
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
return GRPC_ERROR_NONE;
|
605
|
+
// Set the error to an unexpected eof, and return result (code golfed as this
|
606
|
+
// is a common case)
|
607
|
+
template <typename T>
|
608
|
+
T UnexpectedEOF(T return_value) {
|
609
|
+
if (error_ != GRPC_ERROR_NONE) return return_value;
|
610
|
+
eof_error_ = true;
|
611
|
+
return return_value;
|
667
612
|
}
|
668
613
|
|
669
|
-
|
670
|
-
}
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
614
|
+
// Update the frontier - signifies we've successfully parsed another element
|
615
|
+
void UpdateFrontier() { frontier_ = begin_; }
|
616
|
+
|
617
|
+
// Get the frontier - for buffering should we fail due to eof
|
618
|
+
const uint8_t* frontier() const { return frontier_; }
|
619
|
+
|
620
|
+
private:
|
621
|
+
// Helper to set the error to out of range for ParseVarint
|
622
|
+
absl::optional<uint32_t> ParseVarintOutOfRange(uint32_t value,
|
623
|
+
uint8_t last_byte) {
|
624
|
+
return MaybeSetErrorAndReturn(
|
625
|
+
[value, last_byte] {
|
626
|
+
return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrFormat(
|
627
|
+
"integer overflow in hpack integer decoding: have 0x%08x, "
|
628
|
+
"got byte 0x%02x on byte 5",
|
629
|
+
value, last_byte));
|
630
|
+
},
|
631
|
+
absl::optional<uint32_t>());
|
677
632
|
}
|
678
633
|
|
679
|
-
|
680
|
-
|
634
|
+
// Refcount if we are backed by a slice
|
635
|
+
grpc_slice_refcount* current_slice_refcount_;
|
636
|
+
// Current input point
|
637
|
+
const uint8_t* begin_;
|
638
|
+
// End of stream point
|
639
|
+
const uint8_t* const end_;
|
640
|
+
// Frontier denotes the first byte past successfully processed input
|
641
|
+
const uint8_t* frontier_;
|
642
|
+
// Current error
|
643
|
+
grpc_error_handle error_ = GRPC_ERROR_NONE;
|
644
|
+
// If the error was EOF, we flag it here..
|
645
|
+
bool eof_error_ = false;
|
646
|
+
};
|
681
647
|
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
648
|
+
// Helper to parse a string and turn it into a slice with appropriate memory
|
649
|
+
// management characteristics
|
650
|
+
class HPackParser::String {
|
651
|
+
public:
|
652
|
+
// Helper to specify a string should be internalized
|
653
|
+
struct Intern {};
|
654
|
+
// Helper to specify a string should be externalized
|
655
|
+
struct Extern {};
|
656
|
+
|
657
|
+
private:
|
658
|
+
// Forward declare take functions... we'll need them in the public interface
|
659
|
+
UnmanagedMemorySlice Take(Extern);
|
660
|
+
ManagedMemorySlice Take(Intern);
|
661
|
+
|
662
|
+
public:
|
663
|
+
// If a String is a Slice then unref
|
664
|
+
~String() {
|
665
|
+
if (auto* p = absl::get_if<grpc_slice>(&value_)) {
|
666
|
+
grpc_slice_unref_internal(*p);
|
667
|
+
}
|
687
668
|
}
|
688
669
|
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
if (cur == end) {
|
695
|
-
state_ = &HPackParser::parse_stream_dep0;
|
696
|
-
return GRPC_ERROR_NONE;
|
670
|
+
// Take the value and leave this empty
|
671
|
+
// Use Intern/Extern to choose memory management
|
672
|
+
template <typename T>
|
673
|
+
auto Take() -> decltype(this->Take(T())) {
|
674
|
+
return Take(T());
|
697
675
|
}
|
698
676
|
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
return grpc_error_set_int(
|
704
|
-
grpc_error_set_int(
|
705
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid HPACK index received"),
|
706
|
-
GRPC_ERROR_INT_INDEX, static_cast<intptr_t>(index_)),
|
707
|
-
GRPC_ERROR_INT_SIZE, static_cast<intptr_t>(table_.num_ents));
|
708
|
-
}
|
709
|
-
|
710
|
-
/* emit an indexed field; jumps to begin the next field on completion */
|
711
|
-
grpc_error_handle HPackParser::finish_indexed_field(const uint8_t* cur,
|
712
|
-
const uint8_t* end) {
|
713
|
-
grpc_mdelem md = grpc_chttp2_hptbl_lookup<true>(&table_, index_);
|
714
|
-
if (GPR_UNLIKELY(GRPC_MDISNULL(md))) {
|
715
|
-
return InvalidHPackIndexError();
|
677
|
+
String(const String&) = delete;
|
678
|
+
String& operator=(const String&) = delete;
|
679
|
+
String(String&& other) noexcept : value_(std::move(other.value_)) {
|
680
|
+
other.value_ = absl::Span<const uint8_t>();
|
716
681
|
}
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
}
|
722
|
-
|
723
|
-
/* parse an indexed field with index < 127 */
|
724
|
-
grpc_error_handle HPackParser::parse_indexed_field(const uint8_t* cur,
|
725
|
-
const uint8_t* end) {
|
726
|
-
dynamic_table_updates_allowed_ = 0;
|
727
|
-
index_ = (*cur) & 0x7f;
|
728
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
729
|
-
return finish_indexed_field(cur + 1, end);
|
730
|
-
}
|
731
|
-
|
732
|
-
/* parse an indexed field with index >= 127 */
|
733
|
-
grpc_error_handle HPackParser::parse_indexed_field_x(const uint8_t* cur,
|
734
|
-
const uint8_t* end) {
|
735
|
-
static const State and_then[] = {&HPackParser::finish_indexed_field};
|
736
|
-
dynamic_table_updates_allowed_ = 0;
|
737
|
-
next_state_ = and_then;
|
738
|
-
index_ = 0x7f;
|
739
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
740
|
-
parsing_.value = &index_;
|
741
|
-
return parse_value0(cur + 1, end);
|
742
|
-
}
|
743
|
-
|
744
|
-
/* When finishing with a header, get the cached md element for this index.
|
745
|
-
This is set in parse_value_string(). We ensure (in debug mode) that the
|
746
|
-
cached metadata corresponds with the index we are examining. */
|
747
|
-
grpc_mdelem HPackParser::GetPrecomputedMDForIndex() {
|
748
|
-
GPR_DEBUG_ASSERT(md_for_index_.payload != 0);
|
749
|
-
GPR_DEBUG_ASSERT(static_cast<int64_t>(index_) == precomputed_md_index_);
|
750
|
-
grpc_mdelem md = md_for_index_;
|
751
|
-
GPR_DEBUG_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
|
752
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
753
|
-
#ifndef NDEBUG
|
754
|
-
precomputed_md_index_ = -1;
|
755
|
-
#endif
|
756
|
-
return md;
|
757
|
-
}
|
758
|
-
|
759
|
-
static const grpc_core::ManagedMemorySlice& get_indexed_key(grpc_mdelem md) {
|
760
|
-
GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(md));
|
761
|
-
return static_cast<const grpc_core::ManagedMemorySlice&>(
|
762
|
-
grpc_slice_ref_internal(GRPC_MDKEY(md)));
|
763
|
-
}
|
764
|
-
|
765
|
-
/* finish a literal header with incremental indexing */
|
766
|
-
grpc_error_handle HPackParser::finish_lithdr_incidx(const uint8_t* cur,
|
767
|
-
const uint8_t* end) {
|
768
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX();
|
769
|
-
grpc_mdelem md = GetPrecomputedMDForIndex();
|
770
|
-
grpc_error_handle err = FinishHeader<TableAction::kAddToTable>(
|
771
|
-
grpc_mdelem_from_slices(get_indexed_key(md), value_.TakeIntern()));
|
772
|
-
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
773
|
-
return parse_begin(cur, end);
|
774
|
-
}
|
775
|
-
|
776
|
-
/* finish a literal header with incremental indexing with no index */
|
777
|
-
grpc_error_handle HPackParser::finish_lithdr_incidx_v(const uint8_t* cur,
|
778
|
-
const uint8_t* end) {
|
779
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V();
|
780
|
-
grpc_error_handle err = FinishHeader<TableAction::kAddToTable>(
|
781
|
-
grpc_mdelem_from_slices(key_.TakeIntern(), value_.TakeIntern()));
|
782
|
-
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
783
|
-
return parse_begin(cur, end);
|
784
|
-
}
|
785
|
-
|
786
|
-
/* parse a literal header with incremental indexing; index < 63 */
|
787
|
-
grpc_error_handle HPackParser::parse_lithdr_incidx(const uint8_t* cur,
|
788
|
-
const uint8_t* end) {
|
789
|
-
static const State and_then[] = {
|
790
|
-
&HPackParser::parse_value_string_with_indexed_key,
|
791
|
-
&HPackParser::finish_lithdr_incidx};
|
792
|
-
dynamic_table_updates_allowed_ = 0;
|
793
|
-
next_state_ = and_then;
|
794
|
-
index_ = (*cur) & 0x3f;
|
795
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
796
|
-
return parse_string_prefix(cur + 1, end);
|
797
|
-
}
|
798
|
-
|
799
|
-
/* parse a literal header with incremental indexing; index >= 63 */
|
800
|
-
grpc_error_handle HPackParser::parse_lithdr_incidx_x(const uint8_t* cur,
|
801
|
-
const uint8_t* end) {
|
802
|
-
static const State and_then[] = {
|
803
|
-
&HPackParser::parse_string_prefix,
|
804
|
-
&HPackParser::parse_value_string_with_indexed_key,
|
805
|
-
&HPackParser::finish_lithdr_incidx};
|
806
|
-
dynamic_table_updates_allowed_ = 0;
|
807
|
-
next_state_ = and_then;
|
808
|
-
index_ = 0x3f;
|
809
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
810
|
-
parsing_.value = &index_;
|
811
|
-
return parse_value0(cur + 1, end);
|
812
|
-
}
|
813
|
-
|
814
|
-
/* parse a literal header with incremental indexing; index = 0 */
|
815
|
-
grpc_error_handle HPackParser::parse_lithdr_incidx_v(const uint8_t* cur,
|
816
|
-
const uint8_t* end) {
|
817
|
-
static const State and_then[] = {
|
818
|
-
&HPackParser::parse_key_string, &HPackParser::parse_string_prefix,
|
819
|
-
&HPackParser::parse_value_string_with_literal_key,
|
820
|
-
&HPackParser::finish_lithdr_incidx_v};
|
821
|
-
dynamic_table_updates_allowed_ = 0;
|
822
|
-
next_state_ = and_then;
|
823
|
-
return parse_string_prefix(cur + 1, end);
|
824
|
-
}
|
825
|
-
|
826
|
-
/* finish a literal header without incremental indexing */
|
827
|
-
grpc_error_handle HPackParser::finish_lithdr_notidx(const uint8_t* cur,
|
828
|
-
const uint8_t* end) {
|
829
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX();
|
830
|
-
grpc_mdelem md = GetPrecomputedMDForIndex();
|
831
|
-
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(
|
832
|
-
grpc_mdelem_from_slices(get_indexed_key(md), value_.TakeExtern()));
|
833
|
-
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
834
|
-
return parse_begin(cur, end);
|
835
|
-
}
|
836
|
-
|
837
|
-
/* finish a literal header without incremental indexing with index = 0 */
|
838
|
-
grpc_error_handle HPackParser::finish_lithdr_notidx_v(const uint8_t* cur,
|
839
|
-
const uint8_t* end) {
|
840
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V();
|
841
|
-
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(
|
842
|
-
grpc_mdelem_from_slices(key_.TakeIntern(), value_.TakeExtern()));
|
843
|
-
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
844
|
-
return parse_begin(cur, end);
|
845
|
-
}
|
846
|
-
|
847
|
-
/* parse a literal header without incremental indexing; index < 15 */
|
848
|
-
grpc_error_handle HPackParser::parse_lithdr_notidx(const uint8_t* cur,
|
849
|
-
const uint8_t* end) {
|
850
|
-
static const State and_then[] = {
|
851
|
-
&HPackParser::parse_value_string_with_indexed_key,
|
852
|
-
&HPackParser::finish_lithdr_notidx};
|
853
|
-
dynamic_table_updates_allowed_ = 0;
|
854
|
-
next_state_ = and_then;
|
855
|
-
index_ = (*cur) & 0xf;
|
856
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
857
|
-
return parse_string_prefix(cur + 1, end);
|
858
|
-
}
|
859
|
-
|
860
|
-
/* parse a literal header without incremental indexing; index >= 15 */
|
861
|
-
grpc_error_handle HPackParser::parse_lithdr_notidx_x(const uint8_t* cur,
|
862
|
-
const uint8_t* end) {
|
863
|
-
static const State and_then[] = {
|
864
|
-
&HPackParser::parse_string_prefix,
|
865
|
-
&HPackParser::parse_value_string_with_indexed_key,
|
866
|
-
&HPackParser::finish_lithdr_notidx};
|
867
|
-
dynamic_table_updates_allowed_ = 0;
|
868
|
-
next_state_ = and_then;
|
869
|
-
index_ = 0xf;
|
870
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
871
|
-
parsing_.value = &index_;
|
872
|
-
return parse_value0(cur + 1, end);
|
873
|
-
}
|
874
|
-
|
875
|
-
/* parse a literal header without incremental indexing; index == 0 */
|
876
|
-
grpc_error_handle HPackParser::parse_lithdr_notidx_v(const uint8_t* cur,
|
877
|
-
const uint8_t* end) {
|
878
|
-
static const State and_then[] = {
|
879
|
-
&HPackParser::parse_key_string, &HPackParser::parse_string_prefix,
|
880
|
-
&HPackParser::parse_value_string_with_literal_key,
|
881
|
-
&HPackParser::finish_lithdr_notidx_v};
|
882
|
-
dynamic_table_updates_allowed_ = 0;
|
883
|
-
next_state_ = and_then;
|
884
|
-
return parse_string_prefix(cur + 1, end);
|
885
|
-
}
|
886
|
-
|
887
|
-
/* finish a literal header that is never indexed */
|
888
|
-
grpc_error_handle HPackParser::finish_lithdr_nvridx(const uint8_t* cur,
|
889
|
-
const uint8_t* end) {
|
890
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX();
|
891
|
-
grpc_mdelem md = GetPrecomputedMDForIndex();
|
892
|
-
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(
|
893
|
-
grpc_mdelem_from_slices(get_indexed_key(md), value_.TakeExtern()));
|
894
|
-
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
895
|
-
return parse_begin(cur, end);
|
896
|
-
}
|
897
|
-
|
898
|
-
/* finish a literal header that is never indexed with an extra value */
|
899
|
-
grpc_error_handle HPackParser::finish_lithdr_nvridx_v(const uint8_t* cur,
|
900
|
-
const uint8_t* end) {
|
901
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V();
|
902
|
-
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(
|
903
|
-
grpc_mdelem_from_slices(key_.TakeIntern(), value_.TakeExtern()));
|
904
|
-
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
905
|
-
return parse_begin(cur, end);
|
906
|
-
}
|
907
|
-
|
908
|
-
/* parse a literal header that is never indexed; index < 15 */
|
909
|
-
grpc_error_handle HPackParser::parse_lithdr_nvridx(const uint8_t* cur,
|
910
|
-
const uint8_t* end) {
|
911
|
-
static const State and_then[] = {
|
912
|
-
&HPackParser::parse_value_string_with_indexed_key,
|
913
|
-
&HPackParser::finish_lithdr_nvridx};
|
914
|
-
dynamic_table_updates_allowed_ = 0;
|
915
|
-
next_state_ = and_then;
|
916
|
-
index_ = (*cur) & 0xf;
|
917
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
918
|
-
return parse_string_prefix(cur + 1, end);
|
919
|
-
}
|
920
|
-
|
921
|
-
/* parse a literal header that is never indexed; index >= 15 */
|
922
|
-
grpc_error_handle HPackParser::parse_lithdr_nvridx_x(const uint8_t* cur,
|
923
|
-
const uint8_t* end) {
|
924
|
-
static const State and_then[] = {
|
925
|
-
&HPackParser::parse_string_prefix,
|
926
|
-
&HPackParser::parse_value_string_with_indexed_key,
|
927
|
-
&HPackParser::finish_lithdr_nvridx};
|
928
|
-
dynamic_table_updates_allowed_ = 0;
|
929
|
-
next_state_ = and_then;
|
930
|
-
index_ = 0xf;
|
931
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
932
|
-
parsing_.value = &index_;
|
933
|
-
return parse_value0(cur + 1, end);
|
934
|
-
}
|
935
|
-
|
936
|
-
/* parse a literal header that is never indexed; index == 0 */
|
937
|
-
grpc_error_handle HPackParser::parse_lithdr_nvridx_v(const uint8_t* cur,
|
938
|
-
const uint8_t* end) {
|
939
|
-
static const State and_then[] = {
|
940
|
-
&HPackParser::parse_key_string, &HPackParser::parse_string_prefix,
|
941
|
-
&HPackParser::parse_value_string_with_literal_key,
|
942
|
-
&HPackParser::finish_lithdr_nvridx_v};
|
943
|
-
dynamic_table_updates_allowed_ = 0;
|
944
|
-
next_state_ = and_then;
|
945
|
-
return parse_string_prefix(cur + 1, end);
|
946
|
-
}
|
947
|
-
|
948
|
-
/* finish parsing a max table size change */
|
949
|
-
grpc_error_handle HPackParser::finish_max_tbl_size(const uint8_t* cur,
|
950
|
-
const uint8_t* end) {
|
951
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
952
|
-
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", index_);
|
682
|
+
String& operator=(String&& other) noexcept {
|
683
|
+
value_ = std::move(other.value_);
|
684
|
+
other.value_ = absl::Span<const uint8_t>();
|
685
|
+
return *this;
|
953
686
|
}
|
954
|
-
grpc_error_handle err =
|
955
|
-
grpc_chttp2_hptbl_set_current_table_size(&table_, index_);
|
956
|
-
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
957
|
-
return parse_begin(cur, end);
|
958
|
-
}
|
959
687
|
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
688
|
+
// Parse a non-binary string
|
689
|
+
static absl::optional<String> Parse(Input* input) {
|
690
|
+
auto pfx = input->ParseStringPrefix();
|
691
|
+
if (!pfx.has_value()) return {};
|
692
|
+
if (pfx->huff) {
|
693
|
+
// Huffman coded
|
694
|
+
std::vector<uint8_t> output;
|
695
|
+
auto v = ParseHuff(input, pfx->length,
|
696
|
+
[&output](uint8_t c) { output.push_back(c); });
|
697
|
+
if (!v) return {};
|
698
|
+
return String(std::move(output));
|
699
|
+
}
|
700
|
+
return ParseUncompressed(input, pfx->length);
|
968
701
|
}
|
969
|
-
dynamic_table_updates_allowed_--;
|
970
|
-
index_ = (*cur) & 0x1f;
|
971
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
972
|
-
return finish_max_tbl_size(cur + 1, end);
|
973
|
-
}
|
974
702
|
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
703
|
+
// Parse a binary string
|
704
|
+
static absl::optional<String> ParseBinary(Input* input) {
|
705
|
+
auto pfx = input->ParseStringPrefix();
|
706
|
+
if (!pfx.has_value()) return {};
|
707
|
+
if (!pfx->huff) {
|
708
|
+
if (pfx->length > 0 && input->peek() == 0) {
|
709
|
+
// 'true-binary'
|
710
|
+
input->Advance(1);
|
711
|
+
return ParseUncompressed(input, pfx->length - 1);
|
712
|
+
}
|
713
|
+
// Base64 encoded... pull out the string, then unbase64 it
|
714
|
+
auto base64 = ParseUncompressed(input, pfx->length);
|
715
|
+
if (!base64.has_value()) return {};
|
716
|
+
return Unbase64(input, std::move(*base64));
|
717
|
+
} else {
|
718
|
+
// Huffman encoded...
|
719
|
+
std::vector<uint8_t> decompressed;
|
720
|
+
// State here says either we don't know if it's base64 or binary, or we do
|
721
|
+
// and what is it.
|
722
|
+
enum class State { kUnsure, kBinary, kBase64 };
|
723
|
+
State state = State::kUnsure;
|
724
|
+
auto decompressed_ok =
|
725
|
+
ParseHuff(input, pfx->length, [&state, &decompressed](uint8_t c) {
|
726
|
+
if (state == State::kUnsure) {
|
727
|
+
// First byte... if it's zero it's binary
|
728
|
+
if (c == 0) {
|
729
|
+
// Save the type, and skip the zero
|
730
|
+
state = State::kBinary;
|
731
|
+
return;
|
732
|
+
} else {
|
733
|
+
// Flag base64, store this value
|
734
|
+
state = State::kBase64;
|
735
|
+
}
|
736
|
+
}
|
737
|
+
// Non-first byte, or base64 first byte
|
738
|
+
decompressed.push_back(c);
|
739
|
+
});
|
740
|
+
if (!decompressed_ok) return {};
|
741
|
+
switch (state) {
|
742
|
+
case State::kUnsure:
|
743
|
+
// No bytes, empty span
|
744
|
+
return String(absl::Span<const uint8_t>());
|
745
|
+
case State::kBinary:
|
746
|
+
// Binary, we're done
|
747
|
+
return String(std::move(decompressed));
|
748
|
+
case State::kBase64:
|
749
|
+
// Base64 - unpack it
|
750
|
+
return Unbase64(input, String(std::move(decompressed)));
|
751
|
+
}
|
752
|
+
GPR_UNREACHABLE_CODE(abort(););
|
753
|
+
}
|
984
754
|
}
|
985
|
-
dynamic_table_updates_allowed_--;
|
986
|
-
next_state_ = and_then;
|
987
|
-
index_ = 0x1f;
|
988
|
-
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
989
|
-
parsing_.value = &index_;
|
990
|
-
return parse_value0(cur + 1, end);
|
991
|
-
}
|
992
755
|
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
756
|
+
private:
|
757
|
+
void AppendBytes(const uint8_t* data, size_t length);
|
758
|
+
explicit String(std::vector<uint8_t> v) : value_(std::move(v)) {}
|
759
|
+
explicit String(absl::Span<const uint8_t> v) : value_(v) {}
|
760
|
+
String(grpc_slice_refcount* r, const uint8_t* begin, const uint8_t* end)
|
761
|
+
: value_(MakeSlice(r, begin, end)) {}
|
762
|
+
|
763
|
+
// Given a refcount and a byte range, make a slice
|
764
|
+
static grpc_slice MakeSlice(grpc_slice_refcount* r, const uint8_t* begin,
|
765
|
+
const uint8_t* end) {
|
766
|
+
grpc_slice out;
|
767
|
+
out.refcount = r;
|
768
|
+
r->Ref();
|
769
|
+
out.data.refcounted.bytes = const_cast<uint8_t*>(begin);
|
770
|
+
out.data.refcounted.length = end - begin;
|
771
|
+
return out;
|
1000
772
|
}
|
1001
|
-
state_ = &HPackParser::still_parse_error;
|
1002
|
-
return err;
|
1003
|
-
}
|
1004
773
|
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
774
|
+
// Parse some huffman encoded bytes, using output(uint8_t b) to emit each
|
775
|
+
// decoded byte.
|
776
|
+
template <typename Out>
|
777
|
+
static bool ParseHuff(Input* input, uint32_t length, Out output) {
|
778
|
+
GRPC_STATS_INC_HPACK_RECV_HUFFMAN();
|
779
|
+
int16_t state = 0;
|
780
|
+
// Parse one half byte... we leverage some lookup tables to keep the logic
|
781
|
+
// here really simple.
|
782
|
+
auto nibble = [&output, &state](uint8_t nibble) {
|
783
|
+
int16_t emit = emit_sub_tbl[16 * emit_tbl[state] + nibble];
|
784
|
+
int16_t next = next_sub_tbl[16 * next_tbl[state] + nibble];
|
785
|
+
if (emit != -1) {
|
786
|
+
if (emit >= 0 && emit < 256) {
|
787
|
+
output(static_cast<uint8_t>(emit));
|
788
|
+
} else {
|
789
|
+
assert(emit == 256);
|
790
|
+
}
|
791
|
+
}
|
792
|
+
state = next;
|
793
|
+
};
|
794
|
+
// If there's insufficient bytes remaining, return now.
|
795
|
+
if (input->remaining() < length) {
|
796
|
+
return input->UnexpectedEOF(false);
|
797
|
+
}
|
798
|
+
// Grab the byte range, and iterate through it.
|
799
|
+
const uint8_t* p = input->cur_ptr();
|
800
|
+
input->Advance(length);
|
801
|
+
for (uint32_t i = 0; i < length; i++) {
|
802
|
+
nibble(p[i] >> 4);
|
803
|
+
nibble(p[i] & 0xf);
|
804
|
+
}
|
805
|
+
return true;
|
1025
806
|
}
|
1026
807
|
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
808
|
+
// Parse some uncompressed string bytes.
|
809
|
+
static absl::optional<String> ParseUncompressed(Input* input,
|
810
|
+
uint32_t length) {
|
811
|
+
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
812
|
+
// Check there's enough bytes
|
813
|
+
if (input->remaining() < length) {
|
814
|
+
return input->UnexpectedEOF(absl::optional<String>());
|
815
|
+
}
|
816
|
+
auto* refcount = input->slice_refcount();
|
817
|
+
auto* p = input->cur_ptr();
|
818
|
+
input->Advance(length);
|
819
|
+
if (refcount != nullptr) {
|
820
|
+
return String(refcount, p, p + length);
|
821
|
+
} else {
|
822
|
+
return String(absl::Span<const uint8_t>(p, length));
|
823
|
+
}
|
1033
824
|
}
|
1034
|
-
}
|
1035
825
|
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
826
|
+
// Turn base64 encoded bytes into not base64 encoded bytes.
|
827
|
+
// Only takes input to set an error on failure.
|
828
|
+
static absl::optional<String> Unbase64(Input* input, String s) {
|
829
|
+
auto v = Match(
|
830
|
+
s.value_,
|
831
|
+
[](const grpc_slice& slice) {
|
832
|
+
return Unbase64Loop(GRPC_SLICE_START_PTR(slice),
|
833
|
+
GRPC_SLICE_END_PTR(slice));
|
834
|
+
},
|
835
|
+
[](absl::Span<const uint8_t> span) {
|
836
|
+
return Unbase64Loop(span.begin(), span.end());
|
837
|
+
},
|
838
|
+
[](const std::vector<uint8_t>& vec) {
|
839
|
+
return Unbase64Loop(vec.data(), vec.data() + vec.size());
|
840
|
+
});
|
841
|
+
if (!v.has_value()) {
|
842
|
+
return input->MaybeSetErrorAndReturn(
|
843
|
+
[] {
|
844
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
845
|
+
"illegal base64 encoding");
|
846
|
+
},
|
847
|
+
absl::optional<String>());
|
848
|
+
}
|
849
|
+
return String(std::move(*v));
|
1043
850
|
}
|
1044
851
|
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
}
|
1052
|
-
}
|
852
|
+
// Main loop for Unbase64
|
853
|
+
static absl::optional<std::vector<uint8_t>> Unbase64Loop(const uint8_t* cur,
|
854
|
+
const uint8_t* end) {
|
855
|
+
while (cur != end && end[-1] == '=') {
|
856
|
+
--end;
|
857
|
+
}
|
1053
858
|
|
1054
|
-
|
1055
|
-
|
1056
|
-
grpc_error_handle HPackParser::parse_value2(const uint8_t* cur,
|
1057
|
-
const uint8_t* end) {
|
1058
|
-
if (cur == end) {
|
1059
|
-
state_ = &HPackParser::parse_value2;
|
1060
|
-
return GRPC_ERROR_NONE;
|
1061
|
-
}
|
859
|
+
std::vector<uint8_t> out;
|
860
|
+
out.reserve(3 * (end - cur) / 4 + 3);
|
1062
861
|
|
1063
|
-
|
862
|
+
// Decode 4 bytes at a time while we can
|
863
|
+
while (end - cur >= 4) {
|
864
|
+
uint32_t bits = kBase64InverseTable.table[*cur];
|
865
|
+
if (bits > 63) return {};
|
866
|
+
uint32_t buffer = bits << 18;
|
867
|
+
++cur;
|
1064
868
|
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
}
|
1070
|
-
}
|
869
|
+
bits = kBase64InverseTable.table[*cur];
|
870
|
+
if (bits > 63) return {};
|
871
|
+
buffer |= bits << 12;
|
872
|
+
++cur;
|
1071
873
|
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
if (cur == end) {
|
1077
|
-
state_ = &HPackParser::parse_value3;
|
1078
|
-
return GRPC_ERROR_NONE;
|
1079
|
-
}
|
874
|
+
bits = kBase64InverseTable.table[*cur];
|
875
|
+
if (bits > 63) return {};
|
876
|
+
buffer |= bits << 6;
|
877
|
+
++cur;
|
1080
878
|
|
1081
|
-
|
879
|
+
bits = kBase64InverseTable.table[*cur];
|
880
|
+
if (bits > 63) return {};
|
881
|
+
buffer |= bits;
|
882
|
+
++cur;
|
1082
883
|
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
884
|
+
out.insert(out.end(), {static_cast<uint8_t>(buffer >> 16),
|
885
|
+
static_cast<uint8_t>(buffer >> 8),
|
886
|
+
static_cast<uint8_t>(buffer)});
|
887
|
+
}
|
888
|
+
// Deal with the last 0, 1, 2, or 3 bytes.
|
889
|
+
switch (end - cur) {
|
890
|
+
case 0:
|
891
|
+
return out;
|
892
|
+
case 1:
|
893
|
+
return {};
|
894
|
+
case 2: {
|
895
|
+
uint32_t bits = kBase64InverseTable.table[*cur];
|
896
|
+
if (bits > 63) return {};
|
897
|
+
uint32_t buffer = bits << 18;
|
1089
898
|
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
uint8_t c;
|
1095
|
-
uint32_t cur_value;
|
1096
|
-
uint32_t add_value;
|
899
|
+
++cur;
|
900
|
+
bits = kBase64InverseTable.table[*cur];
|
901
|
+
if (bits > 63) return {};
|
902
|
+
buffer |= bits << 12;
|
1097
903
|
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
904
|
+
if (buffer & 0xffff) return {};
|
905
|
+
out.push_back(static_cast<uint8_t>(buffer >> 16));
|
906
|
+
return out;
|
907
|
+
}
|
908
|
+
case 3: {
|
909
|
+
uint32_t bits = kBase64InverseTable.table[*cur];
|
910
|
+
if (bits > 63) return {};
|
911
|
+
uint32_t buffer = bits << 18;
|
1102
912
|
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
913
|
+
++cur;
|
914
|
+
bits = kBase64InverseTable.table[*cur];
|
915
|
+
if (bits > 63) return {};
|
916
|
+
buffer |= bits << 12;
|
1107
917
|
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
}
|
918
|
+
++cur;
|
919
|
+
bits = kBase64InverseTable.table[*cur];
|
920
|
+
if (bits > 63) return {};
|
921
|
+
buffer |= bits << 6;
|
1113
922
|
|
1114
|
-
|
923
|
+
++cur;
|
924
|
+
if (buffer & 0xff) return {};
|
925
|
+
out.push_back(static_cast<uint8_t>(buffer >> 16));
|
926
|
+
out.push_back(static_cast<uint8_t>(buffer >> 8));
|
927
|
+
return out;
|
928
|
+
}
|
929
|
+
}
|
1115
930
|
|
1116
|
-
|
1117
|
-
return parse_value5up(cur + 1, end);
|
1118
|
-
} else {
|
1119
|
-
return parse_next(cur + 1, end);
|
931
|
+
GPR_UNREACHABLE_CODE(return out;);
|
1120
932
|
}
|
1121
933
|
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
"integer overflow in hpack integer decoding: have 0x%08x, "
|
1126
|
-
"got byte 0x%02x on byte 5",
|
1127
|
-
*parsing_.value, *cur)
|
1128
|
-
.c_str());
|
1129
|
-
return parse_error(cur, end, err);
|
1130
|
-
}
|
934
|
+
absl::variant<grpc_slice, absl::Span<const uint8_t>, std::vector<uint8_t>>
|
935
|
+
value_;
|
936
|
+
};
|
1131
937
|
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
938
|
+
// Parser parses one frame + continuations worth of headers.
|
939
|
+
class HPackParser::Parser {
|
940
|
+
public:
|
941
|
+
Parser(Input* input, HPackParser::Sink* sink, HPackTable* table,
|
942
|
+
uint8_t* dynamic_table_updates_allowed)
|
943
|
+
: input_(input),
|
944
|
+
sink_(sink),
|
945
|
+
table_(table),
|
946
|
+
dynamic_table_updates_allowed_(dynamic_table_updates_allowed) {}
|
947
|
+
|
948
|
+
// Skip any priority bits, or return false on failure
|
949
|
+
bool SkipPriority() {
|
950
|
+
if (input_->remaining() < 5) return input_->UnexpectedEOF(false);
|
951
|
+
input_->Advance(5);
|
952
|
+
return true;
|
1139
953
|
}
|
1140
954
|
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
955
|
+
bool Parse() {
|
956
|
+
auto cur = *input_->Next();
|
957
|
+
switch (cur >> 4) {
|
958
|
+
// Literal header not indexed - First byte format: 0000xxxx
|
959
|
+
// Literal header never indexed - First byte format: 0001xxxx
|
960
|
+
// Where xxxx:
|
961
|
+
// 0000 - literal key
|
962
|
+
// 1111 - indexed key, varint encoded index
|
963
|
+
// other - indexed key, inline encoded index
|
964
|
+
case 0:
|
965
|
+
case 1:
|
966
|
+
switch (cur & 0xf) {
|
967
|
+
case 0: // literal key
|
968
|
+
return FinishHeader<TableAction::kOmitFromTable>(
|
969
|
+
ParseLiteralKey<String::Extern>());
|
970
|
+
case 0xf: // varint encoded key index
|
971
|
+
return FinishHeader<TableAction::kOmitFromTable>(
|
972
|
+
ParseVarIdxKey<String::Extern>(0xf));
|
973
|
+
default: // inline encoded key index
|
974
|
+
return FinishHeader<TableAction::kOmitFromTable>(
|
975
|
+
ParseIdxKey<String::Extern>(cur & 0xf));
|
976
|
+
}
|
977
|
+
// Update max table size.
|
978
|
+
// First byte format: 001xxxxx
|
979
|
+
// Where xxxxx:
|
980
|
+
// 11111 - max size is varint encoded
|
981
|
+
// other - max size is stored inline
|
982
|
+
case 2:
|
983
|
+
// inline encoded max table size
|
984
|
+
return FinishMaxTableSize(cur & 0x1f);
|
985
|
+
case 3:
|
986
|
+
if (cur == 0x3f) {
|
987
|
+
// varint encoded max table size
|
988
|
+
return FinishMaxTableSize(input_->ParseVarint(0x1f));
|
989
|
+
} else {
|
990
|
+
// inline encoded max table size
|
991
|
+
return FinishMaxTableSize(cur & 0x1f);
|
992
|
+
}
|
993
|
+
// Literal header with incremental indexing.
|
994
|
+
// First byte format: 01xxxxxx
|
995
|
+
// Where xxxxxx:
|
996
|
+
// 000000 - literal key
|
997
|
+
// 111111 - indexed key, varint encoded index
|
998
|
+
// other - indexed key, inline encoded index
|
999
|
+
case 4:
|
1000
|
+
if (cur == 0x40) {
|
1001
|
+
// literal key
|
1002
|
+
return FinishHeader<TableAction::kAddToTable>(
|
1003
|
+
ParseLiteralKey<String::Intern>());
|
1004
|
+
}
|
1005
|
+
ABSL_FALLTHROUGH_INTENDED;
|
1006
|
+
case 5:
|
1007
|
+
case 6:
|
1008
|
+
// inline encoded key index
|
1009
|
+
return FinishHeader<TableAction::kAddToTable>(
|
1010
|
+
ParseIdxKey<String::Intern>(cur & 0x3f));
|
1011
|
+
case 7:
|
1012
|
+
if (cur == 0x7f) {
|
1013
|
+
// varint encoded key index
|
1014
|
+
return FinishHeader<TableAction::kAddToTable>(
|
1015
|
+
ParseVarIdxKey<String::Intern>(0x3f));
|
1016
|
+
} else {
|
1017
|
+
// inline encoded key index
|
1018
|
+
return FinishHeader<TableAction::kAddToTable>(
|
1019
|
+
ParseIdxKey<String::Intern>(cur & 0x3f));
|
1020
|
+
}
|
1021
|
+
// Indexed Header Field Representation
|
1022
|
+
// First byte format: 1xxxxxxx
|
1023
|
+
// Where xxxxxxx:
|
1024
|
+
// 0000000 - illegal
|
1025
|
+
// 1111111 - varint encoded field index
|
1026
|
+
// other - inline encoded field index
|
1027
|
+
case 8:
|
1028
|
+
if (cur == 0x80) {
|
1029
|
+
// illegal value.
|
1030
|
+
return input_->MaybeSetErrorAndReturn(
|
1031
|
+
[] {
|
1032
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1033
|
+
"Illegal hpack op code");
|
1034
|
+
},
|
1035
|
+
false);
|
1036
|
+
}
|
1037
|
+
ABSL_FALLTHROUGH_INTENDED;
|
1038
|
+
case 9:
|
1039
|
+
case 10:
|
1040
|
+
case 11:
|
1041
|
+
case 12:
|
1042
|
+
case 13:
|
1043
|
+
case 14:
|
1044
|
+
// inline encoded field index
|
1045
|
+
return FinishIndexed(cur & 0x7f);
|
1046
|
+
case 15:
|
1047
|
+
if (cur == 0xff) {
|
1048
|
+
// varint encoded field index
|
1049
|
+
return FinishIndexed(input_->ParseVarint(0x7f));
|
1050
|
+
} else {
|
1051
|
+
// inline encoded field index
|
1052
|
+
return FinishIndexed(cur & 0x7f);
|
1053
|
+
}
|
1054
|
+
}
|
1055
|
+
GPR_UNREACHABLE_CODE(abort());
|
1144
1056
|
}
|
1145
1057
|
|
1146
|
-
|
1147
|
-
|
1058
|
+
private:
|
1059
|
+
void GPR_ATTRIBUTE_NOINLINE LogHeader(grpc_mdelem md) {
|
1060
|
+
char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
|
1061
|
+
char* v = nullptr;
|
1062
|
+
if (grpc_is_binary_header_internal(GRPC_MDKEY(md))) {
|
1063
|
+
v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX);
|
1064
|
+
} else {
|
1065
|
+
v = grpc_slice_to_c_string(GRPC_MDVALUE(md));
|
1066
|
+
}
|
1067
|
+
gpr_log(
|
1068
|
+
GPR_INFO,
|
1069
|
+
"Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
|
1070
|
+
k, v, GRPC_MDELEM_IS_INTERNED(md), GRPC_MDELEM_STORAGE(md),
|
1071
|
+
grpc_slice_is_interned(GRPC_MDKEY(md)),
|
1072
|
+
grpc_slice_is_interned(GRPC_MDVALUE(md)));
|
1073
|
+
gpr_free(k);
|
1074
|
+
gpr_free(v);
|
1148
1075
|
}
|
1149
1076
|
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1077
|
+
// During FinishHeader, how should the header be treated in the hpack table
|
1078
|
+
enum class TableAction {
|
1079
|
+
// Add to the table
|
1080
|
+
kAddToTable,
|
1081
|
+
// Do not add to the table
|
1082
|
+
kOmitFromTable,
|
1083
|
+
};
|
1084
|
+
|
1085
|
+
template <TableAction action>
|
1086
|
+
bool FinishHeader(grpc_mdelem md) {
|
1087
|
+
// Allow higher code to just pass in failures ... simplifies things a bit.
|
1088
|
+
if (GRPC_MDISNULL(md)) return false;
|
1089
|
+
// Log if desired
|
1090
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1091
|
+
LogHeader(md);
|
1092
|
+
}
|
1093
|
+
// Add to the hpack table if needed
|
1094
|
+
if (action == TableAction::kAddToTable) {
|
1095
|
+
GPR_DEBUG_ASSERT(GRPC_MDELEM_STORAGE(md) ==
|
1096
|
+
GRPC_MDELEM_STORAGE_INTERNED ||
|
1097
|
+
GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC);
|
1098
|
+
grpc_error_handle err = table_->Add(md);
|
1099
|
+
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
|
1100
|
+
input_->SetError(err);
|
1101
|
+
return false;
|
1102
|
+
};
|
1103
|
+
}
|
1104
|
+
// Pass up to the transport
|
1105
|
+
grpc_error_handle err = (*sink_)(md);
|
1106
|
+
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
|
1107
|
+
input_->SetError(err);
|
1108
|
+
return false;
|
1109
|
+
}
|
1110
|
+
return true;
|
1165
1111
|
}
|
1166
1112
|
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1113
|
+
// Parse a string encoded key and a string encoded value
|
1114
|
+
template <typename TakeValueType>
|
1115
|
+
grpc_mdelem ParseLiteralKey() {
|
1116
|
+
auto key = String::Parse(input_);
|
1117
|
+
if (!key.has_value()) return GRPC_MDNULL;
|
1118
|
+
auto key_slice = key->Take<String::Intern>();
|
1119
|
+
auto value = ParseValueString(key_slice);
|
1120
|
+
if (GPR_UNLIKELY(!value.has_value())) {
|
1121
|
+
grpc_slice_unref_internal(key_slice);
|
1122
|
+
return GRPC_MDNULL;
|
1123
|
+
}
|
1124
|
+
return grpc_mdelem_from_slices(key_slice, value->Take<TakeValueType>());
|
1174
1125
|
}
|
1175
|
-
}
|
1176
1126
|
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1127
|
+
// Parse an index encoded key and a string encoded value
|
1128
|
+
template <typename TakeValueType>
|
1129
|
+
grpc_mdelem ParseIdxKey(uint32_t index) {
|
1130
|
+
auto elem = table_->Peek(index);
|
1131
|
+
if (GPR_UNLIKELY(GRPC_MDISNULL(elem))) {
|
1132
|
+
return InvalidHPackIndexError(index, elem);
|
1133
|
+
}
|
1134
|
+
GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(elem));
|
1135
|
+
auto value = ParseValueString(GRPC_MDKEY(elem));
|
1136
|
+
if (GPR_UNLIKELY(!value.has_value())) return GRPC_MDNULL;
|
1137
|
+
return grpc_mdelem_from_slices(
|
1138
|
+
static_cast<const ManagedMemorySlice&>(
|
1139
|
+
grpc_slice_ref_internal(GRPC_MDKEY(elem))),
|
1140
|
+
value->Take<TakeValueType>());
|
1185
1141
|
}
|
1186
|
-
memcpy(data_.copied.str + data_.copied.length, data, length);
|
1187
|
-
GPR_ASSERT(length <= UINT32_MAX - data_.copied.length);
|
1188
|
-
data_.copied.length += static_cast<uint32_t>(length);
|
1189
|
-
}
|
1190
1142
|
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
case BinaryState::kNotBinary:
|
1198
|
-
str->AppendBytes(cur, static_cast<size_t>(end - cur));
|
1199
|
-
return GRPC_ERROR_NONE;
|
1200
|
-
case BinaryState::kBinaryBegin:
|
1201
|
-
if (cur == end) {
|
1202
|
-
binary_ = BinaryState::kBinaryBegin;
|
1203
|
-
return GRPC_ERROR_NONE;
|
1204
|
-
}
|
1205
|
-
if (*cur == 0) {
|
1206
|
-
/* 'true-binary' case */
|
1207
|
-
++cur;
|
1208
|
-
binary_ = BinaryState::kNotBinary;
|
1209
|
-
GRPC_STATS_INC_HPACK_RECV_BINARY();
|
1210
|
-
str->AppendBytes(cur, static_cast<size_t>(end - cur));
|
1211
|
-
return GRPC_ERROR_NONE;
|
1212
|
-
}
|
1213
|
-
GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64();
|
1214
|
-
b64_byte0:
|
1215
|
-
ABSL_FALLTHROUGH_INTENDED;
|
1216
|
-
case BinaryState::kBase64Byte0:
|
1217
|
-
if (cur == end) {
|
1218
|
-
binary_ = BinaryState::kBase64Byte0;
|
1219
|
-
return GRPC_ERROR_NONE;
|
1220
|
-
}
|
1221
|
-
bits = kBase64InverseTable.table[*cur];
|
1222
|
-
++cur;
|
1223
|
-
if (bits == 255) {
|
1224
|
-
return parse_error(
|
1225
|
-
cur, end,
|
1226
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1227
|
-
} else if (bits == 64) {
|
1228
|
-
goto b64_byte0;
|
1229
|
-
}
|
1230
|
-
base64_buffer_ = bits << 18;
|
1231
|
-
b64_byte1:
|
1232
|
-
ABSL_FALLTHROUGH_INTENDED;
|
1233
|
-
case BinaryState::kBase64Byte1:
|
1234
|
-
if (cur == end) {
|
1235
|
-
binary_ = BinaryState::kBase64Byte1;
|
1236
|
-
return GRPC_ERROR_NONE;
|
1237
|
-
}
|
1238
|
-
bits = kBase64InverseTable.table[*cur];
|
1239
|
-
++cur;
|
1240
|
-
if (bits == 255) {
|
1241
|
-
return parse_error(
|
1242
|
-
cur, end,
|
1243
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1244
|
-
} else if (bits == 64) {
|
1245
|
-
goto b64_byte1;
|
1246
|
-
}
|
1247
|
-
base64_buffer_ |= bits << 12;
|
1248
|
-
b64_byte2:
|
1249
|
-
ABSL_FALLTHROUGH_INTENDED;
|
1250
|
-
case BinaryState::kBase64Byte2:
|
1251
|
-
if (cur == end) {
|
1252
|
-
binary_ = BinaryState::kBase64Byte2;
|
1253
|
-
return GRPC_ERROR_NONE;
|
1254
|
-
}
|
1255
|
-
bits = kBase64InverseTable.table[*cur];
|
1256
|
-
++cur;
|
1257
|
-
if (bits == 255) {
|
1258
|
-
return parse_error(
|
1259
|
-
cur, end,
|
1260
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1261
|
-
} else if (bits == 64) {
|
1262
|
-
goto b64_byte2;
|
1263
|
-
}
|
1264
|
-
base64_buffer_ |= bits << 6;
|
1265
|
-
b64_byte3:
|
1266
|
-
ABSL_FALLTHROUGH_INTENDED;
|
1267
|
-
case BinaryState::kBase64Byte3:
|
1268
|
-
if (cur == end) {
|
1269
|
-
binary_ = BinaryState::kBase64Byte3;
|
1270
|
-
return GRPC_ERROR_NONE;
|
1271
|
-
}
|
1272
|
-
bits = kBase64InverseTable.table[*cur];
|
1273
|
-
++cur;
|
1274
|
-
if (bits == 255) {
|
1275
|
-
return parse_error(
|
1276
|
-
cur, end,
|
1277
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1278
|
-
} else if (bits == 64) {
|
1279
|
-
goto b64_byte3;
|
1280
|
-
}
|
1281
|
-
base64_buffer_ |= bits;
|
1282
|
-
bits = base64_buffer_;
|
1283
|
-
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1284
|
-
decoded[1] = static_cast<uint8_t>(bits >> 8);
|
1285
|
-
decoded[2] = static_cast<uint8_t>(bits);
|
1286
|
-
str->AppendBytes(decoded, 3);
|
1287
|
-
goto b64_byte0;
|
1143
|
+
// Parse a varint index encoded key and a string encoded value
|
1144
|
+
template <typename TakeValueType>
|
1145
|
+
grpc_mdelem ParseVarIdxKey(uint32_t offset) {
|
1146
|
+
auto index = input_->ParseVarint(offset);
|
1147
|
+
if (GPR_UNLIKELY(!index.has_value())) return GRPC_MDNULL;
|
1148
|
+
return ParseIdxKey<TakeValueType>(*index);
|
1288
1149
|
}
|
1289
|
-
GPR_UNREACHABLE_CODE(return parse_error(
|
1290
|
-
cur, end,
|
1291
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here")));
|
1292
|
-
}
|
1293
1150
|
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
switch (binary_) {
|
1300
|
-
case BinaryState::kNotBinary:
|
1301
|
-
break;
|
1302
|
-
case BinaryState::kBinaryBegin:
|
1303
|
-
break;
|
1304
|
-
case BinaryState::kBase64Byte0:
|
1305
|
-
break;
|
1306
|
-
case BinaryState::kBase64Byte1:
|
1307
|
-
return parse_error(cur, end,
|
1308
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1309
|
-
"illegal base64 encoding")); /* illegal encoding */
|
1310
|
-
case BinaryState::kBase64Byte2:
|
1311
|
-
bits = base64_buffer_;
|
1312
|
-
if (bits & 0xffff) {
|
1313
|
-
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1314
|
-
absl::StrFormat("trailing bits in base64 encoding: 0x%04x",
|
1315
|
-
bits & 0xffff)
|
1316
|
-
.c_str());
|
1317
|
-
return parse_error(cur, end, err);
|
1318
|
-
}
|
1319
|
-
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1320
|
-
str->AppendBytes(decoded, 1);
|
1321
|
-
break;
|
1322
|
-
case BinaryState::kBase64Byte3:
|
1323
|
-
bits = base64_buffer_;
|
1324
|
-
if (bits & 0xff) {
|
1325
|
-
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1326
|
-
absl::StrFormat("trailing bits in base64 encoding: 0x%02x",
|
1327
|
-
bits & 0xff)
|
1328
|
-
.c_str());
|
1329
|
-
return parse_error(cur, end, err);
|
1330
|
-
}
|
1331
|
-
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1332
|
-
decoded[1] = static_cast<uint8_t>(bits >> 8);
|
1333
|
-
str->AppendBytes(decoded, 2);
|
1334
|
-
break;
|
1335
|
-
}
|
1336
|
-
return GRPC_ERROR_NONE;
|
1337
|
-
}
|
1338
|
-
|
1339
|
-
/* decode a nibble from a huffman encoded stream */
|
1340
|
-
grpc_error_handle HPackParser::AppendHuffNibble(uint8_t nibble) {
|
1341
|
-
int16_t emit = emit_sub_tbl[16 * emit_tbl[huff_state_] + nibble];
|
1342
|
-
int16_t next = next_sub_tbl[16 * next_tbl[huff_state_] + nibble];
|
1343
|
-
if (emit != -1) {
|
1344
|
-
if (emit >= 0 && emit < 256) {
|
1345
|
-
uint8_t c = static_cast<uint8_t>(emit);
|
1346
|
-
grpc_error_handle err = AppendString(&c, (&c) + 1);
|
1347
|
-
if (err != GRPC_ERROR_NONE) return err;
|
1151
|
+
// Parse a string, figuring out if it's binary or not by the key name.
|
1152
|
+
template <typename SliceType>
|
1153
|
+
absl::optional<String> ParseValueString(const SliceType& key) {
|
1154
|
+
if (grpc_is_refcounted_slice_binary_header(key)) {
|
1155
|
+
return String::ParseBinary(input_);
|
1348
1156
|
} else {
|
1349
|
-
|
1157
|
+
return String::Parse(input_);
|
1350
1158
|
}
|
1351
1159
|
}
|
1352
|
-
huff_state_ = next;
|
1353
|
-
return GRPC_ERROR_NONE;
|
1354
|
-
}
|
1355
1160
|
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
if (
|
1362
|
-
|
1363
|
-
|
1161
|
+
// Emit an indexed field
|
1162
|
+
bool FinishIndexed(absl::optional<uint32_t> index) {
|
1163
|
+
*dynamic_table_updates_allowed_ = 0;
|
1164
|
+
if (!index.has_value()) return false;
|
1165
|
+
grpc_mdelem md = table_->Fetch(*index);
|
1166
|
+
if (GPR_UNLIKELY(GRPC_MDISNULL(md))) {
|
1167
|
+
return InvalidHPackIndexError(*index, false);
|
1168
|
+
}
|
1169
|
+
GRPC_STATS_INC_HPACK_RECV_INDEXED();
|
1170
|
+
return FinishHeader<TableAction::kOmitFromTable>(md);
|
1364
1171
|
}
|
1365
|
-
return GRPC_ERROR_NONE;
|
1366
|
-
}
|
1367
1172
|
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1173
|
+
// finish parsing a max table size change
|
1174
|
+
bool FinishMaxTableSize(absl::optional<uint32_t> size) {
|
1175
|
+
if (!size.has_value()) return false;
|
1176
|
+
if (*dynamic_table_updates_allowed_ == 0) {
|
1177
|
+
return input_->MaybeSetErrorAndReturn(
|
1178
|
+
[] {
|
1179
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1180
|
+
"More than two max table size changes in a single frame");
|
1181
|
+
},
|
1182
|
+
false);
|
1183
|
+
}
|
1184
|
+
(*dynamic_table_updates_allowed_)--;
|
1185
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1186
|
+
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", *size);
|
1187
|
+
}
|
1188
|
+
grpc_error_handle err = table_->SetCurrentTableSize(*size);
|
1189
|
+
if (err != GRPC_ERROR_NONE) {
|
1190
|
+
input_->SetError(err);
|
1191
|
+
return false;
|
1192
|
+
}
|
1193
|
+
return true;
|
1376
1194
|
}
|
1377
|
-
}
|
1378
1195
|
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
strgot_ += static_cast<uint32_t>(given);
|
1395
|
-
state_ = &HPackParser::parse_string;
|
1396
|
-
return GRPC_ERROR_NONE;
|
1196
|
+
// Set an invalid hpack index error if no error has been set. Returns result
|
1197
|
+
// unmodified.
|
1198
|
+
template <typename R>
|
1199
|
+
R InvalidHPackIndexError(uint32_t index, R result) {
|
1200
|
+
return input_->MaybeSetErrorAndReturn(
|
1201
|
+
[this, index] {
|
1202
|
+
return grpc_error_set_int(
|
1203
|
+
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1204
|
+
"Invalid HPACK index received"),
|
1205
|
+
GRPC_ERROR_INT_INDEX,
|
1206
|
+
static_cast<intptr_t>(index)),
|
1207
|
+
GRPC_ERROR_INT_SIZE,
|
1208
|
+
static_cast<intptr_t>(this->table_->num_entries()));
|
1209
|
+
},
|
1210
|
+
result);
|
1397
1211
|
}
|
1398
|
-
}
|
1399
1212
|
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
if (!huff_ && binary == BinaryState::kNotBinary &&
|
1406
|
-
static_cast<uint32_t>(end - cur) >= strlen_ &&
|
1407
|
-
current_slice_refcount_ != nullptr) {
|
1408
|
-
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
1409
|
-
str->copied_ = false;
|
1410
|
-
str->data_.referenced.refcount = current_slice_refcount_;
|
1411
|
-
str->data_.referenced.data.refcounted.bytes = const_cast<uint8_t*>(cur);
|
1412
|
-
str->data_.referenced.data.refcounted.length = strlen_;
|
1413
|
-
grpc_slice_ref_internal(str->data_.referenced);
|
1414
|
-
return parse_next(cur + strlen_, end);
|
1415
|
-
}
|
1416
|
-
strgot_ = 0;
|
1417
|
-
str->copied_ = true;
|
1418
|
-
str->data_.copied.length = 0;
|
1419
|
-
parsing_.str = str;
|
1420
|
-
huff_state_ = 0;
|
1421
|
-
binary_ = binary;
|
1422
|
-
switch (binary_) {
|
1423
|
-
case BinaryState::kNotBinary:
|
1424
|
-
if (huff_) {
|
1425
|
-
GRPC_STATS_INC_HPACK_RECV_HUFFMAN();
|
1426
|
-
} else {
|
1427
|
-
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
1428
|
-
}
|
1429
|
-
break;
|
1430
|
-
case BinaryState::kBinaryBegin:
|
1431
|
-
/* stats incremented later: don't know true binary or not */
|
1432
|
-
break;
|
1433
|
-
default:
|
1434
|
-
abort();
|
1435
|
-
}
|
1436
|
-
return parse_string(cur, end);
|
1437
|
-
}
|
1213
|
+
Input* input_;
|
1214
|
+
HPackParser::Sink* sink_;
|
1215
|
+
HPackTable* const table_;
|
1216
|
+
uint8_t* dynamic_table_updates_allowed_;
|
1217
|
+
};
|
1438
1218
|
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1219
|
+
UnmanagedMemorySlice HPackParser::String::Take(Extern) {
|
1220
|
+
auto s = Match(
|
1221
|
+
value_,
|
1222
|
+
[](const grpc_slice& slice) {
|
1223
|
+
GPR_DEBUG_ASSERT(!grpc_slice_is_interned(slice));
|
1224
|
+
return static_cast<const UnmanagedMemorySlice&>(slice);
|
1225
|
+
},
|
1226
|
+
[](absl::Span<const uint8_t> span) {
|
1227
|
+
return UnmanagedMemorySlice(
|
1228
|
+
reinterpret_cast<char*>(const_cast<uint8_t*>(span.begin())),
|
1229
|
+
span.size());
|
1230
|
+
},
|
1231
|
+
[](const std::vector<uint8_t>& v) {
|
1232
|
+
return UnmanagedMemorySlice(reinterpret_cast<const char*>(v.data()),
|
1233
|
+
v.size());
|
1234
|
+
});
|
1235
|
+
value_ = absl::Span<const uint8_t>();
|
1236
|
+
return s;
|
1443
1237
|
}
|
1444
1238
|
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1239
|
+
ManagedMemorySlice HPackParser::String::Take(Intern) {
|
1240
|
+
auto s = Match(
|
1241
|
+
value_,
|
1242
|
+
[](const grpc_slice& slice) {
|
1243
|
+
ManagedMemorySlice s(&slice);
|
1244
|
+
grpc_slice_unref_internal(slice);
|
1245
|
+
return s;
|
1246
|
+
},
|
1247
|
+
[](absl::Span<const uint8_t> span) {
|
1248
|
+
return ManagedMemorySlice(
|
1249
|
+
reinterpret_cast<char*>(const_cast<uint8_t*>(span.data())),
|
1250
|
+
span.size());
|
1251
|
+
},
|
1252
|
+
[](const std::vector<uint8_t>& v) {
|
1253
|
+
return ManagedMemorySlice(reinterpret_cast<const char*>(v.data()),
|
1254
|
+
v.size());
|
1255
|
+
});
|
1256
|
+
value_ = absl::Span<const uint8_t>();
|
1257
|
+
return s;
|
1457
1258
|
}
|
1458
1259
|
|
1459
|
-
/*
|
1460
|
-
pointless recomputation of the metadata when finishing a header. We read the
|
1461
|
-
cached value in get_precomputed_md_for_idx(). */
|
1462
|
-
void HPackParser::SetPrecomputedMDIndex(grpc_mdelem md) {
|
1463
|
-
GPR_DEBUG_ASSERT(md_for_index_.payload == 0);
|
1464
|
-
GPR_DEBUG_ASSERT(precomputed_md_index_ == -1);
|
1465
|
-
md_for_index_ = md;
|
1466
|
-
#ifndef NDEBUG
|
1467
|
-
precomputed_md_index_ = index_;
|
1468
|
-
#endif
|
1469
|
-
}
|
1260
|
+
/* PUBLIC INTERFACE */
|
1470
1261
|
|
1471
|
-
|
1472
|
-
is a binary indexed header during string parsing. We'll need to revisit this
|
1473
|
-
metadata when we're done parsing, so we cache the metadata for this index
|
1474
|
-
here using set_precomputed_md_idx(). */
|
1475
|
-
grpc_error_handle HPackParser::IsBinaryIndexedHeader(bool* is) {
|
1476
|
-
grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&table_, index_);
|
1477
|
-
if (GPR_UNLIKELY(GRPC_MDISNULL(elem))) {
|
1478
|
-
return InvalidHPackIndexError();
|
1479
|
-
}
|
1480
|
-
/* We know that GRPC_MDKEY(elem) points to a reference counted slice since:
|
1481
|
-
* 1. elem was a result of grpc_chttp2_hptbl_lookup
|
1482
|
-
* 2. An item in this table is either static (see entries with
|
1483
|
-
* index < GRPC_CHTTP2_LAST_STATIC_ENTRY or added via
|
1484
|
-
* grpc_chttp2_hptbl_add).
|
1485
|
-
* 3. If added via grpc_chttp2_hptbl_add, the entry is either static or
|
1486
|
-
* interned.
|
1487
|
-
* 4. Both static and interned element slices have non-null refcounts. */
|
1488
|
-
*is = grpc_is_refcounted_slice_binary_header(GRPC_MDKEY(elem));
|
1489
|
-
SetPrecomputedMDIndex(elem);
|
1490
|
-
return GRPC_ERROR_NONE;
|
1491
|
-
}
|
1262
|
+
HPackParser::HPackParser() = default;
|
1492
1263
|
|
1493
|
-
|
1494
|
-
grpc_error_handle HPackParser::parse_value_string(const uint8_t* cur,
|
1495
|
-
const uint8_t* end,
|
1496
|
-
bool is_binary) {
|
1497
|
-
return begin_parse_string(
|
1498
|
-
cur, end, is_binary ? BinaryState::kBinaryBegin : BinaryState::kNotBinary,
|
1499
|
-
&value_);
|
1500
|
-
}
|
1264
|
+
HPackParser::~HPackParser() = default;
|
1501
1265
|
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
return parse_value_string(cur, end, is_binary);
|
1266
|
+
void HPackParser::BeginFrame(Sink sink, Boundary boundary, Priority priority) {
|
1267
|
+
sink_ = std::move(sink);
|
1268
|
+
boundary_ = boundary;
|
1269
|
+
priority_ = priority;
|
1270
|
+
dynamic_table_updates_allowed_ = 2;
|
1508
1271
|
}
|
1509
1272
|
|
1510
|
-
grpc_error_handle HPackParser::
|
1511
|
-
|
1512
|
-
|
1273
|
+
grpc_error_handle HPackParser::Parse(const grpc_slice& slice, bool is_last) {
|
1274
|
+
if (GPR_UNLIKELY(!unparsed_bytes_.empty())) {
|
1275
|
+
std::vector<uint8_t> buffer = std::move(unparsed_bytes_);
|
1276
|
+
buffer.insert(buffer.end(), GRPC_SLICE_START_PTR(slice),
|
1277
|
+
GRPC_SLICE_END_PTR(slice));
|
1278
|
+
return ParseInput(
|
1279
|
+
Input(nullptr, buffer.data(), buffer.data() + buffer.size()), is_last);
|
1280
|
+
}
|
1281
|
+
return ParseInput(Input(slice.refcount, GRPC_SLICE_START_PTR(slice),
|
1282
|
+
GRPC_SLICE_END_PTR(slice)),
|
1283
|
+
is_last);
|
1513
1284
|
}
|
1514
1285
|
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
to 0 initially, invalidated when the index changes, and invalidated when it
|
1529
|
-
is read (by get_precomputed_md_for_idx()). It is set during string parsing,
|
1530
|
-
by set_precomputed_md_idx() - which is called by parse_value_string().
|
1531
|
-
The goal here is to avoid recomputing the metadata for the index when
|
1532
|
-
finishing with a header as well as the initial parse. */
|
1533
|
-
md_for_index_.payload = 0;
|
1534
|
-
#ifndef NDEBUG
|
1535
|
-
/* In debug mode, this ensures that the cached metadata we're reading is in
|
1536
|
-
* fact correct for the index we are examining. */
|
1537
|
-
precomputed_md_index_ = -1;
|
1538
|
-
#endif
|
1539
|
-
dynamic_table_updates_allowed_ = 2;
|
1540
|
-
last_error_ = GRPC_ERROR_NONE;
|
1286
|
+
grpc_error_handle HPackParser::ParseInput(Input input, bool is_last) {
|
1287
|
+
if (ParseInputInner(&input)) {
|
1288
|
+
return GRPC_ERROR_NONE;
|
1289
|
+
}
|
1290
|
+
if (input.eof_error()) {
|
1291
|
+
if (GPR_UNLIKELY(is_last && is_boundary())) {
|
1292
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1293
|
+
"Incomplete header at the end of a header/continuation sequence");
|
1294
|
+
}
|
1295
|
+
unparsed_bytes_ = std::vector<uint8_t>(input.frontier(), input.end_ptr());
|
1296
|
+
return GRPC_ERROR_NONE;
|
1297
|
+
}
|
1298
|
+
return input.TakeError();
|
1541
1299
|
}
|
1542
1300
|
|
1543
|
-
|
1544
|
-
|
1545
|
-
boundary_ = boundary;
|
1546
|
-
switch (priority) {
|
1547
|
-
case Priority::Included:
|
1548
|
-
after_prioritization_ = state_;
|
1549
|
-
state_ = &HPackParser::parse_stream_dep0;
|
1550
|
-
break;
|
1301
|
+
bool HPackParser::ParseInputInner(Input* input) {
|
1302
|
+
switch (priority_) {
|
1551
1303
|
case Priority::None:
|
1552
1304
|
break;
|
1305
|
+
case Priority::Included: {
|
1306
|
+
if (input->remaining() < 5) return input->UnexpectedEOF(false);
|
1307
|
+
input->Advance(5);
|
1308
|
+
input->UpdateFrontier();
|
1309
|
+
priority_ = Priority::None;
|
1310
|
+
}
|
1553
1311
|
}
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
gpr_free(key_.data_.copied.str);
|
1562
|
-
gpr_free(value_.data_.copied.str);
|
1563
|
-
}
|
1564
|
-
|
1565
|
-
grpc_error_handle HPackParser::Parse(const grpc_slice& slice) {
|
1566
|
-
/* max number of bytes to parse at a time... limits call stack depth on
|
1567
|
-
* compilers without TCO */
|
1568
|
-
#define MAX_PARSE_LENGTH 1024
|
1569
|
-
current_slice_refcount_ = slice.refcount;
|
1570
|
-
const uint8_t* start = GRPC_SLICE_START_PTR(slice);
|
1571
|
-
const uint8_t* end = GRPC_SLICE_END_PTR(slice);
|
1572
|
-
grpc_error_handle error = GRPC_ERROR_NONE;
|
1573
|
-
while (start != end && error == GRPC_ERROR_NONE) {
|
1574
|
-
const uint8_t* target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
|
1575
|
-
error = (this->*state_)(start, target);
|
1576
|
-
start = target;
|
1312
|
+
while (!input->end_of_stream()) {
|
1313
|
+
if (GPR_UNLIKELY(
|
1314
|
+
!Parser(input, &sink_, &table_, &dynamic_table_updates_allowed_)
|
1315
|
+
.Parse())) {
|
1316
|
+
return false;
|
1317
|
+
}
|
1318
|
+
input->UpdateFrontier();
|
1577
1319
|
}
|
1578
|
-
|
1579
|
-
return error;
|
1320
|
+
return true;
|
1580
1321
|
}
|
1581
1322
|
|
1323
|
+
void HPackParser::FinishFrame() { sink_ = Sink(); }
|
1324
|
+
|
1582
1325
|
} // namespace grpc_core
|
1583
1326
|
|
1584
1327
|
// TODO(ctiller): this serves as an eviction notice for the remainder of this
|
@@ -1630,15 +1373,11 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser,
|
|
1630
1373
|
if (s != nullptr) {
|
1631
1374
|
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
|
1632
1375
|
}
|
1633
|
-
grpc_error_handle error = parser->Parse(slice);
|
1376
|
+
grpc_error_handle error = parser->Parse(slice, is_last != 0);
|
1634
1377
|
if (error != GRPC_ERROR_NONE) {
|
1635
1378
|
return error;
|
1636
1379
|
}
|
1637
1380
|
if (is_last) {
|
1638
|
-
if (parser->is_boundary() && !parser->is_in_begin_state()) {
|
1639
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1640
|
-
"end of header frame not aligned with a hpack record boundary");
|
1641
|
-
}
|
1642
1381
|
/* need to check for null stream: this can occur if we receive an invalid
|
1643
1382
|
stream id on a header */
|
1644
1383
|
if (s != nullptr) {
|