diff options
Diffstat (limited to 'dhcpv6')
39 files changed, 0 insertions, 170 deletions
diff --git a/dhcpv6/dhcpv6.go b/dhcpv6/dhcpv6.go index 25fdcd0..7eaf621 100644 --- a/dhcpv6/dhcpv6.go +++ b/dhcpv6/dhcpv6.go @@ -16,7 +16,6 @@ type DHCPv6 interface { Options() []Option String() string Summary() string - Length() int IsRelay() bool GetOption(code OptionCode) []Option GetOneOption(code OptionCode) Option diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go index 43d9f50..a1e439a 100644 --- a/dhcpv6/dhcpv6message.go +++ b/dhcpv6/dhcpv6message.go @@ -318,14 +318,6 @@ func (d *DHCPv6Message) ToBytes() []byte { return buf.Data() } -func (d *DHCPv6Message) Length() int { - mLen := 4 - for _, opt := range d.options { - mLen += opt.Length() + 4 // +4 for opt code and opt len - } - return mLen -} - func (d *DHCPv6Message) Options() []Option { return d.options } diff --git a/dhcpv6/dhcpv6relay.go b/dhcpv6/dhcpv6relay.go index 337bda6..4a690b9 100644 --- a/dhcpv6/dhcpv6relay.go +++ b/dhcpv6/dhcpv6relay.go @@ -92,14 +92,6 @@ func (r *DHCPv6Relay) SetPeerAddr(peerAddr net.IP) { r.peerAddr = peerAddr } -func (r *DHCPv6Relay) Length() int { - mLen := RelayHeaderSize - for _, opt := range r.options { - mLen += opt.Length() + 4 // +4 for opt code and opt len - } - return mLen -} - func (r *DHCPv6Relay) Options() []Option { return r.options } diff --git a/dhcpv6/option_archtype.go b/dhcpv6/option_archtype.go index afb22b1..83ebf0e 100644 --- a/dhcpv6/option_archtype.go +++ b/dhcpv6/option_archtype.go @@ -29,10 +29,6 @@ func (op *OptClientArchType) ToBytes() []byte { return buf.Data() } -func (op *OptClientArchType) Length() int { - return 2 * len(op.ArchTypes) -} - func (op *OptClientArchType) String() string { atStrings := make([]string, 0) for _, at := range op.ArchTypes { diff --git a/dhcpv6/option_archtype_test.go b/dhcpv6/option_archtype_test.go index cf9f432..b01db08 100644 --- a/dhcpv6/option_archtype_test.go +++ b/dhcpv6/option_archtype_test.go @@ -35,7 +35,6 @@ func TestOptClientArchType(t *testing.T) { opt := OptClientArchType{ ArchTypes: []iana.Arch{iana.EFI_ITANIUM}, } - require.Equal(t, 2, opt.Length()) require.Equal(t, OptionClientArchType, opt.Code()) require.Contains(t, opt.String(), "archtype=EFI Itanium", "String() should contain the correct ArchType output") } diff --git a/dhcpv6/option_bootfileurl.go b/dhcpv6/option_bootfileurl.go index d34f5ec..48c49bc 100644 --- a/dhcpv6/option_bootfileurl.go +++ b/dhcpv6/option_bootfileurl.go @@ -22,11 +22,6 @@ func (op *OptBootFileURL) ToBytes() []byte { return op.BootFileURL } -// Length returns the option length in bytes -func (op *OptBootFileURL) Length() int { - return len(op.BootFileURL) -} - func (op *OptBootFileURL) String() string { return fmt.Sprintf("OptBootFileURL{BootFileUrl=%s}", op.BootFileURL) } diff --git a/dhcpv6/option_bootfileurl_test.go b/dhcpv6/option_bootfileurl_test.go index 97d3163..7d43003 100644 --- a/dhcpv6/option_bootfileurl_test.go +++ b/dhcpv6/option_bootfileurl_test.go @@ -13,9 +13,6 @@ func TestOptBootFileURL(t *testing.T) { if err != nil { t.Fatal(err) } - if optLen := opt.Length(); optLen != len(expected) { - t.Fatalf("Invalid length. Expected %v, got %v", len(expected), optLen) - } if url := opt.BootFileURL; !bytes.Equal(url, expected) { t.Fatalf("Invalid boot file URL. Expected %v, got %v", expected, url) } diff --git a/dhcpv6/option_clientid.go b/dhcpv6/option_clientid.go index d0d31d6..200d1a6 100644 --- a/dhcpv6/option_clientid.go +++ b/dhcpv6/option_clientid.go @@ -21,10 +21,6 @@ func (op *OptClientId) ToBytes() []byte { return op.Cid.ToBytes() } -func (op *OptClientId) Length() int { - return op.Cid.Length() -} - func (op *OptClientId) String() string { return fmt.Sprintf("OptClientId{cid=%v}", op.Cid.String()) } diff --git a/dhcpv6/option_clientid_test.go b/dhcpv6/option_clientid_test.go index b147e57..69a60d1 100644 --- a/dhcpv6/option_clientid_test.go +++ b/dhcpv6/option_clientid_test.go @@ -56,7 +56,6 @@ func TestOptionClientId(t *testing.T) { LinkLayerAddr: net.HardwareAddr([]byte{0xde, 0xad, 0, 0, 0xbe, 0xef}), }, } - require.Equal(t, 10, opt.Length()) require.Equal(t, OptionClientID, opt.Code()) require.Contains( t, diff --git a/dhcpv6/option_dnsrecursivenameserver.go b/dhcpv6/option_dnsrecursivenameserver.go index cd78c8c..9aaeb3b 100644 --- a/dhcpv6/option_dnsrecursivenameserver.go +++ b/dhcpv6/option_dnsrecursivenameserver.go @@ -29,11 +29,6 @@ func (op *OptDNSRecursiveNameServer) ToBytes() []byte { return buf.Data() } -// Length returns the option length -func (op *OptDNSRecursiveNameServer) Length() int { - return len(op.NameServers) * net.IPv6len -} - func (op *OptDNSRecursiveNameServer) String() string { return fmt.Sprintf("OptDNSRecursiveNameServer{nameservers=%v}", op.NameServers) } diff --git a/dhcpv6/option_dnsrecursivenameserver_test.go b/dhcpv6/option_dnsrecursivenameserver_test.go index 436cf2f..c45e9de 100644 --- a/dhcpv6/option_dnsrecursivenameserver_test.go +++ b/dhcpv6/option_dnsrecursivenameserver_test.go @@ -18,7 +18,6 @@ func TestParseOptDNSRecursiveNameServer(t *testing.T) { require.NoError(t, err) require.Equal(t, expected, opt.NameServers) require.Equal(t, OptionDNSRecursiveNameServer, opt.Code()) - require.Equal(t, 16, opt.Length()) require.Contains(t, opt.String(), "nameservers=[2a03:2880:fffe:c:face:b00c:0:35]", "String() should contain the correct nameservers output") } diff --git a/dhcpv6/option_domainsearchlist.go b/dhcpv6/option_domainsearchlist.go index 21d7c23..6bbe4e3 100644 --- a/dhcpv6/option_domainsearchlist.go +++ b/dhcpv6/option_domainsearchlist.go @@ -23,14 +23,6 @@ func (op *OptDomainSearchList) ToBytes() []byte { return op.DomainSearchList.ToBytes() } -func (op *OptDomainSearchList) Length() int { - var length int - for _, label := range op.DomainSearchList.Labels { - length += len(label) + 2 // add the first and the last length bytes - } - return length -} - func (op *OptDomainSearchList) String() string { return fmt.Sprintf("OptDomainSearchList{searchlist=%v}", op.DomainSearchList.Labels) } diff --git a/dhcpv6/option_domainsearchlist_test.go b/dhcpv6/option_domainsearchlist_test.go index 67c053a..b4d0195 100644 --- a/dhcpv6/option_domainsearchlist_test.go +++ b/dhcpv6/option_domainsearchlist_test.go @@ -16,7 +16,6 @@ func TestParseOptDomainSearchList(t *testing.T) { require.NoError(t, err) require.Equal(t, OptionDomainSearchList, opt.Code()) require.Equal(t, 2, len(opt.DomainSearchList.Labels)) - require.Equal(t, len(data), opt.DomainSearchList.Length()) require.Equal(t, "example.com", opt.DomainSearchList.Labels[0]) require.Equal(t, "subnet.example.org", opt.DomainSearchList.Labels[1]) require.Contains(t, opt.String(), "searchlist=[example.com subnet.example.org]", "String() should contain the correct domain search output") diff --git a/dhcpv6/option_elapsedtime.go b/dhcpv6/option_elapsedtime.go index 862cf28..2d65843 100644 --- a/dhcpv6/option_elapsedtime.go +++ b/dhcpv6/option_elapsedtime.go @@ -25,10 +25,6 @@ func (op *OptElapsedTime) ToBytes() []byte { return buf.Data() } -func (op *OptElapsedTime) Length() int { - return 2 -} - func (op *OptElapsedTime) String() string { return fmt.Sprintf("OptElapsedTime{elapsedtime=%v}", op.ElapsedTime) } diff --git a/dhcpv6/option_elapsedtime_test.go b/dhcpv6/option_elapsedtime_test.go index a7ca85c..3442281 100644 --- a/dhcpv6/option_elapsedtime_test.go +++ b/dhcpv6/option_elapsedtime_test.go @@ -12,9 +12,6 @@ func TestOptElapsedTime(t *testing.T) { if err != nil { t.Fatal(err) } - if optLen := opt.Length(); optLen != 2 { - t.Fatalf("Invalid length. Expected 2, got %v", optLen) - } if elapsedTime := opt.ElapsedTime; elapsedTime != 0xaabb { t.Fatalf("Invalid elapsed time. Expected 0xaabb, got %v", elapsedTime) } diff --git a/dhcpv6/option_iaaddress.go b/dhcpv6/option_iaaddress.go index 11c8a00..882e627 100644 --- a/dhcpv6/option_iaaddress.go +++ b/dhcpv6/option_iaaddress.go @@ -33,15 +33,6 @@ func (op *OptIAAddress) ToBytes() []byte { return buf.Data() } -// Length returns the option length -func (op *OptIAAddress) Length() int { - opLen := 24 - for _, opt := range op.Options { - opLen += 4 + opt.Length() - } - return opLen -} - func (op *OptIAAddress) String() string { return fmt.Sprintf("OptIAAddress{ipv6addr=%v, preferredlifetime=%v, validlifetime=%v, options=%v}", op.IPv6Addr, op.PreferredLifetime, op.ValidLifetime, op.Options) diff --git a/dhcpv6/option_iaaddress_test.go b/dhcpv6/option_iaaddress_test.go index 6a16e7f..511a907 100644 --- a/dhcpv6/option_iaaddress_test.go +++ b/dhcpv6/option_iaaddress_test.go @@ -16,7 +16,6 @@ func TestOptIAAddressParse(t *testing.T) { }...) opt, err := ParseOptIAAddress(data) require.NoError(t, err) - require.Equal(t, 30, opt.Length()) require.Equal(t, net.IP(ipaddr), opt.IPv6Addr) require.Equal(t, uint32(0x0a0b0c0d), opt.PreferredLifetime) require.Equal(t, uint32(0x0e0f0102), opt.ValidLifetime) diff --git a/dhcpv6/option_iaprefix.go b/dhcpv6/option_iaprefix.go index 58cdadc..7260d2c 100644 --- a/dhcpv6/option_iaprefix.go +++ b/dhcpv6/option_iaprefix.go @@ -52,15 +52,6 @@ func (op *OptIAPrefix) SetIPv6Prefix(p net.IP) { op.ipv6Prefix = p } -// Length returns the option length -func (op *OptIAPrefix) Length() int { - opLen := 25 - for _, opt := range op.Options { - opLen += 4 + opt.Length() - } - return opLen -} - func (op *OptIAPrefix) String() string { return fmt.Sprintf("OptIAPrefix{preferredlifetime=%v, validlifetime=%v, prefixlength=%v, ipv6prefix=%v, options=%v}", op.PreferredLifetime, op.ValidLifetime, op.PrefixLength(), op.IPv6Prefix(), op.Options) diff --git a/dhcpv6/option_iaprefix_test.go b/dhcpv6/option_iaprefix_test.go index 48b410d..e48594d 100644 --- a/dhcpv6/option_iaprefix_test.go +++ b/dhcpv6/option_iaprefix_test.go @@ -32,9 +32,6 @@ func TestOptIAPrefix(t *testing.T) { if ip := opt.IPv6Prefix(); !bytes.Equal(ip, net.IPv6loopback) { t.Fatalf("Invalid Prefix Length. Expected %v, got %v", net.IPv6loopback, ip) } - if opt.Length() != len(buf) { - t.Fatalf("Invalid Option Length. Expected %v, got %v", len(buf), opt.Length()) - } } func TestOptIAPrefixToBytes(t *testing.T) { diff --git a/dhcpv6/option_interfaceid.go b/dhcpv6/option_interfaceid.go index 5937170..5ed2fba 100644 --- a/dhcpv6/option_interfaceid.go +++ b/dhcpv6/option_interfaceid.go @@ -29,10 +29,6 @@ func (op *OptInterfaceId) SetInterfaceID(interfaceId []byte) { op.interfaceId = append([]byte(nil), interfaceId...) } -func (op *OptInterfaceId) Length() int { - return len(op.interfaceId) -} - func (op *OptInterfaceId) String() string { return fmt.Sprintf("OptInterfaceId{interfaceid=%v}", op.interfaceId) } diff --git a/dhcpv6/option_interfaceid_test.go b/dhcpv6/option_interfaceid_test.go index ec9e80d..df2a762 100644 --- a/dhcpv6/option_interfaceid_test.go +++ b/dhcpv6/option_interfaceid_test.go @@ -13,9 +13,6 @@ func TestOptInterfaceId(t *testing.T) { if err != nil { t.Fatal(err) } - if optLen := opt.Length(); optLen != len(expected) { - t.Fatalf("Invalid length. Expected %v, got %v", len(expected), optLen) - } if url := opt.InterfaceID(); !bytes.Equal(url, expected) { t.Fatalf("Invalid Interface ID. Expected %v, got %v", expected, url) } diff --git a/dhcpv6/option_nii.go b/dhcpv6/option_nii.go index ca86c22..bc47e8c 100644 --- a/dhcpv6/option_nii.go +++ b/dhcpv6/option_nii.go @@ -68,10 +68,6 @@ func (op *OptNetworkInterfaceId) SetMinor(minor uint8) { op.minor = minor } -func (op *OptNetworkInterfaceId) Length() int { - return 3 -} - func (op *OptNetworkInterfaceId) String() string { typeName, ok := niiToStringMap[op.type_] if !ok { diff --git a/dhcpv6/option_nii_test.go b/dhcpv6/option_nii_test.go index ba9ed19..a355122 100644 --- a/dhcpv6/option_nii_test.go +++ b/dhcpv6/option_nii_test.go @@ -14,7 +14,6 @@ func TestOptNetworkInterfaceIdParse(t *testing.T) { } opt, err := ParseOptNetworkInterfaceId(expected) require.NoError(t, err, "ParseOptNetworkInterfaceId() should not return an error with correct bytes") - require.Equal(t, 3, opt.Length(), "Length() should return 3") require.Equal(t, OptionNII, opt.Code(), OptionNII, "Code() should return 62 for OptNetworkInterfaceId") require.Equal(t, uint8(1), opt.Type(), "Type() should return 1 for UNDI") require.Equal(t, uint8(3), opt.Major(), "Major() should return 1 for UNDI") @@ -36,8 +35,6 @@ func TestOptNetworkInterfaceIdToBytes(t *testing.T) { func TestOptNetworkInterfaceIdTooShort(t *testing.T) { buf := []byte{ - 0, 62, // OptNetworkInterfaceId - 0, 3, // length 1, // type (UNDI) // missing major/minor revision bytes } diff --git a/dhcpv6/option_nontemporaryaddress.go b/dhcpv6/option_nontemporaryaddress.go index 8515438..031f22c 100644 --- a/dhcpv6/option_nontemporaryaddress.go +++ b/dhcpv6/option_nontemporaryaddress.go @@ -32,14 +32,6 @@ func (op *OptIANA) ToBytes() []byte { return buf.Data() } -func (op *OptIANA) Length() int { - l := 12 - for _, opt := range op.Options { - l += 4 + opt.Length() - } - return l -} - func (op *OptIANA) String() string { return fmt.Sprintf("OptIANA{IAID=%v, t1=%v, t2=%v, options=%v}", op.IaId, op.T1, op.T2, op.Options) diff --git a/dhcpv6/option_nontemporaryaddress_test.go b/dhcpv6/option_nontemporaryaddress_test.go index 40aae53..afe6917 100644 --- a/dhcpv6/option_nontemporaryaddress_test.go +++ b/dhcpv6/option_nontemporaryaddress_test.go @@ -16,7 +16,6 @@ func TestOptIANAParseOptIANA(t *testing.T) { } opt, err := ParseOptIANA(data) require.NoError(t, err) - require.Equal(t, len(data), opt.Length()) require.Equal(t, OptionIANA, opt.Code()) } diff --git a/dhcpv6/option_prefixdelegation.go b/dhcpv6/option_prefixdelegation.go index eb5deb7..d366673 100644 --- a/dhcpv6/option_prefixdelegation.go +++ b/dhcpv6/option_prefixdelegation.go @@ -30,15 +30,6 @@ func (op *OptIAForPrefixDelegation) ToBytes() []byte { return buf.Data() } -// Length returns the option length -func (op *OptIAForPrefixDelegation) Length() int { - l := 12 - for _, opt := range op.Options { - l += 4 + opt.Length() - } - return l -} - // String returns a string representation of the OptIAForPrefixDelegation data func (op *OptIAForPrefixDelegation) String() string { return fmt.Sprintf("OptIAForPrefixDelegation{IAID=%v, t1=%v, t2=%v, options=%v}", diff --git a/dhcpv6/option_prefixdelegation_test.go b/dhcpv6/option_prefixdelegation_test.go index 377ca3d..802a3a6 100644 --- a/dhcpv6/option_prefixdelegation_test.go +++ b/dhcpv6/option_prefixdelegation_test.go @@ -20,7 +20,6 @@ func TestOptIAForPrefixDelegationParseOptIAForPrefixDelegation(t *testing.T) { } opt, err := ParseOptIAForPrefixDelegation(data) require.NoError(t, err) - require.Equal(t, len(data), opt.Length()) require.Equal(t, OptionIAPD, opt.Code()) require.Equal(t, [4]byte{1, 0, 0, 0}, opt.IaId) require.Equal(t, uint32(1), opt.T1) diff --git a/dhcpv6/option_relaymsg.go b/dhcpv6/option_relaymsg.go index c262dde..3d3d139 100644 --- a/dhcpv6/option_relaymsg.go +++ b/dhcpv6/option_relaymsg.go @@ -27,10 +27,6 @@ func (op *OptRelayMsg) SetRelayMessage(relayMessage DHCPv6) { op.relayMessage = relayMessage } -func (op *OptRelayMsg) Length() int { - return op.relayMessage.Length() -} - func (op *OptRelayMsg) String() string { return fmt.Sprintf("OptRelayMsg{relaymsg=%v}", op.relayMessage) } diff --git a/dhcpv6/option_remoteid.go b/dhcpv6/option_remoteid.go index 84a1a57..5b7d633 100644 --- a/dhcpv6/option_remoteid.go +++ b/dhcpv6/option_remoteid.go @@ -42,10 +42,6 @@ func (op *OptRemoteId) SetRemoteID(remoteId []byte) { op.remoteId = append([]byte(nil), remoteId...) } -func (op *OptRemoteId) Length() int { - return 4 + len(op.remoteId) -} - func (op *OptRemoteId) String() string { return fmt.Sprintf("OptRemoteId{enterprisenum=%v, remoteid=%v}", op.enterpriseNumber, op.remoteId, diff --git a/dhcpv6/option_remoteid_test.go b/dhcpv6/option_remoteid_test.go index 51566e3..b8b90f4 100644 --- a/dhcpv6/option_remoteid_test.go +++ b/dhcpv6/option_remoteid_test.go @@ -15,9 +15,6 @@ func TestOptRemoteId(t *testing.T) { if err != nil { t.Fatal(err) } - if optLen := opt.Length(); optLen != len(expected) { - t.Fatalf("Invalid length. Expected %v, got %v", len(expected), optLen) - } if en := opt.EnterpriseNumber(); en != 0xaabbccdd { t.Fatalf("Invalid Enterprise Number. Expected 0xaabbccdd, got %v", en) } diff --git a/dhcpv6/option_requestedoption.go b/dhcpv6/option_requestedoption.go index d72e2ed..54ff5bf 100644 --- a/dhcpv6/option_requestedoption.go +++ b/dhcpv6/option_requestedoption.go @@ -44,10 +44,6 @@ func (op *OptRequestedOption) AddRequestedOption(opt OptionCode) { op.requestedOptions = append(op.requestedOptions, opt) } -func (op *OptRequestedOption) Length() int { - return len(op.requestedOptions) * 2 -} - func (op *OptRequestedOption) String() string { names := make([]string, 0, len(op.requestedOptions)) for _, code := range op.requestedOptions { diff --git a/dhcpv6/option_serverid.go b/dhcpv6/option_serverid.go index 7202428..2a60209 100644 --- a/dhcpv6/option_serverid.go +++ b/dhcpv6/option_serverid.go @@ -21,10 +21,6 @@ func (op *OptServerId) ToBytes() []byte { return op.Sid.ToBytes() } -func (op *OptServerId) Length() int { - return op.Sid.Length() -} - func (op *OptServerId) String() string { return fmt.Sprintf("OptServerId{sid=%v}", op.Sid.String()) } diff --git a/dhcpv6/option_serverid_test.go b/dhcpv6/option_serverid_test.go index 2cd37a3..23c00f5 100644 --- a/dhcpv6/option_serverid_test.go +++ b/dhcpv6/option_serverid_test.go @@ -56,7 +56,6 @@ func TestOptionServerId(t *testing.T) { LinkLayerAddr: net.HardwareAddr([]byte{0xde, 0xad, 0, 0, 0xbe, 0xef}), }, } - require.Equal(t, 10, opt.Length()) require.Equal(t, OptionServerID, opt.Code()) require.Contains( t, diff --git a/dhcpv6/option_statuscode.go b/dhcpv6/option_statuscode.go index dad4ff6..db0df3e 100644 --- a/dhcpv6/option_statuscode.go +++ b/dhcpv6/option_statuscode.go @@ -29,11 +29,6 @@ func (op *OptStatusCode) ToBytes() []byte { return buf.Data() } -// Length returns the option length -func (op *OptStatusCode) Length() int { - return 2 + len(op.StatusMessage) -} - func (op *OptStatusCode) String() string { return fmt.Sprintf("OptStatusCode{code=%s (%d), message=%v}", op.StatusCode.String(), op.StatusCode, diff --git a/dhcpv6/option_userclass.go b/dhcpv6/option_userclass.go index 75e1d3b..b12b6b9 100644 --- a/dhcpv6/option_userclass.go +++ b/dhcpv6/option_userclass.go @@ -30,15 +30,6 @@ func (op *OptUserClass) ToBytes() []byte { return buf.Data() } -// Length returns the option length -func (op *OptUserClass) Length() int { - ret := 0 - for _, uc := range op.UserClasses { - ret += 2 + len(uc) - } - return ret -} - func (op *OptUserClass) String() string { ucStrings := make([]string, 0, len(op.UserClasses)) for _, uc := range op.UserClasses { diff --git a/dhcpv6/option_vendor_opts.go b/dhcpv6/option_vendor_opts.go index 3deeab9..a1ae400 100644 --- a/dhcpv6/option_vendor_opts.go +++ b/dhcpv6/option_vendor_opts.go @@ -28,15 +28,6 @@ func (op *OptVendorOpts) ToBytes() []byte { return buf.Data() } -// Length returns the option length -func (op *OptVendorOpts) Length() int { - l := 4 // 4 bytes for Enterprise Number - for _, opt := range op.VendorOpts { - l += 4 + opt.Length() // 4 bytes for Code and Length from Vendor - } - return l -} - // String returns a string representation of the VendorOpts data func (op *OptVendorOpts) String() string { return fmt.Sprintf("OptVendorOpts{enterprisenum=%v, vendorOpts=%v}", diff --git a/dhcpv6/option_vendor_opts_test.go b/dhcpv6/option_vendor_opts_test.go index 043995d..f6c2b2a 100644 --- a/dhcpv6/option_vendor_opts_test.go +++ b/dhcpv6/option_vendor_opts_test.go @@ -19,7 +19,6 @@ func TestOptVendorOpts(t *testing.T) { expectedOpts.VendorOpts = append(vendorOpts, &OptionGeneric{OptionCode: 1, OptionData: optData}) opt, err := ParseOptVendorOpts(expected) require.NoError(t, err) - require.Equal(t, len(expected), opt.Length()) require.Equal(t, uint32(0xaabbccdd), opt.EnterpriseNumber) require.Equal(t, expectedOpts.VendorOpts, opt.VendorOpts) diff --git a/dhcpv6/option_vendorclass.go b/dhcpv6/option_vendorclass.go index 67fa15a..ef85087 100644 --- a/dhcpv6/option_vendorclass.go +++ b/dhcpv6/option_vendorclass.go @@ -30,15 +30,6 @@ func (op *OptVendorClass) ToBytes() []byte { return buf.Data() } -// Length returns the option length -func (op *OptVendorClass) Length() int { - ret := 0 - for _, data := range op.Data { - ret += 2 + len(data) - } - return 4 + ret -} - // String returns a string representation of the VendorClass data func (op *OptVendorClass) String() string { vcStrings := make([]string, 0) diff --git a/dhcpv6/options.go b/dhcpv6/options.go index 6c403f5..47ccdca 100644 --- a/dhcpv6/options.go +++ b/dhcpv6/options.go @@ -10,7 +10,6 @@ import ( type Option interface { Code() OptionCode ToBytes() []byte - Length() int String() string } @@ -31,10 +30,6 @@ func (og *OptionGeneric) String() string { return fmt.Sprintf("%s -> %v", og.OptionCode, og.OptionData) } -func (og *OptionGeneric) Length() int { - return len(og.OptionData) -} - // ParseOption parses data according to the given code. func ParseOption(code OptionCode, optData []byte) (Option, error) { // Parse a sequence of bytes as a single DHCPv6 option. |