Permalink
Browse files

Fixed precision of timestmaps.

The C pcap library uses {sec,usec} for timestamps, where usec are
microsconds. Go's time.Time have nanosecond precisions, so we need
to convert between the two.
  • Loading branch information...
1 parent 2051aa6 commit c598ed4466dc0a0861a1bfb9a04b35d465175955 @tsg tsg committed Feb 24, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 pcap.go
View
@@ -107,7 +107,7 @@ func (p *Pcap) NextEx() (pkt *Packet, result int32) {
return
}
pkt = new(Packet)
- pkt.Time = time.Unix(int64(pkthdr.ts.tv_sec), int64(pkthdr.ts.tv_usec))
+ pkt.Time = time.Unix(int64(pkthdr.ts.tv_sec), int64(pkthdr.ts.tv_usec)*1000)
pkt.Caplen = uint32(pkthdr.caplen)
pkt.Len = uint32(pkthdr.len)
pkt.Data = make([]byte, pkthdr.caplen)

0 comments on commit c598ed4

Please sign in to comment.