-
Notifications
You must be signed in to change notification settings - Fork 51
/
ping_type.go
81 lines (69 loc) · 1.87 KB
/
ping_type.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
package claimsheader
// PingType defines the ping type.
type PingType int
// PingType options.
const (
PingTypeNone PingType = iota
PingTypeDefaultIdentity
PingTypeCustomIdentity
PingTypeDefaultIdentityPassthrough
)
// toMask returns the mask based on the type
func (pt PingType) toMask() pingTypeMask {
switch pt {
case PingTypeNone:
return pingTypeNoneMask
case PingTypeDefaultIdentity:
return pingTypeDefaultIdentityMask
case PingTypeCustomIdentity:
return pingTypeCustomIdentityMask
case PingTypeDefaultIdentityPassthrough:
return pingTypeDefaultIdentityPassthroughMask
default:
return pingTypeNoneMask
}
}
// toMask returns the mask based on the type
func (pt PingType) String() string {
switch pt {
case PingTypeNone:
return "None"
case PingTypeDefaultIdentity:
return "DefaultIdentity"
case PingTypeCustomIdentity:
return "CustomIdentity"
case PingTypeDefaultIdentityPassthrough:
return "DefaultIdentityPassthrough"
default:
return "None"
}
}
// pingTypeMask defines the ping type mask.
type pingTypeMask uint8
// PingTypeMask options.
const (
pingTypeNoneMask pingTypeMask = 0x02
pingTypeDefaultIdentityMask pingTypeMask = 0x04
pingTypeCustomIdentityMask pingTypeMask = 0x06
pingTypeDefaultIdentityPassthroughMask pingTypeMask = 0x08
pingTypeBitMask pingTypeMask = 0x3E
)
// toType returns the type based on mask
func (pm pingTypeMask) toType() PingType {
switch pm {
case pingTypeNoneMask:
return PingTypeNone
case pingTypeDefaultIdentityMask:
return PingTypeDefaultIdentity
case pingTypeCustomIdentityMask:
return PingTypeCustomIdentity
case pingTypeDefaultIdentityPassthroughMask:
return PingTypeDefaultIdentityPassthrough
default:
return PingTypeNone
}
}
// toUint8 returns uint8 from PingTypemask
func (pm pingTypeMask) toUint8() uint8 {
return uint8(pm)
}