-
Notifications
You must be signed in to change notification settings - Fork 51
/
constants.go
109 lines (79 loc) · 2.27 KB
/
constants.go
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package packet
const (
// minIPPacketLen is the min ip packet size
minIPPacketLen = 40
// minIPHdrSize
minIPHdrSize = 20
minIPHdrWords = (minIPHdrSize / 4)
)
// IP Header field position constants
const (
// ipHdrLenPos is location of IP (entire packet) length
ipHdrLenPos = 0
// ipLengthPos is location of IP (entire packet) length
ipLengthPos = 2
// ipIDPos is location of IP Identifier
IPIDPos = 4
// ipProtoPos is the location of the IP Protocol
ipProtoPos = 9
// ipChecksumPos is location of IP checksum
ipChecksumPos = 10
// ipSourceAddrPos is location of source IP address
ipSourceAddrPos = 12
// ipDestAddrPos is location of destination IP address
ipDestAddrPos = 16
)
// IP Protocol numbers
const (
// IPProtocolTCP defines the constant for UDP protocol number
IPProtocolTCP = 6
// IPProtocolUDP defines the constant for UDP protocol number
IPProtocolUDP = 17
)
// IP Header masks
const (
ipHdrLenMask = 0xF
)
// TCP Header field position constants
const (
// tcpSourcePortPos is the location of source port
tcpSourcePortPos = 20
// tcpDestPortPos is the location of destination port
tcpDestPortPos = 22
// tcpSeqPos is the location of seq
tcpSeqPos = 24
// tcpAckPos is the location of seq
tcpAckPos = 28
// tcpDataOffsetPos is the location of the TCP data offset
tcpDataOffsetPos = 32
//tcpFlagsOfsetPos is the location of the TCP flags
tcpFlagsOffsetPos = 33
// TCPChecksumPos is the location of TCP checksum
TCPChecksumPos = 36
)
// TCP Header masks
const (
// tcpDataOffsetMask is a mask for TCP data offset field
tcpDataOffsetMask = 0xF0
// TCPSynMask is a mask for the TCP Syn flags
TCPSynMask = 0x2
// TCPSynAckMask mask idenitifies a TCP SYN-ACK packet
TCPSynAckMask = 0x12
// TCPRstMask mask that identifies RST packets
TCPRstMask = 0x4
// TCPAckMask mask that identifies ACK packets
TCPAckMask = 0x10
// TCPFinMask mask that identifies FIN packets
TCPFinMask = 0x1
// TCPPshMask = 0x8 mask that identifies PSH packets
TCPPshMask = 0x8
)
// TCP Options Related constants
const (
// TCPAuthenticationOption is the option number will be using
TCPAuthenticationOption = uint8(34)
// TCPMssOption is the type for MSS option
TCPMssOption = uint8(2)
// TCPMssOptionLen is the type for MSS option
TCPMssOptionLen = uint8(4)
)