1 /* 2 * 3 * Copyright 2017 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H 20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H 21 22 #include <grpc/support/port_platform.h> 23 24 #include <stdbool.h> 25 26 #include <grpc/impl/codegen/grpc_types.h> 27 28 #include "src/core/lib/iomgr/resolve_address.h" 29 30 typedef struct grpc_proxy_mapper grpc_proxy_mapper; 31 32 typedef struct { 33 /// Determines the proxy name to resolve for \a server_uri. 34 /// If no proxy is needed, returns false. 35 /// Otherwise, sets \a name_to_resolve, optionally sets \a new_args, 36 /// and returns true. 37 bool (*map_name)(grpc_proxy_mapper* mapper, const char* server_uri, 38 const grpc_channel_args* args, char** name_to_resolve, 39 grpc_channel_args** new_args); 40 /// Determines the proxy address to use to contact \a address. 41 /// If no proxy is needed, returns false. 42 /// Otherwise, sets \a new_address, optionally sets \a new_args, and 43 /// returns true. 44 bool (*map_address)(grpc_proxy_mapper* mapper, 45 const grpc_resolved_address* address, 46 const grpc_channel_args* args, 47 grpc_resolved_address** new_address, 48 grpc_channel_args** new_args); 49 /// Destroys \a mapper. 50 void (*destroy)(grpc_proxy_mapper* mapper); 51 } grpc_proxy_mapper_vtable; 52 53 struct grpc_proxy_mapper { 54 const grpc_proxy_mapper_vtable* vtable; 55 }; 56 57 void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable, 58 grpc_proxy_mapper* mapper); 59 60 bool grpc_proxy_mapper_map_name(grpc_proxy_mapper* mapper, 61 const char* server_uri, 62 const grpc_channel_args* args, 63 char** name_to_resolve, 64 grpc_channel_args** new_args); 65 66 bool grpc_proxy_mapper_map_address(grpc_proxy_mapper* mapper, 67 const grpc_resolved_address* address, 68 const grpc_channel_args* args, 69 grpc_resolved_address** new_address, 70 grpc_channel_args** new_args); 71 72 void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper); 73 74 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H */ 75