From: Guy Harris Date: Sun, 8 Mar 2015 22:55:47 +0000 (-0700) Subject: Add a #define for the short options and put it above the long options. X-Git-Tag: tcpdump-4.7.2~1^2~10 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/2f63616362063fc8a34b1bb7eaeddae7d395b8d3 Add a #define for the short options and put it above the long options. That puts all the option lists together; hopefully this encourages developers who want to add a new flag to read the big "don't use these options, other tcpdumps use them for their own purposes" command and thus *dis*courages them from using one of those options. --- diff --git a/tcpdump.c b/tcpdump.c index 1ad22927..b1f88cf3 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -607,6 +607,15 @@ show_devices_and_exit (void) * * OS X tcpdump uses -P to indicate that -w should write pcap-ng rather * than pcap files. + * + * OS X tcpdump also uses -Q to specify expressions that match packet + * metadata, including but not limited to the packet direction. + * The expression syntax is different from a simple "in|out|inout", + * and those expressions aren't accepted by OS X tcpdump, but the + * equivalents would be "in" = "dir=in", "out" = "dir=out", and + * "inout" = "dir=in or dir=out", and the parser could conceivably + * special-case "in", "out", and "inout" as expressions for backwards + * compatibility, so all is not (yet) lost. */ /* @@ -655,6 +664,8 @@ show_devices_and_exit (void) #define Q_FLAG #endif +#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:Rs:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#" + /* * Long options. * @@ -1061,7 +1072,7 @@ main(int argc, char **argv) #endif while ( - (op = getopt_long(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" Q_FLAG "r:Rs:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#", longopts, NULL)) != -1) + (op = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1) switch (op) { case 'a':