<rdar://problem/6434656> Sleep Proxy: Put owner OPT records in multicast announcement...
authorcheshire@apple.com <cheshire@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Wed, 2 Sep 2009 20:38:03 +0000 (20:38 +0000)
committercheshire@apple.com <cheshire@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Wed, 2 Sep 2009 20:38:03 +0000 (20:38 +0000)
Additional refinement: Loop that adds questions to the packet needs to take into account
the amount of space that will be needed to add the Owner Option at the end

git-svn-id: http://svn.macosforge.org/repository/mDNSResponder/trunk@6643 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

mDNSCore/mDNS.c

index 22c1b4a..5355971 100755 (executable)
@@ -2168,7 +2168,7 @@ mDNSlocal void SendQueries(mDNS *const m)
                        {
                        // Start a new known-answer list
                        CacheRecord **kalistptr = &KnownAnswerList;
-                       mDNSu32 answerforecast = 0;
+                       mDNSu32 answerforecast = OwnerRecordSpace;              // We start by assuming we'll need at least enough space to put the Owner Option
                        
                        // Put query questions in this packet
                        for (q = m->Questions; q && q != m->NewQuestions; q=q->next)
@@ -2192,7 +2192,7 @@ mDNSlocal void SendQueries(mDNS *const m)
                                        {
                                        mDNSBool ucast = (rr->ProbeCount >= DefaultProbeCountForTypeUnique-1) && m->CanReceiveUnicastOn5353;
                                        mDNSu16 ucbit = (mDNSu16)(ucast ? kDNSQClass_UnicastResponse : 0);
-                                       const mDNSu8 *const limit = m->omsg.data + ((m->omsg.h.numQuestions) ? NormalMaxDNSMessageData : AbsoluteMaxDNSMessageData) - OwnerRecordSpace;
+                                       const mDNSu8 *const limit = m->omsg.data + (m->omsg.h.numQuestions ? NormalMaxDNSMessageData : AbsoluteMaxDNSMessageData);
                                        mDNSu8 *newptr = putQuestion(&m->omsg, queryptr, limit, rr->resrec.name, kDNSQType_ANY, (mDNSu16)(rr->resrec.rrclass | ucbit));
                                        // We forecast: compressed name (2) type (2) class (2) TTL (4) rdlength (2) rdata (n)
                                        mDNSu32 forecast = answerforecast + 12 + rr->resrec.rdestimate;