Classes | Namespaces | Macros | Typedefs | Functions | Variables
alts_handshaker_client.cc File Reference
#include <grpc/support/port_platform.h>
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
#include <list>
#include "upb/upb.hpp"
#include <grpc/byte_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/tsi/alts/handshaker/alts_shared_resource.h"
#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h"
#include "src/core/tsi/alts/handshaker/alts_tsi_utils.h"
Include dependency graph for alts_handshaker_client.cc:

Go to the source code of this file.

Classes

struct  alts_grpc_handshaker_client
 
struct  alts_handshaker_client
 
struct  recv_message_result
 

Namespaces

 grpc_core
 
 grpc_core::internal
 

Macros

#define TSI_ALTS_INITIAL_BUFFER_SIZE   256
 

Typedefs

typedef struct alts_grpc_handshaker_client alts_grpc_handshaker_client
 

Functions

alts_handshaker_clientalts_grpc_handshaker_client_create (alts_tsi_handshaker *handshaker, grpc_channel *channel, const char *handshaker_service_url, grpc_pollset_set *interested_parties, grpc_alts_credentials_options *options, const grpc_slice &target_name, grpc_iomgr_cb_func grpc_cb, tsi_handshaker_on_next_done_cb cb, void *user_data, alts_handshaker_client_vtable *vtable_for_testing, bool is_client, size_t max_frame_size)
 
static void alts_grpc_handshaker_client_unref (alts_grpc_handshaker_client *client)
 
void grpc_core::internal::alts_handshaker_client_check_fields_for_testing (alts_handshaker_client *c, tsi_handshaker_on_next_done_cb cb, void *user_data, bool has_sent_start_message, grpc_slice *recv_bytes)
 
void alts_handshaker_client_destroy (alts_handshaker_client *c)
 
grpc_closuregrpc_core::internal::alts_handshaker_client_get_closure_for_testing (alts_handshaker_client *c)
 
alts_tsi_handshakergrpc_core::internal::alts_handshaker_client_get_handshaker_for_testing (alts_handshaker_client *c)
 
grpc_metadata_arraygrpc_core::internal::alts_handshaker_client_get_initial_metadata_for_testing (alts_handshaker_client *c)
 
grpc_byte_buffer ** grpc_core::internal::alts_handshaker_client_get_recv_buffer_addr_for_testing (alts_handshaker_client *c)
 
grpc_byte_buffergrpc_core::internal::alts_handshaker_client_get_send_buffer_for_testing (alts_handshaker_client *c)
 
void alts_handshaker_client_handle_response (alts_handshaker_client *c, bool is_ok)
 
tsi_result alts_handshaker_client_next (alts_handshaker_client *client, grpc_slice *bytes_received)
 
void grpc_core::internal::alts_handshaker_client_on_status_received_for_testing (alts_handshaker_client *c, grpc_status_code status, grpc_error_handle error)
 
void grpc_core::internal::alts_handshaker_client_ref_for_testing (alts_handshaker_client *c)
 
void grpc_core::internal::alts_handshaker_client_set_cb_for_testing (alts_handshaker_client *c, tsi_handshaker_on_next_done_cb cb)
 
void grpc_core::internal::alts_handshaker_client_set_fields_for_testing (alts_handshaker_client *c, alts_tsi_handshaker *handshaker, tsi_handshaker_on_next_done_cb cb, void *user_data, grpc_byte_buffer *recv_buffer, grpc_status_code status)
 
void grpc_core::internal::alts_handshaker_client_set_grpc_caller_for_testing (alts_handshaker_client *c, alts_grpc_caller caller)
 
void grpc_core::internal::alts_handshaker_client_set_recv_bytes_for_testing (alts_handshaker_client *c, grpc_slice *recv_bytes)
 
void grpc_core::internal::alts_handshaker_client_set_vtable_for_testing (alts_handshaker_client *c, alts_handshaker_client_vtable *vtable)
 
void alts_handshaker_client_shutdown (alts_handshaker_client *client)
 
tsi_result alts_handshaker_client_start_client (alts_handshaker_client *client)
 
tsi_result alts_handshaker_client_start_server (alts_handshaker_client *client, grpc_slice *bytes_received)
 
static tsi_result continue_make_grpc_call (alts_grpc_handshaker_client *client, bool is_start)
 
static grpc_byte_bufferget_serialized_handshaker_req (grpc_gcp_HandshakerReq *req, upb_Arena *arena)
 
static grpc_byte_bufferget_serialized_next (grpc_slice *bytes_received)
 
static grpc_byte_bufferget_serialized_start_client (alts_handshaker_client *c)
 
static grpc_byte_bufferget_serialized_start_server (alts_handshaker_client *c, grpc_slice *bytes_received)
 
static void handle_response_done (alts_grpc_handshaker_client *client, tsi_result status, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *result)
 
static void handshaker_call_unref (void *arg, grpc_error_handle)
 
static void handshaker_client_destruct (alts_handshaker_client *c)
 
static tsi_result handshaker_client_next (alts_handshaker_client *c, grpc_slice *bytes_received)
 
static void handshaker_client_send_buffer_destroy (alts_grpc_handshaker_client *client)
 
static void handshaker_client_shutdown (alts_handshaker_client *c)
 
static tsi_result handshaker_client_start_client (alts_handshaker_client *c)
 
static tsi_result handshaker_client_start_server (alts_handshaker_client *c, grpc_slice *bytes_received)
 
static bool is_handshake_finished_properly (grpc_gcp_HandshakerResp *resp)
 
static tsi_result make_grpc_call (alts_handshaker_client *c, bool is_start)
 
static void maybe_complete_tsi_next (alts_grpc_handshaker_client *client, bool receive_status_finished, recv_message_result *pending_recv_message_result)
 
static void on_status_received (void *arg, grpc_error_handle error)
 

Variables

const int kHandshakerClientOpNum = 4
 
static const alts_handshaker_client_vtable vtable
 

Macro Definition Documentation

◆ TSI_ALTS_INITIAL_BUFFER_SIZE

#define TSI_ALTS_INITIAL_BUFFER_SIZE   256

Definition at line 39 of file alts_handshaker_client.cc.

Typedef Documentation

◆ alts_grpc_handshaker_client

Function Documentation

◆ alts_grpc_handshaker_client_create()

alts_handshaker_client* alts_grpc_handshaker_client_create ( alts_tsi_handshaker handshaker,
grpc_channel channel,
const char *  handshaker_service_url,
grpc_pollset_set interested_parties,
grpc_alts_credentials_options options,
const grpc_slice target_name,
grpc_iomgr_cb_func  grpc_cb,
tsi_handshaker_on_next_done_cb  cb,
void *  user_data,
alts_handshaker_client_vtable vtable_for_testing,
bool  is_client,
size_t  max_frame_size 
)

This method creates an ALTS handshaker client.

  • handshaker: ALTS TSI handshaker to which the created handshaker client belongs to.
  • channel: grpc channel to ALTS handshaker service.
  • handshaker_service_url: address of ALTS handshaker service in the format of "host:port".
  • interested_parties: set of pollsets interested in this connection.
  • options: ALTS credentials options containing information passed from TSI caller (e.g., rpc protocol versions)
  • target_name: the name of the endpoint that the channel is connecting to, and will be used for secure naming check
  • grpc_cb: gRPC provided callbacks passed from TSI handshaker.
  • cb: callback to be executed when tsi_handshaker_next API compltes.
  • user_data: argument passed to cb.
  • vtable_for_testing: ALTS handshaker client vtable instance used for testing purpose.
  • is_client: a boolean value indicating if the created handshaker client is used at the client (is_client = true) or server (is_client = false) side.
  • max_frame_size: Maximum frame size used by frame protector (User specified maximum frame size if present or default max frame size).

It returns the created ALTS handshaker client on success, and NULL on failure.

Definition at line 687 of file alts_handshaker_client.cc.

◆ alts_grpc_handshaker_client_unref()

static void alts_grpc_handshaker_client_unref ( alts_grpc_handshaker_client client)
static

Definition at line 123 of file alts_handshaker_client.cc.

◆ alts_handshaker_client_destroy()

void alts_handshaker_client_destroy ( alts_handshaker_client client)

This method destroys an ALTS handshaker client.

  • client: an ALTS handshaker client instance.

Definition at line 902 of file alts_handshaker_client.cc.

◆ alts_handshaker_client_handle_response()

void alts_handshaker_client_handle_response ( alts_handshaker_client client,
bool  is_ok 
)

This method handles handshaker response returned from ALTS handshaker service. Note that the only reason the API is exposed is that it is used in alts_shared_resources.cc.

  • client: an ALTS handshaker client instance.
  • is_ok: a boolean value indicating if the handshaker response is ok to read.

Definition at line 190 of file alts_handshaker_client.cc.

◆ alts_handshaker_client_next()

tsi_result alts_handshaker_client_next ( alts_handshaker_client client,
grpc_slice bytes_received 
)

This method schedules a next handshaker request to ALTS handshaker service.

  • client: ALTS handshaker client instance.
  • bytes_received: bytes in out_frames returned from the peer's handshaker response.

It returns TSI_OK on success and an error status code on failure.

Definition at line 884 of file alts_handshaker_client.cc.

◆ alts_handshaker_client_shutdown()

void alts_handshaker_client_shutdown ( alts_handshaker_client client)

This method cancels previously scheduled, but yet executed handshaker requests to ALTS handshaker service. After this operation, the handshake will be shutdown, and no more handshaker requests will get scheduled.

  • client: ALTS handshaker client instance.

Definition at line 895 of file alts_handshaker_client.cc.

◆ alts_handshaker_client_start_client()

tsi_result alts_handshaker_client_start_client ( alts_handshaker_client client)

This method schedules a client_start handshaker request to ALTS handshaker service.

  • client: ALTS handshaker client instance.

It returns TSI_OK on success and an error status code on failure.

Definition at line 863 of file alts_handshaker_client.cc.

◆ alts_handshaker_client_start_server()

tsi_result alts_handshaker_client_start_server ( alts_handshaker_client client,
grpc_slice bytes_received 
)

This method schedules a server_start handshaker request to ALTS handshaker service.

  • client: ALTS handshaker client instance.
  • bytes_received: bytes in out_frames returned from the peer's handshaker response.

It returns TSI_OK on success and an error status code on failure.

Definition at line 873 of file alts_handshaker_client.cc.

◆ continue_make_grpc_call()

static tsi_result continue_make_grpc_call ( alts_grpc_handshaker_client client,
bool  is_start 
)
static

Definition at line 291 of file alts_handshaker_client.cc.

◆ get_serialized_handshaker_req()

static grpc_byte_buffer* get_serialized_handshaker_req ( grpc_gcp_HandshakerReq req,
upb_Arena arena 
)
static

Definition at line 464 of file alts_handshaker_client.cc.

◆ get_serialized_next()

static grpc_byte_buffer* get_serialized_next ( grpc_slice bytes_received)
static

Definition at line 602 of file alts_handshaker_client.cc.

◆ get_serialized_start_client()

static grpc_byte_buffer* get_serialized_start_client ( alts_handshaker_client c)
static

Definition at line 478 of file alts_handshaker_client.cc.

◆ get_serialized_start_server()

static grpc_byte_buffer* get_serialized_start_server ( alts_handshaker_client c,
grpc_slice bytes_received 
)
static

Definition at line 543 of file alts_handshaker_client.cc.

◆ handle_response_done()

static void handle_response_done ( alts_grpc_handshaker_client client,
tsi_result  status,
const unsigned char *  bytes_to_send,
size_t  bytes_to_send_size,
tsi_handshaker_result result 
)
static

Definition at line 176 of file alts_handshaker_client.cc.

◆ handshaker_call_unref()

static void handshaker_call_unref ( void *  arg,
grpc_error_handle   
)
static

Definition at line 649 of file alts_handshaker_client.cc.

◆ handshaker_client_destruct()

static void handshaker_client_destruct ( alts_handshaker_client c)
static

Definition at line 654 of file alts_handshaker_client.cc.

◆ handshaker_client_next()

static tsi_result handshaker_client_next ( alts_handshaker_client c,
grpc_slice bytes_received 
)
static

Definition at line 616 of file alts_handshaker_client.cc.

◆ handshaker_client_send_buffer_destroy()

static void handshaker_client_send_buffer_destroy ( alts_grpc_handshaker_client client)
static

Definition at line 111 of file alts_handshaker_client.cc.

◆ handshaker_client_shutdown()

static void handshaker_client_shutdown ( alts_handshaker_client c)
static

Definition at line 640 of file alts_handshaker_client.cc.

◆ handshaker_client_start_client()

static tsi_result handshaker_client_start_client ( alts_handshaker_client c)
static

Definition at line 521 of file alts_handshaker_client.cc.

◆ handshaker_client_start_server()

static tsi_result handshaker_client_start_server ( alts_handshaker_client c,
grpc_slice bytes_received 
)
static

Definition at line 579 of file alts_handshaker_client.cc.

◆ is_handshake_finished_properly()

static bool is_handshake_finished_properly ( grpc_gcp_HandshakerResp resp)
static

Definition at line 118 of file alts_handshaker_client.cc.

◆ make_grpc_call()

static tsi_result make_grpc_call ( alts_handshaker_client c,
bool  is_start 
)
static

Populate grpc operation data with the fields of ALTS handshaker client and make a grpc call.

Definition at line 429 of file alts_handshaker_client.cc.

◆ maybe_complete_tsi_next()

static void maybe_complete_tsi_next ( alts_grpc_handshaker_client client,
bool  receive_status_finished,
recv_message_result pending_recv_message_result 
)
static

Definition at line 144 of file alts_handshaker_client.cc.

◆ on_status_received()

static void on_status_received ( void *  arg,
grpc_error_handle  error 
)
static

Definition at line 441 of file alts_handshaker_client.cc.

Variable Documentation

◆ kHandshakerClientOpNum

const int kHandshakerClientOpNum = 4

Definition at line 41 of file alts_handshaker_client.cc.

◆ vtable

handshaker_client_shutdown
static void handshaker_client_shutdown(alts_handshaker_client *c)
Definition: alts_handshaker_client.cc:640
handshaker_client_destruct
static void handshaker_client_destruct(alts_handshaker_client *c)
Definition: alts_handshaker_client.cc:654
handshaker_client_start_client
static tsi_result handshaker_client_start_client(alts_handshaker_client *c)
Definition: alts_handshaker_client.cc:521
handshaker_client_start_server
static tsi_result handshaker_client_start_server(alts_handshaker_client *c, grpc_slice *bytes_received)
Definition: alts_handshaker_client.cc:579
handshaker_client_next
static tsi_result handshaker_client_next(alts_handshaker_client *c, grpc_slice *bytes_received)
Definition: alts_handshaker_client.cc:616


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:02