2021-11-23 00:08:36 +03:00
|
|
|
package pcap
|
|
|
|
|
|
|
|
// https://pcapng.github.io/pcapng/draft-ietf-opsawg-pcapng.html
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/binary"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/wader/fq/format"
|
2021-11-24 23:20:46 +03:00
|
|
|
"github.com/wader/fq/format/inet/flowsdecoder"
|
2021-11-23 00:08:36 +03:00
|
|
|
"github.com/wader/fq/pkg/decode"
|
2022-07-16 19:39:57 +03:00
|
|
|
"github.com/wader/fq/pkg/interp"
|
2021-12-02 00:48:25 +03:00
|
|
|
"github.com/wader/fq/pkg/scalar"
|
2021-11-23 00:08:36 +03:00
|
|
|
)
|
|
|
|
|
2022-01-03 22:17:01 +03:00
|
|
|
var pcapngLinkFrameFormat decode.Group
|
2021-11-24 23:20:46 +03:00
|
|
|
var pcapngTCPStreamFormat decode.Group
|
|
|
|
var pcapngIPvPacket4Format decode.Group
|
2021-11-23 00:08:36 +03:00
|
|
|
|
|
|
|
func init() {
|
2022-07-16 19:39:57 +03:00
|
|
|
interp.RegisterFormat(decode.Format{
|
2021-11-23 00:08:36 +03:00
|
|
|
Name: format.PCAPNG,
|
|
|
|
Description: "PCAPNG packet capture",
|
|
|
|
RootArray: true,
|
|
|
|
Groups: []string{format.PROBE},
|
|
|
|
Dependencies: []decode.Dependency{
|
2022-01-03 22:17:01 +03:00
|
|
|
{Names: []string{format.LINK_FRAME}, Group: &pcapngLinkFrameFormat},
|
2021-11-24 23:20:46 +03:00
|
|
|
{Names: []string{format.TCP_STREAM}, Group: &pcapngTCPStreamFormat},
|
|
|
|
{Names: []string{format.IPV4_PACKET}, Group: &pcapngIPvPacket4Format},
|
2021-11-23 00:08:36 +03:00
|
|
|
},
|
|
|
|
DecodeFn: decodePcapng,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
ngBigEndian = 0x1a2b3c4d
|
|
|
|
ngLittleEndian = 0x4d3c2b1a
|
|
|
|
)
|
|
|
|
|
2022-09-30 14:58:23 +03:00
|
|
|
var ngEndianMap = scalar.UintMapSymStr{
|
2021-11-23 00:08:36 +03:00
|
|
|
ngBigEndian: "big_endian",
|
|
|
|
ngLittleEndian: "little_endian",
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
blockTypeSectionHeader = 0x0a0d0d0a
|
|
|
|
blockTypeInterfaceDescription = 0x00000001
|
|
|
|
blockTypeNameResolution = 0x00000004
|
|
|
|
blockTypeInterfaceStatistics = 0x00000005
|
|
|
|
blockTypeEnhancedPacketBlock = 0x00000006
|
|
|
|
)
|
|
|
|
|
|
|
|
// from https://pcapng.github.io/pcapng/draft-ietf-opsawg-pcapng.html#section_block_code_registry
|
2022-09-30 14:58:23 +03:00
|
|
|
var blockTypeMap = scalar.UintMap{
|
2021-11-23 00:08:36 +03:00
|
|
|
blockTypeInterfaceDescription: {Sym: "interface_description", Description: "Interface Description Block"},
|
|
|
|
0x00000002: {Description: "Packet Block"},
|
|
|
|
0x00000003: {Description: "Simple Packet Block"},
|
|
|
|
blockTypeNameResolution: {Sym: "name_resolution", Description: "Name Resolution Block"},
|
|
|
|
blockTypeInterfaceStatistics: {Sym: "interface_statistics", Description: "Interface Statistics Block"},
|
|
|
|
blockTypeEnhancedPacketBlock: {Sym: "enhanced_packet", Description: "Enhanced Packet Block"},
|
|
|
|
0x00000007: {Description: "IRIG Timestamp Block"},
|
|
|
|
0x00000008: {Description: "ARINC 429 in AFDX Encapsulation Information Block"},
|
|
|
|
0x00000009: {Description: "systemd Journal Export Block"},
|
|
|
|
0x0000000a: {Description: "Decryption Secrets Block"},
|
|
|
|
0x00000101: {Description: "Hone Project Machine Info Block"},
|
|
|
|
0x00000102: {Description: "Hone Project Connection Event Block"},
|
|
|
|
0x00000201: {Description: "Sysdig Machine Info Block"},
|
|
|
|
0x00000202: {Description: "Sysdig Process Info Block, version 1"},
|
|
|
|
0x00000203: {Description: "Sysdig FD List Block"},
|
|
|
|
0x00000204: {Description: "Sysdig Event Block"},
|
|
|
|
0x00000205: {Description: "Sysdig Interface List Block"},
|
|
|
|
0x00000206: {Description: "Sysdig User List Block"},
|
|
|
|
0x00000207: {Description: "Sysdig Process Info Block, version 2"},
|
|
|
|
0x00000208: {Description: "Sysdig Event Block with flags"},
|
|
|
|
0x00000209: {Description: "Sysdig Process Info Block, version 3"},
|
|
|
|
0x00000210: {Description: "Sysdig Process Info Block, version 4"},
|
|
|
|
0x00000211: {Description: "Sysdig Process Info Block, version 5"},
|
|
|
|
0x00000212: {Description: "Sysdig Process Info Block, version 6"},
|
|
|
|
0x00000213: {Description: "Sysdig Process Info Block, version 7"},
|
|
|
|
0x00000bad: {Description: "Custom Block that rewriters can copy into new files"},
|
|
|
|
0x40000bad: {Description: "Custom Block that rewriters should not copy into new files"},
|
|
|
|
blockTypeSectionHeader: {Sym: "section_header", Description: "Section Header Block"},
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
optionEnd = 0
|
|
|
|
optionComment = 1
|
|
|
|
|
|
|
|
sectionHeaderOptionHardware = 2
|
|
|
|
sectionHeaderOptionOS = 3
|
|
|
|
sectionHeaderOptionUserAppl = 4
|
|
|
|
|
|
|
|
interfaceDescriptionName = 2
|
|
|
|
interfaceDescriptionDescription = 3
|
|
|
|
interfaceDescriptionIPv4addr = 4
|
|
|
|
interfaceDescriptionMACaddr = 6
|
|
|
|
interfaceDescriptionEUIaddr = 7
|
|
|
|
interfaceDescriptionSpeed = 8
|
|
|
|
interfaceDescriptionTsresol = 9
|
|
|
|
interfaceDescriptionTzone = 10
|
|
|
|
interfaceDescriptionFilter = 11
|
|
|
|
interfaceDescriptionOS = 12
|
|
|
|
interfaceDescriptionFcslen = 13
|
|
|
|
interfaceDescriptionTsoffset = 14
|
|
|
|
|
|
|
|
enhancedPacketFlags = 2
|
|
|
|
enhancedPacketHash = 3
|
|
|
|
enhancedPacketDropcount = 4
|
|
|
|
|
|
|
|
nameResolutionDNSName = 2
|
|
|
|
nameResolutionDNSIP4addr = 3
|
|
|
|
nameResolutionDNSIP6addr = 4
|
|
|
|
|
|
|
|
interfaceStatisticsStarttime = 2
|
|
|
|
interfaceStatisticsEndtime = 3
|
|
|
|
interfaceStatisticsIfRecv = 4
|
|
|
|
interfaceStatisticsIfDrop = 5
|
|
|
|
interfaceStatisticsFilterAccept = 6
|
|
|
|
interfaceStatisticsOSDrop = 7
|
|
|
|
interfaceStatisticsUsrdeliv = 8
|
|
|
|
)
|
|
|
|
|
2022-09-30 14:58:23 +03:00
|
|
|
var sectionHeaderOptionsMap = scalar.UintMap{
|
2021-11-23 00:08:36 +03:00
|
|
|
optionEnd: {Sym: "end", Description: "End of options"},
|
|
|
|
optionComment: {Sym: "comment", Description: "Comment"},
|
|
|
|
sectionHeaderOptionHardware: {Sym: "hardware"},
|
|
|
|
sectionHeaderOptionOS: {Sym: "os"},
|
|
|
|
sectionHeaderOptionUserAppl: {Sym: "userappl"},
|
|
|
|
}
|
|
|
|
|
2022-09-30 14:58:23 +03:00
|
|
|
var interfaceDescriptionOptionsMap = scalar.UintMap{
|
2021-11-23 00:08:36 +03:00
|
|
|
optionEnd: {Sym: "end", Description: "End of options"},
|
|
|
|
optionComment: {Sym: "comment", Description: "Comment"},
|
|
|
|
interfaceDescriptionName: {Sym: "name"},
|
|
|
|
interfaceDescriptionDescription: {Sym: "description"},
|
|
|
|
interfaceDescriptionIPv4addr: {Sym: "ipv4addr"},
|
|
|
|
interfaceDescriptionMACaddr: {Sym: "macaddr"},
|
|
|
|
interfaceDescriptionEUIaddr: {Sym: "euiaddr"},
|
|
|
|
interfaceDescriptionSpeed: {Sym: "speed"},
|
|
|
|
interfaceDescriptionTsresol: {Sym: "tsresol"},
|
|
|
|
interfaceDescriptionTzone: {Sym: "tzone"},
|
|
|
|
interfaceDescriptionFilter: {Sym: "filter"},
|
|
|
|
interfaceDescriptionOS: {Sym: "os"},
|
|
|
|
interfaceDescriptionFcslen: {Sym: "fcslen"},
|
|
|
|
interfaceDescriptionTsoffset: {Sym: "tsoffset"},
|
|
|
|
}
|
|
|
|
|
2022-09-30 14:58:23 +03:00
|
|
|
var enhancedPacketOptionsMap = scalar.UintMap{
|
2021-11-23 00:08:36 +03:00
|
|
|
optionEnd: {Sym: "end", Description: "End of options"},
|
|
|
|
optionComment: {Sym: "comment", Description: "Comment"},
|
|
|
|
enhancedPacketFlags: {Sym: "flags"},
|
|
|
|
enhancedPacketHash: {Sym: "hash"},
|
|
|
|
enhancedPacketDropcount: {Sym: "dropcount"},
|
|
|
|
}
|
|
|
|
|
2022-09-30 14:58:23 +03:00
|
|
|
var nameResolutionOptionsMap = scalar.UintMap{
|
2021-11-23 00:08:36 +03:00
|
|
|
optionEnd: {Sym: "end", Description: "End of options"},
|
|
|
|
optionComment: {Sym: "comment", Description: "Comment"},
|
|
|
|
nameResolutionDNSName: {Sym: "dnsname"},
|
|
|
|
nameResolutionDNSIP4addr: {Sym: "dnsip4addr"},
|
|
|
|
nameResolutionDNSIP6addr: {Sym: "dnsip6addr"},
|
|
|
|
}
|
|
|
|
|
2022-09-30 14:58:23 +03:00
|
|
|
var interfaceStatisticsOptionsMap = scalar.UintMap{
|
2021-11-23 00:08:36 +03:00
|
|
|
optionEnd: {Sym: "end", Description: "End of options"},
|
|
|
|
optionComment: {Sym: "comment", Description: "Comment"},
|
|
|
|
interfaceStatisticsStarttime: {Sym: "starttime"},
|
|
|
|
interfaceStatisticsEndtime: {Sym: "endtime"},
|
|
|
|
interfaceStatisticsIfRecv: {Sym: "ifrecv"},
|
|
|
|
interfaceStatisticsIfDrop: {Sym: "ifdrop"},
|
|
|
|
interfaceStatisticsFilterAccept: {Sym: "filteraccept"},
|
|
|
|
interfaceStatisticsOSDrop: {Sym: "osdrop"},
|
|
|
|
interfaceStatisticsUsrdeliv: {Sym: "usrdeliv"},
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
nameResolutionRecordEnd = 0x0000
|
|
|
|
nameResolutionRecordIpv4 = 0x0001
|
|
|
|
nameResolutionRecordIpv6 = 0x0002
|
|
|
|
)
|
|
|
|
|
2022-09-30 14:58:23 +03:00
|
|
|
var nameResolutionRecordMap = scalar.UintMapSymStr{
|
2021-11-23 00:08:36 +03:00
|
|
|
nameResolutionRecordEnd: "end",
|
|
|
|
nameResolutionRecordIpv4: "ipv4",
|
|
|
|
nameResolutionRecordIpv6: "ipv6",
|
|
|
|
}
|
|
|
|
|
2022-09-30 14:58:23 +03:00
|
|
|
func decoodeOptions(d *decode.D, opts scalar.UintMap) {
|
2021-11-23 00:08:36 +03:00
|
|
|
if d.BitsLeft() < 32 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
seenEnd := false
|
|
|
|
for !seenEnd {
|
|
|
|
d.FieldStruct("option", func(d *decode.D) {
|
2021-12-02 00:48:25 +03:00
|
|
|
code := d.FieldU16("code", opts)
|
2021-11-23 00:08:36 +03:00
|
|
|
length := d.FieldU16("length")
|
|
|
|
if code == optionEnd {
|
|
|
|
seenEnd = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
d.FieldUTF8NullFixedLen("value", int(length))
|
|
|
|
d.FieldRawLen("padding", int64(d.AlignBits(32)))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: share
|
2022-09-30 14:58:23 +03:00
|
|
|
var mapUToIPv4Sym = scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) {
|
2021-11-23 00:08:36 +03:00
|
|
|
var b [4]byte
|
2022-09-30 14:58:23 +03:00
|
|
|
binary.BigEndian.PutUint32(b[:], uint32(s.Actual))
|
2021-11-23 00:08:36 +03:00
|
|
|
s.Sym = net.IP(b[:]).String()
|
|
|
|
return s, nil
|
2021-12-02 00:48:25 +03:00
|
|
|
})
|
2021-11-23 00:08:36 +03:00
|
|
|
|
|
|
|
var blockFns = map[uint64]func(d *decode.D, dc *decodeContext){
|
2021-12-07 20:47:31 +03:00
|
|
|
// TODO: SimplePacket
|
|
|
|
// TODO: Packet
|
2021-11-23 00:08:36 +03:00
|
|
|
blockTypeInterfaceDescription: func(d *decode.D, dc *decodeContext) {
|
2021-12-02 00:48:25 +03:00
|
|
|
typ := d.FieldU16("link_type", format.LinkTypeMap)
|
2021-11-23 00:08:36 +03:00
|
|
|
d.FieldU16("reserved")
|
|
|
|
d.FieldU32("snap_len")
|
|
|
|
d.FieldArray("options", func(d *decode.D) { decoodeOptions(d, interfaceDescriptionOptionsMap) })
|
|
|
|
|
|
|
|
dc.interfaceTypes[len(dc.interfaceTypes)] = int(typ)
|
|
|
|
},
|
|
|
|
blockTypeEnhancedPacketBlock: func(d *decode.D, dc *decodeContext) {
|
|
|
|
interfaceID := d.FieldU32("interface_id")
|
|
|
|
d.FieldU32("timestamp_high")
|
|
|
|
d.FieldU32("timestamp_low")
|
|
|
|
capturedLength := d.FieldU32("capture_packet_length")
|
2021-12-07 20:47:31 +03:00
|
|
|
d.FieldU32("original_packet_length")
|
2021-11-23 00:08:36 +03:00
|
|
|
|
2022-06-30 13:13:36 +03:00
|
|
|
bs := d.ReadAllBits(d.BitBufRange(d.Pos(), int64(capturedLength)*8))
|
2021-11-24 23:20:46 +03:00
|
|
|
|
|
|
|
linkType := dc.interfaceTypes[int(interfaceID)]
|
|
|
|
|
|
|
|
if fn, ok := linkToDecodeFn[linkType]; ok {
|
2021-12-06 19:56:48 +03:00
|
|
|
// TODO: report decode errors
|
|
|
|
_ = fn(dc.flowDecoder, bs)
|
2021-11-24 23:20:46 +03:00
|
|
|
}
|
|
|
|
|
2022-04-11 23:45:46 +03:00
|
|
|
d.FieldFormatOrRawLen(
|
|
|
|
"packet",
|
|
|
|
int64(capturedLength)*8,
|
|
|
|
pcapngLinkFrameFormat,
|
|
|
|
format.LinkFrameIn{
|
|
|
|
Type: linkType,
|
|
|
|
IsLittleEndian: d.Endian == decode.LittleEndian,
|
|
|
|
},
|
|
|
|
)
|
2021-11-23 00:08:36 +03:00
|
|
|
|
|
|
|
d.FieldRawLen("padding", int64(d.AlignBits(32)))
|
|
|
|
d.FieldArray("options", func(d *decode.D) { decoodeOptions(d, enhancedPacketOptionsMap) })
|
|
|
|
},
|
|
|
|
blockTypeNameResolution: func(d *decode.D, _ *decodeContext) {
|
|
|
|
seenEnd := false
|
|
|
|
d.FieldArray("records", func(d *decode.D) {
|
|
|
|
for !seenEnd {
|
|
|
|
d.FieldStruct("record", func(d *decode.D) {
|
2021-12-02 00:48:25 +03:00
|
|
|
typ := d.FieldU16("type", nameResolutionRecordMap)
|
2021-11-23 00:08:36 +03:00
|
|
|
length := d.FieldU16("length")
|
|
|
|
if typ == nameResolutionRecordEnd {
|
|
|
|
seenEnd = true
|
|
|
|
return
|
|
|
|
}
|
2022-01-13 20:34:59 +03:00
|
|
|
d.FramedFn(int64(length)*8, func(d *decode.D) {
|
2021-11-23 00:08:36 +03:00
|
|
|
switch typ {
|
|
|
|
case nameResolutionRecordIpv4:
|
2022-09-30 14:58:23 +03:00
|
|
|
d.FieldU32BE("address", mapUToIPv4Sym, scalar.UintHex)
|
2021-11-23 00:08:36 +03:00
|
|
|
d.FieldArray("entries", func(d *decode.D) {
|
|
|
|
for !d.End() {
|
|
|
|
d.FieldUTF8Null("string")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
default:
|
|
|
|
d.FieldUTF8NullFixedLen("value", int(d.BitsLeft()/8))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
d.FieldRawLen("padding", int64(d.AlignBits(32)))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
d.FieldArray("options", func(d *decode.D) { decoodeOptions(d, nameResolutionOptionsMap) })
|
|
|
|
},
|
|
|
|
blockTypeInterfaceStatistics: func(d *decode.D, _ *decodeContext) {
|
|
|
|
d.FieldU32("interface_id")
|
|
|
|
d.FieldU32("timestamp_high")
|
|
|
|
d.FieldU32("timestamp_low")
|
|
|
|
d.FieldRawLen("padding", int64(d.AlignBits(32)))
|
|
|
|
d.FieldArray("options", func(d *decode.D) { decoodeOptions(d, interfaceStatisticsOptionsMap) })
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeBlock(d *decode.D, dc *decodeContext) {
|
2022-09-30 14:58:23 +03:00
|
|
|
typ := d.FieldU32("type", blockTypeMap, scalar.UintHex)
|
2021-11-23 00:08:36 +03:00
|
|
|
length := d.FieldU32("length") - 8
|
|
|
|
const footerLengthSize = 32
|
2022-01-23 14:38:41 +03:00
|
|
|
blockLen := int64(length)*8 - footerLengthSize
|
|
|
|
if blockLen <= 0 {
|
|
|
|
d.Fatalf("%d blockLen < 0", blockLen)
|
|
|
|
}
|
2022-01-13 20:34:59 +03:00
|
|
|
d.FramedFn(blockLen, func(d *decode.D) {
|
2021-11-23 00:08:36 +03:00
|
|
|
if fn, ok := blockFns[typ]; ok {
|
|
|
|
fn(d, dc)
|
|
|
|
} else {
|
|
|
|
d.FieldRawLen("data", d.BitsLeft())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
d.FieldU32("footer_length")
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeSection(d *decode.D, dc *decodeContext) {
|
|
|
|
d.FieldArray("blocks", func(d *decode.D) {
|
|
|
|
sectionLength := int64(-1)
|
|
|
|
sectionD := d
|
|
|
|
sectionStart := d.Pos()
|
|
|
|
|
|
|
|
// treat header block differently as it has endian info
|
|
|
|
d.FieldStruct("block", func(d *decode.D) {
|
2022-09-30 14:58:23 +03:00
|
|
|
d.FieldU32("type", d.UintAssert(blockTypeSectionHeader), blockTypeMap, scalar.UintHex)
|
2021-11-23 00:08:36 +03:00
|
|
|
|
|
|
|
d.SeekRel(32)
|
2022-09-30 14:58:23 +03:00
|
|
|
endian := d.FieldU32("byte_order_magic", ngEndianMap, scalar.UintHex)
|
2021-11-23 00:08:36 +03:00
|
|
|
// peeks length and byte-order magic and marks away length
|
|
|
|
switch endian {
|
|
|
|
case ngBigEndian:
|
|
|
|
d.Endian = decode.BigEndian
|
|
|
|
case ngLittleEndian:
|
|
|
|
d.Endian = decode.LittleEndian
|
|
|
|
default:
|
|
|
|
d.Fatalf("unknown endian %d", endian)
|
|
|
|
}
|
|
|
|
sectionD.Endian = d.Endian
|
|
|
|
d.SeekRel(-64)
|
|
|
|
length := d.FieldU32("length") - 8 - 4
|
|
|
|
d.SeekRel(32)
|
|
|
|
|
2022-01-13 20:34:59 +03:00
|
|
|
d.FramedFn(int64(length)*8, func(d *decode.D) {
|
2021-11-23 00:08:36 +03:00
|
|
|
d.FieldU16("major_version")
|
|
|
|
d.FieldU16("minor_version")
|
|
|
|
sectionLength = d.FieldS64("section_length")
|
2022-01-13 20:34:59 +03:00
|
|
|
d.FramedFn(d.BitsLeft()-32, func(d *decode.D) {
|
2021-11-23 00:08:36 +03:00
|
|
|
d.FieldArray("options", func(d *decode.D) { decoodeOptions(d, sectionHeaderOptionsMap) })
|
|
|
|
})
|
|
|
|
d.FieldU32("footer_total_length")
|
|
|
|
})
|
|
|
|
|
|
|
|
dc.sectionHeaderFound = true
|
|
|
|
})
|
|
|
|
|
2021-12-09 16:19:09 +03:00
|
|
|
for (sectionLength == -1 && !d.End()) ||
|
|
|
|
(sectionLength != -1 && d.Pos()-sectionStart < sectionLength*8) {
|
2021-11-23 00:08:36 +03:00
|
|
|
d.FieldStruct("block", func(d *decode.D) { decodeBlock(d, dc) })
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-11-24 23:20:46 +03:00
|
|
|
type decodeContext struct {
|
|
|
|
sectionHeaderFound bool
|
|
|
|
interfaceTypes map[int]int
|
|
|
|
flowDecoder *flowsdecoder.Decoder
|
|
|
|
}
|
|
|
|
|
2022-07-19 19:33:50 +03:00
|
|
|
func decodePcapng(d *decode.D, _ any) any {
|
2021-11-23 00:08:36 +03:00
|
|
|
sectionHeaders := 0
|
|
|
|
for !d.End() {
|
2023-01-28 22:48:31 +03:00
|
|
|
fd := flowsdecoder.New(flowsdecoder.DecoderOptions{CheckTCPOptions: false})
|
2021-11-23 00:08:36 +03:00
|
|
|
dc := decodeContext{
|
|
|
|
interfaceTypes: map[int]int{},
|
2021-11-24 23:20:46 +03:00
|
|
|
flowDecoder: fd,
|
2021-11-23 00:08:36 +03:00
|
|
|
}
|
2021-11-24 23:20:46 +03:00
|
|
|
|
2021-11-23 00:08:36 +03:00
|
|
|
d.FieldStruct("section", func(d *decode.D) {
|
|
|
|
decodeSection(d, &dc)
|
2021-11-24 23:20:46 +03:00
|
|
|
fd.Flush()
|
|
|
|
fieldFlows(d, dc.flowDecoder, pcapngTCPStreamFormat, pcapngIPvPacket4Format)
|
2021-11-23 00:08:36 +03:00
|
|
|
})
|
|
|
|
if dc.sectionHeaderFound {
|
|
|
|
sectionHeaders++
|
2021-11-24 23:20:46 +03:00
|
|
|
|
2021-11-23 00:08:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if sectionHeaders == 0 {
|
|
|
|
d.Fatalf("no section headers found")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|