]> The Tcpdump Group git mirrors - tcpdump/commitdiff
In mDNS, report IN-class records with the "cache flush" bit set as such,
authorguy <guy>
Wed, 5 Nov 2003 06:02:58 +0000 (06:02 +0000)
committerguy <guy>
Wed, 5 Nov 2003 06:02:58 +0000 (06:02 +0000)
rather than as "Class 32769".

interface.h
nameser.h
print-domain.c
print-tcp.c
print-udp.c

index 744b89ddd647b1e26a92932c2ae04b4347a3162f..2c2821260611d99b9b1c34c5de0df771649ed624 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.216 2003-10-27 10:13:45 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.217 2003-11-05 06:02:58 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -249,7 +249,7 @@ extern u_int ltalk_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void msdp_print(const unsigned char *, u_int);
 extern void nfsreply_print(const u_char *, u_int, const u_char *);
 extern void nfsreq_print(const u_char *, u_int, const u_char *);
-extern void ns_print(const u_char *, u_int);
+extern void ns_print(const u_char *, u_int, int);
 extern void ntp_print(const u_char *, u_int);
 extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void ospf_print(const u_char *, u_int, const u_char *);
index a1d504a8f8ca0cad4fb240a101c62aa8e0813eda..7a9e6113595dc1c96c934614176d504495dd5d59 100644 (file)
--- a/nameser.h
+++ b/nameser.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.13 2002-12-11 07:13:55 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.14 2003-11-05 06:02:59 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1983, 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
 #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 */
 
 /*
  * Status return codes for T_UNSPEC conversion routines
index 6173521ddb3bf8690776a2e7f151837e7ae0122c..788be7f16cf58151b4d0bdc952ae585e57a071bb 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.85 2003-09-25 22:30:22 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.86 2003-11-05 06:03:00 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -305,7 +305,7 @@ struct tok ns_class2str[] = {
 
 /* print a query */
 static const u_char *
-ns_qprint(register const u_char *cp, register const u_char *bp)
+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;
@@ -321,7 +321,9 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
        printf(" %s", tok2str(ns_type2str, "Type%d", i));
        i = EXTRACT_16BITS(cp);
        cp += 2;
-       if (i != C_IN)
+       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));
 
        fputs("? ", stdout);
@@ -331,7 +333,7 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
 
 /* print a reply */
 static const u_char *
-ns_rprint(register const u_char *cp, register const u_char *bp)
+ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
 {
        register u_int class;
        register u_short typ, len;
@@ -352,7 +354,9 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
        cp += 2;
        class = EXTRACT_16BITS(cp);
        cp += 2;
-       if (class != C_IN && typ != T_OPT)
+       if (is_mdns && class == (C_IN|C_CACHE_FLUSH))
+               printf(" (Cache flush)");
+       else if (class != C_IN && typ != T_OPT)
                printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
 
        /* ignore ttl */
@@ -518,7 +522,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
 }
 
 void
-ns_print(register const u_char *bp, u_int length)
+ns_print(register const u_char *bp, u_int length, int is_mdns)
 {
        register const HEADER *np;
        register int qdcount, ancount, nscount, arcount;
@@ -553,7 +557,7 @@ ns_print(register const u_char *bp, u_int length)
                                putchar(',');
                        if (vflag > 1) {
                                fputs(" q:", stdout);
-                               if ((cp = ns_qprint(cp, bp)) == NULL)
+                               if ((cp = ns_qprint(cp, bp, is_mdns)) == NULL)
                                        goto trunc;
                        } else {
                                if ((cp = ns_nskip(cp)) == NULL)
@@ -563,11 +567,11 @@ ns_print(register const u_char *bp, u_int length)
                }
                printf(" %d/%d/%d", ancount, nscount, arcount);
                if (ancount--) {
-                       if ((cp = ns_rprint(cp, bp)) == NULL)
+                       if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                goto trunc;
                        while (cp < snapend && ancount--) {
                                putchar(',');
-                               if ((cp = ns_rprint(cp, bp)) == NULL)
+                               if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                        goto trunc;
                        }
                }
@@ -577,11 +581,11 @@ ns_print(register const u_char *bp, u_int length)
                if (vflag > 1) {
                        if (cp < snapend && nscount--) {
                                fputs(" ns:", stdout);
-                               if ((cp = ns_rprint(cp, bp)) == NULL)
+                               if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                        goto trunc;
                                while (cp < snapend && nscount--) {
                                        putchar(',');
-                                       if ((cp = ns_rprint(cp, bp)) == NULL)
+                                       if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                                goto trunc;
                                }
                        }
@@ -589,11 +593,11 @@ ns_print(register const u_char *bp, u_int length)
                                goto trunc;
                        if (cp < snapend && arcount--) {
                                fputs(" ar:", stdout);
-                               if ((cp = ns_rprint(cp, bp)) == NULL)
+                               if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                        goto trunc;
                                while (cp < snapend && arcount--) {
                                        putchar(',');
-                                       if ((cp = ns_rprint(cp, bp)) == NULL)
+                                       if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                                goto trunc;
                                }
                        }
@@ -631,12 +635,13 @@ ns_print(register const u_char *bp, u_int length)
 
                cp = (const u_char *)(np + 1);
                if (qdcount--) {
-                       cp = ns_qprint(cp, (const u_char *)np);
+                       cp = ns_qprint(cp, (const u_char *)np, is_mdns);
                        if (!cp)
                                goto trunc;
                        while (cp < snapend && qdcount--) {
                                cp = ns_qprint((const u_char *)cp,
-                                              (const u_char *)np);
+                                              (const u_char *)np,
+                                              is_mdns);
                                if (!cp)
                                        goto trunc;
                        }
@@ -647,11 +652,11 @@ ns_print(register const u_char *bp, u_int length)
                /* Print remaining sections on -vv */
                if (vflag > 1) {
                        if (ancount--) {
-                               if ((cp = ns_rprint(cp, bp)) == NULL)
+                               if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                        goto trunc;
                                while (cp < snapend && ancount--) {
                                        putchar(',');
-                                       if ((cp = ns_rprint(cp, bp)) == NULL)
+                                       if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                                goto trunc;
                                }
                        }
@@ -659,11 +664,11 @@ ns_print(register const u_char *bp, u_int length)
                                goto trunc;
                        if (cp < snapend && nscount--) {
                                fputs(" ns:", stdout);
-                               if ((cp = ns_rprint(cp, bp)) == NULL)
+                               if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                        goto trunc;
                                while (nscount-- && cp < snapend) {
                                        putchar(',');
-                                       if ((cp = ns_rprint(cp, bp)) == NULL)
+                                       if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                                goto trunc;
                                }
                        }
@@ -671,11 +676,11 @@ ns_print(register const u_char *bp, u_int length)
                                goto trunc;
                        if (cp < snapend && arcount--) {
                                fputs(" ar:", stdout);
-                               if ((cp = ns_rprint(cp, bp)) == NULL)
+                               if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                        goto trunc;
                                while (cp < snapend && arcount--) {
                                        putchar(',');
-                                       if ((cp = ns_rprint(cp, bp)) == NULL)
+                                       if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
                                                goto trunc;
                                }
                        }
index 2b7c610cf4a6081b2be5a925bf084cb9e0d4e145..c69dbcd0d6df4a8193cdd35e35a1b27ab7108669 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.106 2003-10-28 03:16:36 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.107 2003-11-05 06:03:01 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -622,7 +622,7 @@ tcp_print(register const u_char *bp, register u_int length,
                         * TCP DNS query has 2byte length at the head.
                         * XXX packet could be unaligned, it can go strange
                         */
-                       ns_print(bp + 2, length - 2);
+                       ns_print(bp + 2, length - 2, 0);
                } else if (sport == MSDP_PORT || dport == MSDP_PORT) {
                        msdp_print(bp, length);
                }
index 2bf77d4bfc1d995607f878a211dcda372516c5ff..2888a6d74b9b3af931bd1b5e67634c56a3238208 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.123 2003-10-27 22:44:37 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.124 2003-11-05 06:03:01 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -599,8 +599,10 @@ udp_print(register const u_char *bp, u_int length,
 
        if (!qflag) {
 #define ISPORT(p) (dport == (p) || sport == (p))
-               if (ISPORT(NAMESERVER_PORT) || ISPORT(MULTICASTDNS_PORT))
-                       ns_print((const u_char *)(up + 1), length);
+               if (ISPORT(NAMESERVER_PORT))
+                       ns_print((const u_char *)(up + 1), length, 0);
+               else if (ISPORT(MULTICASTDNS_PORT))
+                       ns_print((const u_char *)(up + 1), length, 1);
                else if (ISPORT(TIMED_PORT))
                        timed_print((const u_char *)(up + 1));
                else if (ISPORT(TFTP_PORT))