Define Adapter base type/interface

This commit is contained in:
Neil Alexander 2018-12-14 18:29:00 +00:00
parent 8045cb4dc3
commit f9dc300787
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 29 additions and 12 deletions

25
src/yggdrasil/adapter.go Normal file
View file

@ -0,0 +1,25 @@
package yggdrasil
// Defines the minimum required functions for an adapter type.
type AdapterInterface interface {
init(core *Core, send chan<- []byte, recv <-chan []byte)
read() error
write() error
close() error
}
// Defines the minimum required struct members for an adapter type (this is
// now the base type for tunAdapter in tun.go)
type Adapter struct {
AdapterInterface
core *Core
send chan<- []byte
recv <-chan []byte
}
// Initialises the adapter.
func (adapter *Adapter) init(core *Core, send chan<- []byte, recv <-chan []byte) {
adapter.core = core
adapter.send = send
adapter.recv = recv
}