-
Notifications
You must be signed in to change notification settings - Fork 51
/
constants.go
145 lines (114 loc) · 3.45 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package packet
const (
// minIPPacketLen is the min ip packet size for TCP packet
minTCPIPPacketLen = 40
// minIPPacketLen is the min ip packet size for UDP packet
minUDPIPPacketLen = 28
// 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)
)
// UDP related constants.
const (
// UDPLengthPos is the location of UDP length
UDPLengthPos = 24
// UDPChecksumPos is the location of UDP checksum
UDPChecksumPos = 26
// UDPDataPos is the location of UDP data
UDPDataPos = 28
// UDPBeginPos is the location of UDP Header
UDPBeginPos = 20
// UDPSynMask is a mask for the UDP Syn flags
UDPSynMask = 0x20
// UDPSynAckMask mask idenitifies a UDP SYN-ACK packet
UDPSynAckMask = 0x40
// UDPAckMask mask that identifies ACK packets.
UDPAckMask = 0x60
// UDPPacketMask identifies type of UDP packet.
UDPPacketMask = 0x60
)
const (
// UDPAuthMarker is 18 byte Aporeto signature for UDP
UDPAuthMarker = "n30njxq7bmiwr6dtxq"
// UDPAuthMarkerLen is the length of UDP marker.
UDPAuthMarkerLen = 18
// UDPSignatureLen is the length of signature on UDP control packet.
UDPSignatureLen = 20
// UDPAuthMarkerOffset is the beginning of UDPAuthMarker
UDPAuthMarkerOffset = 30
// UDPSignatureEnd is the end of UDPSignature.
UDPSignatureEnd = UDPDataPos + UDPSignatureLen
// UDPJwtTokenOffset is beginning of Jwt Token.
UDPJwtTokenOffset = 48
)