]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
Print an optional packet number in the beginning of line
[tcpdump] / tcpdump.c
index fc86d32b4faef6e36a0d85ce09920d172321997d..b08e00f1d90943cb7b1449841592a20fed76b7fd 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -675,6 +675,7 @@ static struct option longopts[] = {
        { "debug-filter-parser", no_argument, NULL, 'Y' },
 #endif
        { "relinquish-privileges", required_argument, NULL, 'Z' },
+       { "number", no_argument, NULL, 'z' + 1},
        { NULL, 0, NULL, 0 }
 };
 
@@ -1256,6 +1257,10 @@ main(int argc, char **argv)
                        username = strdup(optarg);
                        break;
 
+               case 'z' + 1:
+                       gndo->ndo_packet_number = 1;
+                       break;
+
                default:
                        usage();
                        /* NOTREACHED */
@@ -2078,6 +2083,10 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 
        print_info = (struct print_info *)user;
         ndo = print_info->ndo;
+
+       if(ndo->ndo_packet_number)
+               ND_PRINT((ndo, "%5u  ", packets_captured));
+
        ts_print(ndo, &h->ts);
 
        /*
@@ -2266,7 +2275,7 @@ usage(void)
        (void)fprintf(stderr,
 "\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n");
        (void)fprintf(stderr,
-"\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ]\n");
+"\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ] [ --number ]\n");
 #ifdef HAVE_PCAP_SETDIRECTION
        (void)fprintf(stderr,
 "\t\t[ -Q in|out|inout ]\n");