forked from Jamesits/go-windivert
/
enums.go
127 lines (102 loc) · 2.16 KB
/
enums.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
package ffi
import "strings"
// Contains constants defined in the library header.
//go:generate stringer -type=Layer,Event,Param,Shutdown,Direction,ChecksumFlag -output=enums_string.go -trimprefix=WinDivert -linecomment
// WINDIVERT_LAYER
// https://reqrypt.org/windivert-doc.html#divert_layers
type Layer int
const (
// Network packets to/from the local machine.
Network Layer = iota
// Network packets passing through the local machine.
NetworkForward
// Network flow established/deleted events.
Flow
// Socket operation events.
Socket
// Reflect WinDivert handle events.
Reflect
)
// WINDIVERT_EVENT
// https://reqrypt.org/windivert-doc.html#divert_events
type Event int
const (
NetworkPacket Event = iota
FlowEstablished
FlowDeleted
SocketBind
SocketConnect
SocketListen
SocketAccept
SocketClose
ReflectOpen
ReflectClose
)
type Flag uint8
const (
None Flag = 0x00
Sniff Flag = 0x01
Drop Flag = 0x02
ReceiveOnly Flag = 0x04
SendOnly Flag = 0x08
NoInstall Flag = 0x10
Fragments Flag = 0x20
)
func (flags Flag) String() string {
if flags == 0 {
return "NONE"
}
sb := strings.Builder{}
if flags&Sniff > 0 {
sb.WriteString("|SNIFF")
}
if flags&Drop > 0 {
sb.WriteString("|DROP")
}
if flags&ReceiveOnly > 0 {
sb.WriteString("|RECV_ONLY")
}
if flags&SendOnly > 0 {
sb.WriteString("|SEND_ONLY")
}
if flags&NoInstall > 0 {
sb.WriteString("|NO_INSTALL")
}
if flags&Fragments > 0 {
sb.WriteString("|FRAGMENTS")
}
return sb.String()[1:]
}
// WINDIVERT_PARAM
type Param int
const (
QueueLength Param = 0
QueueTime Param = 1
QueueSize Param = 2
VersionMajor Param = 3
VersionMinor Param = 4
)
// WINDIVERT_SHUTDOWN
type Shutdown int64
const (
Recv Shutdown = 0x1
Send Shutdown = 0x2
Both Shutdown = 0x3
)
type Direction int
const (
Outbound Direction = 1
Inbound Direction = 0
)
// Priority of the handles
// Multiple handles should not have the same priority.
type Priority int16
type ChecksumFlag int64
const (
All ChecksumFlag = 0x00
NoIP ChecksumFlag = 0x01
NoICMP ChecksumFlag = 0x02
NoICMPv6 ChecksumFlag = 0x04
NoTCP ChecksumFlag = 0x08
NoUDP ChecksumFlag = 0x10
)