draft in progress
This commit is contained in:
60
docs/data/parse.py
Executable file
60
docs/data/parse.py
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
################################################################################################################################
|
||||
## WireProto Specification © 2024 by Brent Saner is licensed under Creative Commons Attribution-ShareAlike 4.0 International. ##
|
||||
## To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/4.0/ ##
|
||||
################################################################################################################################
|
||||
|
||||
import binascii
|
||||
import re
|
||||
import zlib
|
||||
|
||||
prefixes = ('request', 'response')
|
||||
suffixes = ('simple', 'multi')
|
||||
|
||||
linecharlimit = 80
|
||||
linestrp = re.compile(r'^\s*(?P<hex>[A-Fa-f0-9N]+)?(?:\s*//.*)?$')
|
||||
|
||||
|
||||
def parse(text):
|
||||
ret = []
|
||||
bytelen = 0
|
||||
for line in text.splitlines():
|
||||
m = linestrp.search(line)
|
||||
if not m:
|
||||
continue
|
||||
if not m.group('hex'):
|
||||
continue
|
||||
ret.append(m.group('hex'))
|
||||
raw = ''.join(ret)
|
||||
bytelen = int(len(raw) / 2)
|
||||
ret = []
|
||||
block = ''
|
||||
for idx, c in enumerate(raw):
|
||||
block = block + c
|
||||
if len(block) == linecharlimit:
|
||||
ret.append(block)
|
||||
block = ''
|
||||
if block:
|
||||
ret.append(block)
|
||||
return(('\n'.join(ret), bytelen))
|
||||
|
||||
|
||||
for p in prefixes:
|
||||
for s in suffixes:
|
||||
fnamebase = '{0}.{1}'.format(p, s)
|
||||
fname = '{0}.txt'.format(fnamebase)
|
||||
with open(fname, 'r') as fh:
|
||||
raw = fh.read().strip()
|
||||
hexstr, bytelen = parse(raw)
|
||||
with open('{0}.hex'.format(fnamebase), 'w') as fh:
|
||||
fh.write(hexstr)
|
||||
fh.write('\n')
|
||||
b = binascii.unhexlify(hexstr.replace('\n', '').strip().encode('utf-8'))
|
||||
repr = ['0x{0}'.format(format(i, '02x')) for i in b]
|
||||
repr_split = []
|
||||
for i in range(0, len(repr), 16):
|
||||
repr_split.append(repr[i:i + 16])
|
||||
print(fnamebase)
|
||||
for i in repr_split:
|
||||
print(', '.join(i), end = ',\n')
|
||||
7
docs/data/request.multi.hex
Normal file
7
docs/data/request.multi.hex
Normal file
@@ -0,0 +1,7 @@
|
||||
01000000010200000002000000f00000000200000070000000020000003000000008000000086669
|
||||
656c6441314176616c756541314100000008000000086669656c6441314276616c75654131420000
|
||||
00020000003000000008000000086669656c6441324176616c756541324100000008000000086669
|
||||
656c6441324276616c75654132420000000200000070000000020000003000000008000000086669
|
||||
656c6442314176616c756542314100000008000000086669656c6442314276616c75654231420000
|
||||
00020000003000000008000000086669656c6442324176616c756542324100000008000000086669
|
||||
656c6442324276616c75654232420304
|
||||
67
docs/data/request.multi.txt
Normal file
67
docs/data/request.multi.txt
Normal file
@@ -0,0 +1,67 @@
|
||||
// REQUEST (Complex)
|
||||
-------- // (No Checksum Present)
|
||||
01 // HDR:MSGSTART
|
||||
00000001 // Protocol Version (1)
|
||||
02 // HDR:BODYSTART
|
||||
00000002 // Record Group Count (2)
|
||||
000000f0 // Record Groups Size (240)
|
||||
// Record Group 1 (120 bytes)
|
||||
00000002 // Record Count (2)
|
||||
00000070 // Record Group Size (112)
|
||||
// Record Group 1, Record 1 (56 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000030 // Record Size (48)
|
||||
// Record Group 1, Record 1, Field/Value 1 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64413141 // "fieldA1A"
|
||||
76616c7565413141 // "valueA1A"
|
||||
// Record Group 1, Record 1, Field/Value 2 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64413142 // "fieldA1B"
|
||||
76616c7565413142 // "valueA1B"
|
||||
// Record Group 1, Record 2 (56 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000030 // Record Size (48)
|
||||
// Record Group 1, Record 2, Field/Value 1 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64413241 // "fieldA2A"
|
||||
76616c7565413241 // "valueA2A"
|
||||
// Record Group 1, Record 2, Field/Value 2 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64413242 // "fieldA2B"
|
||||
76616c7565413242 // "valueA2B"
|
||||
// Record Group 2 (120 bytes)
|
||||
00000002 // Record Count (2)
|
||||
00000070 // Record Group Size (112)
|
||||
// Record Group 2, Record 1 (56 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000030 // Record Size (48)
|
||||
// Record Group 2, Record 1, Field/Value 1 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64423141 // "fieldB1A"
|
||||
76616c7565423141 // "valueB1A"
|
||||
// Record Group 2, Record 1, Field/Value 2 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64423142 // "fieldB1B"
|
||||
76616c7565423142 // "valueB1B"
|
||||
// Record Group 2, Record 2 (56 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000030 // Record Size (48)
|
||||
// Record Group 2, Record 2, Field/Value 1 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64423241 // "fieldB2A"
|
||||
76616c7565423241 // "valueB2A"
|
||||
// Record Group 2, Record 2, Field/Value 2 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64423242 // "fieldB2B"
|
||||
76616c7565423242 // "valueB2B"
|
||||
03 // HDR:BODYEND
|
||||
04 // HDR:MSGEND
|
||||
2
docs/data/request.simple.hex
Normal file
2
docs/data/request.simple.hex
Normal file
@@ -0,0 +1,2 @@
|
||||
01000000010200000001000000380000000100000030000000020000002800000006000000066669
|
||||
656c643176616c75653100000006000000066669656c643276616c7565320304
|
||||
25
docs/data/request.simple.txt
Normal file
25
docs/data/request.simple.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
// REQUEST (Simple)
|
||||
-------- // (No Checksum Present)
|
||||
01 // HDR:MSGSTART
|
||||
00000001 // Protocol Version (1)
|
||||
02 // HDR:BODYSTART
|
||||
00000001 // Record Group Count (1)
|
||||
00000038 // Record Groups Size (56)
|
||||
// Record Group 1 (56 bytes)
|
||||
00000001 // Record Count (1)
|
||||
00000030 // Record Group Size (48)
|
||||
// Record Group 1, Record 1 (48 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000028 // Record Size (40)
|
||||
// Record Group 1, Record 1, Field/Value 1 (20 bytes)
|
||||
00000006 // Field Name Size (6)
|
||||
00000006 // Field Value Size (6)
|
||||
6669656c6431 // "field1"
|
||||
76616c756531 // "value1"
|
||||
// Record Group 1, Record 1, Field/Value 2 (20 bytes)
|
||||
00000006 // Field Name Size (6)
|
||||
00000006 // Field Value Size (6)
|
||||
6669656c6432 // "field2"
|
||||
76616c756532 // "value2"
|
||||
03 // HDR:BODYEND
|
||||
04 // HDR:MSGEND
|
||||
11
docs/data/response.multi.hex
Normal file
11
docs/data/response.multi.hex
Normal file
@@ -0,0 +1,11 @@
|
||||
061bd0ba719f010000000102000000020000019800000002000000c4000000010000001e00000038
|
||||
00000006000000106461746141313c61726269747261727920646174613e00000002000000300000
|
||||
0008000000086669656c6441314176616c756541314100000008000000086669656c644131427661
|
||||
6c7565413142000000010000001e0000003800000006000000106461746141323c61726269747261
|
||||
727920646174613e000000020000003000000008000000086669656c6441324176616c7565413241
|
||||
00000008000000086669656c6441324276616c756541324200000002000000c4000000010000001e
|
||||
0000003800000006000000106461746142313c61726269747261727920646174613e000000020000
|
||||
003000000008000000086669656c6442314176616c756542314100000008000000086669656c6442
|
||||
314276616c7565423142000000010000001e0000003800000006000000106461746142323c617262
|
||||
69747261727920646174613e000000020000003000000008000000086669656c6442324176616c75
|
||||
6542324100000008000000086669656c6442324276616c75654232420304
|
||||
109
docs/data/response.multi.txt
Normal file
109
docs/data/response.multi.txt
Normal file
@@ -0,0 +1,109 @@
|
||||
// RESPONSE (Complex)
|
||||
06 // HDR:RESPSTART (Status: OK)
|
||||
1b // HDR:CKSUM
|
||||
d0ba719f // Checksum Value (3501879711)
|
||||
01 // HDR:MSGSTART
|
||||
00000001 // Protocol Version (1)
|
||||
02 // HDR:BODYSTART
|
||||
00000002 // Record Group Count (2)
|
||||
00000198 // Record Groups Size (408)
|
||||
// Record Group 1 (204)
|
||||
00000002 // Record Count (2)
|
||||
000000c4 // Record Group Size (196)
|
||||
// Record Group 1, Record 1 (98 bytes)
|
||||
00000001 // Field/Value Count (1)
|
||||
0000001e // Record Size (30)
|
||||
00000038 // Request Record Size (56)
|
||||
// Record Group 1, Record 1, Field/Value 1 (30 bytes)
|
||||
00000006 // Field Name Size (6)
|
||||
00000010 // Field Value Size (16)
|
||||
646174614131 // "dataA1"
|
||||
3c6172626974726172792064 // "<arbitrary data>"
|
||||
6174613e
|
||||
// Record Group 1, Record 1 (REQUEST RECORD) (56 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000030 // Record Size (48)
|
||||
// Record Group 1, Record 1, Field/Value 1 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64413141 // "fieldA1A"
|
||||
76616c7565413141 // "valueA1A"
|
||||
// Record Group 1, Record 1, Field/Value 2 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64413142 // "fieldA1B"
|
||||
76616c7565413142 // "valueA1B"
|
||||
// Record Group 1, Record 2 (98 bytes)
|
||||
00000001 // Field/Value Count (1)
|
||||
0000001e // Record Size (30)
|
||||
00000038 // Request Record Size (56)
|
||||
// Record Group 1, Record 2, Field/Value 1 (30 bytes)
|
||||
00000006 // Field Name Size (6)
|
||||
00000010 // Field Value Size (16)
|
||||
646174614132 // "dataA2"
|
||||
3c6172626974726172792064 // "<arbitrary data>"
|
||||
6174613e
|
||||
// Record Group 1, Record 2 (REQUEST RECORD) (56 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000030 // Record Size (48)
|
||||
// Record Group 1, Record 2, Field/Value 1 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64413241 // "fieldA2A"
|
||||
76616c7565413241 // "valueA2A"
|
||||
// Record Group 1, Record 2, Field/Value 2 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64413242 // "fieldA2B"
|
||||
76616c7565413242 // "valueA2B"
|
||||
// Record Group 2 (204)
|
||||
00000002 // Record Count (2)
|
||||
000000c4 // Record Group Size (196)
|
||||
// Record Group 2, Record 1 (98 bytes)
|
||||
00000001 // Field/Value Count (1)
|
||||
0000001e // Record Size (30)
|
||||
00000038 // Request Record Size (56)
|
||||
// Record Group 2, Record 1, Field/Value 1 (30 bytes)
|
||||
00000006 // Field Name Size (6)
|
||||
00000010 // Field Value Size (16)
|
||||
646174614231 // "dataB1"
|
||||
3c6172626974726172792064 // "<arbitrary data>"
|
||||
6174613e
|
||||
// Record Group 2, Record 1 (REQUEST RECORD) (56 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000030 // Record Size (48)
|
||||
// Record Group 2, Record 1, Field/Value 1 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64423141 // "fieldB1A"
|
||||
76616c7565423141 // "valueB1A"
|
||||
// Record Group 2, Record 1, Field/Value 2 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64423142 // "fieldB1B"
|
||||
76616c7565423142 // "valueB1B"
|
||||
// Record Group 2, Record 2 (98 bytes)
|
||||
00000001 // Field/Value Count (1)
|
||||
0000001e // Record Size (30)
|
||||
00000038 // Request Record Size (56)
|
||||
// Record Group 2, Record 2, Field/Value 1 (30 bytes)
|
||||
00000006 // Field Name Size (6)
|
||||
00000010 // Field Value Size (16)
|
||||
646174614232 // "dataB2"
|
||||
3c6172626974726172792064 // "<arbitrary data>"
|
||||
6174613e
|
||||
// Record Group 2, Record 2 (REQUEST RECORD) (56 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000030 // Record Size (48)
|
||||
// Record Group 2, Record 2, Field/Value 1 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64423241 // "fieldB2A"
|
||||
76616c7565423241 // "valueB2A"
|
||||
// Record Group 2, Record 2, Field/Value 2 (24 bytes)
|
||||
00000008 // Field Name Size (8)
|
||||
00000008 // Field Value Size (8)
|
||||
6669656c64423242 // "fieldB2B"
|
||||
76616c7565423242 // "valueB2B"
|
||||
03 // HDR:BODYEND
|
||||
04 // HDR:MSGEND
|
||||
3
docs/data/response.simple.hex
Normal file
3
docs/data/response.simple.hex
Normal file
@@ -0,0 +1,3 @@
|
||||
061b5fde82e501000000010200000001000000610000000100000059000000010000001d00000030
|
||||
000000050000001064617461313c61726269747261727920646174613e0000000200000028000000
|
||||
06000000066669656c643176616c75653100000006000000066669656c643276616c7565320304
|
||||
37
docs/data/response.simple.txt
Normal file
37
docs/data/response.simple.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
// RESPONSE (Simple)
|
||||
06 // HDR:RESPSTART (Status: OK)
|
||||
1b // HDR:CKSUM
|
||||
5fde82e5 // Checksum Value (1608418021)
|
||||
01 // HDR:MSGSTART
|
||||
00000001 // Protocol Version (1)
|
||||
02 // HDR:BODYSTART
|
||||
00000001 // Record Group Count (1)
|
||||
00000061 // Record Groups Size (97)
|
||||
// Record Group 1 (97)
|
||||
00000001 // Record Count (1)
|
||||
00000059 // Record Group Size (89)
|
||||
// Record Group 1, Record 1 (89 bytes)
|
||||
00000001 // Field/Value Count (1)
|
||||
0000001d // Record Size (29)
|
||||
00000030 // Request Record Size (48)
|
||||
// Record Group 1, Record 1, Field/Value 1 (29 bytes)
|
||||
00000005 // Field Name Size (5)
|
||||
00000010 // Field Value Size (16)
|
||||
6461746131 // "data1"
|
||||
3c6172626974726172792064 // "<arbitrary data>"
|
||||
6174613e
|
||||
// Record Group 1, Record 1 (REQUEST RECORD) (48 bytes)
|
||||
00000002 // Field/Value Count (2)
|
||||
00000028 // Record Size (40)
|
||||
// Record Group 1, Record 1, Field/Value 1 (20 bytes)
|
||||
00000006 // Field Name Size (6)
|
||||
00000006 // Field Value Size (6)
|
||||
6669656c6431 // "field1"
|
||||
76616c756531 // "value1"
|
||||
// Record Group 1, Record 1, Field/Value 2 (20 bytes)
|
||||
00000006 // Field Name Size (6)
|
||||
00000006 // Field Value Size (6)
|
||||
6669656c6432 // "field2"
|
||||
76616c756532 // "value2"
|
||||
03 // HDR:BODYEND
|
||||
04 // HDR:MSGEND
|
||||
Reference in New Issue
Block a user