grpc 1.23.1 → 1.24.0.pre1

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.

Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +757 -477
  3. data/include/grpc/grpc.h +3 -1
  4. data/include/grpc/grpc_security.h +20 -4
  5. data/include/grpc/impl/codegen/grpc_types.h +6 -5
  6. data/include/grpc/impl/codegen/port_platform.h +25 -0
  7. data/src/core/ext/filters/client_channel/backend_metric.cc +78 -0
  8. data/src/core/ext/filters/client_channel/backend_metric.h +36 -0
  9. data/src/core/ext/filters/client_channel/channel_connectivity.cc +16 -2
  10. data/src/core/ext/filters/client_channel/client_channel.cc +325 -267
  11. data/src/core/ext/filters/client_channel/client_channel_factory.h +0 -4
  12. data/src/core/ext/filters/client_channel/health/health_check_client.cc +23 -32
  13. data/src/core/ext/filters/client_channel/http_proxy.cc +7 -3
  14. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
  15. data/src/core/ext/filters/client_channel/lb_policy.h +58 -34
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +46 -50
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +9 -2
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +35 -17
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +130 -215
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +34 -21
  21. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +1120 -802
  22. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h +8 -2
  23. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +33 -12
  24. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc +151 -40
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h +184 -26
  26. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +389 -245
  27. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +98 -60
  28. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +6 -1
  29. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +89 -0
  30. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +3 -8
  31. data/src/core/ext/filters/client_channel/server_address.cc +1 -3
  32. data/src/core/ext/filters/client_channel/server_address.h +1 -1
  33. data/src/core/ext/filters/client_channel/subchannel.h +2 -1
  34. data/src/core/ext/filters/client_idle/client_idle_filter.cc +207 -29
  35. data/src/core/ext/filters/http/client/http_client_filter.cc +10 -8
  36. data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
  37. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +10 -7
  38. data/src/core/ext/filters/http/server/http_server_filter.cc +52 -26
  39. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +23 -20
  40. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +24 -21
  41. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +1 -1
  42. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +37 -24
  43. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
  44. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +237 -191
  45. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +29 -27
  46. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +1 -1
  47. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +19 -4
  48. data/src/core/ext/transport/chttp2/transport/hpack_table.h +13 -4
  49. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -1
  50. data/src/core/ext/transport/chttp2/transport/internal.h +0 -2
  51. data/src/core/ext/transport/chttp2/transport/parsing.cc +99 -71
  52. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +222 -0
  53. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +818 -0
  54. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +314 -0
  55. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +1142 -0
  56. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +53 -0
  57. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +158 -0
  58. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +34 -0
  59. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +69 -0
  60. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +49 -0
  61. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +240 -0
  62. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +110 -0
  63. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +324 -0
  64. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +235 -0
  65. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +661 -0
  66. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +84 -0
  67. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +274 -0
  68. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +175 -0
  69. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +572 -0
  70. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +150 -0
  71. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +596 -0
  72. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +35 -0
  73. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +80 -0
  74. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +95 -0
  75. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +308 -0
  76. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +128 -0
  77. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +392 -0
  78. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +91 -0
  79. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +236 -0
  80. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +88 -0
  81. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +258 -0
  82. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +111 -0
  83. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +324 -0
  84. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c +23 -0
  85. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +50 -0
  86. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +52 -0
  87. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +130 -0
  88. data/src/core/ext/upb-generated/envoy/type/percent.upb.c +39 -0
  89. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +87 -0
  90. data/src/core/ext/upb-generated/envoy/type/range.upb.c +39 -0
  91. data/src/core/ext/upb-generated/envoy/type/range.upb.h +85 -0
  92. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +17 -0
  93. data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +30 -0
  94. data/src/core/ext/upb-generated/google/api/annotations.upb.c +18 -0
  95. data/src/core/ext/upb-generated/google/api/annotations.upb.h +30 -0
  96. data/src/core/ext/upb-generated/google/api/http.upb.c +66 -0
  97. data/src/core/ext/upb-generated/google/api/http.upb.h +190 -0
  98. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +27 -0
  99. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +58 -0
  100. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +485 -0
  101. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +1690 -0
  102. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +27 -0
  103. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +58 -0
  104. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +22 -0
  105. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +50 -0
  106. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +79 -0
  107. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +215 -0
  108. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +27 -0
  109. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +58 -0
  110. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +106 -0
  111. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +238 -0
  112. data/src/core/ext/upb-generated/google/rpc/status.upb.c +33 -0
  113. data/src/core/ext/upb-generated/google/rpc/status.upb.h +74 -0
  114. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +49 -0
  115. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +126 -0
  116. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +209 -0
  117. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +681 -0
  118. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +42 -0
  119. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +109 -0
  120. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +36 -0
  121. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +84 -0
  122. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +133 -0
  123. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +359 -0
  124. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +58 -0
  125. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +144 -0
  126. data/src/core/ext/upb-generated/validate/validate.upb.c +443 -0
  127. data/src/core/ext/upb-generated/validate/validate.upb.h +2037 -0
  128. data/src/core/lib/channel/channel_args.cc +21 -0
  129. data/src/core/lib/channel/channel_args.h +16 -2
  130. data/src/core/lib/channel/channel_stack.h +2 -1
  131. data/src/core/lib/channel/channelz.cc +54 -56
  132. data/src/core/lib/channel/channelz.h +29 -12
  133. data/src/core/lib/compression/compression.cc +2 -1
  134. data/src/core/lib/compression/compression_internal.h +8 -0
  135. data/src/core/lib/gpr/log_linux.cc +2 -2
  136. data/src/core/lib/gpr/log_posix.cc +2 -2
  137. data/src/core/lib/gpr/time_precise.cc +123 -36
  138. data/src/core/lib/gpr/time_precise.h +37 -0
  139. data/src/core/lib/gprpp/abstract.h +10 -0
  140. data/src/core/lib/gprpp/atomic.h +4 -0
  141. data/src/core/lib/gprpp/inlined_vector.h +20 -4
  142. data/src/core/lib/gprpp/map.h +109 -6
  143. data/src/core/lib/gprpp/memory.h +6 -0
  144. data/src/core/lib/gprpp/ref_counted_ptr.h +2 -0
  145. data/src/core/lib/iomgr/ev_epollex_linux.cc +29 -54
  146. data/src/core/lib/iomgr/exec_ctx.cc +27 -17
  147. data/src/core/lib/iomgr/exec_ctx.h +3 -0
  148. data/src/core/lib/iomgr/sockaddr_utils.cc +1 -3
  149. data/src/core/lib/iomgr/tcp_posix.cc +16 -25
  150. data/src/core/lib/iomgr/tcp_server_custom.cc +1 -1
  151. data/src/core/lib/iomgr/timer_manager.cc +8 -1
  152. data/src/core/lib/iomgr/timer_manager.h +2 -0
  153. data/src/core/lib/security/credentials/credentials.h +8 -2
  154. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +23 -0
  155. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +3 -0
  156. data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +3 -3
  157. data/src/core/lib/security/security_connector/ssl_utils.cc +1 -12
  158. data/src/core/lib/security/security_connector/ssl_utils.h +10 -6
  159. data/src/core/lib/security/security_connector/ssl_utils_config.cc +32 -0
  160. data/src/core/lib/security/security_connector/ssl_utils_config.h +30 -0
  161. data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +161 -49
  162. data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +34 -1
  163. data/src/core/lib/slice/slice_intern.cc +17 -9
  164. data/src/core/lib/slice/slice_internal.h +34 -7
  165. data/src/core/lib/slice/slice_utils.h +7 -3
  166. data/src/core/lib/surface/call.cc +97 -57
  167. data/src/core/lib/surface/channel.cc +2 -2
  168. data/src/core/lib/surface/completion_queue.cc +10 -16
  169. data/src/core/lib/surface/init.cc +3 -0
  170. data/src/core/lib/surface/server.cc +11 -14
  171. data/src/core/lib/surface/validate_metadata.cc +4 -0
  172. data/src/core/lib/surface/version.cc +2 -2
  173. data/src/core/lib/transport/metadata.cc +4 -4
  174. data/src/core/lib/transport/metadata_batch.cc +72 -16
  175. data/src/core/lib/transport/metadata_batch.h +38 -0
  176. data/src/core/lib/transport/static_metadata.cc +814 -1023
  177. data/src/core/lib/transport/static_metadata.h +271 -213
  178. data/src/core/lib/transport/transport.h +12 -0
  179. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  180. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +104 -76
  181. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +34 -16
  182. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +2 -2
  183. data/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +10 -6
  184. data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +4 -3
  185. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +74 -48
  186. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +34 -26
  187. data/src/core/tsi/ssl_transport_security.cc +14 -6
  188. data/src/core/tsi/ssl_transport_security.h +4 -0
  189. data/src/ruby/ext/grpc/ext-export.clang +1 -0
  190. data/src/ruby/ext/grpc/ext-export.gcc +6 -0
  191. data/src/ruby/ext/grpc/extconf.rb +5 -0
  192. data/src/ruby/ext/grpc/rb_enable_cpp.cc +22 -0
  193. data/src/ruby/ext/grpc/rb_grpc.c +1 -42
  194. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  195. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
  196. data/src/ruby/lib/grpc.rb +2 -0
  197. data/src/ruby/lib/grpc/core/status_codes.rb +135 -0
  198. data/src/ruby/lib/grpc/errors.rb +4 -7
  199. data/src/ruby/lib/grpc/google_rpc_status_utils.rb +9 -4
  200. data/src/ruby/lib/grpc/structs.rb +15 -0
  201. data/src/ruby/lib/grpc/version.rb +1 -1
  202. data/src/ruby/spec/errors_spec.rb +1 -0
  203. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto +22 -0
  204. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +34 -0
  205. data/src/ruby/spec/pb/codegen/package_option_spec.rb +53 -29
  206. data/third_party/upb/upb/decode.c +604 -0
  207. data/third_party/upb/upb/decode.h +21 -0
  208. data/third_party/upb/upb/encode.c +378 -0
  209. data/third_party/upb/upb/encode.h +21 -0
  210. data/third_party/upb/upb/generated_util.h +105 -0
  211. data/third_party/upb/upb/msg.c +111 -0
  212. data/third_party/upb/upb/msg.h +69 -0
  213. data/third_party/upb/upb/port.c +27 -0
  214. data/third_party/upb/upb/port_def.inc +152 -0
  215. data/third_party/upb/upb/port_undef.inc +21 -0
  216. data/third_party/upb/upb/table.c +911 -0
  217. data/third_party/upb/upb/table.int.h +507 -0
  218. data/third_party/upb/upb/upb.c +261 -0
  219. data/third_party/upb/upb/upb.h +364 -0
  220. metadata +134 -55
  221. data/src/core/ext/filters/client_channel/health/health.pb.c +0 -23
  222. data/src/core/ext/filters/client_channel/health/health.pb.h +0 -73
  223. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c +0 -19
  224. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h +0 -54
  225. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c +0 -19
  226. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h +0 -54
  227. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +0 -89
  228. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -164
  229. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc +0 -520
  230. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.h +0 -323
  231. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc +0 -145
  232. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +0 -149
  233. data/src/core/tsi/alts/handshaker/altscontext.pb.c +0 -47
  234. data/src/core/tsi/alts/handshaker/altscontext.pb.h +0 -63
  235. data/src/core/tsi/alts/handshaker/handshaker.pb.c +0 -122
  236. data/src/core/tsi/alts/handshaker/handshaker.pb.h +0 -254
  237. data/src/core/tsi/alts/handshaker/transport_security_common.pb.c +0 -49
  238. data/src/core/tsi/alts/handshaker/transport_security_common.pb.h +0 -78
  239. data/third_party/nanopb/pb.h +0 -579
  240. data/third_party/nanopb/pb_common.c +0 -97
  241. data/third_party/nanopb/pb_common.h +0 -42
  242. data/third_party/nanopb/pb_decode.c +0 -1347
  243. data/third_party/nanopb/pb_decode.h +0 -149
  244. data/third_party/nanopb/pb_encode.c +0 -696
  245. data/third_party/nanopb/pb_encode.h +0 -154
@@ -1,323 +0,0 @@
1
- /*
2
- *
3
- * Copyright 2018 gRPC authors.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
-
19
- #ifndef GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H
20
- #define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H
21
-
22
- #include <grpc/support/port_platform.h>
23
-
24
- #include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h"
25
-
26
- /**
27
- * An implementation of nanopb thin wrapper used to set/get and
28
- * serialize/de-serialize of ALTS handshake requests and responses.
29
- *
30
- * All APIs in the header are thread-compatible. A typical usage of this API at
31
- * the client side is as follows:
32
- *
33
- * -----------------------------------------------------------------------------
34
- * // Create, populate, and serialize an ALTS client_start handshake request to
35
- * // send to the server.
36
- * grpc_gcp_handshaker_req* req =
37
- * grpc_gcp_handshaker_req_create(CLIENT_START_REQ);
38
- * grpc_gcp_handshaker_req_set_handshake_protocol(
39
- req, grpc_gcp_HandshakeProtocol_ALTS);
40
- * grpc_gcp_handshaker_req_add_application_protocol(req, "grpc");
41
- * grpc_gcp_handshaker_req_add_record_protocol(req, "ALTSRP_GCM_AES128");
42
- * grpc_slice client_slice;
43
- * if (!grpc_gcp_handshaker_req_encode(req, &client_slice)) {
44
- * fprintf(stderr, "ALTS handshake request encoding failed.";
45
- * }
46
- *
47
- * // De-serialize a data stream received from the server, and store the result
48
- * // at ALTS handshake response.
49
- * grpc_gcp_handshaker_resp* resp = grpc_gcp_handshaker_resp_create();
50
- * if (!grpc_gcp_handshaker_resp_decode(server_slice, resp)) {
51
- * fprintf(stderr, "ALTS handshake response decoding failed.");
52
- * }
53
- * // To access a variable-length datatype field (i.e., pb_callback_t),
54
- * // access its "arg" subfield (if it has been set).
55
- * if (resp->out_frames.arg != nullptr) {
56
- * grpc_slice* slice = resp->out_frames.arg;
57
- * }
58
- * // To access a fixed-length datatype field (i.e., not pb_calback_t),
59
- * // access the field directly (if it has been set).
60
- * if (resp->has_status && resp->status->has_code) {
61
- * uint32_t code = resp->status->code;
62
- * }
63
- *------------------------------------------------------------------------------
64
- */
65
-
66
- /**
67
- * This method creates an ALTS handshake request.
68
- *
69
- * - type: an enum type value that can be either CLIENT_START_REQ,
70
- * SERVER_START_REQ, or NEXT_REQ to indicate the created instance will be
71
- * client_start, server_start, and next handshake request message
72
- * respectively.
73
- *
74
- * The method returns a pointer to the created instance.
75
- */
76
- grpc_gcp_handshaker_req* grpc_gcp_handshaker_req_create(
77
- grpc_gcp_handshaker_req_type type);
78
-
79
- /**
80
- * This method sets the value for handshake_security_protocol field of ALTS
81
- * client_start handshake request.
82
- *
83
- * - req: an ALTS handshake request.
84
- * - handshake_protocol: a enum type value representing the handshake security
85
- * protocol.
86
- *
87
- * The method returns true on success and false otherwise.
88
- */
89
- bool grpc_gcp_handshaker_req_set_handshake_protocol(
90
- grpc_gcp_handshaker_req* req,
91
- grpc_gcp_handshake_protocol handshake_protocol);
92
-
93
- /**
94
- * This method sets the value for target_name field of ALTS client_start
95
- * handshake request.
96
- *
97
- * - req: an ALTS handshake request.
98
- * - target_name: a target name to be set.
99
- *
100
- * The method returns true on success and false otherwise.
101
- */
102
- bool grpc_gcp_handshaker_req_set_target_name(grpc_gcp_handshaker_req* req,
103
- const char* target_name);
104
-
105
- /**
106
- * This method adds an application protocol supported by the server (or
107
- * client) to ALTS server_start (or client_start) handshake request.
108
- *
109
- * - req: an ALTS handshake request.
110
- * - application_protocol: an application protocol (e.g., grpc) to be added.
111
- *
112
- * The method returns true on success and false otherwise.
113
- */
114
- bool grpc_gcp_handshaker_req_add_application_protocol(
115
- grpc_gcp_handshaker_req* req, const char* application_protocol);
116
-
117
- /**
118
- * This method adds a record protocol supported by the client to ALTS
119
- * client_start handshake request.
120
- *
121
- * - req: an ALTS handshake request.
122
- * - record_protocol: a record protocol (e.g., ALTSRP_GCM_AES128) to be
123
- * added.
124
- *
125
- * The method returns true on success and false otherwise.
126
- */
127
- bool grpc_gcp_handshaker_req_add_record_protocol(grpc_gcp_handshaker_req* req,
128
- const char* record_protocol);
129
-
130
- /**
131
- * This method adds a target server identity represented as hostname and
132
- * acceptable by a client to ALTS client_start handshake request.
133
- *
134
- * - req: an ALTS handshake request.
135
- * - hostname: a string representation of hostname at the connection
136
- * endpoint to be added.
137
- *
138
- * The method returns true on success and false otherwise.
139
- */
140
- bool grpc_gcp_handshaker_req_add_target_identity_hostname(
141
- grpc_gcp_handshaker_req* req, const char* hostname);
142
-
143
- /**
144
- * This method adds a target server identity represented as service account and
145
- * acceptable by a client to ALTS client_start handshake request.
146
- *
147
- * - req: an ALTS handshake request.
148
- * - service_account: a string representation of service account at the
149
- * connection endpoint to be added.
150
- *
151
- * The method returns true on success and false otherwise.
152
- */
153
- bool grpc_gcp_handshaker_req_add_target_identity_service_account(
154
- grpc_gcp_handshaker_req* req, const char* service_account);
155
-
156
- /**
157
- * This method sets the hostname for local_identity field of ALTS client_start
158
- * handshake request.
159
- *
160
- * - req: an ALTS handshake request.
161
- * - hostname: a string representation of hostname.
162
- *
163
- * The method returns true on success and false otherwise.
164
- */
165
- bool grpc_gcp_handshaker_req_set_local_identity_hostname(
166
- grpc_gcp_handshaker_req* req, const char* hostname);
167
-
168
- /**
169
- * This method sets the service account for local_identity field of ALTS
170
- * client_start handshake request.
171
- *
172
- * - req: an ALTS handshake request.
173
- * - service_account: a string representation of service account.
174
- *
175
- * The method returns true on success and false otherwise.
176
- */
177
- bool grpc_gcp_handshaker_req_set_local_identity_service_account(
178
- grpc_gcp_handshaker_req* req, const char* service_account);
179
-
180
- /**
181
- * This method sets the value for local_endpoint field of either ALTS
182
- * client_start or server_start handshake request.
183
- *
184
- * - req: an ALTS handshake request.
185
- * - ip_address: a string representation of ip address associated with the
186
- * local endpoint, that could be either IPv4 or IPv6.
187
- * - port: a port number associated with the local endpoint.
188
- * - protocol: a network protocol (e.g., TCP or UDP) associated with the
189
- * local endpoint.
190
- *
191
- * The method returns true on success and false otherwise.
192
- */
193
- bool grpc_gcp_handshaker_req_set_local_endpoint(
194
- grpc_gcp_handshaker_req* req, const char* ip_address, size_t port,
195
- grpc_gcp_network_protocol protocol);
196
-
197
- /**
198
- * This method sets the value for remote_endpoint field of either ALTS
199
- * client_start or server_start handshake request.
200
- *
201
- * - req: an ALTS handshake request.
202
- * - ip_address: a string representation of ip address associated with the
203
- * remote endpoint, that could be either IPv4 or IPv6.
204
- * - port: a port number associated with the remote endpoint.
205
- * - protocol: a network protocol (e.g., TCP or UDP) associated with the
206
- * remote endpoint.
207
- *
208
- * The method returns true on success and false otherwise.
209
- */
210
- bool grpc_gcp_handshaker_req_set_remote_endpoint(
211
- grpc_gcp_handshaker_req* req, const char* ip_address, size_t port,
212
- grpc_gcp_network_protocol protocol);
213
-
214
- /**
215
- * This method sets the value for in_bytes field of either ALTS server_start or
216
- * next handshake request.
217
- *
218
- * - req: an ALTS handshake request.
219
- * - in_bytes: a buffer containing bytes taken from out_frames of the peer's
220
- * ALTS handshake response. It is possible that the peer's out_frames are
221
- * split into multiple handshake request messages.
222
- * - size: size of in_bytes buffer.
223
- *
224
- * The method returns true on success and false otherwise.
225
- */
226
- bool grpc_gcp_handshaker_req_set_in_bytes(grpc_gcp_handshaker_req* req,
227
- const char* in_bytes, size_t size);
228
-
229
- /**
230
- * This method adds a record protocol to handshake parameters mapped by the
231
- * handshake protocol for ALTS server_start handshake request.
232
- *
233
- * - req: an ALTS handshake request.
234
- * - key: an enum type value representing a handshake security protocol.
235
- * - record_protocol: a record protocol to be added.
236
- *
237
- * The method returns true on success and false otherwise.
238
- */
239
- bool grpc_gcp_handshaker_req_param_add_record_protocol(
240
- grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key,
241
- const char* record_protocol);
242
-
243
- /**
244
- * This method adds a local identity represented as hostname to handshake
245
- * parameters mapped by the handshake protocol for ALTS server_start handshake
246
- * request.
247
- *
248
- * - req: an ALTS handshake request.
249
- * - key: an enum type value representing a handshake security protocol.
250
- * - hostname: a string representation of hostname to be added.
251
- *
252
- * The method returns true on success and false otherwise.
253
- */
254
- bool grpc_gcp_handshaker_req_param_add_local_identity_hostname(
255
- grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key,
256
- const char* hostname);
257
-
258
- /**
259
- * This method adds a local identity represented as service account to handshake
260
- * parameters mapped by the handshake protocol for ALTS server_start handshake
261
- * request.
262
- *
263
- * - req: an ALTS handshake request.
264
- * - key: an enum type value representing a handshake security protocol.
265
- * - service_account: a string representation of service account to be added.
266
- *
267
- * The method returns true on success and false otherwise.
268
- */
269
- bool grpc_gcp_handshaker_req_param_add_local_identity_service_account(
270
- grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key,
271
- const char* service_account);
272
-
273
- /**
274
- * This method sets the value for rpc_versions field of either ALTS
275
- * client_start or server_start handshake request.
276
- *
277
- * - req: an ALTS handshake request.
278
- * - max_major: a major version of maximum supported RPC version.
279
- * - max_minor: a minor version of maximum supported RPC version.
280
- * - min_major: a major version of minimum supported RPC version.
281
- * - min_minor: a minor version of minimum supported RPC version.
282
- *
283
- * The method returns true on success and false otherwise.
284
- */
285
- bool grpc_gcp_handshaker_req_set_rpc_versions(grpc_gcp_handshaker_req* req,
286
- uint32_t max_major,
287
- uint32_t max_minor,
288
- uint32_t min_major,
289
- uint32_t min_minor);
290
-
291
- /**
292
- * This method serializes an ALTS handshake request and returns a data stream.
293
- *
294
- * - req: an ALTS handshake request.
295
- * - slice: a data stream where the serialized result will be written.
296
- *
297
- * The method returns true on success and false otherwise.
298
- */
299
- bool grpc_gcp_handshaker_req_encode(grpc_gcp_handshaker_req* req,
300
- grpc_slice* slice);
301
-
302
- /* This method destroys an ALTS handshake request. */
303
- void grpc_gcp_handshaker_req_destroy(grpc_gcp_handshaker_req* req);
304
-
305
- /* This method creates an ALTS handshake response. */
306
- grpc_gcp_handshaker_resp* grpc_gcp_handshaker_resp_create(void);
307
-
308
- /**
309
- * This method de-serializes a data stream and stores the result
310
- * in an ALTS handshake response.
311
- *
312
- * - slice: a data stream containing a serialized ALTS handshake response.
313
- * - resp: an ALTS handshake response used to hold de-serialized result.
314
- *
315
- * The method returns true on success and false otherwise.
316
- */
317
- bool grpc_gcp_handshaker_resp_decode(grpc_slice slice,
318
- grpc_gcp_handshaker_resp* resp);
319
-
320
- /* This method destroys an ALTS handshake response. */
321
- void grpc_gcp_handshaker_resp_destroy(grpc_gcp_handshaker_resp* resp);
322
-
323
- #endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H */
@@ -1,145 +0,0 @@
1
- /*
2
- *
3
- * Copyright 2018 gRPC authors.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
18
-
19
- #include <grpc/support/port_platform.h>
20
-
21
- #include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h"
22
-
23
- #include "src/core/lib/slice/slice_internal.h"
24
-
25
- void add_repeated_field(repeated_field** head, const void* data) {
26
- repeated_field* field =
27
- static_cast<repeated_field*>(gpr_zalloc(sizeof(*field)));
28
- field->data = data;
29
- if (*head == nullptr) {
30
- *head = field;
31
- (*head)->next = nullptr;
32
- } else {
33
- field->next = *head;
34
- *head = field;
35
- }
36
- }
37
-
38
- void destroy_repeated_field_list_identity(repeated_field* head) {
39
- repeated_field* field = head;
40
- while (field != nullptr) {
41
- repeated_field* next_field = field->next;
42
- const grpc_gcp_identity* identity =
43
- static_cast<const grpc_gcp_identity*>(field->data);
44
- destroy_slice(static_cast<grpc_slice*>(identity->hostname.arg));
45
- destroy_slice(static_cast<grpc_slice*>(identity->service_account.arg));
46
- gpr_free((void*)identity);
47
- gpr_free(field);
48
- field = next_field;
49
- }
50
- }
51
-
52
- void destroy_repeated_field_list_string(repeated_field* head) {
53
- repeated_field* field = head;
54
- while (field != nullptr) {
55
- repeated_field* next_field = field->next;
56
- destroy_slice((grpc_slice*)field->data);
57
- gpr_free(field);
58
- field = next_field;
59
- }
60
- }
61
-
62
- grpc_slice* create_slice(const char* data, size_t size) {
63
- grpc_slice slice = grpc_slice_from_copied_buffer(data, size);
64
- grpc_slice* cb_slice =
65
- static_cast<grpc_slice*>(gpr_zalloc(sizeof(*cb_slice)));
66
- memcpy(cb_slice, &slice, sizeof(*cb_slice));
67
- return cb_slice;
68
- }
69
-
70
- void destroy_slice(grpc_slice* slice) {
71
- if (slice != nullptr) {
72
- grpc_slice_unref_internal(*slice);
73
- gpr_free(slice);
74
- }
75
- }
76
-
77
- bool encode_string_or_bytes_cb(pb_ostream_t* stream, const pb_field_t* field,
78
- void* const* arg) {
79
- grpc_slice* slice = static_cast<grpc_slice*>(*arg);
80
- if (!pb_encode_tag_for_field(stream, field)) return false;
81
- return pb_encode_string(stream, GRPC_SLICE_START_PTR(*slice),
82
- GRPC_SLICE_LENGTH(*slice));
83
- }
84
-
85
- bool encode_repeated_identity_cb(pb_ostream_t* stream, const pb_field_t* field,
86
- void* const* arg) {
87
- repeated_field* var = static_cast<repeated_field*>(*arg);
88
- while (var != nullptr) {
89
- if (!pb_encode_tag_for_field(stream, field)) return false;
90
- if (!pb_encode_submessage(stream, grpc_gcp_Identity_fields,
91
- (grpc_gcp_identity*)var->data))
92
- return false;
93
- var = var->next;
94
- }
95
- return true;
96
- }
97
-
98
- bool encode_repeated_string_cb(pb_ostream_t* stream, const pb_field_t* field,
99
- void* const* arg) {
100
- repeated_field* var = static_cast<repeated_field*>(*arg);
101
- while (var != nullptr) {
102
- if (!pb_encode_tag_for_field(stream, field)) return false;
103
- const grpc_slice* slice = static_cast<const grpc_slice*>(var->data);
104
- if (!pb_encode_string(stream, GRPC_SLICE_START_PTR(*slice),
105
- GRPC_SLICE_LENGTH(*slice)))
106
- return false;
107
- var = var->next;
108
- }
109
- return true;
110
- }
111
-
112
- bool decode_string_or_bytes_cb(pb_istream_t* stream, const pb_field_t* field,
113
- void** arg) {
114
- grpc_slice slice = grpc_slice_malloc(stream->bytes_left);
115
- grpc_slice* cb_slice =
116
- static_cast<grpc_slice*>(gpr_zalloc(sizeof(*cb_slice)));
117
- memcpy(cb_slice, &slice, sizeof(*cb_slice));
118
- if (!pb_read(stream, GRPC_SLICE_START_PTR(*cb_slice), stream->bytes_left))
119
- return false;
120
- *arg = cb_slice;
121
- return true;
122
- }
123
-
124
- bool decode_repeated_identity_cb(pb_istream_t* stream, const pb_field_t* field,
125
- void** arg) {
126
- grpc_gcp_identity* identity =
127
- static_cast<grpc_gcp_identity*>(gpr_zalloc(sizeof(*identity)));
128
- identity->hostname.funcs.decode = decode_string_or_bytes_cb;
129
- identity->service_account.funcs.decode = decode_string_or_bytes_cb;
130
- add_repeated_field(reinterpret_cast<repeated_field**>(arg), identity);
131
- if (!pb_decode(stream, grpc_gcp_Identity_fields, identity)) return false;
132
- return true;
133
- }
134
-
135
- bool decode_repeated_string_cb(pb_istream_t* stream, const pb_field_t* field,
136
- void** arg) {
137
- grpc_slice slice = grpc_slice_malloc(stream->bytes_left);
138
- grpc_slice* cb_slice =
139
- static_cast<grpc_slice*>(gpr_zalloc(sizeof(*cb_slice)));
140
- memcpy(cb_slice, &slice, sizeof(grpc_slice));
141
- if (!pb_read(stream, GRPC_SLICE_START_PTR(*cb_slice), stream->bytes_left))
142
- return false;
143
- add_repeated_field(reinterpret_cast<repeated_field**>(arg), cb_slice);
144
- return true;
145
- }