tcpdump mailing list archives
Re: [RFC PATCH 2/2] tcpdump: hw timestamp support
From: "Mcmillan, Scott A" <scott.a.mcmillan () intel com>
Date: Thu, 27 May 2010 09:48:13 -0700
This is an updated patch for tcpdump-4.1.1 to add the capability to select hw timestamps via the -j command line option. The usage has been simplified: -j now takes no argument, and uses the hw timestamp transformed into the system clock basis corresponding to "-j nic" from the previous patch. I left the more generic libpcap infrastructure in place to support future extensions that may want more precise selection of the timestamp source. Thanks to Zhuo Yin who pointed out that I omitted netdissect.h from the original patch. I will upload both patches to SourceForge once the PACKET_TIMESTAMP patch is accepted by the Linux netdev maintainer. Signed-off-by: Scott McMillan <scott.a.mcmillan () intel com> --- a/tcpdump-4.1.1/interface.h 2010-03-11 19:56:44.000000000 -0600 +++ b/tcpdump-4.1.1/interface.h 2010-05-18 14:10:32.000000000 -0500 @@ -356,6 +356,7 @@ #define bflag gndo->ndo_bflag #define eflag gndo->ndo_eflag #define fflag gndo->ndo_fflag +#define jflag gndo->ndo_jflag #define Kflag gndo->ndo_Kflag #define nflag gndo->ndo_nflag #define Nflag gndo->ndo_Nflag --- a/tcpdump-4.1.1/netdissect.h 2010-03-11 19:56:44.000000000 -0600 +++ b/tcpdump-4.1.1/netdissect.h 2010-05-18 14:10:32.000000000 -0500 @@ -107,6 +107,7 @@ int ndo_Iflag; /* rfmon (monitor) mode */ int ndo_Oflag; /* run filter code optimizer */ int ndo_dlt; /* if != -1, ask libpcap for the DLT it names*/ + int ndo_jflag; /* packet time source */ int ndo_pflag; /* don't go promiscuous */ int ndo_Cflag; /* rotate dump files after this many bytes */ --- a/tcpdump-4.1.1/tcpdump.c 2010-03-11 19:56:44.000000000 -0600 +++ b/tcpdump-4.1.1/tcpdump.c 2010-05-27 10:10:58.000000000 -0500 @@ -74,6 +74,9 @@ #include <errno.h> #endif /* WIN32 */ +#ifdef HAVE_LINUX_NET_TSTAMP_H +#include <linux/net_tstamp.h> +#endif /* HAVE_LINUX_NET_TSTAMP_H */ #include "netdissect.h" #include "interface.h" @@ -600,7 +603,7 @@ opterr = 0; while ( - (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) + (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "jKlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) switch (op) { case 'a': @@ -740,6 +743,14 @@ break; #endif /* HAVE_PCAP_CREATE */ + case 'j': +#ifdef HAVE_LINUX_NET_TSTAMP_H + jflag = SOF_TIMESTAMPING_SYS_HARDWARE; +#else + warning("not compiled with hw timestamp support"); +#endif /* HAVE_LINUX_NET_TSTAMP_H */ + break; + case 'l': #ifdef WIN32 /* @@ -1063,6 +1074,12 @@ error("%s: pcap_set_buffer_size failed: %s", device, pcap_statustostr(status)); } + if (jflag != 0) { + status = pcap_set_timesource(pd, jflag); + if (status != 0) + warning("%s: pcap_set_timesource failed: %s", + device, pcap_statustostr(status)); + } status = pcap_activate(pd); if (status < 0) { /* --- a/tcpdump-4.1.1/configure.in 2010-04-05 20:18:35.000000000 -0500 +++ b/tcpdump-4.1.1/configure.in 2010-05-18 14:10:32.000000000 -0500 @@ -1076,6 +1076,16 @@ fi fi +dnl check for hardware timestamp support +case "$host_os" in +linux*) + AC_CHECK_HEADERS([linux/net_tstamp.h]) + ;; +*) + AC_MSG_NOTICE(no hardware timestamp support) + ;; +esac + dnl dnl set additional include path if necessary if test "$missing_includes" = "yes"; then - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- [RFC PATCH 2/2] tcpdump: hw timestamp support Mcmillan, Scott A (May 24)
- Re: [RFC PATCH 2/2] tcpdump: hw timestamp support Mcmillan, Scott A (May 27)
- Re: [RFC PATCH 2/2] tcpdump: hw timestamp support Guy Harris (May 28)
- Re: [RFC PATCH 2/2] tcpdump: hw timestamp support Mcmillan, Scott A (May 27)