From ec2c6ad0658638552ca547a695953609f3b7bd9c Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Mon, 29 Apr 2013 22:45:53 +0200 Subject: dissector: show sw/hw timestamp source Now, with PF_PACKET's extension, we can see what kind of sw/hw timestamp is being reported to us [1]. Thus, report it in the dissector. [1] http://thread.gmane.org/gmane.linux.network/266878/ Signed-off-by: Daniel Borkmann --- built_in.h | 12 ++++++++++++ dissector.h | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/built_in.h b/built_in.h index ee97c74..72618a0 100644 --- a/built_in.h +++ b/built_in.h @@ -341,4 +341,16 @@ static inline u64 cpu_to_le64(u64 val) # define CO_IN_CACHE_SHIFT 5 #endif +#ifndef TP_STATUS_TS_SOFTWARE +# define TP_STATUS_TS_SOFTWARE (1 << 29) +#endif + +#ifndef TP_STATUS_TS_SYS_HARDWARE +# define TP_STATUS_TS_SYS_HARDWARE (1 << 30) +#endif + +#ifndef TP_STATUS_TS_RAW_HARDWARE +# define TP_STATUS_TS_RAW_HARDWARE (1 << 31) +#endif + #endif /* BUILT_IN_H */ diff --git a/dissector.h b/dissector.h index fc2cd5a..d211e06 100644 --- a/dissector.h +++ b/dissector.h @@ -13,6 +13,7 @@ #include "ring.h" #include "tprintf.h" #include "pcap_io.h" +#include "built_in.h" #define PRINT_NORM 0 #define PRINT_LESS 1 @@ -32,6 +33,18 @@ static const char * const packet_types[256]={ extern char *if_indextoname(unsigned ifindex, char *ifname); +static inline const char *__show_ts_source(uint32_t status) +{ + if (status & TP_STATUS_TS_RAW_HARDWARE) + return "(raw hw ts)"; + else if (status & TP_STATUS_TS_SYS_HARDWARE) + return "(sys hw ts)"; + else if (status & TP_STATUS_TS_SOFTWARE) + return "(sw ts)"; + else + return ""; +} + static inline void show_frame_hdr(struct frame_map *hdr, int mode) { char tmp[IFNAMSIZ]; @@ -47,11 +60,12 @@ static inline void show_frame_hdr(struct frame_map *hdr, int mode) hdr->tp_h.tp_len); break; default: - tprintf("%s %s %u %us.%uns\n", + tprintf("%s %s %u %us.%uns %s\n", packet_types[hdr->s_ll.sll_pkttype] ? : "?", if_indextoname(hdr->s_ll.sll_ifindex, tmp) ? : "?", hdr->tp_h.tp_len, hdr->tp_h.tp_sec, - hdr->tp_h.tp_nsec); + hdr->tp_h.tp_nsec, + __show_ts_source(hdr->tp_h.tp_status)); break; } } -- cgit v1.2.3-54-g00ecf