mirror of https://github.com/grpc/grpc.git
parent
e03cdc2a9d
commit
be4e684a82
42 changed files with 637 additions and 3376 deletions
@ -1,520 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2018 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h" |
||||
|
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
|
||||
#include "src/core/tsi/alts/handshaker/transport_security_common_api.h" |
||||
|
||||
/* HandshakerReq */ |
||||
grpc_gcp_handshaker_req* grpc_gcp_handshaker_req_create( |
||||
grpc_gcp_handshaker_req_type type) { |
||||
grpc_gcp_handshaker_req* req = |
||||
static_cast<grpc_gcp_handshaker_req*>(gpr_zalloc(sizeof(*req))); |
||||
switch (type) { |
||||
case CLIENT_START_REQ: |
||||
req->has_client_start = true; |
||||
break; |
||||
case SERVER_START_REQ: |
||||
req->has_server_start = true; |
||||
break; |
||||
case NEXT_REQ: |
||||
req->has_next = true; |
||||
break; |
||||
} |
||||
return req; |
||||
} |
||||
|
||||
void grpc_gcp_handshaker_req_destroy(grpc_gcp_handshaker_req* req) { |
||||
if (req == nullptr) { |
||||
return; |
||||
} |
||||
if (req->has_client_start) { |
||||
/* Destroy client_start request. */ |
||||
destroy_repeated_field_list_identity( |
||||
static_cast<repeated_field*>(req->client_start.target_identities.arg)); |
||||
destroy_repeated_field_list_string(static_cast<repeated_field*>( |
||||
req->client_start.application_protocols.arg)); |
||||
destroy_repeated_field_list_string( |
||||
static_cast<repeated_field*>(req->client_start.record_protocols.arg)); |
||||
if (req->client_start.has_local_identity) { |
||||
destroy_slice(static_cast<grpc_slice*>( |
||||
req->client_start.local_identity.hostname.arg)); |
||||
destroy_slice(static_cast<grpc_slice*>( |
||||
req->client_start.local_identity.service_account.arg)); |
||||
} |
||||
if (req->client_start.has_local_endpoint) { |
||||
destroy_slice(static_cast<grpc_slice*>( |
||||
req->client_start.local_endpoint.ip_address.arg)); |
||||
} |
||||
if (req->client_start.has_remote_endpoint) { |
||||
destroy_slice(static_cast<grpc_slice*>( |
||||
req->client_start.remote_endpoint.ip_address.arg)); |
||||
} |
||||
destroy_slice(static_cast<grpc_slice*>(req->client_start.target_name.arg)); |
||||
} else if (req->has_server_start) { |
||||
/* Destroy server_start request. */ |
||||
size_t i = 0; |
||||
for (i = 0; i < req->server_start.handshake_parameters_count; i++) { |
||||
destroy_repeated_field_list_identity( |
||||
static_cast<repeated_field*>(req->server_start.handshake_parameters[i] |
||||
.value.local_identities.arg)); |
||||
destroy_repeated_field_list_string( |
||||
static_cast<repeated_field*>(req->server_start.handshake_parameters[i] |
||||
.value.record_protocols.arg)); |
||||
} |
||||
destroy_repeated_field_list_string(static_cast<repeated_field*>( |
||||
req->server_start.application_protocols.arg)); |
||||
if (req->server_start.has_local_endpoint) { |
||||
destroy_slice(static_cast<grpc_slice*>( |
||||
req->server_start.local_endpoint.ip_address.arg)); |
||||
} |
||||
if (req->server_start.has_remote_endpoint) { |
||||
destroy_slice(static_cast<grpc_slice*>( |
||||
req->server_start.remote_endpoint.ip_address.arg)); |
||||
} |
||||
destroy_slice(static_cast<grpc_slice*>(req->server_start.in_bytes.arg)); |
||||
} else { |
||||
/* Destroy next request. */ |
||||
destroy_slice(static_cast<grpc_slice*>(req->next.in_bytes.arg)); |
||||
} |
||||
gpr_free(req); |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_set_handshake_protocol( |
||||
grpc_gcp_handshaker_req* req, |
||||
grpc_gcp_handshake_protocol handshake_protocol) { |
||||
if (req == nullptr || !req->has_client_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_set_handshake_protocol()."); |
||||
return false; |
||||
} |
||||
req->client_start.has_handshake_security_protocol = true; |
||||
req->client_start.handshake_security_protocol = handshake_protocol; |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_set_target_name(grpc_gcp_handshaker_req* req, |
||||
const char* target_name) { |
||||
if (req == nullptr || target_name == nullptr || !req->has_client_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_set_target_name()."); |
||||
return false; |
||||
} |
||||
grpc_slice* slice = create_slice(target_name, strlen(target_name)); |
||||
req->client_start.target_name.arg = slice; |
||||
req->client_start.target_name.funcs.encode = encode_string_or_bytes_cb; |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_add_application_protocol( |
||||
grpc_gcp_handshaker_req* req, const char* application_protocol) { |
||||
if (req == nullptr || application_protocol == nullptr || req->has_next) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_add_application_protocol()."); |
||||
return false; |
||||
} |
||||
grpc_slice* slice = |
||||
create_slice(application_protocol, strlen(application_protocol)); |
||||
if (req->has_client_start) { |
||||
add_repeated_field(reinterpret_cast<repeated_field**>( |
||||
&req->client_start.application_protocols.arg), |
||||
slice); |
||||
req->client_start.application_protocols.funcs.encode = |
||||
encode_repeated_string_cb; |
||||
} else { |
||||
add_repeated_field(reinterpret_cast<repeated_field**>( |
||||
&req->server_start.application_protocols.arg), |
||||
slice); |
||||
req->server_start.application_protocols.funcs.encode = |
||||
encode_repeated_string_cb; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_add_record_protocol(grpc_gcp_handshaker_req* req, |
||||
const char* record_protocol) { |
||||
if (req == nullptr || record_protocol == nullptr || !req->has_client_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_add_record_protocol()."); |
||||
return false; |
||||
} |
||||
grpc_slice* slice = create_slice(record_protocol, strlen(record_protocol)); |
||||
add_repeated_field(reinterpret_cast<repeated_field**>( |
||||
&req->client_start.record_protocols.arg), |
||||
slice); |
||||
req->client_start.record_protocols.funcs.encode = encode_repeated_string_cb; |
||||
return true; |
||||
} |
||||
|
||||
static void set_identity_hostname(grpc_gcp_identity* identity, |
||||
const char* hostname) { |
||||
grpc_slice* slice = create_slice(hostname, strlen(hostname)); |
||||
identity->hostname.arg = slice; |
||||
identity->hostname.funcs.encode = encode_string_or_bytes_cb; |
||||
} |
||||
|
||||
static void set_identity_service_account(grpc_gcp_identity* identity, |
||||
const char* service_account) { |
||||
grpc_slice* slice = create_slice(service_account, strlen(service_account)); |
||||
identity->service_account.arg = slice; |
||||
identity->service_account.funcs.encode = encode_string_or_bytes_cb; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_add_target_identity_hostname( |
||||
grpc_gcp_handshaker_req* req, const char* hostname) { |
||||
if (req == nullptr || hostname == nullptr || !req->has_client_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid nullptr arguments to " |
||||
"grpc_gcp_handshaker_req_add_target_identity_hostname()."); |
||||
return false; |
||||
} |
||||
grpc_gcp_identity* target_identity = |
||||
static_cast<grpc_gcp_identity*>(gpr_zalloc(sizeof(*target_identity))); |
||||
set_identity_hostname(target_identity, hostname); |
||||
req->client_start.target_identities.funcs.encode = |
||||
encode_repeated_identity_cb; |
||||
add_repeated_field(reinterpret_cast<repeated_field**>( |
||||
&req->client_start.target_identities.arg), |
||||
target_identity); |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_add_target_identity_service_account( |
||||
grpc_gcp_handshaker_req* req, const char* service_account) { |
||||
if (req == nullptr || service_account == nullptr || !req->has_client_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid nullptr arguments to " |
||||
"grpc_gcp_handshaker_req_add_target_identity_service_account()."); |
||||
return false; |
||||
} |
||||
grpc_gcp_identity* target_identity = |
||||
static_cast<grpc_gcp_identity*>(gpr_zalloc(sizeof(*target_identity))); |
||||
set_identity_service_account(target_identity, service_account); |
||||
req->client_start.target_identities.funcs.encode = |
||||
encode_repeated_identity_cb; |
||||
add_repeated_field(reinterpret_cast<repeated_field**>( |
||||
&req->client_start.target_identities.arg), |
||||
target_identity); |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_set_local_identity_hostname( |
||||
grpc_gcp_handshaker_req* req, const char* hostname) { |
||||
if (req == nullptr || hostname == nullptr || !req->has_client_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid nullptr arguments to " |
||||
"grpc_gcp_handshaker_req_set_local_identity_hostname()."); |
||||
return false; |
||||
} |
||||
req->client_start.has_local_identity = true; |
||||
set_identity_hostname(&req->client_start.local_identity, hostname); |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_set_local_identity_service_account( |
||||
grpc_gcp_handshaker_req* req, const char* service_account) { |
||||
if (req == nullptr || service_account == nullptr || !req->has_client_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid nullptr arguments to " |
||||
"grpc_gcp_handshaker_req_set_local_identity_service_account()."); |
||||
return false; |
||||
} |
||||
req->client_start.has_local_identity = true; |
||||
set_identity_service_account(&req->client_start.local_identity, |
||||
service_account); |
||||
return true; |
||||
} |
||||
|
||||
static void set_endpoint(grpc_gcp_endpoint* endpoint, const char* ip_address, |
||||
size_t port, grpc_gcp_network_protocol protocol) { |
||||
grpc_slice* slice = create_slice(ip_address, strlen(ip_address)); |
||||
endpoint->ip_address.arg = slice; |
||||
endpoint->ip_address.funcs.encode = encode_string_or_bytes_cb; |
||||
endpoint->has_port = true; |
||||
endpoint->port = static_cast<int32_t>(port); |
||||
endpoint->has_protocol = true; |
||||
endpoint->protocol = protocol; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_set_rpc_versions(grpc_gcp_handshaker_req* req, |
||||
uint32_t max_major, |
||||
uint32_t max_minor, |
||||
uint32_t min_major, |
||||
uint32_t min_minor) { |
||||
if (req == nullptr || req->has_next) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_set_rpc_versions()."); |
||||
return false; |
||||
} |
||||
if (req->has_client_start) { |
||||
req->client_start.has_rpc_versions = true; |
||||
grpc_gcp_rpc_protocol_versions_set_max(&req->client_start.rpc_versions, |
||||
max_major, max_minor); |
||||
grpc_gcp_rpc_protocol_versions_set_min(&req->client_start.rpc_versions, |
||||
min_major, min_minor); |
||||
} else { |
||||
req->server_start.has_rpc_versions = true; |
||||
grpc_gcp_rpc_protocol_versions_set_max(&req->server_start.rpc_versions, |
||||
max_major, max_minor); |
||||
grpc_gcp_rpc_protocol_versions_set_min(&req->server_start.rpc_versions, |
||||
min_major, min_minor); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_set_local_endpoint( |
||||
grpc_gcp_handshaker_req* req, const char* ip_address, size_t port, |
||||
grpc_gcp_network_protocol protocol) { |
||||
if (req == nullptr || ip_address == nullptr || port > 65535 || |
||||
req->has_next) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_set_local_endpoint()."); |
||||
return false; |
||||
} |
||||
if (req->has_client_start) { |
||||
req->client_start.has_local_endpoint = true; |
||||
set_endpoint(&req->client_start.local_endpoint, ip_address, port, protocol); |
||||
} else { |
||||
req->server_start.has_local_endpoint = true; |
||||
set_endpoint(&req->server_start.local_endpoint, ip_address, port, protocol); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_set_remote_endpoint( |
||||
grpc_gcp_handshaker_req* req, const char* ip_address, size_t port, |
||||
grpc_gcp_network_protocol protocol) { |
||||
if (req == nullptr || ip_address == nullptr || port > 65535 || |
||||
req->has_next) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_set_remote_endpoint()."); |
||||
return false; |
||||
} |
||||
if (req->has_client_start) { |
||||
req->client_start.has_remote_endpoint = true; |
||||
set_endpoint(&req->client_start.remote_endpoint, ip_address, port, |
||||
protocol); |
||||
} else { |
||||
req->server_start.has_remote_endpoint = true; |
||||
set_endpoint(&req->server_start.remote_endpoint, ip_address, port, |
||||
protocol); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_set_in_bytes(grpc_gcp_handshaker_req* req, |
||||
const char* in_bytes, size_t size) { |
||||
if (req == nullptr || in_bytes == nullptr || req->has_client_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_set_in_bytes()."); |
||||
return false; |
||||
} |
||||
grpc_slice* slice = create_slice(in_bytes, size); |
||||
if (req->has_next) { |
||||
req->next.in_bytes.arg = slice; |
||||
req->next.in_bytes.funcs.encode = &encode_string_or_bytes_cb; |
||||
} else { |
||||
req->server_start.in_bytes.arg = slice; |
||||
req->server_start.in_bytes.funcs.encode = &encode_string_or_bytes_cb; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
static grpc_gcp_server_handshake_parameters* server_start_find_param( |
||||
grpc_gcp_handshaker_req* req, int32_t key) { |
||||
size_t i = 0; |
||||
for (i = 0; i < req->server_start.handshake_parameters_count; i++) { |
||||
if (req->server_start.handshake_parameters[i].key == key) { |
||||
return &req->server_start.handshake_parameters[i].value; |
||||
} |
||||
} |
||||
req->server_start |
||||
.handshake_parameters[req->server_start.handshake_parameters_count] |
||||
.has_key = true; |
||||
req->server_start |
||||
.handshake_parameters[req->server_start.handshake_parameters_count] |
||||
.has_value = true; |
||||
req->server_start |
||||
.handshake_parameters[req->server_start.handshake_parameters_count++] |
||||
.key = key; |
||||
return &req->server_start |
||||
.handshake_parameters |
||||
[req->server_start.handshake_parameters_count - 1] |
||||
.value; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_param_add_record_protocol( |
||||
grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, |
||||
const char* record_protocol) { |
||||
if (req == nullptr || record_protocol == nullptr || !req->has_server_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_param_add_record_protocol()."); |
||||
return false; |
||||
} |
||||
grpc_gcp_server_handshake_parameters* param = |
||||
server_start_find_param(req, key); |
||||
grpc_slice* slice = create_slice(record_protocol, strlen(record_protocol)); |
||||
add_repeated_field( |
||||
reinterpret_cast<repeated_field**>(¶m->record_protocols.arg), slice); |
||||
param->record_protocols.funcs.encode = &encode_repeated_string_cb; |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_param_add_local_identity_hostname( |
||||
grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, |
||||
const char* hostname) { |
||||
if (req == nullptr || hostname == nullptr || !req->has_server_start) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_param_add_local_identity_hostname()."); |
||||
return false; |
||||
} |
||||
grpc_gcp_server_handshake_parameters* param = |
||||
server_start_find_param(req, key); |
||||
grpc_gcp_identity* local_identity = |
||||
static_cast<grpc_gcp_identity*>(gpr_zalloc(sizeof(*local_identity))); |
||||
set_identity_hostname(local_identity, hostname); |
||||
add_repeated_field( |
||||
reinterpret_cast<repeated_field**>(¶m->local_identities.arg), |
||||
local_identity); |
||||
param->local_identities.funcs.encode = &encode_repeated_identity_cb; |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_param_add_local_identity_service_account( |
||||
grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, |
||||
const char* service_account) { |
||||
if (req == nullptr || service_account == nullptr || !req->has_server_start) { |
||||
gpr_log( |
||||
GPR_ERROR, |
||||
"Invalid arguments to " |
||||
"grpc_gcp_handshaker_req_param_add_local_identity_service_account()."); |
||||
return false; |
||||
} |
||||
grpc_gcp_server_handshake_parameters* param = |
||||
server_start_find_param(req, key); |
||||
grpc_gcp_identity* local_identity = |
||||
static_cast<grpc_gcp_identity*>(gpr_zalloc(sizeof(*local_identity))); |
||||
set_identity_service_account(local_identity, service_account); |
||||
add_repeated_field( |
||||
reinterpret_cast<repeated_field**>(¶m->local_identities.arg), |
||||
local_identity); |
||||
param->local_identities.funcs.encode = &encode_repeated_identity_cb; |
||||
return true; |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_req_encode(grpc_gcp_handshaker_req* req, |
||||
grpc_slice* slice) { |
||||
if (req == nullptr || slice == nullptr) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid nullptr arguments to grpc_gcp_handshaker_req_encode()."); |
||||
return false; |
||||
} |
||||
pb_ostream_t size_stream; |
||||
memset(&size_stream, 0, sizeof(pb_ostream_t)); |
||||
if (!pb_encode(&size_stream, grpc_gcp_HandshakerReq_fields, req)) { |
||||
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&size_stream)); |
||||
return false; |
||||
} |
||||
size_t encoded_length = size_stream.bytes_written; |
||||
*slice = grpc_slice_malloc(encoded_length); |
||||
pb_ostream_t output_stream = |
||||
pb_ostream_from_buffer(GRPC_SLICE_START_PTR(*slice), encoded_length); |
||||
if (!pb_encode(&output_stream, grpc_gcp_HandshakerReq_fields, req) != 0) { |
||||
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&output_stream)); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/* HandshakerResp. */ |
||||
grpc_gcp_handshaker_resp* grpc_gcp_handshaker_resp_create(void) { |
||||
grpc_gcp_handshaker_resp* resp = |
||||
static_cast<grpc_gcp_handshaker_resp*>(gpr_zalloc(sizeof(*resp))); |
||||
return resp; |
||||
} |
||||
|
||||
void grpc_gcp_handshaker_resp_destroy(grpc_gcp_handshaker_resp* resp) { |
||||
if (resp != nullptr) { |
||||
destroy_slice(static_cast<grpc_slice*>(resp->out_frames.arg)); |
||||
if (resp->has_status) { |
||||
destroy_slice(static_cast<grpc_slice*>(resp->status.details.arg)); |
||||
} |
||||
if (resp->has_result) { |
||||
destroy_slice( |
||||
static_cast<grpc_slice*>(resp->result.application_protocol.arg)); |
||||
destroy_slice(static_cast<grpc_slice*>(resp->result.record_protocol.arg)); |
||||
destroy_slice(static_cast<grpc_slice*>(resp->result.key_data.arg)); |
||||
if (resp->result.has_local_identity) { |
||||
destroy_slice( |
||||
static_cast<grpc_slice*>(resp->result.local_identity.hostname.arg)); |
||||
destroy_slice(static_cast<grpc_slice*>( |
||||
resp->result.local_identity.service_account.arg)); |
||||
} |
||||
if (resp->result.has_peer_identity) { |
||||
destroy_slice( |
||||
static_cast<grpc_slice*>(resp->result.peer_identity.hostname.arg)); |
||||
destroy_slice(static_cast<grpc_slice*>( |
||||
resp->result.peer_identity.service_account.arg)); |
||||
} |
||||
} |
||||
gpr_free(resp); |
||||
} |
||||
} |
||||
|
||||
bool grpc_gcp_handshaker_resp_decode(grpc_slice encoded_handshaker_resp, |
||||
grpc_gcp_handshaker_resp* resp) { |
||||
if (resp == nullptr) { |
||||
gpr_log(GPR_ERROR, |
||||
"Invalid nullptr argument to grpc_gcp_handshaker_resp_decode()."); |
||||
return false; |
||||
} |
||||
pb_istream_t stream = |
||||
pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_handshaker_resp), |
||||
GRPC_SLICE_LENGTH(encoded_handshaker_resp)); |
||||
resp->out_frames.funcs.decode = decode_string_or_bytes_cb; |
||||
resp->status.details.funcs.decode = decode_string_or_bytes_cb; |
||||
resp->result.application_protocol.funcs.decode = decode_string_or_bytes_cb; |
||||
resp->result.record_protocol.funcs.decode = decode_string_or_bytes_cb; |
||||
resp->result.key_data.funcs.decode = decode_string_or_bytes_cb; |
||||
resp->result.peer_identity.hostname.funcs.decode = decode_string_or_bytes_cb; |
||||
resp->result.peer_identity.service_account.funcs.decode = |
||||
decode_string_or_bytes_cb; |
||||
resp->result.local_identity.hostname.funcs.decode = decode_string_or_bytes_cb; |
||||
resp->result.local_identity.service_account.funcs.decode = |
||||
decode_string_or_bytes_cb; |
||||
if (!pb_decode(&stream, grpc_gcp_HandshakerResp_fields, resp)) { |
||||
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
@ -1,323 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2018 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H |
||||
#define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h" |
||||
|
||||
/**
|
||||
* An implementation of nanopb thin wrapper used to set/get and |
||||
* serialize/de-serialize of ALTS handshake requests and responses. |
||||
* |
||||
* All APIs in the header are thread-compatible. A typical usage of this API at |
||||
* the client side is as follows: |
||||
* |
||||
* ----------------------------------------------------------------------------- |
||||
* // Create, populate, and serialize an ALTS client_start handshake request to
|
||||
* // send to the server.
|
||||
* grpc_gcp_handshaker_req* req = |
||||
* grpc_gcp_handshaker_req_create(CLIENT_START_REQ); |
||||
* grpc_gcp_handshaker_req_set_handshake_protocol( |
||||
req, grpc_gcp_HandshakeProtocol_ALTS); |
||||
* grpc_gcp_handshaker_req_add_application_protocol(req, "grpc"); |
||||
* grpc_gcp_handshaker_req_add_record_protocol(req, "ALTSRP_GCM_AES128"); |
||||
* grpc_slice client_slice; |
||||
* if (!grpc_gcp_handshaker_req_encode(req, &client_slice)) { |
||||
* fprintf(stderr, "ALTS handshake request encoding failed."; |
||||
* } |
||||
* |
||||
* // De-serialize a data stream received from the server, and store the result
|
||||
* // at ALTS handshake response.
|
||||
* grpc_gcp_handshaker_resp* resp = grpc_gcp_handshaker_resp_create(); |
||||
* if (!grpc_gcp_handshaker_resp_decode(server_slice, resp)) { |
||||
* fprintf(stderr, "ALTS handshake response decoding failed."); |
||||
* } |
||||
* // To access a variable-length datatype field (i.e., pb_callback_t),
|
||||
* // access its "arg" subfield (if it has been set).
|
||||
* if (resp->out_frames.arg != nullptr) { |
||||
* grpc_slice* slice = resp->out_frames.arg; |
||||
* } |
||||
* // To access a fixed-length datatype field (i.e., not pb_calback_t),
|
||||
* // access the field directly (if it has been set).
|
||||
* if (resp->has_status && resp->status->has_code) { |
||||
* uint32_t code = resp->status->code; |
||||
* } |
||||
*------------------------------------------------------------------------------ |
||||
*/ |
||||
|
||||
/**
|
||||
* This method creates an ALTS handshake request. |
||||
* |
||||
* - type: an enum type value that can be either CLIENT_START_REQ, |
||||
* SERVER_START_REQ, or NEXT_REQ to indicate the created instance will be |
||||
* client_start, server_start, and next handshake request message |
||||
* respectively. |
||||
* |
||||
* The method returns a pointer to the created instance. |
||||
*/ |
||||
grpc_gcp_handshaker_req* grpc_gcp_handshaker_req_create( |
||||
grpc_gcp_handshaker_req_type type); |
||||
|
||||
/**
|
||||
* This method sets the value for handshake_security_protocol field of ALTS |
||||
* client_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - handshake_protocol: a enum type value representing the handshake security |
||||
* protocol. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_set_handshake_protocol( |
||||
grpc_gcp_handshaker_req* req, |
||||
grpc_gcp_handshake_protocol handshake_protocol); |
||||
|
||||
/**
|
||||
* This method sets the value for target_name field of ALTS client_start |
||||
* handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - target_name: a target name to be set. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_set_target_name(grpc_gcp_handshaker_req* req, |
||||
const char* target_name); |
||||
|
||||
/**
|
||||
* This method adds an application protocol supported by the server (or |
||||
* client) to ALTS server_start (or client_start) handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - application_protocol: an application protocol (e.g., grpc) to be added. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_add_application_protocol( |
||||
grpc_gcp_handshaker_req* req, const char* application_protocol); |
||||
|
||||
/**
|
||||
* This method adds a record protocol supported by the client to ALTS |
||||
* client_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - record_protocol: a record protocol (e.g., ALTSRP_GCM_AES128) to be |
||||
* added. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_add_record_protocol(grpc_gcp_handshaker_req* req, |
||||
const char* record_protocol); |
||||
|
||||
/**
|
||||
* This method adds a target server identity represented as hostname and |
||||
* acceptable by a client to ALTS client_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - hostname: a string representation of hostname at the connection |
||||
* endpoint to be added. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_add_target_identity_hostname( |
||||
grpc_gcp_handshaker_req* req, const char* hostname); |
||||
|
||||
/**
|
||||
* This method adds a target server identity represented as service account and |
||||
* acceptable by a client to ALTS client_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - service_account: a string representation of service account at the |
||||
* connection endpoint to be added. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_add_target_identity_service_account( |
||||
grpc_gcp_handshaker_req* req, const char* service_account); |
||||
|
||||
/**
|
||||
* This method sets the hostname for local_identity field of ALTS client_start |
||||
* handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - hostname: a string representation of hostname. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_set_local_identity_hostname( |
||||
grpc_gcp_handshaker_req* req, const char* hostname); |
||||
|
||||
/**
|
||||
* This method sets the service account for local_identity field of ALTS |
||||
* client_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - service_account: a string representation of service account. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_set_local_identity_service_account( |
||||
grpc_gcp_handshaker_req* req, const char* service_account); |
||||
|
||||
/**
|
||||
* This method sets the value for local_endpoint field of either ALTS |
||||
* client_start or server_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - ip_address: a string representation of ip address associated with the |
||||
* local endpoint, that could be either IPv4 or IPv6. |
||||
* - port: a port number associated with the local endpoint. |
||||
* - protocol: a network protocol (e.g., TCP or UDP) associated with the |
||||
* local endpoint. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_set_local_endpoint( |
||||
grpc_gcp_handshaker_req* req, const char* ip_address, size_t port, |
||||
grpc_gcp_network_protocol protocol); |
||||
|
||||
/**
|
||||
* This method sets the value for remote_endpoint field of either ALTS |
||||
* client_start or server_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - ip_address: a string representation of ip address associated with the |
||||
* remote endpoint, that could be either IPv4 or IPv6. |
||||
* - port: a port number associated with the remote endpoint. |
||||
* - protocol: a network protocol (e.g., TCP or UDP) associated with the |
||||
* remote endpoint. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_set_remote_endpoint( |
||||
grpc_gcp_handshaker_req* req, const char* ip_address, size_t port, |
||||
grpc_gcp_network_protocol protocol); |
||||
|
||||
/**
|
||||
* This method sets the value for in_bytes field of either ALTS server_start or |
||||
* next handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - in_bytes: a buffer containing bytes taken from out_frames of the peer's |
||||
* ALTS handshake response. It is possible that the peer's out_frames are |
||||
* split into multiple handshake request messages. |
||||
* - size: size of in_bytes buffer. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_set_in_bytes(grpc_gcp_handshaker_req* req, |
||||
const char* in_bytes, size_t size); |
||||
|
||||
/**
|
||||
* This method adds a record protocol to handshake parameters mapped by the |
||||
* handshake protocol for ALTS server_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - key: an enum type value representing a handshake security protocol. |
||||
* - record_protocol: a record protocol to be added. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_param_add_record_protocol( |
||||
grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, |
||||
const char* record_protocol); |
||||
|
||||
/**
|
||||
* This method adds a local identity represented as hostname to handshake |
||||
* parameters mapped by the handshake protocol for ALTS server_start handshake |
||||
* request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - key: an enum type value representing a handshake security protocol. |
||||
* - hostname: a string representation of hostname to be added. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_param_add_local_identity_hostname( |
||||
grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, |
||||
const char* hostname); |
||||
|
||||
/**
|
||||
* This method adds a local identity represented as service account to handshake |
||||
* parameters mapped by the handshake protocol for ALTS server_start handshake |
||||
* request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - key: an enum type value representing a handshake security protocol. |
||||
* - service_account: a string representation of service account to be added. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_param_add_local_identity_service_account( |
||||
grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, |
||||
const char* service_account); |
||||
|
||||
/**
|
||||
* This method sets the value for rpc_versions field of either ALTS |
||||
* client_start or server_start handshake request. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - max_major: a major version of maximum supported RPC version. |
||||
* - max_minor: a minor version of maximum supported RPC version. |
||||
* - min_major: a major version of minimum supported RPC version. |
||||
* - min_minor: a minor version of minimum supported RPC version. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_set_rpc_versions(grpc_gcp_handshaker_req* req, |
||||
uint32_t max_major, |
||||
uint32_t max_minor, |
||||
uint32_t min_major, |
||||
uint32_t min_minor); |
||||
|
||||
/**
|
||||
* This method serializes an ALTS handshake request and returns a data stream. |
||||
* |
||||
* - req: an ALTS handshake request. |
||||
* - slice: a data stream where the serialized result will be written. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_req_encode(grpc_gcp_handshaker_req* req, |
||||
grpc_slice* slice); |
||||
|
||||
/* This method destroys an ALTS handshake request. */ |
||||
void grpc_gcp_handshaker_req_destroy(grpc_gcp_handshaker_req* req); |
||||
|
||||
/* This method creates an ALTS handshake response. */ |
||||
grpc_gcp_handshaker_resp* grpc_gcp_handshaker_resp_create(void); |
||||
|
||||
/**
|
||||
* This method de-serializes a data stream and stores the result |
||||
* in an ALTS handshake response. |
||||
* |
||||
* - slice: a data stream containing a serialized ALTS handshake response. |
||||
* - resp: an ALTS handshake response used to hold de-serialized result. |
||||
* |
||||
* The method returns true on success and false otherwise. |
||||
*/ |
||||
bool grpc_gcp_handshaker_resp_decode(grpc_slice slice, |
||||
grpc_gcp_handshaker_resp* resp); |
||||
|
||||
/* This method destroys an ALTS handshake response. */ |
||||
void grpc_gcp_handshaker_resp_destroy(grpc_gcp_handshaker_resp* resp); |
||||
|
||||
#endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H */ |
@ -1,145 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2018 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h" |
||||
|
||||
#include "src/core/lib/slice/slice_internal.h" |
||||
|
||||
void add_repeated_field(repeated_field** head, const void* data) { |
||||
repeated_field* field = |
||||
static_cast<repeated_field*>(gpr_zalloc(sizeof(*field))); |
||||
field->data = data; |
||||
if (*head == nullptr) { |
||||
*head = field; |
||||
(*head)->next = nullptr; |
||||
} else { |
||||
field->next = *head; |
||||
*head = field; |
||||
} |
||||
} |
||||
|
||||
void destroy_repeated_field_list_identity(repeated_field* head) { |
||||
repeated_field* field = head; |
||||
while (field != nullptr) { |
||||
repeated_field* next_field = field->next; |
||||
const grpc_gcp_identity* identity = |
||||
static_cast<const grpc_gcp_identity*>(field->data); |
||||
destroy_slice(static_cast<grpc_slice*>(identity->hostname.arg)); |
||||
destroy_slice(static_cast<grpc_slice*>(identity->service_account.arg)); |
||||
gpr_free((void*)identity); |
||||
gpr_free(field); |
||||
field = next_field; |
||||
} |
||||
} |
||||
|
||||
void destroy_repeated_field_list_string(repeated_field* head) { |
||||
repeated_field* field = head; |
||||
while (field != nullptr) { |
||||
repeated_field* next_field = field->next; |
||||
destroy_slice((grpc_slice*)field->data); |
||||
gpr_free(field); |
||||
field = next_field; |
||||
} |
||||
} |
||||
|
||||
grpc_slice* create_slice(const char* data, size_t size) { |
||||
grpc_slice slice = grpc_slice_from_copied_buffer(data, size); |
||||
grpc_slice* cb_slice = |
||||
static_cast<grpc_slice*>(gpr_zalloc(sizeof(*cb_slice))); |
||||
memcpy(cb_slice, &slice, sizeof(*cb_slice)); |
||||
return cb_slice; |
||||
} |
||||
|
||||
void destroy_slice(grpc_slice* slice) { |
||||
if (slice != nullptr) { |
||||
grpc_slice_unref_internal(*slice); |
||||
gpr_free(slice); |
||||
} |
||||
} |
||||
|
||||
bool encode_string_or_bytes_cb(pb_ostream_t* stream, const pb_field_t* field, |
||||
void* const* arg) { |
||||
grpc_slice* slice = static_cast<grpc_slice*>(*arg); |
||||
if (!pb_encode_tag_for_field(stream, field)) return false; |
||||
return pb_encode_string(stream, GRPC_SLICE_START_PTR(*slice), |
||||
GRPC_SLICE_LENGTH(*slice)); |
||||
} |
||||
|
||||
bool encode_repeated_identity_cb(pb_ostream_t* stream, const pb_field_t* field, |
||||
void* const* arg) { |
||||
repeated_field* var = static_cast<repeated_field*>(*arg); |
||||
while (var != nullptr) { |
||||
if (!pb_encode_tag_for_field(stream, field)) return false; |
||||
if (!pb_encode_submessage(stream, grpc_gcp_Identity_fields, |
||||
(grpc_gcp_identity*)var->data)) |
||||
return false; |
||||
var = var->next; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
bool encode_repeated_string_cb(pb_ostream_t* stream, const pb_field_t* field, |
||||
void* const* arg) { |
||||
repeated_field* var = static_cast<repeated_field*>(*arg); |
||||
while (var != nullptr) { |
||||
if (!pb_encode_tag_for_field(stream, field)) return false; |
||||
const grpc_slice* slice = static_cast<const grpc_slice*>(var->data); |
||||
if (!pb_encode_string(stream, GRPC_SLICE_START_PTR(*slice), |
||||
GRPC_SLICE_LENGTH(*slice))) |
||||
return false; |
||||
var = var->next; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
bool decode_string_or_bytes_cb(pb_istream_t* stream, const pb_field_t* field, |
||||
void** arg) { |
||||
grpc_slice slice = grpc_slice_malloc(stream->bytes_left); |
||||
grpc_slice* cb_slice = |
||||
static_cast<grpc_slice*>(gpr_zalloc(sizeof(*cb_slice))); |
||||
memcpy(cb_slice, &slice, sizeof(*cb_slice)); |
||||
if (!pb_read(stream, GRPC_SLICE_START_PTR(*cb_slice), stream->bytes_left)) |
||||
return false; |
||||
*arg = cb_slice; |
||||
return true; |
||||
} |
||||
|
||||
bool decode_repeated_identity_cb(pb_istream_t* stream, const pb_field_t* field, |
||||
void** arg) { |
||||
grpc_gcp_identity* identity = |
||||
static_cast<grpc_gcp_identity*>(gpr_zalloc(sizeof(*identity))); |
||||
identity->hostname.funcs.decode = decode_string_or_bytes_cb; |
||||
identity->service_account.funcs.decode = decode_string_or_bytes_cb; |
||||
add_repeated_field(reinterpret_cast<repeated_field**>(arg), identity); |
||||
if (!pb_decode(stream, grpc_gcp_Identity_fields, identity)) return false; |
||||
return true; |
||||
} |
||||
|
||||
bool decode_repeated_string_cb(pb_istream_t* stream, const pb_field_t* field, |
||||
void** arg) { |
||||
grpc_slice slice = grpc_slice_malloc(stream->bytes_left); |
||||
grpc_slice* cb_slice = |
||||
static_cast<grpc_slice*>(gpr_zalloc(sizeof(*cb_slice))); |
||||
memcpy(cb_slice, &slice, sizeof(grpc_slice)); |
||||
if (!pb_read(stream, GRPC_SLICE_START_PTR(*cb_slice), stream->bytes_left)) |
||||
return false; |
||||
add_repeated_field(reinterpret_cast<repeated_field**>(arg), cb_slice); |
||||
return true; |
||||
} |
@ -1,149 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2018 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H |
||||
#define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include "pb_decode.h" |
||||
#include "pb_encode.h" |
||||
|
||||
#include <grpc/slice.h> |
||||
#include <grpc/slice_buffer.h> |
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/tsi/alts/handshaker/handshaker.pb.h" |
||||
|
||||
/**
|
||||
* An implementation of utility functions used to serialize/ |
||||
* de-serialize ALTS handshake requests/responses. All APIs in the header |
||||
* are thread-compatible. |
||||
*/ |
||||
|
||||
/* Renaming of message/field structs generated by nanopb compiler. */ |
||||
typedef grpc_gcp_HandshakeProtocol grpc_gcp_handshake_protocol; |
||||
typedef grpc_gcp_NetworkProtocol grpc_gcp_network_protocol; |
||||
typedef grpc_gcp_Identity grpc_gcp_identity; |
||||
typedef grpc_gcp_NextHandshakeMessageReq grpc_gcp_next_handshake_message_req; |
||||
typedef grpc_gcp_ServerHandshakeParameters grpc_gcp_server_handshake_parameters; |
||||
typedef grpc_gcp_Endpoint grpc_gcp_endpoint; |
||||
typedef grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry |
||||
grpc_gcp_handshake_parameters_entry; |
||||
typedef grpc_gcp_StartClientHandshakeReq grpc_gcp_start_client_handshake_req; |
||||
typedef grpc_gcp_StartServerHandshakeReq grpc_gcp_start_server_handshake_req; |
||||
typedef grpc_gcp_HandshakerReq grpc_gcp_handshaker_req; |
||||
typedef grpc_gcp_HandshakerResult grpc_gcp_handshaker_result; |
||||
typedef grpc_gcp_HandshakerStatus grpc_gcp_handshaker_status; |
||||
typedef grpc_gcp_HandshakerResp grpc_gcp_handshaker_resp; |
||||
|
||||
typedef enum { |
||||
CLIENT_START_REQ = 0, /* StartClientHandshakeReq. */ |
||||
SERVER_START_REQ = 1, /* StartServerHandshakeReq. */ |
||||
NEXT_REQ = 2, /* NextHandshakeMessageReq. */ |
||||
} grpc_gcp_handshaker_req_type; |
||||
|
||||
/**
|
||||
* A struct representing a repeated field. The struct is used to organize all |
||||
* instances of a specific repeated field into a linked list, which then will |
||||
* be used at encode/decode phase. For instance at the encode phase, the encode |
||||
* function will iterate through the list, encode each field, and then output |
||||
* the result to the stream. |
||||
*/ |
||||
typedef struct repeated_field_ { |
||||
struct repeated_field_* next; |
||||
const void* data; |
||||
} repeated_field; |
||||
|
||||
/**
|
||||
* This method adds a repeated field to the head of repeated field list. |
||||
* |
||||
* - head: a head of repeated field list. |
||||
* - field: a repeated field to be added to the list. |
||||
*/ |
||||
void add_repeated_field(repeated_field** head, const void* field); |
||||
|
||||
/**
|
||||
* This method destroys a repeated field list that consists of string type |
||||
* fields. |
||||
* |
||||
* - head: a head of repeated field list. |
||||
*/ |
||||
void destroy_repeated_field_list_string(repeated_field* head); |
||||
|
||||
/**
|
||||
* This method destroys a repeated field list that consists of |
||||
* grpc_gcp_identity type fields. |
||||
* |
||||
* - head: a head of repeated field list. |
||||
*/ |
||||
void destroy_repeated_field_list_identity(repeated_field* head); |
||||
|
||||
/**
|
||||
* This method creates a grpc_slice instance by copying a data buffer. It is |
||||
* similar to grpc_slice_from_copied_buffer() except that it returns an instance |
||||
* allocated from the heap. |
||||
* |
||||
* - data: a data buffer to be copied to grpc_slice instance. |
||||
* - size: size of data buffer. |
||||
*/ |
||||
grpc_slice* create_slice(const char* data, size_t size); |
||||
|
||||
/* This method destroys a grpc_slice instance. */ |
||||
void destroy_slice(grpc_slice* slice); |
||||
|
||||
/**
|
||||
* The following encode/decode functions will be assigned to encode/decode |
||||
* function pointers of pb_callback_t struct (defined in |
||||
* //third_party/nanopb/pb.h), that represent a repeated field with a dynamic
|
||||
* length (e.g., a string type or repeated field). |
||||
*/ |
||||
|
||||
/* This method is an encode callback function for a string or byte array. */ |
||||
bool encode_string_or_bytes_cb(pb_ostream_t* stream, const pb_field_t* field, |
||||
void* const* arg); |
||||
|
||||
/**
|
||||
* This method is an encode callback function for a repeated grpc_gcp_identity |
||||
* field. |
||||
*/ |
||||
bool encode_repeated_identity_cb(pb_ostream_t* stream, const pb_field_t* field, |
||||
void* const* arg); |
||||
|
||||
/* This method is an encode callback function for a repeated string field. */ |
||||
bool encode_repeated_string_cb(pb_ostream_t* stream, const pb_field_t* field, |
||||
void* const* arg); |
||||
|
||||
/**
|
||||
* This method is a decode callback function for a string or byte array field. |
||||
*/ |
||||
bool decode_string_or_bytes_cb(pb_istream_t* stream, const pb_field_t* field, |
||||
void** arg); |
||||
/**
|
||||
* This method is a decode callback function for a repeated grpc_gcp_identity |
||||
* field. |
||||
*/ |
||||
bool decode_repeated_identity_cb(pb_istream_t* stream, const pb_field_t* field, |
||||
void** arg); |
||||
|
||||
/* This method is a decode callback function for a repeated string field. */ |
||||
bool decode_repeated_string_cb(pb_istream_t* stream, const pb_field_t* field, |
||||
void** arg); |
||||
|
||||
#endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H */ |
@ -1,47 +0,0 @@ |
||||
/* Automatically generated nanopb constant definitions */ |
||||
/* Generated by nanopb-0.3.7-dev */ |
||||
|
||||
#include "src/core/tsi/alts/handshaker/altscontext.pb.h" |
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
|
||||
|
||||
const pb_field_t grpc_gcp_AltsContext_fields[7] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_gcp_AltsContext, application_protocol, application_protocol, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_AltsContext, record_protocol, application_protocol, 0), |
||||
PB_FIELD( 3, UENUM , OPTIONAL, STATIC , OTHER, grpc_gcp_AltsContext, security_level, record_protocol, 0), |
||||
PB_FIELD( 4, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_AltsContext, peer_service_account, security_level, 0), |
||||
PB_FIELD( 5, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_AltsContext, local_service_account, peer_service_account, 0), |
||||
PB_FIELD( 6, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_AltsContext, peer_rpc_versions, local_service_account, &grpc_gcp_RpcProtocolVersions_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
|
||||
/* Check that field information fits in pb_field_t */ |
||||
#if !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_32BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in 8 or 16 bit |
||||
* field descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(grpc_gcp_AltsContext, peer_rpc_versions) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_gcp_AltsContext) |
||||
#endif |
||||
|
||||
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_16BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in the default |
||||
* 8 bit descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(grpc_gcp_AltsContext, peer_rpc_versions) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_gcp_AltsContext) |
||||
#endif |
||||
|
||||
|
||||
/* @@protoc_insertion_point(eof) */ |
@ -1,63 +0,0 @@ |
||||
/* Automatically generated nanopb header */ |
||||
/* Generated by nanopb-0.3.7-dev */ |
||||
|
||||
#ifndef PB_GRPC_GCP_ALTSCONTEXT_PB_H_INCLUDED |
||||
#define PB_GRPC_GCP_ALTSCONTEXT_PB_H_INCLUDED |
||||
#include "pb.h" |
||||
#include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" |
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Struct definitions */ |
||||
typedef struct _grpc_gcp_AltsContext { |
||||
pb_callback_t application_protocol; |
||||
pb_callback_t record_protocol; |
||||
bool has_security_level; |
||||
grpc_gcp_SecurityLevel security_level; |
||||
pb_callback_t peer_service_account; |
||||
pb_callback_t local_service_account; |
||||
bool has_peer_rpc_versions; |
||||
grpc_gcp_RpcProtocolVersions peer_rpc_versions; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_AltsContext) */ |
||||
} grpc_gcp_AltsContext; |
||||
|
||||
/* Default values for struct fields */ |
||||
|
||||
/* Initializer values for message structs */ |
||||
#define grpc_gcp_AltsContext_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, (grpc_gcp_SecurityLevel)0, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_RpcProtocolVersions_init_default} |
||||
#define grpc_gcp_AltsContext_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, (grpc_gcp_SecurityLevel)0, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_RpcProtocolVersions_init_zero} |
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */ |
||||
#define grpc_gcp_AltsContext_application_protocol_tag 1 |
||||
#define grpc_gcp_AltsContext_record_protocol_tag 2 |
||||
#define grpc_gcp_AltsContext_security_level_tag 3 |
||||
#define grpc_gcp_AltsContext_peer_service_account_tag 4 |
||||
#define grpc_gcp_AltsContext_local_service_account_tag 5 |
||||
#define grpc_gcp_AltsContext_peer_rpc_versions_tag 6 |
||||
|
||||
/* Struct field encoding specification for nanopb */ |
||||
extern const pb_field_t grpc_gcp_AltsContext_fields[7]; |
||||
|
||||
/* Maximum encoded size of messages (where known) */ |
||||
/* grpc_gcp_AltsContext_size depends on runtime parameters */ |
||||
|
||||
/* Message IDs (where set with "msgid" option) */ |
||||
#ifdef PB_MSGID |
||||
|
||||
#define ALTSCONTEXT_MESSAGES \ |
||||
|
||||
|
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} /* extern "C" */ |
||||
#endif |
||||
/* @@protoc_insertion_point(eof) */ |
||||
|
||||
#endif |
@ -1,122 +0,0 @@ |
||||
/* Automatically generated nanopb constant definitions */ |
||||
/* Generated by nanopb-0.3.7-dev */ |
||||
|
||||
#include "src/core/tsi/alts/handshaker/handshaker.pb.h" |
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
|
||||
|
||||
const pb_field_t grpc_gcp_Endpoint_fields[4] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_gcp_Endpoint, ip_address, ip_address, 0), |
||||
PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_gcp_Endpoint, port, ip_address, 0), |
||||
PB_FIELD( 3, UENUM , OPTIONAL, STATIC , OTHER, grpc_gcp_Endpoint, protocol, port, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_Identity_fields[3] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_gcp_Identity, service_account, service_account, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_Identity, hostname, service_account, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_StartClientHandshakeReq_fields[10] = { |
||||
PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, grpc_gcp_StartClientHandshakeReq, handshake_security_protocol, handshake_security_protocol, 0), |
||||
PB_FIELD( 2, STRING , REPEATED, CALLBACK, OTHER, grpc_gcp_StartClientHandshakeReq, application_protocols, handshake_security_protocol, 0), |
||||
PB_FIELD( 3, STRING , REPEATED, CALLBACK, OTHER, grpc_gcp_StartClientHandshakeReq, record_protocols, application_protocols, 0), |
||||
PB_FIELD( 4, MESSAGE , REPEATED, CALLBACK, OTHER, grpc_gcp_StartClientHandshakeReq, target_identities, record_protocols, &grpc_gcp_Identity_fields), |
||||
PB_FIELD( 5, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartClientHandshakeReq, local_identity, target_identities, &grpc_gcp_Identity_fields), |
||||
PB_FIELD( 6, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartClientHandshakeReq, local_endpoint, local_identity, &grpc_gcp_Endpoint_fields), |
||||
PB_FIELD( 7, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartClientHandshakeReq, remote_endpoint, local_endpoint, &grpc_gcp_Endpoint_fields), |
||||
PB_FIELD( 8, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_StartClientHandshakeReq, target_name, remote_endpoint, 0), |
||||
PB_FIELD( 9, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartClientHandshakeReq, rpc_versions, target_name, &grpc_gcp_RpcProtocolVersions_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_ServerHandshakeParameters_fields[3] = { |
||||
PB_FIELD( 1, STRING , REPEATED, CALLBACK, FIRST, grpc_gcp_ServerHandshakeParameters, record_protocols, record_protocols, 0), |
||||
PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, grpc_gcp_ServerHandshakeParameters, local_identities, record_protocols, &grpc_gcp_Identity_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_StartServerHandshakeReq_fields[7] = { |
||||
PB_FIELD( 1, STRING , REPEATED, CALLBACK, FIRST, grpc_gcp_StartServerHandshakeReq, application_protocols, application_protocols, 0), |
||||
PB_FIELD( 2, MESSAGE , REPEATED, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq, handshake_parameters, application_protocols, &grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_fields), |
||||
PB_FIELD( 3, BYTES , OPTIONAL, CALLBACK, OTHER, grpc_gcp_StartServerHandshakeReq, in_bytes, handshake_parameters, 0), |
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq, local_endpoint, in_bytes, &grpc_gcp_Endpoint_fields), |
||||
PB_FIELD( 5, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq, remote_endpoint, local_endpoint, &grpc_gcp_Endpoint_fields), |
||||
PB_FIELD( 6, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq, rpc_versions, remote_endpoint, &grpc_gcp_RpcProtocolVersions_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_fields[3] = { |
||||
PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry, key, key, 0), |
||||
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry, value, key, &grpc_gcp_ServerHandshakeParameters_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_NextHandshakeMessageReq_fields[2] = { |
||||
PB_FIELD( 1, BYTES , OPTIONAL, CALLBACK, FIRST, grpc_gcp_NextHandshakeMessageReq, in_bytes, in_bytes, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_HandshakerReq_fields[4] = { |
||||
PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_gcp_HandshakerReq, client_start, client_start, &grpc_gcp_StartClientHandshakeReq_fields), |
||||
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerReq, server_start, client_start, &grpc_gcp_StartServerHandshakeReq_fields), |
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerReq, next, server_start, &grpc_gcp_NextHandshakeMessageReq_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_HandshakerResult_fields[8] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_gcp_HandshakerResult, application_protocol, application_protocol, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_HandshakerResult, record_protocol, application_protocol, 0), |
||||
PB_FIELD( 3, BYTES , OPTIONAL, CALLBACK, OTHER, grpc_gcp_HandshakerResult, key_data, record_protocol, 0), |
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResult, peer_identity, key_data, &grpc_gcp_Identity_fields), |
||||
PB_FIELD( 5, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResult, local_identity, peer_identity, &grpc_gcp_Identity_fields), |
||||
PB_FIELD( 6, BOOL , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResult, keep_channel_open, local_identity, 0), |
||||
PB_FIELD( 7, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResult, peer_rpc_versions, keep_channel_open, &grpc_gcp_RpcProtocolVersions_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_HandshakerStatus_fields[3] = { |
||||
PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, grpc_gcp_HandshakerStatus, code, code, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_HandshakerStatus, details, code, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_HandshakerResp_fields[5] = { |
||||
PB_FIELD( 1, BYTES , OPTIONAL, CALLBACK, FIRST, grpc_gcp_HandshakerResp, out_frames, out_frames, 0), |
||||
PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResp, bytes_consumed, out_frames, 0), |
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResp, result, bytes_consumed, &grpc_gcp_HandshakerResult_fields), |
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResp, status, result, &grpc_gcp_HandshakerStatus_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
|
||||
/* Check that field information fits in pb_field_t */ |
||||
#if !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_32BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in 8 or 16 bit |
||||
* field descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(grpc_gcp_StartClientHandshakeReq, target_identities) < 65536 && pb_membersize(grpc_gcp_StartClientHandshakeReq, local_identity) < 65536 && pb_membersize(grpc_gcp_StartClientHandshakeReq, local_endpoint) < 65536 && pb_membersize(grpc_gcp_StartClientHandshakeReq, remote_endpoint) < 65536 && pb_membersize(grpc_gcp_StartClientHandshakeReq, rpc_versions) < 65536 && pb_membersize(grpc_gcp_ServerHandshakeParameters, local_identities) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq, handshake_parameters[0]) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq, local_endpoint) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq, remote_endpoint) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq, rpc_versions) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry, value) < 65536 && pb_membersize(grpc_gcp_HandshakerReq, client_start) < 65536 && pb_membersize(grpc_gcp_HandshakerReq, server_start) < 65536 && pb_membersize(grpc_gcp_HandshakerReq, next) < 65536 && pb_membersize(grpc_gcp_HandshakerResult, peer_identity) < 65536 && pb_membersize(grpc_gcp_HandshakerResult, local_identity) < 65536 && pb_membersize(grpc_gcp_HandshakerResult, peer_rpc_versions) < 65536 && pb_membersize(grpc_gcp_HandshakerResp, result) < 65536 && pb_membersize(grpc_gcp_HandshakerResp, status) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_gcp_Endpoint_grpc_gcp_Identity_grpc_gcp_StartClientHandshakeReq_grpc_gcp_ServerHandshakeParameters_grpc_gcp_StartServerHandshakeReq_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_grpc_gcp_NextHandshakeMessageReq_grpc_gcp_HandshakerReq_grpc_gcp_HandshakerResult_grpc_gcp_HandshakerStatus_grpc_gcp_HandshakerResp) |
||||
#endif |
||||
|
||||
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_16BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in the default |
||||
* 8 bit descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(grpc_gcp_StartClientHandshakeReq, target_identities) < 256 && pb_membersize(grpc_gcp_StartClientHandshakeReq, local_identity) < 256 && pb_membersize(grpc_gcp_StartClientHandshakeReq, local_endpoint) < 256 && pb_membersize(grpc_gcp_StartClientHandshakeReq, remote_endpoint) < 256 && pb_membersize(grpc_gcp_StartClientHandshakeReq, rpc_versions) < 256 && pb_membersize(grpc_gcp_ServerHandshakeParameters, local_identities) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq, handshake_parameters[0]) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq, local_endpoint) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq, remote_endpoint) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq, rpc_versions) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry, value) < 256 && pb_membersize(grpc_gcp_HandshakerReq, client_start) < 256 && pb_membersize(grpc_gcp_HandshakerReq, server_start) < 256 && pb_membersize(grpc_gcp_HandshakerReq, next) < 256 && pb_membersize(grpc_gcp_HandshakerResult, peer_identity) < 256 && pb_membersize(grpc_gcp_HandshakerResult, local_identity) < 256 && pb_membersize(grpc_gcp_HandshakerResult, peer_rpc_versions) < 256 && pb_membersize(grpc_gcp_HandshakerResp, result) < 256 && pb_membersize(grpc_gcp_HandshakerResp, status) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_gcp_Endpoint_grpc_gcp_Identity_grpc_gcp_StartClientHandshakeReq_grpc_gcp_ServerHandshakeParameters_grpc_gcp_StartServerHandshakeReq_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_grpc_gcp_NextHandshakeMessageReq_grpc_gcp_HandshakerReq_grpc_gcp_HandshakerResult_grpc_gcp_HandshakerStatus_grpc_gcp_HandshakerResp) |
||||
#endif |
||||
|
||||
|
||||
/* @@protoc_insertion_point(eof) */ |
@ -1,254 +0,0 @@ |
||||
/* Automatically generated nanopb header */ |
||||
/* Generated by nanopb-0.3.7-dev */ |
||||
|
||||
#ifndef PB_GRPC_GCP_HANDSHAKER_PB_H_INCLUDED |
||||
#define PB_GRPC_GCP_HANDSHAKER_PB_H_INCLUDED |
||||
#include "pb.h" |
||||
#include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" |
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Enum definitions */ |
||||
typedef enum _grpc_gcp_HandshakeProtocol { |
||||
grpc_gcp_HandshakeProtocol_HANDSHAKE_PROTOCOL_UNSPECIFIED = 0, |
||||
grpc_gcp_HandshakeProtocol_TLS = 1, |
||||
grpc_gcp_HandshakeProtocol_ALTS = 2 |
||||
} grpc_gcp_HandshakeProtocol; |
||||
#define _grpc_gcp_HandshakeProtocol_MIN grpc_gcp_HandshakeProtocol_HANDSHAKE_PROTOCOL_UNSPECIFIED |
||||
#define _grpc_gcp_HandshakeProtocol_MAX grpc_gcp_HandshakeProtocol_ALTS |
||||
#define _grpc_gcp_HandshakeProtocol_ARRAYSIZE ((grpc_gcp_HandshakeProtocol)(grpc_gcp_HandshakeProtocol_ALTS+1)) |
||||
|
||||
typedef enum _grpc_gcp_NetworkProtocol { |
||||
grpc_gcp_NetworkProtocol_NETWORK_PROTOCOL_UNSPECIFIED = 0, |
||||
grpc_gcp_NetworkProtocol_TCP = 1, |
||||
grpc_gcp_NetworkProtocol_UDP = 2 |
||||
} grpc_gcp_NetworkProtocol; |
||||
#define _grpc_gcp_NetworkProtocol_MIN grpc_gcp_NetworkProtocol_NETWORK_PROTOCOL_UNSPECIFIED |
||||
#define _grpc_gcp_NetworkProtocol_MAX grpc_gcp_NetworkProtocol_UDP |
||||
#define _grpc_gcp_NetworkProtocol_ARRAYSIZE ((grpc_gcp_NetworkProtocol)(grpc_gcp_NetworkProtocol_UDP+1)) |
||||
|
||||
/* Struct definitions */ |
||||
typedef struct _grpc_gcp_Identity { |
||||
pb_callback_t service_account; |
||||
pb_callback_t hostname; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_Identity) */ |
||||
} grpc_gcp_Identity; |
||||
|
||||
typedef struct _grpc_gcp_NextHandshakeMessageReq { |
||||
pb_callback_t in_bytes; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_NextHandshakeMessageReq) */ |
||||
} grpc_gcp_NextHandshakeMessageReq; |
||||
|
||||
typedef struct _grpc_gcp_ServerHandshakeParameters { |
||||
pb_callback_t record_protocols; |
||||
pb_callback_t local_identities; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_ServerHandshakeParameters) */ |
||||
} grpc_gcp_ServerHandshakeParameters; |
||||
|
||||
typedef struct _grpc_gcp_Endpoint { |
||||
pb_callback_t ip_address; |
||||
bool has_port; |
||||
int32_t port; |
||||
bool has_protocol; |
||||
grpc_gcp_NetworkProtocol protocol; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_Endpoint) */ |
||||
} grpc_gcp_Endpoint; |
||||
|
||||
typedef struct _grpc_gcp_HandshakerResult { |
||||
pb_callback_t application_protocol; |
||||
pb_callback_t record_protocol; |
||||
pb_callback_t key_data; |
||||
bool has_peer_identity; |
||||
grpc_gcp_Identity peer_identity; |
||||
bool has_local_identity; |
||||
grpc_gcp_Identity local_identity; |
||||
bool has_keep_channel_open; |
||||
bool keep_channel_open; |
||||
bool has_peer_rpc_versions; |
||||
grpc_gcp_RpcProtocolVersions peer_rpc_versions; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_HandshakerResult) */ |
||||
} grpc_gcp_HandshakerResult; |
||||
|
||||
typedef struct _grpc_gcp_HandshakerStatus { |
||||
bool has_code; |
||||
uint32_t code; |
||||
pb_callback_t details; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_HandshakerStatus) */ |
||||
} grpc_gcp_HandshakerStatus; |
||||
|
||||
typedef struct _grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry { |
||||
bool has_key; |
||||
int32_t key; |
||||
bool has_value; |
||||
grpc_gcp_ServerHandshakeParameters value; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry) */ |
||||
} grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry; |
||||
|
||||
typedef struct _grpc_gcp_HandshakerResp { |
||||
pb_callback_t out_frames; |
||||
bool has_bytes_consumed; |
||||
uint32_t bytes_consumed; |
||||
bool has_result; |
||||
grpc_gcp_HandshakerResult result; |
||||
bool has_status; |
||||
grpc_gcp_HandshakerStatus status; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_HandshakerResp) */ |
||||
} grpc_gcp_HandshakerResp; |
||||
|
||||
typedef struct _grpc_gcp_StartClientHandshakeReq { |
||||
bool has_handshake_security_protocol; |
||||
grpc_gcp_HandshakeProtocol handshake_security_protocol; |
||||
pb_callback_t application_protocols; |
||||
pb_callback_t record_protocols; |
||||
pb_callback_t target_identities; |
||||
bool has_local_identity; |
||||
grpc_gcp_Identity local_identity; |
||||
bool has_local_endpoint; |
||||
grpc_gcp_Endpoint local_endpoint; |
||||
bool has_remote_endpoint; |
||||
grpc_gcp_Endpoint remote_endpoint; |
||||
pb_callback_t target_name; |
||||
bool has_rpc_versions; |
||||
grpc_gcp_RpcProtocolVersions rpc_versions; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_StartClientHandshakeReq) */ |
||||
} grpc_gcp_StartClientHandshakeReq; |
||||
|
||||
typedef struct _grpc_gcp_StartServerHandshakeReq { |
||||
pb_callback_t application_protocols; |
||||
pb_size_t handshake_parameters_count; |
||||
grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry handshake_parameters[3]; |
||||
pb_callback_t in_bytes; |
||||
bool has_local_endpoint; |
||||
grpc_gcp_Endpoint local_endpoint; |
||||
bool has_remote_endpoint; |
||||
grpc_gcp_Endpoint remote_endpoint; |
||||
bool has_rpc_versions; |
||||
grpc_gcp_RpcProtocolVersions rpc_versions; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_StartServerHandshakeReq) */ |
||||
} grpc_gcp_StartServerHandshakeReq; |
||||
|
||||
typedef struct _grpc_gcp_HandshakerReq { |
||||
bool has_client_start; |
||||
grpc_gcp_StartClientHandshakeReq client_start; |
||||
bool has_server_start; |
||||
grpc_gcp_StartServerHandshakeReq server_start; |
||||
bool has_next; |
||||
grpc_gcp_NextHandshakeMessageReq next; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_HandshakerReq) */ |
||||
} grpc_gcp_HandshakerReq; |
||||
|
||||
/* Default values for struct fields */ |
||||
|
||||
/* Initializer values for message structs */ |
||||
#define grpc_gcp_Endpoint_init_default {{{NULL}, NULL}, false, 0, false, (grpc_gcp_NetworkProtocol)0} |
||||
#define grpc_gcp_Identity_init_default {{{NULL}, NULL}, {{NULL}, NULL}} |
||||
#define grpc_gcp_StartClientHandshakeReq_init_default {false, (grpc_gcp_HandshakeProtocol)0, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_Identity_init_default, false, grpc_gcp_Endpoint_init_default, false, grpc_gcp_Endpoint_init_default, {{NULL}, NULL}, false, grpc_gcp_RpcProtocolVersions_init_default} |
||||
#define grpc_gcp_ServerHandshakeParameters_init_default {{{NULL}, NULL}, {{NULL}, NULL}} |
||||
#define grpc_gcp_StartServerHandshakeReq_init_default {{{NULL}, NULL}, 0, {grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_default, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_default, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_default}, {{NULL}, NULL}, false, grpc_gcp_Endpoint_init_default, false, grpc_gcp_Endpoint_init_default, false, grpc_gcp_RpcProtocolVersions_init_default} |
||||
#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_default {false, 0, false, grpc_gcp_ServerHandshakeParameters_init_default} |
||||
#define grpc_gcp_NextHandshakeMessageReq_init_default {{{NULL}, NULL}} |
||||
#define grpc_gcp_HandshakerReq_init_default {false, grpc_gcp_StartClientHandshakeReq_init_default, false, grpc_gcp_StartServerHandshakeReq_init_default, false, grpc_gcp_NextHandshakeMessageReq_init_default} |
||||
#define grpc_gcp_HandshakerResult_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_Identity_init_default, false, grpc_gcp_Identity_init_default, false, 0, false, grpc_gcp_RpcProtocolVersions_init_default} |
||||
#define grpc_gcp_HandshakerStatus_init_default {false, 0, {{NULL}, NULL}} |
||||
#define grpc_gcp_HandshakerResp_init_default {{{NULL}, NULL}, false, 0, false, grpc_gcp_HandshakerResult_init_default, false, grpc_gcp_HandshakerStatus_init_default} |
||||
#define grpc_gcp_Endpoint_init_zero {{{NULL}, NULL}, false, 0, false, (grpc_gcp_NetworkProtocol)0} |
||||
#define grpc_gcp_Identity_init_zero {{{NULL}, NULL}, {{NULL}, NULL}} |
||||
#define grpc_gcp_StartClientHandshakeReq_init_zero {false, (grpc_gcp_HandshakeProtocol)0, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_Identity_init_zero, false, grpc_gcp_Endpoint_init_zero, false, grpc_gcp_Endpoint_init_zero, {{NULL}, NULL}, false, grpc_gcp_RpcProtocolVersions_init_zero} |
||||
#define grpc_gcp_ServerHandshakeParameters_init_zero {{{NULL}, NULL}, {{NULL}, NULL}} |
||||
#define grpc_gcp_StartServerHandshakeReq_init_zero {{{NULL}, NULL}, 0, {grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_zero, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_zero, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_zero}, {{NULL}, NULL}, false, grpc_gcp_Endpoint_init_zero, false, grpc_gcp_Endpoint_init_zero, false, grpc_gcp_RpcProtocolVersions_init_zero} |
||||
#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_zero {false, 0, false, grpc_gcp_ServerHandshakeParameters_init_zero} |
||||
#define grpc_gcp_NextHandshakeMessageReq_init_zero {{{NULL}, NULL}} |
||||
#define grpc_gcp_HandshakerReq_init_zero {false, grpc_gcp_StartClientHandshakeReq_init_zero, false, grpc_gcp_StartServerHandshakeReq_init_zero, false, grpc_gcp_NextHandshakeMessageReq_init_zero} |
||||
#define grpc_gcp_HandshakerResult_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_Identity_init_zero, false, grpc_gcp_Identity_init_zero, false, 0, false, grpc_gcp_RpcProtocolVersions_init_zero} |
||||
#define grpc_gcp_HandshakerStatus_init_zero {false, 0, {{NULL}, NULL}} |
||||
#define grpc_gcp_HandshakerResp_init_zero {{{NULL}, NULL}, false, 0, false, grpc_gcp_HandshakerResult_init_zero, false, grpc_gcp_HandshakerStatus_init_zero} |
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */ |
||||
#define grpc_gcp_Identity_service_account_tag 1 |
||||
#define grpc_gcp_Identity_hostname_tag 2 |
||||
#define grpc_gcp_NextHandshakeMessageReq_in_bytes_tag 1 |
||||
#define grpc_gcp_ServerHandshakeParameters_record_protocols_tag 1 |
||||
#define grpc_gcp_ServerHandshakeParameters_local_identities_tag 2 |
||||
#define grpc_gcp_Endpoint_ip_address_tag 1 |
||||
#define grpc_gcp_Endpoint_port_tag 2 |
||||
#define grpc_gcp_Endpoint_protocol_tag 3 |
||||
#define grpc_gcp_HandshakerResult_application_protocol_tag 1 |
||||
#define grpc_gcp_HandshakerResult_record_protocol_tag 2 |
||||
#define grpc_gcp_HandshakerResult_key_data_tag 3 |
||||
#define grpc_gcp_HandshakerResult_peer_identity_tag 4 |
||||
#define grpc_gcp_HandshakerResult_local_identity_tag 5 |
||||
#define grpc_gcp_HandshakerResult_keep_channel_open_tag 6 |
||||
#define grpc_gcp_HandshakerResult_peer_rpc_versions_tag 7 |
||||
#define grpc_gcp_HandshakerStatus_code_tag 1 |
||||
#define grpc_gcp_HandshakerStatus_details_tag 2 |
||||
#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_key_tag 1 |
||||
#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_value_tag 2 |
||||
#define grpc_gcp_HandshakerResp_out_frames_tag 1 |
||||
#define grpc_gcp_HandshakerResp_bytes_consumed_tag 2 |
||||
#define grpc_gcp_HandshakerResp_result_tag 3 |
||||
#define grpc_gcp_HandshakerResp_status_tag 4 |
||||
#define grpc_gcp_StartClientHandshakeReq_handshake_security_protocol_tag 1 |
||||
#define grpc_gcp_StartClientHandshakeReq_application_protocols_tag 2 |
||||
#define grpc_gcp_StartClientHandshakeReq_record_protocols_tag 3 |
||||
#define grpc_gcp_StartClientHandshakeReq_target_identities_tag 4 |
||||
#define grpc_gcp_StartClientHandshakeReq_local_identity_tag 5 |
||||
#define grpc_gcp_StartClientHandshakeReq_local_endpoint_tag 6 |
||||
#define grpc_gcp_StartClientHandshakeReq_remote_endpoint_tag 7 |
||||
#define grpc_gcp_StartClientHandshakeReq_target_name_tag 8 |
||||
#define grpc_gcp_StartClientHandshakeReq_rpc_versions_tag 9 |
||||
#define grpc_gcp_StartServerHandshakeReq_application_protocols_tag 1 |
||||
#define grpc_gcp_StartServerHandshakeReq_handshake_parameters_tag 2 |
||||
#define grpc_gcp_StartServerHandshakeReq_in_bytes_tag 3 |
||||
#define grpc_gcp_StartServerHandshakeReq_local_endpoint_tag 4 |
||||
#define grpc_gcp_StartServerHandshakeReq_remote_endpoint_tag 5 |
||||
#define grpc_gcp_StartServerHandshakeReq_rpc_versions_tag 6 |
||||
#define grpc_gcp_HandshakerReq_client_start_tag 1 |
||||
#define grpc_gcp_HandshakerReq_server_start_tag 2 |
||||
#define grpc_gcp_HandshakerReq_next_tag 3 |
||||
|
||||
/* Struct field encoding specification for nanopb */ |
||||
extern const pb_field_t grpc_gcp_Endpoint_fields[4]; |
||||
extern const pb_field_t grpc_gcp_Identity_fields[3]; |
||||
extern const pb_field_t grpc_gcp_StartClientHandshakeReq_fields[10]; |
||||
extern const pb_field_t grpc_gcp_ServerHandshakeParameters_fields[3]; |
||||
extern const pb_field_t grpc_gcp_StartServerHandshakeReq_fields[7]; |
||||
extern const pb_field_t grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_fields[3]; |
||||
extern const pb_field_t grpc_gcp_NextHandshakeMessageReq_fields[2]; |
||||
extern const pb_field_t grpc_gcp_HandshakerReq_fields[4]; |
||||
extern const pb_field_t grpc_gcp_HandshakerResult_fields[8]; |
||||
extern const pb_field_t grpc_gcp_HandshakerStatus_fields[3]; |
||||
extern const pb_field_t grpc_gcp_HandshakerResp_fields[5]; |
||||
|
||||
/* Maximum encoded size of messages (where known) */ |
||||
/* grpc_gcp_Endpoint_size depends on runtime parameters */ |
||||
/* grpc_gcp_Identity_size depends on runtime parameters */ |
||||
/* grpc_gcp_StartClientHandshakeReq_size depends on runtime parameters */ |
||||
/* grpc_gcp_ServerHandshakeParameters_size depends on runtime parameters */ |
||||
/* grpc_gcp_StartServerHandshakeReq_size depends on runtime parameters */ |
||||
#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_size (17 + grpc_gcp_ServerHandshakeParameters_size) |
||||
/* grpc_gcp_NextHandshakeMessageReq_size depends on runtime parameters */ |
||||
#define grpc_gcp_HandshakerReq_size (18 + grpc_gcp_StartClientHandshakeReq_size + grpc_gcp_StartServerHandshakeReq_size + grpc_gcp_NextHandshakeMessageReq_size) |
||||
/* grpc_gcp_HandshakerResult_size depends on runtime parameters */ |
||||
/* grpc_gcp_HandshakerStatus_size depends on runtime parameters */ |
||||
/* grpc_gcp_HandshakerResp_size depends on runtime parameters */ |
||||
|
||||
/* Message IDs (where set with "msgid" option) */ |
||||
#ifdef PB_MSGID |
||||
|
||||
#define HANDSHAKER_MESSAGES \ |
||||
|
||||
|
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} /* extern "C" */ |
||||
#endif |
||||
/* @@protoc_insertion_point(eof) */ |
||||
|
||||
#endif |
@ -1,49 +0,0 @@ |
||||
/* Automatically generated nanopb constant definitions */ |
||||
/* Generated by nanopb-0.3.7-dev */ |
||||
|
||||
#include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" |
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
|
||||
|
||||
const pb_field_t grpc_gcp_RpcProtocolVersions_fields[3] = { |
||||
PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_gcp_RpcProtocolVersions, max_rpc_version, max_rpc_version, &grpc_gcp_RpcProtocolVersions_Version_fields), |
||||
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_RpcProtocolVersions, min_rpc_version, max_rpc_version, &grpc_gcp_RpcProtocolVersions_Version_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_gcp_RpcProtocolVersions_Version_fields[3] = { |
||||
PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, grpc_gcp_RpcProtocolVersions_Version, major, major, 0), |
||||
PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, grpc_gcp_RpcProtocolVersions_Version, minor, major, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
|
||||
/* Check that field information fits in pb_field_t */ |
||||
#if !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_32BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in 8 or 16 bit |
||||
* field descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(grpc_gcp_RpcProtocolVersions, max_rpc_version) < 65536 && pb_membersize(grpc_gcp_RpcProtocolVersions, min_rpc_version) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_gcp_RpcProtocolVersions_grpc_gcp_RpcProtocolVersions_Version) |
||||
#endif |
||||
|
||||
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_16BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in the default |
||||
* 8 bit descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(grpc_gcp_RpcProtocolVersions, max_rpc_version) < 256 && pb_membersize(grpc_gcp_RpcProtocolVersions, min_rpc_version) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_gcp_RpcProtocolVersions_grpc_gcp_RpcProtocolVersions_Version) |
||||
#endif |
||||
|
||||
|
||||
/* @@protoc_insertion_point(eof) */ |
@ -1,78 +0,0 @@ |
||||
/* Automatically generated nanopb header */ |
||||
/* Generated by nanopb-0.3.7-dev */ |
||||
|
||||
#ifndef PB_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PB_H_INCLUDED |
||||
#define PB_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PB_H_INCLUDED |
||||
#include "pb.h" |
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Enum definitions */ |
||||
typedef enum _grpc_gcp_SecurityLevel { |
||||
grpc_gcp_SecurityLevel_SECURITY_NONE = 0, |
||||
grpc_gcp_SecurityLevel_INTEGRITY_ONLY = 1, |
||||
grpc_gcp_SecurityLevel_INTEGRITY_AND_PRIVACY = 2 |
||||
} grpc_gcp_SecurityLevel; |
||||
#define _grpc_gcp_SecurityLevel_MIN grpc_gcp_SecurityLevel_SECURITY_NONE |
||||
#define _grpc_gcp_SecurityLevel_MAX grpc_gcp_SecurityLevel_INTEGRITY_AND_PRIVACY |
||||
#define _grpc_gcp_SecurityLevel_ARRAYSIZE ((grpc_gcp_SecurityLevel)(grpc_gcp_SecurityLevel_INTEGRITY_AND_PRIVACY+1)) |
||||
|
||||
/* Struct definitions */ |
||||
typedef struct _grpc_gcp_RpcProtocolVersions_Version { |
||||
bool has_major; |
||||
uint32_t major; |
||||
bool has_minor; |
||||
uint32_t minor; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_RpcProtocolVersions_Version) */ |
||||
} grpc_gcp_RpcProtocolVersions_Version; |
||||
|
||||
typedef struct _grpc_gcp_RpcProtocolVersions { |
||||
bool has_max_rpc_version; |
||||
grpc_gcp_RpcProtocolVersions_Version max_rpc_version; |
||||
bool has_min_rpc_version; |
||||
grpc_gcp_RpcProtocolVersions_Version min_rpc_version; |
||||
/* @@protoc_insertion_point(struct:grpc_gcp_RpcProtocolVersions) */ |
||||
} grpc_gcp_RpcProtocolVersions; |
||||
|
||||
/* Default values for struct fields */ |
||||
|
||||
/* Initializer values for message structs */ |
||||
#define grpc_gcp_RpcProtocolVersions_init_default {false, grpc_gcp_RpcProtocolVersions_Version_init_default, false, grpc_gcp_RpcProtocolVersions_Version_init_default} |
||||
#define grpc_gcp_RpcProtocolVersions_Version_init_default {false, 0, false, 0} |
||||
#define grpc_gcp_RpcProtocolVersions_init_zero {false, grpc_gcp_RpcProtocolVersions_Version_init_zero, false, grpc_gcp_RpcProtocolVersions_Version_init_zero} |
||||
#define grpc_gcp_RpcProtocolVersions_Version_init_zero {false, 0, false, 0} |
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */ |
||||
#define grpc_gcp_RpcProtocolVersions_Version_major_tag 1 |
||||
#define grpc_gcp_RpcProtocolVersions_Version_minor_tag 2 |
||||
#define grpc_gcp_RpcProtocolVersions_max_rpc_version_tag 1 |
||||
#define grpc_gcp_RpcProtocolVersions_min_rpc_version_tag 2 |
||||
|
||||
/* Struct field encoding specification for nanopb */ |
||||
extern const pb_field_t grpc_gcp_RpcProtocolVersions_fields[3]; |
||||
extern const pb_field_t grpc_gcp_RpcProtocolVersions_Version_fields[3]; |
||||
|
||||
/* Maximum encoded size of messages (where known) */ |
||||
#define grpc_gcp_RpcProtocolVersions_size 28 |
||||
#define grpc_gcp_RpcProtocolVersions_Version_size 12 |
||||
|
||||
/* Message IDs (where set with "msgid" option) */ |
||||
#ifdef PB_MSGID |
||||
|
||||
#define TRANSPORT_SECURITY_COMMON_MESSAGES \ |
||||
|
||||
|
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} /* extern "C" */ |
||||
#endif |
||||
/* @@protoc_insertion_point(eof) */ |
||||
|
||||
#endif |
@ -1,149 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2018 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include <stdbool.h> |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
|
||||
#include "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h" |
||||
|
||||
int main(int argc, char** argv) { |
||||
const char in_bytes[] = "HELLO GOOGLE!"; |
||||
const char out_frames[] = "HELLO WORLD!"; |
||||
const char key_data[] = "THIS IS KEY DATA."; |
||||
const char details[] = "DETAILS NEED TO BE POPULATED"; |
||||
const uint32_t max_rpc_version_major = 3; |
||||
const uint32_t max_rpc_version_minor = 2; |
||||
const uint32_t min_rpc_version_major = 2; |
||||
const uint32_t min_rpc_version_minor = 1; |
||||
|
||||
/* handshaker_req_next. */ |
||||
grpc_gcp_handshaker_req* req = grpc_gcp_handshaker_req_create(NEXT_REQ); |
||||
grpc_gcp_handshaker_req* decoded_req = |
||||
grpc_gcp_handshaker_decoded_req_create(NEXT_REQ); |
||||
GPR_ASSERT( |
||||
grpc_gcp_handshaker_req_set_in_bytes(req, in_bytes, strlen(in_bytes))); |
||||
grpc_slice encoded_req; |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_encode(req, &encoded_req)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_decode(encoded_req, decoded_req)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_equals(req, decoded_req)); |
||||
grpc_gcp_handshaker_req_destroy(req); |
||||
grpc_gcp_handshaker_req_destroy(decoded_req); |
||||
grpc_slice_unref(encoded_req); |
||||
|
||||
/* handshaker_req_client_start. */ |
||||
req = grpc_gcp_handshaker_req_create(CLIENT_START_REQ); |
||||
decoded_req = grpc_gcp_handshaker_decoded_req_create(CLIENT_START_REQ); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_handshake_protocol( |
||||
req, grpc_gcp_HandshakeProtocol_TLS)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_local_identity_hostname( |
||||
req, "www.google.com")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_local_endpoint( |
||||
req, "2001:db8::8:800:200C:417a", 9876, grpc_gcp_NetworkProtocol_TCP)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_remote_endpoint( |
||||
req, "2001:db8::bac5::fed0:84a2", 1234, grpc_gcp_NetworkProtocol_TCP)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_add_application_protocol(req, "grpc")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_add_application_protocol(req, "http2")); |
||||
GPR_ASSERT( |
||||
grpc_gcp_handshaker_req_add_record_protocol(req, "ALTSRP_GCM_AES256")); |
||||
GPR_ASSERT( |
||||
grpc_gcp_handshaker_req_add_record_protocol(req, "ALTSRP_GCM_AES384")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_add_target_identity_service_account( |
||||
req, "foo@google.com")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_target_name( |
||||
req, "google.example.library.service")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_rpc_versions( |
||||
req, max_rpc_version_major, max_rpc_version_minor, min_rpc_version_major, |
||||
min_rpc_version_minor)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_encode(req, &encoded_req)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_decode(encoded_req, decoded_req)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_equals(req, decoded_req)); |
||||
grpc_gcp_handshaker_req_destroy(req); |
||||
grpc_gcp_handshaker_req_destroy(decoded_req); |
||||
grpc_slice_unref(encoded_req); |
||||
|
||||
/* handshaker_req_server_start. */ |
||||
req = grpc_gcp_handshaker_req_create(SERVER_START_REQ); |
||||
decoded_req = grpc_gcp_handshaker_decoded_req_create(SERVER_START_REQ); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_add_application_protocol(req, "grpc")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_add_application_protocol(req, "http2")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_local_endpoint( |
||||
req, "2001:db8::8:800:200C:417a", 9876, grpc_gcp_NetworkProtocol_TCP)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_remote_endpoint( |
||||
req, "2001:db8::bac5::fed0:84a2", 1234, grpc_gcp_NetworkProtocol_UDP)); |
||||
GPR_ASSERT( |
||||
grpc_gcp_handshaker_req_set_in_bytes(req, in_bytes, strlen(in_bytes))); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_param_add_record_protocol( |
||||
req, grpc_gcp_HandshakeProtocol_TLS, "ALTSRP_GCM_AES128")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_param_add_local_identity_service_account( |
||||
req, grpc_gcp_HandshakeProtocol_TLS, "foo@google.com")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_param_add_local_identity_hostname( |
||||
req, grpc_gcp_HandshakeProtocol_TLS, "yihuaz0.mtv.corp.google.com")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_param_add_record_protocol( |
||||
req, grpc_gcp_HandshakeProtocol_ALTS, "ALTSRP_GCM_AES128")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_param_add_local_identity_hostname( |
||||
req, grpc_gcp_HandshakeProtocol_ALTS, "www.amazon.com")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_set_rpc_versions( |
||||
req, max_rpc_version_major, max_rpc_version_minor, min_rpc_version_major, |
||||
min_rpc_version_minor)); |
||||
|
||||
GPR_ASSERT(grpc_gcp_handshaker_req_encode(req, &encoded_req)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_decode(encoded_req, decoded_req)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_req_equals(req, decoded_req)); |
||||
grpc_gcp_handshaker_req_destroy(req); |
||||
grpc_gcp_handshaker_req_destroy(decoded_req); |
||||
grpc_slice_unref(encoded_req); |
||||
|
||||
/* handshaker_resp. */ |
||||
grpc_gcp_handshaker_resp* resp = grpc_gcp_handshaker_resp_create(); |
||||
grpc_gcp_handshaker_resp* decoded_resp = grpc_gcp_handshaker_resp_create(); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_out_frames(resp, out_frames, |
||||
strlen(out_frames))); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_bytes_consumed(resp, 1024)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_application_protocol(resp, "http")); |
||||
GPR_ASSERT( |
||||
grpc_gcp_handshaker_resp_set_record_protocol(resp, "ALTSRP_GCM_AES128")); |
||||
GPR_ASSERT( |
||||
grpc_gcp_handshaker_resp_set_key_data(resp, key_data, strlen(key_data))); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_local_identity_hostname( |
||||
resp, "www.faceboook.com")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_identity_hostname( |
||||
resp, "www.amazon.com")); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_channel_open( |
||||
resp, false /* channel_open */)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_code(resp, 1023)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_details(resp, details)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_rpc_versions( |
||||
resp, max_rpc_version_major, max_rpc_version_minor, min_rpc_version_major, |
||||
min_rpc_version_minor)); |
||||
grpc_slice encoded_resp; |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_encode(resp, &encoded_resp)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_decode(encoded_resp, decoded_resp)); |
||||
GPR_ASSERT(grpc_gcp_handshaker_resp_equals(resp, decoded_resp)); |
||||
grpc_gcp_handshaker_resp_destroy(resp); |
||||
grpc_gcp_handshaker_resp_destroy(decoded_resp); |
||||
grpc_slice_unref(encoded_resp); |
||||
/* Test invalid arguments. */ |
||||
GPR_ASSERT(!grpc_gcp_handshaker_req_set_in_bytes(nullptr, in_bytes, |
||||
strlen(in_bytes))); |
||||
GPR_ASSERT(!grpc_gcp_handshaker_req_param_add_record_protocol( |
||||
req, grpc_gcp_HandshakeProtocol_TLS, nullptr)); |
||||
GPR_ASSERT(!grpc_gcp_handshaker_req_param_add_local_identity_service_account( |
||||
nullptr, grpc_gcp_HandshakeProtocol_TLS, nullptr)); |
||||
GPR_ASSERT(!grpc_gcp_handshaker_resp_set_record_protocol(nullptr, nullptr)); |
||||
} |
Loading…
Reference in new issue