Lines Matching defs:query
413 // Right now we just stop and re-use the existing query. If we really wanted to be 100% perfect,
414 // and track CNAMEs coming and going, we should really create a subordinate query here,
421 mDNS_StopQuery_internal(m, q); // Stop old query
424 // If a unicast query results in a CNAME that points to a .local, we need to re-try
426 // to try this as unicast query even though it is a .local name
433 mDNS_StartQuery_internal(m, q); // start new query
651 // CacheRecord *ka is the CacheRecord from the known answer list in the query.
735 // If we already have a *query* scheduled to go out sooner, then use that time to get better aggregation
2217 else if (rr->ImmedAnswer) // Else, just respond to a single query on single interface:
2357 // When we're generating an NSEC record in response to a specify query for that type
2517 // If we have an active question, then see if we want to schedule a refresher query for this record.
2547 // so that the reconfirmation questions can be grouped into a single query packet
2561 // BuildQuestion puts a question into a DNS Query packet and if successful, updates the value of queryptr.
2564 mDNSlocal mDNSBool BuildQuestion(mDNS *const m, DNSMessage *query, mDNSu8 **queryptr, DNSQuestion *q,
2569 const mDNSu8 *const limit = query->data + NormalMaxDNSMessageData;
2570 mDNSu8 *newptr = putQuestion(query, *queryptr, limit - *answerforecast, &q->qname, q->qtype, (mDNSu16)(q->qclass | ucbit));
2595 // That concept really does not apply to unique records, and indeed if we do send a query for
2605 if (query->h.numQuestions > 1 && newptr + forecast >= limit)
2608 q->qname.c, DNSTypeName(q->qtype), newptr + forecast - query->data);
2609 query->h.numQuestions--;
2636 // When we have a query looking for a specified name, but there appear to be no answers with
2666 // If we get no answer for a AAAA query, then before doing an automatic implicit ReconfirmAntecedents
2686 if (SameNameRecordAnswersQuestion(&cr->resrec, q)) // and answers our browse query,
2719 mDNSBool v4 = !intf->IPv4Available; // If this interface doesn't do v4, we don't need to find a v4 duplicate of this query
2720 mDNSBool v6 = !intf->IPv6Available; // If this interface doesn't do v6, we don't need to find a v6 duplicate of this query
2747 // Record the info about this query we saw
2809 // If more than 90% of the way to the query time, we should unconditionally accelerate it
2813 // If half-way to next scheduled query time, only accelerate if it will add less than 512 bytes to the packet
2862 // 1. If time for a query, work out what we need to do
2864 // We're expecting to send a query anyway, so see if any expiring cache records are close enough
2870 debugf("Sending %d%% cache expiration query for %s", 80 + 5 * cr->UnansweredQueries, CRDisplayString(m, cr));
2874 // and bump UnansweredQueries so that we don't spin trying to send the same cache expiration query repeatedly
2875 if (q->Target.type) q->SendQNow = mDNSInterfaceMark; // If targeted query, mark it
2944 // If at least halfway to next query time, advance to next interval
2945 // If less than halfway to next query time, then
2960 // It's not especially noteworthy if a query finds no results -- this usually happens for domain
2966 // Sending third query, and no answers yet; time to begin doubting the source
2980 // then we consider it recent enough that we don't need to do an identical query ourselves.
3090 // Put query questions in this packet
3311 // Normally we don't send out the unicast query if we have answered using our local only auth records e.g., /etc/hosts.
3312 // But if the query for "A" record has a local answer but query for "AAAA" record has no local answer, we might
3313 // send the AAAA query out which will come back with CNAME and will also answer the "A" query. To prevent that,
3314 // we check to see if that query already has a unique local answer.
3325 // If the query is suppressed, then we don't want to answer from the cache. But if this query is
3347 // (a) a no-cache add, where we've already done at least one 'QM' query, or
3520 // second of sending the last query packet, then that indicates some radical network topology change,
3523 // because we will anyway send another query within a few seconds. The first reset query is sent out
3733 // not send out a query
3748 else // else, not expired; see if we need to query
3758 if (m->timenow - rr->NextRequiredQuery < 0) // If not yet time for next query
3759 event = NextCacheCheckEvent(rr); // then just record when we want the next query
3765 // After sending the query we'll increment UnansweredQueries and call SetNextCacheCheckTimeForRecord(),
3852 // to answer the query. This is handled in AnswerNewLocalOnlyQuestion.
3877 // Before we go check the cache and ship this query on the wire, we have to be sure that there are
3917 // -- we don't need to rush out on the network and query immediately to see if there are more answers out there
3936 // If the query was suppressed above, we already generated a negative response. When it gets unsuppressed,
3946 // Note: When a query gets suppressed or retried with search domains, we de-activate the question.
4484 // 7. Send Query packets. This may cause some probing records to advance to announcing state
4589 // Otherwise we can get the situation where the A query completes really fast (with an NXDOMAIN result) and the
4593 // as this would trigger looking up _autotunnel6._autotunnel6 and end up failing the original query.
4658 // GetZoneData questions are referenced by other questions (original query that started the GetZoneData
4659 // question) through their "nta" pointer. Normally when the original query stops, it stops the
4661 // question followed by the original query that refers to this GetZoneData question, we will end up
4692 // But this can't prevent a CNAME/AAAA query to not to be sent on the wire. When it is sent on the wire,
4694 // for the original query using these cache entries as ADDs were never delivered using these cache
4697 // If the query is suppressed, the RMV events won't be delivered
4722 // 3. Callback before we start the query
5417 mDNSlocal mDNSu8 *GenerateUnicastResponse(const DNSMessage *const query, const mDNSu8 *const end,
5422 const mDNSu8 *ptr = query->data;
5428 InitializeDNSMessage(&response->h, query->h.id, ResponseFlags);
5436 for (i=0; i<query->h.numQuestions; i++) // For each question...
5439 ptr = getQuestion(query, ptr, end, InterfaceID, &q); // get the question...
5596 mDNSlocal void ResolveSimultaneousProbe(mDNS *const m, const DNSMessage *const query, const mDNSu8 *const end,
5600 const mDNSu8 *ptr = LocateAuthorities(query, end);
5603 for (i = 0; i < query->h.numAuthorities; i++)
5605 ptr = GetLargeResourceRecord(m, query, ptr, end, q->InterfaceID, kDNSRecordTypePacketAuth, &m->rec);
5729 // ProcessQuery examines a received query to see if we have any answers to give
5730 mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, const mDNSu8 *const end,
5751 ptr = LocateOptRR(query, end, DNSOpt_OwnerData_ID_Space);
5754 ptr = GetLargeResourceRecord(m, query, ptr, end, InterfaceID, kDNSRecordTypePacketAdd, &m->rec);
5774 ptr = query->data;
5775 for (i=0; i<query->h.numQuestions; i++) // For each question...
5781 ptr = getQuestion(query, ptr, end, InterfaceID, &pktq); // get the question...
5814 ResolveSimultaneousProbe(m, query, end, &pktq, rr);
5818 // Note: We should check here if this is a probe-type query, and if so, generate an immediate
5822 // NR_AnswerTo pointing into query packet means "answer via immediate legacy unicast" (may *also* choose to multicast)
5865 // For any query generating a unicast response we don't do this because we can't assume we will see the response.
5868 if (QuestionNeedsMulticastResponse && !(query->h.flags.b[0] & kDNSFlag0_TC))
5875 // Make a list indicating which of our own cache records we expect to see updated as a result of this query
5878 if (!(query->h.flags.b[0] & kDNSFlag0_TC))
5889 // Although MPUnansweredQ is only really used for multi-packet query processing,
5891 // with the MPUnansweredKA value, which by necessity is incremented for both query types.
5902 // can't guarantee to receive all of the Known Answer packets that go with a particular query.
5904 if (!(query->h.flags.b[0] & kDNSFlag0_TC))
5932 for (i=0; i<query->h.numAnswers; i++) // For each record in the query's answer section...
5936 ptr = GetLargeResourceRecord(m, query, ptr, end, InterfaceID, kDNSRecordTypePacketAns, &m->rec);
5993 // See if this Known-Answer is a surprise to us. If so, we shouldn't suppress our own query.
6070 if (query->h.flags.b[0] & kDNSFlag0_TC) delayresponse = mDNSPlatformOneSecond * 20; // Divided by 50 = 400ms
6116 // *** 9. If query is from a legacy client, or from a new client requesting a unicast reply, then generate a unicast response too
6119 responseptr = GenerateUnicastResponse(query, end, InterfaceID, LegacyQuery, response, ResponseRecords);
6144 if (!(query->h.flags.b[0] & kDNSFlag0_TC))
6170 // Make a guess, based on the multi-packet query / known answer counts, whether we think we
6191 cr->UnansweredQueries++; // Treat this as equivalent to one definite unanswered query
6226 LogMsg("Ignoring Query from %#-15a:%-5d to %#-15a:%-5d on 0x%p with "
6236 verbosedebugf("Received Query from %#-15a:%-5d to %#-15a:%-5d on 0x%p with "
6293 // DNS server or a response to the QU query. Hence, the cache record's InterfaceId can be both NULL or non-NULL (QU case)
6440 // We adjust the 100 second TTL to 126. This means that when we do our 80% query at 101 seconds,
6450 // This gives the server up to three seconds to respond between when we send our 80% query at 12 seconds
6505 // set, it should ignore that response, and query again, using a
6511 // In addition, if the client immediately canceled its query after getting the initial partial response, then we'll
6513 // Next time there's a query for this RRSet we'll see answers in our cache, and assume we have the whole RRSet already,
6514 // and not even do the TCP query.
6566 LogInfo("mDNSCoreReceiveResponse: Server %p responded with code %d to query %##s (%s)", qptr->qDNSServer, rcode, q.qname.c, DNSTypeName(q.qtype));
6580 // generate negative cache entries (we want to query the next server)
6633 // then see if it answers a recent query of ours, which would also make it acceptable for caching.
6662 // came from the same DNS server that we sent the query to.
6791 // When we issue a query for A record, the response might contain both a CNAME and A records. Only the CNAME would
6809 // Also, we ignore any apparent attempts at cache poisoning unicast to us that do not answer any outstanding active query
7062 // 1. If we got a fresh answer to this query, then don't need to generate a negative entry
7072 // suppress sending our mDNS query packet because we think we already have a valid (negative) answer to that query in our cache.
7104 query to find
7141 // the case where the record doesn't exist (e.g. particularly for things like our lb._dns-sd._udp.<domain> query),
7588 // Note: We explicitly disallow making a public query be a duplicate of a private one. This is to avoid the
7589 // circular deadlock where a client does a query for something like "dns-sd -Q _dns-query-tls._tcp.company.com SRV"
7590 // and we have a key for company.com, so we try to locate the private query server for company.com, which necessarily entails
7591 // doing a standard DNS query for the _dns-query-tls._tcp SRV record for company.com. If we make the latter (public) query
7592 // a duplicate of the former (private) query, then it will block forever waiting for an answer that will never come.
7595 // the queries that are not marked SuppressUnusable. But if the query is not suppressed, they are treated the same as
7604 // (b) being performed by a unicast DNS long-lived query (either full LLQ, or polling)
7621 (!q->AuthInfo || question->AuthInfo) && // to avoid deadlock, don't make public query dup of a private one
8050 else { LogInfo("ShouldSuppressQuery: Query not suppressed for %##s, qtype %s, not A/AAAA type", qname, DNSTypeName(qtype)); return mDNSfalse; }
8055 if (InterfaceID != mDNSInterface_Unicast && IsLocalDomain(qname)) { LogInfo("ShouldSuppressQuery: Query not suppressed for %##s, qtype %s, Local question", qname, DNSTypeName(qtype)); return mDNSfalse; }
8060 { LogInfo("ShouldSuppressQuery: Query not suppressed for %##s, qtype %s, Private Domain", qname, DNSTypeName(qtype)); return mDNSfalse; }
8075 LogInfo("ShouldSuppressQuery: Query not suppressed for %##s, qtype %s, Local Address %.4a found", qname, DNSTypeName(qtype),
8085 LogInfo("ShouldSuppressQuery: Query not suppressed for %##s, qtype %s, Local Address %.16a found", qname, DNSTypeName(qtype),
8091 LogInfo("ShouldSuppressQuery: Query suppressed for %##s, qtype %s, because no matching interface found", qname, DNSTypeName(qtype));
8275 // the query so that it can be answered from the cache.
8341 LogMsg("Attempt to start query with invalid qname %##s (%s)", question->qname.c, DNSTypeName(question->qtype));
8369 // wanted, and they may immediately cancel their question. In this case, sending an actual query on the wire would
8370 // be a waste. For that reason, we schedule our first query to go out in half a second (InitialQuestionInterval).
8493 // If long-lived query, and we don't have our NAT mapping active, start it now
8554 if (question->ThisQInterval >= 0) // Only log error message if the query was supposed to be active
8623 // *first*, then they're all ready to be updated a second time if necessary when we cancel our GetZoneData query.
8789 ServiceInfoQuery *query = (ServiceInfoQuery *)question->QuestionContext;
8790 mDNSBool PortChanged = !mDNSSameIPPort(query->info->port, answer->rdata->u.srv.port);
8794 query->info->port = answer->rdata->u.srv.port;
8796 // If this is our first answer, then set the GotSRV flag and start the address query
8797 if (!query->GotSRV)
8799 query->GotSRV = mDNStrue;
8800 query->qAv4.InterfaceID = answer->InterfaceID;
8801 AssignDomainName(&query->qAv4.qname, &answer->rdata->u.srv.target);
8802 query->qAv6.InterfaceID = answer->InterfaceID;
8803 AssignDomainName(&query->qAv6.qname, &answer->rdata->u.srv.target);
8804 mDNS_StartQuery(m, &query->qAv4);
8805 // Only do the AAAA query if this machine actually has IPv6 active
8806 if (MachineHasActiveIPv6(m)) mDNS_StartQuery(m, &query->qAv6);
8808 // If this is not our first answer, only re-issue the address query if the target host name has changed
8809 else if ((query->qAv4.InterfaceID != query->qSRV.InterfaceID && query->qAv4.InterfaceID != answer->InterfaceID) ||
8810 !SameDomainName(&query->qAv4.qname, &answer->rdata->u.srv.target))
8812 mDNS_StopQuery(m, &query->qAv4);
8813 if (query->qAv6.ThisQInterval >= 0) mDNS_StopQuery(m, &query->qAv6);
8814 if (SameDomainName(&query->qAv4.qname, &answer->rdata->u.srv.target) && !PortChanged)
8820 // make our address queries at least as broad as the original SRV query so that we catch all the answers.
8821 query->qAv4.InterfaceID = query->qSRV.InterfaceID; // Will be mDNSInterface_Any, or a specific interface
8822 query->qAv6.InterfaceID = query->qSRV.InterfaceID;
8826 query->qAv4.InterfaceID = answer->InterfaceID;
8827 AssignDomainName(&query->qAv4.qname, &answer->rdata->u.srv.target);
8828 query->qAv6.InterfaceID = answer->InterfaceID;
8829 AssignDomainName(&query->qAv6.qname, &answer->rdata->u.srv.target);
8831 debugf("FoundServiceInfoSRV: Restarting address queries for %##s (%s)", query->qAv4.qname.c, DNSTypeName(query->qAv4.qtype));
8832 mDNS_StartQuery(m, &query->qAv4);
8833 // Only do the AAAA query if this machine actually has IPv6 active
8834 if (MachineHasActiveIPv6(m)) mDNS_StartQuery(m, &query->qAv6);
8836 else if (query->ServiceInfoQueryCallback && query->GotADD && query->GotTXT && PortChanged)
8838 if (++query->Answers >= 100)
8840 query->Answers, query->qSRV.qname.c, answer->rdata->u.srv.target.c,
8842 query->ServiceInfoQueryCallback(m, query);
8844 // CAUTION: MUST NOT do anything more with query after calling query->Callback(), because the client's
8845 // callback function is allowed to do anything, including deleting this query and freeing its memory.
8850 ServiceInfoQuery *query = (ServiceInfoQuery *)question->QuestionContext;
8853 if (answer->rdlength > sizeof(query->info->TXTinfo)) return;
8855 query->GotTXT = mDNStrue;
8856 query->info->TXTlen = answer->rdlength;
8857 query->info->TXTinfo[0] = 0; // In case answer->rdlength is zero
8858 mDNSPlatformMemCopy(query
8860 verbosedebugf("FoundServiceInfoTXT: %##s GotADD=%d", query->info->name.c, query->GotADD);
8862 // CAUTION: MUST NOT do anything more with query after calling query->Callback(), because the client's
8863 // callback function is allowed to do anything, including deleting this query and freeing its memory.
8864 if (query->ServiceInfoQueryCallback && query->GotADD)
8866 if (++query->Answers >= 100)
8868 query->Answers, query->qSRV.qname.c, answer->rdata->u.txt.c);
8869 query->ServiceInfoQueryCallback(m, query);
8875 ServiceInfoQuery *query = (ServiceInfoQuery *)question->QuestionContext;
8881 query->info->ip.type = mDNSAddrType_IPv4;
8882 query->info->ip.ip.v4 = answer->rdata->u.ipv4;
8886 query->info->ip.type = mDNSAddrType_IPv6;
8887 query->info->ip.ip.v6 = answer->rdata->u.ipv6;
8895 query->GotADD = mDNStrue;
8896 query->info->InterfaceID = answer->InterfaceID;
8898 verbosedebugf("FoundServiceInfo v%ld: %##s GotTXT=%d", query->info->ip.type, query->info->name.c, query->GotTXT);
8900 // CAUTION: MUST NOT do anything more with query after calling query->Callback(), because the client's
8901 // callback function is allowed to do anything, including deleting this query and freeing its memory.
8902 if (query->ServiceInfoQueryCallback && query->GotTXT)
8904 if (++query->Answers >= 100)
8908 query->Answers, query->qSRV.qname.c, &answer->rdata->u.data);
8909 query->ServiceInfoQueryCallback(m, query);
8914 // If the query is not interface-specific, then InterfaceID may be zero
8918 ServiceInfoQuery *query, ServiceInfo *info, mDNSServiceInfoQueryCallback *Callback, void *Context)
8923 query->qSRV.ThisQInterval = -1; // So that mDNS_StopResolveService() knows whether to cancel this question
8924 query->qSRV.InterfaceID = info->InterfaceID;
8925 query->qSRV.Target = zeroAddr;
8926 AssignDomainName(&query->qSRV.qname, &info->name);
8927 query->qSRV.qtype = kDNSType_SRV;
8928 query->qSRV.qclass = kDNSClass_IN;
8929 query->qSRV.LongLived = mDNSfalse;
8930 query->qSRV.ExpectUnique = mDNStrue;
8931 query->qSRV.ForceMCast = mDNSfalse;
8932 query->qSRV.ReturnIntermed = mDNSfalse;
8933 query->qSRV.SuppressUnusable = mDNSfalse;
8934 query->qSRV.SearchListIndex = 0;
8935 query->qSRV.AppendSearchDomains = 0;
8936 query->qSRV.RetryWithSearchDomains = mDNSfalse;
8937 query->qSRV.TimeoutQuestion = 0;
8938 query->qSRV.WakeOnResolve = 0;
8939 query->qSRV.qnameOrig = mDNSNULL;
8940 query->qSRV.QuestionCallback = FoundServiceInfoSRV;
8941 query->qSRV.QuestionContext = query;
8943 query->qTXT.ThisQInterval = -1; // So that mDNS_StopResolveService() knows whether to cancel this question
8944 query->qTXT.InterfaceID = info->InterfaceID;
8945 query->qTXT.Target = zeroAddr;
8946 AssignDomainName(&query->qTXT.qname, &info->name);
8947 query->qTXT.qtype = kDNSType_TXT;
8948 query->qTXT.qclass = kDNSClass_IN;
8949 query->qTXT.LongLived = mDNSfalse;
8950 query->qTXT.ExpectUnique = mDNStrue;
8951 query->qTXT.ForceMCast = mDNSfalse;
8952 query->qTXT.ReturnIntermed = mDNSfalse;
8953 query->qTXT.SuppressUnusable = mDNSfalse;
8954 query->qTXT.SearchListIndex = 0;
8955 query->qTXT.AppendSearchDomains = 0;
8956 query->qTXT.RetryWithSearchDomains = mDNSfalse;
8957 query->qTXT.TimeoutQuestion = 0;
8958 query->qTXT.WakeOnResolve = 0;
8959 query->qTXT.qnameOrig = mDNSNULL;
8960 query->qTXT.QuestionCallback = FoundServiceInfoTXT;
8961 query->qTXT.QuestionContext = query;
8963 query->qAv4.ThisQInterval = -1; // So that mDNS_StopResolveService() knows whether to cancel this question
8964 query->qAv4.InterfaceID = info->InterfaceID;
8965 query->qAv4.Target = zeroAddr;
8966 query->qAv4.qname.c[0] = 0;
8967 query->qAv4.qtype = kDNSType_A;
8968 query->qAv4.qclass = kDNSClass_IN;
8969 query->qAv4.LongLived = mDNSfalse;
8970 query->qAv4.ExpectUnique = mDNStrue;
8971 query->qAv4.ForceMCast = mDNSfalse;
8972 query->qAv4.ReturnIntermed = mDNSfalse;
8973 query->qAv4.SuppressUnusable = mDNSfalse;
8974 query->qAv4.SearchListIndex = 0;
8975 query->qAv4.AppendSearchDomains = 0;
8976 query->qAv4.RetryWithSearchDomains = mDNSfalse;
8977 query->qAv4.TimeoutQuestion = 0;
8978 query->qAv4.WakeOnResolve = 0;
8979 query->qAv4.qnameOrig = mDNSNULL;
8980 query->qAv4.QuestionCallback = FoundServiceInfo;
8981 query->qAv4.QuestionContext = query;
8983 query->qAv6.ThisQInterval = -1; // So that mDNS_StopResolveService() knows whether to cancel this question
8984 query->qAv6.InterfaceID = info->InterfaceID;
8985 query->qAv6.Target = zeroAddr;
8986 query->qAv6.qname.c[0] = 0;
8987 query->qAv6.qtype = kDNSType_AAAA;
8988 query->qAv6.qclass = kDNSClass_IN;
8989 query->qAv6.LongLived = mDNSfalse;
8990 query->qAv6.ExpectUnique = mDNStrue;
8991 query->qAv6.ForceMCast = mDNSfalse;
8992 query->qAv6.ReturnIntermed = mDNSfalse;
8993 query->qAv6.SuppressUnusable = mDNSfalse;
8994 query->qAv6.SearchListIndex = 0;
8995 query->qAv6.AppendSearchDomains = 0;
8996 query->qAv6.RetryWithSearchDomains = mDNSfalse;
8997 query->qAv6.TimeoutQuestion = 0;
8998 query->qAv6.WakeOnResolve = 0;
8999 query->qAv6.qnameOrig = mDNSNULL;
9000 query->qAv6.QuestionCallback = FoundServiceInfo;
9001 query->qAv6.QuestionContext = query;
9003 query->GotSRV = mDNSfalse;
9004 query->GotTXT = mDNSfalse;
9005 query->GotADD = mDNSfalse;
9006 query->Answers = 0;
9008 query->info = info;
9009 query->ServiceInfoQueryCallback = Callback;
9010 query->ServiceInfoQueryContext = Context;
9019 status = mDNS_StartQuery_internal(m, &query->qSRV);
9020 if (status == mStatus_NoError) status = mDNS_StartQuery_internal(m, &query->qTXT);
9021 if (status != mStatus_NoError) mDNS_StopResolveService(m, query);
10887 // case happens when we pick a DNSServer, issue a query and get a valid response and create
10888 // cache entries after which it stops responding. Another query (non-duplicate) picks a different
10906 // AnswerNewQuestion. This case happens when we picked a DNSServer, sent the query and
11043 // The m->StartWABQueries is set when we get the first domain enumeration query (no need to hit the network
11137 // 1) The query gets sent out and when the actual response comes back later it is possible
11146 // 3) We might have marked the cache entries for reconfirm above, for which we send the query out which is
11152 // suppressed, but it is wrong to activate the query as DNS server change
11156 debugf("uDNS_SetupDNSConfig: Activating query %p %##s (%s)", q, q->qname.c, DNSTypeName(q->qtype));