]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Merge pull request #743 from taghos/master
authorGuy Harris <[email protected]>
Wed, 3 Apr 2019 18:17:30 +0000 (11:17 -0700)
committerGitHub <[email protected]>
Wed, 3 Apr 2019 18:17:30 +0000 (11:17 -0700)
Add shortcuts for setting time stamp precision

1  2 
tcpdump.c

diff --combined tcpdump.c
index 7e2bc36d1f21805e12ac0ecab5f10abcf81e019c,c4b2c9c4e247c2b0c16988437da43f4afa4ffc60..52af74af5fbdcb581c0d555cd53e93a99383e55d
+++ b/tcpdump.c
@@@ -92,19 -92,6 +92,19 @@@ The Regents of the University of Califo
  #endif        /* HAVE_CASPER */
  #endif        /* HAVE_CAPSICUM */
  #ifdef HAVE_PCAP_OPEN
 +/*
 + * We found pcap_open() in the capture library, so we'll be using
 + * the remote capture APIs; define PCAP_REMOTE before we include pcap.h,
 + * so we get those APIs declared, and the types and #defines that they
 + * use defined.
 + *
 + * WinPcap's headers require that PCAP_REMOTE be defined in order to get
 + * remote-capture APIs declared and types and #defines that they use
 + * defined.
 + *
 + * (Versions of libpcap with those APIs, and thus Npcap, which is based on
 + * those versions of libpcap, don't require it.)
 + */
  #define HAVE_REMOTE
  #endif
  #include <pcap.h>
@@@ -683,6 -670,8 +683,8 @@@ show_remote_devices_and_exit(void
  #define OPTION_IMMEDIATE_MODE         130
  #define OPTION_PRINT                  131
  #define OPTION_LIST_REMOTE_INTERFACES 132
+ #define OPTION_TSTAMP_MICRO           133
+ #define OPTION_TSTAMP_NANO            134
  
  static const struct option longopts[] = {
  #if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
        { "list-time-stamp-types", no_argument, NULL, 'J' },
  #endif
  #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+       { "micro", no_argument, NULL, OPTION_TSTAMP_MICRO},
+       { "nano", no_argument, NULL, OPTION_TSTAMP_NANO},
        { "time-stamp-precision", required_argument, NULL, OPTION_TSTAMP_PRECISION},
  #endif
        { "dont-verify-checksums", no_argument, NULL, 'K' },
  #define IMMEDIATE_MODE_USAGE ""
  #endif
  
- #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
- #define TIME_STAMP_PRECISION_USAGE " [ --time-stamp-precision precision ]"
- #else
- #define TIME_STAMP_PRECISION_USAGE
- #endif
  #ifndef _WIN32
  /* Drop root privileges and chroot if necessary */
  static void
@@@ -1873,6 -1858,16 +1871,16 @@@ main(int argc, char **argv
                        print = 1;
                        break;
  
+ #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+               case OPTION_TSTAMP_MICRO:
+                       ndo->ndo_tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO;
+                       break;
+               case OPTION_TSTAMP_NANO:
+                       ndo->ndo_tstamp_precision = PCAP_TSTAMP_PRECISION_NANO;
+                       break;
+ #endif
                default:
                        print_usage();
                        exit_tcpdump(S_ERR_HOST_PROGRAM);
@@@ -3087,11 -3082,13 +3095,13 @@@ print_usage(void
        (void)fprintf(stderr,
  "\t\t[ -M secret ] [ --number ] [ --print ]" Q_FLAG_USAGE "\n");
        (void)fprintf(stderr,
- "\t\t[ -r file ] [ -s snaplen ]" TIME_STAMP_PRECISION_USAGE "\n");
+ "\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ --version ]\n");
        (void)fprintf(stderr,
- "\t\t[ -T type ] [ --version ] [ -V file ] [ -w file ]\n");
+ "\t\t[ -V file ] [ -w file ] [ -W filecount ] [ -y datalinktype ]\n");
+ #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
        (void)fprintf(stderr,
- "\t\t[ -W filecount ] [ -y datalinktype ]\n");
+ "\t\t[ --time-stamp-precision precision ] [ --micro ] [ --nano ]\n");
+ #endif
        (void)fprintf(stderr,
  "\t\t[ -z postrotate-command ] [ -Z user ] [ expression ]\n");
  }