]> The Tcpdump Group git mirrors - tcpdump/commitdiff
add a short option '#', same as long option '--number' (print a packet number)
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 10 Jul 2014 12:47:11 +0000 (14:47 +0200)
committerMichael Richardson <[email protected]>
Sat, 19 Jul 2014 13:09:46 +0000 (09:09 -0400)
tcpdump.1.in
tcpdump.c

index efc086535cc0b75b74cc5324575edaf2f8915bbf..b2cbe7841de4768eb19bfd2f406a96a4861d6c3f 100644 (file)
@@ -27,7 +27,7 @@ tcpdump \- dump traffic on a network
 .na
 .B tcpdump
 [
-.B \-AbdDefhHIJKlLnNOpqRStuUvxX
+.B \-AbdDefhHIJKlLnNOpqRStuUvxX#
 ] [
 .B \-B
 .I buffer_size
@@ -534,6 +534,9 @@ E.g.,
 if you give this flag then \fItcpdump\fP will print ``nic''
 instead of ``nic.ddn.mil''.
 .TP
+.B \-#
+.PD 0
+.TP
 .B \-\-number
 Print an optional packet number at the beginning of the line.
 .TP
index 40b930d3b4ffe10609b1cb37ffed9d65289a83c0..11dc8bc8b854f356ccbe805ef0308357afbd637f 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -658,9 +658,8 @@ show_devices_and_exit (void)
  * component of the entry for the long option, and have a case for that
  * option in the switch statement.
  */
-#define OPTION_NUMBER          128
-#define OPTION_VERSION         129
-#define OPTION_TSTAMP_PRECISION        130
+#define OPTION_VERSION         128
+#define OPTION_TSTAMP_PRECISION        129
 
 static const struct option longopts[] = {
 #if defined(HAVE_PCAP_CREATE) || defined(WIN32)
@@ -696,7 +695,7 @@ static const struct option longopts[] = {
        { "debug-filter-parser", no_argument, NULL, 'Y' },
 #endif
        { "relinquish-privileges", required_argument, NULL, 'Z' },
-       { "number", no_argument, NULL, OPTION_NUMBER },
+       { "number", no_argument, NULL, '#' },
        { "version", no_argument, NULL, OPTION_VERSION },
        { NULL, 0, NULL, 0 }
 };
@@ -960,7 +959,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, "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)
                switch (op) {
 
                case 'a':
@@ -1321,7 +1320,7 @@ main(int argc, char **argv)
                        username = strdup(optarg);
                        break;
 
-               case OPTION_NUMBER:
+               case '#':
                        gndo->ndo_packet_number = 1;
                        break;
 
@@ -2499,7 +2498,7 @@ print_usage(void)
 {
        print_version();
        (void)fprintf(stderr,
-"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name);
+"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX#]" B_FLAG_USAGE " [ -c count ]\n", program_name);
        (void)fprintf(stderr,
 "\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n");
        (void)fprintf(stderr,