]> git.saurik.com Git - apple/mdnsresponder.git/commitdiff
mDNSResponder-58.6.tar.gz v58.6
authorApple <opensource@apple.com>
Tue, 2 Mar 2004 02:56:45 +0000 (02:56 +0000)
committerApple <opensource@apple.com>
Tue, 2 Mar 2004 02:56:45 +0000 (02:56 +0000)
Makefile
mDNSCore/mDNS.c
mDNSCore/mDNSClientAPI.h

index b733f4d2762d6859c6519df7cc7a2f2de17c023f..71d4559e91a7117caa8aeacd61f22e257053d7e2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
 
 include /Developer/Makefiles/pb_makefiles/platform.make
 
-MVERS = "mDNSResponder-58.5"
+MVERS = "mDNSResponder-58.6"
 
 install:
        cd "$(SRCROOT)/mDNSMacOSX"; pbxbuild install     OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) DSTROOT=$(DSTROOT) MVERS=$(MVERS)
index e25482f9bdf280dff4741cc5de9db155f9306fbe..2bee7da8f96730ec9d68a26b6269dc5bfef90ff8 100755 (executable)
     Change History (most recent first):
 
 $Log: mDNS.c,v $
+Revision 1.307.2.5  2004/03/02 02:55:24  cheshire
+<rdar://problem/3549576> Properly support "_services._dns-sd._udp" meta-queries
+
+Revision 1.307.2.4  2004/02/18 01:55:08  cheshire
+<rdar://problem/3553472>: Increase delay to 400ms when answering queries with multi-packet KA lists
+
 Revision 1.307.2.3  2004/01/28 23:08:45  cheshire
 <rdar://problem/3488559>: Hard code domain enumeration functions to return ".local" only
 
@@ -1099,10 +1105,10 @@ static const mDNSOpaque16 ResponseFlags = { { kDNSFlag0_QR_Response | kDNSFlag0_
 
 static const char *const mDNS_DomainTypeNames[] =
        {
-       "_browse._mdns._udp.local.",
-       "_default._browse._mdns._udp.local.",
-       "_register._mdns._udp.local.",
-       "_default._register._mdns._udp.local."
+       "_browse._dns-sd._udp.local.",
+       "_default._browse._dns-sd._udp.local.",
+       "_register._dns-sd._udp.local.",
+       "_default._register._dns-sd._udp.local."
        };
 
 #define AssignDomainName(DST, SRC) mDNSPlatformMemCopy((SRC).c, (DST).c, DomainNameLength(&(SRC)))
@@ -4950,7 +4956,7 @@ mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, con
        CacheRecord **eap             = &ExpectedAnswers;
        DNSQuestion     *DupQuestions    = mDNSNULL;                    // Our questions that are identical to questions in this packet
        DNSQuestion    **dqp             = &DupQuestions;
-       mDNSBool         delayresponse   = mDNSfalse;
+       mDNSs32          delayresponse   = 0;
        mDNSBool         HaveUnicastAnswer = mDNSfalse;
        const mDNSu8    *ptr             = query->data;
        mDNSu8          *responseptr     = mDNSNULL;
@@ -4958,7 +4964,7 @@ mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, con
        int i;
 
        // If TC flag is set, it means we should expect that additional known answers may be coming in another packet.
-       if (query->h.flags.b[0] & kDNSFlag0_TC) delayresponse = mDNStrue;
+       if (query->h.flags.b[0] & kDNSFlag0_TC) delayresponse = mDNSPlatformOneSecond;  // Divided by 50 = 20ms
 
        // ***
        // *** 1. Parse Question Section and mark potential answers
@@ -5028,7 +5034,7 @@ mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, con
                        CacheRecord *rr;
                        // If we couldn't answer this question, someone else might be able to,
                        // so use random delay on response to reduce collisions
-                       if (NumAnswersForThisQuestion == 0) delayresponse = mDNStrue;
+                       if (NumAnswersForThisQuestion == 0) delayresponse = mDNSPlatformOneSecond;      // Divided by 50 = 20ms
 
                        // Make a list indicating which of our own cache records we expect to see updated as a result of this query
                        // Note: Records larger than 1K are not habitually multicast, so don't expect those to be updated
@@ -5068,10 +5074,7 @@ mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, con
        // ***
        for (rr = m->ResourceRecords; rr; rr=rr->next)                          // Now build our list of potential answers
                if (rr->NR_AnswerTo)                                                                    // If we marked the record...
-                       {
                        AddRecordToResponseList(&nrp, rr, mDNSNULL);            // ... add it to the list
-                       if (rr->resrec.RecordType == kDNSRecordTypeShared) delayresponse = mDNStrue;
-                       }
 
        // ***
        // *** 3. Add additional records
@@ -5214,6 +5217,11 @@ mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, con
                                                }
                                        }
                                }
+                       if (rr->resrec.RecordType == kDNSRecordTypeShared)
+                               {
+                               if (query->h.flags.b[0] & kDNSFlag0_TC) delayresponse = mDNSPlatformOneSecond * 20;     // Divided by 50 = 400ms
+                               else                                    delayresponse = mDNSPlatformOneSecond;          // Divided by 50 = 20ms
+                       }
                        }
                else if (rr->NR_AdditionalTo && rr->NR_AdditionalTo->NR_AnswerTo == (mDNSu8*)~0)
                        {
@@ -5229,10 +5237,22 @@ mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, con
        // ***
        // *** 7. If we think other machines are likely to answer these questions, set our packet suppression timer
        // ***
-       if (delayresponse && !m->SuppressSending)
-               {
-               // Pick a random delay between 20ms and 120ms.
-               m->SuppressSending = m->timenow + (mDNSPlatformOneSecond*2 + (mDNSs32)mDNSRandom((mDNSu32)mDNSPlatformOneSecond*10)) / 100;
+       if (delayresponse && (!m->SuppressSending || (m->SuppressSending - m->timenow) < (delayresponse + 49) / 50))
+               {
+               // Pick a random delay:
+               // We start with the base delay chosen above (typically either 1 second or 20 seconds),
+               // and add a random value in the range 0-5 seconds (making 1-6 seconds or 20-25 seconds).
+               // This is an integer value, with resolution determined by the platform clock rate.
+               // We then divide that by 50 to get the delay value in ticks. We defer the division until last
+               // to get better results on platforms with coarse clock granularity (e.g. ten ticks per second).
+               // The +49 before dividing is to ensure we round up, not down, to ensure that even
+               // on platforms where the native clock rate is less than fifty ticks per second,
+               // we still guarantee that the final calculated delay is at least one platform tick.
+               // We want to make sure we don't ever allow the delay to be zero ticks,
+               // because if that happens we'll fail the Rendezvous Conformance Test.
+               // Our final computed delay is 20-120ms for normal delayed replies,
+               // or 400-500ms in the case of multi-packet known-answer lists.
+               m->SuppressSending = m->timenow + (delayresponse + (mDNSs32)mDNSRandom((mDNSu32)mDNSPlatformOneSecond*5) + 49) / 50;
                if (m->SuppressSending == 0) m->SuppressSending = 1;
                }
 
@@ -6639,7 +6659,7 @@ mDNSexport mStatus mDNS_RegisterService(mDNS *const m, ServiceRecordSet *sr,
        // Set up the record names
        // For now we only create an advisory record for the main type, not for subtypes
        // We need to gain some operational experience before we decide if there's a need to create them for subtypes too
-       if (ConstructServiceName(&sr->RR_ADV.resrec.name, (domainlabel*)"\x09_services", (domainname*)"\x05_mdns\x04_udp", domain) == mDNSNULL)
+       if (ConstructServiceName(&sr->RR_ADV.resrec.name, (domainlabel*)"\x09_services", (domainname*)"\x07_dns-sd\x04_udp", domain) == mDNSNULL)
                return(mStatus_BadParamErr);
        if (ConstructServiceName(&sr->RR_PTR.resrec.name, mDNSNULL, type, domain) == mDNSNULL) return(mStatus_BadParamErr);
        if (ConstructServiceName(&sr->RR_SRV.resrec.name, name,     type, domain) == mDNSNULL) return(mStatus_BadParamErr);
index f64ffacba83cb36c988cb95cc401c28f9b2b05b9..a968c7f6c84bc81876446f7892430d43735e68b3 100755 (executable)
@@ -23,6 +23,9 @@
     Change History (most recent first):
 
 $Log: mDNSClientAPI.h,v $
+Revision 1.114.2.6  2004/03/02 02:55:25  cheshire
+<rdar://problem/3549576> Properly support "_services._dns-sd._udp" meta-queries
+
 Revision 1.114.2.5  2004/02/18 23:35:17  cheshire
 <rdar://problem/3488559>: Hard code domain enumeration functions to return ".local" only
 Also make mDNS_StopGetDomains() a no-op too, so that we don't get warning messages in syslog
@@ -901,7 +904,7 @@ struct ServiceRecordSet_struct
        AuthRecord          *SubTypes;
        mDNSBool             Conflict;  // Set if this record set was forcibly deregistered because of a conflict
        domainname           Host;              // Set if this service record does not use the standard target host name
-       AuthRecord           RR_ADV;    // e.g. _services._mdns._udp.local. PTR _printer._tcp.local.
+       AuthRecord           RR_ADV;    // e.g. _services._dns-sd._udp.local. PTR _printer._tcp.local.
        AuthRecord           RR_PTR;    // e.g. _printer._tcp.local.        PTR Name._printer._tcp.local.
        AuthRecord           RR_SRV;    // e.g. Name._printer._tcp.local.   SRV 0 0 port target
        AuthRecord           RR_TXT;    // e.g. Name._printer._tcp.local.   TXT PrintQueueName