Add round-robin implementation (#66)

* add handler.encapsulateNode

* implement round robin handler approach

* simplify round robin implementation

* leave TODO

* internet.node touch up

* fix conflict resolve f-up

* replace certain ErrShortBuffer with ErrTruncatedFrame error
This commit is contained in:
Pat Whittingslow
2026-04-09 09:36:17 -03:00
committed by GitHub
parent ec44889896
commit 63f7870fe5
21 changed files with 104 additions and 70 deletions
+1 -2
View File
@@ -19,8 +19,7 @@ var (
errQueryNotFound = errors.New("arp: query not found")
// errGeneric aliases for common ARP errors.
errARPBufferFull = lneto.ErrBufferFull
errShortARP = lneto.ErrShortBuffer
errShortARP = lneto.ErrTruncatedFrame
errARPUnsupported = lneto.ErrUnsupported
errLargeSizes = lneto.ErrPacketDrop
)
+3 -3
View File
@@ -10,13 +10,13 @@ import (
"github.com/soypat/lneto/ethernet"
)
// NewARPFrame returns a ARPFrame with data set to buf.
// NewFrame returns a Frame with data set to buf.
// An error is returned if the buffer size is smaller than 28 (IPv4 min size).
// Users should still call [ARPFrame.ValidateSize] before working
// Users should still call [Frame.ValidateSize] before working
// with payload/options of frames to avoid panics.
func NewFrame(buf []byte) (Frame, error) {
if len(buf) < sizeHeaderv4 {
return Frame{buf: nil}, lneto.ErrShortBuffer
return Frame{buf: nil}, lneto.ErrTruncatedFrame
}
return Frame{buf: buf}, nil
}
+2 -2
View File
@@ -149,7 +149,7 @@ func (h *Handler) StartQuery(dstHWAddr, proto []byte) error {
if len(h.queries) == cap(h.queries) {
h.compactQueries()
if len(h.queries) == cap(h.queries) {
return lneto.ErrBufferFull
return lneto.ErrExhausted
}
}
if len(proto) != len(h.ourProtoAddr) {
@@ -214,7 +214,7 @@ func (h *Handler) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int)
func (h *Handler) Demux(ethFrame []byte, frameOffset int) error {
if len(h.pendingResponse) == cap(h.pendingResponse) {
return errARPBufferFull
return lneto.ErrExhausted
}
b := ethFrame[frameOffset:]