Lines Matching refs:rr

139 	const CacheRecord *rr;
140 FORALL_CACHERECORDS(slot, cg, rr)
141 if (rr->resrec.InterfaceID == id) used++;
174 mDNSexport char *GetRRDisplayString_rdb(const ResourceRecord *const rr, const RDataBody *const rd1, char *const buffer)
179 mDNSu32 length = mDNS_snprintf(buffer, MaxMsg-1, "%4d %##s %s ", rr->rdlength, rr->name->c, DNSTypeName(rr->rrtype));
180 if (rr->RecordType == kDNSRecordTypePacketNegative) return(buffer);
181 if (!rr->rdlength) { mDNS_snprintf(buffer+length, RemSpc, "<< ZERO RDATA LENGTH >>"); return(buffer); }
183 switch (rr->rrtype)
199 while (t < rd->txt.c + rr->rdlength)
212 const rdataOPT *const end = (const rdataOPT *)&rd->data[rr->rdlength];
213 length += mDNS_snprintf(buffer+length, RemSpc, "Max %d", rr->rrclass);
255 default: mDNS_snprintf(buffer+length, RemSpc, "RDLen %d: %s", rr->rdlength, rd->data);
991 mDNSexport void mDNS_SetupResourceRecord(AuthRecord *rr, RData *RDataStorage, mDNSInterfaceID InterfaceID,
1024 rr->resrec.RecordType = RecordType;
1025 rr->resrec.InterfaceID = InterfaceID;
1026 rr->resrec.name = &rr->namestorage;
1027 rr->resrec.rrtype = rrtype;
1028 rr->resrec.rrclass = kDNSClass_IN;
1029 rr->resrec.rroriginalttl = ttl;
1030 rr->resrec.rDNSServer = mDNSNULL;
1031 // rr->resrec.rdlength = MUST set by client and/or in mDNS_Register_internal
1032 // rr->resrec.rdestimate = set in mDNS_Register_internal
1033 // rr->resrec.rdata = MUST be set by client
1036 rr->resrec.rdata = RDataStorage;
1039 rr->resrec.rdata = &rr->rdatastorage;
1040 rr->resrec.rdata->MaxRDLength = sizeof(RDataBody);
1044 rr->Additional1 = mDNSNULL;
1045 rr->Additional2 = mDNSNULL;
1046 rr->DependentOn = mDNSNULL;
1047 rr->RRSet = mDNSNULL;
1048 rr->RecordCallback = Callback;
1049 rr->RecordContext = Context;
1051 rr->AutoTarget = Target_Manual;
1052 rr->AllowRemoteQuery = mDNSfalse;
1053 rr->ForceMCast = mDNSfalse;
1055 rr->WakeUp = zeroOwner;
1056 rr->AddressProxy = zeroAddr;
1057 rr->TimeRcvd = 0;
1058 rr->TimeExpire = 0;
1059 rr->ARType = artype;
1066 // of fields don't get set up properly. In particular, if we don't zero rr->QueuedRData then the uDNS code crashes.)
1067 rr->state = regState_Zero;
1068 rr->uselease = 0;
1069 rr->expire = 0;
1070 rr->Private = 0;
1071 rr->updateid = zeroID;
1072 rr->zone = rr->resrec.name;
1073 rr->nta = mDNSNULL;
1074 rr->tcp = mDNSNULL;
1075 rr->OrigRData = 0;
1076 rr->OrigRDLen = 0;
1077 rr->InFlightRData = 0;
1078 rr->InFlightRDLen = 0;
1079 rr->QueuedRData = 0;
1080 rr->QueuedRDLen = 0;
1081 mDNSPlatformMemZero(&rr->NATinfo, sizeof(rr->NATinfo));
1082 rr->SRVChanged = mDNSfalse;
1083 rr->mState = mergeState_Zero;
1085 rr->namestorage.c[0] = 0; // MUST be set by client before calling mDNS_Register()
1111 mDNSexport mDNSu32 RDataHashValue(const ResourceRecord *const rr)
1113 int len = rr->rdlength;
1114 const RDataBody2 *const rdb = (RDataBody2 *)rr->rdata->u.data;
1115 switch(rr->rrtype)
1217 mDNSexport mDNSBool SameNameRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q)
1221 if ((rr->InterfaceID == mDNSInterface_LocalOnly) || (rr->InterfaceID == mDNSInterface_P2P))
1223 LogMsg("SameNameRecordAnswersQuestion: ERROR!! called with LocalOnly ResourceRecord %p, Question %p", rr->InterfaceID, q->InterfaceID);
1226 if (rr->InterfaceID &&
1228 rr->InterfaceID != q->InterfaceID) return(mDNSfalse);
1231 if (!rr->InterfaceID && rr->rDNSServer != q->qDNSServer) return(mDNSfalse);
1234 if (rr->InterfaceID && !mDNSOpaque16IsZero(q->TargetQID)) return(mDNSfalse);
1237 if (!RRTypeAnswersQuestionType(rr,q->qtype)) return(mDNSfalse);
1238 if (rr->rrclass != q->qclass && q->qclass != kDNSQClass_ANY) return(mDNSfalse);
1243 mDNSexport mDNSBool ResourceRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q)
1247 if ((rr->InterfaceID == mDNSInterface_LocalOnly) || (rr->InterfaceID == mDNSInterface_P2P))
1249 LogMsg("ResourceRecordAnswersQuestion: ERROR!! called with LocalOnly/P2P ResourceRecord %p, Question %p", rr->InterfaceID, q->InterfaceID);
1253 if (rr->InterfaceID &&
1255 rr->InterfaceID != q->InterfaceID) return(mDNSfalse);
1258 if (!rr->InterfaceID && rr->rDNSServer != q->qDNSServer) return(mDNSfalse);
1261 if (rr->InterfaceID && !mDNSOpaque16IsZero(q->TargetQID)) return(mDNSfalse);
1264 if (!RRTypeAnswersQuestionType(rr,q->qtype)) return(mDNSfalse);
1265 if (rr->rrclass != q->qclass && q->qclass != kDNSQClass_ANY) return(mDNSfalse);
1267 return(rr->namehash == q->qnamehash && SameDomainName(rr->name, &q->qname));
1281 ResourceRecord *rr = &ar->resrec;
1287 LogMsg("LocalOnlyRecordAnswersQuestion: ERROR!! called with regular AuthRecordAny %##s", rr->name->c);
1298 if (rr->InterfaceID &&
1300 rr->InterfaceID != q->InterfaceID) return(mDNSfalse);
1337 if (ar->ARType != AuthRecordLocalOnly && rr->InterfaceID && !mDNSOpaque16IsZero(q->TargetQID)) return(mDNSfalse);
1340 if (!RRTypeAnswersQuestionType(rr,q->qtype)) return(mDNSfalse);
1341 if (rr->rrclass != q->qclass && q->qclass != kDNSQClass_ANY) return(mDNSfalse);
1343 return(rr->namehash == q->qnamehash && SameDomainName(rr->name, &q->qname));
1346 mDNSexport mDNSBool AnyTypeRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q)
1350 if ((rr->InterfaceID == mDNSInterface_LocalOnly) || (rr->InterfaceID == mDNSInterface_P2P))
1352 LogMsg("AnyTypeRecordAnswersQuestion: ERROR!! called with LocalOnly ResourceRecord %p, Question %p", rr->InterfaceID, q->InterfaceID);
1355 if (rr->InterfaceID &&
1357 rr->InterfaceID != q->InterfaceID) return(mDNSfalse);
1362 if (!rr->InterfaceID && rr->rDNSServer != q->qDNSServer) return(mDNSfalse);
1365 if (rr->InterfaceID && !mDNSOpaque16IsZero(q->TargetQID)) return(mDNSfalse);
1367 if (rr->rrclass != q->qclass && q->qclass != kDNSQClass_ANY) return(mDNSfalse);
1369 return(rr->namehash == q->qnamehash && SameDomainName(rr->name, &q->qname));
1377 mDNSexport mDNSBool ResourceRecordAnswersUnicastResponse(const ResourceRecord *const rr, const DNSQuestion *const q)
1380 if (rr->InterfaceID &&
1381 q->InterfaceID && rr->InterfaceID != q->InterfaceID) return(mDNSfalse);
1384 if (rr->InterfaceID && !mDNSOpaque16IsZero(q->TargetQID)) return(mDNSfalse);
1387 if (!RRTypeAnswersQuestionType(rr,q->qtype)) return(mDNSfalse);
1389 if (rr->rrclass != q->qclass && q->qclass != kDNSQClass_ANY) return(mDNSfalse);
1391 return(rr->namehash == q->qnamehash && SameDomainName(rr->name, &q->qname));
1394 mDNSexport mDNSu16 GetRDLength(const ResourceRecord *const rr, mDNSBool estimate)
1396 const RDataBody2 *const rd = (RDataBody2 *)rr->rdata->u.data;
1397 const domainname *const name = estimate ? rr->name : mDNSNULL;
1398 if (rr->rrclass == kDNSQClass_ANY) return(rr->rdlength); // Used in update packets to mean "Delete An RRset" (RFC 2136)
1399 else switch (rr->rrtype)
1418 case kDNSType_DHCID:return(rr->rdlength); // Not self-describing, so have to just trust rdlength
1437 case kDNSType_OPT: return(rr->rdlength);
1448 return(mDNSu16)((estimate ? 2 : DomainNameLength(rr->name)) + (i ? (2 + i) : 0));
1451 default: debugf("Warning! Don't know how to get length of resource type %d", rr->rrtype);
1452 return(rr->rdlength);
1647 mDNSexport mDNSu8 *putRData(const DNSMessage *const msg, mDNSu8 *ptr, const mDNSu8 *const limit, const ResourceRecord *const rr)
1649 const RDataBody2 *const rdb = (RDataBody2 *)rr->rdata->u.data;
1650 switch (rr->rrtype)
1652 case kDNSType_A: if (rr->rdlength != 4)
1653 { debugf("putRData: Illegal length %d for kDNSType_A", rr->rdlength); return(mDNSNULL); }
1684 case kDNSType_DHCID:if (ptr + rr->rdlength > limit) return(mDNSNULL);
1685 mDNSPlatformMemCopy(ptr, rdb->data, rr->rdlength);
1686 return(ptr + rr->rdlength);
1707 case kDNSType_AAAA: if (rr->rdlength != sizeof(rdb->ipv6))
1708 { debugf("putRData: Illegal length %d for kDNSType_AAAA", rr->rdlength); return(mDNSNULL); }
1725 const rdataOPT *const end = (const rdataOPT *)&rr->rdata->u.data[rr->rdlength];
1726 for (opt = &rr->rdata->u.opt[0]; opt < end; opt++) len += DNSOpt_Data_Space(opt);
1729 for (opt = &rr->rdata->u.opt[0]; opt < end; opt++)
1776 ptr = putDomainNameAsLabels(msg, ptr, limit, rr->name);
1788 default: debugf("putRData: Warning! Writing unknown resource type %d as raw data", rr->rrtype);
1789 if (ptr + rr->rdlength > limit) return(mDNSNULL);
1790 mDNSPlatformMemCopy(ptr, rdb->data, rr->rdlength);
1791 return(ptr + rr->rdlength);
1797 mDNSexport mDNSu8 *PutResourceRecordTTLWithLimit(DNSMessage *const msg, mDNSu8 *ptr, mDNSu16 *count, ResourceRecord *rr, mDNSu32 ttl, const mDNSu8 *limit)
1802 const DNSMessage *const rdatacompressionbase = (IsUnicastUpdate(msg) && rr->rrtype == kDNSType_SRV) ? mDNSNULL : msg;
1804 if (rr->RecordType == kDNSRecordTypeUnregistered)
1806 LogMsg("PutResourceRecord ERROR! Attempt to put kDNSRecordTypeUnregistered %##s (%s)", rr->name->c, DNSTypeName(rr->rrtype));
1812 ptr = putDomainNameAsLabels(msg, ptr, limit, rr->name);
1814 ptr[0] = (mDNSu8)(rr->rrtype >> 8);
1815 ptr[1] = (mDNSu8)(rr->rrtype & 0xFF);
1816 ptr[2] = (mDNSu8)(rr->rrclass >> 8);
1817 ptr[3] = (mDNSu8)(rr->rrclass & 0xFF);
1824 endofrdata = putRData(rdatacompressionbase, ptr+10, limit, rr);
1825 if (!endofrdata) { verbosedebugf("Ran out of space in PutResourceRecord for %##s (%s)", rr->name->c, DNSTypeName(rr->rrtype)); return(mDNSNULL); }
1834 else LogMsg("PutResourceRecordTTL: ERROR: No target count to update for %##s (%s)", rr->name->c, DNSTypeName(rr->rrtype));
1838 mDNSlocal mDNSu8 *putEmptyResourceRecord(DNSMessage *const msg, mDNSu8 *ptr, const mDNSu8 *const limit, mDNSu16 *count, const AuthRecord *rr)
1840 ptr = putDomainNameAsLabels(msg, ptr, limit, rr->resrec.name);
1842 ptr[0] = (mDNSu8)(rr->resrec.rrtype >> 8); // Put type
1843 ptr[1] = (mDNSu8)(rr->resrec.rrtype & 0xFF);
1844 ptr[2] = (mDNSu8)(rr->resrec.rrclass >> 8); // Put class
1845 ptr[3] = (mDNSu8)(rr->resrec.rrclass & 0xFF);
1889 mDNSexport mDNSu8 *putDeletionRecord(DNSMessage *msg, mDNSu8 *ptr, ResourceRecord *rr)
1892 const mDNSu16 origclass = rr->rrclass;
1893 rr->rrclass = kDNSClass_NONE;
1894 ptr = PutResourceRecordTTLJumbo(msg, ptr, &msg->h.mDNS_numUpdates, rr, 0);
1895 rr->rrclass = origclass;
1900 mDNSexport mDNSu8 *putDeletionRecordWithLimit(DNSMessage *msg, mDNSu8 *ptr, ResourceRecord *rr, mDNSu8 *limit)
1903 const mDNSu16 origclass = rr->rrclass;
1904 rr->rrclass = kDNSClass_NONE;
1905 ptr = PutResourceRecordTTLWithLimit(msg, ptr, &msg->h.mDNS_numUpdates, rr, 0, limit);
1906 rr->rrclass = origclass;
1950 AuthRecord rr;
1951 mDNS_SetupResourceRecord(&rr, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, AuthRecordAny, mDNSNULL, mDNSNULL);
1952 rr.resrec.rrclass = NormalMaxDNSMessageData;
1953 rr.resrec.rdlength = sizeof(rdataOPT); // One option in this OPT record
1954 rr.resrec.rdestimate = sizeof(rdataOPT);
1955 rr.resrec.rdata->u.opt[0].opt = kDNSOpt_Lease;
1956 rr.resrec.rdata->u.opt[0].u.updatelease = lease;
1957 end = PutResourceRecordTTLJumbo(msg, end, &msg->h.numAdditionals, &rr.resrec, 0);
1965 AuthRecord rr;
1966 mDNS_SetupResourceRecord(&rr, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, AuthRecordAny, mDNSNULL, mDNSNULL);
1967 rr.resrec.rrclass = NormalMaxDNSMessageData;
1968 rr.resrec.rdlength = sizeof(rdataOPT); // One option in this OPT record
1969 rr.resrec.rdestimate = sizeof(rdataOPT);
1970 rr.resrec.rdata->u.opt[0].opt = kDNSOpt_Lease;
1971 rr.resrec.rdata->u.opt[0].u.updatelease = lease;
1972 end = PutResourceRecordTTLWithLimit(msg, end, &msg->h.numAdditionals, &rr.resrec, 0, limit);
2022 mDNSexport void SetNewRData(ResourceRecord *const rr, RData *NewRData, mDNSu16 rdlength)
2027 rr->rdata = NewRData;
2028 rr->rdlength = rdlength;
2030 // Must not try to get target pointer until after updating rr->rdata
2031 target = GetRRDomainNameTarget(rr);
2032 rr->rdlength = GetRDLength(rr, mDNSfalse);
2033 rr->rdestimate = GetRDLength(rr, mDNStrue);
2034 rr->rdatahash = target ? DomainNameHashValue(target) : RDataHashValue(rr);
2134 CacheRecord *const rr = &largecr->r;
2135 RDataBody2 *const rdb = (RDataBody2 *)rr->smallrdatastorage.data;
2146 rr->next = mDNSNULL;
2147 rr->resrec.name = &largecr->namestorage;
2149 rr->NextInKAList = mDNSNULL;
2150 rr->TimeRcvd = m ? m->timenow : 0;
2151 rr->DelayDelivery = 0;
2152 rr->NextRequiredQuery = m ? m->timenow : 0; // Will be updated to the real value when we call SetNextCacheCheckTimeForRecord()
2153 rr->LastUsed = m ? m->timenow : 0;
2154 rr->CRActiveQuestion = mDNSNULL;
2155 rr->UnansweredQueries = 0;
2156 rr->LastUnansweredTime= 0;
2158 rr->MPUnansweredQ = 0;
2159 rr->MPLastUnansweredQT= 0;
2160 rr->MPUnansweredKA = 0;
2161 rr->MPExpectingKA = mDNSfalse;
2163 rr->NextInCFList = mDNSNULL;
2165 rr->resrec.InterfaceID = InterfaceID;
2166 rr->resrec.rDNSServer = mDNSNULL;
2170 rr->resrec.namehash = DomainNameHashValue(rr->resrec.name);
2174 rr->resrec.rrtype = (mDNSu16) ((mDNSu16)ptr[0] << 8 | ptr[1]);
2175 rr->resrec.rrclass = (mDNSu16)(((mDNSu16)ptr[2] << 8 | ptr[3]) & kDNSClass_Mask);
2176 rr->resrec.rroriginalttl = (mDNSu32) ((mDNSu32)ptr[4] << 24 | (mDNSu32)ptr[5] << 16 | (mDNSu32)ptr[6] << 8 | ptr[7]);
2177 if (rr->resrec.rroriginalttl > 0x70000000UL / mDNSPlatformOneSecond && (mDNSs32)rr->resrec.rroriginalttl != -1)
2178 rr->resrec.rroriginalttl = 0x70000000UL / mDNSPlatformOneSecond;
2192 rr->resrec.rdata = (RData*)&rr->smallrdatastorage;
2193 rr->resrec.rdata->MaxRDLength = MaximumRDSize;
2195 if (!RecordType) LogMsg("GetLargeResourceRecord: No RecordType for %##s", rr->resrec.name->c);
2202 if (rr->resrec.rrclass == kDNSQClass_ANY && pktrdlength == 0) // Used in update packets to mean "Delete An RRset" (RFC 2136)
2203 rr->resrec.rdlength = 0;
2204 else switch (rr->resrec.rrtype)
2218 //debugf("%##s PTR %##s rdlen %d", rr->resrec.name.c, rdb->name.c, pktrdlength);
2240 case kDNSType_DHCID:if (pktrdlength > rr->resrec.rdata->MaxRDLength)
2243 DNSTypeName(rr->resrec.rrtype), pktrdlength, rr->resrec.rdata->MaxRDLength);
2246 rr->resrec.rdlength = pktrdlength;
2257 //debugf("%##s SRV %##s rdlen %d", rr->resrec.name.c, rdb->srv.target.c, pktrdlength);
2285 //debugf("%##s SRV %##s rdlen %d", rr->resrec.name.c, rdb->srv.target.c, pktrdlength);
2289 rdataOPT *opt = rr->resrec.rdata->u.opt;
2290 rr->resrec.rdlength = 0;
2291 while (ptr < end && (mDNSu8 *)(opt+1) < &rr->resrec.rdata->u.data[MaximumRDSize])
2345 rr->resrec.rdlength = (mDNSu16)((mDNSu8*)opt - rr->resrec.rdata->u.data);
2367 default: if (pktrdlength > rr->resrec.rdata->MaxRDLength)
2370 rr->resrec.rrtype, DNSTypeName(rr->resrec.rrtype), pktrdlength, rr->resrec.rdata->MaxRDLength);
2374 rr->resrec.rrtype, DNSTypeName(rr->resrec.rrtype));
2380 rr->resrec.rdlength = pktrdlength;
2385 SetNewRData(&rr->resrec, mDNSNULL, 0); // Sets rdlength, rdestimate, rdatahash for us
2388 rr->resrec.RecordType = RecordType;
2394 rr->resrec.RecordType = kDNSRecordTypePacketNegative;
2395 rr->resrec.rdlength = 0;
2396 rr->resrec.rdestimate = 0;
2397 rr->resrec.rdatahash = 0;
2711 AuthRecord *rr;
2712 for (rr = m->NewLocalRecords; rr; rr = rr->next)
2713 if (LocalRecordReady(rr)) return rr;
2760 AuthRecord *rr;
2777 rr = AnyLocalRecordReady(m);
2778 if (rr) LogMsg("Task Scheduling Error: NewLocalRecords %s", ARDisplayString(m, rr));