]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
bumped VERSION to 4.5.1
[tcpdump] / tcpdump.c
index 1145d1982c932e979887d32a025d534c008c07ec..739f9c8ae859296a3348a03659fe3b3016a2b75b 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -106,7 +106,7 @@ static int Lflag;                   /* list available data link types and exit */
 static int Jflag;                      /* list available time stamp types */
 #endif
 #ifdef HAVE_PCAP_SETDIRECTION
-int Pflag = PCAP_D_INOUT;      /* Restrict captured packet by sent/receive direction */
+int Pflag = -1;        /* Restrict captured packet by sent/receive direction */
 #endif
 static char *zflag = NULL;             /* compress each savefile using a specified command (like gzip or bzip2) */
 
@@ -747,7 +747,7 @@ main(int argc, char **argv)
 #endif
 
        while (
-           (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOp" P_FLAG "qr:Rs:StT:u" U_FLAG "V:vw:W:xXy:Yz:Z:")) != -1)
+           (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOp" P_FLAG "qr:Rs:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:")) != -1)
                switch (op) {
 
                case 'a':
@@ -1334,10 +1334,12 @@ main(int argc, char **argv)
                                    pcap_statustostr(status));
                }
 #ifdef HAVE_PCAP_SETDIRECTION
-               status = pcap_setdirection(pd, Pflag);
-               if (status != 0)
-                       error("%s: pcap_set_direction failed: %s",
-                           device,  pcap_geterr(pd));
+               if (Pflag != -1) {
+                       status = pcap_setdirection(pd, Pflag);
+                       if (status != 0)
+                               error("%s: pcap_setdirection() failed: %s",
+                                     device,  pcap_geterr(pd));
+               }
 #endif
 #else
                *ebuf = '\0';