2019-09-20 19:51:57 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c)2019 ZeroTier, Inc.
|
|
|
|
*
|
|
|
|
* Use of this software is governed by the Business Source License included
|
|
|
|
* in the LICENSE.TXT file in the project's root directory.
|
|
|
|
*
|
|
|
|
* Change Date: 2023-01-01
|
|
|
|
*
|
|
|
|
* On the date above, in accordance with the Business Source License, use
|
|
|
|
* of this software will be governed by version 2.0 of the Apache License.
|
|
|
|
*/
|
|
|
|
/****/
|
|
|
|
|
|
|
|
package zerotier
|
|
|
|
|
|
|
|
import "net"
|
|
|
|
|
|
|
|
// Tap represents an Ethernet tap connecting a virtual network to a device or something else "real"
|
|
|
|
type Tap interface {
|
2019-09-27 14:55:46 -07:00
|
|
|
// Close is called when this tap is being shut down
|
|
|
|
Close()
|
|
|
|
|
|
|
|
// Type is a string describing what kind of tap this is e.g. "native" for OS-native
|
2019-09-20 21:00:54 -07:00
|
|
|
Type() string
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// Error returns the most recent error experienced by this tap
|
2019-09-20 21:00:54 -07:00
|
|
|
Error() (int, string)
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// SetEnabled sets whether this tap will accept and process packets
|
2019-09-20 19:51:57 -07:00
|
|
|
SetEnabled(enabled bool)
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// Enabled returns the current enabled status
|
2019-09-20 19:51:57 -07:00
|
|
|
Enabled() bool
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// AddIP assigns an IP address to this tap device
|
2019-09-21 18:22:25 -07:00
|
|
|
AddIP(ip *net.IPNet) error
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// RemoveIP removes an IP address from this tap
|
2019-09-21 18:22:25 -07:00
|
|
|
RemoveIP(ip *net.IPNet) error
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// IPs returns an array of all IPs currently assigned to this tap including those not assigned by ZeroTier
|
2019-09-20 19:51:57 -07:00
|
|
|
IPs() ([]net.IPNet, error)
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// DeviceName gets the OS-specific device name for this tap or an empty string if none
|
2019-09-20 19:51:57 -07:00
|
|
|
DeviceName() string
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// AddMulticastGroupChangeHandler registers a function to be called on multicast group subscribe or unsubscribe (first argument)
|
2019-09-20 20:34:31 -07:00
|
|
|
AddMulticastGroupChangeHandler(func(bool, *MulticastGroup))
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// AddRoute adds a route to this tap device via the system or other routing table
|
2019-09-21 18:22:25 -07:00
|
|
|
AddRoute(r *Route) error
|
2019-09-27 14:55:46 -07:00
|
|
|
|
|
|
|
// RemoveRoute removes a route from this tap device
|
2019-09-21 18:22:25 -07:00
|
|
|
RemoveRoute(r *Route) error
|
2019-09-20 19:51:57 -07:00
|
|
|
}
|