Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed precision of timestmaps. #21

Merged
merged 1 commit into from

2 participants

@tsg

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.

@tsg tsg 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.
c598ed4
@akrennmair akrennmair merged commit e9a12e1 into akrennmair:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 24, 2013
  1. @tsg

    Fixed precision of timestmaps.

    tsg authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  pcap.go
View
2  pcap.go
@@ -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)
Something went wrong with that request. Please try again.