forked from ti-mo/conntrack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilter.go
47 lines (39 loc) · 1.02 KB
/
filter.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
package conntrack
import (
"github.com/ti-mo/netfilter"
)
type Filter interface {
Marshal() []netfilter.Attribute
}
// Filter is a structure used in dump operations to filter the response
// based on a given connmark and mask. The mask is applied to the Mark field of
// all flows in the conntrack table, the result is compared to the filter's Mark.
// Each flow that matches will be returned by the kernel.
type FilterMark struct {
Mark, Mask uint32
}
// marshal marshals a Filter into a list of netfilter.Attributes.
func (f FilterMark) Marshal() []netfilter.Attribute {
return []netfilter.Attribute{
{
Type: uint16(ctaMark),
Data: netfilter.Uint32Bytes(f.Mark),
},
{
Type: uint16(ctaMarkMask),
Data: netfilter.Uint32Bytes(f.Mask),
},
}
}
type FilterZone struct {
Zone uint16
}
// marshal marshals a Filter into a list of netfilter.Attributes.
func (f FilterZone) Marshal() []netfilter.Attribute {
return []netfilter.Attribute{
{
Type: uint16(ctaZone),
Data: netfilter.Uint16Bytes(f.Zone),
},
}
}