2018-12-14 21:29:00 +03:00
|
|
|
package yggdrasil
|
|
|
|
|
2019-03-28 03:30:25 +03:00
|
|
|
import (
|
|
|
|
"github.com/gologme/log"
|
|
|
|
"github.com/yggdrasil-network/yggdrasil-go/src/address"
|
|
|
|
"github.com/yggdrasil-network/yggdrasil-go/src/config"
|
|
|
|
)
|
|
|
|
|
2018-12-14 21:29:00 +03:00
|
|
|
// Defines the minimum required struct members for an adapter type (this is
|
2019-03-28 03:30:25 +03:00
|
|
|
// now the base type for TunAdapter in tun.go)
|
2018-12-14 21:29:00 +03:00
|
|
|
type Adapter struct {
|
2019-03-28 03:30:25 +03:00
|
|
|
adapterImplementation
|
|
|
|
Core *Core
|
|
|
|
Send chan<- []byte
|
|
|
|
Recv <-chan []byte
|
|
|
|
Reconfigure chan chan error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Defines the minimum required functions for an adapter type
|
|
|
|
type adapterImplementation interface {
|
|
|
|
Init(*config.NodeState, *log.Logger, chan<- []byte, <-chan []byte)
|
|
|
|
Name() string
|
|
|
|
MTU() int
|
|
|
|
IsTAP() bool
|
|
|
|
Start(address.Address, address.Subnet) error
|
|
|
|
Read() error
|
|
|
|
Write() error
|
|
|
|
Close() error
|
2018-12-14 21:29:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Initialises the adapter.
|
2019-03-28 03:30:25 +03:00
|
|
|
func (adapter Adapter) Init(config *config.NodeState, log *log.Logger, send chan<- []byte, recv <-chan []byte) {
|
|
|
|
adapter.Send = send
|
|
|
|
adapter.Recv = recv
|
|
|
|
adapter.Reconfigure = make(chan chan error, 1)
|
2018-12-14 21:29:00 +03:00
|
|
|
}
|