alts_handshaker_service_api_test_lib.cc
Go to the documentation of this file.
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 
20 
23  uint32_t max_minor, uint32_t min_major, uint32_t min_minor) {
24  if (resp == nullptr) {
26  "Invalid nullptr argument to "
27  "grpc_gcp_handshaker_resp_set_peer_rpc_versions().");
28  return false;
29  }
31  versions.max_rpc_version.major = max_major;
32  versions.max_rpc_version.minor = max_minor;
33  versions.min_rpc_version.major = min_major;
34  versions.min_rpc_version.minor = min_minor;
37  grpc_gcp_RpcProtocolVersions* upb_versions =
40  &versions);
41  return true;
42 }
43 
45  upb_Arena* arena) {
46  size_t buf_size = GPR_SLICE_LENGTH(slice);
47  void* buf = upb_Arena_Malloc(arena, buf_size);
48  memcpy(buf, reinterpret_cast<const char*>(GPR_SLICE_START_PTR(slice)),
49  buf_size);
51  reinterpret_cast<char*>(buf), buf_size, arena);
52  if (!resp) {
53  gpr_log(GPR_ERROR, "grpc_gcp_HandshakerReq decode error");
54  return nullptr;
55  }
56  return resp;
57 }
58 
59 /* Check equality of a pair of grpc_gcp_identity fields. */
61  const grpc_gcp_Identity* r_id) {
66  return false;
67  }
68 
72  return false;
73  }
74  } else if (grpc_gcp_Identity_has_hostname(l_id)) {
77  return false;
78  }
79  }
80  return true;
81 }
82 
84  const grpc_gcp_RpcProtocolVersions* l_version,
85  const grpc_gcp_RpcProtocolVersions* r_version) {
86  const grpc_gcp_RpcProtocolVersions_Version* l_maxver =
88  const grpc_gcp_RpcProtocolVersions_Version* r_maxver =
90  const grpc_gcp_RpcProtocolVersions_Version* l_minver =
92  const grpc_gcp_RpcProtocolVersions_Version* r_minver =
102 }
103 
104 /* Check equality of a pair of ALTS handshake responses. */
106  const grpc_gcp_HandshakerResp* r_resp) {
117 }
118 
119 /* This method checks equality of two handshaker response results. */
121  const grpc_gcp_HandshakerResult* l_result,
122  const grpc_gcp_HandshakerResult* r_result) {
123  if (l_result == nullptr && r_result == nullptr) {
124  return true;
125  } else if ((l_result != nullptr && r_result == nullptr) ||
126  (l_result == nullptr && r_result != nullptr)) {
127  return false;
128  }
129  return upb_StringView_IsEqual(
148 }
149 
150 /* This method checks equality of two handshaker response statuses. */
152  const grpc_gcp_HandshakerStatus* l_status,
153  const grpc_gcp_HandshakerStatus* r_status) {
154  if (l_status == nullptr && r_status == nullptr) {
155  return true;
156  } else if ((l_status != nullptr && r_status == nullptr) ||
157  (l_status == nullptr && r_status != nullptr)) {
158  return false;
159  }
160  return (grpc_gcp_HandshakerStatus_code(l_status) ==
161  grpc_gcp_HandshakerStatus_code(r_status)) &&
164 }
grpc_gcp_HandshakerResp_result
const UPB_INLINE grpc_gcp_HandshakerResult * grpc_gcp_HandshakerResp_result(const grpc_gcp_HandshakerResp *msg)
Definition: handshaker.upb.h:1079
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
grpc_gcp_Identity_service_account
UPB_INLINE upb_StringView grpc_gcp_Identity_service_account(const grpc_gcp_Identity *msg)
Definition: handshaker.upb.h:181
grpc_gcp_HandshakerStatus
struct grpc_gcp_HandshakerStatus grpc_gcp_HandshakerStatus
Definition: handshaker.upb.h:45
handshaker_rpc_versions_equals
static bool handshaker_rpc_versions_equals(const grpc_gcp_RpcProtocolVersions *l_version, const grpc_gcp_RpcProtocolVersions *r_version)
Definition: alts_handshaker_service_api_test_lib.cc:83
grpc_gcp_RpcProtocolVersions_Version
struct grpc_gcp_RpcProtocolVersions_Version grpc_gcp_RpcProtocolVersions_Version
Definition: transport_security_common.upb.h:26
grpc_gcp_HandshakerResult_key_data
UPB_INLINE upb_StringView grpc_gcp_HandshakerResult_key_data(const grpc_gcp_HandshakerResult *msg)
Definition: handshaker.upb.h:881
grpc_gcp_Identity_hostname
UPB_INLINE upb_StringView grpc_gcp_Identity_hostname(const grpc_gcp_Identity *msg)
Definition: handshaker.upb.h:190
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
grpc_gcp_RpcProtocolVersions_assign_from_struct
void grpc_gcp_RpcProtocolVersions_assign_from_struct(grpc_gcp_RpcProtocolVersions *versions, upb_Arena *arena, const grpc_gcp_rpc_protocol_versions *value)
Definition: transport_security_common_api.cc:137
grpc_gcp_HandshakerResult_record_protocol
UPB_INLINE upb_StringView grpc_gcp_HandshakerResult_record_protocol(const grpc_gcp_HandshakerResult *msg)
Definition: handshaker.upb.h:875
grpc_gcp_handshaker_req_decode
grpc_gcp_HandshakerReq * grpc_gcp_handshaker_req_decode(grpc_slice slice, upb_Arena *arena)
Definition: alts_handshaker_service_api_test_lib.cc:44
grpc_gcp_HandshakerResult_peer_identity
const UPB_INLINE grpc_gcp_Identity * grpc_gcp_HandshakerResult_peer_identity(const grpc_gcp_HandshakerResult *msg)
Definition: handshaker.upb.h:890
grpc_gcp_HandshakerReq_parse
UPB_INLINE grpc_gcp_HandshakerReq * grpc_gcp_HandshakerReq_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: handshaker.upb.h:735
grpc_gcp_HandshakerResult_mutable_peer_rpc_versions
UPB_INLINE struct grpc_gcp_RpcProtocolVersions * grpc_gcp_HandshakerResult_mutable_peer_rpc_versions(grpc_gcp_HandshakerResult *msg, upb_Arena *arena)
Definition: handshaker.upb.h:966
grpc_gcp_HandshakerResult_application_protocol
UPB_INLINE upb_StringView grpc_gcp_HandshakerResult_application_protocol(const grpc_gcp_HandshakerResult *msg)
Definition: handshaker.upb.h:869
grpc_gcp_HandshakerResp_bytes_consumed
UPB_INLINE uint32_t grpc_gcp_HandshakerResp_bytes_consumed(const grpc_gcp_HandshakerResp *msg)
Definition: handshaker.upb.h:1070
_grpc_gcp_RpcProtocolVersions::max_rpc_version
grpc_gcp_rpc_protocol_versions_version max_rpc_version
Definition: transport_security_common_api.h:39
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
grpc_gcp_HandshakerReq
struct grpc_gcp_HandshakerReq grpc_gcp_HandshakerReq
Definition: handshaker.upb.h:43
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
grpc_gcp_Identity_has_service_account
UPB_INLINE bool grpc_gcp_Identity_has_service_account(const grpc_gcp_Identity *msg)
Definition: handshaker.upb.h:175
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
grpc_gcp_RpcProtocolVersions_max_rpc_version
const UPB_INLINE grpc_gcp_RpcProtocolVersions_Version * grpc_gcp_RpcProtocolVersions_max_rpc_version(const grpc_gcp_RpcProtocolVersions *msg)
Definition: transport_security_common.upb.h:75
grpc_gcp_HandshakerResult_keep_channel_open
UPB_INLINE bool grpc_gcp_HandshakerResult_keep_channel_open(const grpc_gcp_HandshakerResult *msg)
Definition: handshaker.upb.h:905
grpc_gcp_HandshakerResp
struct grpc_gcp_HandshakerResp grpc_gcp_HandshakerResp
Definition: handshaker.upb.h:46
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
grpc_gcp_RpcProtocolVersions_Version_major
UPB_INLINE uint32_t grpc_gcp_RpcProtocolVersions_Version_major(const grpc_gcp_RpcProtocolVersions_Version *msg)
Definition: transport_security_common.upb.h:149
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_gcp_RpcProtocolVersions_Version_minor
UPB_INLINE uint32_t grpc_gcp_RpcProtocolVersions_Version_minor(const grpc_gcp_RpcProtocolVersions_Version *msg)
Definition: transport_security_common.upb.h:155
http2_server_health_check.resp
resp
Definition: http2_server_health_check.py:31
upb_Arena_Malloc
UPB_INLINE void * upb_Arena_Malloc(upb_Arena *a, size_t size)
Definition: upb/upb/upb.h:222
grpc_gcp_handshaker_resp_set_peer_rpc_versions
bool grpc_gcp_handshaker_resp_set_peer_rpc_versions(grpc_gcp_HandshakerResp *resp, upb_Arena *arena, uint32_t max_major, uint32_t max_minor, uint32_t min_major, uint32_t min_minor)
Definition: alts_handshaker_service_api_test_lib.cc:21
handshaker_identity_equals
static bool handshaker_identity_equals(const grpc_gcp_Identity *l_id, const grpc_gcp_Identity *r_id)
Definition: alts_handshaker_service_api_test_lib.cc:60
grpc_gcp_HandshakerResult_peer_rpc_versions
UPB_INLINE const struct grpc_gcp_RpcProtocolVersions * grpc_gcp_HandshakerResult_peer_rpc_versions(const grpc_gcp_HandshakerResult *msg)
Definition: handshaker.upb.h:914
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
grpc_gcp_HandshakerStatus_details
UPB_INLINE upb_StringView grpc_gcp_HandshakerStatus_details(const grpc_gcp_HandshakerStatus *msg)
Definition: handshaker.upb.h:1019
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
upb_StringView_IsEqual
UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b)
Definition: upb/upb/upb.h:89
grpc_gcp_RpcProtocolVersions
struct grpc_gcp_RpcProtocolVersions grpc_gcp_RpcProtocolVersions
Definition: transport_security_common.upb.h:25
_grpc_gcp_RpcProtocolVersions_Version::major
uint32_t major
Definition: transport_security_common_api.h:33
_grpc_gcp_RpcProtocolVersions::min_rpc_version
grpc_gcp_rpc_protocol_versions_version min_rpc_version
Definition: transport_security_common_api.h:40
grpc_gcp_HandshakerResp_out_frames
UPB_INLINE upb_StringView grpc_gcp_HandshakerResp_out_frames(const grpc_gcp_HandshakerResp *msg)
Definition: handshaker.upb.h:1064
grpc_gcp_handshaker_resp_status_equals
bool grpc_gcp_handshaker_resp_status_equals(const grpc_gcp_HandshakerStatus *l_status, const grpc_gcp_HandshakerStatus *r_status)
Definition: alts_handshaker_service_api_test_lib.cc:151
_grpc_gcp_RpcProtocolVersions_Version::minor
uint32_t minor
Definition: transport_security_common_api.h:34
grpc_gcp_Identity
struct grpc_gcp_Identity grpc_gcp_Identity
Definition: handshaker.upb.h:36
grpc_gcp_handshaker_resp_equals
bool grpc_gcp_handshaker_resp_equals(const grpc_gcp_HandshakerResp *l_resp, const grpc_gcp_HandshakerResp *r_resp)
Definition: alts_handshaker_service_api_test_lib.cc:105
grpc_gcp_HandshakerResult
struct grpc_gcp_HandshakerResult grpc_gcp_HandshakerResult
Definition: handshaker.upb.h:44
alts_handshaker_service_api_test_lib.h
grpc_gcp_handshaker_resp_result_equals
bool grpc_gcp_handshaker_resp_result_equals(const grpc_gcp_HandshakerResult *l_result, const grpc_gcp_HandshakerResult *r_result)
Definition: alts_handshaker_service_api_test_lib.cc:120
grpc_gcp_HandshakerResp_mutable_result
UPB_INLINE struct grpc_gcp_HandshakerResult * grpc_gcp_HandshakerResp_mutable_result(grpc_gcp_HandshakerResp *msg, upb_Arena *arena)
Definition: handshaker.upb.h:1102
grpc_gcp_HandshakerResult_local_identity
const UPB_INLINE grpc_gcp_Identity * grpc_gcp_HandshakerResult_local_identity(const grpc_gcp_HandshakerResult *msg)
Definition: handshaker.upb.h:899
_grpc_gcp_RpcProtocolVersions
Definition: transport_security_common_api.h:38
grpc_gcp_HandshakerResp_status
const UPB_INLINE grpc_gcp_HandshakerStatus * grpc_gcp_HandshakerResp_status(const grpc_gcp_HandshakerResp *msg)
Definition: handshaker.upb.h:1088
grpc_gcp_HandshakerStatus_code
UPB_INLINE uint32_t grpc_gcp_HandshakerStatus_code(const grpc_gcp_HandshakerStatus *msg)
Definition: handshaker.upb.h:1013
grpc_gcp_Identity_has_hostname
UPB_INLINE bool grpc_gcp_Identity_has_hostname(const grpc_gcp_Identity *msg)
Definition: handshaker.upb.h:184
upb_Arena
Definition: upb_internal.h:36
grpc_gcp_RpcProtocolVersions_min_rpc_version
const UPB_INLINE grpc_gcp_RpcProtocolVersions_Version * grpc_gcp_RpcProtocolVersions_min_rpc_version(const grpc_gcp_RpcProtocolVersions *msg)
Definition: transport_security_common.upb.h:84


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:41