-
Notifications
You must be signed in to change notification settings - Fork 51
/
countererrors.go
264 lines (241 loc) · 8.08 KB
/
countererrors.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
package nfqdatapath
import (
"go.aporeto.io/trireme-lib/controller/pkg/counters"
"go.aporeto.io/trireme-lib/controller/pkg/tokens"
)
func appSynCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrTokenEncodeFailed:
return counters.ErrSynTokenEncodeFailed
case tokens.ErrTokenHashFailed:
return counters.ErrSynTokenHashFailed
case tokens.ErrTokenSignFailed:
return counters.ErrSynTokenSignFailed
case tokens.ErrSharedSecretMissing:
return counters.ErrSynSharedSecretMissing
case tokens.ErrInvalidSecret:
return counters.ErrSynInvalidSecret
case tokens.ErrInvalidSignature:
return counters.ErrSynInvalidSignature
default:
return counters.ErrSynTokenFailed
}
}
func appSynAckCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrTokenEncodeFailed:
return counters.ErrSynAckTokenEncodeFailed
case tokens.ErrTokenHashFailed:
return counters.ErrSynAckTokenHashFailed
case tokens.ErrTokenSignFailed:
return counters.ErrSynAckTokenSignFailed
case tokens.ErrSharedSecretMissing:
return counters.ErrSynAckSharedSecretMissing
case tokens.ErrInvalidSecret:
return counters.ErrSynAckInvalidSecret
case tokens.ErrInvalidSignature:
return counters.ErrSynAckInvalidSignature
default:
return counters.ErrSynAckTokenFailed
}
}
func appAckCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrTokenEncodeFailed:
return counters.ErrAckTokenEncodeFailed
case tokens.ErrTokenHashFailed:
return counters.ErrAckTokenHashFailed
case tokens.ErrInvalidSecret:
return counters.ErrAckInvalidSecret
case tokens.ErrSharedSecretMissing:
return counters.ErrAckSharedSecretMissing
default:
return counters.ErrAckTokenFailed
}
}
func netSynCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrInvalidTokenLength:
return counters.ErrSynInvalidTokenLength
case tokens.ErrMissingSignature:
return counters.ErrSynMissingSignature
case tokens.ErrCompressedTagMismatch:
return counters.ErrSynCompressedTagMismatch
case tokens.ErrDatapathVersionMismatch:
return counters.ErrSynDatapathVersionMismatch
case tokens.ErrTokenDecodeFailed:
return counters.ErrSynTokenDecodeFailed
case tokens.ErrTokenExpired:
return counters.ErrSynTokenExpired
case tokens.ErrPublicKeyFailed:
return counters.ErrSynPublicKeyFailed
case tokens.ErrSharedKeyHashFailed:
return counters.ErrSynSharedKeyHashFailed
default:
return counters.ErrSynDroppedInvalidToken
}
}
func netSynAckCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrInvalidTokenLength:
return counters.ErrSynAckInvalidTokenLength
case tokens.ErrMissingSignature:
return counters.ErrSynAckMissingSignature
case tokens.ErrCompressedTagMismatch:
return counters.ErrSynAckCompressedTagMismatch
case tokens.ErrDatapathVersionMismatch:
return counters.ErrSynAckDatapathVersionMismatch
case tokens.ErrTokenDecodeFailed:
return counters.ErrSynAckTokenDecodeFailed
case tokens.ErrTokenExpired:
return counters.ErrSynAckTokenExpired
case tokens.ErrPublicKeyFailed:
return counters.ErrSynAckPublicKeyFailed
case tokens.ErrSharedKeyHashFailed:
return counters.ErrSynAckSharedKeyHashFailed
default:
return counters.ErrSynAckInvalidToken
}
}
func netAckCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrInvalidTokenLength:
return counters.ErrAckInvalidTokenLength
case tokens.ErrMissingSignature:
return counters.ErrAckMissingSignature
case tokens.ErrCompressedTagMismatch:
return counters.ErrAckCompressedTagMismatch
case tokens.ErrDatapathVersionMismatch:
return counters.ErrAckDatapathVersionMismatch
case tokens.ErrTokenDecodeFailed:
return counters.ErrAckTokenDecodeFailed
case tokens.ErrTokenExpired:
return counters.ErrAckTokenExpired
case tokens.ErrSharedSecretMissing:
return counters.ErrAckSharedSecretMissing
case tokens.ErrTokenHashFailed:
return counters.ErrAckTokenHashFailed
case tokens.ErrSignatureMismatch:
return counters.ErrAckSignatureMismatch
default:
return counters.ErrAckInvalidToken
}
}
func appUDPSynCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrTokenEncodeFailed:
return counters.ErrUDPSynTokenEncodeFailed
case tokens.ErrTokenHashFailed:
return counters.ErrUDPSynTokenHashFailed
case tokens.ErrTokenSignFailed:
return counters.ErrUDPSynTokenSignFailed
case tokens.ErrSharedSecretMissing:
return counters.ErrUDPSynSharedSecretMissing
case tokens.ErrInvalidSecret:
return counters.ErrUDPSynInvalidSecret
case tokens.ErrInvalidSignature:
return counters.ErrUDPSynInvalidSignature
default:
return counters.ErrUDPSynTokenFailed
}
}
func appUDPSynAckCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrTokenEncodeFailed:
return counters.ErrUDPSynAckTokenEncodeFailed
case tokens.ErrTokenHashFailed:
return counters.ErrUDPSynAckTokenHashFailed
case tokens.ErrTokenSignFailed:
return counters.ErrUDPSynAckTokenSignFailed
case tokens.ErrSharedSecretMissing:
return counters.ErrUDPSynAckSharedSecretMissing
case tokens.ErrInvalidSecret:
return counters.ErrUDPSynAckInvalidSecret
case tokens.ErrInvalidSignature:
return counters.ErrUDPSynAckInvalidSignature
default:
return counters.ErrUDPSynAckTokenFailed
}
}
func appUDPAckCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrTokenEncodeFailed:
return counters.ErrUDPAckTokenEncodeFailed
case tokens.ErrTokenHashFailed:
return counters.ErrUDPAckTokenHashFailed
case tokens.ErrInvalidSecret:
return counters.ErrUDPAckInvalidSecret
case tokens.ErrSharedSecretMissing:
return counters.ErrUDPAckSharedSecretMissing
default:
return counters.ErrUDPAckTokenFailed
}
}
func netUDPSynCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrInvalidTokenLength:
return counters.ErrUDPSynInvalidTokenLength
case tokens.ErrMissingSignature:
return counters.ErrUDPSynMissingSignature
case tokens.ErrCompressedTagMismatch:
return counters.ErrUDPSynCompressedTagMismatch
case tokens.ErrDatapathVersionMismatch:
return counters.ErrUDPSynDatapathVersionMismatch
case tokens.ErrTokenDecodeFailed:
return counters.ErrUDPSynTokenDecodeFailed
case tokens.ErrTokenExpired:
return counters.ErrUDPSynTokenExpired
case tokens.ErrPublicKeyFailed:
return counters.ErrUDPSynPublicKeyFailed
case tokens.ErrSharedKeyHashFailed:
return counters.ErrUDPSynSharedKeyHashFailed
default:
return counters.ErrUDPSynDroppedInvalidToken
}
}
func netUDPSynAckCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrInvalidTokenLength:
return counters.ErrUDPSynAckInvalidTokenLength
case tokens.ErrMissingSignature:
return counters.ErrUDPSynAckMissingSignature
case tokens.ErrCompressedTagMismatch:
return counters.ErrUDPSynAckCompressedTagMismatch
case tokens.ErrDatapathVersionMismatch:
return counters.ErrUDPSynAckDatapathVersionMismatch
case tokens.ErrTokenDecodeFailed:
return counters.ErrUDPSynAckTokenDecodeFailed
case tokens.ErrTokenExpired:
return counters.ErrUDPSynAckTokenExpired
case tokens.ErrPublicKeyFailed:
return counters.ErrUDPSynAckPublicKeyFailed
case tokens.ErrSharedKeyHashFailed:
return counters.ErrUDPSynAckSharedKeyHashFailed
default:
return counters.ErrUDPSynAckInvalidToken
}
}
func netUDPAckCounterFromError(err error) counters.CounterType {
switch err {
case tokens.ErrInvalidTokenLength:
return counters.ErrUDPAckInvalidTokenLength
case tokens.ErrMissingSignature:
return counters.ErrUDPAckMissingSignature
case tokens.ErrCompressedTagMismatch:
return counters.ErrUDPAckCompressedTagMismatch
case tokens.ErrDatapathVersionMismatch:
return counters.ErrUDPAckDatapathVersionMismatch
case tokens.ErrTokenDecodeFailed:
return counters.ErrUDPAckTokenDecodeFailed
case tokens.ErrTokenExpired:
return counters.ErrUDPAckTokenExpired
case tokens.ErrSharedSecretMissing:
return counters.ErrUDPAckSharedSecretMissing
case tokens.ErrTokenHashFailed:
return counters.ErrUDPAckTokenHashFailed
case tokens.ErrSignatureMismatch:
return counters.ErrUDPAckSignatureMismatch
default:
return counters.ErrUDPAckInvalidToken
}
}