ares_getaddrinfo.c
Go to the documentation of this file.
1 
2 /* Copyright 1998, 2011, 2013 by the Massachusetts Institute of Technology.
3  * Copyright (C) 2017 - 2018 by Christian Ammer
4  * Copyright (C) 2019 by Andrew Selivanov
5  *
6  * Permission to use, copy, modify, and distribute this
7  * software and its documentation for any purpose and without
8  * fee is hereby granted, provided that the above copyright
9  * notice appear in all copies and that both that copyright
10  * notice and this permission notice appear in supporting
11  * documentation, and that the name of M.I.T. not be used in
12  * advertising or publicity pertaining to distribution of the
13  * software without specific, written prior permission.
14  * M.I.T. makes no representations about the suitability of
15  * this software for any purpose. It is provided "as is"
16  * without express or implied warranty.
17  */
18 
19 #include "ares_setup.h"
20 
21 #ifdef HAVE_GETSERVBYNAME_R
22 # if !defined(GETSERVBYNAME_R_ARGS) || \
23  (GETSERVBYNAME_R_ARGS < 4) || (GETSERVBYNAME_R_ARGS > 6)
24 # error "you MUST specifiy a valid number of arguments for getservbyname_r"
25 # endif
26 #endif
27 
28 #ifdef HAVE_NETINET_IN_H
29 # include <netinet/in.h>
30 #endif
31 #ifdef HAVE_NETDB_H
32 # include <netdb.h>
33 #endif
34 #ifdef HAVE_ARPA_INET_H
35 # include <arpa/inet.h>
36 #endif
37 
38 #include "ares_nameser.h"
39 
40 #ifdef HAVE_STRINGS_H
41 #include <strings.h>
42 #endif
43 #include <assert.h>
44 
45 #ifdef HAVE_LIMITS_H
46 #include <limits.h>
47 #endif
48 
49 #include "ares.h"
50 #include "bitncmp.h"
51 #include "ares_private.h"
52 
53 #ifdef WATT32
54 #undef WIN32
55 #endif
56 #ifdef WIN32
57 # include "ares_platform.h"
58 #endif
59 
60 struct host_query
61 {
63  char *name;
64  unsigned short port; /* in host order */
66  void *arg;
68  int sent_family; /* this family is what was is being used */
69  int timeouts; /* number of timeouts we saw for this request */
70  const char *remaining_lookups; /* types of lookup we need to perform ("fb" by
71  default, file and dns respectively) */
72  struct ares_addrinfo *ai; /* store results between lookups */
73  int remaining; /* number of DNS answers waiting for */
74  int next_domain; /* next search domain to try */
75 };
76 
77 static const struct ares_addrinfo_hints default_hints = {
78  0, /* ai_flags */
79  AF_UNSPEC, /* ai_family */
80  0, /* ai_socktype */
81  0, /* ai_protocol */
82 };
83 
85  INT_MAX, /* ttl */
86  NULL, /* alias */
87  NULL, /* name */
88  NULL, /* next */
89 };
90 
91 static const struct ares_addrinfo_node empty_addrinfo_node = {
92  0, /* ai_ttl */
93  0, /* ai_flags */
94  0, /* ai_family */
95  0, /* ai_socktype */
96  0, /* ai_protocol */
97  0, /* ai_addrlen */
98  NULL, /* ai_addr */
99  NULL /* ai_next */
100 };
101 
102 static const struct ares_addrinfo empty_addrinfo = {
103  NULL, /* cnames */
104  NULL /* nodes */
105 };
106 
107 /* forward declarations */
108 static void host_callback(void *arg, int status, int timeouts,
109  unsigned char *abuf, int alen);
110 static int as_is_first(const struct host_query *hquery);
111 static int next_dns_lookup(struct host_query *hquery);
112 
114 {
115  struct ares_addrinfo_cname *cname = ares_malloc(sizeof(struct ares_addrinfo_cname));
116  if (!cname)
117  return NULL;
118 
119  *cname = empty_addrinfo_cname;
120  return cname;
121 }
122 
124 {
126  struct ares_addrinfo_cname *last = *head;
127  if (!last)
128  {
129  *head = tail;
130  return tail;
131  }
132 
133  while (last->next)
134  {
135  last = last->next;
136  }
137 
138  last->next = tail;
139  return tail;
140 }
141 
143  struct ares_addrinfo_cname *tail)
144 {
145  struct ares_addrinfo_cname *last = *head;
146  if (!last)
147  {
148  *head = tail;
149  return;
150  }
151 
152  while (last->next)
153  {
154  last = last->next;
155  }
156 
157  last->next = tail;
158 }
159 
161 {
162  struct ares_addrinfo *ai = ares_malloc(sizeof(struct ares_addrinfo));
163  if (!ai)
164  return NULL;
165 
166  *ai = empty_addrinfo;
167  return ai;
168 }
169 
171 {
172  struct ares_addrinfo_node *node =
173  ares_malloc(sizeof(struct ares_addrinfo_node));
174  if (!node)
175  return NULL;
176 
177  *node = empty_addrinfo_node;
178  return node;
179 }
180 
181 /* Allocate new addrinfo and append to the tail. */
183 {
185  struct ares_addrinfo_node *last = *head;
186  if (!last)
187  {
188  *head = tail;
189  return tail;
190  }
191 
192  while (last->ai_next)
193  {
194  last = last->ai_next;
195  }
196 
197  last->ai_next = tail;
198  return tail;
199 }
200 
202  struct ares_addrinfo_node *tail)
203 {
204  struct ares_addrinfo_node *last = *head;
205  if (!last)
206  {
207  *head = tail;
208  return;
209  }
210 
211  while (last->ai_next)
212  {
213  last = last->ai_next;
214  }
215 
216  last->ai_next = tail;
217 }
218 
219 /* Resolve service name into port number given in host byte order.
220  * If not resolved, return 0.
221  */
222 static unsigned short lookup_service(const char *service, int flags)
223 {
224  const char *proto;
225  struct servent *sep;
226 #ifdef HAVE_GETSERVBYNAME_R
227  struct servent se;
228  char tmpbuf[4096];
229 #endif
230 
231  if (service)
232  {
233  if (flags & ARES_NI_UDP)
234  proto = "udp";
235  else if (flags & ARES_NI_SCTP)
236  proto = "sctp";
237  else if (flags & ARES_NI_DCCP)
238  proto = "dccp";
239  else
240  proto = "tcp";
241 #ifdef HAVE_GETSERVBYNAME_R
242  memset(&se, 0, sizeof(se));
243  sep = &se;
244  memset(tmpbuf, 0, sizeof(tmpbuf));
245 #if GETSERVBYNAME_R_ARGS == 6
246  if (getservbyname_r(service, proto, &se, (void *)tmpbuf, sizeof(tmpbuf),
247  &sep) != 0)
248  sep = NULL; /* LCOV_EXCL_LINE: buffer large so this never fails */
249 #elif GETSERVBYNAME_R_ARGS == 5
250  sep =
251  getservbyname_r(service, proto, &se, (void *)tmpbuf, sizeof(tmpbuf));
252 #elif GETSERVBYNAME_R_ARGS == 4
253  if (getservbyname_r(service, proto, &se, (void *)tmpbuf) != 0)
254  sep = NULL;
255 #else
256  /* Lets just hope the OS uses TLS! */
257  sep = getservbyname(service, proto);
258 #endif
259 #else
260  /* Lets just hope the OS uses TLS! */
261 #if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
262  sep = getservbyname(service, (char *)proto);
263 #else
264  sep = getservbyname(service, proto);
265 #endif
266 #endif
267  return (sep ? ntohs((unsigned short)sep->s_port) : 0);
268  }
269  return 0;
270 }
271 
272 /* If the name looks like an IP address or an error occured,
273  * fake up a host entry, end the query immediately, and return true.
274  * Otherwise return false.
275  */
276 static int fake_addrinfo(const char *name,
277  unsigned short port,
278  const struct ares_addrinfo_hints *hints,
279  struct ares_addrinfo *ai,
281  void *arg)
282 {
283  struct ares_addrinfo_cname *cname;
284  struct ares_addrinfo_node *node;
286  size_t addrlen;
287  int result = 0;
288  int family = hints->ai_family;
289  if (family == AF_INET || family == AF_INET6 || family == AF_UNSPEC)
290  {
291  /* It only looks like an IP address if it's all numbers and dots. */
292  int numdots = 0, valid = 1;
293  const char *p;
294  for (p = name; *p; p++)
295  {
296  if (!ISDIGIT(*p) && *p != '.')
297  {
298  valid = 0;
299  break;
300  }
301  else if (*p == '.')
302  {
303  numdots++;
304  }
305  }
306 
307  memset(&addr, 0, sizeof(addr));
308 
309  /* if we don't have 3 dots, it is illegal
310  * (although inet_pton doesn't think so).
311  */
312  if (numdots != 3 || !valid)
313  result = 0;
314  else
315  result =
316  (ares_inet_pton(AF_INET, name, &addr.sa4.sin_addr) < 1 ? 0 : 1);
317 
318  if (result)
319  {
320  family = addr.sa.sa_family = AF_INET;
321  addr.sa4.sin_port = htons(port);
322  addrlen = sizeof(addr.sa4);
323  }
324  }
325 
326  if (family == AF_INET6 || family == AF_UNSPEC)
327  {
328  result =
329  (ares_inet_pton(AF_INET6, name, &addr.sa6.sin6_addr) < 1 ? 0 : 1);
330  addr.sa6.sin6_family = AF_INET6;
331  addr.sa6.sin6_port = htons(port);
332  addrlen = sizeof(addr.sa6);
333  }
334 
335  if (!result)
336  return 0;
337 
339  if (!node)
340  {
341  ares_freeaddrinfo(ai);
342  callback(arg, ARES_ENOMEM, 0, NULL);
343  return 1;
344  }
345 
346  ai->nodes = node;
347 
348  node->ai_addr = ares_malloc(addrlen);
349  if (!node->ai_addr)
350  {
351  ares_freeaddrinfo(ai);
352  callback(arg, ARES_ENOMEM, 0, NULL);
353  return 1;
354  }
355 
356  node->ai_addrlen = (unsigned int)addrlen;
357  node->ai_family = addr.sa.sa_family;
358  if (addr.sa.sa_family == AF_INET)
359  memcpy(node->ai_addr, &addr.sa4, sizeof(addr.sa4));
360  else
361  memcpy(node->ai_addr, &addr.sa6, sizeof(addr.sa6));
362 
363  if (hints->ai_flags & ARES_AI_CANONNAME)
364  {
365  cname = ares__append_addrinfo_cname(&ai->cnames);
366  if (!cname)
367  {
368  ares_freeaddrinfo(ai);
369  callback(arg, ARES_ENOMEM, 0, NULL);
370  return 1;
371  }
372 
373  /* Duplicate the name, to avoid a constness violation. */
374  cname->name = ares_strdup(name);
375  if (!cname->name)
376  {
377  ares_freeaddrinfo(ai);
378  callback(arg, ARES_ENOMEM, 0, NULL);
379  return 1;
380  }
381  }
382 
383  node->ai_socktype = hints->ai_socktype;
384  node->ai_protocol = hints->ai_protocol;
385 
386  callback(arg, ARES_SUCCESS, 0, ai);
387  return 1;
388 }
389 
390 static void end_hquery(struct host_query *hquery, int status)
391 {
392  struct ares_addrinfo_node sentinel;
393  struct ares_addrinfo_node *next;
394  if (status == ARES_SUCCESS)
395  {
396  if (!(hquery->hints.ai_flags & ARES_AI_NOSORT) && hquery->ai->nodes)
397  {
398  sentinel.ai_next = hquery->ai->nodes;
399  ares__sortaddrinfo(hquery->channel, &sentinel);
400  hquery->ai->nodes = sentinel.ai_next;
401  }
402  next = hquery->ai->nodes;
403  /* Set port into each address (resolved separately). */
404  while (next)
405  {
406  next->ai_socktype = hquery->hints.ai_socktype;
407  next->ai_protocol = hquery->hints.ai_protocol;
408  if (next->ai_family == AF_INET)
409  {
410  (CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr))->sin_port = htons(hquery->port);
411  }
412  else
413  {
414  (CARES_INADDR_CAST(struct sockaddr_in6 *, next->ai_addr))->sin6_port = htons(hquery->port);
415  }
416  next = next->ai_next;
417  }
418  }
419  else
420  {
421  /* Clean up what we have collected by so far. */
422  ares_freeaddrinfo(hquery->ai);
423  hquery->ai = NULL;
424  }
425 
426  hquery->callback(hquery->arg, status, hquery->timeouts, hquery->ai);
427  ares_free(hquery->name);
428  ares_free(hquery);
429 }
430 
431 static int file_lookup(struct host_query *hquery)
432 {
433  FILE *fp;
434  int error;
435  int status;
436  const char *path_hosts = NULL;
437 
438  if (hquery->hints.ai_flags & ARES_AI_ENVHOSTS)
439  {
440  path_hosts = getenv("CARES_HOSTS");
441  }
442 
443  if (!path_hosts)
444  {
445 #ifdef WIN32
446  char PATH_HOSTS[MAX_PATH];
447  win_platform platform;
448 
449  PATH_HOSTS[0] = '\0';
450 
451  platform = ares__getplatform();
452 
453  if (platform == WIN_NT)
454  {
455  char tmp[MAX_PATH];
456  HKEY hkeyHosts;
457 
458  if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
459  &hkeyHosts) == ERROR_SUCCESS)
460  {
461  DWORD dwLength = MAX_PATH;
462  RegQueryValueExA(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
463  &dwLength);
464  ExpandEnvironmentStringsA(tmp, PATH_HOSTS, MAX_PATH);
465  RegCloseKey(hkeyHosts);
466  }
467  }
468  else if (platform == WIN_9X)
469  GetWindowsDirectoryA(PATH_HOSTS, MAX_PATH);
470  else
471  return ARES_ENOTFOUND;
472 
473  strcat(PATH_HOSTS, WIN_PATH_HOSTS);
474  path_hosts = PATH_HOSTS;
475 
476 #elif defined(WATT32)
477  const char *PATH_HOSTS = _w32_GetHostsFile();
478 
479  if (!PATH_HOSTS)
480  return ARES_ENOTFOUND;
481 #endif
482  path_hosts = PATH_HOSTS;
483  }
484 
485  fp = fopen(path_hosts, "r");
486  if (!fp)
487  {
488  error = ERRNO;
489  switch (error)
490  {
491  case ENOENT:
492  case ESRCH:
493  return ARES_ENOTFOUND;
494  default:
495  DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error,
496  strerror(error)));
497  DEBUGF(fprintf(stderr, "Error opening file: %s\n", path_hosts));
498  return ARES_EFILE;
499  }
500  }
501  status = ares__readaddrinfo(fp, hquery->name, hquery->port, &hquery->hints, hquery->ai);
502  fclose(fp);
503  return status;
504 }
505 
506 static void next_lookup(struct host_query *hquery, int status)
507 {
508  switch (*hquery->remaining_lookups)
509  {
510  case 'b':
511  /* DNS lookup */
512  if (next_dns_lookup(hquery))
513  break;
514  hquery->remaining_lookups++;
515  next_lookup(hquery, status);
516  break;
517 
518  case 'f':
519  /* Host file lookup */
520  if (file_lookup(hquery) == ARES_SUCCESS)
521  {
522  end_hquery(hquery, ARES_SUCCESS);
523  break;
524  }
525  hquery->remaining_lookups++;
526  next_lookup(hquery, status);
527  break;
528  default:
529  /* No lookup left */
530  end_hquery(hquery, status);
531  break;
532  }
533 }
534 
535 static void host_callback(void *arg, int status, int timeouts,
536  unsigned char *abuf, int alen)
537 {
538  struct host_query *hquery = (struct host_query*)arg;
539  int addinfostatus = ARES_SUCCESS;
540  hquery->timeouts += timeouts;
541  hquery->remaining--;
542 
543  if (status == ARES_SUCCESS)
544  {
545  addinfostatus = ares__parse_into_addrinfo(abuf, alen, hquery->ai);
546  }
547 
548  if (!hquery->remaining)
549  {
550  if (addinfostatus != ARES_SUCCESS)
551  {
552  /* error in parsing result e.g. no memory */
553  end_hquery(hquery, addinfostatus);
554  }
555  else if (hquery->ai->nodes)
556  {
557  /* at least one query ended with ARES_SUCCESS */
558  end_hquery(hquery, ARES_SUCCESS);
559  }
560  else if (status == ARES_ENOTFOUND)
561  {
562  next_lookup(hquery, status);
563  }
564  else if (status == ARES_EDESTRUCTION)
565  {
566  /* NOTE: Could also be ARES_EDESTRUCTION. We need to only call this
567  * once all queries (there can be multiple for getaddrinfo) are
568  * terminated. */
569  end_hquery(hquery, status);
570  }
571  else
572  {
573  end_hquery(hquery, status);
574  }
575  }
576 
577  /* at this point we keep on waiting for the next query to finish */
578 }
579 
581  const char* name, const char* service,
582  const struct ares_addrinfo_hints* hints,
584 {
585  struct host_query *hquery;
586  unsigned short port = 0;
587  int family;
588  struct ares_addrinfo *ai;
589 
590  if (!hints)
591  {
592  hints = &default_hints;
593  }
594 
595  family = hints->ai_family;
596 
597  /* Right now we only know how to look up Internet addresses
598  and unspec means try both basically. */
599  if (family != AF_INET &&
600  family != AF_INET6 &&
601  family != AF_UNSPEC)
602  {
603  callback(arg, ARES_ENOTIMP, 0, NULL);
604  return;
605  }
606 
608  {
609  callback(arg, ARES_ENOTFOUND, 0, NULL);
610  return;
611  }
612 
613  if (service)
614  {
615  if (hints->ai_flags & ARES_AI_NUMERICSERV)
616  {
617  port = (unsigned short)strtoul(service, NULL, 0);
618  if (!port)
619  {
620  callback(arg, ARES_ESERVICE, 0, NULL);
621  return;
622  }
623  }
624  else
625  {
627  if (!port)
628  {
629  port = (unsigned short)strtoul(service, NULL, 0);
630  if (!port)
631  {
632  callback(arg, ARES_ESERVICE, 0, NULL);
633  return;
634  }
635  }
636  }
637  }
638 
639  ai = ares__malloc_addrinfo();
640  if (!ai)
641  {
642  callback(arg, ARES_ENOMEM, 0, NULL);
643  return;
644  }
645 
646  if (fake_addrinfo(name, port, hints, ai, callback, arg))
647  {
648  return;
649  }
650 
651  /* Allocate and fill in the host query structure. */
652  hquery = ares_malloc(sizeof(struct host_query));
653  if (!hquery)
654  {
655  ares_freeaddrinfo(ai);
656  callback(arg, ARES_ENOMEM, 0, NULL);
657  return;
658  }
659 
660  hquery->name = ares_strdup(name);
661  if (!hquery->name)
662  {
663  ares_free(hquery);
664  ares_freeaddrinfo(ai);
665  callback(arg, ARES_ENOMEM, 0, NULL);
666  return;
667  }
668 
669  hquery->port = port;
670  hquery->channel = channel;
671  hquery->hints = *hints;
672  hquery->sent_family = -1; /* nothing is sent yet */
673  hquery->callback = callback;
674  hquery->arg = arg;
675  hquery->remaining_lookups = channel->lookups;
676  hquery->timeouts = 0;
677  hquery->ai = ai;
678  hquery->next_domain = -1;
679  hquery->remaining = 0;
680 
681  /* Start performing lookups according to channel->lookups. */
682  next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */);
683 }
684 
685 static int next_dns_lookup(struct host_query *hquery)
686 {
687  char *s = NULL;
688  int is_s_allocated = 0;
689  int status;
690 
691  /* if next_domain == -1 and as_is_first is true, try hquery->name */
692  if (hquery->next_domain == -1)
693  {
694  if (as_is_first(hquery))
695  {
696  s = hquery->name;
697  }
698  hquery->next_domain = 0;
699  }
700 
701  /* if as_is_first is false, try hquery->name at last */
702  if (!s && hquery->next_domain == hquery->channel->ndomains) {
703  if (!as_is_first(hquery))
704  {
705  s = hquery->name;
706  }
707  hquery->next_domain++;
708  }
709 
710  if (!s && hquery->next_domain < hquery->channel->ndomains)
711  {
713  hquery->name,
714  hquery->channel->domains[hquery->next_domain++],
715  &s);
716  if (status == ARES_SUCCESS)
717  {
718  is_s_allocated = 1;
719  }
720  }
721 
722  if (s)
723  {
724  switch (hquery->hints.ai_family)
725  {
726  case AF_INET:
727  hquery->remaining += 1;
728  ares_query(hquery->channel, s, C_IN, T_A, host_callback, hquery);
729  break;
730  case AF_INET6:
731  hquery->remaining += 1;
732  ares_query(hquery->channel, s, C_IN, T_AAAA, host_callback, hquery);
733  break;
734  case AF_UNSPEC:
735  hquery->remaining += 2;
736  ares_query(hquery->channel, s, C_IN, T_A, host_callback, hquery);
737  ares_query(hquery->channel, s, C_IN, T_AAAA, host_callback, hquery);
738  break;
739  default: break;
740  }
741  if (is_s_allocated)
742  {
743  ares_free(s);
744  }
745  return 1;
746  }
747  else
748  {
749  assert(!hquery->ai->nodes);
750  return 0;
751  }
752 }
753 
754 static int as_is_first(const struct host_query* hquery)
755 {
756  char* p;
757  int ndots = 0;
758  size_t nname = strlen(hquery->name);
759  for (p = hquery->name; *p; p++)
760  {
761  if (*p == '.')
762  {
763  ndots++;
764  }
765  }
766  if (nname && hquery->name[nname-1] == '.')
767  {
768  /* prevent ARES_EBADNAME for valid FQDN, where ndots < channel->ndots */
769  return 1;
770  }
771  return ndots >= hquery->channel->ndots;
772 }
ares__malloc_addrinfo_node
struct ares_addrinfo_node * ares__malloc_addrinfo_node()
Definition: ares_getaddrinfo.c:170
host_query::remaining
int remaining
Definition: ares_getaddrinfo.c:73
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
lookup_service
static unsigned short lookup_service(const char *service, int flags)
Definition: ares_getaddrinfo.c:222
ARES_ENOMEM
#define ARES_ENOMEM
Definition: ares.h:117
ARES_NI_SCTP
#define ARES_NI_SCTP
Definition: ares.h:180
ares_inet_pton
CARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst)
Definition: inet_net_pton.c:418
ares_addrinfo_node
Definition: ares.h:593
T_A
#define T_A
Definition: ares_nameser.h:310
ares_addrinfo_node::ai_addrlen
ares_socklen_t ai_addrlen
Definition: ares.h:599
ares_addrinfo_hints::ai_protocol
int ai_protocol
Definition: ares.h:625
host_query::hints
struct ares_addrinfo_hints hints
Definition: ares_getaddrinfo.c:67
AF_INET6
#define AF_INET6
Definition: ares_setup.h:208
ares_addrinfo
Definition: ares.h:616
memset
return memset(p, 0, total)
ares_query
CARES_EXTERN void ares_query(ares_channel channel, const char *name, int dnsclass, int type, ares_callback callback, void *arg)
Definition: ares_query.c:105
ares__malloc_addrinfo_cname
struct ares_addrinfo_cname * ares__malloc_addrinfo_cname()
Definition: ares_getaddrinfo.c:113
ares__addrinfo_cat_cnames
void ares__addrinfo_cat_cnames(struct ares_addrinfo_cname **head, struct ares_addrinfo_cname *tail)
Definition: ares_getaddrinfo.c:142
ares.h
ares_addrinfo_hints
Definition: ares.h:621
ares_strdup
char * ares_strdup(const char *s1)
Definition: ares_strdup.c:23
next_dns_lookup
static int next_dns_lookup(struct host_query *hquery)
Definition: ares_getaddrinfo.c:685
ISDIGIT
#define ISDIGIT(x)
Definition: setup_once.h:276
end_hquery
static void end_hquery(struct host_query *hquery, int status)
Definition: ares_getaddrinfo.c:390
error
grpc_error_handle error
Definition: retry_filter.cc:499
ares_addrinfo_callback
void(* ares_addrinfo_callback)(void *arg, int status, int timeouts, struct ares_addrinfo *res)
Definition: ares.h:315
ares_addrinfo_node::ai_addr
struct sockaddr * ai_addr
Definition: ares.h:600
ares__append_addrinfo_node
struct ares_addrinfo_node * ares__append_addrinfo_node(struct ares_addrinfo_node **head)
Definition: ares_getaddrinfo.c:182
ares_addrinfo_node::ai_family
int ai_family
Definition: ares.h:596
status
absl::Status status
Definition: rls.cc:251
host_query::ai
struct ares_addrinfo * ai
Definition: ares_getaddrinfo.c:72
host_query::sent_family
int sent_family
Definition: ares_getaddrinfo.c:68
setup.name
name
Definition: setup.py:542
ares__is_onion_domain
int ares__is_onion_domain(const char *name)
Definition: ares_getnameinfo.c:438
xds_manager.p
p
Definition: xds_manager.py:60
empty_addrinfo
static const struct ares_addrinfo empty_addrinfo
Definition: ares_getaddrinfo.c:102
host_query::channel
ares_channel channel
Definition: ares_getaddrinfo.c:62
host_query::name
char * name
Definition: ares_getaddrinfo.c:63
DEBUGF
#define DEBUGF(x)
Definition: setup_once.h:402
ARES_AI_CANONNAME
#define ARES_AI_CANONNAME
Definition: ares.h:191
ares__append_addrinfo_cname
struct ares_addrinfo_cname * ares__append_addrinfo_cname(struct ares_addrinfo_cname **head)
Definition: ares_getaddrinfo.c:123
python_utils.port_server.stderr
stderr
Definition: port_server.py:51
empty_addrinfo_node
static const struct ares_addrinfo_node empty_addrinfo_node
Definition: ares_getaddrinfo.c:91
ares_addrinfo_node::ai_socktype
int ai_socktype
Definition: ares.h:597
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
ARES_ENOTFOUND
#define ARES_ENOTFOUND
Definition: ares.h:104
host_query::remaining_lookups
const char * remaining_lookups
Definition: ares_getaddrinfo.c:70
ARES_AI_NUMERICSERV
#define ARES_AI_NUMERICSERV
Definition: ares.h:194
ares_addrinfo_hints::ai_family
int ai_family
Definition: ares.h:623
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
ares_malloc
void *(* ares_malloc)(size_t size)=default_malloc
Definition: ares_library_init.c:58
xds_interop_client.int
int
Definition: xds_interop_client.py:113
sockaddr_in6
Definition: ares_ipv6.h:25
CARES_INADDR_CAST
#define CARES_INADDR_CAST(type, var)
Definition: ares_private.h:56
text_format_test_wrapper.sep
sep
Definition: text_format_test_wrapper.py:34
empty_addrinfo_cname
static const struct ares_addrinfo_cname empty_addrinfo_cname
Definition: ares_getaddrinfo.c:84
ares_addrinfo_node::ai_protocol
int ai_protocol
Definition: ares.h:598
host_query::arg
void * arg
Definition: ares_getaddrinfo.c:66
host_query
Definition: ares_getaddrinfo.c:60
ARES_AI_NOSORT
#define ARES_AI_NOSORT
Definition: ares.h:198
ARES_AI_ENVHOSTS
#define ARES_AI_ENVHOSTS
Definition: ares.h:199
ares_addrinfo_hints::ai_socktype
int ai_socktype
Definition: ares.h:624
valid
@ valid
Definition: base64_test.cc:37
host_callback
static void host_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen)
Definition: ares_getaddrinfo.c:535
arg
Definition: cmdline.cc:40
T_AAAA
#define T_AAAA
Definition: ares_nameser.h:391
ares_sockaddr
Definition: ares_ipv6.h:35
ERRNO
#define ERRNO
Definition: fake_udp_and_tcp_server.cc:40
ares_platform.h
callback
static void callback(void *arg, int status, int timeouts, struct hostent *host)
Definition: acountry.c:224
ares__parse_into_addrinfo
int ares__parse_into_addrinfo(const unsigned char *abuf, int alen, struct ares_addrinfo *ai)
Definition: ares__parse_into_addrinfo.c:251
ARES_SUCCESS
#define ARES_SUCCESS
Definition: ares.h:98
ARES_NI_DCCP
#define ARES_NI_DCCP
Definition: ares.h:181
ares_channeldata::ndots
int ndots
Definition: ares_private.h:271
ares_getaddrinfo
void ares_getaddrinfo(ares_channel channel, const char *name, const char *service, const struct ares_addrinfo_hints *hints, ares_addrinfo_callback callback, void *arg)
Definition: ares_getaddrinfo.c:580
ares__malloc_addrinfo
struct ares_addrinfo * ares__malloc_addrinfo()
Definition: ares_getaddrinfo.c:160
host_query::timeouts
int timeouts
Definition: ares_getaddrinfo.c:69
ARES_ECONNREFUSED
#define ARES_ECONNREFUSED
Definition: ares.h:113
ares__addrinfo_cat_nodes
void ares__addrinfo_cat_nodes(struct ares_addrinfo_node **head, struct ares_addrinfo_node *tail)
Definition: ares_getaddrinfo.c:201
ares_setup.h
tests.unit._exit_scenarios.port
port
Definition: _exit_scenarios.py:179
ares_addrinfo_cname::next
struct ares_addrinfo_cname * next
Definition: ares.h:613
fake_addrinfo
static int fake_addrinfo(const char *name, unsigned short port, const struct ares_addrinfo_hints *hints, struct ares_addrinfo *ai, ares_addrinfo_callback callback, void *arg)
Definition: ares_getaddrinfo.c:276
ares_addrinfo::nodes
struct ares_addrinfo_node * nodes
Definition: ares.h:618
ares_channeldata
Definition: ares_private.h:266
ares_addrinfo_cname
Definition: ares.h:609
bitncmp.h
ARES_EFILE
#define ARES_EFILE
Definition: ares.h:116
PATH_HOSTS
#define PATH_HOSTS
Definition: ares_private.h:94
ares_addrinfo::cnames
struct ares_addrinfo_cname * cnames
Definition: ares.h:617
benchmark.FILE
FILE
Definition: benchmark.py:21
C_IN
#define C_IN
Definition: ares_nameser.h:292
as_is_first
static int as_is_first(const struct host_query *hquery)
Definition: ares_getaddrinfo.c:754
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
ares_freeaddrinfo
CARES_EXTERN void ares_freeaddrinfo(struct ares_addrinfo *ai)
Definition: ares_freeaddrinfo.c:52
ares_channeldata::ndomains
int ndomains
Definition: ares_private.h:278
grpc::fclose
fclose(creds_file)
next
AllocList * next[kMaxLevel]
Definition: abseil-cpp/absl/base/internal/low_level_alloc.cc:100
ares_addrinfo_hints::ai_flags
int ai_flags
Definition: ares.h:622
ares_addrinfo_node::ai_next
struct ares_addrinfo_node * ai_next
Definition: ares.h:601
ares_free
void(* ares_free)(void *ptr)=default_free
Definition: ares_library_init.c:60
arg
struct arg arg
ARES_ESERVICE
#define ARES_ESERVICE
Definition: ares.h:139
ares_private.h
ares_channeldata::domains
char ** domains
Definition: ares_private.h:277
host_query::port
unsigned short port
Definition: ares_getaddrinfo.c:64
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
ares_nameser.h
host_query::callback
ares_addrinfo_callback callback
Definition: ares_getaddrinfo.c:65
ares__cat_domain
int ares__cat_domain(const char *name, const char *domain, char **s)
Definition: ares_search.c:214
ares_addrinfo_cname::name
char * name
Definition: ares.h:612
ares__sortaddrinfo
int ares__sortaddrinfo(ares_channel channel, struct ares_addrinfo_node *list_sentinel)
Definition: ares__sortaddrinfo.c:443
getenv
#define getenv(ptr)
Definition: ares_private.h:106
ARES_NI_UDP
#define ARES_NI_UDP
Definition: ares.h:179
ARES_ENOTIMP
#define ARES_ENOTIMP
Definition: ares.h:105
platform
Definition: test_arm_regression.c:18
host_query::next_domain
int next_domain
Definition: ares_getaddrinfo.c:74
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
ARES_EDESTRUCTION
#define ARES_EDESTRUCTION
Definition: ares.h:118
file_lookup
static int file_lookup(struct host_query *hquery)
Definition: ares_getaddrinfo.c:431
next_lookup
static void next_lookup(struct host_query *hquery, int status)
Definition: ares_getaddrinfo.c:506
ares__readaddrinfo
int ares__readaddrinfo(FILE *fp, const char *name, unsigned short port, const struct ares_addrinfo_hints *hints, struct ares_addrinfo *ai)
Definition: ares__readaddrinfo.c:35
default_hints
static const struct ares_addrinfo_hints default_hints
Definition: ares_getaddrinfo.c:77
generate_build_files.platform
dictionary platform
Definition: generate_build_files.py:990


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:43