-
Notifications
You must be signed in to change notification settings - Fork 51
/
types.go
52 lines (44 loc) · 968 Bytes
/
types.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
package claimsheader
// ClaimsHeader holds header sub attributes
type ClaimsHeader struct {
// CompressionType represents compressed tag mode attribute
compressionType CompressionType
// Encrypt represents enryption enabled attribute
encrypt bool
// Handshake type represents datapath version
datapathVersion DatapathVersion
// Ping represents ping is set
ping bool
}
type boolType int
const (
encrypt boolType = iota
ping
)
// boolToUint8 converts bool to uint8
// to populate the bits based on v
func boolToUint8(t boolType, v bool) uint8 {
if !v {
return zeroBit
}
switch t {
case encrypt:
return encryptionEnabledBit
case ping:
return pingEnabledBit
default:
return zeroBit
}
}
// uint8ToBool converts uint8 to bool
// to populate the struct based on n
func uint8ToBool(t boolType, n uint8) bool {
switch t {
case encrypt:
return n == encryptionEnabledBit
case ping:
return n == pingEnabledBit
default:
return false
}
}