mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Refactoring: move tuntap and icmpv6 into separate package
This commit is contained in:
parent
67c670ab4c
commit
0b494a8255
20 changed files with 307 additions and 240 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue