1 /* 2 * 3 * Copyright 2015 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_PARSE_ADDRESS_H 20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H 21 22 #include <grpc/support/port_platform.h> 23 24 #include <stddef.h> 25 26 #include "src/core/ext/filters/client_channel/uri_parser.h" 27 #include "src/core/lib/iomgr/resolve_address.h" 28 29 /** Populate \a resolved_addr from \a uri, whose path is expected to contain a 30 * unix socket path. Returns true upon success. */ 31 bool grpc_parse_unix(const grpc_uri* uri, grpc_resolved_address* resolved_addr); 32 33 /** Populate \a resolved_addr from \a uri, whose path is expected to contain an 34 * IPv4 host:port pair. Returns true upon success. */ 35 bool grpc_parse_ipv4(const grpc_uri* uri, grpc_resolved_address* resolved_addr); 36 37 /** Populate \a resolved_addr from \a uri, whose path is expected to contain an 38 * IPv6 host:port pair. Returns true upon success. */ 39 bool grpc_parse_ipv6(const grpc_uri* uri, grpc_resolved_address* resolved_addr); 40 41 /** Populate \a resolved_addr from \a uri. Returns true upon success. */ 42 bool grpc_parse_uri(const grpc_uri* uri, grpc_resolved_address* resolved_addr); 43 44 /** Parse bare IPv4 or IPv6 "IP:port" strings. */ 45 bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, 46 bool log_errors); 47 bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, 48 bool log_errors); 49 50 /* Converts named or numeric port to a uint16 suitable for use in a sockaddr. */ 51 uint16_t grpc_strhtons(const char* port); 52 53 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */ 54