]> 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:22:15 +0000 (01:22 +0000)
committerguy <guy>
Thu, 7 Jul 2005 01:22:15 +0000 (01:22 +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 2c798812757f97660ac095d2c557c068f9d80645..66639b0697ebc9cb112d523dfabfa06f906760d2 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.256 2005-07-06 20:53:30 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.257 2005-07-07 01:22:15 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 09dc676f53d311c5a55ede83bb0779c3ecf59d89..cca820e46487b9a14a78e4f813b558bb6187e556 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.17 2005-07-06 20:53:31 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.18 2005-07-07 01:22:16 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 81abc64141ad3066185912d6f07e7f085c665305..e7acb79ec96745493bf6a067afabd93a6c468c4a 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.32 2005-04-20 19:32:16 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.33 2005-07-07 01:22:16 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..21e9c19cb0076cba2cb37e859a403472c908f8b3 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.4 2005-07-07 01:22:17 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 919d5e07f6bbdd41897a3b43c55cb49a167931c4..3bcd5f2e41f57b3404c32d6491e25c8bbd1ba2de 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.40 2005-06-20 07:37:02 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.41 2005-07-07 01:22:17 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..e9d672fe761b5f0bb80fe2845bae93bd2b369083 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.26 2005-07-07 01:22:17 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 4f04915c96df56e370f1a5d28412cc107aa35c98..ace88877a01ecd3f268d0b576b33b5712a181b67 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.97 2005-07-01 16:15:59 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.98 2005-07-07 01:22:17 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..308f8c903da7a42fbd2bd8da2e1722bca8c858b7 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.65 2005-07-07 01:22:18 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 082847c2fa2ca3b0a4f10076fb6decad9687b053..ea56c6dabd4a4ad2c903fd333fe086d9fdbb8e3d 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-       "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.36 2005-05-27 14:53:48 hannes Exp $ (LBL)";
+       "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.37 2005-07-07 01:22:18 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..e19d9791ac8c6c9909a3f831ea19552f9bdf79bd 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.8 2005-07-07 01:22:19 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..ab03a44a38b0a947ec8636d83d514790827b44c1 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.24 2005-07-07 01:22:19 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 11f90ef36023e3e603d08d06d6fef411a571b9e7..6de6d48908b2ac8635effbfc504e70bdd09be166 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.55 2005-05-19 07:25:49 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.56 2005-07-07 01:22:19 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..0505af9dc590be1a3f4f314e38357780959faa2f 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.14 2005-07-07 01:22:20 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 b18ab793b09bbf31886c5116dec954d861a9bec2..d38cfde2d6755ddcb276b621346ddbbb2a0c4bc4 100644 (file)
@@ -35,7 +35,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.19 2005-05-06 10:53:01 guy Exp $ (NETLAB/PEL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.20 2005-07-07 01:22:20 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 c08dd83b480d0bd635027b0edde20bea60f51436..989583029fec455262c82e8eb808a61eaebda24c 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.17 2005-04-26 00:16:28 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.18 2005-07-07 01:22:21 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..ebb62cd4d135ac5bb67644d8915484dfa69a4f72 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.5 2005-07-07 01:22:21 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..d17e9506863544d53a840db6f379597b68a0223b 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.26 2005-07-07 01:22:21 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 3cb39fccbc7a49a81a5f204f683f069599e6f0b2..44a218dae487fcb4c40f70c9af63de3b3555a175 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.259 2005-07-06 20:53:32 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.260 2005-07-07 01:22:21 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':