diff options
Diffstat (limited to 'dhcpv4')
68 files changed, 0 insertions, 299 deletions
diff --git a/dhcpv4/bsdp/bsdp_option_boot_image_list.go b/dhcpv4/bsdp/bsdp_option_boot_image_list.go index ae2e59e..e67cb46 100644 --- a/dhcpv4/bsdp/bsdp_option_boot_image_list.go +++ b/dhcpv4/bsdp/bsdp_option_boot_image_list.go @@ -52,12 +52,3 @@ func (o *OptBootImageList) String() string { } return s } - -// Length returns the length of the data portion of this option. -func (o *OptBootImageList) Length() int { - length := 0 - for _, image := range o.Images { - length += 4 + 1 + len(image.Name) - } - return length -} diff --git a/dhcpv4/bsdp/bsdp_option_boot_image_list_test.go b/dhcpv4/bsdp/bsdp_option_boot_image_list_test.go index 8e9c27f..5d1b77c 100644 --- a/dhcpv4/bsdp/bsdp_option_boot_image_list_test.go +++ b/dhcpv4/bsdp/bsdp_option_boot_image_list_test.go @@ -27,7 +27,6 @@ func TestOptBootImageListInterfaceMethods(t *testing.T) { } o := OptBootImageList{bs} require.Equal(t, OptionBootImageList, o.Code(), "Code") - require.Equal(t, 22, o.Length(), "Length") expectedBytes := []byte{ // boot image 1 0x1, 0x0, 0x03, 0xe9, // ID diff --git a/dhcpv4/bsdp/bsdp_option_default_boot_image_id.go b/dhcpv4/bsdp/bsdp_option_default_boot_image_id.go index d75c883..40ab0be 100644 --- a/dhcpv4/bsdp/bsdp_option_default_boot_image_id.go +++ b/dhcpv4/bsdp/bsdp_option_default_boot_image_id.go @@ -40,8 +40,3 @@ func (o *OptDefaultBootImageID) ToBytes() []byte { func (o *OptDefaultBootImageID) String() string { return fmt.Sprintf("BSDP Default Boot Image ID -> %s", o.ID.String()) } - -// Length returns the length of the data portion of this option. -func (o *OptDefaultBootImageID) Length() int { - return 4 -} diff --git a/dhcpv4/bsdp/bsdp_option_default_boot_image_id_test.go b/dhcpv4/bsdp/bsdp_option_default_boot_image_id_test.go index eb63457..a5abdaf 100644 --- a/dhcpv4/bsdp/bsdp_option_default_boot_image_id_test.go +++ b/dhcpv4/bsdp/bsdp_option_default_boot_image_id_test.go @@ -11,7 +11,6 @@ func TestOptDefaultBootImageIDInterfaceMethods(t *testing.T) { b := BootImageID{IsInstall: true, ImageType: BootImageTypeMacOSX, Index: 1001} o := OptDefaultBootImageID{b} require.Equal(t, OptionDefaultBootImageID, o.Code(), "Code") - require.Equal(t, 4, o.Length(), "Length") require.Equal(t, uio.ToBigEndian(b), o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/bsdp/bsdp_option_generic.go b/dhcpv4/bsdp/bsdp_option_generic.go index cfcffb8..3859d8b 100644 --- a/dhcpv4/bsdp/bsdp_option_generic.go +++ b/dhcpv4/bsdp/bsdp_option_generic.go @@ -38,8 +38,3 @@ func (o OptGeneric) String() string { } return fmt.Sprintf("%v -> %v", code, o.Data) } - -// Length returns the number of bytes comprising the data section of the option. -func (o OptGeneric) Length() int { - return len(o.Data) -} diff --git a/dhcpv4/bsdp/bsdp_option_generic_test.go b/dhcpv4/bsdp/bsdp_option_generic_test.go index 131af9f..fe78242 100644 --- a/dhcpv4/bsdp/bsdp_option_generic_test.go +++ b/dhcpv4/bsdp/bsdp_option_generic_test.go @@ -55,12 +55,3 @@ func TestOptGenericStringUnknown(t *testing.T) { } require.Equal(t, "Unknown -> [5]", o.String()) } - -func TestOptGenericLength(t *testing.T) { - filename := "some_machine_name" - o := OptGeneric{ - OptionCode: OptionMachineName, - Data: []byte(filename), - } - require.Equal(t, len(filename), o.Length()) -} diff --git a/dhcpv4/bsdp/bsdp_option_machine_name.go b/dhcpv4/bsdp/bsdp_option_machine_name.go index ef38921..ced88b0 100644 --- a/dhcpv4/bsdp/bsdp_option_machine_name.go +++ b/dhcpv4/bsdp/bsdp_option_machine_name.go @@ -32,8 +32,3 @@ func (o *OptMachineName) ToBytes() []byte { func (o *OptMachineName) String() string { return "BSDP Machine Name -> " + o.Name } - -// Length returns the length of the data portion of this option. -func (o *OptMachineName) Length() int { - return len(o.Name) -} diff --git a/dhcpv4/bsdp/bsdp_option_machine_name_test.go b/dhcpv4/bsdp/bsdp_option_machine_name_test.go index c06ae7b..abc0d54 100644 --- a/dhcpv4/bsdp/bsdp_option_machine_name_test.go +++ b/dhcpv4/bsdp/bsdp_option_machine_name_test.go @@ -9,7 +9,6 @@ import ( func TestOptMachineNameInterfaceMethods(t *testing.T) { o := OptMachineName{"somebox"} require.Equal(t, OptionMachineName, o.Code(), "Code") - require.Equal(t, 7, o.Length(), "Length") expectedBytes := []byte{'s', 'o', 'm', 'e', 'b', 'o', 'x'} require.Equal(t, expectedBytes, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/bsdp/bsdp_option_message_type.go b/dhcpv4/bsdp/bsdp_option_message_type.go index c427dd1..5f96f12 100644 --- a/dhcpv4/bsdp/bsdp_option_message_type.go +++ b/dhcpv4/bsdp/bsdp_option_message_type.go @@ -60,8 +60,3 @@ func (o *OptMessageType) ToBytes() []byte { func (o *OptMessageType) String() string { return fmt.Sprintf("BSDP Message Type -> %s", o.Type.String()) } - -// Length returns the length of the data portion of this option. -func (o *OptMessageType) Length() int { - return 1 -} diff --git a/dhcpv4/bsdp/bsdp_option_message_type_test.go b/dhcpv4/bsdp/bsdp_option_message_type_test.go index 5dcda6c..a6695cc 100644 --- a/dhcpv4/bsdp/bsdp_option_message_type_test.go +++ b/dhcpv4/bsdp/bsdp_option_message_type_test.go @@ -9,7 +9,6 @@ import ( func TestOptMessageTypeInterfaceMethods(t *testing.T) { o := OptMessageType{MessageTypeList} require.Equal(t, OptionMessageType, o.Code(), "Code") - require.Equal(t, 1, o.Length(), "Length") require.Equal(t, []byte{1}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/bsdp/bsdp_option_reply_port.go b/dhcpv4/bsdp/bsdp_option_reply_port.go index 39277c3..5eea5ee 100644 --- a/dhcpv4/bsdp/bsdp_option_reply_port.go +++ b/dhcpv4/bsdp/bsdp_option_reply_port.go @@ -40,8 +40,3 @@ func (o *OptReplyPort) ToBytes() []byte { func (o *OptReplyPort) String() string { return fmt.Sprintf("BSDP Reply Port -> %v", o.Port) } - -// Length returns the length of the data portion of this option. -func (o *OptReplyPort) Length() int { - return 2 -} diff --git a/dhcpv4/bsdp/bsdp_option_reply_port_test.go b/dhcpv4/bsdp/bsdp_option_reply_port_test.go index 413c977..de94ffb 100644 --- a/dhcpv4/bsdp/bsdp_option_reply_port_test.go +++ b/dhcpv4/bsdp/bsdp_option_reply_port_test.go @@ -9,7 +9,6 @@ import ( func TestOptReplyPortInterfaceMethods(t *testing.T) { o := OptReplyPort{1234} require.Equal(t, OptionReplyPort, o.Code(), "Code") - require.Equal(t, 2, o.Length(), "Length") require.Equal(t, []byte{4, 210}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/bsdp/bsdp_option_selected_boot_image_id.go b/dhcpv4/bsdp/bsdp_option_selected_boot_image_id.go index 9079346..67f99a8 100644 --- a/dhcpv4/bsdp/bsdp_option_selected_boot_image_id.go +++ b/dhcpv4/bsdp/bsdp_option_selected_boot_image_id.go @@ -40,8 +40,3 @@ func (o *OptSelectedBootImageID) ToBytes() []byte { func (o *OptSelectedBootImageID) String() string { return fmt.Sprintf("BSDP Selected Boot Image ID -> %s", o.ID.String()) } - -// Length returns the length of the data portion of this option. -func (o *OptSelectedBootImageID) Length() int { - return 4 -} diff --git a/dhcpv4/bsdp/bsdp_option_selected_boot_image_id_test.go b/dhcpv4/bsdp/bsdp_option_selected_boot_image_id_test.go index d9bf2df..e187fc7 100644 --- a/dhcpv4/bsdp/bsdp_option_selected_boot_image_id_test.go +++ b/dhcpv4/bsdp/bsdp_option_selected_boot_image_id_test.go @@ -11,7 +11,6 @@ func TestOptSelectedBootImageIDInterfaceMethods(t *testing.T) { b := BootImageID{IsInstall: true, ImageType: BootImageTypeMacOSX, Index: 1001} o := OptSelectedBootImageID{b} require.Equal(t, OptionSelectedBootImageID, o.Code(), "Code") - require.Equal(t, 4, o.Length(), "Length") require.Equal(t, uio.ToBigEndian(b), o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/bsdp/bsdp_option_server_identifier.go b/dhcpv4/bsdp/bsdp_option_server_identifier.go index 704d4f2..8f2c41a 100644 --- a/dhcpv4/bsdp/bsdp_option_server_identifier.go +++ b/dhcpv4/bsdp/bsdp_option_server_identifier.go @@ -34,9 +34,3 @@ func (o *OptServerIdentifier) ToBytes() []byte { func (o *OptServerIdentifier) String() string { return fmt.Sprintf("BSDP Server Identifier -> %v", o.ServerID.String()) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptServerIdentifier) Length() int { - return len(o.ServerID.To4()) -} diff --git a/dhcpv4/bsdp/bsdp_option_server_identifier_test.go b/dhcpv4/bsdp/bsdp_option_server_identifier_test.go index 8c4555e..5a77644 100644 --- a/dhcpv4/bsdp/bsdp_option_server_identifier_test.go +++ b/dhcpv4/bsdp/bsdp_option_server_identifier_test.go @@ -13,7 +13,6 @@ func TestOptServerIdentifierInterfaceMethods(t *testing.T) { require.Equal(t, OptionServerIdentifier, o.Code(), "Code") expectedBytes := []byte{192, 168, 0, 1} require.Equal(t, expectedBytes, o.ToBytes(), "ToBytes") - require.Equal(t, 4, o.Length(), "Length") require.Equal(t, "BSDP Server Identifier -> 192.168.0.1", o.String(), "String") } diff --git a/dhcpv4/bsdp/bsdp_option_server_priority.go b/dhcpv4/bsdp/bsdp_option_server_priority.go index b362f01..f6fcf57 100644 --- a/dhcpv4/bsdp/bsdp_option_server_priority.go +++ b/dhcpv4/bsdp/bsdp_option_server_priority.go @@ -35,9 +35,3 @@ func (o *OptServerPriority) ToBytes() []byte { func (o *OptServerPriority) String() string { return fmt.Sprintf("BSDP Server Priority -> %v", o.Priority) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptServerPriority) Length() int { - return 2 -} diff --git a/dhcpv4/bsdp/bsdp_option_server_priority_test.go b/dhcpv4/bsdp/bsdp_option_server_priority_test.go index 91a21b6..c4c96de 100644 --- a/dhcpv4/bsdp/bsdp_option_server_priority_test.go +++ b/dhcpv4/bsdp/bsdp_option_server_priority_test.go @@ -10,7 +10,6 @@ func TestOptServerPriorityInterfaceMethods(t *testing.T) { o := OptServerPriority{Priority: 100} require.Equal(t, OptionServerPriority, o.Code(), "Code") require.Equal(t, []byte{0, 100}, o.ToBytes(), "ToBytes") - require.Equal(t, 2, o.Length(), "Length") require.Equal(t, "BSDP Server Priority -> 100", o.String(), "String") } diff --git a/dhcpv4/bsdp/bsdp_option_version.go b/dhcpv4/bsdp/bsdp_option_version.go index 9314cbe..041f3d1 100644 --- a/dhcpv4/bsdp/bsdp_option_version.go +++ b/dhcpv4/bsdp/bsdp_option_version.go @@ -41,8 +41,3 @@ func (o *OptVersion) ToBytes() []byte { func (o *OptVersion) String() string { return fmt.Sprintf("BSDP Version -> %v.%v", o.Version[0], o.Version[1]) } - -// Length returns the length of the data portion of this option. -func (o *OptVersion) Length() int { - return 2 -} diff --git a/dhcpv4/bsdp/bsdp_option_version_test.go b/dhcpv4/bsdp/bsdp_option_version_test.go index a74ea0e..8b592a8 100644 --- a/dhcpv4/bsdp/bsdp_option_version_test.go +++ b/dhcpv4/bsdp/bsdp_option_version_test.go @@ -9,7 +9,6 @@ import ( func TestOptVersionInterfaceMethods(t *testing.T) { o := OptVersion{Version1_1} require.Equal(t, OptionVersion, o.Code(), "Code") - require.Equal(t, 2, o.Length(), "Length") require.Equal(t, []byte{1, 1}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/bsdp/option_vendor_specific_information.go b/dhcpv4/bsdp/option_vendor_specific_information.go index 2207059..7d68f7f 100644 --- a/dhcpv4/bsdp/option_vendor_specific_information.go +++ b/dhcpv4/bsdp/option_vendor_specific_information.go @@ -82,16 +82,6 @@ func (o *OptVendorSpecificInformation) String() string { return s } -// Length returns the length of the data portion of this option. Take into -// account code + data length bytes for each sub option. -func (o *OptVendorSpecificInformation) Length() int { - var length int - for _, opt := range o.Options { - length += 2 + opt.Length() - } - return length -} - // GetOption returns all suboptions that match the given OptionCode code. func (o *OptVendorSpecificInformation) GetOption(code dhcpv4.OptionCode) []dhcpv4.Option { return o.Options.Get(code) diff --git a/dhcpv4/bsdp/option_vendor_specific_information_test.go b/dhcpv4/bsdp/option_vendor_specific_information_test.go index e62589e..108a95b 100644 --- a/dhcpv4/bsdp/option_vendor_specific_information_test.go +++ b/dhcpv4/bsdp/option_vendor_specific_information_test.go @@ -12,7 +12,6 @@ func TestOptVendorSpecificInformationInterfaceMethods(t *testing.T) { versionOpt := &OptVersion{Version1_1} o := &OptVendorSpecificInformation{[]dhcpv4.Option{messageTypeOpt, versionOpt}} require.Equal(t, dhcpv4.OptionVendorSpecificInformation, o.Code(), "Code") - require.Equal(t, 2+messageTypeOpt.Length()+2+versionOpt.Length(), o.Length(), "Length") expectedBytes := []byte{ 1, 1, 1, // List option diff --git a/dhcpv4/option_archtype.go b/dhcpv4/option_archtype.go index f400a21..2977d8a 100644 --- a/dhcpv4/option_archtype.go +++ b/dhcpv4/option_archtype.go @@ -30,12 +30,6 @@ func (o *OptClientArchType) ToBytes() []byte { return buf.Data() } -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptClientArchType) Length() int { - return 2 * len(o.ArchTypes) -} - // String returns a human-readable string. func (o *OptClientArchType) String() string { var archTypes string diff --git a/dhcpv4/option_archtype_test.go b/dhcpv4/option_archtype_test.go index 9e0db5b..7be896e 100644 --- a/dhcpv4/option_archtype_test.go +++ b/dhcpv4/option_archtype_test.go @@ -56,6 +56,5 @@ func TestOptClientArchType(t *testing.T) { opt := OptClientArchType{ ArchTypes: []iana.ArchType{iana.EFI_ITANIUM}, } - require.Equal(t, opt.Length(), 2) require.Equal(t, opt.Code(), OptionClientSystemArchitectureType) } diff --git a/dhcpv4/option_bootfile_name.go b/dhcpv4/option_bootfile_name.go index b0b8464..9e55bc3 100644 --- a/dhcpv4/option_bootfile_name.go +++ b/dhcpv4/option_bootfile_name.go @@ -22,14 +22,8 @@ func (op *OptBootfileName) ToBytes() []byte { return []byte(op.BootfileName) } -// Length returns the option length in bytes -func (op *OptBootfileName) Length() int { - return len(op.BootfileName) -} - func (op *OptBootfileName) String() string { return fmt.Sprintf("Bootfile Name -> %s", op.BootfileName) - } // ParseOptBootfileName returns a new OptBootfile from a byte stream or error if any diff --git a/dhcpv4/option_bootfile_name_test.go b/dhcpv4/option_bootfile_name_test.go index 76f60f4..38a200d 100644 --- a/dhcpv4/option_bootfile_name_test.go +++ b/dhcpv4/option_bootfile_name_test.go @@ -28,7 +28,6 @@ func TestParseOptBootfileName(t *testing.T) { } opt, err := ParseOptBootfileName(expected) require.NoError(t, err) - require.Equal(t, 9, opt.Length()) require.Equal(t, "linuxboot", opt.BootfileName) } diff --git a/dhcpv4/option_broadcast_address.go b/dhcpv4/option_broadcast_address.go index 1f6d4b8..c8bfe71 100644 --- a/dhcpv4/option_broadcast_address.go +++ b/dhcpv4/option_broadcast_address.go @@ -36,9 +36,3 @@ func (o *OptBroadcastAddress) ToBytes() []byte { func (o *OptBroadcastAddress) String() string { return fmt.Sprintf("Broadcast Address -> %v", o.BroadcastAddress.String()) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptBroadcastAddress) Length() int { - return len(o.BroadcastAddress.To4()) -} diff --git a/dhcpv4/option_broadcast_address_test.go b/dhcpv4/option_broadcast_address_test.go index 7980429..5b6b44f 100644 --- a/dhcpv4/option_broadcast_address_test.go +++ b/dhcpv4/option_broadcast_address_test.go @@ -16,8 +16,6 @@ func TestOptBroadcastAddressInterfaceMethods(t *testing.T) { expectedBytes := []byte{192, 168, 0, 1} require.Equal(t, expectedBytes, o.ToBytes(), "ToBytes") - require.Equal(t, 4, o.Length(), "Length") - require.Equal(t, "Broadcast Address -> 192.168.0.1", o.String(), "String") } diff --git a/dhcpv4/option_class_identifier.go b/dhcpv4/option_class_identifier.go index 6610df5..23394f0 100644 --- a/dhcpv4/option_class_identifier.go +++ b/dhcpv4/option_class_identifier.go @@ -32,9 +32,3 @@ func (o *OptClassIdentifier) ToBytes() []byte { func (o *OptClassIdentifier) String() string { return fmt.Sprintf("Class Identifier -> %v", o.Identifier) } - -// Length returns the length of the data portion (excluding option code and byte -// for length, if any). -func (o *OptClassIdentifier) Length() int { - return len(o.Identifier) -} diff --git a/dhcpv4/option_class_identifier_test.go b/dhcpv4/option_class_identifier_test.go index 6ff7888..780cf1d 100644 --- a/dhcpv4/option_class_identifier_test.go +++ b/dhcpv4/option_class_identifier_test.go @@ -9,7 +9,6 @@ import ( func TestOptClassIdentifierInterfaceMethods(t *testing.T) { o := OptClassIdentifier{Identifier: "foo"} require.Equal(t, OptionClassIdentifier, o.Code(), "Code") - require.Equal(t, 3, o.Length(), "Length") require.Equal(t, []byte{'f', 'o', 'o'}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/option_domain_name.go b/dhcpv4/option_domain_name.go index 689064b..456614d 100644 --- a/dhcpv4/option_domain_name.go +++ b/dhcpv4/option_domain_name.go @@ -30,9 +30,3 @@ func (o *OptDomainName) ToBytes() []byte { func (o *OptDomainName) String() string { return fmt.Sprintf("Domain Name -> %v", o.DomainName) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptDomainName) Length() int { - return len(o.DomainName) -} diff --git a/dhcpv4/option_domain_name_server.go b/dhcpv4/option_domain_name_server.go index 59299c3..a8a679f 100644 --- a/dhcpv4/option_domain_name_server.go +++ b/dhcpv4/option_domain_name_server.go @@ -38,9 +38,3 @@ func (o *OptDomainNameServer) ToBytes() []byte { func (o *OptDomainNameServer) String() string { return fmt.Sprintf("Domain Name Servers -> %s", IPsToString(o.NameServers)) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptDomainNameServer) Length() int { - return len(o.NameServers) * 4 -} diff --git a/dhcpv4/option_domain_name_server_test.go b/dhcpv4/option_domain_name_server_test.go index 546d399..407e0d6 100644 --- a/dhcpv4/option_domain_name_server_test.go +++ b/dhcpv4/option_domain_name_server_test.go @@ -14,7 +14,6 @@ func TestOptDomainNameServerInterfaceMethods(t *testing.T) { } o := OptDomainNameServer{NameServers: servers} require.Equal(t, OptionDomainNameServer, o.Code(), "Code") - require.Equal(t, net.IPv4len*len(servers), o.Length(), "Length") require.Equal(t, servers, o.NameServers, "NameServers") } diff --git a/dhcpv4/option_domain_name_test.go b/dhcpv4/option_domain_name_test.go index 473e28d..8c259d5 100644 --- a/dhcpv4/option_domain_name_test.go +++ b/dhcpv4/option_domain_name_test.go @@ -9,7 +9,6 @@ import ( func TestOptDomainNameInterfaceMethods(t *testing.T) { o := OptDomainName{DomainName: "foo"} require.Equal(t, OptionDomainName, o.Code(), "Code") - require.Equal(t, 3, o.Length(), "Length") require.Equal(t, []byte{'f', 'o', 'o'}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/option_domain_search.go b/dhcpv4/option_domain_search.go index 55b8bf5..d4d1383 100644 --- a/dhcpv4/option_domain_search.go +++ b/dhcpv4/option_domain_search.go @@ -27,12 +27,6 @@ func (op *OptDomainSearch) ToBytes() []byte { return op.DomainSearch.ToBytes() } -// Length returns the length of the data portion (excluding option code an byte -// length). -func (op *OptDomainSearch) Length() int { - return op.DomainSearch.Length() -} - // String returns a human-readable string. func (op *OptDomainSearch) String() string { return fmt.Sprintf("DNS Domain Search List -> %v", op.DomainSearch.Labels) diff --git a/dhcpv4/option_domain_search_test.go b/dhcpv4/option_domain_search_test.go index 677309e..6425d57 100644 --- a/dhcpv4/option_domain_search_test.go +++ b/dhcpv4/option_domain_search_test.go @@ -16,7 +16,6 @@ func TestParseOptDomainSearch(t *testing.T) { require.NoError(t, err) require.Equal(t, 2, len(opt.DomainSearch.Labels)) require.Equal(t, data, opt.DomainSearch.ToBytes()) - require.Equal(t, len(data), opt.DomainSearch.Length()) require.Equal(t, opt.DomainSearch.Labels[0], "example.com") require.Equal(t, opt.DomainSearch.Labels[1], "subnet.example.org") } diff --git a/dhcpv4/option_generic.go b/dhcpv4/option_generic.go index 4afcfe1..264340c 100644 --- a/dhcpv4/option_generic.go +++ b/dhcpv4/option_generic.go @@ -36,8 +36,3 @@ func (o OptionGeneric) ToBytes() []byte { func (o OptionGeneric) String() string { return fmt.Sprintf("%v -> %v", o.OptionCode.String(), o.Data) } - -// Length returns the number of bytes comprising the data section of the option. -func (o OptionGeneric) Length() int { - return len(o.Data) -} diff --git a/dhcpv4/option_generic_test.go b/dhcpv4/option_generic_test.go index 8a1acc1..1a35841 100644 --- a/dhcpv4/option_generic_test.go +++ b/dhcpv4/option_generic_test.go @@ -45,12 +45,3 @@ func TestOptionGenericStringUnknown(t *testing.T) { } require.Equal(t, "Unknown -> [1]", o.String()) } - -func TestOptionGenericLength(t *testing.T) { - filename := "/path/to/file" - o := OptionGeneric{ - OptionCode: OptionBootfileName, - Data: []byte(filename), - } - require.Equal(t, len(filename), o.Length()) -} diff --git a/dhcpv4/option_host_name.go b/dhcpv4/option_host_name.go index 77ed17c..417fa6d 100644 --- a/dhcpv4/option_host_name.go +++ b/dhcpv4/option_host_name.go @@ -30,9 +30,3 @@ func (o *OptHostName) ToBytes() []byte { func (o *OptHostName) String() string { return fmt.Sprintf("Host Name -> %v", o.HostName) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptHostName) Length() int { - return len(o.HostName) -} diff --git a/dhcpv4/option_host_name_test.go b/dhcpv4/option_host_name_test.go index ddae067..3761ada 100644 --- a/dhcpv4/option_host_name_test.go +++ b/dhcpv4/option_host_name_test.go @@ -9,7 +9,6 @@ import ( func TestOptHostNameInterfaceMethods(t *testing.T) { o := OptHostName{HostName: "foo"} require.Equal(t, OptionHostName, o.Code(), "Code") - require.Equal(t, 3, o.Length(), "Length") require.Equal(t, []byte{'f', 'o', 'o'}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/option_ip_address_lease_time.go b/dhcpv4/option_ip_address_lease_time.go index c020e6e..f6a85c7 100644 --- a/dhcpv4/option_ip_address_lease_time.go +++ b/dhcpv4/option_ip_address_lease_time.go @@ -38,9 +38,3 @@ func (o *OptIPAddressLeaseTime) ToBytes() []byte { func (o *OptIPAddressLeaseTime) String() string { return fmt.Sprintf("IP Addresses Lease Time -> %v", o.LeaseTime) } - -// Length returns the length of the data portion (excluding option code and byte -// for length, if any). -func (o *OptIPAddressLeaseTime) Length() int { - return 4 -} diff --git a/dhcpv4/option_ip_address_lease_time_test.go b/dhcpv4/option_ip_address_lease_time_test.go index fb11cf6..384db1c 100644 --- a/dhcpv4/option_ip_address_lease_time_test.go +++ b/dhcpv4/option_ip_address_lease_time_test.go @@ -9,7 +9,6 @@ import ( func TestOptIPAddressLeaseTimeInterfaceMethods(t *testing.T) { o := OptIPAddressLeaseTime{LeaseTime: 43200} require.Equal(t, OptionIPAddressLeaseTime, o.Code(), "Code") - require.Equal(t, 4, o.Length(), "Length") require.Equal(t, []byte{0, 0, 168, 192}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/option_maximum_dhcp_message_size.go b/dhcpv4/option_maximum_dhcp_message_size.go index 097ba8f..b8a8213 100644 --- a/dhcpv4/option_maximum_dhcp_message_size.go +++ b/dhcpv4/option_maximum_dhcp_message_size.go @@ -37,9 +37,3 @@ func (o *OptMaximumDHCPMessageSize) ToBytes() []byte { func (o *OptMaximumDHCPMessageSize) String() string { return fmt.Sprintf("Maximum DHCP Message Size -> %v", o.Size) } - -// Length returns the length of the data portion (excluding option code and byte -// for length, if any). -func (o *OptMaximumDHCPMessageSize) Length() int { - return 2 -} diff --git a/dhcpv4/option_maximum_dhcp_message_size_test.go b/dhcpv4/option_maximum_dhcp_message_size_test.go index 550ea77..0b36b0e 100644 --- a/dhcpv4/option_maximum_dhcp_message_size_test.go +++ b/dhcpv4/option_maximum_dhcp_message_size_test.go @@ -9,7 +9,6 @@ import ( func TestOptMaximumDHCPMessageSizeInterfaceMethods(t *testing.T) { o := OptMaximumDHCPMessageSize{Size: 1500} require.Equal(t, OptionMaximumDHCPMessageSize, o.Code(), "Code") - require.Equal(t, 2, o.Length(), "Length") require.Equal(t, []byte{5, 220}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/option_message_type.go b/dhcpv4/option_message_type.go index 426f35a..501394c 100644 --- a/dhcpv4/option_message_type.go +++ b/dhcpv4/option_message_type.go @@ -35,9 +35,3 @@ func (o *OptMessageType) ToBytes() []byte { func (o *OptMessageType) String() string { return fmt.Sprintf("DHCP Message Type -> %s", o.MessageType.String()) } - -// Length returns the length of the data portion (excluding option code and byte -// for length, if any). -func (o *OptMessageType) Length() int { - return 1 -} diff --git a/dhcpv4/option_message_type_test.go b/dhcpv4/option_message_type_test.go index 03ce4da..f5ad424 100644 --- a/dhcpv4/option_message_type_test.go +++ b/dhcpv4/option_message_type_test.go @@ -9,7 +9,6 @@ import ( func TestOptMessageTypeInterfaceMethods(t *testing.T) { o := OptMessageType{MessageType: MessageTypeDiscover} require.Equal(t, OptionDHCPMessageType, o.Code(), "Code") - require.Equal(t, 1, o.Length(), "Length") require.Equal(t, []byte{1}, o.ToBytes(), "ToBytes") } diff --git a/dhcpv4/option_ntp_servers.go b/dhcpv4/option_ntp_servers.go index 5415c63..1c74e13 100644 --- a/dhcpv4/option_ntp_servers.go +++ b/dhcpv4/option_ntp_servers.go @@ -36,9 +36,3 @@ func (o *OptNTPServers) ToBytes() []byte { func (o *OptNTPServers) String() string { return fmt.Sprintf("NTP Servers -> %v", IPsToString(o.NTPServers)) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptNTPServers) Length() int { - return len(o.NTPServers) * 4 -} diff --git a/dhcpv4/option_ntp_servers_test.go b/dhcpv4/option_ntp_servers_test.go index 4d321ff..d73cd24 100644 --- a/dhcpv4/option_ntp_servers_test.go +++ b/dhcpv4/option_ntp_servers_test.go @@ -14,7 +14,6 @@ func TestOptNTPServersInterfaceMethods(t *testing.T) { } o := OptNTPServers{NTPServers: ntpServers} require.Equal(t, OptionNTPServers, o.Code(), "Code") - require.Equal(t, net.IPv4len*len(ntpServers), o.Length(), "Length") require.Equal(t, ntpServers, o.NTPServers, "NTPServers") } diff --git a/dhcpv4/option_parameter_request_list.go b/dhcpv4/option_parameter_request_list.go index e3eb7ff..d1ad2a1 100644 --- a/dhcpv4/option_parameter_request_list.go +++ b/dhcpv4/option_parameter_request_list.go @@ -52,9 +52,3 @@ func (o *OptParameterRequestList) String() string { } return fmt.Sprintf("Parameter Request List -> [%v]", strings.Join(optNames, ", ")) } - -// Length returns the length of the data portion (excluding option code and byte -// for length, if any). -func (o *OptParameterRequestList) Length() int { - return len(o.RequestedOpts) -} diff --git a/dhcpv4/option_relay_agent_information.go b/dhcpv4/option_relay_agent_information.go index 624e261..d3fac80 100644 --- a/dhcpv4/option_relay_agent_information.go +++ b/dhcpv4/option_relay_agent_information.go @@ -39,13 +39,3 @@ func (o *OptRelayAgentInformation) ToBytes() []byte { func (o *OptRelayAgentInformation) String() string { return fmt.Sprintf("Relay Agent Information -> %v", o.Options) } - -// Length returns the length of the data portion (excluding option code and byte -// for length, if any). -func (o *OptRelayAgentInformation) Length() int { - l := 0 - for _, opt := range o.Options { - l += 2 + opt.Length() - } - return l -} diff --git a/dhcpv4/option_requested_ip_address.go b/dhcpv4/option_requested_ip_address.go index 403f262..d3e565d 100644 --- a/dhcpv4/option_requested_ip_address.go +++ b/dhcpv4/option_requested_ip_address.go @@ -37,9 +37,3 @@ func (o *OptRequestedIPAddress) ToBytes() []byte { func (o *OptRequestedIPAddress) String() string { return fmt.Sprintf("Requested IP Address -> %v", o.RequestedAddr.String()) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptRequestedIPAddress) Length() int { - return len(o.RequestedAddr.To4()) -} diff --git a/dhcpv4/option_requested_ip_address_test.go b/dhcpv4/option_requested_ip_address_test.go index 84761b5..7d33b1e 100644 --- a/dhcpv4/option_requested_ip_address_test.go +++ b/dhcpv4/option_requested_ip_address_test.go @@ -16,8 +16,6 @@ func TestOptRequestedIPAddressInterfaceMethods(t *testing.T) { expectedBytes := []byte{192, 168, 0, 1} require.Equal(t, expectedBytes, o.ToBytes(), "ToBytes") - require.Equal(t, 4, o.Length(), "Length") - require.Equal(t, "Requested IP Address -> 192.168.0.1", o.String(), "String") } diff --git a/dhcpv4/option_root_path.go b/dhcpv4/option_root_path.go index 350109f..84e392e 100644 --- a/dhcpv4/option_root_path.go +++ b/dhcpv4/option_root_path.go @@ -32,9 +32,3 @@ func (o *OptRootPath) ToBytes() []byte { func (o *OptRootPath) String() string { return fmt.Sprintf("Root Path -> %v", o.Path) } - -// Length returns the length of the data portion (excluding option code and byte -// for length, if any). -func (o *OptRootPath) Length() int { - return len(o.Path) -} diff --git a/dhcpv4/option_root_path_test.go b/dhcpv4/option_root_path_test.go index 0bfbd65..e05dd0e 100644 --- a/dhcpv4/option_root_path_test.go +++ b/dhcpv4/option_root_path_test.go @@ -9,7 +9,6 @@ import ( func TestOptRootPathInterfaceMethods(t *testing.T) { o := OptRootPath{Path: "/foo/bar/baz"} require.Equal(t, OptionRootPath, o.Code(), "Code") - require.Equal(t, 12, o.Length(), "Length") wantBytes := []byte{ '/', 'f', 'o', 'o', '/', 'b', 'a', 'r', '/', 'b', 'a', 'z', } diff --git a/dhcpv4/option_router.go b/dhcpv4/option_router.go index 686e3dc..a082414 100644 --- a/dhcpv4/option_router.go +++ b/dhcpv4/option_router.go @@ -76,9 +76,3 @@ func (o *OptRouter) ToBytes() []byte { func (o *OptRouter) String() string { return fmt.Sprintf("Routers -> %s", IPsToString(o.Routers)) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptRouter) Length() int { - return len(o.Routers) * 4 -} diff --git a/dhcpv4/option_router_test.go b/dhcpv4/option_router_test.go index 3264ce3..0f23858 100644 --- a/dhcpv4/option_router_test.go +++ b/dhcpv4/option_router_test.go @@ -14,7 +14,6 @@ func TestOptRoutersInterfaceMethods(t *testing.T) { } o := OptRouter{Routers: routers} require.Equal(t, OptionRouter, o.Code(), "Code") - require.Equal(t, net.IPv4len*len(routers), o.Length(), "Length") require.Equal(t, routers, o.Routers, "Routers") } diff --git a/dhcpv4/option_server_identifier.go b/dhcpv4/option_server_identifier.go index 64185aa..cc5e1a5 100644 --- a/dhcpv4/option_server_identifier.go +++ b/dhcpv4/option_server_identifier.go @@ -36,9 +36,3 @@ func (o *OptServerIdentifier) ToBytes() []byte { func (o *OptServerIdentifier) String() string { return fmt.Sprintf("Server Identifier -> %v", o.ServerID.String()) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptServerIdentifier) Length() int { - return len(o.ServerID.To4()) -} diff --git a/dhcpv4/option_server_identifier_test.go b/dhcpv4/option_server_identifier_test.go index f41c90f..e250ad7 100644 --- a/dhcpv4/option_server_identifier_test.go +++ b/dhcpv4/option_server_identifier_test.go @@ -16,8 +16,6 @@ func TestOptServerIdentifierInterfaceMethods(t *testing.T) { expectedBytes := []byte{192, 168, 0, 1} require.Equal(t, expectedBytes, o.ToBytes(), "ToBytes") - require.Equal(t, 4, o.Length(), "Length") - require.Equal(t, "Server Identifier -> 192.168.0.1", o.String(), "String") } diff --git a/dhcpv4/option_subnet_mask.go b/dhcpv4/option_subnet_mask.go index 7c8a2c1..037a0ad 100644 --- a/dhcpv4/option_subnet_mask.go +++ b/dhcpv4/option_subnet_mask.go @@ -36,9 +36,3 @@ func (o *OptSubnetMask) ToBytes() []byte { func (o *OptSubnetMask) String() string { return fmt.Sprintf("Subnet Mask -> %v", o.SubnetMask.String()) } - -// Length returns the length of the data portion (excluding option code an byte -// length). -func (o *OptSubnetMask) Length() int { - return 4 -} diff --git a/dhcpv4/option_subnet_mask_test.go b/dhcpv4/option_subnet_mask_test.go index beeeda0..f04a481 100644 --- a/dhcpv4/option_subnet_mask_test.go +++ b/dhcpv4/option_subnet_mask_test.go @@ -16,8 +16,6 @@ func TestOptSubnetMaskInterfaceMethods(t *testing.T) { expectedBytes := []byte{255, 255, 255, 0} require.Equal(t, expectedBytes, o.ToBytes(), "ToBytes") - require.Equal(t, 4, o.Length(), "Length") - require.Equal(t, "Subnet Mask -> ffffff00", o.String(), "String") } diff --git a/dhcpv4/option_tftp_server_name.go b/dhcpv4/option_tftp_server_name.go index 2aa832f..3daa2f5 100644 --- a/dhcpv4/option_tftp_server_name.go +++ b/dhcpv4/option_tftp_server_name.go @@ -22,11 +22,6 @@ func (op *OptTFTPServerName) ToBytes() []byte { return []byte(op.TFTPServerName) } -// Length returns the option length in bytes -func (op *OptTFTPServerName) Length() int { - return len(op.TFTPServerName) -} - func (op *OptTFTPServerName) String() string { return fmt.Sprintf("TFTP Server Name -> %s", op.TFTPServerName) } diff --git a/dhcpv4/option_tftp_server_name_test.go b/dhcpv4/option_tftp_server_name_test.go index d85b254..c46b5db 100644 --- a/dhcpv4/option_tftp_server_name_test.go +++ b/dhcpv4/option_tftp_server_name_test.go @@ -28,7 +28,6 @@ func TestParseOptTFTPServerName(t *testing.T) { } opt, err := ParseOptTFTPServerName(expected) require.NoError(t, err) - require.Equal(t, 9, opt.Length()) require.Equal(t, "linuxboot", string(opt.TFTPServerName)) } diff --git a/dhcpv4/option_userclass.go b/dhcpv4/option_userclass.go index 560d6ac..2e31846 100644 --- a/dhcpv4/option_userclass.go +++ b/dhcpv4/option_userclass.go @@ -36,18 +36,6 @@ func (op *OptUserClass) ToBytes() []byte { return buf.Data() } -// Length returns the option length -func (op *OptUserClass) Length() int { - ret := 0 - if !op.Rfc3004 { - return len(op.UserClasses[0]) - } - for _, uc := range op.UserClasses { - ret += 1 + len(uc) - } - return ret -} - func (op *OptUserClass) String() string { ucStrings := make([]string, 0, len(op.UserClasses)) if !op.Rfc3004 { diff --git a/dhcpv4/option_userclass_test.go b/dhcpv4/option_userclass_test.go index ccbabef..e321a64 100644 --- a/dhcpv4/option_userclass_test.go +++ b/dhcpv4/option_userclass_test.go @@ -93,15 +93,6 @@ func TestOptUserClassToBytesMultiple(t *testing.T) { require.Equal(t, expected, data) } -func TestOptUserClassLength(t *testing.T) { - expected := []byte{ - 9, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', 'X', - } - opt, err := ParseOptUserClass(expected) - require.NoError(t, err) - require.Equal(t, 11, opt.Length()) -} - func TestParseOptUserClassZeroLength(t *testing.T) { expected := []byte{ 0, 0, diff --git a/dhcpv4/option_vivc.go b/dhcpv4/option_vivc.go index 4c278e0..b0fe85d 100644 --- a/dhcpv4/option_vivc.go +++ b/dhcpv4/option_vivc.go @@ -63,14 +63,3 @@ func (o *OptVIVC) String() string { return buf.String()[:buf.Len()-1] } - -// Length returns the length of the data portion (excluding option code and byte -// for length, if any). -func (o *OptVIVC) Length() int { - n := 0 - for _, id := range o.Identifiers { - // each class has a header of endID (4 bytes) and length (1 byte) - n += 5 + len(id.Data) - } - return n -} diff --git a/dhcpv4/option_vivc_test.go b/dhcpv4/option_vivc_test.go index 855bc2a..9b3b704 100644 --- a/dhcpv4/option_vivc_test.go +++ b/dhcpv4/option_vivc_test.go @@ -25,7 +25,6 @@ var ( func TestOptVIVCInterfaceMethods(t *testing.T) { require.Equal(t, OptionVendorIdentifyingVendorClass, sampleVIVCOpt.Code(), "Code") - require.Equal(t, 44, sampleVIVCOpt.Length(), "Length") require.Equal(t, sampleVIVCOptRaw, sampleVIVCOpt.ToBytes(), "ToBytes") } diff --git a/dhcpv4/options.go b/dhcpv4/options.go index ce2fdcd..905495e 100644 --- a/dhcpv4/options.go +++ b/dhcpv4/options.go @@ -31,7 +31,6 @@ type OptionCode byte type Option interface { Code() OptionCode ToBytes() []byte - Length() int String() string } diff --git a/dhcpv4/options_test.go b/dhcpv4/options_test.go index 02d4018..6e50768 100644 --- a/dhcpv4/options_test.go +++ b/dhcpv4/options_test.go @@ -18,7 +18,6 @@ func TestParseOption(t *testing.T) { generic := opt.(*OptionGeneric) require.Equal(t, OptionNameServer, generic.Code()) require.Equal(t, []byte{192, 168, 1, 254}, generic.Data) - require.Equal(t, 4, generic.Length()) require.Equal(t, "Name Server -> [192 168 1 254]", generic.String()) // Option subnet mask @@ -26,7 +25,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionSubnetMask, option) require.NoError(t, err) require.Equal(t, OptionSubnetMask, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option router @@ -34,7 +32,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionRouter, option) require.NoError(t, err) require.Equal(t, OptionRouter, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option domain name server @@ -42,7 +39,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionDomainNameServer, option) require.NoError(t, err) require.Equal(t, OptionDomainNameServer, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option host name @@ -50,7 +46,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionHostName, option) require.NoError(t, err) require.Equal(t, OptionHostName, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option domain name @@ -58,7 +53,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionDomainName, option) require.NoError(t, err) require.Equal(t, OptionDomainName, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option root path @@ -66,7 +60,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionRootPath, option) require.NoError(t, err) require.Equal(t, OptionRootPath, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option broadcast address @@ -74,7 +67,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionBroadcastAddress, option) require.NoError(t, err) require.Equal(t, OptionBroadcastAddress, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option NTP servers @@ -82,7 +74,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionNTPServers, option) require.NoError(t, err) require.Equal(t, OptionNTPServers, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Requested IP address @@ -90,7 +81,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionRequestedIPAddress, option) require.NoError(t, err) require.Equal(t, OptionRequestedIPAddress, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Requested IP address lease time @@ -98,7 +88,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionIPAddressLeaseTime, option) require.NoError(t, err) require.Equal(t, OptionIPAddressLeaseTime, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Message type @@ -106,7 +95,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionDHCPMessageType, option) require.NoError(t, err) require.Equal(t, OptionDHCPMessageType, opt.Code(), "Code") - require.Equal(t, 1, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option server ID @@ -114,7 +102,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionServerIdentifier, option) require.NoError(t, err) require.Equal(t, OptionServerIdentifier, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Parameter request list @@ -122,7 +109,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionParameterRequestList, option) require.NoError(t, err) require.Equal(t, OptionParameterRequestList, opt.Code(), "Code") - require.Equal(t, 3, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option max message size @@ -130,7 +116,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionMaximumDHCPMessageSize, option) require.NoError(t, err) require.Equal(t, OptionMaximumDHCPMessageSize, opt.Code(), "Code") - require.Equal(t, 2, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option class identifier @@ -138,7 +123,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionClassIdentifier, option) require.NoError(t, err) require.Equal(t, OptionClassIdentifier, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option TFTP server name @@ -146,7 +130,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionTFTPServerName, option) require.NoError(t, err) require.Equal(t, OptionTFTPServerName, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option Bootfile name @@ -154,7 +137,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionBootfileName, option) require.NoError(t, err) require.Equal(t, OptionBootfileName, opt.Code(), "Code") - require.Equal(t, 9, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option user class information @@ -162,7 +144,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionUserClassInformation, option) require.NoError(t, err) require.Equal(t, OptionUserClassInformation, opt.Code(), "Code") - require.Equal(t, 5, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option relay agent information @@ -170,7 +151,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionRelayAgentInformation, option) require.NoError(t, err) require.Equal(t, OptionRelayAgentInformation, opt.Code(), "Code") - require.Equal(t, 6, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") // Option client system architecture type option @@ -178,7 +158,6 @@ func TestParseOption(t *testing.T) { opt, err = ParseOption(OptionClientSystemArchitectureType, option) require.NoError(t, err) require.Equal(t, OptionClientSystemArchitectureType, opt.Code(), "Code") - require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") } |