]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add a flag to suppress the "default_print()" call made in various
authorguy <guy>
Thu, 7 Jul 2005 01:24:32 +0000 (01:24 +0000)
committerguy <guy>
Thu, 7 Jul 2005 01:24:32 +0000 (01:24 +0000)
link-layer print routines if no other print routine claimed the packet.
Test whether that flag is set rather than testing whether neither of -x
or -q were specified, and have -x, -q, *and* -X set that flag, so that
-X suppresses it just as -x does.  That way you don't get those pckets
dumped twice if -X was specified.

18 files changed:
interface.h
netdissect.h
print-802_11.c
print-ap1394.c
print-atm.c
print-cip.c
print-ether.c
print-fddi.c
print-fr.c
print-ipfc.c
print-lane.c
print-null.c
print-pflog.c
print-sctp.c
print-sll.c
print-symantec.c
print-token.c
tcpdump.c

index 9e3f5c502a359756fe71b1695ce80d081453631a..36d4078b5a23b40c58d0bd606f620e171c96354a 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.244.2.12 2005-07-06 20:54:48 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.13 2005-07-07 01:24:32 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -347,6 +347,7 @@ extern netdissect_options *gndo;
 #define Xflag gndo->ndo_Xflag 
 #define Cflag gndo->ndo_Cflag 
 #define Aflag gndo->ndo_Aflag 
+#define suppress_default_print gndo->ndo_suppress_default_print
 #define packettype gndo->ndo_packettype
 #define tcpmd5secret gndo->ndo_tcpmd5secret
 #define Wflag gndo->ndo_Wflag
index 3f6bc92bb414565b8d436028bebcd6913433fc70..b5e805b236f97776752ded2870f6f98011f5e4d3 100644 (file)
@@ -21,7 +21,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.16.2.1 2005-07-06 20:54:48 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.16.2.2 2005-07-07 01:24:32 guy Exp $ (LBL)
  */
 
 #ifndef netdissect_h
@@ -107,7 +107,8 @@ struct netdissect_options {
   int ndo_Cflag;                /* rotate dump files after this many bytes */ 
   int ndo_Cflag_count;      /* Keep track of which file number we're writing */
   int ndo_Wflag;          /* recycle output files after this number of files */
-  int ndo_WflagChars;     
+  int ndo_WflagChars;
+  int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
   const char *ndo_dltname;
 
   char *ndo_espsecret;
index b4a1c7e94c61848186cf59113037c44f2195101f..383078d3e42cc903721251cd4519def66b936276 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.1 2005-04-20 19:32:41 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.2 2005-07-07 01:24:33 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -900,7 +900,7 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
                                printf("(LLC %s) ",
                                    etherproto_string(
                                        htons(extracted_ethertype)));
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                                default_print(p, caplen);
                }
                break;
index 07a5df54bd52b53f7f9b793d8c07101ef73ffc6e..13a3ccce22ac401bfe43c8c6711d0943190b9000 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.3 2004-03-17 23:24:35 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.3.2.1 2005-07-07 01:24:33 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -111,7 +111,7 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
                if (!eflag)
                        ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);
 
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        } 
 
index 8fee26dd27620ce629b80f9b310b8322b9e7f8f3..243af9ab56b410077d5313866b4adf1e11b516b6 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.2 2005-06-20 07:45:06 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.3 2005-07-07 01:24:34 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -106,7 +106,7 @@ atm_llc_print(const u_char *p, int length, int caplen)
                        printf("(LLC %s) ",
                etherproto_string(htons(extracted_ethertype)));
                }
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
 }
index 3a7d33a5c258508cfb1e2c45576c5469fe7733fb..ddc7c909cfdea9dcf681dbfbc8d9cbecf184e49d 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.25 2005-04-06 21:32:39 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.25.2.1 2005-07-07 01:24:34 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -94,7 +94,7 @@ cip_if_print(const struct pcap_pkthdr *h, const u_char *p)
                                printf("(LLC %s) ",
                               etherproto_string(htons(extracted_ethertype)));
                        }
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                                default_print(p, caplen);
                }
        } else {
index 4b30d19ce81818500594586ea1ad0b7598a78871..4dd7904e8457221579213f4fd1ad70687e011868 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.2 2005-07-01 16:16:30 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.3 2005-07-07 01:24:35 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -136,7 +136,7 @@ ether_print(const u_char *p, u_int length, u_int caplen)
                        if (!eflag)
                                ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN);
 
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                                default_print(p, caplen);
                }
        } else if (ether_encap_print(ether_type, p, length, caplen,
@@ -145,7 +145,7 @@ ether_print(const u_char *p, u_int length, u_int caplen)
                if (!eflag)
                        ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN);
 
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        } 
 }
@@ -245,7 +245,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
                                ether_hdr_print(p - 18, length + 4);
                }
 
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p - 18, caplen + 4);
 
                return (1);
@@ -270,7 +270,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
                     ether_hdr_print(p - 16, length + 2);
                 }
 
-                if (!xflag && !qflag)
+                if (!suppress_default_print)
                     default_print(p - 16, caplen + 2);
 
                 return (1);
index 84aea5524b36face46d09a5697afb24d492a496a..2a3513db02d28cef7534d481d7628cb3b59a436f 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.64 2004-03-17 23:24:37 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.64.2.1 2005-07-07 01:24:35 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -280,7 +280,7 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
                                printf("(LLC %s) ",
                        etherproto_string(htons(extracted_ethertype)));
                        }
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                                default_print(p, caplen);
                }
        } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
@@ -290,7 +290,7 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
                if (!eflag)
                        fddi_hdr_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
                            EDST(&ehdr));
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
 }
index adfb39f1c52ae8f720bd72203be19725562471bb..7af7e9f79aed72a4c79fb4824e27e96139b157f0 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-       "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.4 2005-05-27 14:56:52 hannes Exp $ (LBL)";
+       "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.5 2005-07-07 01:24:35 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -276,7 +276,7 @@ fr_print(register const u_char *p, u_int length)
                         if (!eflag)
                             fr_hdr_print(length + hdr_len, hdr_len,
                                          dlci, flags, nlpid);
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                             default_print(p - hdr_len, length + hdr_len);
                }
                break;
index cf3f5626f204948d312ecb1cfebd483c832dd916..90b3ea79aafdb9f4f5492d220a125e17be396116 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.7 2004-03-17 23:24:37 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.7.2.1 2005-07-07 01:24:36 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -117,7 +117,7 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
                        printf("(LLC %s) ",
                etherproto_string(htons(extracted_ethertype)));
                }
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
 }
index 03e5652d10f738249f4499cc8450cb4095efd273..2b9f4ded6412bd1285ba49a356d89363cd1e7dc3 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.23 2004-03-17 23:24:37 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.23.2.1 2005-07-07 01:24:37 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -146,7 +146,7 @@ lane_print(const u_char *p, u_int length, u_int caplen)
                                printf("(LLC %s) ",
                               etherproto_string(htons(extracted_ethertype)));
                        }
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                                default_print(p, caplen);
                }
        } else if (ether_encap_print(ether_type, p, length, caplen,
@@ -154,7 +154,7 @@ lane_print(const u_char *p, u_int length, u_int caplen)
                /* ether_type not known, print raw packet */
                if (!eflag)
                        lane_hdr_print((u_char *)ep, length + sizeof(*ep));
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
 }
index 50283ebbbc1036a4e00a89f7150bbb46eb98dc24..0d1dcf5948487068e8f58729012905cd08353552 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.2 2005-05-19 07:26:18 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.3 2005-07-07 01:24:38 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -173,7 +173,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
                /* unknown AF_ value */
                if (!eflag)
                        null_hdr_print(family, length + NULL_HDRLEN);
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
 
index 6cd004cc1c68cddf97da3a8c30525ff92f9575c0..60a7f2ac3352beca313418eef6a3a8bc978be18d 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.13 2005-04-06 21:32:41 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.13.2.1 2005-07-07 01:24:38 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -152,7 +152,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
                /* address family not handled, print raw packet */
                if (!eflag)
                        pflog_print(hdr);
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
        
index 53887f69fcf64375acf90e10652569c755d7ce8e..360aad21c3c9f84ee4e975ad833cce3e427ce698 100644 (file)
@@ -35,7 +35,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.16.2.3 2005-05-06 10:53:20 guy Exp $ (NETLAB/PEL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.16.2.4 2005-07-07 01:24:38 guy Exp $ (NETLAB/PEL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -200,7 +200,7 @@ void sctp_print(const u_char *bp,        /* beginning of sctp packet */
 
                printf("[Payload");
 
-               if (!xflag && !qflag) {
+               if (!suppress_default_print) {
                        payloadPtr = (const u_char *) (++dataHdrPtr);
                        printf(":");
                        if (htons(chunkDescPtr->chunkLength) <
index 877a3e43afc29b063f27e7ee777c5e5e65a68187..00406304b5250d0d5e97bfa9e49c7e640a06fce6 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.16.2.1 2005-04-26 00:16:43 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.16.2.2 2005-07-07 01:24:39 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -181,7 +181,7 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
                                printf("(LLC %s) ",
                               etherproto_string(htons(extracted_ethertype)));
                        }
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                                default_print(p, caplen);
                        break;
                }
@@ -190,7 +190,7 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
                /* ether_type not known, print raw packet */
                if (!eflag)
                        sll_print(sllp, length + SLL_HDR_LEN);
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
 
index ec5f02e141fe6c24e042d0971222c896bb84efd8..1b0f2ec5d50f68cee7404c2bf46885a78ed7911b 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-symantec.c,v 1.4 2004-04-05 00:13:59 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-symantec.c,v 1.4.2.1 2005-07-07 01:24:39 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -105,7 +105,7 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
                if (!eflag)
                        symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
 
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        } else if (ether_encap_print(ether_type, p, length, caplen,
            &extracted_ether_type) == 0) {
@@ -113,7 +113,7 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
                if (!eflag)
                        symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
 
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        } 
 
index 1ef215d28537a8c7a06ea669e25851cd37d03b44..35ba465cdfce682b28133562267156ad4ccf4293 100644 (file)
@@ -25,7 +25,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25 2004-03-17 23:24:38 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25.2.1 2005-07-07 01:24:40 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -167,7 +167,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
                                printf("(LLC %s) ",
                        etherproto_string(htons(extracted_ethertype)));
                        }
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                                default_print(p, caplen);
                }
        } else {
@@ -176,7 +176,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
                if (!eflag)
                        token_hdr_print(trp, length + TOKEN_HDRLEN + route_len,
                            ESRC(&ehdr), EDST(&ehdr));
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
        return (hdr_len);
index 2da258d0f5cfaf82e601e7630bcf14fa22f37641..93a77558a921a0269d31f9a9924e98240fa3a296 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.9 2005-07-06 20:54:49 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.10 2005-07-07 01:24:40 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -653,6 +653,7 @@ main(int argc, char **argv)
 
                case 'q':
                        ++qflag;
+                       ++suppress_default_print;
                        break;
 
                case 'r':
@@ -733,10 +734,12 @@ main(int argc, char **argv)
 
                case 'x':
                        ++xflag;
+                       ++suppress_default_print;
                        break;
 
                case 'X':
                        ++Xflag;
+                       ++suppress_default_print;
                        break;
 
                case 'y':