Documentation
¶
Overview ¶
Package gnet implements TCP/IP connectivity through a generic NetworkDevice interface.
The TCP/IP stack is implemented using gVisor pure Go implementation.
This package is only meant to be used with `GOOS=tamago` as supported by the TamaGo framework for bare metal Go, see https://github.com/usbarmory/tamago.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // MTU represents the Ethernet Maximum Transmission Unit. MTU uint32 = 1518 // NICID represents the default gVisor NIC identifier NICID = tcpip.NICID(1) // DefaultStackOptions represents the default gVisor Stack configuration DefaultStackOptions = stack.Options{ NetworkProtocols: []stack.NetworkProtocolFactory{ ipv4.NewProtocol, arp.NewProtocol}, TransportProtocols: []stack.TransportProtocolFactory{ tcp.NewProtocol, icmp.NewProtocol4, udp.NewProtocol}, } )
Functions ¶
This section is empty.
Types ¶
type Interface ¶
Interface represents an Ethernet interface instance.
func (*Interface) EnableICMP ¶
EnableICMP adds an ICMP endpoint to the interface, it is useful to enable ping requests.
func (*Interface) Init ¶
func (iface *Interface) Init(nic NetworkDevice, addr string, mac string, gateway string) (err error)
Init initializes a NetworkDevice associating it to a gVisor link, a default NICID and TCP/IP gVisor Stack are set if not previously assigned, a random MAC address is set if its argument is empty.
type NIC ¶
type NIC struct {
// MAC address
MAC net.HardwareAddr
// Link is a gVisor channel endpoint
Link *channel.Endpoint
// Device is the physical interface associated to the virtual one.
Device NetworkDevice
}
NIC represents an virtual Ethernet instance.
func (*NIC) Init ¶
Init initializes a virtual Ethernet instance bound to a physical Ethernet device.
type NetworkDevice ¶
type NetworkDevice interface {
// Receive receives a single Ethernet frame from a network adapter.
Receive(buf []byte) (n int, err error)
// Transmit transmits a single Ethernet frame to a network adapter.
Transmit(buf []byte) (err error)
}
NetworkDevice represents a generic network device interface capable of receiving and transmitting raw Ethernet frames.