Lines Matching refs:channel
56 static struct in_addr *ares_save_opt_servers(ares_channel_t *channel,
61 ares_malloc_zero(ares__slist_len(channel->servers) * sizeof(*out));
69 for (snode = ares__slist_node_first(channel->servers); snode != NULL;
84 /* Save options from initialized channel */
85 int ares_save_options(ares_channel_t *channel, struct ares_options *options,
107 if (!ARES_CONFIG_CHECK(channel)) {
111 if (channel->optmask & ARES_OPT_FLAGS) {
112 options->flags = (int)channel->flags;
117 if (channel->optmask & ARES_OPT_TIMEOUTMS) {
118 options->timeout = (int)channel->timeout;
121 if (channel->optmask & ARES_OPT_TRIES) {
122 options->tries = (int)channel->tries;
125 if (channel->optmask & ARES_OPT_NDOTS) {
126 options->ndots = (int)channel->ndots;
129 if (channel->optmask & ARES_OPT_MAXTIMEOUTMS) {
130 options->maxtimeout = (int)channel->maxtimeout;
133 if (channel->optmask & ARES_OPT_UDP_PORT) {
134 options->udp_port = channel->udp_port;
136 if (channel->optmask & ARES_OPT_TCP_PORT) {
137 options->tcp_port = channel->tcp_port;
140 if (channel->optmask & ARES_OPT_SOCK_STATE_CB) {
141 options->sock_state_cb = channel->sock_state_cb;
142 options->sock_state_cb_data = channel->sock_state_cb_data;
145 if (channel->optmask & ARES_OPT_SERVERS) {
146 options->servers = ares_save_opt_servers(channel, &options->nservers);
152 if (channel->optmask & ARES_OPT_DOMAINS) {
154 if (channel->ndomains) {
155 options->domains = ares_malloc(channel->ndomains * sizeof(char *));
160 for (i = 0; i < channel->ndomains; i++) {
161 options->domains[i] = ares_strdup(channel->domains[i]);
168 options->ndomains = (int)channel->ndomains;
171 if (channel->optmask & ARES_OPT_LOOKUPS) {
172 options->lookups = ares_strdup(channel->lookups);
173 if (!options->lookups && channel->lookups) {
178 if (channel->optmask & ARES_OPT_SORTLIST) {
180 if (channel->nsort) {
181 options->sortlist = ares_malloc(channel->nsort * sizeof(struct apattern));
185 for (i = 0; i < channel->nsort; i++) {
186 options->sortlist[i] = channel->sortlist[i];
189 options->nsort = (int)channel->nsort;
192 if (channel->optmask & ARES_OPT_RESOLVCONF) {
193 options->resolvconf_path = ares_strdup(channel->resolvconf_path);
199 if (channel->optmask & ARES_OPT_HOSTS_FILE) {
200 options->hosts_path = ares_strdup(channel->hosts_path);
206 if (channel->optmask & ARES_OPT_SOCK_SNDBUF &&
207 channel->socket_send_buffer_size > 0) {
208 options->socket_send_buffer_size = channel->socket_send_buffer_size;
211 if (channel->optmask & ARES_OPT_SOCK_RCVBUF &&
212 channel->socket_receive_buffer_size > 0) {
213 options->socket_receive_buffer_size = channel->socket_receive_buffer_size;
216 if (channel->optmask & ARES_OPT_EDNSPSZ) {
217 options->ednspsz = (int)channel->ednspsz;
220 if (channel->optmask & ARES_OPT_UDP_MAX_QUERIES) {
221 options->udp_max_queries = (int)channel->udp_max_queries;
224 if (channel->optmask & ARES_OPT_QUERY_CACHE) {
225 options->qcache_max_ttl = channel->qcache_max_ttl;
228 if (channel->optmask & ARES_OPT_EVENT_THREAD) {
229 options->evsys = channel->evsys;
232 *optmask = (int)channel->optmask;
237 static ares_status_t ares__init_options_servers(ares_channel_t *channel,
249 status = ares__servers_update(channel, slist, ARES_TRUE);
256 ares_status_t ares__init_by_options(ares_channel_t *channel,
262 if (channel == NULL) {
284 channel->evsys = options->evsys;
288 channel->flags = (unsigned int)options->flags;
297 channel->timeout = (unsigned int)options->timeout;
306 channel->timeout = (unsigned int)options->timeout * 1000;
314 channel->tries = (size_t)options->tries;
322 channel->ndots = (size_t)options->ndots;
330 channel->maxtimeout = (size_t)options->maxtimeout;
335 channel->rotate = ARES_TRUE;
339 channel->rotate = ARES_FALSE;
343 channel->udp_port = options->udp_port;
347 channel->tcp_port = options->tcp_port;
351 channel->sock_state_cb = options->sock_state_cb;
352 channel->sock_state_cb_data = options->sock_state_cb_data;
359 channel->socket_send_buffer_size = options->socket_send_buffer_size;
367 channel->socket_receive_buffer_size = options->socket_receive_buffer_size;
375 channel->ednspsz = (size_t)options->ednspsz;
379 /* Copy the domains, if given. Keep channel->ndomains consistent so
383 channel->domains =
385 if (!channel->domains) {
388 channel->ndomains = (size_t)options->ndomains;
390 channel->domains[i] = ares_strdup(options->domains[i]);
391 if (!channel->domains[i]) {
402 channel->lookups = ares_strdup(options->lookups);
403 if (!channel->lookups) {
411 channel->nsort = (size_t)options->nsort;
412 channel->sortlist =
414 if (!channel->sortlist) {
418 channel->sortlist[i] = options->sortlist[i];
427 channel->resolvconf_path = ares_strdup(options->resolvconf_path);
428 if (channel->resolvconf_path == NULL) {
439 channel->hosts_path = ares_strdup(options->hosts_path);
440 if (channel->hosts_path == NULL) {
450 channel->udp_max_queries = (size_t)options->udp_max_queries;
459 channel->qcache_max_ttl = options->qcache_max_ttl;
469 status = ares__init_options_servers(channel, options->servers,
477 channel->optmask = (unsigned int)optmask;