]> The Tcpdump Group git mirrors - tcpdump/commitdiff
The topmost bit in the class field isn't a "cache flush" flag in mDNS
authorguy <guy>
Fri, 10 Nov 2006 03:15:35 +0000 (03:15 +0000)
committerguy <guy>
Fri, 10 Nov 2006 03:15:35 +0000 (03:15 +0000)
queries.  Display that bit correctly (as per Marc Krochmal's request).

In mDNS, the topmost bit of the class field should be handled the same
way regardless of the value of the lower 15 bits, and *vice versa* -
they're independent fields.

nameser.h
print-domain.c

index 55616e415e86326255317f7b7d303eb00a68749f..8dcc92b67c8faf5e7b4037cf49c5bb1f93ac4c0e 100644 (file)
--- a/nameser.h
+++ b/nameser.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.14.4.1 2006-04-07 08:48:09 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.14.4.2 2006-11-10 03:15:35 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1983, 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
  * Internet nameserver port number
  */
 #define NAMESERVER_PORT        53
+
+/*
+ * Port for multicast DNS; see
+ *
+ *     http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt
+ *
+ * for the current mDNS spec.
+ */
 #define MULTICASTDNS_PORT      5353
 
 /*
 #define C_HS           4               /* for Hesiod name server (MIT) (XXX) */
        /* Query class values which do not appear in resource records */
 #define C_ANY          255             /* wildcard match */
-#define C_CACHE_FLUSH  0x8000          /* mDNS cache flush flag */
+#define C_QU           0x8000          /* mDNS QU flag in queries */
+#define C_CACHE_FLUSH  0x8000          /* mDNS cache flush flag in replies */
 
 /*
  * Status return codes for T_UNSPEC conversion routines
index 3db942720f73e901237df5f80f482dadc9e61644..bc16c70a7abd7544de22f1813e2d093b89d8fc80 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.3 2006-04-07 08:58:43 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.4 2006-11-10 03:15:35 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -320,23 +320,33 @@ static const u_char *
 ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
 {
        register const u_char *np = cp;
-       register u_int i;
+       register u_int i, class, qu;
 
        cp = ns_nskip(cp);
 
        if (cp == NULL || !TTEST2(*cp, 4))
                return(NULL);
 
-       /* print the qtype and qclass (if it's not IN) */
+       /* print the qtype */
        i = EXTRACT_16BITS(cp);
        cp += 2;
        printf(" %s", tok2str(ns_type2str, "Type%d", i));
+       /* print the qclass (if it's not IN) */
        i = EXTRACT_16BITS(cp);
        cp += 2;
-       if (is_mdns && i == (C_IN|C_CACHE_FLUSH))
-               printf(" (Cache flush)");
-       else if (i != C_IN)
-               printf(" %s", tok2str(ns_class2str, "(Class %d)", i));
+       if (is_mdns) {
+               class = (i & ~C_QU);
+               qu = (i & C_QU);
+       } else {
+               class = i;
+               qu = 0;
+       }
+       if (class != C_IN)
+               printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+       if (qu)
+               printf(" (QU)");
+       else
+               printf(" (QM)");
 
        fputs("? ", stdout);
        cp = ns_nprint(np, bp);
@@ -347,7 +357,7 @@ ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
 static const u_char *
 ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
 {
-       register u_int class, opt_flags = 0;
+       register u_int i, class, cache_flush, opt_flags = 0;
        register u_short typ, len;
        register const u_char *rp;
 
@@ -361,15 +371,23 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
        if (cp == NULL || !TTEST2(*cp, 10))
                return (snapend);
 
-       /* print the type/qtype and class (if it's not IN) */
+       /* print the type/qtype */
        typ = EXTRACT_16BITS(cp);
        cp += 2;
-       class = EXTRACT_16BITS(cp);
+       /* print the class (if it's not IN and the type isn't OPT) */
+       i = EXTRACT_16BITS(cp);
        cp += 2;
-       if (is_mdns && class == (C_IN|C_CACHE_FLUSH))
-               printf(" (Cache flush)");
-       else if (class != C_IN && typ != T_OPT)
+       if (is_mdns) {
+               class = (i & ~C_CACHE_FLUSH);
+               cache_flush = i & C_CACHE_FLUSH;
+       } else {
+               class = i;
+               cache_flush = 0;
+       }
+       if (class != C_IN && typ != T_OPT)
                printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+       if (cache_flush)
+               printf(" (Cache flush)");
 
        /* ignore ttl */
        cp += 2;