diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-16 20:39:02 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-16 21:39:43 +0300 |
| commit | 81f365e99636104ff81151370048a51e8ae8027a (patch) | |
| tree | 0bd2781ad73fdc982abdcb70f9f44c551ac76bcf /pkg/messages/types/svcPacketEntities.go | |
| parent | update CI workflow for go 1.21.0 (diff) | |
| download | sdp.go-81f365e99636104ff81151370048a51e8ae8027a.tar.gz sdp.go-81f365e99636104ff81151370048a51e8ae8027a.tar.bz2 sdp.go-81f365e99636104ff81151370048a51e8ae8027a.zip | |
feat: parsing sar custom data (#4)
Diffstat (limited to 'pkg/messages/types/svcPacketEntities.go')
| -rw-r--r-- | pkg/messages/types/svcPacketEntities.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pkg/messages/types/svcPacketEntities.go b/pkg/messages/types/svcPacketEntities.go index b1c23e5..54e4a2a 100644 --- a/pkg/messages/types/svcPacketEntities.go +++ b/pkg/messages/types/svcPacketEntities.go | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | package messages | 1 | package messages |
| 2 | 2 | ||
| 3 | import "github.com/pektezol/bitreader" | 3 | import ( |
| 4 | "github.com/pektezol/bitreader" | ||
| 5 | ) | ||
| 4 | 6 | ||
| 5 | type SvcPacketEntities struct { | 7 | type SvcPacketEntities struct { |
| 6 | MaxEntries int16 | 8 | MaxEntries int16 |
| @@ -13,18 +15,23 @@ type SvcPacketEntities struct { | |||
| 13 | Data []byte | 15 | Data []byte |
| 14 | } | 16 | } |
| 15 | 17 | ||
| 16 | func ParseSvcPacketEntities(reader *bitreader.ReaderType) SvcPacketEntities { | 18 | func ParseSvcPacketEntities(reader *bitreader.Reader) SvcPacketEntities { |
| 17 | svcPacketEntities := SvcPacketEntities{ | 19 | svcPacketEntities := SvcPacketEntities{ |
| 18 | MaxEntries: int16(reader.TryReadBits(11)), | 20 | MaxEntries: int16(reader.TryReadBits(11)), |
| 19 | IsDelta: reader.TryReadBool(), | 21 | IsDelta: reader.TryReadBool(), |
| 20 | } | 22 | } |
| 21 | if svcPacketEntities.IsDelta { | 23 | if svcPacketEntities.IsDelta { |
| 22 | svcPacketEntities.DeltaFrom = int32(reader.TryReadBits(32)) | 24 | svcPacketEntities.DeltaFrom = int32(reader.TryReadBits(32)) |
| 25 | } else { | ||
| 26 | svcPacketEntities.DeltaFrom = -1 | ||
| 23 | } | 27 | } |
| 24 | svcPacketEntities.BaseLine = reader.TryReadBool() | 28 | svcPacketEntities.BaseLine = reader.TryReadBool() |
| 25 | svcPacketEntities.UpdatedEntries = int16(reader.TryReadBits(11)) | 29 | svcPacketEntities.UpdatedEntries = int16(reader.TryReadBits(11)) |
| 26 | svcPacketEntities.Length = int32(reader.TryReadBits(20)) | 30 | svcPacketEntities.Length = int32(reader.TryReadBits(20)) |
| 27 | svcPacketEntities.UpdatedBaseline = reader.TryReadBool() | 31 | svcPacketEntities.UpdatedBaseline = reader.TryReadBool() |
| 28 | svcPacketEntities.Data = reader.TryReadBitsToSlice(int(svcPacketEntities.Length)) | 32 | svcPacketEntities.Data = reader.TryReadBitsToSlice(uint64(svcPacketEntities.Length)) //, dataReader = reader.ForkAndSkip(int(svcPacketEntities.Length)) |
| 33 | // for count := 0; count < int(svcPacketEntities.UpdatedEntries); count++ { | ||
| 34 | // dataReader.TryReadBool() | ||
| 35 | // } | ||
| 29 | return svcPacketEntities | 36 | return svcPacketEntities |
| 30 | } | 37 | } |