Lines Matching refs:lookup
368 (*dighost_trying)(char *frm, dig_lookup_t *lookup);
376 cancel_lookup(dig_lookup_t *lookup);
391 check_next_lookup(dig_lookup_t *lookup);
592 * Create a server structure, which is part of the lookup structure.
757 * Create an empty lookup structure, which holds all the information needed
901 * Clone a lookup, perhaps copying the server list. This does not clone
903 * function, nor does it queue up the new lookup for processing.
1011 * Requeue a lookup for further processing, perhaps copying the server
1012 * list. The new lookup structure is returned to the caller, and is
1015 * completion of the event may result in the next entry on the lookup
1654 save_opt(dig_lookup_t *lookup, char *code, char *value) {
1661 if (lookup->ednsoptscnt >= EDNSOPT_OPTIONS)
1678 if (lookup->ednsopts == NULL) {
1679 cloneopts(lookup, NULL);
1682 if (lookup->ednsopts[lookup->ednsoptscnt].value != NULL)
1683 isc_mem_free(mctx, lookup->ednsopts[lookup->ednsoptscnt].value);
1685 lookup->ednsopts[lookup->ednsoptscnt].code = num;
1686 lookup->ednsopts[lookup->ednsoptscnt].length = 0;
1687 lookup->ednsopts[lookup->ednsoptscnt].value = NULL;
1697 lookup->ednsopts[lookup->ednsoptscnt].value =
1699 lookup->ednsopts[lookup->ednsoptscnt].length =
1703 lookup->ednsoptscnt++;
1748 * and the lookup list is empty.
1751 * a whole or reseed the lookup list.
1772 dig_lookup_t *lookup;
1780 lookup = query->lookup;
1782 if (lookup->current_query == query)
1783 lookup->current_query = NULL;
1786 ISC_LIST_UNLINK(lookup->q, query, link);
1788 ISC_LIST_UNLINK(lookup->connecting, query, clink);
1812 * Try and clear out a lookup if we're done with it. Return ISC_TRUE if
1813 * the lookup was successfully cleared. If ISC_TRUE is returned, the
1814 * lookup pointer has been invalidated.
1817 try_clear_lookup(dig_lookup_t *lookup) {
1820 REQUIRE(lookup != NULL);
1822 debug("try_clear_lookup(%p)", lookup);
1824 if (ISC_LIST_HEAD(lookup->q) != NULL ||
1825 ISC_LIST_HEAD(lookup->connecting) != NULL)
1828 q = ISC_LIST_HEAD(lookup->q);
1834 q = ISC_LIST_HEAD(lookup->connecting);
1845 * At this point, we know there are no queries on the lookup,
1848 destroy_lookup(lookup);
1853 destroy_lookup(dig_lookup_t *lookup) {
1858 s = ISC_LIST_HEAD(lookup->my_server_list);
1860 debug("freeing server %p belonging to %p", s, lookup);
1863 ISC_LIST_DEQUEUE(lookup->my_server_list,
1867 if (lookup->sendmsg != NULL)
1868 dns_message_destroy(&lookup->sendmsg);
1869 if (lookup->querysig != NULL) {
1870 debug("freeing buffer %p", lookup->querysig);
1871 isc_buffer_free(&lookup->querysig);
1873 if (lookup->sendspace != NULL)
1874 isc_mempool_put(commctx, lookup->sendspace);
1876 if (lookup->tsigctx != NULL)
1877 dst_context_destroy(&lookup->tsigctx);
1879 if (lookup->ecs_addr != NULL)
1880 isc_mem_free(mctx, lookup->ecs_addr);
1882 if (lookup->ednsopts != NULL) {
1885 if (lookup->ednsopts[i].value != NULL)
1886 isc_mem_free(mctx, lookup->ednsopts[i].value);
1888 isc_mem_free(mctx, lookup->ednsopts);
1891 isc_mem_free(mctx, lookup);
1895 * If we can, start the next lookup in the queue running.
1896 * This assumes that the lookup on the head of the queue hasn't been
1897 * started yet. It also removes the lookup from the head of the queue,
1907 * If there's a current lookup running, we really shouldn't get
1914 * Put the current lookup somewhere so cancel_all can find it
2010 * If we can, clear the current lookup and start the next one running.
2011 * This calls try_clear_lookup, so may invalidate the lookup pointer.
2014 check_next_lookup(dig_lookup_t *lookup) {
2018 debug("check_next_lookup(%p)", lookup);
2020 if (ISC_LIST_HEAD(lookup->q) != NULL) {
2024 if (try_clear_lookup(lookup)) {
2031 * Create and queue a new lookup as a followup to the current lookup,
2033 * name server search modes to start a new lookup using servers from
2039 dig_lookup_t *lookup = NULL;
2055 debug("following up %s", query->lookup->textname);
2080 if (query->lookup->trace && !query->lookup->trace_root) {
2085 domain = dns_fixedname_name(&query->lookup->fdomain);
2106 if (query->lookup->trace_root &&
2107 query->lookup->nsfound >= MXSERV)
2112 query->lookup->nsfound++;
2118 /* Initialize lookup if we've not yet */
2123 lookup = requeue_lookup(query->lookup,
2125 cancel_lookup(query->lookup);
2126 lookup->doing_xfr = ISC_FALSE;
2127 if (!lookup->trace_root &&
2129 lookup->trace = ISC_FALSE;
2131 lookup->trace = query->lookup->trace;
2132 lookup->ns_search_only =
2133 query->lookup->ns_search_only;
2134 lookup->trace_root = ISC_FALSE;
2135 if (lookup->ns_search_only)
2136 lookup->recurse = ISC_FALSE;
2137 domain = dns_fixedname_name(&lookup->fdomain);
2141 num = getaddresses(lookup, namestr, &lresult);
2160 if (lookup == NULL &&
2162 (query->lookup->trace || query->lookup->ns_search_only))
2176 for (srv = ISC_LIST_HEAD(lookup->my_server_list);
2178 srv = ISC_LIST_HEAD(lookup->my_server_list)) {
2187 ISC_LIST_DEQUEUE(lookup->my_server_list, srv, link);
2191 ISC_LIST_APPENDLIST(lookup->my_server_list,
2199 * Create and queue a new lookup using the next origin from the search
2257 * Insert an SOA record into the sendmessage in a lookup. Used for
2261 insert_soa(dig_lookup_t *lookup) {
2271 soa.serial = lookup->ixfr_serial;
2276 soa.common.rdclass = lookup->rdclass;
2285 isc_buffer_init(&lookup->rdatabuf, lookup->rdatastore,
2286 sizeof(lookup->rdatastore));
2288 result = dns_message_gettemprdata(lookup->sendmsg, &rdata);
2291 result = dns_rdata_fromstruct(rdata, lookup->rdclass,
2293 &lookup->rdatabuf);
2296 result = dns_message_gettemprdatalist(lookup->sendmsg, &rdatalist);
2299 result = dns_message_gettemprdataset(lookup->sendmsg, &rdataset);
2304 rdatalist->rdclass = lookup->rdclass;
2309 result = dns_message_gettempname(lookup->sendmsg, &soaname);
2312 dns_name_clone(lookup->name, soaname);
2315 dns_message_addname(lookup->sendmsg, soaname, DNS_SECTION_AUTHORITY);
2326 * Setup the supplied lookup structure, making it ready to start sending
2332 setup_lookup(dig_lookup_t *lookup) {
2349 result = dns_name_settotextfilter(lookup->idnout ?
2354 REQUIRE(lookup != NULL);
2357 debug("setup_lookup(%p)", lookup);
2360 &lookup->sendmsg);
2363 if (lookup->new_search) {
2364 debug("resetting lookup counter.");
2368 if (ISC_LIST_EMPTY(lookup->my_server_list)) {
2370 clone_server_list(server_list, &lookup->my_server_list);
2372 result = dns_message_gettempname(lookup->sendmsg, &lookup->name);
2374 dns_name_init(lookup->name, NULL);
2376 isc_buffer_init(&lookup->namebuf, lookup->name_space,
2377 sizeof(lookup->name_space));
2378 isc_buffer_init(&lookup->onamebuf, lookup->oname_space,
2379 sizeof(lookup->oname_space));
2387 mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, lookup->textname,
2394 * (which produces an absolute lookup). Otherwise, take the origin
2399 if (lookup->new_search) {
2402 lookup->origin = NULL; /* Force abs lookup */
2403 lookup->done_as_is = ISC_TRUE;
2404 lookup->need_search = usesearch;
2405 } else if (lookup->origin == NULL && usesearch) {
2406 lookup->origin = ISC_LIST_HEAD(search_list);
2407 lookup->need_search = ISC_FALSE;
2410 if ((count_dots(lookup->textname) >= ndots) || !usesearch) {
2411 lookup->origin = NULL; /* Force abs lookup */
2412 lookup->done_as_is = ISC_TRUE;
2413 lookup->need_search = usesearch;
2414 } else if (lookup->origin == NULL && usesearch) {
2415 lookup->origin = ISC_LIST_HEAD(search_list);
2416 lookup->need_search = ISC_FALSE;
2422 if (lookup->origin != NULL) {
2424 lookup->origin->origin, utf8_origin,
2436 if (lookup->origin != NULL) {
2437 debug("trying origin %s", lookup->origin->origin);
2438 result = dns_message_gettempname(lookup->sendmsg,
2439 &lookup->oname);
2441 dns_name_init(lookup->oname, NULL);
2443 len = (unsigned int) strlen(lookup->origin->origin);
2444 isc_buffer_init(&b, lookup->origin->origin, len);
2446 result = dns_name_fromtext(lookup->oname, &b, dns_rootname,
2447 0, &lookup->onamebuf);
2449 dns_message_puttempname(lookup->sendmsg,
2450 &lookup->name);
2451 dns_message_puttempname(lookup->sendmsg,
2452 &lookup->oname);
2454 lookup->origin->origin,
2457 if (lookup->trace && lookup->trace_root) {
2458 dns_name_clone(dns_rootname, lookup->name);
2465 len = (unsigned int) strlen(lookup->textname);
2466 isc_buffer_init(&b, lookup->textname, len);
2472 lookup->oname,
2473 lookup->name,
2474 &lookup->namebuf);
2476 result = dns_name_copy(name, lookup->name,
2477 &lookup->namebuf);
2479 dns_message_puttempname(lookup->sendmsg,
2480 &lookup->name);
2481 dns_message_puttempname(lookup->sendmsg,
2482 &lookup->oname);
2486 lookup->textname,
2490 dns_message_puttempname(lookup->sendmsg, &lookup->oname);
2495 if (lookup->trace && lookup->trace_root)
2496 dns_name_clone(dns_rootname, lookup->name);
2502 result = dns_name_fromtext(lookup->name, &b,
2504 &lookup->namebuf);
2506 len = (unsigned int) strlen(lookup->textname);
2507 isc_buffer_init(&b, lookup->textname, len);
2509 result = dns_name_fromtext(lookup->name, &b,
2511 &lookup->namebuf);
2515 dns_message_puttempname(lookup->sendmsg,
2516 &lookup->name);
2518 "(%s)", lookup->textname,
2522 dns_name_format(lookup->name, store, sizeof(store));
2523 dighost_trying(store, lookup);
2524 INSIST(dns_name_isabsolute(lookup->name));
2527 lookup->sendmsg->id = (unsigned short)id & 0xFFFF;
2528 lookup->sendmsg->opcode = lookup->opcode;
2529 lookup->msgcounter = 0;
2534 if (lookup->trace || (lookup->ns_search_only && !lookup->trace_root))
2535 lookup->recurse = ISC_FALSE;
2537 if (lookup->recurse &&
2538 lookup->rdtype != dns_rdatatype_axfr &&
2539 lookup->rdtype != dns_rdatatype_ixfr) {
2541 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_RD;
2545 if (lookup->aaonly) {
2547 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_AA;
2550 if (lookup->adflag) {
2552 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_AD;
2555 if (lookup->cdflag) {
2557 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_CD;
2560 if (lookup->zflag) {
2562 lookup->sendmsg->flags |= 0x0040U;
2565 dns_message_addname(lookup->sendmsg, lookup->name,
2568 if (lookup->trace && lookup->trace_root) {
2569 lookup->qrdtype = lookup->rdtype;
2570 lookup->rdtype = dns_rdatatype_ns;
2573 if ((lookup->rdtype == dns_rdatatype_axfr) ||
2574 (lookup->rdtype == dns_rdatatype_ixfr)) {
2578 if (lookup->rdtype == dns_rdatatype_axfr) {
2579 lookup->doing_xfr = ISC_TRUE;
2580 lookup->tcp_mode = ISC_TRUE;
2581 } else if (lookup->tcp_mode) {
2582 lookup->doing_xfr = ISC_TRUE;
2586 if (!lookup->header_only)
2587 add_question(lookup->sendmsg, lookup->name, lookup->rdclass,
2588 lookup->rdtype);
2591 if (lookup->rdtype == dns_rdatatype_ixfr)
2592 insert_soa(lookup);
2595 lookup->tsigctx = NULL;
2596 lookup->querysig = NULL;
2599 result = dns_message_settsigkey(lookup->sendmsg, key);
2603 lookup->sendspace = isc_mempool_get(commctx);
2604 if (lookup->sendspace == NULL)
2611 isc_buffer_init(&lookup->renderbuf, lookup->sendspace, COMMSIZE);
2612 result = dns_message_renderbegin(lookup->sendmsg, &cctx,
2613 &lookup->renderbuf);
2615 if (lookup->udpsize > 0 || lookup->dnssec ||
2616 lookup->edns > -1 || lookup->ecs_addr != NULL)
2623 if (lookup->udpsize == 0)
2624 lookup->udpsize = 4096;
2625 if (lookup->edns < 0)
2626 lookup->edns = 0;
2628 if (lookup->nsid) {
2636 if (lookup->ecs_addr != NULL) {
2645 sa = &lookup->ecs_addr->type.sa;
2646 plen = lookup->ecs_addr->length;
2719 if (lookup->sendcookie) {
2722 if (lookup->cookie != NULL) {
2725 result = isc_hex_decodestring(lookup->cookie,
2738 if (lookup->expire) {
2746 if (lookup->ednsoptscnt != 0) {
2747 INSIST(i + lookup->ednsoptscnt <= MAXOPTS);
2748 memmove(&opts[i], lookup->ednsopts,
2749 sizeof(dns_ednsopt_t) * lookup->ednsoptscnt);
2750 i += lookup->ednsoptscnt;
2753 flags = lookup->ednsflags;
2755 if (lookup->dnssec)
2757 add_opt(lookup->sendmsg, lookup->udpsize,
2758 lookup->edns, flags, opts, i);
2761 result = dns_message_rendersection(lookup->sendmsg,
2764 result = dns_message_rendersection(lookup->sendmsg,
2767 result = dns_message_renderend(lookup->sendmsg);
2776 if (isc_buffer_usedlength(&lookup->renderbuf) > 512)
2777 lookup->tcp_mode = ISC_TRUE;
2779 lookup->pending = ISC_FALSE;
2781 for (serv = ISC_LIST_HEAD(lookup->my_server_list);
2788 debug("create query %p linked to lookup %p",
2789 query, lookup);
2790 query->lookup = lookup;
2820 query->sendbuf = lookup->renderbuf;
2824 ISC_LIST_ENQUEUE(lookup->q, query, link);
2828 if (!ISC_LIST_EMPTY(lookup->q) && qr) {
2830 dighost_printmessage(ISC_LIST_HEAD(lookup->q), lookup->sendmsg,
2832 if (lookup->stats)
2834 isc_buffer_usedlength(&lookup->renderbuf));
2870 l = query->lookup;
2889 * Cancel a lookup, sending isc_socket_cancel() requests to all outstanding
2891 * query and lookup structures
2894 cancel_lookup(dig_lookup_t *lookup) {
2898 query = ISC_LIST_HEAD(lookup->q);
2910 lookup->pending = ISC_FALSE;
2911 lookup->retries = 0;
2926 l = query->lookup;
2975 * query. When we retry TCP, we requeue the whole lookup, which should
2986 l = query->lookup;
2988 query->lookup->current_query = query;
3014 l = query->lookup;
3035 l = query->lookup;
3062 if (query->lookup->dscp != -1)
3063 isc_socket_dscp(query->sock, query->lookup->dscp);
3064 isc_socket_ipv6only(query->sock, ISC_TF(!query->lookup->mapped));
3124 l = query->lookup;
3127 debug("working on lookup %p, query %p", query->lookup, query);
3149 l = query->lookup;
3166 if (query->lookup->dscp != -1)
3167 isc_socket_dscp(query->sock, query->lookup->dscp);
3169 ISC_TF(!query->lookup->mapped));
3184 debug("recving with lookup=%p, query=%p, sock=%p",
3185 query->lookup, query, query->sock);
3210 * new TCP lookup. Otherwise, cancel the lookup.
3224 l = query->lookup;
3229 if ((query != NULL) && (query->lookup->current_query != NULL) &&
3230 ISC_LINK_LINKED(query->lookup->current_query, link) &&
3231 (ISC_LIST_NEXT(query->lookup->current_query, link) != NULL)) {
3233 cq = query->lookup->current_query;
3311 l = query->lookup;
3325 l = query->lookup;
3358 debug("recving with lookup=%p, query=%p", query->lookup, query);
3383 if (!query->lookup->pending) {
3390 l = query->lookup;
3430 check_next_lookup(query->lookup);
3468 query->lookup->textname,
3476 l = query->lookup;
3490 query->servname, query->lookup->textname,
3501 l = query->lookup;
3540 isc_uint32_t ixfr_serial = query->lookup->ixfr_serial, serial;
3542 isc_boolean_t ixfr = query->lookup->rdtype == dns_rdatatype_ixfr;
3543 isc_boolean_t axfr = query->lookup->rdtype == dns_rdatatype_axfr;
3808 debug("lookup=%p, query=%p", query->lookup, query);
3810 l = query->lookup;
4193 if (!next_origin(query->lookup) || showsearch) {
4319 if (!query->lookup->ns_search_only)
4320 query->lookup->pending = ISC_FALSE;
4321 if (!query->lookup->ns_search_only ||
4322 query->lookup->trace_root || docancel) {
4384 getaddresses(dig_lookup_t *lookup, const char *host, isc_result_t *resultp) {
4407 ISC_LIST_APPEND(lookup->my_server_list, srv, link);
4414 * Initiate either a TCP or UDP lookup
4417 do_lookup(dig_lookup_t *lookup) {
4420 REQUIRE(lookup != NULL);
4423 lookup->pending = ISC_TRUE;
4424 query = ISC_LIST_HEAD(lookup->q);
4426 if (lookup->tcp_mode)
4447 * Make everything on the lookup queue go away. Mainly used by the
4901 dig_lookup_t *lookup;
4915 lookup = clone_lookup(current_lookup, ISC_TRUE);
4916 lookup->trace_root = ISC_FALSE;
4917 lookup->new_search = ISC_TRUE;
4925 strlcpy(lookup->textname, (char*)r.base, sizeof(lookup->textname));
4938 lookup->rdtype = querytype;
4939 lookup->rdtypeset = ISC_TRUE;
4940 lookup->qrdtype = querytype;
4943 ISC_LIST_APPEND(lookup_list, lookup, link);
4946 printf(" for zone: %s\n", lookup->textname);
5088 dig_lookup_t *lookup = NULL;
5092 lookup = clone_lookup(current_lookup, ISC_TRUE);
5093 lookup->trace_root = ISC_FALSE;
5094 lookup->new_search = ISC_TRUE;
5095 lookup->trace_root_sigchase = ISC_FALSE;
5097 strlcpy(lookup->textname, lookup->textnamesigchase, MXNAME);
5099 lookup->rdtype = lookup->rdtype_sigchase;
5100 lookup->rdtypeset = ISC_TRUE;
5101 lookup->qrdtype = lookup->qrdtype_sigchase;
5103 s = ISC_LIST_HEAD(lookup->my_server_list);
5106 s, lookup);
5109 ISC_LIST_DEQUEUE(lookup->my_server_list,
5163 ISC_LIST_APPEND(lookup->my_server_list,
5193 ISC_LIST_APPEND(lookup->my_server_list,
5205 ISC_LIST_APPEND(lookup->my_server_list, srv, link);
5213 ISC_LIST_APPEND(lookup_list, lookup, link);
5215 print_type(lookup->rdtype);
5216 printf(" for zone: %s", lookup->textname);