rule.go 833 B

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