Lines Matching refs:lookup

357 cancel_lookup(dig_lookup_t *lookup);
568 * Create a server structure, which is part of the lookup structure.
726 * Create an empty lookup structure, which holds all the information needed
812 * Clone a lookup, perhaps copying the server list. This does not clone
814 * function, nor does it queue up the new lookup for processing.
888 * Requeue a lookup for further processing, perhaps copying the server
889 * list. The new lookup structure is returned to the caller, and is
892 * completion of the event may result in the next entry on the lookup
1451 * and the lookup list is empty.
1454 * a whole or reseed the lookup list.
1475 dig_lookup_t *lookup;
1481 lookup = query->lookup;
1483 if (lookup->current_query == query)
1484 lookup->current_query = NULL;
1487 ISC_LIST_UNLINK(lookup->q, query, link);
1489 ISC_LIST_UNLINK(lookup->connecting, query, clink);
1513 * Try and clear out a lookup if we're done with it. Return ISC_TRUE if
1514 * the lookup was successfully cleared. If ISC_TRUE is returned, the
1515 * lookup pointer has been invalidated.
1518 try_clear_lookup(dig_lookup_t *lookup) {
1521 REQUIRE(lookup != NULL);
1523 debug("try_clear_lookup(%p)", lookup);
1525 if (ISC_LIST_HEAD(lookup->q) != NULL ||
1526 ISC_LIST_HEAD(lookup->connecting) != NULL)
1529 q = ISC_LIST_HEAD(lookup->q);
1535 q = ISC_LIST_HEAD(lookup->connecting);
1546 * At this point, we know there are no queries on the lookup,
1549 destroy_lookup(lookup);
1554 destroy_lookup(dig_lookup_t *lookup) {
1559 s = ISC_LIST_HEAD(lookup->my_server_list);
1561 debug("freeing server %p belonging to %p", s, lookup);
1564 ISC_LIST_DEQUEUE(lookup->my_server_list,
1568 if (lookup->sendmsg != NULL)
1569 dns_message_destroy(&lookup->sendmsg);
1570 if (lookup->querysig != NULL) {
1571 debug("freeing buffer %p", lookup->querysig);
1572 isc_buffer_free(&lookup->querysig);
1574 if (lookup->timer != NULL)
1575 isc_timer_detach(&lookup->timer);
1576 if (lookup->sendspace != NULL)
1577 isc_mempool_put(commctx, lookup->sendspace);
1579 if (lookup->tsigctx != NULL)
1580 dst_context_destroy(&lookup->tsigctx);
1582 isc_mem_free(mctx, lookup);
1586 * If we can, start the next lookup in the queue running.
1587 * This assumes that the lookup on the head of the queue hasn't been
1588 * started yet. It also removes the lookup from the head of the queue,
1598 * If there's a current lookup running, we really shouldn't get
1605 * Put the current lookup somewhere so cancel_all can find it
1699 * If we can, clear the current lookup and start the next one running.
1700 * This calls try_clear_lookup, so may invalidate the lookup pointer.
1703 check_next_lookup(dig_lookup_t *lookup) {
1707 debug("check_next_lookup(%p)", lookup);
1709 if (ISC_LIST_HEAD(lookup->q) != NULL) {
1713 if (try_clear_lookup(lookup)) {
1720 * Create and queue a new lookup as a followup to the current lookup,
1722 * name server search modes to start a new lookup using servers from
1728 dig_lookup_t *lookup = NULL;
1744 debug("following up %s", query->lookup->textname);
1769 if (query->lookup->trace && !query->lookup->trace_root) {
1774 domain = dns_fixedname_name(&query->lookup->fdomain);
1795 if (query->lookup->trace_root &&
1796 query->lookup->nsfound >= MXSERV)
1801 query->lookup->nsfound++;
1807 /* Initialize lookup if we've not yet */
1812 lookup = requeue_lookup(query->lookup,
1814 cancel_lookup(query->lookup);
1815 lookup->doing_xfr = ISC_FALSE;
1816 if (!lookup->trace_root &&
1818 lookup->trace = ISC_FALSE;
1820 lookup->trace = query->lookup->trace;
1821 lookup->ns_search_only =
1822 query->lookup->ns_search_only;
1823 lookup->trace_root = ISC_FALSE;
1824 if (lookup->ns_search_only)
1825 lookup->recurse = ISC_FALSE;
1826 dns_fixedname_init(&lookup->fdomain);
1827 domain = dns_fixedname_name(&lookup->fdomain);
1831 num = getaddresses(lookup, namestr, &lresult);
1849 if (lookup == NULL &&
1851 (query->lookup->trace || query->lookup->ns_search_only))
1865 for (srv = ISC_LIST_HEAD(lookup->my_server_list);
1867 srv = ISC_LIST_HEAD(lookup->my_server_list)) {
1876 ISC_LIST_DEQUEUE(lookup->my_server_list, srv, link);
1880 ISC_LIST_APPENDLIST(lookup->my_server_list,
1888 * Create and queue a new lookup using the next origin from the search
1895 dig_lookup_t *lookup;
1904 debug("following up %s", query->lookup->textname);
1918 result = dns_name_fromstring2(name, query->lookup->textname, NULL,
1925 if (query->lookup->origin == NULL && !query->lookup->need_search)
1930 if (query->lookup->origin == NULL && query->lookup->need_search) {
1931 lookup = requeue_lookup(query->lookup, ISC_TRUE);
1932 lookup->origin = ISC_LIST_HEAD(search_list);
1933 lookup->need_search = ISC_FALSE;
1935 search = ISC_LIST_NEXT(query->lookup->origin, link);
1936 if (search == NULL && query->lookup->done_as_is)
1938 lookup = requeue_lookup(query->lookup, ISC_TRUE);
1939 lookup->origin = search;
1941 cancel_lookup(query->lookup);
1946 * Insert an SOA record into the sendmessage in a lookup. Used for
1950 insert_soa(dig_lookup_t *lookup) {
1960 soa.serial = lookup->ixfr_serial;
1965 soa.common.rdclass = lookup->rdclass;
1974 isc_buffer_init(&lookup->rdatabuf, lookup->rdatastore,
1975 sizeof(lookup->rdatastore));
1977 result = dns_message_gettemprdata(lookup->sendmsg, &rdata);
1980 result = dns_rdata_fromstruct(rdata, lookup->rdclass,
1982 &lookup->rdatabuf);
1985 result = dns_message_gettemprdatalist(lookup->sendmsg, &rdatalist);
1988 result = dns_message_gettemprdataset(lookup->sendmsg, &rdataset);
1993 rdatalist->rdclass = lookup->rdclass;
2002 result = dns_message_gettempname(lookup->sendmsg, &soaname);
2005 dns_name_clone(lookup->name, soaname);
2008 dns_message_addname(lookup->sendmsg, soaname, DNS_SECTION_AUTHORITY);
2012 * Setup the supplied lookup structure, making it ready to start sending
2018 setup_lookup(dig_lookup_t *lookup) {
2037 REQUIRE(lookup != NULL);
2040 debug("setup_lookup(%p)", lookup);
2043 &lookup->sendmsg);
2046 if (lookup->new_search) {
2047 debug("resetting lookup counter.");
2051 if (ISC_LIST_EMPTY(lookup->my_server_list)) {
2053 clone_server_list(server_list, &lookup->my_server_list);
2055 result = dns_message_gettempname(lookup->sendmsg, &lookup->name);
2057 dns_name_init(lookup->name, NULL);
2059 isc_buffer_init(&lookup->namebuf, lookup->namespace,
2060 sizeof(lookup->namespace));
2061 isc_buffer_init(&lookup->onamebuf, lookup->onamespace,
2062 sizeof(lookup->onamespace));
2070 mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, lookup->textname,
2077 * (which produces an absolute lookup). Otherwise, take the origin
2082 if (lookup->new_search) {
2085 lookup->origin = NULL; /* Force abs lookup */
2086 lookup->done_as_is = ISC_TRUE;
2087 lookup->need_search = usesearch;
2088 } else if (lookup->origin == NULL && usesearch) {
2089 lookup->origin = ISC_LIST_HEAD(search_list);
2090 lookup->need_search = ISC_FALSE;
2093 if ((count_dots(lookup->textname) >= ndots) || !usesearch) {
2094 lookup->origin = NULL; /* Force abs lookup */
2095 lookup->done_as_is = ISC_TRUE;
2096 lookup->need_search = usesearch;
2097 } else if (lookup->origin == NULL && usesearch) {
2098 lookup->origin = ISC_LIST_HEAD(search_list);
2099 lookup->need_search = ISC_FALSE;
2105 if (lookup->origin != NULL) {
2107 lookup->origin->origin, utf8_origin,
2119 if (lookup->origin != NULL) {
2120 debug("trying origin %s", lookup->origin->origin);
2121 result = dns_message_gettempname(lookup->sendmsg,
2122 &lookup->oname);
2124 dns_name_init(lookup->oname, NULL);
2126 len = strlen(lookup->origin->origin);
2127 isc_buffer_init(&b, lookup->origin->origin, len);
2129 result = dns_name_fromtext(lookup->oname, &b, dns_rootname,
2130 0, &lookup->onamebuf);
2132 dns_message_puttempname(lookup->sendmsg,
2133 &lookup->name);
2134 dns_message_puttempname(lookup->sendmsg,
2135 &lookup->oname);
2137 lookup->origin->origin,
2140 if (lookup->trace && lookup->trace_root) {
2141 dns_name_clone(dns_rootname, lookup->name);
2143 len = strlen(lookup->textname);
2144 isc_buffer_init(&b, lookup->textname, len);
2146 result = dns_name_fromtext(lookup->name, &b,
2147 lookup->oname, 0,
2148 &lookup->namebuf);
2151 dns_message_puttempname(lookup->sendmsg,
2152 &lookup->name);
2153 dns_message_puttempname(lookup->sendmsg,
2154 &lookup->oname);
2156 lookup->textname, isc_result_totext(result));
2158 dns_message_puttempname(lookup->sendmsg, &lookup->oname);
2163 if (lookup->trace && lookup->trace_root)
2164 dns_name_clone(dns_rootname, lookup->name);
2170 result = dns_name_fromtext(lookup->name, &b,
2172 &lookup->namebuf);
2174 len = strlen(lookup->textname);
2175 isc_buffer_init(&b, lookup->textname, len);
2177 result = dns_name_fromtext(lookup->name, &b,
2179 &lookup->namebuf);
2183 dns_message_puttempname(lookup->sendmsg,
2184 &lookup->name);
2187 "(%s)", lookup->textname,
2191 dns_name_format(lookup->name, store, sizeof(store));
2192 trying(store, lookup);
2193 INSIST(dns_name_isabsolute(lookup->name));
2196 lookup->sendmsg->id = (unsigned short)id & 0xFFFF;
2197 lookup->sendmsg->opcode = dns_opcode_query;
2198 lookup->msgcounter = 0;
2203 if (lookup->trace || (lookup->ns_search_only && !lookup->trace_root))
2204 lookup->recurse = ISC_FALSE;
2206 if (lookup->recurse &&
2207 lookup->rdtype != dns_rdatatype_axfr &&
2208 lookup->rdtype != dns_rdatatype_ixfr) {
2210 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_RD;
2214 if (lookup->aaonly) {
2216 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_AA;
2219 if (lookup->adflag) {
2221 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_AD;
2224 if (lookup->cdflag) {
2226 lookup->sendmsg->flags |= DNS_MESSAGEFLAG_CD;
2229 dns_message_addname(lookup->sendmsg, lookup->name,
2232 if (lookup->trace && lookup->trace_root) {
2233 lookup->qrdtype = lookup->rdtype;
2234 lookup->rdtype = dns_rdatatype_ns;
2237 if ((lookup->rdtype == dns_rdatatype_axfr) ||
2238 (lookup->rdtype == dns_rdatatype_ixfr)) {
2242 if (lookup->rdtype == dns_rdatatype_axfr) {
2243 lookup->doing_xfr = ISC_TRUE;
2244 lookup->tcp_mode = ISC_TRUE;
2245 } else if (lookup->tcp_mode) {
2246 lookup->doing_xfr = ISC_TRUE;
2250 add_question(lookup->sendmsg, lookup->name, lookup->rdclass,
2251 lookup->rdtype);
2254 if (lookup->rdtype == dns_rdatatype_ixfr)
2255 insert_soa(lookup);
2258 lookup->tsigctx = NULL;
2259 lookup->querysig = NULL;
2262 result = dns_message_settsigkey(lookup->sendmsg, key);
2266 lookup->sendspace = isc_mempool_get(commctx);
2267 if (lookup->sendspace == NULL)
2274 isc_buffer_init(&lookup->renderbuf, lookup->sendspace, COMMSIZE);
2275 result = dns_message_renderbegin(lookup->sendmsg, &cctx,
2276 &lookup->renderbuf);
2278 if (lookup->udpsize > 0 || lookup->dnssec || lookup->edns > -1) {
2279 if (lookup->udpsize == 0)
2280 lookup->udpsize = 4096;
2281 if (lookup->edns < 0)
2282 lookup->edns = 0;
2283 add_opt(lookup->sendmsg, lookup->udpsize,
2284 lookup->edns, lookup->dnssec, lookup->nsid);
2287 result = dns_message_rendersection(lookup->sendmsg,
2290 result = dns_message_rendersection(lookup->sendmsg,
2293 result = dns_message_renderend(lookup->sendmsg);
2302 if (isc_buffer_usedlength(&lookup->renderbuf) > 512)
2303 lookup->tcp_mode = ISC_TRUE;
2305 lookup->pending = ISC_FALSE;
2307 for (serv = ISC_LIST_HEAD(lookup->my_server_list);
2314 debug("create query %p linked to lookup %p",
2315 query, lookup);
2316 query->lookup = lookup;
2344 query->sendbuf = lookup->renderbuf;
2348 ISC_LIST_ENQUEUE(lookup->q, query, link);
2351 if (!ISC_LIST_EMPTY(lookup->q) && qr) {
2353 printmessage(ISC_LIST_HEAD(lookup->q), lookup->sendmsg,
2389 l = query->lookup;
2408 * Cancel a lookup, sending isc_socket_cancel() requests to all outstanding
2410 * query and lookup structures
2413 cancel_lookup(dig_lookup_t *lookup) {
2417 query = ISC_LIST_HEAD(lookup->q);
2429 if (lookup->timer != NULL)
2430 isc_timer_detach(&lookup->timer);
2431 lookup->pending = ISC_FALSE;
2432 lookup->retries = 0;
2447 l = query->lookup;
2496 * query. When we retry TCP, we requeue the whole lookup, which should
2507 l = query->lookup;
2509 query->lookup->current_query = query;
2528 l = query->lookup;
2611 l = query->lookup;
2614 debug("working on lookup %p, query %p", query->lookup, query);
2645 debug("recving with lookup=%p, query=%p, sock=%p",
2646 query->lookup, query, query->sock);
2671 * new TCP lookup. Otherwise, cancel the lookup.
2690 if ((query != NULL) && (query->lookup->current_query != NULL) &&
2691 (ISC_LIST_NEXT(query->lookup->current_query, link) != NULL)) {
2693 cq = query->lookup->current_query;
2766 l = query->lookup;
2778 l = query->lookup;
2806 debug("recving with lookup=%p, query=%p", query->lookup, query);
2831 if (!query->lookup->pending) {
2838 l = query->lookup;
2878 check_next_lookup(query->lookup);
2917 l = query->lookup;
2932 query->servname, query->lookup->textname,
2943 l = query->lookup;
2981 isc_uint32_t ixfr_serial = query->lookup->ixfr_serial, serial;
2983 isc_boolean_t ixfr = query->lookup->rdtype == dns_rdatatype_ixfr;
2984 isc_boolean_t axfr = query->lookup->rdtype == dns_rdatatype_axfr;
3152 debug("lookup=%p, query=%p", query->lookup, query);
3154 l = query->lookup;
3375 n->origin = query->lookup->origin;
3601 if (!query->lookup->ns_search_only)
3602 query->lookup->pending = ISC_FALSE;
3603 if (!query->lookup->ns_search_only ||
3604 query->lookup->trace_root || docancel) {
3662 getaddresses(dig_lookup_t *lookup, const char *host, isc_result_t *resultp) {
3685 ISC_LIST_APPEND(lookup->my_server_list, srv, link);
3692 * Initiate either a TCP or UDP lookup
3695 do_lookup(dig_lookup_t *lookup) {
3698 REQUIRE(lookup != NULL);
3701 lookup->pending = ISC_TRUE;
3702 query = ISC_LIST_HEAD(lookup->q);
3704 if (lookup->tcp_mode)
3725 * Make everything on the lookup queue go away. Mainly used by the
4172 dig_lookup_t *lookup;
4186 lookup = clone_lookup(current_lookup, ISC_TRUE);
4187 lookup->trace_root = ISC_FALSE;
4188 lookup->new_search = ISC_TRUE;
4196 strlcpy(lookup->textname, (char*)r.base, sizeof(lookup->textname));
4209 lookup->rdtype = querytype;
4210 lookup->rdtypeset = ISC_TRUE;
4211 lookup->qrdtype = querytype;
4214 ISC_LIST_APPEND(lookup_list, lookup, link);
4217 printf(" for zone: %s\n", lookup->textname);
4360 dig_lookup_t *lookup = NULL;
4364 lookup = clone_lookup(current_lookup, ISC_TRUE);
4365 lookup->trace_root = ISC_FALSE;
4366 lookup->new_search = ISC_TRUE;
4367 lookup->trace_root_sigchase = ISC_FALSE;
4369 strlcpy(lookup->textname, lookup->textnamesigchase, MXNAME);
4371 lookup->rdtype = lookup->rdtype_sigchase;
4372 lookup->rdtypeset = ISC_TRUE;
4373 lookup->qrdtype = lookup->qrdtype_sigchase;
4375 s = ISC_LIST_HEAD(lookup->my_server_list);
4378 s, lookup);
4381 ISC_LIST_DEQUEUE(lookup->my_server_list,
4436 ISC_LIST_APPEND(lookup->my_server_list,
4466 ISC_LIST_APPEND(lookup->my_server_list,
4478 ISC_LIST_APPEND(lookup->my_server_list, srv, link);
4486 ISC_LIST_APPEND(lookup_list, lookup, link);
4488 print_type(lookup->rdtype);
4489 printf(" for zone: %s", lookup->textname);