tap.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (C)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2025-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. package zerotier
  14. import "net"
  15. // Tap represents an Ethernet tap connecting a virtual network to a device or something else "real"
  16. type Tap interface {
  17. // Close is called when this tap is being shut down
  18. Close()
  19. // Type is a string describing what kind of tap this is e.g. "native" for OS-native
  20. Type() string
  21. // Error returns the most recent error experienced by this tap
  22. Error() (int, string)
  23. // SetEnabled sets whether this tap will accept and process packets
  24. SetEnabled(enabled bool)
  25. // Enabled returns the current enabled status
  26. Enabled() bool
  27. // AddIP assigns an IP address to this tap device
  28. AddIP(ip *InetAddress) error
  29. // RemoveIP removes an IP address from this tap
  30. RemoveIP(ip *InetAddress) error
  31. // IPs returns an array of all IPs currently assigned to this tap including those not assigned by ZeroTier
  32. IPs() ([]net.IPNet, error)
  33. // DeviceName gets the OS-specific device name for this tap or an empty string if none
  34. DeviceName() string
  35. // AddMulticastGroupChangeHandler registers a function to be called on multicast group subscribe or unsubscribe (first argument)
  36. AddMulticastGroupChangeHandler(func(bool, *MulticastGroup))
  37. }