From 9d718c83d4894f5012ff006cdde286ac09c69dda Mon Sep 17 00:00:00 2001 From: Georg Date: Tue, 1 Feb 2022 17:58:19 +0100 Subject: [PATCH 1/2] SourceID should be uint32 According to https://sflow.org/SFLOW-DATAGRAM5.txt the SourceID should be treated as uint32. --- sflow/flow_sample.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sflow/flow_sample.go b/sflow/flow_sample.go index 0a284673..f87f86e0 100644 --- a/sflow/flow_sample.go +++ b/sflow/flow_sample.go @@ -44,7 +44,7 @@ const ( // FlowSample represents single flow sample type FlowSample struct { SequenceNo uint32 // Incremented with each flow sample - SourceID byte // sfSourceID + SourceID uint32 // sfSourceID SamplingRate uint32 // sfPacketSamplingRate SamplePool uint32 // Total number of packets that could have been sampled Drops uint32 // Number of times a packet was dropped due to lack of resources From 68c7e456bdfa1183d6f13845bcb5e20cdc571fdc Mon Sep 17 00:00:00 2001 From: Georg Date: Tue, 1 Feb 2022 18:32:23 +0100 Subject: [PATCH 2/2] FlowSample.unmarshal do not skip 3 bytes of source_id SourceID is now a uint32 (4byte) instead of a byte. Previously the r.Seek skipped the 3 bytes that were not read, this is not necessary because we read in all the data. --- sflow/flow_sample.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/sflow/flow_sample.go b/sflow/flow_sample.go index f87f86e0..46222689 100644 --- a/sflow/flow_sample.go +++ b/sflow/flow_sample.go @@ -93,8 +93,6 @@ func (fs *FlowSample) unmarshal(r io.ReadSeeker) error { return err } - r.Seek(3, 1) // skip counter sample decoding - if err = read(r, &fs.SamplingRate); err != nil { return err }