Refactoring: move tuntap and icmpv6 into separate package

This commit is contained in:
Neil Alexander 2019-03-28 00:30:25 +00:00
parent 67c670ab4c
commit 0b494a8255
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
20 changed files with 307 additions and 240 deletions

View file

@ -1,18 +1,36 @@
package yggdrasil
import (
"github.com/gologme/log"
"github.com/yggdrasil-network/yggdrasil-go/src/address"
"github.com/yggdrasil-network/yggdrasil-go/src/config"
)
// Defines the minimum required struct members for an adapter type (this is
// now the base type for tunAdapter in tun.go)
// now the base type for TunAdapter in tun.go)
type Adapter struct {
core *Core
send chan<- []byte
recv <-chan []byte
reconfigure chan chan error
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
}
// Initialises the adapter.
func (adapter *Adapter) init(core *Core, send chan<- []byte, recv <-chan []byte) {
adapter.core = core
adapter.send = send
adapter.recv = recv
adapter.reconfigure = make(chan chan error, 1)
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)
}