fix couple bugs in ARP and add benchmarks

This commit is contained in:
Patricio Whittingslow
2026-01-13 10:15:18 -03:00
parent a5af5b58ce
commit f51cdf74b6
3 changed files with 202 additions and 17 deletions
+18 -17
View File
@@ -191,24 +191,25 @@ func (h *Handler) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int)
return n, nil
}
for i := range h.queries {
if !h.queries[i].querysent {
h.queries[i].querysent = true
afrm, _ := NewFrame(b)
afrm.SetHardware(h.htype, uint8(len(h.ourHWAddr)))
afrm.SetProtocol(h.protoType, uint8(len(h.ourProtoAddr)))
afrm.SetOperation(OpRequest)
hwSender, protoSender := afrm.Sender()
copy(hwSender, h.ourHWAddr)
copy(protoSender, h.ourProtoAddr)
hwTarget, protoTarget := afrm.Target()
copy(protoTarget, h.queries[i].protoaddr)
for j := range hwTarget {
hwTarget[j] = 0
}
broadcast := ethernet.BroadcastAddr()
trySetEthernetDst(carrierData[:offsetToFrame], broadcast[:])
return n, nil
if h.queries[i].isInvalid() || h.queries[i].querysent {
continue
}
h.queries[i].querysent = true
afrm, _ := NewFrame(b)
afrm.SetHardware(h.htype, uint8(len(h.ourHWAddr)))
afrm.SetProtocol(h.protoType, uint8(len(h.ourProtoAddr)))
afrm.SetOperation(OpRequest)
hwSender, protoSender := afrm.Sender()
copy(hwSender, h.ourHWAddr)
copy(protoSender, h.ourProtoAddr)
hwTarget, protoTarget := afrm.Target()
copy(protoTarget, h.queries[i].protoaddr)
for j := range hwTarget {
hwTarget[j] = 0
}
broadcast := ethernet.BroadcastAddr()
trySetEthernetDst(carrierData[:offsetToFrame], broadcast[:])
return n, nil
}
return 0, nil
}