1package netlink 2 3import ( 4 "fmt" 5 "net" 6) 7 8// Rule represents a netlink rule. 9type Rule struct { 10 Priority int 11 Family int 12 Table int 13 Mark int 14 Mask int 15 TunID uint 16 Goto int 17 Src *net.IPNet 18 Dst *net.IPNet 19 Flow int 20 IifName string 21 OifName string 22 SuppressIfgroup int 23 SuppressPrefixlen int 24 Invert bool 25} 26 27func (r Rule) String() string { 28 return fmt.Sprintf("ip rule %d: from %s table %d", r.Priority, r.Src, r.Table) 29} 30 31// NewRule return empty rules. 32func NewRule() *Rule { 33 return &Rule{ 34 SuppressIfgroup: -1, 35 SuppressPrefixlen: -1, 36 Priority: -1, 37 Mark: -1, 38 Mask: -1, 39 Goto: -1, 40 Flow: -1, 41 } 42} 43