device.go 709 B

1234567891011121314151617181920212223242526272829303132
  1. package overlay
  2. import (
  3. "io"
  4. "net/netip"
  5. "github.com/slackhq/nebula/routing"
  6. )
  7. // BatchReadWriter extends io.ReadWriteCloser with batch I/O operations
  8. type BatchReadWriter interface {
  9. io.ReadWriteCloser
  10. // BatchRead reads multiple packets at once
  11. BatchRead(bufs [][]byte, sizes []int) (int, error)
  12. // WriteBatch writes multiple packets at once
  13. WriteBatch(bufs [][]byte, offset int) (int, error)
  14. // BatchSize returns the optimal batch size for this device
  15. BatchSize() int
  16. }
  17. type Device interface {
  18. BatchReadWriter
  19. Activate() error
  20. Networks() []netip.Prefix
  21. Name() string
  22. RoutesFor(netip.Addr) routing.Gateways
  23. SupportsMultiqueue() bool
  24. NewMultiQueueReader() (BatchReadWriter, error)
  25. }