mirror of
https://github.com/soypat/lneto.git
synced 2026-09-11 17:19:30 +00:00
add dhcp failing test
This commit is contained in:
@@ -2,6 +2,7 @@ package dhcpv4
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
//go:generate stringer -type=OptNum,Op,MessageType,ClientState -linecomment -output stringers.go
|
||||
@@ -38,6 +39,11 @@ func AppendOption(dst []byte, opt OptNum, data ...byte) []byte {
|
||||
return dst
|
||||
}
|
||||
|
||||
func AppendOptionString(dst []byte, opt OptNum, data string) []byte {
|
||||
bdata := unsafe.Slice(unsafe.StringData(data), len(data))
|
||||
return AppendOption(dst, opt, bdata...)
|
||||
}
|
||||
|
||||
func EncodeOption(dst []byte, opt OptNum, data ...byte) (int, error) {
|
||||
if len(data) > 255 {
|
||||
return 0, errors.New("DHCPv4 option data too long (>255)")
|
||||
|
||||
Reference in New Issue
Block a user