mirror of
https://github.com/soypat/lneto.git
synced 2026-08-19 14:14:07 +00:00
begin adding packet capture functionality
This commit is contained in:
@@ -14,6 +14,7 @@ var (
|
||||
errARPBufferFull = errors.New("ARP client need handling:too many ops pending")
|
||||
errShortARP = errors.New("packet too short to be ARP")
|
||||
errARPUnsupported = errors.New("ARP not supprortedf")
|
||||
errLargeSizes = errors.New("size of ARP protocol+hardware is unusually large")
|
||||
)
|
||||
|
||||
// Operation represents the type of ARP packet, either request or reply/response.
|
||||
|
||||
+3
-1
@@ -138,9 +138,11 @@ func (afrm Frame) SwapTargetSender() {
|
||||
func (afrm Frame) ValidateSize(v *lneto.Validator) {
|
||||
_, hlen := afrm.Hardware()
|
||||
_, ilen := afrm.Protocol()
|
||||
minLen := 8 + 2*(hlen+ilen)
|
||||
minLen := 8 + 2*(int(hlen)+int(ilen))
|
||||
if len(afrm.buf) < int(minLen) {
|
||||
v.AddError(errShortARP)
|
||||
} else if minLen > 255 {
|
||||
v.AddError(errLargeSizes) // We don't want a uint8 overflow somewhere. This is probably a maliciously crafted packet.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user