Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | d4c9833 | 2016-03-31 13:45:47 -0700 | [diff] [blame] | 3 | * Copyright 2015-2016, Google Inc. |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
David Garcia Quintas | 64ddf13 | 2016-03-30 23:53:50 -0700 | [diff] [blame] | 34 | #include <stdbool.h> |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 35 | #include <stdio.h> |
Mark D. Roth | 72d0b16 | 2016-09-30 09:49:50 -0700 | [diff] [blame] | 36 | #include <stdlib.h> |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 37 | #include <string.h> |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 38 | |
| 39 | #include <grpc/support/alloc.h> |
| 40 | #include <grpc/support/host_port.h> |
David Garcia Quintas | f47240e | 2016-04-04 13:51:29 -0700 | [diff] [blame] | 41 | #include <grpc/support/port_platform.h> |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 42 | #include <grpc/support/string_util.h> |
| 43 | |
Mark D. Roth | ae07f7f | 2016-10-21 15:23:53 -0700 | [diff] [blame] | 44 | #include "src/core/ext/client_channel/lb_policy_factory.h" |
Mark D. Roth | 2137cd8 | 2016-09-14 09:04:00 -0700 | [diff] [blame] | 45 | #include "src/core/ext/client_channel/parse_address.h" |
| 46 | #include "src/core/ext/client_channel/resolver_registry.h" |
Mark D. Roth | 72d0b16 | 2016-09-30 09:49:50 -0700 | [diff] [blame] | 47 | #include "src/core/lib/channel/channel_args.h" |
Craig Tiller | 972470b | 2017-02-09 15:05:36 -0800 | [diff] [blame] | 48 | #include "src/core/lib/iomgr/combiner.h" |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 49 | #include "src/core/lib/iomgr/resolve_address.h" |
| 50 | #include "src/core/lib/iomgr/unix_sockets_posix.h" |
Craig Tiller | a59c16c | 2016-10-31 07:25:01 -0700 | [diff] [blame] | 51 | #include "src/core/lib/slice/slice_internal.h" |
Craig Tiller | 0f31080 | 2016-10-26 16:25:56 -0700 | [diff] [blame] | 52 | #include "src/core/lib/slice/slice_string_helpers.h" |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 53 | #include "src/core/lib/support/string.h" |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 54 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 55 | typedef struct { |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 56 | /** base class: must be first */ |
| 57 | grpc_resolver base; |
David Garcia Quintas | 2bfd275 | 2015-08-20 11:42:29 -0700 | [diff] [blame] | 58 | /** the addresses that we've 'resolved' */ |
Mark D. Roth | c5c3878 | 2016-09-16 08:51:01 -0700 | [diff] [blame] | 59 | grpc_lb_addresses *addresses; |
Mark D. Roth | 98abfd3 | 2016-10-21 08:10:51 -0700 | [diff] [blame] | 60 | /** channel args */ |
| 61 | grpc_channel_args *channel_args; |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 62 | /** have we published? */ |
Mark D. Roth | f655c85 | 2016-09-06 10:40:38 -0700 | [diff] [blame] | 63 | bool published; |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 64 | /** pending next completion, or NULL */ |
Craig Tiller | 3382511 | 2015-09-18 07:44:19 -0700 | [diff] [blame] | 65 | grpc_closure *next_completion; |
Mark D. Roth | ff4df06 | 2016-08-22 15:02:49 -0700 | [diff] [blame] | 66 | /** target result address for next completion */ |
Mark D. Roth | af84245 | 2016-10-21 15:05:15 -0700 | [diff] [blame] | 67 | grpc_channel_args **target_result; |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 68 | } sockaddr_resolver; |
| 69 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 70 | static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r); |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 71 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 72 | static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, |
| 73 | sockaddr_resolver *r); |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 74 | |
Craig Tiller | 972470b | 2017-02-09 15:05:36 -0800 | [diff] [blame] | 75 | static void sockaddr_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *r); |
| 76 | static void sockaddr_channel_saw_error_locked(grpc_exec_ctx *exec_ctx, |
| 77 | grpc_resolver *r); |
| 78 | static void sockaddr_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *r, |
| 79 | grpc_channel_args **target_result, |
| 80 | grpc_closure *on_complete); |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 81 | |
| 82 | static const grpc_resolver_vtable sockaddr_resolver_vtable = { |
Craig Tiller | 972470b | 2017-02-09 15:05:36 -0800 | [diff] [blame] | 83 | sockaddr_destroy, sockaddr_shutdown_locked, |
| 84 | sockaddr_channel_saw_error_locked, sockaddr_next_locked}; |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 85 | |
Craig Tiller | 972470b | 2017-02-09 15:05:36 -0800 | [diff] [blame] | 86 | static void sockaddr_shutdown_locked(grpc_exec_ctx *exec_ctx, |
| 87 | grpc_resolver *resolver) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 88 | sockaddr_resolver *r = (sockaddr_resolver *)resolver; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 89 | if (r->next_completion != NULL) { |
Mark D. Roth | ff4df06 | 2016-08-22 15:02:49 -0700 | [diff] [blame] | 90 | *r->target_result = NULL; |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 91 | grpc_closure_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 92 | r->next_completion = NULL; |
| 93 | } |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Craig Tiller | 972470b | 2017-02-09 15:05:36 -0800 | [diff] [blame] | 96 | static void sockaddr_channel_saw_error_locked(grpc_exec_ctx *exec_ctx, |
| 97 | grpc_resolver *resolver) { |
Craig Tiller | 486ea35 | 2015-11-24 16:58:41 -0800 | [diff] [blame] | 98 | sockaddr_resolver *r = (sockaddr_resolver *)resolver; |
Mark D. Roth | f655c85 | 2016-09-06 10:40:38 -0700 | [diff] [blame] | 99 | r->published = false; |
Craig Tiller | 486ea35 | 2015-11-24 16:58:41 -0800 | [diff] [blame] | 100 | sockaddr_maybe_finish_next_locked(exec_ctx, r); |
Craig Tiller | 486ea35 | 2015-11-24 16:58:41 -0800 | [diff] [blame] | 101 | } |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 102 | |
Craig Tiller | 972470b | 2017-02-09 15:05:36 -0800 | [diff] [blame] | 103 | static void sockaddr_next_locked(grpc_exec_ctx *exec_ctx, |
| 104 | grpc_resolver *resolver, |
| 105 | grpc_channel_args **target_result, |
| 106 | grpc_closure *on_complete) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 107 | sockaddr_resolver *r = (sockaddr_resolver *)resolver; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 108 | GPR_ASSERT(!r->next_completion); |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 109 | r->next_completion = on_complete; |
Mark D. Roth | ff4df06 | 2016-08-22 15:02:49 -0700 | [diff] [blame] | 110 | r->target_result = target_result; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 111 | sockaddr_maybe_finish_next_locked(exec_ctx, r); |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 114 | static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, |
| 115 | sockaddr_resolver *r) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 116 | if (r->next_completion != NULL && !r->published) { |
Mark D. Roth | f655c85 | 2016-09-06 10:40:38 -0700 | [diff] [blame] | 117 | r->published = true; |
Mark D. Roth | 3686996 | 2016-10-21 10:43:45 -0700 | [diff] [blame] | 118 | grpc_arg arg = grpc_lb_addresses_create_channel_arg(r->addresses); |
Mark D. Roth | af84245 | 2016-10-21 15:05:15 -0700 | [diff] [blame] | 119 | *r->target_result = |
Mark D. Roth | 3686996 | 2016-10-21 10:43:45 -0700 | [diff] [blame] | 120 | grpc_channel_args_copy_and_add(r->channel_args, &arg, 1); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 121 | grpc_closure_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 122 | r->next_completion = NULL; |
| 123 | } |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 126 | static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) { |
| 127 | sockaddr_resolver *r = (sockaddr_resolver *)gr; |
Craig Tiller | 87a7e1f | 2016-11-09 09:42:19 -0800 | [diff] [blame] | 128 | grpc_lb_addresses_destroy(exec_ctx, r->addresses); |
| 129 | grpc_channel_args_destroy(exec_ctx, r->channel_args); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 130 | gpr_free(r); |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 133 | static char *ip_get_default_authority(grpc_uri *uri) { |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 134 | const char *path = uri->path; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 135 | if (path[0] == '/') ++path; |
| 136 | return gpr_strdup(path); |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 139 | static char *ipv4_get_default_authority(grpc_resolver_factory *factory, |
| 140 | grpc_uri *uri) { |
| 141 | return ip_get_default_authority(uri); |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 142 | } |
| 143 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 144 | static char *ipv6_get_default_authority(grpc_resolver_factory *factory, |
| 145 | grpc_uri *uri) { |
| 146 | return ip_get_default_authority(uri); |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 147 | } |
| 148 | |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 149 | #ifdef GRPC_HAVE_UNIX_SOCKET |
Craig Tiller | f82ddc4 | 2016-04-05 17:15:07 -0700 | [diff] [blame] | 150 | char *unix_get_default_authority(grpc_resolver_factory *factory, |
| 151 | grpc_uri *uri) { |
| 152 | return gpr_strdup("localhost"); |
| 153 | } |
| 154 | #endif |
| 155 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 156 | static void do_nothing(void *ignored) {} |
Craig Tiller | 45724b3 | 2015-09-22 10:42:19 -0700 | [diff] [blame] | 157 | |
Craig Tiller | a59c16c | 2016-10-31 07:25:01 -0700 | [diff] [blame] | 158 | static grpc_resolver *sockaddr_create(grpc_exec_ctx *exec_ctx, |
| 159 | grpc_resolver_args *args, |
Mark D. Roth | 07aab59 | 2016-10-04 10:02:00 -0700 | [diff] [blame] | 160 | int parse(grpc_uri *uri, |
murgatroid99 | dedb923 | 2016-09-26 13:54:04 -0700 | [diff] [blame] | 161 | grpc_resolved_address *dst)) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 162 | if (0 != strcmp(args->uri->authority, "")) { |
| 163 | gpr_log(GPR_ERROR, "authority based uri's not supported by the %s scheme", |
| 164 | args->uri->scheme); |
| 165 | return NULL; |
| 166 | } |
Mark D. Roth | b34b055 | 2016-10-03 13:34:55 -0700 | [diff] [blame] | 167 | /* Construct addresses. */ |
Craig Tiller | d41a4a7 | 2016-10-26 16:16:06 -0700 | [diff] [blame] | 168 | grpc_slice path_slice = |
| 169 | grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing); |
| 170 | grpc_slice_buffer path_parts; |
| 171 | grpc_slice_buffer_init(&path_parts); |
| 172 | grpc_slice_split(path_slice, ",", &path_parts); |
Mark D. Roth | 557c990 | 2016-10-24 11:12:05 -0700 | [diff] [blame] | 173 | grpc_lb_addresses *addresses = |
| 174 | grpc_lb_addresses_create(path_parts.count, NULL /* user_data_vtable */); |
Mark D. Roth | b34b055 | 2016-10-03 13:34:55 -0700 | [diff] [blame] | 175 | bool errors_found = false; |
| 176 | for (size_t i = 0; i < addresses->num_addresses; i++) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 177 | grpc_uri ith_uri = *args->uri; |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 178 | char *part_str = grpc_slice_to_c_string(path_parts.slices[i]); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 179 | ith_uri.path = part_str; |
murgatroid99 | fde76d7 | 2016-10-07 15:09:53 -0700 | [diff] [blame] | 180 | if (!parse(&ith_uri, &addresses->addresses[i].address)) { |
murgatroid99 | 08b0fab | 2016-09-23 14:35:49 -0700 | [diff] [blame] | 181 | errors_found = true; /* GPR_TRUE */ |
David Garcia Quintas | 2bfd275 | 2015-08-20 11:42:29 -0700 | [diff] [blame] | 182 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 183 | gpr_free(part_str); |
| 184 | if (errors_found) break; |
| 185 | } |
Craig Tiller | a59c16c | 2016-10-31 07:25:01 -0700 | [diff] [blame] | 186 | grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts); |
| 187 | grpc_slice_unref_internal(exec_ctx, path_slice); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 188 | if (errors_found) { |
Craig Tiller | 87a7e1f | 2016-11-09 09:42:19 -0800 | [diff] [blame] | 189 | grpc_lb_addresses_destroy(exec_ctx, addresses); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 190 | return NULL; |
| 191 | } |
Mark D. Roth | b34b055 | 2016-10-03 13:34:55 -0700 | [diff] [blame] | 192 | /* Instantiate resolver. */ |
| 193 | sockaddr_resolver *r = gpr_malloc(sizeof(sockaddr_resolver)); |
| 194 | memset(r, 0, sizeof(*r)); |
Mark D. Roth | b34b055 | 2016-10-03 13:34:55 -0700 | [diff] [blame] | 195 | r->addresses = addresses; |
Mark D. Roth | 201db7d | 2016-12-12 09:36:02 -0800 | [diff] [blame] | 196 | r->channel_args = grpc_channel_args_copy(args->args); |
Craig Tiller | 0bfad14 | 2017-02-17 16:01:08 -0800 | [diff] [blame] | 197 | grpc_resolver_init(&r->base, &sockaddr_resolver_vtable, args->combiner); |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 198 | return &r->base; |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | * FACTORY |
| 203 | */ |
| 204 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 205 | static void sockaddr_factory_ref(grpc_resolver_factory *factory) {} |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 206 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 207 | static void sockaddr_factory_unref(grpc_resolver_factory *factory) {} |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 208 | |
Craig Tiller | f82ddc4 | 2016-04-05 17:15:07 -0700 | [diff] [blame] | 209 | #define DECL_FACTORY(name) \ |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 210 | static grpc_resolver *name##_factory_create_resolver( \ |
Craig Tiller | a59c16c | 2016-10-31 07:25:01 -0700 | [diff] [blame] | 211 | grpc_exec_ctx *exec_ctx, grpc_resolver_factory *factory, \ |
| 212 | grpc_resolver_args *args) { \ |
| 213 | return sockaddr_create(exec_ctx, args, parse_##name); \ |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 214 | } \ |
| 215 | static const grpc_resolver_factory_vtable name##_factory_vtable = { \ |
| 216 | sockaddr_factory_ref, sockaddr_factory_unref, \ |
Craig Tiller | f82ddc4 | 2016-04-05 17:15:07 -0700 | [diff] [blame] | 217 | name##_factory_create_resolver, name##_get_default_authority, #name}; \ |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 218 | static grpc_resolver_factory name##_resolver_factory = { \ |
Craig Tiller | 65938df | 2016-03-31 13:08:49 -0700 | [diff] [blame] | 219 | &name##_factory_vtable} |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 220 | |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 221 | #ifdef GRPC_HAVE_UNIX_SOCKET |
Craig Tiller | f82ddc4 | 2016-04-05 17:15:07 -0700 | [diff] [blame] | 222 | DECL_FACTORY(unix); |
Craig Tiller | 698d00c | 2015-07-20 12:32:58 -0700 | [diff] [blame] | 223 | #endif |
Craig Tiller | f82ddc4 | 2016-04-05 17:15:07 -0700 | [diff] [blame] | 224 | DECL_FACTORY(ipv4); |
| 225 | DECL_FACTORY(ipv6); |
Craig Tiller | 65938df | 2016-03-31 13:08:49 -0700 | [diff] [blame] | 226 | |
| 227 | void grpc_resolver_sockaddr_init(void) { |
| 228 | grpc_register_resolver_type(&ipv4_resolver_factory); |
| 229 | grpc_register_resolver_type(&ipv6_resolver_factory); |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 230 | #ifdef GRPC_HAVE_UNIX_SOCKET |
Craig Tiller | 65938df | 2016-03-31 13:08:49 -0700 | [diff] [blame] | 231 | grpc_register_resolver_type(&unix_resolver_factory); |
| 232 | #endif |
| 233 | } |
| 234 | |
| 235 | void grpc_resolver_sockaddr_shutdown(void) {} |