rule.go 831 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package netlink
  2. import (
  3. "fmt"
  4. "net"
  5. )
  6. // Rule represents a netlink rule.
  7. type Rule struct {
  8. Priority int
  9. Family int
  10. Table int
  11. Mark int
  12. Mask int
  13. TunID uint
  14. Goto int
  15. Src *net.IPNet
  16. Dst *net.IPNet
  17. Flow int
  18. IifName string
  19. OifName string
  20. SuppressIfgroup int
  21. SuppressPrefixlen int
  22. Invert bool
  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. }