Imported Upstream version 1.41.0
[platform/upstream/grpc.git] / src / core / lib / iomgr / resolve_address.cc
1 /*
2  *
3  * Copyright 2018 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 #include <grpc/support/port_platform.h>
19
20 #include "src/core/lib/iomgr/resolve_address.h"
21
22 #include <grpc/event_engine/event_engine.h>
23 #include <grpc/support/alloc.h>
24
25 namespace grpc_core {
26 const char* kDefaultSecurePort = "https";
27 }  // namespace grpc_core
28
29 grpc_address_resolver_vtable* grpc_resolve_address_impl;
30
31 void grpc_set_resolver_impl(grpc_address_resolver_vtable* vtable) {
32   grpc_resolve_address_impl = vtable;
33 }
34
35 void grpc_resolve_address(const char* addr, const char* default_port,
36                           grpc_pollset_set* interested_parties,
37                           grpc_closure* on_done,
38                           grpc_resolved_addresses** addresses) {
39   grpc_resolve_address_impl->resolve_address(
40       addr, default_port, interested_parties, on_done, addresses);
41 }
42
43 void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addresses) {
44   if (addresses != nullptr) {
45     gpr_free(addresses->addrs);
46   }
47   gpr_free(addresses);
48 }
49
50 grpc_error_handle grpc_blocking_resolve_address(
51     const char* name, const char* default_port,
52     grpc_resolved_addresses** addresses) {
53   return grpc_resolve_address_impl->blocking_resolve_address(name, default_port,
54                                                              addresses);
55 }