-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcommon.typ
73 lines (65 loc) · 2.34 KB
/
common.typ
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#import "lib/api.typ": *
// Common network protocols
#let ipv4 = bytefield(
bitheader("bytes"),
bits(4)[Version], bits(4)[IHL], bytes(1)[TOS], bytes(2)[Total Length],
bytes(2)[Identification], bits(3)[Flags], bits(13)[Fragment Offset],
bytes(1)[TTL], bytes(1)[Protocol], bytes(2)[Header Checksum],
bytes(4)[Source Address],
bytes(4)[Destination Address],
bytes(3)[Options], bytes(1)[Padding]
)
#let ipv6 = bytefield(
bitheader("bytes"),
bits(4)[Version], bytes(1)[Traffic Class], bits(20)[Flowlabel],
bytes(2)[Payload Length], bytes(1)[Next Header], bytes(1)[Hop Limit],
bytes(int(128/8))[Source Address],
bytes(int(128/8))[Destination Address],
)
#let icmp = bytefield(
bitheader("bytes"),
byte[Type], byte[Code], bytes(2)[Checksum],
bytes(2)[Identifier], bytes(2)[Sequence Number],
bits(auto)[Optional Data]
)
#let icmpv6 = bytefield(
bitheader("bytes"),
byte[Type], byte[Code], bytes(2)[Checksum],
bits(auto)[Internet Header + 64 bits of Original Data Datagram]
)
#let dns = bytefield(
bitheader("bytes"),
bytes(2)[Identification], bytes(2)[Flags],
bytes(2)[Number of Questions], bytes(2)[Number of answer RRs],
bytes(2)[Number of authority RRs], bytes(2)[Number of additional RRs],
bytes(8)[Questions],
bytes(8)[Answers (variable number of resource records)],
bytes(8)[Authority (variable number of resource records)],
bytes(8)[Additional information (variable number of resource records)],
)
#let tcp = bytefield(
bitheader("bytes"),
bytes(2)[Source Port], bytes(2)[Destination Port],
bytes(4)[Sequence Number],
bytes(4)[Acknowledgment Number],
bits(4)[Data Offset],bits(6)[Reserved], bits(6)[Flags], bytes(2)[Window],
bytes(2)[Checksum], bytes(2)[Urgent Pointer],
bytes(3)[Options], byte[Padding],
bits(auto)[...DATA...]
)
#let tcp_detailed = bytefield(
bitheader("bytes"),
bytes(2)[Source Port], bytes(2)[ Destination Port],
bytes(4)[Sequence Number],
bytes(4)[Acknowledgment Number],
bits(4)[Data Offset],bits(6)[Reserved], flag("URG"), flag("ACK"), flag("PSH"), flag("RST"), flag("SYN"), flag("FIN"), bytes(2)[Window],
bytes(2)[Checksum], bytes(2)[Urgent Pointer],
bytes(3)[Options], byte[Padding],
bits(auto)[...DATA...]
)
#let udp = bytefield(
bitheader("bytes"),
bytes(2)[Source Port], bytes(2)[ Destination Port],
bytes(2)[Length], bytes(2)[Checksum],
bits(auto)[...DATA...]
)