grpc 1.2.5 → 1.3.4
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 +1434 -399
- data/etc/roots.pem +34 -150
- data/include/grpc/grpc.h +71 -0
- data/include/grpc/impl/codegen/atm.h +5 -0
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +6 -0
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +11 -0
- data/include/grpc/impl/codegen/grpc_types.h +54 -13
- data/include/grpc/impl/codegen/port_platform.h +15 -1
- data/include/grpc/support/alloc.h +2 -1
- data/include/grpc/support/sync.h +4 -0
- data/include/grpc/support/tls.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.h +1 -1
- data/src/core/ext/census/grpc_filter.c +14 -10
- data/src/core/ext/census/grpc_plugin.c +3 -1
- data/src/core/ext/census/trace_label.h +1 -1
- data/src/core/ext/census/trace_propagation.h +1 -1
- data/src/core/ext/census/trace_status.h +1 -1
- data/src/core/ext/census/trace_string.h +1 -1
- data/src/core/ext/census/tracing.h +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/channel_connectivity.c +56 -27
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel.c +407 -202
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel.h +10 -6
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_plugin.c +12 -7
- data/src/core/ext/{client_channel → filters/client_channel}/connector.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/connector.h +3 -5
- data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.c +6 -6
- data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.c +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.h +4 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.c +22 -20
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.h +4 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel.h +5 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel_secure.c +2 -2
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.c +1 -1
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.h +6 -5
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +1 -1
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -0
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/pick_first/pick_first.c +20 -15
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/round_robin/round_robin.c +21 -16
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.h +5 -5
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/parse_address.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/parse_address.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.c +10 -4
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/resolver.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/resolver.h +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
- data/src/core/ext/{resolver → filters/client_channel/resolver}/dns/native/dns_resolver.c +21 -5
- data/src/core/ext/{resolver → filters/client_channel/resolver}/sockaddr/sockaddr_resolver.c +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.h +6 -6
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.c +1 -2
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.h +4 -4
- data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
- data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel.c +49 -43
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel.h +21 -7
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.h +5 -5
- data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.h +3 -3
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.c +4 -2
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.h +3 -3
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.c +17 -14
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.h +4 -4
- data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
- data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +6 -41
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +2 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +3 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +2 -5
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +449 -204
- data/src/core/ext/transport/chttp2/transport/frame_data.c +10 -7
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +37 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +4 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +18 -38
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -29
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +64 -37
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +11 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +60 -39
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
- data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +22 -43
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +8 -10
- data/src/core/ext/transport/chttp2/transport/internal.h +24 -2
- data/src/core/ext/transport/chttp2/transport/parsing.c +33 -15
- data/src/core/ext/transport/chttp2/transport/writing.c +56 -10
- data/src/core/lib/channel/channel_args.c +7 -0
- data/src/core/lib/channel/channel_args.h +2 -0
- data/src/core/lib/channel/channel_stack.c +20 -27
- data/src/core/lib/channel/channel_stack.h +18 -16
- data/src/core/lib/channel/compress_filter.c +20 -18
- data/src/core/lib/channel/connected_channel.c +9 -8
- data/src/core/lib/channel/deadline_filter.c +28 -24
- data/src/core/lib/channel/deadline_filter.h +3 -3
- data/src/core/lib/channel/handshaker.c +3 -2
- data/src/core/lib/channel/http_client_filter.c +119 -61
- data/src/core/lib/channel/http_server_filter.c +124 -69
- data/src/core/lib/channel/message_size_filter.c +23 -19
- data/src/core/lib/http/httpcli.c +8 -6
- data/src/core/lib/http/httpcli_security_connector.c +5 -5
- data/src/core/lib/http/parser.c +57 -31
- data/src/core/lib/iomgr/closure.c +15 -0
- data/src/core/lib/iomgr/closure.h +4 -0
- data/src/core/lib/iomgr/combiner.c +8 -0
- data/src/core/lib/iomgr/endpoint_pair.h +2 -3
- data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -7
- data/src/core/lib/iomgr/endpoint_pair_uv.c +2 -3
- data/src/core/lib/iomgr/endpoint_pair_windows.c +9 -6
- data/src/core/lib/iomgr/error.c +360 -177
- data/src/core/lib/iomgr/error.h +31 -33
- data/src/core/lib/iomgr/error_internal.h +30 -9
- data/src/core/lib/iomgr/ev_epoll_linux.c +25 -239
- data/src/core/lib/iomgr/ev_poll_posix.c +11 -7
- data/src/core/lib/iomgr/ev_posix.c +6 -0
- data/src/core/lib/iomgr/ev_posix.h +3 -0
- data/src/core/lib/iomgr/exec_ctx.c +6 -0
- data/src/core/lib/iomgr/executor.c +8 -2
- data/src/core/lib/iomgr/load_file.c +6 -3
- data/src/core/lib/iomgr/lockfree_event.c +238 -0
- data/src/core/{ext/client_channel/initial_connect_string.h → lib/iomgr/lockfree_event.h} +17 -13
- data/src/core/lib/iomgr/pollset.h +4 -0
- data/src/core/lib/iomgr/pollset_windows.c +2 -2
- data/src/core/lib/iomgr/port.h +9 -0
- data/src/core/lib/iomgr/resolve_address_posix.c +15 -9
- data/src/core/lib/iomgr/resolve_address_uv.c +8 -6
- data/src/core/lib/iomgr/resolve_address_windows.c +2 -2
- data/src/core/lib/iomgr/resource_quota.c +19 -4
- data/src/core/lib/iomgr/resource_quota.h +2 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +3 -1
- data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
- data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.c +25 -9
- data/src/core/lib/iomgr/socket_utils_posix.h +7 -0
- data/src/core/lib/iomgr/tcp_client.h +0 -4
- data/src/core/lib/iomgr/tcp_client_posix.c +15 -31
- data/src/core/lib/iomgr/tcp_client_uv.c +10 -6
- data/src/core/lib/iomgr/tcp_client_windows.c +9 -19
- data/src/core/lib/iomgr/tcp_posix.c +111 -22
- data/src/core/lib/iomgr/tcp_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_server_posix.c +39 -417
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
- data/src/core/lib/iomgr/tcp_server_uv.c +43 -16
- data/src/core/lib/iomgr/tcp_server_windows.c +10 -22
- data/src/core/lib/iomgr/tcp_uv.c +16 -13
- data/src/core/lib/iomgr/tcp_windows.c +24 -12
- data/src/core/lib/iomgr/tcp_windows.h +2 -2
- data/src/core/lib/iomgr/timer.h +3 -0
- data/src/core/lib/iomgr/timer_generic.c +257 -72
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_heap.c +8 -8
- data/src/core/lib/iomgr/udp_server.c +54 -24
- data/src/core/lib/iomgr/udp_server.h +7 -7
- data/src/core/lib/iomgr/unix_sockets_posix.c +1 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +2 -1
- data/src/core/lib/iomgr/wakeup_fd_posix.h +1 -1
- data/src/core/lib/profiling/basic_timers.c +1 -1
- data/src/core/lib/security/credentials/credentials.h +1 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +10 -9
- data/src/core/lib/security/credentials/jwt/json_token.c +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +2 -2
- data/src/core/lib/security/transport/client_auth_filter.c +33 -26
- data/src/core/lib/security/transport/secure_endpoint.c +8 -5
- data/src/core/lib/security/transport/security_connector.c +37 -37
- data/src/core/lib/security/transport/security_connector.h +1 -1
- data/src/core/lib/security/transport/security_handshaker.c +15 -12
- data/src/core/lib/security/transport/server_auth_filter.c +20 -18
- data/src/core/lib/security/transport/tsi_error.c +5 -3
- data/src/core/lib/security/transport/tsi_error.h +1 -1
- data/src/core/lib/{security/util → slice}/b64.c +21 -6
- data/src/core/lib/{security/util → slice}/b64.h +16 -4
- data/src/core/lib/slice/slice.c +4 -2
- data/src/core/lib/slice/slice_buffer.c +16 -14
- data/src/core/lib/support/arena.c +98 -0
- data/src/core/{ext/client_channel/initial_connect_string.c → lib/support/arena.h} +17 -15
- data/src/core/{ext/client_channel/default_initial_connect_string.c → lib/support/atm.c} +14 -5
- data/src/core/lib/support/cpu_linux.c +5 -0
- data/src/core/lib/support/sync.c +4 -0
- data/src/core/lib/support/time.c +4 -10
- data/src/core/lib/support/wrap_memcpy.c +3 -1
- data/src/core/lib/surface/call.c +252 -221
- data/src/core/lib/surface/channel.c +72 -21
- data/src/core/lib/surface/channel.h +8 -0
- data/src/core/lib/surface/completion_queue.c +2 -3
- data/src/core/lib/surface/completion_queue_factory.c +77 -0
- data/src/core/lib/surface/completion_queue_factory.h +51 -0
- data/src/core/lib/surface/init_secure.c +3 -1
- data/src/core/lib/surface/lame_client.c +18 -14
- data/src/core/lib/surface/server.c +43 -41
- data/src/core/lib/surface/validate_metadata.c +8 -4
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.h +1 -1
- data/src/core/lib/transport/connectivity_state.c +2 -1
- data/src/core/lib/transport/error_utils.c +17 -17
- data/src/core/lib/transport/error_utils.h +1 -1
- data/src/core/lib/transport/metadata_batch.c +6 -7
- data/src/core/lib/transport/pid_controller.c +1 -0
- data/src/core/lib/transport/service_config.c +12 -0
- data/src/core/lib/transport/service_config.h +6 -0
- data/src/core/lib/transport/transport.c +29 -17
- data/src/core/lib/transport/transport.h +85 -42
- data/src/core/lib/transport/transport_impl.h +5 -3
- data/src/core/lib/transport/transport_op_string.c +20 -14
- data/src/core/plugin_registry/grpc_plugin_registry.c +8 -0
- data/src/core/{lib/tsi → tsi}/fake_transport_security.c +2 -2
- data/src/core/{lib/tsi → tsi}/fake_transport_security.h +4 -4
- data/src/core/{lib/tsi → tsi}/ssl_transport_security.c +40 -79
- data/src/core/{lib/tsi → tsi}/ssl_transport_security.h +44 -21
- data/src/core/{lib/tsi → tsi}/ssl_types.h +3 -3
- data/src/core/{lib/tsi → tsi}/transport_security.c +2 -2
- data/src/core/{lib/tsi → tsi}/transport_security.h +4 -4
- data/src/core/{lib/tsi → tsi}/transport_security_interface.h +3 -3
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +2 -2
- data/src/ruby/ext/grpc/rb_channel.c +520 -93
- data/src/ruby/ext/grpc/rb_channel.h +2 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +5 -2
- data/src/ruby/ext/grpc/rb_event_thread.c +6 -6
- data/src/ruby/ext/grpc/rb_grpc.c +29 -7
- data/src/ruby/ext/grpc/rb_grpc.h +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_connection_spec.rb +173 -0
- data/src/ruby/spec/channel_spec.rb +29 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +27 -17
- data/third_party/cares/ares_build.h +264 -0
- data/third_party/cares/cares/ares.h +636 -0
- data/third_party/cares/cares/ares__close_sockets.c +61 -0
- data/third_party/cares/cares/ares__get_hostent.c +261 -0
- data/third_party/cares/cares/ares__read_line.c +73 -0
- data/third_party/cares/cares/ares__timeval.c +111 -0
- data/third_party/cares/cares/ares_cancel.c +63 -0
- data/third_party/cares/cares/ares_create_query.c +202 -0
- data/third_party/cares/cares/ares_data.c +221 -0
- data/third_party/cares/cares/ares_data.h +72 -0
- data/third_party/cares/cares/ares_destroy.c +108 -0
- data/third_party/cares/cares/ares_dns.h +103 -0
- data/third_party/cares/cares/ares_expand_name.c +205 -0
- data/third_party/cares/cares/ares_expand_string.c +70 -0
- data/third_party/cares/cares/ares_fds.c +59 -0
- data/third_party/cares/cares/ares_free_hostent.c +41 -0
- data/third_party/cares/cares/ares_free_string.c +25 -0
- data/third_party/cares/cares/ares_getenv.c +30 -0
- data/third_party/cares/cares/ares_getenv.h +26 -0
- data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
- data/third_party/cares/cares/ares_gethostbyname.c +518 -0
- data/third_party/cares/cares/ares_getnameinfo.c +422 -0
- data/third_party/cares/cares/ares_getopt.c +122 -0
- data/third_party/cares/cares/ares_getopt.h +53 -0
- data/third_party/cares/cares/ares_getsock.c +66 -0
- data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
- data/third_party/cares/cares/ares_init.c +2146 -0
- data/third_party/cares/cares/ares_iphlpapi.h +221 -0
- data/third_party/cares/cares/ares_ipv6.h +78 -0
- data/third_party/cares/cares/ares_library_init.c +167 -0
- data/third_party/cares/cares/ares_library_init.h +42 -0
- data/third_party/cares/cares/ares_llist.c +63 -0
- data/third_party/cares/cares/ares_llist.h +39 -0
- data/third_party/cares/cares/ares_mkquery.c +24 -0
- data/third_party/cares/cares/ares_nowarn.c +260 -0
- data/third_party/cares/cares/ares_nowarn.h +61 -0
- data/third_party/cares/cares/ares_options.c +402 -0
- data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
- data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
- data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
- data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
- data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
- data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
- data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
- data/third_party/cares/cares/ares_platform.c +11035 -0
- data/third_party/cares/cares/ares_platform.h +43 -0
- data/third_party/cares/cares/ares_private.h +363 -0
- data/third_party/cares/cares/ares_process.c +1359 -0
- data/third_party/cares/cares/ares_query.c +186 -0
- data/third_party/cares/cares/ares_rules.h +125 -0
- data/third_party/cares/cares/ares_search.c +316 -0
- data/third_party/cares/cares/ares_send.c +131 -0
- data/third_party/cares/cares/ares_setup.h +217 -0
- data/third_party/cares/cares/ares_strcasecmp.c +66 -0
- data/third_party/cares/cares/ares_strcasecmp.h +30 -0
- data/third_party/cares/cares/ares_strdup.c +49 -0
- data/third_party/cares/cares/ares_strdup.h +24 -0
- data/third_party/cares/cares/ares_strerror.c +56 -0
- data/third_party/cares/cares/ares_timeout.c +88 -0
- data/third_party/cares/cares/ares_version.c +11 -0
- data/third_party/cares/cares/ares_version.h +24 -0
- data/third_party/cares/cares/ares_writev.c +79 -0
- data/third_party/cares/cares/bitncmp.c +59 -0
- data/third_party/cares/cares/bitncmp.h +26 -0
- data/third_party/cares/cares/config-win32.h +377 -0
- data/third_party/cares/cares/inet_net_pton.c +450 -0
- data/third_party/cares/cares/inet_ntop.c +208 -0
- data/third_party/cares/cares/setup_once.h +554 -0
- data/third_party/cares/cares/windows_port.c +22 -0
- data/third_party/cares/config_darwin/ares_config.h +523 -0
- data/third_party/cares/config_linux/ares_config.h +524 -0
- metadata +164 -68
@@ -49,7 +49,7 @@
|
|
49
49
|
#include "src/core/lib/slice/slice_internal.h"
|
50
50
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
51
51
|
#include "src/core/lib/support/string.h"
|
52
|
-
#include "src/core/
|
52
|
+
#include "src/core/tsi/transport_security_interface.h"
|
53
53
|
|
54
54
|
#define STAGING_BUFFER_SIZE 8192
|
55
55
|
|
@@ -162,7 +162,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
|
|
162
162
|
|
163
163
|
if (error != GRPC_ERROR_NONE) {
|
164
164
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
|
165
|
-
call_read_cb(exec_ctx, ep,
|
165
|
+
call_read_cb(exec_ctx, ep, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
166
166
|
"Secure read failed", &error, 1));
|
167
167
|
return;
|
168
168
|
}
|
@@ -220,8 +220,10 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
|
|
220
220
|
|
221
221
|
if (result != TSI_OK) {
|
222
222
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
|
223
|
-
call_read_cb(
|
224
|
-
|
223
|
+
call_read_cb(
|
224
|
+
exec_ctx, ep,
|
225
|
+
grpc_set_tsi_error_result(
|
226
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result));
|
225
227
|
return;
|
226
228
|
}
|
227
229
|
|
@@ -332,7 +334,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
|
|
332
334
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
|
333
335
|
grpc_closure_sched(
|
334
336
|
exec_ctx, cb,
|
335
|
-
grpc_set_tsi_error_result(
|
337
|
+
grpc_set_tsi_error_result(
|
338
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result));
|
336
339
|
GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
|
337
340
|
return;
|
338
341
|
}
|
@@ -54,8 +54,8 @@
|
|
54
54
|
#include "src/core/lib/security/transport/security_handshaker.h"
|
55
55
|
#include "src/core/lib/support/env.h"
|
56
56
|
#include "src/core/lib/support/string.h"
|
57
|
-
#include "src/core/
|
58
|
-
#include "src/core/
|
57
|
+
#include "src/core/tsi/fake_transport_security.h"
|
58
|
+
#include "src/core/tsi/ssl_transport_security.h"
|
59
59
|
|
60
60
|
/* -- Constants. -- */
|
61
61
|
|
@@ -137,9 +137,9 @@ void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx,
|
|
137
137
|
grpc_auth_context **auth_context,
|
138
138
|
grpc_closure *on_peer_checked) {
|
139
139
|
if (sc == NULL) {
|
140
|
-
grpc_closure_sched(
|
141
|
-
|
142
|
-
|
140
|
+
grpc_closure_sched(exec_ctx, on_peer_checked,
|
141
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
142
|
+
"cannot check peer -- no security connector"));
|
143
143
|
tsi_peer_destruct(&peer);
|
144
144
|
} else {
|
145
145
|
sc->vtable->check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
|
@@ -330,7 +330,8 @@ static void fake_check_peer(grpc_exec_ctx *exec_ctx,
|
|
330
330
|
grpc_error *error = GRPC_ERROR_NONE;
|
331
331
|
*auth_context = NULL;
|
332
332
|
if (peer.property_count != 1) {
|
333
|
-
error =
|
333
|
+
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
334
|
+
"Fake peers should only have 1 property.");
|
334
335
|
goto end;
|
335
336
|
}
|
336
337
|
prop_name = peer.properties[0].name;
|
@@ -339,13 +340,14 @@ static void fake_check_peer(grpc_exec_ctx *exec_ctx,
|
|
339
340
|
char *msg;
|
340
341
|
gpr_asprintf(&msg, "Unexpected property in fake peer: %s.",
|
341
342
|
prop_name == NULL ? "<EMPTY>" : prop_name);
|
342
|
-
error =
|
343
|
+
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
343
344
|
gpr_free(msg);
|
344
345
|
goto end;
|
345
346
|
}
|
346
347
|
if (strncmp(peer.properties[0].value.data, TSI_FAKE_CERTIFICATE_TYPE,
|
347
348
|
peer.properties[0].value.length)) {
|
348
|
-
error =
|
349
|
+
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
350
|
+
"Invalid value for cert type property.");
|
349
351
|
goto end;
|
350
352
|
}
|
351
353
|
*auth_context = grpc_auth_context_create(NULL);
|
@@ -446,14 +448,14 @@ grpc_server_security_connector *grpc_fake_server_security_connector_create(
|
|
446
448
|
|
447
449
|
typedef struct {
|
448
450
|
grpc_channel_security_connector base;
|
449
|
-
|
451
|
+
tsi_ssl_client_handshaker_factory *handshaker_factory;
|
450
452
|
char *target_name;
|
451
453
|
char *overridden_target_name;
|
452
454
|
} grpc_ssl_channel_security_connector;
|
453
455
|
|
454
456
|
typedef struct {
|
455
457
|
grpc_server_security_connector base;
|
456
|
-
|
458
|
+
tsi_ssl_server_handshaker_factory *handshaker_factory;
|
457
459
|
} grpc_ssl_server_security_connector;
|
458
460
|
|
459
461
|
static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx,
|
@@ -462,7 +464,7 @@ static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx,
|
|
462
464
|
(grpc_ssl_channel_security_connector *)sc;
|
463
465
|
grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
|
464
466
|
if (c->handshaker_factory != NULL) {
|
465
|
-
|
467
|
+
tsi_ssl_client_handshaker_factory_destroy(c->handshaker_factory);
|
466
468
|
}
|
467
469
|
if (c->target_name != NULL) gpr_free(c->target_name);
|
468
470
|
if (c->overridden_target_name != NULL) gpr_free(c->overridden_target_name);
|
@@ -474,26 +476,11 @@ static void ssl_server_destroy(grpc_exec_ctx *exec_ctx,
|
|
474
476
|
grpc_ssl_server_security_connector *c =
|
475
477
|
(grpc_ssl_server_security_connector *)sc;
|
476
478
|
if (c->handshaker_factory != NULL) {
|
477
|
-
|
479
|
+
tsi_ssl_server_handshaker_factory_destroy(c->handshaker_factory);
|
478
480
|
}
|
479
481
|
gpr_free(sc);
|
480
482
|
}
|
481
483
|
|
482
|
-
static grpc_security_status ssl_create_handshaker(
|
483
|
-
tsi_ssl_handshaker_factory *handshaker_factory, bool is_client,
|
484
|
-
const char *peer_name, tsi_handshaker **handshaker) {
|
485
|
-
tsi_result result = TSI_OK;
|
486
|
-
if (handshaker_factory == NULL) return GRPC_SECURITY_ERROR;
|
487
|
-
result = tsi_ssl_handshaker_factory_create_handshaker(
|
488
|
-
handshaker_factory, is_client ? peer_name : NULL, handshaker);
|
489
|
-
if (result != TSI_OK) {
|
490
|
-
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
|
491
|
-
tsi_result_to_string(result));
|
492
|
-
return GRPC_SECURITY_ERROR;
|
493
|
-
}
|
494
|
-
return GRPC_SECURITY_OK;
|
495
|
-
}
|
496
|
-
|
497
484
|
static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx,
|
498
485
|
grpc_channel_security_connector *sc,
|
499
486
|
grpc_handshake_manager *handshake_mgr) {
|
@@ -501,11 +488,17 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx,
|
|
501
488
|
(grpc_ssl_channel_security_connector *)sc;
|
502
489
|
// Instantiate TSI handshaker.
|
503
490
|
tsi_handshaker *tsi_hs = NULL;
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
491
|
+
tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
|
492
|
+
c->handshaker_factory,
|
493
|
+
c->overridden_target_name != NULL ? c->overridden_target_name
|
494
|
+
: c->target_name,
|
495
|
+
&tsi_hs);
|
496
|
+
if (result != TSI_OK) {
|
497
|
+
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
|
498
|
+
tsi_result_to_string(result));
|
499
|
+
return;
|
500
|
+
}
|
501
|
+
|
509
502
|
// Create handshakers.
|
510
503
|
grpc_handshake_manager_add(handshake_mgr, grpc_security_handshaker_create(
|
511
504
|
exec_ctx, tsi_hs, &sc->base));
|
@@ -518,8 +511,14 @@ static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx,
|
|
518
511
|
(grpc_ssl_server_security_connector *)sc;
|
519
512
|
// Instantiate TSI handshaker.
|
520
513
|
tsi_handshaker *tsi_hs = NULL;
|
521
|
-
|
522
|
-
|
514
|
+
tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker(
|
515
|
+
c->handshaker_factory, &tsi_hs);
|
516
|
+
if (result != TSI_OK) {
|
517
|
+
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
|
518
|
+
tsi_result_to_string(result));
|
519
|
+
return;
|
520
|
+
}
|
521
|
+
|
523
522
|
// Create handshakers.
|
524
523
|
grpc_handshake_manager_add(handshake_mgr, grpc_security_handshaker_create(
|
525
524
|
exec_ctx, tsi_hs, &sc->base));
|
@@ -586,18 +585,19 @@ static grpc_error *ssl_check_peer(grpc_security_connector *sc,
|
|
586
585
|
const tsi_peer_property *p =
|
587
586
|
tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
|
588
587
|
if (p == NULL) {
|
589
|
-
return
|
588
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
590
589
|
"Cannot check peer: missing selected ALPN property.");
|
591
590
|
}
|
592
591
|
if (!grpc_chttp2_is_alpn_version_supported(p->value.data, p->value.length)) {
|
593
|
-
return
|
592
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
593
|
+
"Cannot check peer: invalid ALPN value.");
|
594
594
|
}
|
595
595
|
|
596
596
|
/* Check the peer name if specified. */
|
597
597
|
if (peer_name != NULL && !ssl_host_matches_name(peer, peer_name)) {
|
598
598
|
char *msg;
|
599
599
|
gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name);
|
600
|
-
grpc_error *error =
|
600
|
+
grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
601
601
|
gpr_free(msg);
|
602
602
|
return error;
|
603
603
|
}
|
@@ -39,7 +39,7 @@
|
|
39
39
|
#include "src/core/lib/channel/handshaker.h"
|
40
40
|
#include "src/core/lib/iomgr/endpoint.h"
|
41
41
|
#include "src/core/lib/iomgr/tcp_server.h"
|
42
|
-
#include "src/core/
|
42
|
+
#include "src/core/tsi/transport_security_interface.h"
|
43
43
|
|
44
44
|
/* --- status enum. --- */
|
45
45
|
|
@@ -120,7 +120,7 @@ static void security_handshake_failed_locked(grpc_exec_ctx *exec_ctx,
|
|
120
120
|
if (error == GRPC_ERROR_NONE) {
|
121
121
|
// If we were shut down after the handshake succeeded but before an
|
122
122
|
// endpoint callback was invoked, we need to generate our own error.
|
123
|
-
error =
|
123
|
+
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshaker shutdown");
|
124
124
|
}
|
125
125
|
const char *msg = grpc_error_string(error);
|
126
126
|
gpr_log(GPR_DEBUG, "Security handshake failed: %s", msg);
|
@@ -156,7 +156,8 @@ static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg,
|
|
156
156
|
tsi_handshaker_create_frame_protector(h->handshaker, NULL, &protector);
|
157
157
|
if (result != TSI_OK) {
|
158
158
|
error = grpc_set_tsi_error_result(
|
159
|
-
|
159
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Frame protector creation failed"),
|
160
|
+
result);
|
160
161
|
security_handshake_failed_locked(exec_ctx, h, error);
|
161
162
|
goto done;
|
162
163
|
}
|
@@ -191,7 +192,7 @@ static grpc_error *check_peer_locked(grpc_exec_ctx *exec_ctx,
|
|
191
192
|
tsi_result result = tsi_handshaker_extract_peer(h->handshaker, &peer);
|
192
193
|
if (result != TSI_OK) {
|
193
194
|
return grpc_set_tsi_error_result(
|
194
|
-
|
195
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Peer extraction failed"), result);
|
195
196
|
}
|
196
197
|
grpc_security_connector_check_peer(exec_ctx, h->connector, peer,
|
197
198
|
&h->auth_context, &h->on_peer_checked);
|
@@ -215,8 +216,8 @@ static grpc_error *send_handshake_bytes_to_peer_locked(grpc_exec_ctx *exec_ctx,
|
|
215
216
|
}
|
216
217
|
} while (result == TSI_INCOMPLETE_DATA);
|
217
218
|
if (result != TSI_OK) {
|
218
|
-
return grpc_set_tsi_error_result(
|
219
|
-
|
219
|
+
return grpc_set_tsi_error_result(
|
220
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result);
|
220
221
|
}
|
221
222
|
// Send data.
|
222
223
|
grpc_slice to_send =
|
@@ -234,8 +235,8 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
|
|
234
235
|
gpr_mu_lock(&h->mu);
|
235
236
|
if (error != GRPC_ERROR_NONE || h->shutdown) {
|
236
237
|
security_handshake_failed_locked(
|
237
|
-
exec_ctx, h,
|
238
|
-
|
238
|
+
exec_ctx, h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
239
|
+
"Handshake read failed", &error, 1));
|
239
240
|
gpr_mu_unlock(&h->mu);
|
240
241
|
security_handshaker_unref(exec_ctx, h);
|
241
242
|
return;
|
@@ -270,8 +271,9 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
|
|
270
271
|
}
|
271
272
|
if (result != TSI_OK) {
|
272
273
|
security_handshake_failed_locked(
|
273
|
-
exec_ctx, h,
|
274
|
-
|
274
|
+
exec_ctx, h,
|
275
|
+
grpc_set_tsi_error_result(
|
276
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result));
|
275
277
|
gpr_mu_unlock(&h->mu);
|
276
278
|
security_handshaker_unref(exec_ctx, h);
|
277
279
|
return;
|
@@ -313,8 +315,8 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, void *arg,
|
|
313
315
|
gpr_mu_lock(&h->mu);
|
314
316
|
if (error != GRPC_ERROR_NONE || h->shutdown) {
|
315
317
|
security_handshake_failed_locked(
|
316
|
-
exec_ctx, h,
|
317
|
-
|
318
|
+
exec_ctx, h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
319
|
+
"Handshake write failed", &error, 1));
|
318
320
|
gpr_mu_unlock(&h->mu);
|
319
321
|
security_handshaker_unref(exec_ctx, h);
|
320
322
|
return;
|
@@ -428,7 +430,8 @@ static void fail_handshaker_do_handshake(grpc_exec_ctx *exec_ctx,
|
|
428
430
|
grpc_closure *on_handshake_done,
|
429
431
|
grpc_handshaker_args *args) {
|
430
432
|
grpc_closure_sched(exec_ctx, on_handshake_done,
|
431
|
-
|
433
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
434
|
+
"Failed to create security handshaker"));
|
432
435
|
}
|
433
436
|
|
434
437
|
static const grpc_handshaker_vtable fail_handshaker_vtable = {
|
@@ -49,7 +49,7 @@ typedef struct call_data {
|
|
49
49
|
up-call on transport_op, and remember to call our on_done_recv member after
|
50
50
|
handling it. */
|
51
51
|
grpc_closure auth_on_recv;
|
52
|
-
|
52
|
+
grpc_transport_stream_op_batch *transport_op;
|
53
53
|
grpc_metadata_array md;
|
54
54
|
const grpc_metadata *consumed_md;
|
55
55
|
size_t num_consumed_md;
|
@@ -138,15 +138,15 @@ static void on_md_processing_done(
|
|
138
138
|
error_details = error_details != NULL
|
139
139
|
? error_details
|
140
140
|
: "Authentication metadata processing failed.";
|
141
|
-
calld->transport_op->
|
142
|
-
|
143
|
-
|
144
|
-
calld->transport_op->send_message = NULL;
|
141
|
+
if (calld->transport_op->send_message) {
|
142
|
+
grpc_byte_stream_destroy(
|
143
|
+
&exec_ctx, calld->transport_op->payload->send_message.send_message);
|
144
|
+
calld->transport_op->payload->send_message.send_message = NULL;
|
145
145
|
}
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
146
|
+
grpc_closure_sched(
|
147
|
+
&exec_ctx, calld->on_done_recv,
|
148
|
+
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_details),
|
149
|
+
GRPC_ERROR_INT_GRPC_STATUS, status));
|
150
150
|
}
|
151
151
|
|
152
152
|
grpc_exec_ctx_finish(&exec_ctx);
|
@@ -158,7 +158,7 @@ static void auth_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
|
|
158
158
|
call_data *calld = elem->call_data;
|
159
159
|
channel_data *chand = elem->channel_data;
|
160
160
|
if (error == GRPC_ERROR_NONE) {
|
161
|
-
if (chand->creds->processor.process != NULL) {
|
161
|
+
if (chand->creds != NULL && chand->creds->processor.process != NULL) {
|
162
162
|
calld->md = metadata_batch_to_md_array(calld->recv_initial_metadata);
|
163
163
|
chand->creds->processor.process(
|
164
164
|
chand->creds->processor.state, calld->auth_context,
|
@@ -170,14 +170,17 @@ static void auth_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
|
|
170
170
|
}
|
171
171
|
|
172
172
|
static void set_recv_ops_md_callbacks(grpc_call_element *elem,
|
173
|
-
|
173
|
+
grpc_transport_stream_op_batch *op) {
|
174
174
|
call_data *calld = elem->call_data;
|
175
175
|
|
176
|
-
if (op->recv_initial_metadata
|
176
|
+
if (op->recv_initial_metadata) {
|
177
177
|
/* substitute our callback for the higher callback */
|
178
|
-
calld->recv_initial_metadata =
|
179
|
-
|
180
|
-
|
178
|
+
calld->recv_initial_metadata =
|
179
|
+
op->payload->recv_initial_metadata.recv_initial_metadata;
|
180
|
+
calld->on_done_recv =
|
181
|
+
op->payload->recv_initial_metadata.recv_initial_metadata_ready;
|
182
|
+
op->payload->recv_initial_metadata.recv_initial_metadata_ready =
|
183
|
+
&calld->auth_on_recv;
|
181
184
|
calld->transport_op = op;
|
182
185
|
}
|
183
186
|
}
|
@@ -189,7 +192,7 @@ static void set_recv_ops_md_callbacks(grpc_call_element *elem,
|
|
189
192
|
that is being sent or received. */
|
190
193
|
static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
|
191
194
|
grpc_call_element *elem,
|
192
|
-
|
195
|
+
grpc_transport_stream_op_batch *op) {
|
193
196
|
set_recv_ops_md_callbacks(elem, op);
|
194
197
|
grpc_call_next_op(exec_ctx, elem, op);
|
195
198
|
}
|
@@ -227,7 +230,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
|
227
230
|
/* Destructor for call_data */
|
228
231
|
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
229
232
|
const grpc_call_final_info *final_info,
|
230
|
-
|
233
|
+
grpc_closure *ignored) {}
|
231
234
|
|
232
235
|
/* Constructor for channel_data */
|
233
236
|
static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
@@ -242,7 +245,6 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
242
245
|
|
243
246
|
GPR_ASSERT(!args->is_last);
|
244
247
|
GPR_ASSERT(auth_context != NULL);
|
245
|
-
GPR_ASSERT(creds != NULL);
|
246
248
|
|
247
249
|
/* initialize members */
|
248
250
|
chand->auth_context =
|
@@ -34,7 +34,9 @@
|
|
34
34
|
#include "src/core/lib/security/transport/tsi_error.h"
|
35
35
|
|
36
36
|
grpc_error *grpc_set_tsi_error_result(grpc_error *error, tsi_result result) {
|
37
|
-
return grpc_error_set_int(
|
38
|
-
|
39
|
-
|
37
|
+
return grpc_error_set_int(
|
38
|
+
grpc_error_set_str(
|
39
|
+
error, GRPC_ERROR_STR_TSI_ERROR,
|
40
|
+
grpc_slice_from_static_string(tsi_result_to_string(result))),
|
41
|
+
GRPC_ERROR_INT_TSI_CODE, result);
|
40
42
|
}
|
@@ -35,7 +35,7 @@
|
|
35
35
|
#define GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H
|
36
36
|
|
37
37
|
#include "src/core/lib/iomgr/error.h"
|
38
|
-
#include "src/core/
|
38
|
+
#include "src/core/tsi/transport_security_interface.h"
|
39
39
|
|
40
40
|
grpc_error *grpc_set_tsi_error_result(grpc_error *error, tsi_result result);
|
41
41
|
|
@@ -31,7 +31,7 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#include "src/core/lib/
|
34
|
+
#include "src/core/lib/slice/b64.h"
|
35
35
|
|
36
36
|
#include <stdint.h>
|
37
37
|
#include <string.h>
|
@@ -71,15 +71,31 @@ static const char base64_url_safe_chars[] =
|
|
71
71
|
|
72
72
|
char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
|
73
73
|
int multiline) {
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
size_t result_projected_size =
|
75
|
+
grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
|
76
|
+
char *result = gpr_malloc(result_projected_size);
|
77
|
+
grpc_base64_encode_core(result, vdata, data_size, url_safe, multiline);
|
78
|
+
return result;
|
79
|
+
}
|
80
|
+
|
81
|
+
size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe,
|
82
|
+
int multiline) {
|
77
83
|
size_t result_projected_size =
|
78
84
|
4 * ((data_size + 3) / 3) +
|
79
85
|
2 * (multiline ? (data_size / (3 * GRPC_BASE64_MULTILINE_NUM_BLOCKS))
|
80
86
|
: 0) +
|
81
87
|
1;
|
82
|
-
|
88
|
+
return result_projected_size;
|
89
|
+
}
|
90
|
+
|
91
|
+
void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
|
92
|
+
int url_safe, int multiline) {
|
93
|
+
const unsigned char *data = vdata;
|
94
|
+
const char *base64_chars =
|
95
|
+
url_safe ? base64_url_safe_chars : base64_url_unsafe_chars;
|
96
|
+
const size_t result_projected_size =
|
97
|
+
grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
|
98
|
+
|
83
99
|
char *current = result;
|
84
100
|
size_t num_blocks = 0;
|
85
101
|
size_t i = 0;
|
@@ -119,7 +135,6 @@ char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
|
|
119
135
|
GPR_ASSERT(current >= result);
|
120
136
|
GPR_ASSERT((uintptr_t)(current - result) < result_projected_size);
|
121
137
|
result[current - result] = '\0';
|
122
|
-
return result;
|
123
138
|
}
|
124
139
|
|
125
140
|
grpc_slice grpc_base64_decode(grpc_exec_ctx *exec_ctx, const char *b64,
|