Lines Matching refs:lookup

184 (*dighost_trying)(char *frm, dig_lookup_t *lookup);
192 cancel_lookup(dig_lookup_t *lookup);
207 check_next_lookup(dig_lookup_t *lookup);
406 * Create a server structure, which is part of the lookup structure.
632 * Create an empty lookup structure, which holds all the information needed
754 * Clone a lookup, perhaps copying the server list. This does not clone
756 * function, nor does it queue up the new lookup for processing.
843 * Requeue a lookup for further processing, perhaps copying the server
844 * list. The new lookup structure is returned to the caller, and is
847 * completion of the event may result in the next entry on the lookup
1283 save_opt(dig_lookup_t *lookup, char *code, char *value) {
1291 if (lookup->ednsoptscnt >= EDNSOPT_OPTIONS)
1308 if (lookup->ednsopts == NULL) {
1309 cloneopts(lookup, NULL);
1312 if (lookup->ednsopts[lookup->ednsoptscnt].value != NULL)
1313 free(lookup->ednsopts[lookup->ednsoptscnt].value);
1315 lookup->ednsopts[lookup->ednsoptscnt].code = num;
1316 lookup->ednsopts[lookup->ednsoptscnt].length = 0;
1317 lookup->ednsopts[lookup->ednsoptscnt].value = NULL;
1327 lookup->ednsopts[lookup->ednsoptscnt].value =
1329 lookup->ednsopts[lookup->ednsoptscnt].length =
1333 lookup->ednsoptscnt++;
1378 * and the lookup list is empty.
1381 * a whole or reseed the lookup list.
1402 dig_lookup_t *lookup;
1410 lookup = query->lookup;
1412 if (lookup->current_query == query)
1413 lookup->current_query = NULL;
1416 ISC_LIST_UNLINK(lookup->q, query, link);
1418 ISC_LIST_UNLINK(lookup->connecting, query, clink);
1442 * Try and clear out a lookup if we're done with it. Return 1 if
1443 * the lookup was successfully cleared. If 1 is returned, the
1444 * lookup pointer has been invalidated.
1447 try_clear_lookup(dig_lookup_t *lookup) {
1450 REQUIRE(lookup != NULL);
1452 debug("try_clear_lookup(%p)", lookup);
1454 if (ISC_LIST_HEAD(lookup->q) != NULL ||
1455 ISC_LIST_HEAD(lookup->connecting) != NULL)
1458 q = ISC_LIST_HEAD(lookup->q);
1464 q = ISC_LIST_HEAD(lookup->connecting);
1475 * At this point, we know there are no queries on the lookup,
1478 destroy_lookup(lookup);
1483 destroy_lookup(dig_lookup_t *lookup) {
1488 s = ISC_LIST_HEAD(lookup->my_server_list);
1490 debug("freeing server %p belonging to %p", s, lookup);
1493 ISC_LIST_DEQUEUE(lookup->my_server_list,
1497 if (lookup->sendmsg != NULL)
1498 dns_message_destroy(&lookup->sendmsg);
1499 if (lookup->querysig != NULL) {
1500 debug("freeing buffer %p", lookup->querysig);
1501 isc_buffer_free(&lookup->querysig);
1503 if (lookup->sendspace != NULL)
1504 free(lookup->sendspace);
1506 if (lookup->tsigctx != NULL)
1507 dst_context_destroy(&lookup->tsigctx);
1509 if (lookup->ecs_addr != NULL)
1510 free(lookup->ecs_addr);
1512 if (lookup->ednsopts != NULL) {
1515 if (lookup->ednsopts[i].value != NULL)
1516 free(lookup->ednsopts[i].value);
1518 free(lookup->ednsopts);
1521 free(lookup);
1525 * If we can, start the next lookup in the queue running.
1526 * This assumes that the lookup on the head of the queue hasn't been
1527 * started yet. It also removes the lookup from the head of the queue,
1537 * If there's a current lookup running, we really shouldn't get
1544 * Put the current lookup somewhere so cancel_all can find it
1558 * If we can, clear the current lookup and start the next one running.
1559 * This calls try_clear_lookup, so may invalidate the lookup pointer.
1562 check_next_lookup(dig_lookup_t *lookup) {
1566 debug("check_next_lookup(%p)", lookup);
1568 if (ISC_LIST_HEAD(lookup->q) != NULL) {
1572 if (try_clear_lookup(lookup)) {
1579 * Create and queue a new lookup as a followup to the current lookup,
1581 * name server search modes to start a new lookup using servers from
1587 dig_lookup_t *lookup = NULL;
1603 debug("following up %s", query->lookup->textname);
1628 if (query->lookup->trace && !query->lookup->trace_root) {
1633 domain = dns_fixedname_name(&query->lookup->fdomain);
1654 if (query->lookup->trace_root &&
1655 query->lookup->nsfound >= MXSERV)
1660 query->lookup->nsfound++;
1666 /* Initialize lookup if we've not yet */
1671 lookup = requeue_lookup(query->lookup,
1673 cancel_lookup(query->lookup);
1674 lookup->doing_xfr = 0;
1675 if (!lookup->trace_root &&
1677 lookup->trace = 0;
1679 lookup->trace = query->lookup->trace;
1680 lookup->ns_search_only =
1681 query->lookup->ns_search_only;
1682 lookup->trace_root = 0;
1683 if (lookup->ns_search_only)
1684 lookup->recurse = 0;
1685 domain = dns_fixedname_name(&lookup->fdomain);
1689 num = getaddresses(lookup, namestr, &lresult);
1708 if (lookup == NULL &&
1710 (query->lookup->trace || query->lookup->ns_search_only))
1724 for (srv = ISC_LIST_HEAD(lookup->my_server_list);
1726 srv = ISC_LIST_HEAD(lookup->my_server_list)) {
1734 ISC_LIST_DEQUEUE(lookup->my_server_list, srv, link);
1738 ISC_LIST_APPENDLIST(lookup->my_server_list,
1746 * Create and queue a new lookup using the next origin from the search
1803 * Insert an SOA record into the sendmessage in a lookup. Used for
1807 insert_soa(dig_lookup_t *lookup) {
1816 soa.serial = lookup->ixfr_serial;
1821 soa.common.rdclass = lookup->rdclass;
1830 isc_buffer_init(&lookup->rdatabuf, lookup->rdatastore,
1831 sizeof(lookup->rdatastore));
1833 result = dns_message_gettemprdata(lookup->sendmsg, &rdata);
1836 result = dns_rdata_fromstruct_soa(rdata, lookup->rdclass,
1838 &lookup->rdatabuf);
1841 result = dns_message_gettemprdatalist(lookup->sendmsg, &rdatalist);
1844 result = dns_message_gettemprdataset(lookup->sendmsg, &rdataset);
1849 rdatalist->rdclass = lookup->rdclass;
1854 result = dns_message_gettempname(lookup->sendmsg, &soaname);
1857 dns_name_clone(lookup->name, soaname);
1860 dns_message_addname(lookup->sendmsg, soaname, DNS_SECTION_AUTHORITY);
1893 * Setup the supplied lookup structure, making it ready to start sending
1899 setup_lookup(dig_lookup_t *lookup) {
1911 REQUIRE(lookup != NULL);
1914 debug("setup_lookup(%p)", lookup);
1917 &lookup->sendmsg);
1920 if (lookup->new_search) {
1921 debug("resetting lookup counter.");
1925 if (ISC_LIST_EMPTY(lookup->my_server_list)) {
1926 if (lookup->trace && lookup->trace_root) {
1929 &lookup->my_server_list);
1933 &lookup->my_server_list);
1936 result = dns_message_gettempname(lookup->sendmsg, &lookup->name);
1938 dns_name_init(lookup->name, NULL);
1940 isc_buffer_init(&lookup->namebuf, lookup->name_space,
1941 sizeof(lookup->name_space));
1942 isc_buffer_init(&lookup->onamebuf, lookup->oname_space,
1943 sizeof(lookup->oname_space));
1947 * (which produces an absolute lookup). Otherwise, take the origin
1952 if (lookup->new_search) {
1953 if ((count_dots(lookup->textname) >= ndots) || !usesearch) {
1954 lookup->origin = NULL; /* Force abs lookup */
1955 lookup->done_as_is = 1;
1956 lookup->need_search = usesearch;
1957 } else if (lookup->origin == NULL && usesearch) {
1958 lookup->origin = ISC_LIST_HEAD(search_list);
1959 lookup->need_search = 0;
1963 if (lookup->origin != NULL) {
1964 debug("trying origin %s", lookup->origin->origin);
1965 result = dns_message_gettempname(lookup->sendmsg,
1966 &lookup->oname);
1968 dns_name_init(lookup->oname, NULL);
1970 len = (unsigned int) strlen(lookup->origin->origin);
1971 isc_buffer_init(&b, lookup->origin->origin, len);
1973 result = dns_name_fromtext(lookup->oname, &b, dns_rootname,
1974 0, &lookup->onamebuf);
1976 dns_message_puttempname(lookup->sendmsg,
1977 &lookup->name);
1978 dns_message_puttempname(lookup->sendmsg,
1979 &lookup->oname);
1981 lookup->origin->origin,
1984 if (lookup->trace && lookup->trace_root) {
1985 dns_name_clone(dns_rootname, lookup->name);
1992 len = (unsigned int) strlen(lookup->textname);
1993 isc_buffer_init(&b, lookup->textname, len);
1999 lookup->oname,
2000 lookup->name,
2001 &lookup->namebuf);
2003 result = dns_name_copy(name, lookup->name,
2004 &lookup->namebuf);
2006 dns_message_puttempname(lookup->sendmsg,
2007 &lookup->name);
2008 dns_message_puttempname(lookup->sendmsg,
2009 &lookup->oname);
2013 lookup->textname,
2017 dns_message_puttempname(lookup->sendmsg, &lookup->oname);
2021 if (lookup->trace && lookup->trace_root)
2022 dns_name_clone(dns_rootname, lookup->name);
2024 len = (unsigned int) strlen(lookup->textname);
2025 isc_buffer_init(&b, lookup->textname, len);
2027 result = dns_name_fromtext(lookup->name, &b,
2029 &lookup->namebuf);
2032 dns_message_puttempname(lookup->sendmsg,
2033 &lookup->name);
2035 "(%s)", lookup->textname,
2039 dns_name_format(lookup->name, store, sizeof(store));
2040 dighost_trying(store, lookup);
2041 INSIST(dns_name_isabsolute(lookup->name));
2044 lookup->sendmsg->id = (unsigned short)id & 0xFFFF;
2045 lookup->sendmsg->opcode = lookup->opcode;
2046 lookup->msgcounter = 0;
2051 if (lookup->trace || (lookup->ns_search_only && !lookup->trace_root))
2052 lookup->recurse = 0;
2054 if (lookup->recurse &&
2055 lookup->rdtype != dns_rdatatype_axfr &&
2056 lookup->rdtype != dns_rdatatype_ixfr) {
2058 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_RD;
2062 if (lookup->aaonly) {
2064 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_AA;
2067 if (lookup->adflag) {
2069 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_AD;
2072 if (lookup->cdflag) {
2074 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_CD;
2077 dns_message_addname(lookup->sendmsg, lookup->name,
2080 if (lookup->trace && lookup->trace_root) {
2081 lookup->qrdtype = lookup->rdtype;
2082 lookup->rdtype = dns_rdatatype_ns;
2085 if ((lookup->rdtype == dns_rdatatype_axfr) ||
2086 (lookup->rdtype == dns_rdatatype_ixfr)) {
2090 if (lookup->rdtype == dns_rdatatype_axfr) {
2091 lookup->doing_xfr = 1;
2092 lookup->tcp_mode = 1;
2093 } else if (lookup->tcp_mode) {
2094 lookup->doing_xfr = 1;
2098 add_question(lookup->sendmsg, lookup->name, lookup->rdclass,
2099 lookup->rdtype);
2102 if (lookup->rdtype == dns_rdatatype_ixfr)
2103 insert_soa(lookup);
2106 lookup->tsigctx = NULL;
2107 lookup->querysig = NULL;
2110 result = dns_message_settsigkey(lookup->sendmsg, tsigkey);
2114 lookup->sendspace = malloc(COMMSIZE);
2115 if (lookup->sendspace == NULL)
2122 isc_buffer_init(&lookup->renderbuf, lookup->sendspace, COMMSIZE);
2123 result = dns_message_renderbegin(lookup->sendmsg, &cctx,
2124 &lookup->renderbuf);
2126 if (lookup->udpsize > 0 || lookup->dnssec ||
2127 lookup->edns > -1 || lookup->ecs_addr != NULL)
2134 if (lookup->udpsize == 0)
2135 lookup->udpsize = 4096;
2136 if (lookup->edns < 0)
2137 lookup->edns = 0;
2139 if (lookup->nsid) {
2147 if (lookup->ecs_addr != NULL) {
2156 sa = (struct sockaddr *)lookup->ecs_addr;
2157 plen = lookup->ecs_plen;
2230 if (lookup->sit) {
2233 if (lookup->sitvalue != NULL) {
2235 result = isc_hex_decodestring(lookup->sitvalue,
2248 if (lookup->expire) {
2256 if (lookup->ednsoptscnt != 0) {
2257 INSIST(i + lookup->ednsoptscnt <= MAXOPTS);
2258 memmove(&opts[i], lookup->ednsopts,
2259 sizeof(dns_ednsopt_t) * lookup->ednsoptscnt);
2260 i += lookup->ednsoptscnt;
2263 flags = lookup->ednsflags;
2265 if (lookup->dnssec)
2267 add_opt(lookup->sendmsg, lookup->udpsize,
2268 lookup->edns, flags, opts, i);
2271 result = dns_message_rendersection(lookup->sendmsg,
2274 result = dns_message_rendersection(lookup->sendmsg,
2277 result = dns_message_renderend(lookup->sendmsg);
2286 if (isc_buffer_usedlength(&lookup->renderbuf) > 512)
2287 lookup->tcp_mode = 1;
2289 lookup->pending = 0;
2291 for (serv = ISC_LIST_HEAD(lookup->my_server_list);
2298 debug("create query %p linked to lookup %p",
2299 query, lookup);
2300 query->lookup = lookup;
2330 query->sendbuf = lookup->renderbuf;
2334 ISC_LIST_ENQUEUE(lookup->q, query, link);
2338 if (!ISC_LIST_EMPTY(lookup->q) && qr) {
2340 dighost_printmessage(ISC_LIST_HEAD(lookup->q), lookup->sendmsg,
2375 l = query->lookup;
2393 * Cancel a lookup, sending isc_socket_cancel() requests to all outstanding
2395 * query and lookup structures
2398 cancel_lookup(dig_lookup_t *lookup) {
2402 query = ISC_LIST_HEAD(lookup->q);
2414 lookup->pending = 0;
2415 lookup->retries = 0;
2430 l = query->lookup;
2479 * query. When we retry TCP, we requeue the whole lookup, which should
2490 l = query->lookup;
2492 query->lookup->current_query = query;
2514 l = query->lookup;
2599 l = query->lookup;
2602 debug("working on lookup %p, query %p", query->lookup, query);
2633 debug("recving with lookup=%p, query=%p, sock=%p",
2634 query->lookup, query, query->sock);
2659 * new TCP lookup. Otherwise, cancel the lookup.
2672 l = query->lookup;
2677 if ((query != NULL) && (query->lookup->current_query != NULL) &&
2678 ISC_LINK_LINKED(query->lookup->current_query, link) &&
2679 (ISC_LIST_NEXT(query->lookup->current_query, link) != NULL)) {
2681 cq = query->lookup->current_query;
2756 l = query->lookup;
2769 l = query->lookup;
2800 debug("recving with lookup=%p, query=%p", query->lookup, query);
2824 if (!query->lookup->pending) {
2831 l = query->lookup;
2905 query->lookup->textname,
2913 l = query->lookup;
2926 query->servname, query->lookup->textname,
2937 l = query->lookup;
2974 uint32_t ixfr_serial = query->lookup->ixfr_serial, serial;
2976 int ixfr = query->lookup->rdtype == dns_rdatatype_ixfr;
2977 int axfr = query->lookup->rdtype == dns_rdatatype_axfr;
3232 debug("lookup=%p, query=%p", query->lookup, query);
3234 l = query->lookup;
3579 if (!next_origin(query->lookup) || showsearch) {
3649 if (!query->lookup->ns_search_only)
3650 query->lookup->pending = 0;
3651 if (!query->lookup->ns_search_only ||
3652 query->lookup->trace_root || docancel) {
3698 getaddresses(dig_lookup_t *lookup, const char *host, isc_result_t *resultp) {
3725 ISC_LIST_APPEND(lookup->my_server_list, srv, link);
3732 * Initiate either a TCP or UDP lookup
3735 do_lookup(dig_lookup_t *lookup) {
3738 REQUIRE(lookup != NULL);
3741 lookup->pending = 1;
3742 query = ISC_LIST_HEAD(lookup->q);
3744 if (lookup->tcp_mode)
3763 * Make everything on the lookup queue go away. Mainly used by the