3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H
20 #define GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H
22 #include <grpc/support/port_platform.h>
26 #include "src/core/lib/iomgr/port.h"
32 #ifdef GRPC_WINSOCK_SOCKET
36 #if defined(GRPC_POSIX_SOCKET) || defined(GRPC_CFSTREAM)
37 #include <sys/socket.h>
40 #include "src/core/lib/iomgr/pollset_set.h"
42 #define GRPC_MAX_SOCKADDR_SIZE 128
44 struct grpc_resolved_address {
45 char addr[GRPC_MAX_SOCKADDR_SIZE];
48 struct grpc_resolved_addresses {
50 grpc_resolved_address* addrs;
52 typedef struct grpc_address_resolver_vtable {
53 void (*resolve_address)(const char* addr, const char* default_port,
54 grpc_pollset_set* interested_parties,
55 grpc_closure* on_done,
56 grpc_resolved_addresses** addresses);
57 grpc_error_handle (*blocking_resolve_address)(
58 const char* name, const char* default_port,
59 grpc_resolved_addresses** addresses);
60 } grpc_address_resolver_vtable;
62 void grpc_set_resolver_impl(grpc_address_resolver_vtable* vtable);
64 /* Asynchronously resolve addr. Use default_port if a port isn't designated
65 in addr, otherwise use the port in addr. */
66 /* TODO(apolcyn): add a timeout here */
67 void grpc_resolve_address(const char* addr, const char* default_port,
68 grpc_pollset_set* interested_parties,
69 grpc_closure* on_done,
70 grpc_resolved_addresses** addresses);
72 /* Destroy resolved addresses */
73 void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addresses);
75 /* Resolve addr in a blocking fashion. On success,
76 result must be freed with grpc_resolved_addresses_destroy. */
77 grpc_error_handle grpc_blocking_resolve_address(
78 const char* name, const char* default_port,
79 grpc_resolved_addresses** addresses);
81 #endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */