diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-12 20:53:09 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-16 21:39:42 +0300 |
| commit | 82871ba1bac1d62f69e1933b66659e62d2e5e063 (patch) | |
| tree | a906310fba89b670bcfda9625a6d776553d482f6 /pkg/messages/types/svcCreateStringTable.go | |
| parent | net/svc messages finally getting parsed correctly (diff) | |
| download | sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.tar.gz sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.tar.bz2 sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.zip | |
another rewrite, v1.0.0
Diffstat (limited to 'pkg/messages/types/svcCreateStringTable.go')
| -rw-r--r-- | pkg/messages/types/svcCreateStringTable.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pkg/messages/types/svcCreateStringTable.go b/pkg/messages/types/svcCreateStringTable.go new file mode 100644 index 0000000..ed9e477 --- /dev/null +++ b/pkg/messages/types/svcCreateStringTable.go | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | package messages | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "math" | ||
| 5 | |||
| 6 | "github.com/pektezol/bitreader" | ||
| 7 | ) | ||
| 8 | |||
| 9 | type SvcCreateStringTable struct { | ||
| 10 | Name string | ||
| 11 | MaxEntries int16 | ||
| 12 | NumEntries int8 | ||
| 13 | Length int32 | ||
| 14 | UserDataFixedSize bool | ||
| 15 | UserDataSize int16 | ||
| 16 | UserDataSizeBits int8 | ||
| 17 | Flags int8 | ||
| 18 | StringData int | ||
| 19 | } | ||
| 20 | |||
| 21 | func ParseSvcCreateStringTable(reader *bitreader.ReaderType) SvcCreateStringTable { | ||
| 22 | svcCreateStringTable := SvcCreateStringTable{ | ||
| 23 | Name: reader.TryReadString(), | ||
| 24 | MaxEntries: int16(reader.TryReadBits(16)), | ||
| 25 | } | ||
| 26 | svcCreateStringTable.NumEntries = int8(reader.TryReadBits(int(math.Log2(float64(svcCreateStringTable.MaxEntries))) + 1)) | ||
| 27 | svcCreateStringTable.Length = int32(reader.TryReadBits(20)) | ||
| 28 | svcCreateStringTable.UserDataFixedSize = reader.TryReadBool() | ||
| 29 | if svcCreateStringTable.UserDataFixedSize { | ||
| 30 | svcCreateStringTable.UserDataSize = int16(reader.TryReadBits(12)) | ||
| 31 | svcCreateStringTable.UserDataSizeBits = int8(reader.TryReadBits(4)) | ||
| 32 | } | ||
| 33 | svcCreateStringTable.Flags = int8(reader.TryReadBits(2)) | ||
| 34 | reader.SkipBits(int(svcCreateStringTable.Length)) // TODO: StringTable parsing | ||
| 35 | return svcCreateStringTable | ||
| 36 | } | ||