-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbits.vest
More file actions
56 lines (48 loc) · 975 Bytes
/
Copy pathbits.vest
File metadata and controls
56 lines (48 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
!BIG_ENDIAN
version_ihl = bits {
version: u4,
ihl: u4,
}
cross_byte_span = bits {
prefix: u3,
span: u10,
suffix: u3,
}
payload_kind = enum {
Raw = 0u3,
Words = 1u3,
Tiny = 2u3,
...
}
packet_header = bits {
@kind: payload_kind,
@count: u5 | { 1..31 },
@len: u8,
}
choice_packet = {
@hdr: packet_header,
payload: choose(@hdr.kind) {
Raw => [u8; @hdr.len],
Words => [u16; @hdr.count],
Tiny => u8,
_ => [u8; @hdr.len],
},
}
closed_payload_kind = enum {
Raw = 0u3,
Words = 1u3,
Tiny = 2u3,
}
closed_packet_header = bits {
kind: closed_payload_kind,
count: u5 | { 1..31 },
len: u8,
}
closed_choice_packet = {
@hdr: closed_packet_header,
payload: choose(@hdr.kind) {
Raw => [u8; @hdr.len],
Words => [u16; @hdr.count],
Tiny => u8,
},
}