chromium/third_party/grpc/src/src/core/tsi/transport_security.h

//
//
// Copyright 2015 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_SRC_CORE_TSI_TRANSPORT_SECURITY_H
#define GRPC_SRC_CORE_TSI_TRANSPORT_SECURITY_H

#include <grpc/support/port_platform.h>

#include <stdbool.h>

#include "src/core/lib/debug/trace.h"
#include "src/core/tsi/transport_security_interface.h"

extern grpc_core::TraceFlag tsi_tracing_enabled;

// Base for tsi_frame_protector implementations.
// See transport_security_interface.h for documentation.
// All methods must be implemented.
struct tsi_frame_protector_vtable {};
struct tsi_frame_protector {};

// Base for tsi_handshaker implementations.
// See transport_security_interface.h for documentation.
struct tsi_handshaker_vtable {};
struct tsi_handshaker {};

// Base for tsi_handshaker_result implementations.
// See transport_security_interface.h for documentation.
// The exec_ctx parameter in create_zero_copy_grpc_protector is supposed to be
// of type grpc_exec_ctx*, but we're using void* instead to avoid making the TSI
// API depend on grpc. The create_zero_copy_grpc_protector() method is only used
// in grpc, where we do need the exec_ctx passed through, but the API still
// needs to compile in other applications, where grpc_exec_ctx is not defined.
// All methods must be non-null, except where noted below.
//
struct tsi_handshaker_result_vtable {};
struct tsi_handshaker_result {};

// Peer and property construction/destruction functions.
tsi_result tsi_construct_peer(size_t property_count, tsi_peer* peer);
tsi_peer_property tsi_init_peer_property(void);
void tsi_peer_property_destruct(tsi_peer_property* property);
tsi_result tsi_construct_string_peer_property(const char* name,
                                              const char* value,
                                              size_t value_length,
                                              tsi_peer_property* property);
tsi_result tsi_construct_allocated_string_peer_property(
    const char* name, size_t value_length, tsi_peer_property* property);
tsi_result tsi_construct_string_peer_property_from_cstring(
    const char* name, const char* value, tsi_peer_property* property);
const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* peer,
                                                       const char* name);
// Utils.
char* tsi_strdup(const char* src);  // Sadly, no strdup in C89.

#endif  // GRPC_SRC_CORE_TSI_TRANSPORT_SECURITY_H