Lines Matching refs:q

164 mDNSexport void PenalizeDNSServer(mDNS *const m, DNSQuestion *q)  in PenalizeDNSServer()  argument
167 DNSServer *orig = q->qDNSServer; in PenalizeDNSServer()
177 if (!q->qDNSServer) in PenalizeDNSServer()
179 …lizeDNSServer: ERROR!! Null DNS server for %##s (%s) %d", q->qname.c, DNSTypeName(q->qtype), q->un… in PenalizeDNSServer()
184 …&q->qDNSServer->addr, mDNSVal16(q->qDNSServer->port), q->qDNSServer->domain.c, q, q->qname.c, DNST… in PenalizeDNSServer()
185 q->SuppressUnusable); in PenalizeDNSServer()
200 if (q->qtype == kDNSType_PTR) in PenalizeDNSServer()
206 LogInfo("PenalizeDNSServer: Penalizing question type %d", q->qtype); in PenalizeDNSServer()
207 q->qDNSServer->penaltyTime = NonZeroTime(m->timenow + DNSSERVER_PENALTY_TIME); in PenalizeDNSServer()
216 new = GetServerForQuestion(m, q); in PenalizeDNSServer()
226 q->ThisQInterval = 0; // Inactivate this question so that we dont bombard the network in PenalizeDNSServer()
231 DNSServerChangeForQuestion(m, q, new); in PenalizeDNSServer()
236q->qname.c, DNSTypeName(q->qtype), &q->qDNSServer->addr, mDNSVal16(q->qDNSServer->port), q->qDNSSe… in PenalizeDNSServer()
241 if (!q->triedAllServersOnce) in PenalizeDNSServer()
243 q->ThisQInterval = InitialQuestionInterval; in PenalizeDNSServer()
244 q->LastQTime = m->timenow - q->ThisQInterval; in PenalizeDNSServer()
245 SetNextQueryTime(m, q); in PenalizeDNSServer()
273 … Server for %p, %##s (%s) changed to NULL, Interval %d", q, q->qname.c, DNSTypeName(q->qtype), q->… in PenalizeDNSServer()
275 q->unansweredQueries = 0; in PenalizeDNSServer()
316 DNSQuestion *q; in GetAuthInfoForName_internal() local
320 for (q = m->Questions; q; q=q->next) in GetAuthInfoForName_internal()
321 if (q->AuthInfo == info) in GetAuthInfoForName_internal()
323 q->AuthInfo = GetAuthInfoForName_direct(m, &q->qname); in GetAuthInfoForName_internal()
325 …info->domain.c, q->AuthInfo ? q->AuthInfo->domain.c : mDNSNULL, q->qname.c, DNSTypeName(q->qtype)); in GetAuthInfoForName_internal()
354 DNSQuestion *q; in mDNS_SetSecretForDomain() local
398 for (q = m->Questions; q; q=q->next) in mDNS_SetSecretForDomain()
400 DomainAuthInfo *newinfo = GetAuthInfoForQuestion(m, q); in mDNS_SetSecretForDomain()
401 if (q->AuthInfo != newinfo) in mDNS_SetSecretForDomain()
404 q->AuthInfo ? q->AuthInfo->domain.c : mDNSNULL, in mDNS_SetSecretForDomain()
405 newinfo ? newinfo ->domain.c : mDNSNULL, q->qname.c, DNSTypeName(q->qtype)); in mDNS_SetSecretForDomain()
406 q->AuthInfo = newinfo; in mDNS_SetSecretForDomain()
688 mDNSlocal void StartLLQPolling(mDNS *const m, DNSQuestion *q) in StartLLQPolling() argument
690 debugf("StartLLQPolling: %##s", q->qname.c); in StartLLQPolling()
691 q->state = LLQ_Poll; in StartLLQPolling()
692 q->ThisQInterval = INIT_UCAST_POLL_INTERVAL; in StartLLQPolling()
695 q->LastQTime = m->timenow - q->ThisQInterval + 1; in StartLLQPolling()
696 SetNextQueryTime(m, q); in StartLLQPolling()
748 mDNSlocal void sendChallengeResponse(mDNS *const m, DNSQuestion *const q, const LLQOptData *llq) in sendChallengeResponse() argument
753 …if (q->tcp) { LogMsg("sendChallengeResponse: ERROR!!: question %##s (%s) tcp non-NULL", q->qname.c… in sendChallengeResponse()
755 …if (PrivateQuery(q)) { LogMsg("sendChallengeResponse: ERROR!!: Private Query %##s (%s)", q->qname.… in sendChallengeResponse()
757 if (q->ntries++ == kLLQ_MAX_TRIES) in sendChallengeResponse()
759 LogMsg("sendChallengeResponse: %d failed attempts for LLQ %##s", kLLQ_MAX_TRIES, q->qname.c); in sendChallengeResponse()
760 StartLLQPolling(m,q); in sendChallengeResponse()
769 llqBuf.id = q->id; in sendChallengeResponse()
770 llqBuf.llqlease = q->ReqLease; in sendChallengeResponse()
774 q->LastQTime = m->timenow; in sendChallengeResponse()
775q->ThisQInterval = q->tcp ? 0 : (kLLQ_INIT_RESEND * q->ntries * mDNSPlatformOneSecond); // If usi… in sendChallengeResponse()
776 SetNextQueryTime(m, q); in sendChallengeResponse()
781 InitializeDNSMessage(&m->omsg.h, q->TargetQID, uQueryFlags); in sendChallengeResponse()
782 responsePtr = putLLQ(&m->omsg, responsePtr, q, llq); in sendChallengeResponse()
785 …SSendDNSMessage(m, &m->omsg, responsePtr, mDNSInterface_Any, q->LocalSocket, &q->servAddr, q->serv… in sendChallengeResponse()
786 …if (err) { LogMsg("sendChallengeResponse: mDNSSendDNSMessage%s failed: %d", q->tcp ? " (TCP)" : ""… in sendChallengeResponse()
788 else StartLLQPolling(m,q); in sendChallengeResponse()
791 mDNSlocal void SetLLQTimer(mDNS *const m, DNSQuestion *const q, const LLQOptData *const llq) in SetLLQTimer() argument
794 q->ReqLease = llq->llqlease; in SetLLQTimer()
795 q->LastQTime = m->timenow; in SetLLQTimer()
796 q->expire = m->timenow + lease; in SetLLQTimer()
797 q->ThisQInterval = lease/2 + mDNSRandom(lease/10); in SetLLQTimer()
798 …f("SetLLQTimer setting %##s (%s) to %d %d", q->qname.c, DNSTypeName(q->qtype), lease/mDNSPlatformO… in SetLLQTimer()
799 SetNextQueryTime(m, q); in SetLLQTimer()
802 mDNSlocal void recvSetupResponse(mDNS *const m, mDNSu8 rcode, DNSQuestion *const q, const LLQOptDat… in recvSetupResponse() argument
805 …pResponse %##s (%s) - rcode && rcode != kDNSFlag1_RC_NXDomain", q->qname.c, DNSTypeName(q->qtype))… in recvSetupResponse()
808 …{ LogMsg("ERROR: recvSetupResponse %##s (%s) - bad op %d", q->qname.c, DNSTypeName(q->qtype), llq-… in recvSetupResponse()
811 …{ LogMsg("ERROR: recvSetupResponse %##s (%s) - bad vers %d", q->qname.c, DNSTypeName(q->qtype), ll… in recvSetupResponse()
813 if (q->state == LLQ_InitialRequest) in recvSetupResponse()
817 …("recvSetupResponse - received llq->err %d from server", llq->err); StartLLQPolling(m,q); return; } in recvSetupResponse()
819 if (q->ReqLease != llq->llqlease) in recvSetupResponse()
820 debugf("recvSetupResponse: requested lease %lu, granted lease %lu", q->ReqLease, llq->llqlease); in recvSetupResponse()
823 q->ReqLease = llq->llqlease; in recvSetupResponse()
824 q->expire = m->timenow + ((mDNSs32)llq->llqlease * mDNSPlatformOneSecond); in recvSetupResponse()
827 q->state = LLQ_SecondaryRequest; in recvSetupResponse()
828 q->id = llq->id; in recvSetupResponse()
829 q->ntries = 0; // first attempt to send response in recvSetupResponse()
830 sendChallengeResponse(m, q, llq); in recvSetupResponse()
832 else if (q->state == LLQ_SecondaryRequest) in recvSetupResponse()
840 if (PrivateQuery(q)) in recvSetupResponse()
843 q->id = llq->id; in recvSetupResponse()
846 …tupResponse %##s (%s) code %d from server", q->qname.c, DNSTypeName(q->qtype), llq->err); StartLLQ… in recvSetupResponse()
847 if (!mDNSSameOpaque64(&q->id, &llq->id)) in recvSetupResponse()
849 q->state = LLQ_Established; in recvSetupResponse()
850 q->ntries = 0; in recvSetupResponse()
851 SetLLQTimer(m, q, llq); in recvSetupResponse()
861 DNSQuestion pktQ, *q; in uDNS_recvLLQResponse() local
866 for (q = m->Questions; q; q = q->next) in uDNS_recvLLQResponse()
868 …(!mDNSOpaque16IsZero(q->TargetQID) && q->LongLived && q->qtype == pktQ.qtype && q->qnamehash == pk… in uDNS_recvLLQResponse()
871 q->qname.c, DNSTypeName(q->qtype), q->state, srcaddr, &q->servAddr, in uDNS_recvLLQResponse()
872 …opt ? opt->u.llq.id.l[0] : 0, opt ? opt->u.llq.id.l[1] : 0, q->id.l[0], q->id.l[1], opt ? opt->u.l… in uDNS_recvLLQResponse()
873 …if (q->state == LLQ_Poll) debugf("uDNS_LLQ_Events: q->state == LLQ_Poll msg->h.id %d q->TargetQID … in uDNS_recvLLQResponse()
874 if (q->state == LLQ_Poll && mDNSSameOpaque16(msg->h.id, q->TargetQID)) in uDNS_recvLLQResponse()
890 if (!mDNSAddressIsOnes(&q->servAddr) && !mDNSIPPortIsZero(m->LLQNAT.ExternalPort) && in uDNS_recvLLQResponse()
893 …got poll response; moving to LLQ_InitialRequest for %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); in uDNS_recvLLQResponse()
894 q->state = LLQ_InitialRequest; in uDNS_recvLLQResponse()
896q->servPort = zeroIPPort; // Clear servPort so that startLLQHandshake will retry the GetZone… in uDNS_recvLLQResponse()
897q->ThisQInterval = LLQ_POLL_INTERVAL + mDNSRandom(LLQ_POLL_INTERVAL/10); // Retry LLQ setup in app… in uDNS_recvLLQResponse()
898 q->LastQTime = m->timenow; in uDNS_recvLLQResponse()
899 SetNextQueryTime(m, q); in uDNS_recvLLQResponse()
900 *matchQuestion = q; in uDNS_recvLLQResponse()
904 …else if (opt && q->state == LLQ_Established && opt->u.llq.llqOp == kLLQOp_Event && mDNSSameOpaque6… in uDNS_recvLLQResponse()
909 ackEnd = putLLQ(&m->omsg, m->omsg.data, q, &opt->u.llq); in uDNS_recvLLQResponse()
910 …if (ackEnd) mDNSSendDNSMessage(m, &m->omsg, ackEnd, mDNSInterface_Any, q->LocalSocket, srcaddr, sr… in uDNS_recvLLQResponse()
912 …e == LLQ_Established msg->h.id %d q->TargetQID %d", mDNSVal16(msg->h.id), mDNSVal16(q->TargetQID)); in uDNS_recvLLQResponse()
913 *matchQuestion = q; in uDNS_recvLLQResponse()
916 if (opt && mDNSSameOpaque16(msg->h.id, q->TargetQID)) in uDNS_recvLLQResponse()
918 …if (q->state == LLQ_Established && opt->u.llq.llqOp == kLLQOp_Refresh && mDNSSameOpaque64(&opt->u.… in uDNS_recvLLQResponse()
927 GrantCacheExtensions(m, q, opt->u.llq.llqlease); in uDNS_recvLLQResponse()
928 SetLLQTimer(m, q, &opt->u.llq); in uDNS_recvLLQResponse()
929 q->ntries = 0; in uDNS_recvLLQResponse()
932 *matchQuestion = q; in uDNS_recvLLQResponse()
935 if (q->state < LLQ_Established && mDNSSameAddress(srcaddr, &q->servAddr)) in uDNS_recvLLQResponse()
937 LLQ_State oldstate = q->state; in uDNS_recvLLQResponse()
938 recvSetupResponse(m, msg->h.flags.b[1] & kDNSFlag1_RC_Mask, q, &opt->u.llq); in uDNS_recvLLQResponse()
947 *matchQuestion = q; in uDNS_recvLLQResponse()
969 DNSQuestion *const q = tcpInfo->question; in tcpCallback() local
971 q ? &q ->tcp : in tcpCallback()
975 mDNSPlatformTCPGetFD(tcpInfo->sock), *backpointer, tcpInfo, q, tcpInfo->rr); in tcpCallback()
994 if (q && q->LongLived && q->state == LLQ_Established) in tcpCallback()
999 …else if (q && q->LongLived && q->state != LLQ_Poll && !mDNSIPPortIsZero(m->LLQNAT.ExternalPort) &&… in tcpCallback()
1012 InitializeDNSMessage(&tcpInfo->request.h, q->TargetQID, uQueryFlags); in tcpCallback()
1013 end = putLLQ(&tcpInfo->request, tcpInfo->request.data, q, &llqData); in tcpCallback()
1015 AuthInfo = q->AuthInfo; // Need to add TSIG to this message in tcpCallback()
1016q->ntries = 0; // Reset ntries so that tcp/tls connection failures don't affect sendChallengeRespo… in tcpCallback()
1018 else if (q) in tcpCallback()
1021 InitializeDNSMessage(&tcpInfo->request.h, q->TargetQID, uQueryFlags); in tcpCallback()
1022 …->request.data, tcpInfo->request.data + AbsoluteMaxDNSMessageData, &q->qname, q->qtype, q->qclass); in tcpCallback()
1023 AuthInfo = q->AuthInfo; // Need to add TSIG to this message in tcpCallback()
1030 if (q) in tcpCallback()
1033 q->LastQTime = m->timenow; in tcpCallback()
1034 …if (q->ThisQInterval < (256 * mDNSPlatformOneSecond)) // Now we have a TCP connection open, make s… in tcpCallback()
1035 q->ThisQInterval = (256 * mDNSPlatformOneSecond); in tcpCallback()
1036 SetNextQueryTime(m, q); in tcpCallback()
1139 if (q && q->tcp) {srcPort = q->tcp->SrcPort; q->tcpSrcPort = srcPort;} in tcpCallback()
1142 if (!q || !q->LongLived || m->SleepState) in tcpCallback()
1163 if (q) in tcpCallback()
1165 if (q->ThisQInterval == 0) in tcpCallback()
1169 q->LastQTime = m->timenow; in tcpCallback()
1170 if (q->LongLived) in tcpCallback()
1176 mDNSu32 count = q->ntries + 1; // want to wait at least 1 second before retrying in tcpCallback()
1178 q->ThisQInterval = InitialQuestionInterval; in tcpCallback()
1181 q->ThisQInterval *= QuestionIntervalStep; in tcpCallback()
1183 if (q->ThisQInterval > LLQ_POLL_INTERVAL) in tcpCallback()
1184 q->ThisQInterval = LLQ_POLL_INTERVAL; in tcpCallback()
1186 q->ntries++; in tcpCallback()
1188 …r LLQ %##s (%s) failed %d times, retrying in %d ms", q->qname.c, DNSTypeName(q->qtype), q->ntries,… in tcpCallback()
1192 q->ThisQInterval = MAX_UCAST_POLL_INTERVAL; in tcpCallback()
1193 …ream connection for %##s (%s) failed, retrying in %d ms", q->qname.c, DNSTypeName(q->qtype), q->Th… in tcpCallback()
1195 SetNextQueryTime(m, q); in tcpCallback()
1197 …else if (NextQSendTime(q) - m->timenow > (q->LongLived ? LLQ_POLL_INTERVAL : MAX_UCAST_POLL_INTERV… in tcpCallback()
1201 q->LastQTime = m->timenow; in tcpCallback()
1202 q->ThisQInterval = q->LongLived ? LLQ_POLL_INTERVAL : MAX_UCAST_POLL_INTERVAL; in tcpCallback()
1203 SetNextQueryTime(m, q); in tcpCallback()
1204 …ream connection for %##s (%s) failed, retrying in %d ms", q->qname.c, DNSTypeName(q->qtype), q->Th… in tcpCallback()
1211 if (q->LongLived && q->state == LLQ_SecondaryRequest) in tcpCallback()
1212 q->state = LLQ_InitialRequest; in tcpCallback()
1219 if (q->LongLived && q->state != LLQ_Poll) StartLLQPolling(m, q); in tcpCallback()
1286 mDNSexport void startLLQHandshake(mDNS *m, DNSQuestion *q) in startLLQHandshake() argument
1290 …LogInfo("startLLQHandshake: waiting for NAT status for %##s (%s)", q->qname.c, DNSTypeName(q->qtyp… in startLLQHandshake()
1291q->ThisQInterval = LLQ_POLL_INTERVAL + mDNSRandom(LLQ_POLL_INTERVAL/10); // Retry in approx 15 min… in startLLQHandshake()
1292 q->LastQTime = m->timenow; in startLLQHandshake()
1293 SetNextQueryTime(m, q); in startLLQHandshake()
1302 q->qname.c, DNSTypeName(q->qtype), mDNSVal16(m->LLQNAT.ExternalPort), m->LLQNAT.Result); in startLLQHandshake()
1303 StartLLQPolling(m, q); in startLLQHandshake()
1307 if (mDNSIPPortIsZero(q->servPort)) in startLLQHandshake()
1309 debugf("startLLQHandshake: StartGetZoneData for %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); in startLLQHandshake()
1310q->ThisQInterval = LLQ_POLL_INTERVAL + mDNSRandom(LLQ_POLL_INTERVAL/10); // Retry in approx 15 min… in startLLQHandshake()
1311 q->LastQTime = m->timenow; in startLLQHandshake()
1312 SetNextQueryTime(m, q); in startLLQHandshake()
1313 q->servAddr = zeroAddr; in startLLQHandshake()
1315 if (q->nta) CancelGetZoneData(m, q->nta); in startLLQHandshake()
1316 q->nta = StartGetZoneData(m, &q->qname, ZoneServiceLLQ, LLQGotZoneData, q); in startLLQHandshake()
1320 if (PrivateQuery(q)) in startLLQHandshake()
1322 …if (q->tcp) LogInfo("startLLQHandshake: Disposing existing TCP connection for %##s (%s)", q->qname… in startLLQHandshake()
1323 if (q->tcp) { DisposeTCPConn(q->tcp); q->tcp = mDNSNULL; } in startLLQHandshake()
1324 if (!q->nta) in startLLQHandshake()
1333 LogInfo("startLLQHandshake: nta is NULL for %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); in startLLQHandshake()
1334 q->nta = StartGetZoneData(m, &q->qname, ZoneServiceLLQ, LLQGotZoneData, q); in startLLQHandshake()
1337 else if (!q->nta->Host.c[0]) in startLLQHandshake()
1340 …r %##s (%s) but HostName %d NULL, LongLived %d", q->qname.c, DNSTypeName(q->qtype), q->nta->Host.c… in startLLQHandshake()
1342q->tcp = MakeTCPConn(m, mDNSNULL, mDNSNULL, kTCPSocketFlags_UseTLS, &q->servAddr, q->servPort, &q-… in startLLQHandshake()
1343 if (!q->tcp) in startLLQHandshake()
1344q->ThisQInterval = mDNSPlatformOneSecond * 5; // If TCP failed (transient networking glitch) try a… in startLLQHandshake()
1347q->state = LLQ_SecondaryRequest; // Right now, for private DNS, we skip the four-way LLQ … in startLLQHandshake()
1348 q->ReqLease = kLLQ_DefLease; in startLLQHandshake()
1349 q->ThisQInterval = 0; in startLLQHandshake()
1351 q->LastQTime = m->timenow; in startLLQHandshake()
1352 SetNextQueryTime(m, q); in startLLQHandshake()
1358 …&q->servAddr, mDNSVal16(q->servPort), mDNSAddrIsRFC1918(&q->servAddr) ? " (RFC 1918)" … in startLLQHandshake()
1359 q->qname.c, DNSTypeName(q->qtype)); in startLLQHandshake()
1361 if (q->ntries++ >= kLLQ_MAX_TRIES) in startLLQHandshake()
1363 … LogMsg("startLLQHandshake: %d failed attempts for LLQ %##s Polling.", kLLQ_MAX_TRIES, q->qname.c); in startLLQHandshake()
1364 StartLLQPolling(m, q); in startLLQHandshake()
1378 InitializeDNSMessage(&m->omsg.h, q->TargetQID, uQueryFlags); in startLLQHandshake()
1379 end = putLLQ(&m->omsg, m->omsg.data, q, &llqData); in startLLQHandshake()
1380 if (!end) { LogMsg("ERROR: startLLQHandshake - putLLQ"); StartLLQPolling(m,q); return; } in startLLQHandshake()
1382 …mDNSSendDNSMessage(m, &m->omsg, end, mDNSInterface_Any, q->LocalSocket, &q->servAddr, q->servPort,… in startLLQHandshake()
1385 q->state = LLQ_InitialRequest; in startLLQHandshake()
1386 q->ReqLease = kLLQ_DefLease; in startLLQHandshake()
1387 q->ThisQInterval = (kLLQ_INIT_RESEND * mDNSPlatformOneSecond); in startLLQHandshake()
1388 q->LastQTime = m->timenow; in startLLQHandshake()
1389 SetNextQueryTime(m, q); in startLLQHandshake()
1658 mDNSexport mDNSBool IsGetZoneDataQuestion(DNSQuestion *q) in IsGetZoneDataQuestion() argument
1660 if (q->QuestionCallback == GetZoneData_QuestionCallback) return(mDNStrue); in IsGetZoneDataQuestion()
1669 mDNSexport DomainAuthInfo *GetAuthInfoForQuestion(mDNS *m, const DNSQuestion *const q) // Must be c… in GetAuthInfoForQuestion() argument
1671 if (q->QuestionCallback == GetZoneData_QuestionCallback) return(mDNSNULL); in GetAuthInfoForQuestion()
1672 if (q->qtype == kDNSType_SOA ) return(mDNSNULL); in GetAuthInfoForQuestion()
1673 return(GetAuthInfoForName_internal(m, &q->qname)); in GetAuthInfoForQuestion()
2250 DNSQuestion *q = &m->ReverseMap; in GetStaticHostname() local
2257 mDNSPlatformMemZero(q, sizeof(*q)); in GetStaticHostname()
2260 …if (!MakeDomainNameFromDNSNameString(&q->qname, buf)) { LogMsg("Error: GetStaticHostname - bad nam… in GetStaticHostname()
2262 q->InterfaceID = mDNSInterface_Any; in GetStaticHostname()
2263 q->Target = zeroAddr; in GetStaticHostname()
2264 q->qtype = kDNSType_PTR; in GetStaticHostname()
2265 q->qclass = kDNSClass_IN; in GetStaticHostname()
2266 q->LongLived = mDNSfalse; in GetStaticHostname()
2267 q->ExpectUnique = mDNSfalse; in GetStaticHostname()
2268 q->ForceMCast = mDNSfalse; in GetStaticHostname()
2269 q->ReturnIntermed = mDNStrue; in GetStaticHostname()
2270 q->SuppressUnusable = mDNSfalse; in GetStaticHostname()
2271 q->SearchListIndex = 0; in GetStaticHostname()
2272 q->AppendSearchDomains = 0; in GetStaticHostname()
2273 q->RetryWithSearchDomains = mDNSfalse; in GetStaticHostname()
2274 q->TimeoutQuestion = 0; in GetStaticHostname()
2275 q->WakeOnResolve = 0; in GetStaticHostname()
2276 q->qnameOrig = mDNSNULL; in GetStaticHostname()
2277 q->QuestionCallback = FoundStaticHostname; in GetStaticHostname()
2278 q->QuestionContext = mDNSNULL; in GetStaticHostname()
2280 LogInfo("GetStaticHostname: %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); in GetStaticHostname()
2281 err = mDNS_StartQuery_internal(m, q); in GetStaticHostname()
3413 mDNSlocal mDNSBool NoTestQuery(DNSQuestion *q) in NoTestQuery() argument
3416 mDNSu8 *p = q->qname.c; in NoTestQuery()
3417 …if (q->AuthInfo) return(mDNStrue); // Don't need a test query for private queries sent directly t… in NoTestQuery()
3418 if (q->qtype != kDNSType_PTR) return(mDNStrue); // Don't need a test query for any non-PTR queries in NoTestQuery()
3462 DNSQuestion *q; in uDNS_ReceiveTestQuestionResponse() local
3480 for (q = m->Questions; q; q=q->next) in uDNS_ReceiveTestQuestionResponse()
3481 if (q->qDNSServer == s && !NoTestQuery(q)) in uDNS_ReceiveTestQuestionResponse()
3483 q->ThisQInterval = INIT_UCAST_POLL_INTERVAL / QuestionIntervalStep; in uDNS_ReceiveTestQuestionResponse()
3484 q->unansweredQueries = 0; in uDNS_ReceiveTestQuestionResponse()
3485 q->LastQTime = m->timenow - q->ThisQInterval; in uDNS_ReceiveTestQuestionResponse()
3574 mDNSexport void sendLLQRefresh(mDNS *m, DNSQuestion *q) in sendLLQRefresh() argument
3580 if (q->ReqLease) in sendLLQRefresh()
3581 if ((q->state == LLQ_Established && q->ntries >= kLLQ_MAX_TRIES) || q->expire - m->timenow < 0) in sendLLQRefresh()
3583 …LogMsg("Unable to refresh LLQ %##s (%s) - will retry in %d seconds", q->qname.c, DNSTypeName(q->qt… in sendLLQRefresh()
3584 StartLLQPolling(m,q); in sendLLQRefresh()
3590 …llq.err = q->tcp ? GetLLQEventPort(m, &q->servAddr) : LLQErr_NoError; // If using TCP tell se… in sendLLQRefresh()
3591 llq.id = q->id; in sendLLQRefresh()
3592 llq.llqlease = q->ReqLease; in sendLLQRefresh()
3594 InitializeDNSMessage(&m->omsg.h, q->TargetQID, uQueryFlags); in sendLLQRefresh()
3595 end = putLLQ(&m->omsg, m->omsg.data, q, &llq); in sendLLQRefresh()
3596 …if (!end) { LogMsg("sendLLQRefresh: putLLQ failed %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); … in sendLLQRefresh()
3600 end = putHINFO(m, &m->omsg, end, q->AuthInfo, limit); in sendLLQRefresh()
3601 …if (!end) { LogMsg("sendLLQRefresh: putHINFO failed %##s (%s)", q->qname.c, DNSTypeName(q->qtype))… in sendLLQRefresh()
3603 if (PrivateQuery(q)) in sendLLQRefresh()
3605 DNSDigest_SignMessageHostByteOrder(&m->omsg, &end, q->AuthInfo); in sendLLQRefresh()
3606 …ogMsg("sendLLQRefresh: DNSDigest_SignMessage failed %##s (%s)", q->qname.c, DNSTypeName(q->qtype))… in sendLLQRefresh()
3609 if (PrivateQuery(q) && !q->tcp) in sendLLQRefresh()
3611 LogInfo("sendLLQRefresh setting up new TLS session %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); in sendLLQRefresh()
3612 …if (!q->nta) { LogMsg("sendLLQRefresh:ERROR!! q->nta is NULL for %##s (%s)", q->qname.c, DNSTypeNa… in sendLLQRefresh()
3613q->tcp = MakeTCPConn(m, &m->omsg, end, kTCPSocketFlags_UseTLS, &q->servAddr, q->servPort, &q->nta-… in sendLLQRefresh()
3621 LogInfo("sendLLQRefresh: using existing %s session %##s (%s)", PrivateQuery(q) ? "TLS" : "UDP", in sendLLQRefresh()
3622 q->qname.c, DNSTypeName(q->qtype)); in sendLLQRefresh()
3624 …ndDNSMessage(m, &m->omsg, end, mDNSInterface_Any, q->LocalSocket, &q->servAddr, q->servPort, q->tc… in sendLLQRefresh()
3627 LogMsg("sendLLQRefresh: mDNSSendDNSMessage%s failed: %d", q->tcp ? " (TCP)" : "", err); in sendLLQRefresh()
3628 if (q->tcp) { DisposeTCPConn(q->tcp); q->tcp = mDNSNULL; } in sendLLQRefresh()
3632 q->ntries++; in sendLLQRefresh()
3634 debugf("sendLLQRefresh ntries %d %##s (%s)", q->ntries, q->qname.c, DNSTypeName(q->qtype)); in sendLLQRefresh()
3636 q->LastQTime = m->timenow; in sendLLQRefresh()
3637 SetNextQueryTime(m, q); in sendLLQRefresh()
3642 DNSQuestion *q = (DNSQuestion *)zoneInfo->ZoneDataContext; in LLQGotZoneData() local
3649 q->servAddr = zeroAddr; in LLQGotZoneData()
3650 q->servPort = zeroIPPort; in LLQGotZoneData()
3654 q->servAddr = zoneInfo->Addr; in LLQGotZoneData()
3655 q->servPort = zoneInfo->Port; in LLQGotZoneData()
3656 if (!PrivateQuery(q)) in LLQGotZoneData()
3660 if (q->nta) in LLQGotZoneData()
3662 …if (q->nta != zoneInfo) LogMsg("LLQGotZoneData: nta (%p) != zoneInfo (%p) %##s (%s)", q->nta, zon… in LLQGotZoneData()
3663 CancelGetZoneData(m, q->nta); in LLQGotZoneData()
3664 q->nta = mDNSNULL; in LLQGotZoneData()
3667 q->ntries = 0; in LLQGotZoneData()
3668 debugf("LLQGotZoneData %#a:%d", &q->servAddr, mDNSVal16(q->servPort)); in LLQGotZoneData()
3669 startLLQHandshake(m, q); in LLQGotZoneData()
3673 if (q->nta) in LLQGotZoneData()
3675 …if (q->nta != zoneInfo) LogMsg("LLQGotZoneData: nta (%p) != zoneInfo (%p) %##s (%s)", q->nta, zon… in LLQGotZoneData()
3676 CancelGetZoneData(m, q->nta); in LLQGotZoneData()
3677 q->nta = mDNSNULL; in LLQGotZoneData()
3679 StartLLQPolling(m,q); in LLQGotZoneData()
3683 q->servAddr.type = mDNSAddrType_IPv4; in LLQGotZoneData()
3684 q->servAddr.ip.v4 = onesIPv4Addr; in LLQGotZoneData()
3694 DNSQuestion *q = (DNSQuestion *) zoneInfo->ZoneDataContext; in PrivateQueryGotZoneData() local
3696 …LogInfo("PrivateQueryGotZoneData %##s (%s) err %d Zone %##s Private %d", q->qname.c, DNSTypeName(q in PrivateQueryGotZoneData()
3698 …if (q->nta != zoneInfo) LogMsg("PrivateQueryGotZoneData:ERROR!!: nta (%p) != zoneInfo (%p) %##s (… in PrivateQueryGotZoneData()
3703 q->qname.c, DNSTypeName(q->qtype), err, zoneInfo, in PrivateQueryGotZoneData()
3706 CancelGetZoneData(m, q->nta); in PrivateQueryGotZoneData()
3707 q->nta = mDNSNULL; in PrivateQueryGotZoneData()
3713 …ivate port lookup failed -- retrying without TLS -- %##s (%s)", q->qname.c, DNSTypeName(q->qtype)); in PrivateQueryGotZoneData()
3714 q->AuthInfo = mDNSNULL; // Clear AuthInfo so we try again non-private in PrivateQueryGotZoneData()
3715 q->ThisQInterval = InitialQuestionInterval; in PrivateQueryGotZoneData()
3716 q->LastQTime = m->timenow - q->ThisQInterval; in PrivateQueryGotZoneData()
3717 CancelGetZoneData(m, q->nta); in PrivateQueryGotZoneData()
3718 q->nta = mDNSNULL; in PrivateQueryGotZoneData()
3720 SetNextQueryTime(m, q); in PrivateQueryGotZoneData()
3726 if (!PrivateQuery(q)) in PrivateQueryGotZoneData()
3728 …Data: ERROR!! Not a private query %##s (%s) AuthInfo %p", q->qname.c, DNSTypeName(q->qtype), q->Au… in PrivateQueryGotZoneData()
3729 CancelGetZoneData(m, q->nta); in PrivateQueryGotZoneData()
3730 q->nta = mDNSNULL; in PrivateQueryGotZoneData()
3734 q->TargetQID = mDNS_NewMessageID(m); in PrivateQueryGotZoneData()
3735 if (q->tcp) { DisposeTCPConn(q->tcp); q->tcp = mDNSNULL; } in PrivateQueryGotZoneData()
3736 …if (!q->nta) { LogMsg("PrivateQueryGotZoneData:ERROR!! nta is NULL for %##s (%s)", q->qname.c, DNS… in PrivateQueryGotZoneData()
3737q->tcp = MakeTCPConn(m, mDNSNULL, mDNSNULL, kTCPSocketFlags_UseTLS, &zoneInfo->Addr, zoneInfo->Por… in PrivateQueryGotZoneData()
3738 if (q->nta) { CancelGetZoneData(m, q->nta); q->nta = mDNSNULL; } in PrivateQueryGotZoneData()
4165 DNSQuestion *q = m->CurrentQuestion; in uDNS_CheckCurrentQuestion() local
4166 if (m->timenow - NextQSendTime(q) < 0) return; in uDNS_CheckCurrentQuestion()
4168 if (q->LongLived) in uDNS_CheckCurrentQuestion()
4170 switch (q->state) in uDNS_CheckCurrentQuestion()
4172 case LLQ_InitialRequest: startLLQHandshake(m, q); break; in uDNS_CheckCurrentQuestion()
4175 if (PrivateQuery(q)) in uDNS_CheckCurrentQuestion()
4176 startLLQHandshake(m, q); in uDNS_CheckCurrentQuestion()
4178 sendChallengeResponse(m, q, mDNSNULL); in uDNS_CheckCurrentQuestion()
4180 case LLQ_Established: sendLLQRefresh(m, q); break; in uDNS_CheckCurrentQuestion()
4186 if (!(q->LongLived && q->state != LLQ_Poll)) in uDNS_CheckCurrentQuestion()
4188 if (q->unansweredQueries >= MAX_UCAST_UNANSWERED_QUERIES) in uDNS_CheckCurrentQuestion()
4190 DNSServer *orig = q->qDNSServer; in uDNS_CheckCurrentQuestion()
4193q->unansweredQueries, q->qname.c, DNSTypeName(q->qtype), &orig->addr, mDNSVal16(orig->port), orig-… in uDNS_CheckCurrentQuestion()
4195 PenalizeDNSServer(m, q); in uDNS_CheckCurrentQuestion()
4196 q->noServerResponse = 1; in uDNS_CheckCurrentQuestion()
4211 if (!q->qDNSServer && q->noServerResponse) in uDNS_CheckCurrentQuestion()
4215 q->triedAllServersOnce = 1; in uDNS_CheckCurrentQuestion()
4218 SetValidDNSServers(m, q); in uDNS_CheckCurrentQuestion()
4219 new = GetServerForQuestion(m, q); in uDNS_CheckCurrentQuestion()
4223q, q->qname.c, DNSTypeName(q->qtype), new ? &new->addr : mDNSNULL, mDNSVal16(new ? new->port : zer… in uDNS_CheckCurrentQuestion()
4224 DNSServerChangeForQuestion(m, q, new); in uDNS_CheckCurrentQuestion()
4226 for (qptr = q->next ; qptr; qptr = qptr->next) in uDNS_CheckCurrentQuestion()
4227 …if (qptr->DuplicateOf == q) { qptr->validDNSServers = q->validDNSServers; qptr->qDNSServer = q->qD… in uDNS_CheckCurrentQuestion()
4229 if (q->qDNSServer && q->qDNSServer->teststate != DNSServer_Disabled) in uDNS_CheckCurrentQuestion()
4235 InitializeDNSMessage(&m->omsg.h, q->TargetQID, uQueryFlags); in uDNS_CheckCurrentQuestion()
4237 if (q->qDNSServer->teststate != DNSServer_Untested || NoTestQuery(q)) in uDNS_CheckCurrentQuestion()
4239 …(&m->omsg, m->omsg.data, m->omsg.data + AbsoluteMaxDNSMessageData, &q->qname, q->qtype, q->qclass); in uDNS_CheckCurrentQuestion()
4240 private = PrivateQuery(q); in uDNS_CheckCurrentQuestion()
4242 …else if (m->timenow - q->qDNSServer->lasttest >= INIT_UCAST_POLL_INTERVAL) // Make sure at least t… in uDNS_CheckCurrentQuestion()
4244 … LogInfo("Sending DNS test query to %#a:%d", &q->qDNSServer->addr, mDNSVal16(q->qDNSServer->port)); in uDNS_CheckCurrentQuestion()
4245 q->ThisQInterval = INIT_UCAST_POLL_INTERVAL / QuestionIntervalStep; in uDNS_CheckCurrentQuestion()
4246 q->qDNSServer->lasttest = m->timenow; in uDNS_CheckCurrentQuestion()
4248 q->qDNSServer->testid = m->omsg.h.id; in uDNS_CheckCurrentQuestion()
4251 if (end > m->omsg.data && (q->qDNSServer->teststate != DNSServer_Failed || NoTestQuery(q))) in uDNS_CheckCurrentQuestion()
4256 if (q->nta) CancelGetZoneData(m, q->nta); in uDNS_CheckCurrentQuestion()
4257q->nta = StartGetZoneData(m, &q->qname, q->LongLived ? ZoneServiceLLQ : ZoneServiceQuery, PrivateQ… in uDNS_CheckCurrentQuestion()
4258 …if (q->state == LLQ_Poll) q->ThisQInterval = (LLQ_POLL_INTERVAL + mDNSRandom(LLQ_POLL_INTERVAL/10)… in uDNS_CheckCurrentQuestion()
4263 q, q->qname.c, DNSTypeName(q->qtype), in uDNS_CheckCurrentQuestion()
4264q->qDNSServer ? &q->qDNSServer->addr : mDNSNULL, mDNSVal16(q->qDNSServer ? q->qDNSServer->port : z… in uDNS_CheckCurrentQuestion()
4265 if (!q->LocalSocket) q->LocalSocket = mDNSPlatformUDPSocket(m, zeroIPPort); in uDNS_CheckCurrentQuestion()
4266 …if (!q->LocalSocket) err = mStatus_NoMemoryErr; // If failed to make socket (should be very rare),… in uDNS_CheckCurrentQuestion()
4267 … err = mDNSSendDNSMessage(m, &m->omsg, end, q->qDNSServer->interface, q->LocalSocket, &q->qDNSServ… in uDNS_CheckCurrentQuestion()
4274q->ThisQInterval = q->ThisQInterval * QuestionIntervalStep; // Only increase interval if send succ… in uDNS_CheckCurrentQuestion()
4275 q->unansweredQueries++; in uDNS_CheckCurrentQuestion()
4276 if (q->ThisQInterval > MAX_UCAST_POLL_INTERVAL) in uDNS_CheckCurrentQuestion()
4277 q->ThisQInterval = MAX_UCAST_POLL_INTERVAL; in uDNS_CheckCurrentQuestion()
4278 if (private && q->state != LLQ_Poll) in uDNS_CheckCurrentQuestion()
4282 if (q->ThisQInterval < (3 * mDNSPlatformOneSecond)) in uDNS_CheckCurrentQuestion()
4283 q->ThisQInterval = q->ThisQInterval * QuestionIntervalStep; in uDNS_CheckCurrentQuestion()
4284 if (q->ThisQInterval > LLQ_POLL_INTERVAL) in uDNS_CheckCurrentQuestion()
4285 q->ThisQInterval = LLQ_POLL_INTERVAL; in uDNS_CheckCurrentQuestion()
4286 …polling question for %##s (%s) will be retried in %d ms", q->qname.c, DNSTypeName(q->qtype), q->Th… in uDNS_CheckCurrentQuestion()
4288 …debugf("Increased ThisQInterval to %d for %##s (%s)", q->ThisQInterval, q->qname.c, DNSTypeName(q-… in uDNS_CheckCurrentQuestion()
4290 q->LastQTime = m->timenow; in uDNS_CheckCurrentQuestion()
4291 SetNextQueryTime(m, q); in uDNS_CheckCurrentQuestion()
4305 const mDNSu32 slot = HashSlot(&q->qname); in uDNS_CheckCurrentQuestion()
4306 CacheGroup *const cg = CacheGroupForName(m, slot, q->qnamehash, &q->qname); in uDNS_CheckCurrentQuestion()
4309 if (SameNameRecordAnswersQuestion(&rr->resrec, q)) mDNS_PurgeCacheResourceRecord(m, rr); in uDNS_CheckCurrentQuestion()
4311 if (!q->qDNSServer) in uDNS_CheckCurrentQuestion()
4313 if (!mDNSOpaque64IsZero(&q->validDNSServers)) in uDNS_CheckCurrentQuestion()
4315 q->validDNSServers.l[1], q->validDNSServers.l[0], q->qname.c, DNSTypeName(q->qtype)); in uDNS_CheckCurrentQuestion()
4320 SetValidDNSServers(m, q); in uDNS_CheckCurrentQuestion()
4321 if (mDNSOpaque64IsZero(&q->validDNSServers)) in uDNS_CheckCurrentQuestion()
4323 …LogInfo("uDNS_CheckCurrentQuestion: no DNS server for %##s (%s)", q->qname.c, DNSTypeName(q->qtype… in uDNS_CheckCurrentQuestion()
4324 q->ThisQInterval = 0; in uDNS_CheckCurrentQuestion()
4332 q->ThisQInterval = q->ThisQInterval * QuestionIntervalStep; in uDNS_CheckCurrentQuestion()
4333 q->LastQTime = m->timenow; in uDNS_CheckCurrentQuestion()
4334 SetNextQueryTime(m, q); in uDNS_CheckCurrentQuestion()
4337 q->qDNSServer = GetServerForQuestion(m, q); in uDNS_CheckCurrentQuestion()
4338 for (qptr = q->next ; qptr; qptr = qptr->next) in uDNS_CheckCurrentQuestion()
4339 …if (qptr->DuplicateOf == q) { qptr->validDNSServers = q->validDNSServers; qptr->qDNSServer = q->qD… in uDNS_CheckCurrentQuestion()
4341 q, q->SuppressUnusable, q->qname.c, DNSTypeName(q->qtype), in uDNS_CheckCurrentQuestion()
4342q->qDNSServer ? &q->qDNSServer->addr : mDNSNULL, mDNSVal16(q->qDNSServer ? q->qDNSServer->port : z… in uDNS_CheckCurrentQuestion()
4347 q->ThisQInterval = 0; in uDNS_CheckCurrentQuestion()
4348 …estion DNS server %#a:%d for %##s is disabled", &q->qDNSServer->addr, mDNSVal16(q->qDNSServer->por… in uDNS_CheckCurrentQuestion()
4354 …eRecord(m, &m->rec.r, &q->qname, q->qnamehash, q->qtype, q->qclass, (WABQuestion(&q->qname) ? 60 *… in uDNS_CheckCurrentQuestion()
4355 q->unansweredQueries = 0; in uDNS_CheckCurrentQuestion()
4595 DNSQuestion *const q = m->CurrentQuestion; in uDNS_Tasks() local
4596 if (ActiveQuestion(q) && !mDNSOpaque16IsZero(q->TargetQID)) in uDNS_Tasks()
4599 if (q == m->CurrentQuestion) in uDNS_Tasks()
4600 if (m->NextuDNSEvent - NextQSendTime(q) > 0) in uDNS_Tasks()
4601 m->NextuDNSEvent = NextQSendTime(q); in uDNS_Tasks()
4606 if (m->CurrentQuestion == q) in uDNS_Tasks()
4607 m->CurrentQuestion = q->next; in uDNS_Tasks()