Blame SOURCES/0008-Change-P-to-Q-and-print-warning.patch

47589a
From 8a60760db57f496c2f893486f245b40560653ccd Mon Sep 17 00:00:00 2001
47589a
From: rpm-build <rpm-build>
47589a
Date: Mon, 20 Feb 2017 11:01:19 +0100
47589a
Subject: [PATCH 08/13] Change -P to -Q and print warning
47589a
47589a
Guy Harris points that -P is already taken by MacOS derived work and
47589a
that the only remaining single-letter option is -Q (see GH #252). Fix
47589a
some formatting while at it.
47589a
---
47589a
 tcpdump.1.in |  4 ++--
47589a
 tcpdump.c    | 23 +++++++++++++----------
47589a
 2 files changed, 15 insertions(+), 12 deletions(-)
47589a
47589a
diff --git a/tcpdump.1.in b/tcpdump.1.in
47589a
index f233934..88b1266 100644
47589a
--- a/tcpdump.1.in
47589a
+++ b/tcpdump.1.in
47589a
@@ -74,7 +74,7 @@ tcpdump \- dump traffic on a network
47589a
 .B \-\-number
47589a
 ]
47589a
 [
47589a
-.B \-Q
47589a
+.B \-Q|\-P
47589a
 .I in|out|inout
47589a
 ]
47589a
 .ti +8
47589a
@@ -583,7 +583,7 @@ Note that the interface might be in promiscuous
47589a
 mode for some other reason; hence, `-p' cannot be used as an abbreviation for
47589a
 `ether host {local-hw-addr} or ether broadcast'.
47589a
 .TP
47589a
-.BI \-Q " direction"
47589a
+.BI \-Q|\-P " direction"
47589a
 .PD 0
47589a
 .TP
47589a
 .BI \-\-direction= direction
47589a
diff --git a/tcpdump.c b/tcpdump.c
47589a
index e4e0d89..d7b094b 100644
47589a
--- a/tcpdump.c
47589a
+++ b/tcpdump.c
47589a
@@ -157,7 +157,7 @@ static int Jflag;			/* list available time stamp types */
47589a
 static int jflag = -1;			/* packet time stamp source */
47589a
 static int pflag;			/* don't go promiscuous */
47589a
 #ifdef HAVE_PCAP_SETDIRECTION
47589a
-static int Qflag = -1;			/* restrict captured packet by send/receive direction */
47589a
+static int PQflag = -1;			/* restrict captured packet by send/receive direction */
47589a
 #endif
47589a
 static int Uflag;			/* "unbuffered" output of dump files */
47589a
 static int Wflag;			/* recycle output files after this number of files */
47589a
@@ -509,12 +509,12 @@ show_devices_and_exit (void)
47589a
 #endif
47589a
 
47589a
 #ifdef HAVE_PCAP_SETDIRECTION
47589a
-#define Q_FLAG "Q:"
47589a
+#define PQ_FLAG "P:Q:"
47589a
 #else
47589a
-#define Q_FLAG
47589a
+#define PQ_FLAG
47589a
 #endif
47589a
 
47589a
-#define SHORTOPTS "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" Q_FLAG "r:s:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#"
47589a
+#define SHORTOPTS "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" PQ_FLAG "r:s:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#"
47589a
 
47589a
 /*
47589a
  * Long options.
47589a
@@ -1059,8 +1059,8 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf)
47589a
 			    pcap_statustostr(status));
47589a
 	}
47589a
 #ifdef HAVE_PCAP_SETDIRECTION
47589a
-	if (Qflag != -1) {
47589a
-		status = pcap_setdirection(pc, Qflag);
47589a
+	if (PQflag != -1) {
47589a
+		status = pcap_setdirection(pc, PQflag);
47589a
 		if (status != 0)
47589a
 			error("%s: pcap_setdirection() failed: %s",
47589a
 			      device,  pcap_geterr(pc));
47589a
@@ -1343,13 +1343,16 @@ main(int argc, char **argv)
47589a
 			break;
47589a
 
47589a
 #ifdef HAVE_PCAP_SETDIRECTION
47589a
+                case 'P':
47589a
+                        fprintf(stderr, "Warning: -P switch is not compatible with the upstream version. You should use -Q instead.\n");
47589a
+                        /* Intentional fall through */
47589a
 		case 'Q':
47589a
 			if (ascii_strcasecmp(optarg, "in") == 0)
47589a
-				Qflag = PCAP_D_IN;
47589a
+				PQflag = PCAP_D_IN;
47589a
 			else if (ascii_strcasecmp(optarg, "out") == 0)
47589a
-				Qflag = PCAP_D_OUT;
47589a
+				PQflag = PCAP_D_OUT;
47589a
 			else if (ascii_strcasecmp(optarg, "inout") == 0)
47589a
-				Qflag = PCAP_D_INOUT;
47589a
+				PQflag = PCAP_D_INOUT;
47589a
 			else
47589a
 				error("unknown capture direction `%s'", optarg);
47589a
 			break;
47589a
@@ -2613,7 +2616,7 @@ print_usage(void)
47589a
 "\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ] [ --number ]\n");
47589a
 #ifdef HAVE_PCAP_SETDIRECTION
47589a
 	(void)fprintf(stderr,
47589a
-"\t\t[ -Q in|out|inout ]\n");
47589a
+"\t\t[ -Q|-P in|out|inout ]\n");
47589a
 #endif
47589a
 	(void)fprintf(stderr,
47589a
 "\t\t[ -r file ] [ -s snaplen ] ");
47589a
-- 
47589a
2.13.5
47589a