MCPcopy Index your code
hub / github.com/google/gopacket / writePacketHeader

Method writePacketHeader

pcapgo/write.go:101–114  ·  view source on GitHub ↗
(ci gopacket.CaptureInfo)

Source from the content-addressed store, hash-verified

99const nanosPerNano = 1
100
101func (w *Writer) writePacketHeader(ci gopacket.CaptureInfo) error {
102 t := ci.Timestamp
103 if t.IsZero() {
104 t = time.Now()
105 }
106 secs := t.Unix()
107 usecs := t.Nanosecond() / w.tsScaler
108 binary.LittleEndian.PutUint32(w.buf[0:4], uint32(secs))
109 binary.LittleEndian.PutUint32(w.buf[4:8], uint32(usecs))
110 binary.LittleEndian.PutUint32(w.buf[8:12], uint32(ci.CaptureLength))
111 binary.LittleEndian.PutUint32(w.buf[12:16], uint32(ci.Length))
112 _, err := w.w.Write(w.buf[:])
113 return err
114}
115
116// WritePacket writes the given packet data out to the file.
117func (w *Writer) WritePacket(ci gopacket.CaptureInfo, data []byte) error {

Callers 1

WritePacketMethod · 0.95

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected