tcpdump mailing list archives
[RFC PATCH 2/2] tcpdump: hw timestamp support
From: "Mcmillan, Scott A" <scott.a.mcmillan () intel com>
Date: Mon, 24 May 2010 07:26:53 -0700
[My apologies if this double posts. The mail server didn't care for the first submission.]
This patch adds the capability to select the packet timestamp source via the -j command line option.
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/tcpdump.c 2010-03-11 19:56:44.000000000 -0600
+++ b/tcpdump-4.1.1/tcpdump.c 2010-05-18 14:12:31.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 "j:KlLm:M:nNOpqr:Rs:StT:u" U_FLAG
"vw:W:xXy:Yz:Z:")) != -1)
switch (op) {
case 'a':
@@ -740,6 +743,17 @@
break;
#endif /* HAVE_PCAP_CREATE */
+ case 'j':
+#ifdef HAVE_LINUX_NET_TSTAMP_H
+ if (strcasecmp(optarg, "raw") == 0)
+ jflag = SOF_TIMESTAMPING_RAW_HARDWARE;
+ else if (strcasecmp(optarg, "nic") == 0)
+ jflag = SOF_TIMESTAMPING_SYS_HARDWARE;
+ else
+ error("unknown packet time source `%s'", optarg);
+#endif /* HAVE_LINUX_NET_TSTAMP_H */
+ break;
+
case 'l':
#ifdef WIN32
/*
@@ -1063,6 +1077,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)
