stack

package
v0.0.0-...-7a82295 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const UDPProtocolNumber tcpip.TransportProtocolNumber = 17

Variables

View Source
var ErrUnknownProtocol = errors.New("unknown protocol")

Functions

func RegisterNetworkProtocol

func RegisterNetworkProtocol(name string, p INetworkProtocol)

func RegisterTransportProtocol

func RegisterTransportProtocol(name string, p ITransportProtocol)

Types

type IEndpoint

type IEndpoint interface {
	Close()
	Bind(address tcpip.FullAddress) error
	RecvMsg(*tcpip.FullAddress) (buffer.View, error)

	Write(buffer.View, *tcpip.FullAddress) (uintptr, error)
}

type ILinkEndpoint

type ILinkEndpoint interface {
	Attach(dispatcher INetworkDispatcher)
}

func FindLinkEndpoint

func FindLinkEndpoint(id tcpip.LinkEndpointID) ILinkEndpoint

type INetworkDispatcher

type INetworkDispatcher interface{}

type INetworkEndpoint

type INetworkEndpoint interface {
	MTU() uint32
	MaxHeaderLength() uint16
	ID() *NetworkEndpointID
	NICID() tcpip.NICID

	WritePacket(r *Route, hdr *buffer.Prependable, payload buffer.View, protocol tcpip.TransportProtocolNumber) error
	HandlePacket(r *Route, v buffer.View)
}

type INetworkProtocol

type INetworkProtocol interface {
	NewEndpoint(nicid tcpip.NICID, addr tcpip.Address, dispatcher ITransportDispatcher, sender ILinkEndpoint) (INetworkEndpoint, error)
	Number() tcpip.NetworkProtocolNumber
}

type IStack

type IStack interface {
	NewEndpoint(transport tcpip.TransportProtocolNumber, network tcpip.NetworkProtocolNumber) (IEndpoint, error)
}

func New

func New(network []string, transport []string) IStack

type ITransportDispatcher

type ITransportDispatcher interface{}

type ITransportProtocol

type ITransportProtocol interface {
	NewEndpoint(netProto tcpip.NetworkProtocolNumber) (IEndpoint, error)
	Number() tcpip.TransportProtocolNumber
}

type NIC

type NIC struct {
	// contains filtered or unexported fields
}

func (*NIC) AddAddress

func (n *NIC) AddAddress(protocol tcpip.NetworkProtocolNumber, addr tcpip.Address) error

type NetworkEndpointID

type NetworkEndpointID struct {
	LocalAddress tcpip.Address
}

type Route

type Route struct {
	RemoteAddress tcpip.Address
	LocalAddress  tcpip.Address
	NextHop       tcpip.Address
	NetProto      tcpip.NetworkProtocolNumber
	// contains filtered or unexported fields
}

func (*Route) MaxHeaderLength

func (r *Route) MaxHeaderLength() uint16

func (*Route) NICID

func (r *Route) NICID() tcpip.NICID

func (*Route) PseudoHeaderChecksum

func (r *Route) PseudoHeaderChecksum(protocol tcpip.TransportProtocolNumber) uint16

func (*Route) Release

func (r *Route) Release()

func (*Route) WritePacket

func (r *Route) WritePacket(hdr *buffer.Prependable, payload buffer.View, protocol tcpip.TransportProtocolNumber) error

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

func (*Stack) AddAddress

func (s *Stack) AddAddress(id tcpip.NICID, protocol tcpip.NetworkProtocolNumber, addr tcpip.Address) error

func (*Stack) CreateNIC

func (s *Stack) CreateNIC(id tcpip.NICID, linkEP tcpip.LinkEndpointID) error

attach so early, the endpoint is even not created

func (*Stack) FindRoute

func (s *Stack) FindRoute(id tcpip.NICID, localAddr, remoteAddr tcpip.Address, netProto tcpip.NetworkProtocolNumber) (Route, error)

Transport endpoint uses this to find the route, then uses the route to write

func (*Stack) NewEndpoint

func (s *Stack) NewEndpoint(transport tcpip.TransportProtocolNumber, network tcpip.NetworkProtocolNumber) (IEndpoint, error)

new TransportEndpoint

func (*Stack) SetRouteTable

func (s *Stack) SetRouteTable(table []tcpip.Route)

later transportendpoint will need to find route and send package with the route's networkendpoint

type TransportEndpointID

type TransportEndpointID struct {
	LocalPort    uint16
	LocalAddress tcpip.Address

	RemotePort    uint16
	RemoteAddress tcpip.Address
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL