From: Francois-Xavier Le Bail Date: Thu, 10 Jul 2014 12:47:11 +0000 (+0200) Subject: add a short option '#', same as long option '--number' (print a packet number) X-Git-Tag: tcpdump-4.6.1~4 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/ce4ccb8a10c247ba36da448b9a9e86a5964acd2b add a short option '#', same as long option '--number' (print a packet number) --- diff --git a/tcpdump.1.in b/tcpdump.1.in index efc08653..b2cbe784 100644 --- a/tcpdump.1.in +++ b/tcpdump.1.in @@ -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 diff --git a/tcpdump.c b/tcpdump.c index 40b930d3..11dc8bc8 100644 --- 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,