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
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
/* Copyright (C) 2009-2013 by Daniel Stenberg
|
3
|
+
*
|
4
|
+
* Permission to use, copy, modify, and distribute this
|
5
|
+
* software and its documentation for any purpose and without
|
6
|
+
* fee is hereby granted, provided that the above copyright
|
7
|
+
* notice appear in all copies and that both that copyright
|
8
|
+
* notice and this permission notice appear in supporting
|
9
|
+
* documentation, and that the name of M.I.T. not be used in
|
10
|
+
* advertising or publicity pertaining to distribution of the
|
11
|
+
* software without specific, written prior permission.
|
12
|
+
* M.I.T. makes no representations about the suitability of
|
13
|
+
* this software for any purpose. It is provided "as is"
|
14
|
+
* without express or implied warranty.
|
15
|
+
*/
|
16
|
+
|
17
|
+
typedef enum {
|
18
|
+
ARES_DATATYPE_UNKNOWN = 1, /* unknown data type - introduced in 1.7.0 */
|
19
|
+
ARES_DATATYPE_SRV_REPLY, /* struct ares_srv_reply - introduced in 1.7.0 */
|
20
|
+
ARES_DATATYPE_TXT_REPLY, /* struct ares_txt_reply - introduced in 1.7.0 */
|
21
|
+
ARES_DATATYPE_TXT_EXT, /* struct ares_txt_ext - introduced in 1.11.0 */
|
22
|
+
ARES_DATATYPE_ADDR_NODE, /* struct ares_addr_node - introduced in 1.7.1 */
|
23
|
+
ARES_DATATYPE_MX_REPLY, /* struct ares_mx_reply - introduced in 1.7.2 */
|
24
|
+
ARES_DATATYPE_NAPTR_REPLY,/* struct ares_naptr_reply - introduced in 1.7.6 */
|
25
|
+
ARES_DATATYPE_SOA_REPLY, /* struct ares_soa_reply - introduced in 1.9.0 */
|
26
|
+
#if 0
|
27
|
+
ARES_DATATYPE_ADDR6TTL, /* struct ares_addrttl */
|
28
|
+
ARES_DATATYPE_ADDRTTL, /* struct ares_addr6ttl */
|
29
|
+
ARES_DATATYPE_HOSTENT, /* struct hostent */
|
30
|
+
ARES_DATATYPE_OPTIONS, /* struct ares_options */
|
31
|
+
#endif
|
32
|
+
ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced in 1.11.0 */
|
33
|
+
ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */
|
34
|
+
} ares_datatype;
|
35
|
+
|
36
|
+
#define ARES_DATATYPE_MARK 0xbead
|
37
|
+
|
38
|
+
/*
|
39
|
+
* ares_data struct definition is internal to c-ares and shall not
|
40
|
+
* be exposed by the public API in order to allow future changes
|
41
|
+
* and extensions to it without breaking ABI. This will be used
|
42
|
+
* internally by c-ares as the container of multiple types of data
|
43
|
+
* dynamically allocated for which a reference will be returned
|
44
|
+
* to the calling application.
|
45
|
+
*
|
46
|
+
* c-ares API functions returning a pointer to c-ares internally
|
47
|
+
* allocated data will actually be returning an interior pointer
|
48
|
+
* into this ares_data struct.
|
49
|
+
*
|
50
|
+
* All this is 'invisible' to the calling application, the only
|
51
|
+
* requirement is that this kind of data must be free'ed by the
|
52
|
+
* calling application using ares_free_data() with the pointer
|
53
|
+
* it has received from a previous c-ares function call.
|
54
|
+
*/
|
55
|
+
|
56
|
+
struct ares_data {
|
57
|
+
ares_datatype type; /* Actual data type identifier. */
|
58
|
+
unsigned int mark; /* Private ares_data signature. */
|
59
|
+
union {
|
60
|
+
struct ares_txt_reply txt_reply;
|
61
|
+
struct ares_txt_ext txt_ext;
|
62
|
+
struct ares_srv_reply srv_reply;
|
63
|
+
struct ares_addr_node addr_node;
|
64
|
+
struct ares_addr_port_node addr_port_node;
|
65
|
+
struct ares_mx_reply mx_reply;
|
66
|
+
struct ares_naptr_reply naptr_reply;
|
67
|
+
struct ares_soa_reply soa_reply;
|
68
|
+
} data;
|
69
|
+
};
|
70
|
+
|
71
|
+
void *ares_malloc_data(ares_datatype type);
|
72
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
|
2
|
+
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
3
|
+
* Copyright (C) 2004-2011 by Daniel Stenberg
|
4
|
+
*
|
5
|
+
* Permission to use, copy, modify, and distribute this
|
6
|
+
* software and its documentation for any purpose and without
|
7
|
+
* fee is hereby granted, provided that the above copyright
|
8
|
+
* notice appear in all copies and that both that copyright
|
9
|
+
* notice and this permission notice appear in supporting
|
10
|
+
* documentation, and that the name of M.I.T. not be used in
|
11
|
+
* advertising or publicity pertaining to distribution of the
|
12
|
+
* software without specific, written prior permission.
|
13
|
+
* M.I.T. makes no representations about the suitability of
|
14
|
+
* this software for any purpose. It is provided "as is"
|
15
|
+
* without express or implied warranty.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#include "ares_setup.h"
|
19
|
+
|
20
|
+
#include <assert.h>
|
21
|
+
|
22
|
+
#include "ares.h"
|
23
|
+
#include "ares_private.h"
|
24
|
+
|
25
|
+
void ares_destroy_options(struct ares_options *options)
|
26
|
+
{
|
27
|
+
int i;
|
28
|
+
|
29
|
+
if(options->servers)
|
30
|
+
ares_free(options->servers);
|
31
|
+
for (i = 0; i < options->ndomains; i++)
|
32
|
+
ares_free(options->domains[i]);
|
33
|
+
if(options->domains)
|
34
|
+
ares_free(options->domains);
|
35
|
+
if(options->sortlist)
|
36
|
+
ares_free(options->sortlist);
|
37
|
+
if(options->lookups)
|
38
|
+
ares_free(options->lookups);
|
39
|
+
}
|
40
|
+
|
41
|
+
void ares_destroy(ares_channel channel)
|
42
|
+
{
|
43
|
+
int i;
|
44
|
+
struct query *query;
|
45
|
+
struct list_node* list_head;
|
46
|
+
struct list_node* list_node;
|
47
|
+
|
48
|
+
if (!channel)
|
49
|
+
return;
|
50
|
+
|
51
|
+
list_head = &(channel->all_queries);
|
52
|
+
for (list_node = list_head->next; list_node != list_head; )
|
53
|
+
{
|
54
|
+
query = list_node->data;
|
55
|
+
list_node = list_node->next; /* since we're deleting the query */
|
56
|
+
query->callback(query->arg, ARES_EDESTRUCTION, 0, NULL, 0);
|
57
|
+
ares__free_query(query);
|
58
|
+
}
|
59
|
+
#ifndef NDEBUG
|
60
|
+
/* Freeing the query should remove it from all the lists in which it sits,
|
61
|
+
* so all query lists should be empty now.
|
62
|
+
*/
|
63
|
+
assert(ares__is_list_empty(&(channel->all_queries)));
|
64
|
+
for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
|
65
|
+
{
|
66
|
+
assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
|
67
|
+
}
|
68
|
+
for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
|
69
|
+
{
|
70
|
+
assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
|
71
|
+
}
|
72
|
+
#endif
|
73
|
+
|
74
|
+
ares__destroy_servers_state(channel);
|
75
|
+
|
76
|
+
if (channel->domains) {
|
77
|
+
for (i = 0; i < channel->ndomains; i++)
|
78
|
+
ares_free(channel->domains[i]);
|
79
|
+
ares_free(channel->domains);
|
80
|
+
}
|
81
|
+
|
82
|
+
if(channel->sortlist)
|
83
|
+
ares_free(channel->sortlist);
|
84
|
+
|
85
|
+
if (channel->lookups)
|
86
|
+
ares_free(channel->lookups);
|
87
|
+
|
88
|
+
ares_free(channel);
|
89
|
+
}
|
90
|
+
|
91
|
+
void ares__destroy_servers_state(ares_channel channel)
|
92
|
+
{
|
93
|
+
struct server_state *server;
|
94
|
+
int i;
|
95
|
+
|
96
|
+
if (channel->servers)
|
97
|
+
{
|
98
|
+
for (i = 0; i < channel->nservers; i++)
|
99
|
+
{
|
100
|
+
server = &channel->servers[i];
|
101
|
+
ares__close_sockets(channel, server);
|
102
|
+
assert(ares__is_list_empty(&server->queries_to_server));
|
103
|
+
}
|
104
|
+
ares_free(channel->servers);
|
105
|
+
channel->servers = NULL;
|
106
|
+
}
|
107
|
+
channel->nservers = -1;
|
108
|
+
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#ifndef HEADER_CARES_DNS_H
|
2
|
+
#define HEADER_CARES_DNS_H
|
3
|
+
|
4
|
+
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
|
5
|
+
*
|
6
|
+
* Permission to use, copy, modify, and distribute this
|
7
|
+
* software and its documentation for any purpose and without
|
8
|
+
* fee is hereby granted, provided that the above copyright
|
9
|
+
* notice appear in all copies and that both that copyright
|
10
|
+
* notice and this permission notice appear in supporting
|
11
|
+
* documentation, and that the name of M.I.T. not be used in
|
12
|
+
* advertising or publicity pertaining to distribution of the
|
13
|
+
* software without specific, written prior permission.
|
14
|
+
* M.I.T. makes no representations about the suitability of
|
15
|
+
* this software for any purpose. It is provided "as is"
|
16
|
+
* without express or implied warranty.
|
17
|
+
*/
|
18
|
+
|
19
|
+
/*
|
20
|
+
* Macro DNS__16BIT reads a network short (16 bit) given in network
|
21
|
+
* byte order, and returns its value as an unsigned short.
|
22
|
+
*/
|
23
|
+
#define DNS__16BIT(p) ((unsigned short)((unsigned int) 0xffff & \
|
24
|
+
(((unsigned int)((unsigned char)(p)[0]) << 8U) | \
|
25
|
+
((unsigned int)((unsigned char)(p)[1])))))
|
26
|
+
|
27
|
+
/*
|
28
|
+
* Macro DNS__32BIT reads a network long (32 bit) given in network
|
29
|
+
* byte order, and returns its value as an unsigned int.
|
30
|
+
*/
|
31
|
+
#define DNS__32BIT(p) ((unsigned int) \
|
32
|
+
(((unsigned int)((unsigned char)(p)[0]) << 24U) | \
|
33
|
+
((unsigned int)((unsigned char)(p)[1]) << 16U) | \
|
34
|
+
((unsigned int)((unsigned char)(p)[2]) << 8U) | \
|
35
|
+
((unsigned int)((unsigned char)(p)[3]))))
|
36
|
+
|
37
|
+
#define DNS__SET16BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 8) & 0xff)), \
|
38
|
+
((p)[1] = (unsigned char)((v) & 0xff)))
|
39
|
+
#define DNS__SET32BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 24) & 0xff)), \
|
40
|
+
((p)[1] = (unsigned char)(((v) >> 16) & 0xff)), \
|
41
|
+
((p)[2] = (unsigned char)(((v) >> 8) & 0xff)), \
|
42
|
+
((p)[3] = (unsigned char)((v) & 0xff)))
|
43
|
+
|
44
|
+
#if 0
|
45
|
+
/* we cannot use this approach on systems where we can't access 16/32 bit
|
46
|
+
data on un-aligned addresses */
|
47
|
+
#define DNS__16BIT(p) ntohs(*(unsigned short*)(p))
|
48
|
+
#define DNS__32BIT(p) ntohl(*(unsigned long*)(p))
|
49
|
+
#define DNS__SET16BIT(p, v) *(unsigned short*)(p) = htons(v)
|
50
|
+
#define DNS__SET32BIT(p, v) *(unsigned long*)(p) = htonl(v)
|
51
|
+
#endif
|
52
|
+
|
53
|
+
/* Macros for parsing a DNS header */
|
54
|
+
#define DNS_HEADER_QID(h) DNS__16BIT(h)
|
55
|
+
#define DNS_HEADER_QR(h) (((h)[2] >> 7) & 0x1)
|
56
|
+
#define DNS_HEADER_OPCODE(h) (((h)[2] >> 3) & 0xf)
|
57
|
+
#define DNS_HEADER_AA(h) (((h)[2] >> 2) & 0x1)
|
58
|
+
#define DNS_HEADER_TC(h) (((h)[2] >> 1) & 0x1)
|
59
|
+
#define DNS_HEADER_RD(h) ((h)[2] & 0x1)
|
60
|
+
#define DNS_HEADER_RA(h) (((h)[3] >> 7) & 0x1)
|
61
|
+
#define DNS_HEADER_Z(h) (((h)[3] >> 4) & 0x7)
|
62
|
+
#define DNS_HEADER_RCODE(h) ((h)[3] & 0xf)
|
63
|
+
#define DNS_HEADER_QDCOUNT(h) DNS__16BIT((h) + 4)
|
64
|
+
#define DNS_HEADER_ANCOUNT(h) DNS__16BIT((h) + 6)
|
65
|
+
#define DNS_HEADER_NSCOUNT(h) DNS__16BIT((h) + 8)
|
66
|
+
#define DNS_HEADER_ARCOUNT(h) DNS__16BIT((h) + 10)
|
67
|
+
|
68
|
+
/* Macros for constructing a DNS header */
|
69
|
+
#define DNS_HEADER_SET_QID(h, v) DNS__SET16BIT(h, v)
|
70
|
+
#define DNS_HEADER_SET_QR(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 7))
|
71
|
+
#define DNS_HEADER_SET_OPCODE(h, v) ((h)[2] |= (unsigned char)(((v) & 0xf) << 3))
|
72
|
+
#define DNS_HEADER_SET_AA(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 2))
|
73
|
+
#define DNS_HEADER_SET_TC(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 1))
|
74
|
+
#define DNS_HEADER_SET_RD(h, v) ((h)[2] |= (unsigned char)((v) & 0x1))
|
75
|
+
#define DNS_HEADER_SET_RA(h, v) ((h)[3] |= (unsigned char)(((v) & 0x1) << 7))
|
76
|
+
#define DNS_HEADER_SET_Z(h, v) ((h)[3] |= (unsigned char)(((v) & 0x7) << 4))
|
77
|
+
#define DNS_HEADER_SET_RCODE(h, v) ((h)[3] |= (unsigned char)((v) & 0xf))
|
78
|
+
#define DNS_HEADER_SET_QDCOUNT(h, v) DNS__SET16BIT((h) + 4, v)
|
79
|
+
#define DNS_HEADER_SET_ANCOUNT(h, v) DNS__SET16BIT((h) + 6, v)
|
80
|
+
#define DNS_HEADER_SET_NSCOUNT(h, v) DNS__SET16BIT((h) + 8, v)
|
81
|
+
#define DNS_HEADER_SET_ARCOUNT(h, v) DNS__SET16BIT((h) + 10, v)
|
82
|
+
|
83
|
+
/* Macros for parsing the fixed part of a DNS question */
|
84
|
+
#define DNS_QUESTION_TYPE(q) DNS__16BIT(q)
|
85
|
+
#define DNS_QUESTION_CLASS(q) DNS__16BIT((q) + 2)
|
86
|
+
|
87
|
+
/* Macros for constructing the fixed part of a DNS question */
|
88
|
+
#define DNS_QUESTION_SET_TYPE(q, v) DNS__SET16BIT(q, v)
|
89
|
+
#define DNS_QUESTION_SET_CLASS(q, v) DNS__SET16BIT((q) + 2, v)
|
90
|
+
|
91
|
+
/* Macros for parsing the fixed part of a DNS resource record */
|
92
|
+
#define DNS_RR_TYPE(r) DNS__16BIT(r)
|
93
|
+
#define DNS_RR_CLASS(r) DNS__16BIT((r) + 2)
|
94
|
+
#define DNS_RR_TTL(r) DNS__32BIT((r) + 4)
|
95
|
+
#define DNS_RR_LEN(r) DNS__16BIT((r) + 8)
|
96
|
+
|
97
|
+
/* Macros for constructing the fixed part of a DNS resource record */
|
98
|
+
#define DNS_RR_SET_TYPE(r, v) DNS__SET16BIT(r, v)
|
99
|
+
#define DNS_RR_SET_CLASS(r, v) DNS__SET16BIT((r) + 2, v)
|
100
|
+
#define DNS_RR_SET_TTL(r, v) DNS__SET32BIT((r) + 4, v)
|
101
|
+
#define DNS_RR_SET_LEN(r, v) DNS__SET16BIT((r) + 8, v)
|
102
|
+
|
103
|
+
#endif /* HEADER_CARES_DNS_H */
|
@@ -0,0 +1,205 @@
|
|
1
|
+
|
2
|
+
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
|
3
|
+
*
|
4
|
+
* Permission to use, copy, modify, and distribute this
|
5
|
+
* software and its documentation for any purpose and without
|
6
|
+
* fee is hereby granted, provided that the above copyright
|
7
|
+
* notice appear in all copies and that both that copyright
|
8
|
+
* notice and this permission notice appear in supporting
|
9
|
+
* documentation, and that the name of M.I.T. not be used in
|
10
|
+
* advertising or publicity pertaining to distribution of the
|
11
|
+
* software without specific, written prior permission.
|
12
|
+
* M.I.T. makes no representations about the suitability of
|
13
|
+
* this software for any purpose. It is provided "as is"
|
14
|
+
* without express or implied warranty.
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include "ares_setup.h"
|
18
|
+
|
19
|
+
#ifdef HAVE_NETINET_IN_H
|
20
|
+
# include <netinet/in.h>
|
21
|
+
#endif
|
22
|
+
#ifdef HAVE_ARPA_NAMESER_H
|
23
|
+
# include <arpa/nameser.h>
|
24
|
+
#else
|
25
|
+
# include "nameser.h"
|
26
|
+
#endif
|
27
|
+
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
28
|
+
# include <arpa/nameser_compat.h>
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#include "ares.h"
|
32
|
+
#include "ares_nowarn.h"
|
33
|
+
#include "ares_private.h" /* for the memdebug */
|
34
|
+
|
35
|
+
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
36
|
+
int alen);
|
37
|
+
|
38
|
+
/* Expand an RFC1035-encoded domain name given by encoded. The
|
39
|
+
* containing message is given by abuf and alen. The result given by
|
40
|
+
* *s, which is set to a NUL-terminated allocated buffer. *enclen is
|
41
|
+
* set to the length of the encoded name (not the length of the
|
42
|
+
* expanded name; the goal is to tell the caller how many bytes to
|
43
|
+
* move forward to get past the encoded name).
|
44
|
+
*
|
45
|
+
* In the simple case, an encoded name is a series of labels, each
|
46
|
+
* composed of a one-byte length (limited to values between 0 and 63
|
47
|
+
* inclusive) followed by the label contents. The name is terminated
|
48
|
+
* by a zero-length label.
|
49
|
+
*
|
50
|
+
* In the more complicated case, a label may be terminated by an
|
51
|
+
* indirection pointer, specified by two bytes with the high bits of
|
52
|
+
* the first byte (corresponding to INDIR_MASK) set to 11. With the
|
53
|
+
* two high bits of the first byte stripped off, the indirection
|
54
|
+
* pointer gives an offset from the beginning of the containing
|
55
|
+
* message with more labels to decode. Indirection can happen an
|
56
|
+
* arbitrary number of times, so we have to detect loops.
|
57
|
+
*
|
58
|
+
* Since the expanded name uses '.' as a label separator, we use
|
59
|
+
* backslashes to escape periods or backslashes in the expanded name.
|
60
|
+
*/
|
61
|
+
|
62
|
+
int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
63
|
+
int alen, char **s, long *enclen)
|
64
|
+
{
|
65
|
+
int len, indir = 0;
|
66
|
+
char *q;
|
67
|
+
const unsigned char *p;
|
68
|
+
union {
|
69
|
+
ssize_t sig;
|
70
|
+
size_t uns;
|
71
|
+
} nlen;
|
72
|
+
|
73
|
+
nlen.sig = name_length(encoded, abuf, alen);
|
74
|
+
if (nlen.sig < 0)
|
75
|
+
return ARES_EBADNAME;
|
76
|
+
|
77
|
+
*s = ares_malloc(nlen.uns + 1);
|
78
|
+
if (!*s)
|
79
|
+
return ARES_ENOMEM;
|
80
|
+
q = *s;
|
81
|
+
|
82
|
+
if (nlen.uns == 0) {
|
83
|
+
/* RFC2181 says this should be ".": the root of the DNS tree.
|
84
|
+
* Since this function strips trailing dots though, it becomes ""
|
85
|
+
*/
|
86
|
+
q[0] = '\0';
|
87
|
+
|
88
|
+
/* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but
|
89
|
+
valid) */
|
90
|
+
if ((*encoded & INDIR_MASK) == INDIR_MASK)
|
91
|
+
*enclen = 2L;
|
92
|
+
else
|
93
|
+
*enclen = 1L; /* the caller should move one byte to get past this */
|
94
|
+
|
95
|
+
return ARES_SUCCESS;
|
96
|
+
}
|
97
|
+
|
98
|
+
/* No error-checking necessary; it was all done by name_length(). */
|
99
|
+
p = encoded;
|
100
|
+
while (*p)
|
101
|
+
{
|
102
|
+
if ((*p & INDIR_MASK) == INDIR_MASK)
|
103
|
+
{
|
104
|
+
if (!indir)
|
105
|
+
{
|
106
|
+
*enclen = aresx_uztosl(p + 2U - encoded);
|
107
|
+
indir = 1;
|
108
|
+
}
|
109
|
+
p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1));
|
110
|
+
}
|
111
|
+
else
|
112
|
+
{
|
113
|
+
len = *p;
|
114
|
+
p++;
|
115
|
+
while (len--)
|
116
|
+
{
|
117
|
+
if (*p == '.' || *p == '\\')
|
118
|
+
*q++ = '\\';
|
119
|
+
*q++ = *p;
|
120
|
+
p++;
|
121
|
+
}
|
122
|
+
*q++ = '.';
|
123
|
+
}
|
124
|
+
}
|
125
|
+
if (!indir)
|
126
|
+
*enclen = aresx_uztosl(p + 1U - encoded);
|
127
|
+
|
128
|
+
/* Nuke the trailing period if we wrote one. */
|
129
|
+
if (q > *s)
|
130
|
+
*(q - 1) = 0;
|
131
|
+
else
|
132
|
+
*q = 0; /* zero terminate; LCOV_EXCL_LINE: empty names exit above */
|
133
|
+
|
134
|
+
return ARES_SUCCESS;
|
135
|
+
}
|
136
|
+
|
137
|
+
/* Return the length of the expansion of an encoded domain name, or
|
138
|
+
* -1 if the encoding is invalid.
|
139
|
+
*/
|
140
|
+
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
141
|
+
int alen)
|
142
|
+
{
|
143
|
+
int n = 0, offset, indir = 0, top;
|
144
|
+
|
145
|
+
/* Allow the caller to pass us abuf + alen and have us check for it. */
|
146
|
+
if (encoded >= abuf + alen)
|
147
|
+
return -1;
|
148
|
+
|
149
|
+
while (*encoded)
|
150
|
+
{
|
151
|
+
top = (*encoded & INDIR_MASK);
|
152
|
+
if (top == INDIR_MASK)
|
153
|
+
{
|
154
|
+
/* Check the offset and go there. */
|
155
|
+
if (encoded + 1 >= abuf + alen)
|
156
|
+
return -1;
|
157
|
+
offset = (*encoded & ~INDIR_MASK) << 8 | *(encoded + 1);
|
158
|
+
if (offset >= alen)
|
159
|
+
return -1;
|
160
|
+
encoded = abuf + offset;
|
161
|
+
|
162
|
+
/* If we've seen more indirects than the message length,
|
163
|
+
* then there's a loop.
|
164
|
+
*/
|
165
|
+
if (++indir > alen)
|
166
|
+
return -1;
|
167
|
+
}
|
168
|
+
else if (top == 0x00)
|
169
|
+
{
|
170
|
+
offset = *encoded;
|
171
|
+
if (encoded + offset + 1 >= abuf + alen)
|
172
|
+
return -1;
|
173
|
+
encoded++;
|
174
|
+
while (offset--)
|
175
|
+
{
|
176
|
+
n += (*encoded == '.' || *encoded == '\\') ? 2 : 1;
|
177
|
+
encoded++;
|
178
|
+
}
|
179
|
+
n++;
|
180
|
+
}
|
181
|
+
else
|
182
|
+
{
|
183
|
+
/* RFC 1035 4.1.4 says other options (01, 10) for top 2
|
184
|
+
* bits are reserved.
|
185
|
+
*/
|
186
|
+
return -1;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
/* If there were any labels at all, then the number of dots is one
|
191
|
+
* less than the number of labels, so subtract one.
|
192
|
+
*/
|
193
|
+
return (n) ? n - 1 : n;
|
194
|
+
}
|
195
|
+
|
196
|
+
/* Like ares_expand_name but returns EBADRESP in case of invalid input. */
|
197
|
+
int ares__expand_name_for_response(const unsigned char *encoded,
|
198
|
+
const unsigned char *abuf, int alen,
|
199
|
+
char **s, long *enclen)
|
200
|
+
{
|
201
|
+
int status = ares_expand_name(encoded, abuf, alen, s, enclen);
|
202
|
+
if (status == ARES_EBADNAME)
|
203
|
+
status = ARES_EBADRESP;
|
204
|
+
return status;
|
205
|
+
}
|