Lines Matching defs:query
283 dns_name_t chase_name; /* the query name */
357 send_udp(dig_query_t *query);
363 launch_next_query(dig_query_t *query, isc_boolean_t include_question);
545 * This is little more than a linked list of servers to query in hopes
704 * linked lists: the server list (servers to query) and the query list
789 * the query list, since it will be regenerated by the setup_lookup()
1284 * Clear out a query when we're done with it. WARNING: This routine
1285 * WILL invalidate the query pointer.
1288 clear_query(dig_query_t *query) {
1291 REQUIRE(query != NULL);
1293 debug("clear_query(%p)", query);
1295 lookup = query->lookup;
1297 if (lookup->current_query == query)
1300 if (ISC_LINK_LINKED(query, link))
1301 ISC_LIST_UNLINK(lookup->q, query, link);
1302 if (ISC_LINK_LINKED(query, clink))
1303 ISC_LIST_UNLINK(lookup->connecting, query, clink);
1304 if (ISC_LINK_LINKED(&query->recvbuf, link))
1305 ISC_LIST_DEQUEUE(query->recvlist, &query->recvbuf,
1307 if (ISC_LINK_LINKED(&query->lengthbuf, link))
1308 ISC_LIST_DEQUEUE(query->lengthlist, &query->lengthbuf,
1310 INSIST(query->recvspace != NULL);
1312 if (query->sock != NULL) {
1313 isc_socket_detach(&query->sock);
1317 isc_mempool_put(commctx, query->recvspace);
1318 isc_buffer_invalidate(&query->recvbuf);
1319 isc_buffer_invalidate(&query->lengthbuf);
1320 if (query->waiting_senddone)
1321 query->pending_free = ISC_TRUE;
1323 isc_mem_free(mctx, query);
1345 debug("query to %s still pending", q->servname);
1351 debug("query to %s still connecting",
1540 followup_lookup(dns_message_t *msg, dig_query_t *query, dns_section_t section)
1558 debug("following up %s", query->lookup->textname);
1583 if (query->lookup->trace && !query->lookup->trace_root) {
1588 domain = dns_fixedname_name(&query->lookup->fdomain);
1609 if (query->lookup->trace_root &&
1610 query->lookup->nsfound >= MXSERV)
1615 query->lookup->nsfound++;
1626 lookup = requeue_lookup(query->lookup,
1628 cancel_lookup(query->lookup);
1634 lookup->trace = query->lookup->trace;
1636 query->lookup->ns_search_only;
1665 (query->lookup->trace || query->lookup->ns_search_only))
1666 return (followup_lookup(msg, query, DNS_SECTION_AUTHORITY));
1708 next_origin(dns_message_t *msg, dig_query_t *query) {
1720 debug("following up %s", query->lookup->textname);
1734 result = dns_name_fromstring2(name, query->lookup->textname, NULL,
1741 if (query->lookup->origin == NULL && !query->lookup->need_search)
1746 if (query->lookup->origin == NULL && query->lookup->need_search) {
1747 lookup = requeue_lookup(query->lookup, ISC_TRUE);
1751 search = ISC_LIST_NEXT(query->lookup->origin, link);
1752 if (search == NULL && query->lookup->done_as_is)
1754 lookup = requeue_lookup(query->lookup, ISC_TRUE);
1757 cancel_lookup(query->lookup);
1830 * well as the query structures and buffer space for the replies. If the
1839 dig_query_t *query;
2027 debug("recursive query");
2033 debug("AA query");
2038 debug("AD query");
2043 debug("CD query");
2128 query = isc_mem_allocate(mctx, sizeof(dig_query_t));
2129 if (query == NULL)
2132 debug("create query %p linked to lookup %p",
2133 query, lookup);
2134 query->lookup = lookup;
2135 query->waiting_connect = ISC_FALSE;
2136 query->waiting_senddone = ISC_FALSE;
2137 query->pending_free = ISC_FALSE;
2138 query->recv_made = ISC_FALSE;
2139 query->first_pass = ISC_TRUE;
2140 query->first_soa_rcvd = ISC_FALSE;
2141 query->second_rr_rcvd = ISC_FALSE;
2142 query->first_repeat_rcvd = ISC_FALSE;
2143 query->warn_id = ISC_TRUE;
2144 query->first_rr_serial = 0;
2145 query->second_rr_serial = 0;
2146 query->servname = serv->servername;
2147 query->userarg = serv->userarg;
2148 query->rr_count = 0;
2149 query->msg_count = 0;
2150 query->byte_count = 0;
2151 query->ixfr_axfr = ISC_FALSE;
2152 ISC_LIST_INIT(query->recvlist);
2153 ISC_LIST_INIT(query->lengthlist);
2154 query->sock = NULL;
2155 query->recvspace = isc_mempool_get(commctx);
2156 if (query->recvspace == NULL)
2159 isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE);
2160 isc_buffer_init(&query->lengthbuf, query->lengthspace, 2);
2161 isc_buffer_init(&query->slbuf, query->slspace, 2);
2162 query->sendbuf = lookup->renderbuf;
2164 ISC_LINK_INIT(query, clink);
2165 ISC_LINK_INIT(query, link);
2166 ISC_LIST_ENQUEUE(lookup->q, query, link);
2178 * the query if the send was canceled.
2184 dig_query_t *query, *next;
2205 query = event->ev_arg;
2206 query->waiting_senddone = ISC_FALSE;
2207 l = query->lookup;
2211 next = ISC_LIST_NEXT(query, link);
2218 if (query->pending_free)
2219 isc_mem_free(mctx, query);
2228 * query and lookup structures
2232 dig_query_t *query, *next;
2235 query = ISC_LIST_HEAD(lookup->q);
2236 while (query != NULL) {
2237 next = ISC_LIST_NEXT(query, link);
2238 if (query->sock != NULL) {
2239 isc_socket_cancel(query->sock, global_task,
2243 clear_query(query);
2245 query = next;
2254 bringup_timer(dig_query_t *query, unsigned int default_timeout) {
2265 l = query->lookup;
2266 if (ISC_LIST_NEXT(query, link) != NULL)
2285 force_timeout(dig_lookup_t *l, dig_query_t *query) {
2289 event = isc_event_allocate(mctx, query, ISC_TIMEREVENT_IDLE,
2314 * query. When we retry TCP, we requeue the whole lookup, which should
2318 send_tcp_connect(dig_query_t *query) {
2323 debug("send_tcp_connect(%p)", query);
2325 l = query->lookup;
2326 query->waiting_connect = ISC_TRUE;
2327 query->lookup->current_query = query;
2328 result = get_address(query->servname, port, &query->sockaddr);
2335 force_timeout(l, query);
2340 (isc_sockaddr_pf(&query->sockaddr) !=
2343 "address family\n", query->servname);
2344 query->waiting_connect = ISC_FALSE;
2345 next = ISC_LIST_NEXT(query, link);
2346 l = query->lookup;
2347 clear_query(query);
2357 INSIST(query->sock == NULL);
2359 if (keep != NULL && isc_sockaddr_equal(&keepaddr, &query->sockaddr)) {
2361 isc_socket_attach(keep, &query->sock);
2362 query->waiting_connect = ISC_FALSE;
2363 launch_next_query(query, ISC_TRUE);
2368 isc_sockaddr_pf(&query->sockaddr),
2369 isc_sockettype_tcp, &query->sock);
2374 result = isc_socket_bind(query->sock, &bind_address,
2377 if ((isc_sockaddr_pf(&query->sockaddr) == AF_INET) &&
2382 result = isc_socket_bind(query->sock, &bind_any, 0);
2385 bringup_timer(query, TCP_TIMEOUT);
2386 result = isc_socket_connect(query->sock, &query->sockaddr,
2387 global_task, connect_done, query);
2396 next = ISC_LIST_NEXT(query, link);
2397 if (ISC_LINK_LINKED(query, link))
2398 ISC_LIST_DEQUEUE(l->q, query, link);
2399 ISC_LIST_ENQUEUE(l->connecting, query, clink);
2422 send_udp(dig_query_t *query) {
2427 debug("send_udp(%p)", query);
2429 l = query->lookup;
2430 bringup_timer(query, UDP_TIMEOUT);
2431 l->current_query = query;
2432 debug("working on lookup %p, query %p", query->lookup, query);
2433 if (!query->recv_made) {
2435 query->waiting_connect = ISC_FALSE;
2436 result = get_address(query->servname, port, &query->sockaddr);
2439 force_timeout(l, query);
2444 isc_sockaddr_pf(&query->sockaddr),
2445 isc_sockettype_udp, &query->sock);
2450 result = isc_socket_bind(query->sock, &bind_address,
2454 isc_sockaddr_pf(&query->sockaddr));
2455 result = isc_socket_bind(query->sock, &bind_any, 0);
2459 query->recv_made = ISC_TRUE;
2460 ISC_LINK_INIT(&query->recvbuf, link);
2461 ISC_LIST_ENQUEUE(query->recvlist, &query->recvbuf,
2463 debug("recving with lookup=%p, query=%p, sock=%p",
2464 query->lookup, query, query->sock);
2465 result = isc_socket_recvv(query->sock, &query->recvlist, 1,
2466 global_task, recv_done, query);
2471 ISC_LIST_INIT(query->sendlist);
2472 sendbuf = clone_buffer(&query->sendbuf);
2473 ISC_LIST_ENQUEUE(query->sendlist, sendbuf, link);
2475 TIME_NOW(&query->time_sent);
2476 INSIST(query->sock != NULL);
2477 query->waiting_senddone = ISC_TRUE;
2478 result = isc_socket_sendtov2(query->sock, &query->sendlist,
2479 global_task, send_done, query,
2480 &query->sockaddr, NULL,
2494 dig_query_t *query = NULL, *next, *cq;
2503 query = l->current_query;
2508 if ((query != NULL) && (query->lookup->current_query != NULL) &&
2509 (ISC_LIST_NEXT(query->lookup->current_query, link) != NULL)) {
2511 cq = query->lookup->current_query;
2515 if (query->sock != NULL)
2516 isc_socket_cancel(query->sock, NULL,
2560 dig_query_t *query = NULL;
2573 query = event->ev_arg;
2579 INSIST(b == &query->lengthbuf);
2584 l = query->lookup;
2585 clear_query(query);
2592 isc_sockaddr_format(&query->sockaddr, sockstr,
2596 l = query->lookup;
2597 isc_socket_detach(&query->sock);
2602 clear_query(query);
2610 launch_next_query(query, ISC_FALSE);
2619 isc_buffer_invalidate(&query->recvbuf);
2620 isc_buffer_init(&query->recvbuf, query->recvspace, length);
2621 ENSURE(ISC_LIST_EMPTY(query->recvlist));
2622 ISC_LINK_INIT(&query->recvbuf, link);
2623 ISC_LIST_ENQUEUE(query->recvlist, &query->recvbuf, link);
2624 debug("recving with lookup=%p, query=%p", query->lookup, query);
2625 result = isc_socket_recvv(query->sock, &query->recvlist, length, task,
2626 recv_done, query);
2640 launch_next_query(dig_query_t *query, isc_boolean_t include_question) {
2649 if (!query->lookup->pending) {
2651 isc_socket_detach(&query->sock);
2655 query->waiting_connect = ISC_FALSE;
2656 l = query->lookup;
2657 clear_query(query);
2662 isc_buffer_clear(&query->slbuf);
2663 isc_buffer_clear(&query->lengthbuf);
2664 isc_buffer_putuint16(&query->slbuf, (isc_uint16_t) query->sendbuf.used);
2665 ISC_LIST_INIT(query->sendlist);
2666 ISC_LINK_INIT(&query->slbuf, link);
2667 if (!query->first_soa_rcvd) {
2668 buffer = clone_buffer(&query->slbuf);
2669 ISC_LIST_ENQUEUE(query->sendlist, buffer, link);
2671 buffer = clone_buffer(&query->sendbuf);
2672 ISC_LIST_ENQUEUE(query->sendlist, buffer, link);
2676 ISC_LINK_INIT(&query->lengthbuf, link);
2677 ISC_LIST_ENQUEUE(query->lengthlist, &query->lengthbuf, link);
2679 result = isc_socket_recvv(query->sock, &query->lengthlist, 0,
2680 global_task, tcp_length_done, query);
2684 if (!query->first_soa_rcvd) {
2686 TIME_NOW(&query->time_sent);
2687 query->waiting_senddone = ISC_TRUE;
2688 result = isc_socket_sendv(query->sock, &query->sendlist,
2689 global_task, send_done, query);
2694 query->waiting_connect = ISC_FALSE;
2696 check_next_lookup(query->lookup);
2709 dig_query_t *query = NULL, *next;
2721 query = sevent->ev_arg;
2723 INSIST(query->waiting_connect);
2725 query->waiting_connect = ISC_FALSE;
2729 isc_socket_detach(&query->sock);
2733 query->waiting_connect = ISC_FALSE;
2735 l = query->lookup;
2736 clear_query(query);
2746 isc_sockaddr_format(&query->sockaddr, sockstr, sizeof(sockstr));
2750 query->servname, query->lookup->textname,
2752 isc_socket_detach(&query->sock);
2759 query->waiting_connect = ISC_FALSE;
2761 l = query->lookup;
2766 clear_query(query);
2778 isc_socket_attach(query->sock, &keep);
2779 keepaddr = query->sockaddr;
2781 launch_next_query(query, ISC_TRUE);
2793 check_for_more_data(dig_query_t *query, dns_message_t *msg,
2799 isc_uint32_t ixfr_serial = query->lookup->ixfr_serial, serial;
2801 isc_boolean_t ixfr = query->lookup->rdtype == dns_rdatatype_ixfr;
2802 isc_boolean_t axfr = query->lookup->rdtype == dns_rdatatype_axfr;
2805 axfr = query->ixfr_axfr;
2818 query->msg_count++;
2819 query->byte_count += sevent->n;
2837 query->rr_count++;
2844 if ((!query->first_soa_rcvd) &&
2850 if ((!query->second_rr_rcvd) &&
2852 query->second_rr_rcvd = ISC_TRUE;
2853 query->second_rr_serial = 0;
2855 axfr = query->ixfr_axfr = ISC_TRUE;
2872 if (!query->first_soa_rcvd) {
2873 query->first_soa_rcvd = ISC_TRUE;
2874 query->first_rr_serial = serial;
2889 if (!query->second_rr_rcvd) {
2890 if (query->first_rr_serial == serial) {
2897 query->second_rr_rcvd = ISC_TRUE;
2898 query->second_rr_serial = serial;
2906 if (query->first_rr_serial == serial) {
2908 if (!query->first_repeat_rcvd) {
2909 query->first_repeat_rcvd =
2923 launch_next_query(query, ISC_FALSE);
2926 received(sevent->n, &sevent->address, query);
2937 dig_query_t *query = NULL;
2969 query = event->ev_arg;
2970 debug("lookup=%p, query=%p", query->lookup, query);
2972 l = query->lookup;
2978 INSIST(b == &query->recvbuf);
2979 ISC_LIST_DEQUEUE(sevent->bufferlist, &query->recvbuf, link);
2986 query->waiting_connect = ISC_FALSE;
2989 clear_query(query);
2998 query->waiting_connect = ISC_FALSE;
3002 isc_socket_detach(&query->sock);
3008 clear_query(query);
3015 !isc_sockaddr_compare(&sevent->address, &query->sockaddr,
3024 if (isc_sockaddr_pf(&query->sockaddr) == AF_INET)
3034 if ((!isc_sockaddr_eqaddr(&query->sockaddr, &any) &&
3035 !isc_sockaddr_ismulticast(&query->sockaddr)) ||
3036 isc_sockaddr_getport(&query->sockaddr) !=
3040 isc_sockaddr_format(&query->sockaddr, buf2,
3054 if (!query->first_soa_rcvd ||
3055 query->warn_id)
3058 query->first_soa_rcvd ?
3061 if (query->first_soa_rcvd)
3063 query->warn_id = ISC_FALSE;
3069 clear_query(query);
3084 printf(";; Warning: query response not set\n");
3133 query->waiting_connect = ISC_FALSE;
3136 clear_query(query);
3180 clear_query(query);
3193 n->origin = query->lookup->origin;
3196 clear_query(query);
3205 dig_query_t *next = ISC_LIST_NEXT(query, link);
3206 if (l->current_query == query)
3209 debug("sending query %p\n", next);
3216 * If our query is at the head of the list and there
3220 if ((ISC_LIST_HEAD(l->q) != query) ||
3221 (ISC_LIST_NEXT(query, link) != NULL)) {
3228 query->servname);
3229 clear_query(query);
3239 result = dns_tsig_verify(&query->recvbuf, msg, NULL, NULL);
3259 l->xfr_q = query;
3290 if (!l->doing_xfr || l->xfr_q == query) {
3293 if (!next_origin(msg, query) || showsearch) {
3294 printmessage(query, msg, ISC_TRUE);
3295 received(b->used, &sevent->address, query);
3301 printmessage(query, msg, ISC_TRUE);
3308 printmessage(query, msg, ISC_TRUE);
3314 n = followup_lookup(msg, query,
3318 n = followup_lookup(msg, query,
3327 * This is the initial NS query.
3332 n = followup_lookup(msg, query,
3342 printmessage(query, msg, ISC_TRUE);
3394 if (query != l->xfr_q) {
3397 query->waiting_connect = ISC_FALSE;
3402 docancel = check_for_more_data(query, msg, sevent);
3405 clear_query(query);
3416 received(b->used, &sevent->address, query);
3419 if (!query->lookup->ns_search_only)
3420 query->lookup->pending = ISC_FALSE;
3421 if (!query->lookup->ns_search_only ||
3422 query->lookup->trace_root || docancel) {
3430 clear_query(query);
3446 isc_buffer_invalidate(&query->recvbuf);
3447 isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE);
3448 ISC_LIST_ENQUEUE(query->recvlist, &query->recvbuf, link);
3449 result = isc_socket_recvv(query->sock, &query->recvlist, 1,
3450 global_task, recv_done, query);
3514 dig_query_t *query;
3520 query = ISC_LIST_HEAD(lookup->q);
3521 if (query != NULL) {
3523 send_tcp_connect(query);
3525 send_udp(query);
3567 debug("canceling pending query %p, belonging to %p",
3580 debug("canceling connecting query %p, belonging to %p",
4031 printf("\n\nLaunch a query to find a RRset of type ");
4303 printf("\nLaunch a query to find a RRset of type ");
4692 * the lookedup is to known if you have already done the query on the net.
4695 * and we do a query on the net
5015 printf("\n;; OK the query doesn't have response but"