From a0fc6b6e069069506090bfe01934cdb1b7222fb3 Mon Sep 17 00:00:00 2001 From: Dmitri Dolguikh Date: Wed, 3 Jan 2018 14:29:30 -0800 Subject: [PATCH] Renamed MakePacket to Unmarshal and MakeOptions to UnmarshalOptions --- dhcp6/conn.go | 2 +- dhcp6/options.go | 4 ++-- dhcp6/options_test.go | 2 +- dhcp6/packet.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dhcp6/conn.go b/dhcp6/conn.go index 4ef3ba3..9d5c65a 100644 --- a/dhcp6/conn.go +++ b/dhcp6/conn.go @@ -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 } diff --git a/dhcp6/options.go b/dhcp6/options.go index e4b1e41..ce91f98 100644 --- a/dhcp6/options.go +++ b/dhcp6/options.go @@ -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) diff --git a/dhcp6/options_test.go b/dhcp6/options_test.go index dd44c05..877c017 100644 --- a/dhcp6/options_test.go +++ b/dhcp6/options_test.go @@ -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.") } } diff --git a/dhcp6/packet.go b/dhcp6/packet.go index 529d150..b4f5a53 100644 --- a/dhcp6/packet.go +++ b/dhcp6/packet.go @@ -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) }