Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/apache2/mDNSResponder/dist Import mDNSResponder-258...



details:   https://anonhg.NetBSD.org/src/rev/bbd918321302
branches:  trunk
changeset: 328024:bbd918321302
user:      pettai <pettai%NetBSD.org@localhost>
date:      Mon Mar 24 00:23:27 2014 +0000

description:
Import mDNSResponder-258-14 as per discussion with gdt@ and cristos@

diffstat:

 external/apache2/mDNSResponder/dist/Clients/ClientCommon.c      |    13 +-
 external/apache2/mDNSResponder/dist/Clients/ClientCommon.h      |    10 +-
 external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h        |   191 +-
 external/apache2/mDNSResponder/dist/mDNSCore/mDNSDebug.h        |   177 +-
 external/apache2/mDNSResponder/dist/mDNSCore/uDNS.c             |  4538 ++++-----
 external/apache2/mDNSResponder/dist/mDNSCore/uDNS.h             |   234 +-
 external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.h       |    65 +-
 external/apache2/mDNSResponder/dist/mDNSPosix/mDNSUNP.h         |    68 +-
 external/apache2/mDNSResponder/dist/mDNSShared/CommonServices.h |    60 +-
 external/apache2/mDNSResponder/dist/mDNSShared/GenLinkedList.c  |    15 +-
 external/apache2/mDNSResponder/dist/mDNSShared/GenLinkedList.h  |    19 +-
 external/apache2/mDNSResponder/dist/mDNSShared/PlatformCommon.c |    73 -
 external/apache2/mDNSResponder/dist/mDNSShared/PlatformCommon.h |    29 -
 external/apache2/mDNSResponder/dist/mDNSShared/dnssd_ipc.c      |    56 -
 external/apache2/mDNSResponder/dist/mDNSShared/mDNSDebug.c      |    59 +-
 external/apache2/mDNSResponder/dist/mDNSShared/mDNSResponder.8  |    33 -
 external/apache2/mDNSResponder/dist/mDNSShared/uds_daemon.h     |   112 +-
 17 files changed, 2182 insertions(+), 3570 deletions(-)

diffs (truncated from 7250 to 300 lines):

diff -r 8748eafb6669 -r bbd918321302 external/apache2/mDNSResponder/dist/Clients/ClientCommon.c
--- a/external/apache2/mDNSResponder/dist/Clients/ClientCommon.c        Mon Mar 24 00:13:23 2014 +0000
+++ b/external/apache2/mDNSResponder/dist/Clients/ClientCommon.c        Mon Mar 24 00:23:27 2014 +0000
@@ -36,18 +36,7 @@
  * OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  * (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-    Change History (most recent first):
-
-Log: ClientCommon.c,v $
-Revision 1.2  2008/05/08 00:42:03  cheshire
-Removed some unnecessary header files
-
-Revision 1.1  2008/05/08 00:25:48  cheshire
-<rdar://problem/5919272> GetNextLabel insufficiently defensive
-
-
-*/
+ */
 
 #include <ctype.h>
 #include <stdio.h>                     // For stdout, stderr
diff -r 8748eafb6669 -r bbd918321302 external/apache2/mDNSResponder/dist/Clients/ClientCommon.h
--- a/external/apache2/mDNSResponder/dist/Clients/ClientCommon.h        Mon Mar 24 00:13:23 2014 +0000
+++ b/external/apache2/mDNSResponder/dist/Clients/ClientCommon.h        Mon Mar 24 00:23:27 2014 +0000
@@ -36,14 +36,6 @@
  * OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  * (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-    Change History (most recent first):
-
-Log: ClientCommon.h,v $
-Revision 1.1  2008/05/08 00:25:48  cheshire
-<rdar://problem/5919272> GetNextLabel insufficiently defensive
-
-
-*/
+ */
 
 extern const char *GetNextLabel(const char *cstr, char label[64]);
diff -r 8748eafb6669 -r bbd918321302 external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h
--- a/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h  Mon Mar 24 00:13:23 2014 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h  Mon Mar 24 00:23:27 2014 +0000
@@ -13,146 +13,7 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-
-    Change History (most recent first):
-
-Log: DNSCommon.h,v $
-Revision 1.73  2009/04/24 00:28:05  cheshire
-<rdar://problem/3476350> Return negative answers when host knows authoritatively that no answer exists
-Added definitions for RRTypeAnswersQuestionType/RRAssertsNonexistence/AnyTypeRecordAnswersQuestion
-
-Revision 1.72  2009/04/01 21:12:56  herscher
-<rdar://problem/5925472> Current Bonjour code does not compile on Windows
-
-Revision 1.71  2009/04/01 17:50:10  mcguire
-cleanup mDNSRandom
-
-Revision 1.70  2009/03/04 00:40:12  cheshire
-Updated DNS server error codes to be more consistent with definitions at
-<http://www.iana.org/assignments/dns-parameters>
-
-Revision 1.69  2008/11/26 20:57:37  cheshire
-For consistency with other similar macros, renamed mdnsIsDigit/mdnsIsLetter/mdnsValidHostChar
-to mDNSIsDigit/mDNSIsLetter/mDNSValidHostChar
-
-Revision 1.68  2008/11/14 21:56:31  cheshire
-Moved debugging routine ShowTaskSchedulingError() from daemon.c into DNSCommon.c
-
-Revision 1.67  2008/11/13 19:05:09  cheshire
-Added definition of LocateOptRR()
-
-Revision 1.66  2008/10/22 19:56:54  cheshire
-Removed unused SameRData() macro -- it duplicates the functionality of IdenticalSameNameRecord()
-
-Revision 1.65  2008/10/20 15:39:20  cheshire
-Group "#define PutResourceRecord ..." with related definitions
-
-Revision 1.64  2008/10/08 01:03:33  cheshire
-Change GetFirstActiveInterface() so the NetworkInterfaceInfo it returns is not "const"
-
-Revision 1.63  2008/09/23 02:30:07  cheshire
-Get rid of PutResourceRecordCappedTTL()
-
-Revision 1.62  2008/09/23 02:26:09  cheshire
-Don't need to export putEmptyResourceRecord (it's only used from DNSCommon.c)
-
-Revision 1.61  2008/08/13 00:47:53  mcguire
-Handle failures when packet logging
-
-Revision 1.60  2008/07/24 20:23:03  cheshire
-<rdar://problem/3988320> Should use randomized source ports and transaction IDs to avoid DNS cache poisoning
-
-Revision 1.59  2008/03/14 19:58:38  mcguire
-<rdar://problem/5500969> BTMM: Need ability to identify version of mDNSResponder client
-Make sure we add the record when sending LLQ refreshes
-
-Revision 1.58  2008/03/06 21:26:10  cheshire
-Moved duplicated STRINGIFY macro from individual C files to DNSCommon.h
-
-Revision 1.57  2007/12/13 20:20:17  cheshire
-Minor efficiency tweaks -- converted IdenticalResourceRecord, IdenticalSameNameRecord, and
-SameRData from functions to macros, which allows the code to be inlined (the compiler can't
-inline a function defined in a different compilation unit) and therefore optimized better.
-
-Revision 1.56  2007/12/13 00:13:03  cheshire
-Simplified RDataHashValue to take a single ResourceRecord pointer, instead of separate rdlength and RDataBody
-
-Revision 1.55  2007/12/13 00:09:28  cheshire
-For completeness added MX, AFSDB, RT, KX to list of RRTYPES that are considered to have a target domainname in their rdata
-
-Revision 1.54  2007/10/05 17:56:10  cheshire
-Move CountLabels and SkipLeadingLabels to DNSCommon.c so they're callable from other files
-
-Revision 1.53  2007/09/27 17:42:49  cheshire
-Fix naming: for consistency, "kDNSFlag1_RC" should be "kDNSFlag1_RC_Mask"
-
-Revision 1.52  2007/09/26 00:49:46  cheshire
-Improve packet logging to show sent and received packets,
-transport protocol (UDP/TCP/TLS) and source/destination address:port
-
-Revision 1.51  2007/09/21 21:12:36  cheshire
-<rdar://problem/5498009> BTMM: Need to log updates and query packet contents
-
-Revision 1.50  2007/09/20 01:12:06  cheshire
-Moved HashSlot(X) from mDNS.c to DNSCommon.h so it's usable in other files
-
-Revision 1.49  2007/08/30 00:31:20  cheshire
-Improve "locking failure" debugging messages to show function name using __func__ macro
-
-Revision 1.48  2007/05/25 00:25:44  cheshire
-<rdar://problem/5227737> Need to enhance putRData to output all current known types
-
-Revision 1.47  2007/05/01 21:46:31  cheshire
-Move GetLLQOptData/GetPktLease from uDNS.c into DNSCommon.c so that dnsextd can use them
-
-Revision 1.46  2007/04/22 20:18:10  cheshire
-Add comment about mDNSRandom()
-
-Revision 1.45  2007/04/22 06:02:02  cheshire
-<rdar://problem/4615977> Query should immediately return failure when no server
-
-Revision 1.44  2007/03/28 01:20:05  cheshire
-<rdar://problem/4883206> Improve/create logging for secure browse
-
-Revision 1.43  2007/03/20 17:07:15  cheshire
-Rename "struct uDNS_TCPSocket_struct" to "TCPSocket", "struct uDNS_UDPSocket_struct" to "UDPSocket"
-
-Revision 1.42  2007/03/10 03:26:44  cheshire
-<rdar://problem/4961667> uDNS: LLQ refresh response packet causes cached records to be removed from cache
-
-Revision 1.41  2007/01/18 23:18:17  cheshire
-Source code tidying: Delete extraneous white space
-
-Revision 1.40  2007/01/05 08:30:40  cheshire
-Trim excessive "Log" checkin history from before 2006
-(checkin history still available via "cvs log ..." of course)
-
-Revision 1.39  2007/01/04 21:45:20  cheshire
-Added mDNS_DropLockBeforeCallback/mDNS_ReclaimLockAfterCallback macros,
-to do additional lock sanity checking around callback invocations
-
-Revision 1.38  2006/12/22 20:59:49  cheshire
-<rdar://problem/4742742> Read *all* DNS keys from keychain,
- not just key for the system-wide default registration domain
-
-Revision 1.37  2006/08/14 23:24:22  cheshire
-Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
-
-Revision 1.36  2006/07/05 22:56:07  cheshire
-<rdar://problem/4472014> Add Private DNS client functionality to mDNSResponder
-Update mDNSSendDNSMessage() to use uDNS_TCPSocket type instead of "int"
-
-Revision 1.35  2006/06/29 07:42:14  cheshire
-<rdar://problem/3922989> Performance: Remove unnecessary SameDomainName() checks
-
-Revision 1.34  2006/03/18 21:47:56  cheshire
-<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
-
-Revision 1.33  2006/03/10 21:51:41  cheshire
-<rdar://problem/4111464> After record update, old record sometimes remains in cache
-Split out SameRDataBody() into a separate routine so it can be called from other code
-
-*/
+ */
 
 #ifndef __DNSCOMMON_H_
 #define __DNSCOMMON_H_
@@ -254,7 +115,7 @@
 extern mDNSu32 TruncateUTF8ToLength(mDNSu8 *string, mDNSu32 length, mDNSu32 max);
 extern mDNSBool LabelContainsSuffix(const domainlabel *const name, const mDNSBool RichText);
 extern mDNSu32 RemoveLabelSuffix(domainlabel *name, mDNSBool RichText);
-extern void AppendLabelSuffix(domainlabel *name, mDNSu32 val, mDNSBool RichText);
+extern void AppendLabelSuffix(domainlabel *const name, mDNSu32 val, const mDNSBool RichText);
 #define ValidateDomainName(N) (DomainNameLength(N) <= MAX_DOMAIN_NAME)
 
 // ***************************************************************************
@@ -283,7 +144,7 @@
        (r1)->namehash  == (r2)->namehash    && \
        (r1)->rdlength  == (r2)->rdlength    && \
        (r1)->rdatahash == (r2)->rdatahash   && \
-       SameRDataBody((r1), &(r2)->rdata->u) && \
+       SameRDataBody((r1), &(r2)->rdata->u, SameDomainName) && \
        SameDomainName((r1)->name, (r2)->name))
 
 #define IdenticalSameNameRecord(r1,r2) ( \
@@ -291,18 +152,19 @@
        (r1)->rrclass   == (r2)->rrclass     && \
        (r1)->rdlength  == (r2)->rdlength    && \
        (r1)->rdatahash == (r2)->rdatahash   && \
-       SameRDataBody((r1), &(r2)->rdata->u))
+       SameRDataBody((r1), &(r2)->rdata->u, SameDomainName))
 
 // A given RRType answers a QuestionType if RRType is CNAME, or types match, or QuestionType is ANY,
 // or the RRType is NSEC and positively asserts the nonexistence of the type being requested
-#define RRTypeAnswersQuestionType(R,T) ((R)->rrtype == kDNSType_CNAME || (R)->rrtype == (T) || (T) == kDNSQType_ANY || RRAssertsNonexistence((R),(T)))
+#define RRTypeAnswersQuestionType(R,Q) ((R)->rrtype == kDNSType_CNAME || (R)->rrtype == (Q) || (Q) == kDNSQType_ANY || RRAssertsNonexistence((R),(Q)))
 #define RRAssertsNonexistence(R,T) ((R)->rrtype == kDNSType_NSEC && (T) < kDNSQType_ANY && !((R)->rdata->u.nsec.bitmap[(T)>>3] & (128 >> ((T)&7))))
 
 extern mDNSu32 RDataHashValue(const ResourceRecord *const rr);
-extern mDNSBool SameRDataBody(const ResourceRecord *const r1, const RDataBody *const r2);
+extern mDNSBool SameRDataBody(const ResourceRecord *const r1, const RDataBody *const r2, DomainNameComparisonFn *samename);
 extern mDNSBool SameNameRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q);
 extern mDNSBool ResourceRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q);
 extern mDNSBool AnyTypeRecordAnswersQuestion (const ResourceRecord *const rr, const DNSQuestion *const q);
+extern mDNSBool UnicastResourceRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q);
 extern mDNSu16 GetRDLength(const ResourceRecord *const rr, mDNSBool estimate);
 extern mDNSBool ValidateRData(const mDNSu16 rrtype, const mDNSu16 rdlength, const RData *const rd);
 
@@ -311,7 +173,7 @@
        ((RR)->rrtype == kDNSType_MX || (RR)->rrtype == kDNSType_AFSDB || (RR)->rrtype == kDNSType_RT  || (RR)->rrtype == kDNSType_KX   ) ? &(RR)->rdata->u.mx.exchange : \
        ((RR)->rrtype == kDNSType_SRV                                  ) ? &(RR)->rdata->u.srv.target : mDNSNULL )
 
-#define LocalRecordReady(X) ((X)->resrec.RecordType != kDNSRecordTypeUnique && (X)->resrec.RecordType != kDNSRecordTypeDeregistering)
+#define LocalRecordReady(X) ((X)->resrec.RecordType != kDNSRecordTypeUnique)
 
 // ***************************************************************************
 #if COMPILER_LIKES_PRAGMA_MARK
@@ -326,24 +188,37 @@
 
 // If we have a single large record to put in the packet, then we allow the packet to be up to 9K bytes,
 // but in the normal case we try to keep the packets below 1500 to avoid IP fragmentation on standard Ethernet
+
+#define AllowedRRSpace(msg) (((msg)->h.numAnswers || (msg)->h.numAuthorities || (msg)->h.numAdditionals) ? NormalMaxDNSMessageData : AbsoluteMaxDNSMessageData)
+
 extern mDNSu8 *PutResourceRecordTTLWithLimit(DNSMessage *const msg, mDNSu8 *ptr, mDNSu16 *count, ResourceRecord *rr, mDNSu32 ttl, const mDNSu8 *limit);
 
 #define PutResourceRecordTTL(msg, ptr, count, rr, ttl) \
-       PutResourceRecordTTLWithLimit((msg), (ptr), (count), (rr), (ttl), \
-       ((msg)->h.numAnswers || (msg)->h.numAuthorities || (msg)->h.numAdditionals) ? (msg)->data + NormalMaxDNSMessageData : (msg)->data + AbsoluteMaxDNSMessageData)
+       PutResourceRecordTTLWithLimit((msg), (ptr), (count), (rr), (ttl), (msg)->data + AllowedRRSpace(msg))
+
 #define PutResourceRecordTTLJumbo(msg, ptr, count, rr, ttl) \
        PutResourceRecordTTLWithLimit((msg), (ptr), (count), (rr), (ttl), (msg)->data + AbsoluteMaxDNSMessageData)
+
 #define PutResourceRecord(MSG, P, C, RR) PutResourceRecordTTL((MSG), (P), (C), (RR), (RR)->rroriginalttl)
 
+// The PutRR_OS variants assume a local variable 'm', put build the packet at m->omsg,
+// and assume a local variable 'OwnerRecordSpace' indicating how many bytes (if any) to reserve to add an OWNER option at the end
+#define PutRR_OS_TTL(ptr, count, rr, ttl) \
+       PutResourceRecordTTLWithLimit(&m->omsg, (ptr), (count), (rr), (ttl), m->omsg.data + AllowedRRSpace(&m->omsg) - OwnerRecordSpace)
+
+#define PutRR_OS(P, C, RR) PutRR_OS_TTL((P), (C), (RR), (RR)->rroriginalttl)
+
 extern mDNSu8 *putQuestion(DNSMessage *const msg, mDNSu8 *ptr, const mDNSu8 *const limit, const domainname *const name, mDNSu16 rrtype, mDNSu16 rrclass);
 extern mDNSu8 *putZone(DNSMessage *const msg, mDNSu8 *ptr, mDNSu8 *limit, const domainname *zone, mDNSOpaque16 zoneClass);
-extern mDNSu8 *putPrereqNameNotInUse(const domainname *const name, DNSMessage *msg, mDNSu8 *ptr, mDNSu8 *end);
+extern mDNSu8 *putPrereqNameNotInUse(const domainname *const name, DNSMessage *const msg, mDNSu8 *const ptr, mDNSu8 *const end);
 extern mDNSu8 *putDeletionRecord(DNSMessage *msg, mDNSu8 *ptr, ResourceRecord *rr);
-extern  mDNSu8 *putDeleteRRSet(DNSMessage *msg, mDNSu8 *ptr, const domainname *name, mDNSu16 rrtype);
+extern mDNSu8 *putDeletionRecordWithLimit(DNSMessage *msg, mDNSu8 *ptr, ResourceRecord *rr, mDNSu8 *limit);
+extern mDNSu8 *putDeleteRRSetWithLimit(DNSMessage *msg, mDNSu8 *ptr, const domainname *name, mDNSu16 rrtype, mDNSu8 *limit);
 extern mDNSu8 *putDeleteAllRRSets(DNSMessage *msg, mDNSu8 *ptr, const domainname *name);
 extern mDNSu8 *putUpdateLease(DNSMessage *msg, mDNSu8 *end, mDNSu32 lease);
+extern mDNSu8 *putUpdateLeaseWithLimit(DNSMessage *msg, mDNSu8 *ptr, mDNSu32 lease, mDNSu8 *limit);
 
-extern mDNSu8 *putHINFO(const mDNS *const m, DNSMessage *const msg, mDNSu8 *end, DomainAuthInfo *authInfo);
+extern mDNSu8 *putHINFO(const mDNS *const m, DNSMessage *const msg, mDNSu8 *ptr, DomainAuthInfo *authInfo, mDNSu8 *limit);
 
 // ***************************************************************************
 #if COMPILER_LIKES_PRAGMA_MARK
@@ -359,7 +234,7 @@
        domainname *const name);
 extern const mDNSu8 *skipResourceRecord(const DNSMessage *msg, const mDNSu8 *ptr, const mDNSu8 *end);
 extern const mDNSu8 *GetLargeResourceRecord(mDNS *const m, const DNSMessage * const msg, const mDNSu8 *ptr,
-    const mDNSu8 * end, const mDNSInterfaceID InterfaceID, mDNSu8 RecordType, LargeCacheRecord *largecr);
+    const mDNSu8 * end, const mDNSInterfaceID InterfaceID, mDNSu8 RecordType, LargeCacheRecord *const largecr);
 extern const mDNSu8 *skipQuestion(const DNSMessage *msg, const mDNSu8 *ptr, const mDNSu8 *end);
 extern const mDNSu8 *getQuestion(const DNSMessage *msg, const mDNSu8 *ptr, const mDNSu8 *end, const mDNSInterfaceID InterfaceID,
        DNSQuestion *question);
@@ -389,20 +264,16 @@
 #endif
 
 extern void ShowTaskSchedulingError(mDNS *const m);
-extern void mDNS_Lock_(mDNS *const m);



Home | Main Index | Thread Index | Old Index