rule.go 784 B

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