mirror of
https://github.com/soypat/lneto.git
synced 2026-09-10 08:39:30 +00:00
Error rewrites (#43)
* pcap: reuse Frame memory * slog: reduce heap allocations of addresses; also prevent heap alloc of dhcp options in pcap * dns: heapless improvement; add StackAsync buffer for more heapless operation; start thinking of errors * errors: begin standardise errors in lneto * errors: finish standardization of errors * fix merge issues * add more lneto errors to rest of package * format errors.go
This commit is contained in:
@@ -2,7 +2,8 @@ package icmpv4
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
|
||||
"github.com/soypat/lneto"
|
||||
)
|
||||
|
||||
type Type uint8
|
||||
@@ -52,13 +53,9 @@ const (
|
||||
CodeRedirectToSAndHost // redirect for ToS+host
|
||||
)
|
||||
|
||||
var (
|
||||
errShortFrame = errors.New("icmpv4: short frame")
|
||||
)
|
||||
|
||||
func NewFrame(buf []byte) (Frame, error) {
|
||||
if len(buf) < 8 {
|
||||
return Frame{}, errShortFrame
|
||||
return Frame{}, lneto.ErrShortBuffer
|
||||
}
|
||||
return Frame{buf: buf}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user