• Home
  • Raw
  • Download

Lines Matching refs:hquery

112 static int as_is_first(const struct host_query *hquery);
113 static int as_is_only(const struct host_query* hquery);
114 static int next_dns_lookup(struct host_query *hquery);
374 static void end_hquery(struct host_query *hquery, int status) in end_hquery() argument
380 if (!(hquery->hints.ai_flags & ARES_AI_NOSORT) && hquery->ai->nodes) in end_hquery()
382 sentinel.ai_next = hquery->ai->nodes; in end_hquery()
383 ares__sortaddrinfo(hquery->channel, &sentinel); in end_hquery()
384 hquery->ai->nodes = sentinel.ai_next; in end_hquery()
386 next = hquery->ai->nodes; in end_hquery()
390 next->ai_socktype = hquery->hints.ai_socktype; in end_hquery()
391 next->ai_protocol = hquery->hints.ai_protocol; in end_hquery()
398 ares_freeaddrinfo(hquery->ai); in end_hquery()
399 hquery->ai = NULL; in end_hquery()
402 hquery->callback(hquery->arg, status, hquery->timeouts, hquery->ai); in end_hquery()
403 ares_free(hquery->name); in end_hquery()
404 ares_free(hquery); in end_hquery()
407 static int file_lookup(struct host_query *hquery) in file_lookup() argument
414 if (hquery->hints.ai_flags & ARES_AI_ENVHOSTS) in file_lookup()
477 status = ares__readaddrinfo(fp, hquery->name, hquery->port, &hquery->hints, hquery->ai); in file_lookup()
483 if (status == ARES_ENOTFOUND && strcmp(hquery->name, "localhost") == 0) in file_lookup()
485 return ares__addrinfo_localhost(hquery->name, hquery->port, in file_lookup()
486 &hquery->hints, hquery->ai); in file_lookup()
492 static void next_lookup(struct host_query *hquery, int status) in next_lookup() argument
494 switch (*hquery->remaining_lookups) in next_lookup()
500 if (strcmp(hquery->name, "localhost") != 0) in next_lookup()
503 if (next_dns_lookup(hquery)) in next_lookup()
507 hquery->remaining_lookups++; in next_lookup()
508 next_lookup(hquery, status); in next_lookup()
513 if (file_lookup(hquery) == ARES_SUCCESS) in next_lookup()
515 end_hquery(hquery, ARES_SUCCESS); in next_lookup()
518 hquery->remaining_lookups++; in next_lookup()
519 next_lookup(hquery, status); in next_lookup()
523 end_hquery(hquery, status); in next_lookup()
531 struct host_query *hquery = (struct host_query*)arg; in host_callback() local
533 hquery->timeouts += timeouts; in host_callback()
534 hquery->remaining--; in host_callback()
538 addinfostatus = ares__parse_into_addrinfo(abuf, alen, 1, hquery->port, hquery->ai); in host_callback()
541 if (!hquery->remaining) in host_callback()
546 end_hquery(hquery, addinfostatus); in host_callback()
548 else if (hquery->ai->nodes) in host_callback()
551 end_hquery(hquery, ARES_SUCCESS); in host_callback()
557 hquery->nodata_cnt++; in host_callback()
558 next_lookup(hquery, hquery->nodata_cnt?ARES_ENODATA:status); in host_callback()
565 end_hquery(hquery, status); in host_callback()
569 end_hquery(hquery, status); in host_callback()
581 struct host_query *hquery; in ares_getaddrinfo() local
665 hquery = ares_malloc(sizeof(struct host_query)); in ares_getaddrinfo()
666 if (!hquery) in ares_getaddrinfo()
674 hquery->name = ares_strdup(name); in ares_getaddrinfo()
676 if (!hquery->name) in ares_getaddrinfo()
678 ares_free(hquery); in ares_getaddrinfo()
684 hquery->port = port; in ares_getaddrinfo()
685 hquery->channel = channel; in ares_getaddrinfo()
686 hquery->hints = *hints; in ares_getaddrinfo()
687 hquery->sent_family = -1; /* nothing is sent yet */ in ares_getaddrinfo()
688 hquery->callback = callback; in ares_getaddrinfo()
689 hquery->arg = arg; in ares_getaddrinfo()
690 hquery->remaining_lookups = channel->lookups; in ares_getaddrinfo()
691 hquery->timeouts = 0; in ares_getaddrinfo()
692 hquery->ai = ai; in ares_getaddrinfo()
693 hquery->next_domain = -1; in ares_getaddrinfo()
694 hquery->remaining = 0; in ares_getaddrinfo()
695 hquery->nodata_cnt = 0; in ares_getaddrinfo()
698 next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */); in ares_getaddrinfo()
701 static int next_dns_lookup(struct host_query *hquery) in next_dns_lookup() argument
708 if (hquery->next_domain == -1) in next_dns_lookup()
710 if (as_is_first(hquery)) in next_dns_lookup()
712 s = hquery->name; in next_dns_lookup()
714 hquery->next_domain = 0; in next_dns_lookup()
718 if (!s && hquery->next_domain == hquery->channel->ndomains) { in next_dns_lookup()
719 if (!as_is_first(hquery)) in next_dns_lookup()
721 s = hquery->name; in next_dns_lookup()
723 hquery->next_domain++; in next_dns_lookup()
726 if (!s && hquery->next_domain < hquery->channel->ndomains && !as_is_only(hquery)) in next_dns_lookup()
729 hquery->name, in next_dns_lookup()
730 hquery->channel->domains[hquery->next_domain++], in next_dns_lookup()
740 switch (hquery->hints.ai_family) in next_dns_lookup()
743 hquery->remaining += 1; in next_dns_lookup()
744 ares_query(hquery->channel, s, C_IN, T_A, host_callback, hquery); in next_dns_lookup()
747 hquery->remaining += 1; in next_dns_lookup()
748 ares_query(hquery->channel, s, C_IN, T_AAAA, host_callback, hquery); in next_dns_lookup()
751 hquery->remaining += 2; in next_dns_lookup()
752 ares_query(hquery->channel, s, C_IN, T_A, host_callback, hquery); in next_dns_lookup()
753 ares_query(hquery->channel, s, C_IN, T_AAAA, host_callback, hquery); in next_dns_lookup()
765 assert(!hquery->ai->nodes); in next_dns_lookup()
770 static int as_is_first(const struct host_query* hquery) in as_is_first() argument
774 size_t nname = hquery->name?strlen(hquery->name):0; in as_is_first()
775 for (p = hquery->name; *p; p++) in as_is_first()
782 if (nname && hquery->name[nname-1] == '.') in as_is_first()
787 return ndots >= hquery->channel->ndots; in as_is_first()
790 static int as_is_only(const struct host_query* hquery) in as_is_only() argument
792 size_t nname = hquery->name?strlen(hquery->name):0; in as_is_only()
793 if (nname && hquery->name[nname-1] == '.') in as_is_only()