From b19557cbf459018308d40e464baf62457b4058ee Mon Sep 17 00:00:00 2001 From: Sven Rebhan <36194019+srebhan@users.noreply.github.com> Date: Thu, 18 Jul 2024 06:06:59 +0200 Subject: [PATCH] feat(decoders.sflow): Add decoding of ethernet flow record (#336) --- decoders/sflow/sflow.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/decoders/sflow/sflow.go b/decoders/sflow/sflow.go index e5995b09..5eeceb1d 100644 --- a/decoders/sflow/sflow.go +++ b/decoders/sflow/sflow.go @@ -185,6 +185,20 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord, } sampledHeader.HeaderData = payload.Bytes() flowRecord.Data = sampledHeader + case FLOW_TYPE_ETH: + sampledEth := SampledEthernet{ + SrcMac: make([]byte, 6), + DstMac: make([]byte, 6), + } + if err := utils.BinaryDecoder(payload, + &sampledEth.Length, + sampledEth.SrcMac, + sampledEth.DstMac, + &sampledEth.EthType, + ); err != nil { + return flowRecord, &RecordError{header.DataFormat, err} + } + flowRecord.Data = sampledEth case FLOW_TYPE_IPV4: sampledIP := SampledIPv4{ SampledIPBase: SampledIPBase{