aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-06-15 11:50:07 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-06-15 11:50:07 +0000
commitdd382a4e93b0edce7c56a41eda63d2e420a506b9 (patch)
tree3ef5addf02db373c03f058f64977dd70f80ba6e7
parentc6f62ab22a039cb5e41b7ce930e5c2738bca778f (diff)
downloadhcidump-dd382a4e93b0edce7c56a41eda63d2e420a506b9.tar.gz
Correct timestamp handling for btsnoop files
-rw-r--r--src/hcidump.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/hcidump.c b/src/hcidump.c
index 5337d92..bef05b1 100644
--- a/src/hcidump.c
+++ b/src/hcidump.c
@@ -233,12 +233,14 @@ static void process_frames(int dev, int sock, int fd, unsigned long flags)
case SEND:
/* Save or send dump */
if (flags & DUMP_BTSNOOP) {
+ uint64_t ts;
uint8_t pkt_type = ((uint8_t *) frm.data)[0];
dp->size = htonl(frm.data_len);
dp->len = dp->size;
dp->flags = ntohl(frm.in & 0x01);
dp->drops = 0;
- dp->ts = hton64(0);
+ ts = (frm.ts.tv_sec - 946684800ll) * 1000000ll + frm.ts.tv_usec;
+ dp->ts = hton64(ts + 0x00E03AB44A676000ll);
if (pkt_type == HCI_COMMAND_PKT ||
pkt_type == HCI_EVENT_PKT)
dp->flags |= ntohl(0x02);
@@ -324,11 +326,13 @@ static void read_dump(int fd)
frm.len = frm.data_len;
if (parser.flags & DUMP_BTSNOOP) {
- frm.in = ntohl(dp.flags) & 0x01;
- frm.ts.tv_sec = ntoh64(dp.ts) / 10000;
- frm.ts.tv_usec = ntoh64(dp.ts) % 10000;
+ uint64_t ts;
+ frm.in = ntohl(dp.flags) & 0x01;
+ ts = ntoh64(dp.ts) - 0x00E03AB44A676000ll;
+ frm.ts.tv_sec = (ts / 1000000ll) + 946684800ll;
+ frm.ts.tv_usec = ts % 1000000ll;
} else {
- frm.in = dh.in;
+ frm.in = dh.in;
frm.ts.tv_sec = btohl(dh.ts_sec);
frm.ts.tv_usec = btohl(dh.ts_usec);
}