rule.go 807 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. }
  23. func (r Rule) String() string {
  24. return fmt.Sprintf("ip rule %d: from %s table %d", r.Priority, r.Src, r.Table)
  25. }
  26. // NewRule return empty rules.
  27. func NewRule() *Rule {
  28. return &Rule{
  29. SuppressIfgroup: -1,
  30. SuppressPrefixlen: -1,
  31. Priority: -1,
  32. Mark: -1,
  33. Mask: -1,
  34. Goto: -1,
  35. Flow: -1,
  36. }
  37. }