Skip to content

Commit 053ebc6

Browse files
fixed pcapng
1 parent aad11ba commit 053ebc6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

mpcapng/write.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ func (pw *Writer) writeIdbOptions(in *net.Interface, expr string) ([]byte, error
198198
3 + // padding
199199
2 + // if_filter code
200200
2 + // if_filter length
201-
1 + // BPF string
202201
exprLen + // if_filter
203202
exprPad + // padding
204203
2 + // if_os code
@@ -246,7 +245,8 @@ func (pw *Writer) writeIdbOptions(in *net.Interface, expr string) ([]byte, error
246245
// https://www.ietf.org/archive/id/draft-tuexen-opsawg-pcapng-05.html#name-enhanced-packet-block
247246
func (pw *Writer) WritePacket(timestamp time.Time, data []byte) error {
248247
packetLen := len(data)
249-
blockLen := 4 + 4 + 4 + 4 + 4 + 4 + 4 + packetLen + 4
248+
padLen := pad(packetLen)
249+
blockLen := 4 + 4 + 4 + 4 + 4 + 4 + 4 + packetLen + padLen + 4
250250
binary.Write(pw.w, nativeEndian, epbBlockType)
251251
binary.Write(pw.w, nativeEndian, uint32(blockLen))
252252
binary.Write(pw.w, nativeEndian, interfaceID)
@@ -258,7 +258,7 @@ func (pw *Writer) WritePacket(timestamp time.Time, data []byte) error {
258258
if _, err := pw.w.Write(data); err != nil {
259259
return err
260260
}
261-
pw.w.Write(bytes.Repeat(zero, pad(packetLen)))
261+
pw.w.Write(bytes.Repeat(zero, padLen))
262262
binary.Write(pw.w, nativeEndian, uint32(blockLen))
263263
return nil
264264
}

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package mshark
22

3-
const Version string = "mshark v0.0.18"
3+
const Version string = "mshark v0.0.19"

0 commit comments

Comments
 (0)