alts_tsi_utils.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 
22 
24 
26 
28  switch (code) {
29  case GRPC_STATUS_OK:
30  return TSI_OK;
32  return TSI_UNKNOWN_ERROR;
34  return TSI_INVALID_ARGUMENT;
36  return TSI_NOT_FOUND;
38  return TSI_INTERNAL_ERROR;
39  default:
40  return TSI_UNKNOWN_ERROR;
41  }
42 }
43 
45  grpc_byte_buffer* resp_buffer, upb_Arena* arena) {
46  GPR_ASSERT(resp_buffer != nullptr);
47  GPR_ASSERT(arena != nullptr);
49  grpc_byte_buffer_reader_init(&bbr, resp_buffer);
51  size_t buf_size = GPR_SLICE_LENGTH(slice);
52  void* buf = upb_Arena_Malloc(arena, buf_size);
53  memcpy(buf, reinterpret_cast<const char*>(GPR_SLICE_START_PTR(slice)),
54  buf_size);
56  reinterpret_cast<char*>(buf), buf_size, arena);
59  if (resp == nullptr) {
60  gpr_log(GPR_ERROR, "grpc_gcp_handshaker_resp_decode() failed");
61  return nullptr;
62  }
63  return resp;
64 }
TSI_INTERNAL_ERROR
@ TSI_INTERNAL_ERROR
Definition: transport_security_interface.h:39
grpc_byte_buffer_reader_readall
GRPCAPI grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader)
Definition: byte_buffer_reader.cc:84
grpc_gcp_HandshakerResp_parse
UPB_INLINE grpc_gcp_HandshakerResp * grpc_gcp_HandshakerResp_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: handshaker.upb.h:1035
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
grpc_status_code
grpc_status_code
Definition: include/grpc/impl/codegen/status.h:28
GRPC_STATUS_NOT_FOUND
@ GRPC_STATUS_NOT_FOUND
Definition: include/grpc/impl/codegen/status.h:56
GRPC_STATUS_INVALID_ARGUMENT
@ GRPC_STATUS_INVALID_ARGUMENT
Definition: include/grpc/impl/codegen/status.h:46
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
TSI_UNKNOWN_ERROR
@ TSI_UNKNOWN_ERROR
Definition: transport_security_interface.h:33
byte_buffer_reader.h
TSI_OK
@ TSI_OK
Definition: transport_security_interface.h:32
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
GRPC_STATUS_OK
@ GRPC_STATUS_OK
Definition: include/grpc/impl/codegen/status.h:30
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
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
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
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_byte_buffer_reader_init
GRPCAPI int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer)
Definition: byte_buffer_reader.cc:33
grpc_byte_buffer
Definition: grpc_types.h:43
tsi_result
tsi_result
Definition: transport_security_interface.h:31
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
alts_tsi_utils_deserialize_response
grpc_gcp_HandshakerResp * alts_tsi_utils_deserialize_response(grpc_byte_buffer *resp_buffer, upb_Arena *arena)
Definition: alts_tsi_utils.cc:44
slice_internal.h
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
alts_tsi_utils.h
TSI_INVALID_ARGUMENT
@ TSI_INVALID_ARGUMENT
Definition: transport_security_interface.h:34
alts_tsi_utils_convert_to_tsi_result
tsi_result alts_tsi_utils_convert_to_tsi_result(grpc_status_code code)
Definition: alts_tsi_utils.cc:27
GRPC_STATUS_INTERNAL
@ GRPC_STATUS_INTERNAL
Definition: include/grpc/impl/codegen/status.h:129
code
Definition: bloaty/third_party/zlib/contrib/infback9/inftree9.h:24
grpc_byte_buffer_reader
Definition: impl/codegen/byte_buffer_reader.h:30
upb_Arena
Definition: upb_internal.h:36
grpc_byte_buffer_reader_destroy
GRPCAPI void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader)
Definition: byte_buffer_reader.cc:45
GRPC_STATUS_UNKNOWN
@ GRPC_STATUS_UNKNOWN
Definition: include/grpc/impl/codegen/status.h:40
grpc_slice_unref_internal
void grpc_slice_unref_internal(const grpc_slice &slice)
Definition: slice_refcount.h:39
TSI_NOT_FOUND
@ TSI_NOT_FOUND
Definition: transport_security_interface.h:41
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:30