Diff between d9a75ab909ff90308bbd487096bd465216a29007 and 059884caae70c0d42be1362df1f30f4c80489b44

Changed Files

File Additions Deletions Status
monitor/main.c +1 -1 modified
monitor/packet.c +13 -0 modified
monitor/packet.h +3 -2 modified

Full Patch

diff --git a/monitor/main.c b/monitor/main.c
index 9307f52..4e32f22 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
 
 	mainloop_set_signal(&mask, signal_callback, NULL, NULL);
 
-	filter_mask |= PACKET_FILTER_SHOW_TIME;
+	filter_mask |= PACKET_FILTER_SHOW_TIME_OFFSET;
 
 	packet_set_filter(filter_mask);
 
diff --git a/monitor/packet.c b/monitor/packet.c
index 9145f21..59213e4 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -82,6 +82,7 @@
 		use_color() ? COLOR_OFF : ""); \
 } while (0);
 
+static time_t time_offset = ((time_t) -1);
 static unsigned long filter_mask = 0;
 
 void packet_set_filter(unsigned long filter)
@@ -152,6 +153,15 @@ static void print_packet(struct timeval *tv, uint16_t index, char ident,
 				ts_len += n;
 			}
 		}
+
+		if (filter_mask & PACKET_FILTER_SHOW_TIME_OFFSET) {
+			n = sprintf(ts_str + ts_pos, " %lu.%06lu",
+					tv->tv_sec - time_offset, tv->tv_usec);
+			if (n > 0) {
+				ts_pos += n;
+				ts_len += n;
+			}
+		}
 	}
 
 	if (use_color()) {
@@ -1221,6 +1231,9 @@ void packet_monitor(struct timeval *tv, uint16_t index, uint16_t opcode,
 	const struct monitor_new_index *ni;
 	char str[18], extra_str[24];
 
+	if (tv && time_offset == ((time_t) -1))
+		time_offset = tv->tv_sec;
+
 	switch (opcode) {
 	case MONITOR_NEW_INDEX:
 		ni = data;
diff --git a/monitor/packet.h b/monitor/packet.h
index 29fab66..711e35c 100644
--- a/monitor/packet.h
+++ b/monitor/packet.h
@@ -29,8 +29,9 @@
 #define PACKET_FILTER_SHOW_INDEX	(1 << 0)
 #define PACKET_FILTER_SHOW_DATE		(1 << 1)
 #define PACKET_FILTER_SHOW_TIME		(1 << 2)
-#define PACKET_FILTER_SHOW_ACL_DATA	(1 << 3)
-#define PACKET_FILTER_SHOW_SCO_DATA	(1 << 4)
+#define PACKET_FILTER_SHOW_TIME_OFFSET	(1 << 3)
+#define PACKET_FILTER_SHOW_ACL_DATA	(1 << 4)
+#define PACKET_FILTER_SHOW_SCO_DATA	(1 << 5)
 
 void packet_set_filter(unsigned long filter);
 void packet_add_filter(unsigned long filter);