func (e *Endpoint) WritePacket(_ *stack.Route, hdr buffer.Prependable, payload buffer.VectorisedView, protocol tcpip.NetworkProtocolNumber) *tcpip.Error {
	p := PacketInfo{
		Header:  hdr.View(),
		Proto:   protocol,
		Payload: payload.ToView(),
	}
	select {
	case e.C <- p:
	default:
	}
	return nil
}
WritePacket stores outbound packets into the channel.
package channel
import (
	tcpip "github.com/brewlin/net-protocol/protocol"
	"github.com/brewlin/net-protocol/pkg/buffer"
	"github.com/brewlin/net-protocol/stack"
)
type PacketInfo struct {
	Header  buffer.View
	Payload buffer.View
	Proto   tcpip.NetworkProtocolNumber
}
type Endpoint struct {
	dispatcher stack.NetworkDispatcher
	mtu        uint32
	linkAddr   tcpip.LinkAddress
	C chan PacketInfo
}
func New(size int, mtu uint32, linkAddr tcpip.LinkAddress) (tcpip.LinkEndpointID, *Endpoint) {
	e := &Endpoint{
		C:        make(chan PacketInfo, size),
		mtu:      mtu,
		linkAddr: linkAddr,
	}
	return stack.RegisterLinkEndpoint(e), e
}
func (e *Endpoint) Drain() int {
	c := 0
	for {
		select {
		case <-e.C:
			c++
		default:
			return c
		}
	}
}
func (e *Endpoint) Inject(protocol tcpip.NetworkProtocolNumber, vv buffer.VectorisedView) {
	e.InjectLinkAddr(protocol, "", vv)
}
func (e *Endpoint) InjectLinkAddr(protocol tcpip.NetworkProtocolNumber, remoteLinkAddr tcpip.LinkAddress, vv buffer.VectorisedView) {
	e.dispatcher.DeliverNetworkPacket(e, remoteLinkAddr, ""  , protocol, vv.Clone(nil))
}
func (e *Endpoint) Attach(dispatcher stack.NetworkDispatcher) {
	e.dispatcher = dispatcher
}
func (e *Endpoint) IsAttached() bool {
	return e.dispatcher != nil
}
func (e *Endpoint) MTU() uint32 {
	return e.mtu
}
func (*Endpoint) Capabilities() stack.LinkEndpointCapabilities {
	return 0
}
func (*Endpoint) MaxHeaderLength() uint16 {
	return 0
}
func (e *Endpoint) LinkAddress() tcpip.LinkAddress {
	return e.linkAddr
}