mirror of
https://github.com/danderson/netboot.git
synced 2026-05-05 12:26:38 +02:00
Renamed MakePacket to Unmarshal and MakeOptions to UnmarshalOptions
This commit is contained in:
parent
09440c6b84
commit
a0fc6b6e06
@ -98,7 +98,7 @@ func (c *Conn) RecvDHCP() (*Packet, net.IP, error) {
|
||||
if !rcm.Dst.IsMulticast() || !rcm.Dst.Equal(c.group) {
|
||||
continue // unknown group, discard
|
||||
}
|
||||
pkt, err := MakePacket(b, n)
|
||||
pkt, err := Unmarshal(b, n)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ func MakeOption(id uint16, value []byte) *Option {
|
||||
// Options contains all options of a DHCPv6 packet
|
||||
type Options map[uint16][]*Option
|
||||
|
||||
// MakeOptions unmarshals individual Options and returns them in a new Options data structure
|
||||
func MakeOptions(bs []byte) (Options, error) {
|
||||
// UnmarshalOptions unmarshals individual Options and returns them in a new Options data structure
|
||||
func UnmarshalOptions(bs []byte) (Options, error) {
|
||||
ret := make(Options)
|
||||
for len(bs) > 0 {
|
||||
o, err := UnmarshalOption(bs)
|
||||
|
||||
@ -98,7 +98,7 @@ func TestMakeStatusOption(t *testing.T) {
|
||||
|
||||
func TestUnmarshalFailsIfOROLengthIsOdd(t *testing.T) {
|
||||
in := []byte{0, 6, 0, 3, 0, 1, 1}
|
||||
if _, err := MakeOptions(in); err == nil {
|
||||
if _, err := UnmarshalOptions(in); err == nil {
|
||||
t.Fatalf("Parsing options should fail: option request for options has odd length.")
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +32,9 @@ type Packet struct {
|
||||
Options Options
|
||||
}
|
||||
|
||||
// MakePacket creates a Packet out of its serialized representation
|
||||
func MakePacket(bs []byte, packetLength int) (*Packet, error) {
|
||||
options, err := MakeOptions(bs[4:packetLength])
|
||||
// Unmarshal creates a Packet out of its serialized representation
|
||||
func Unmarshal(bs []byte, packetLength int) (*Packet, error) {
|
||||
options, err := UnmarshalOptions(bs[4:packetLength])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("packet has malformed options section: %s", err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user