summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/bsdp/option_vendor_specific_information_test.go
diff options
context:
space:
mode:
authorChristopher Koch <chrisko@google.com>2019-01-13 15:52:18 -0500
committerinsomniac <insomniacslk@users.noreply.github.com>2019-01-15 14:35:19 +0000
commit916e0d0fc6b84b1be09ed1bb16b8de09943a9921 (patch)
treecd78de83de0c94d3377abf6f34a964b23c94a61b /dhcpv4/bsdp/option_vendor_specific_information_test.go
parent84a6137d6c7a6de89e1de7010eb6d003290f89c2 (diff)
dhcpv4: conform to RFC 2131 with respect to options.
Removes AddOption and GetOption. RFC 2131 specifies that options may only appear once (Section 4.1). If an option does appear more than once, its byte values must be concatenated. RFC 3396 further specifies that to send options longer than 255 bytes, one option may be split into multiple option codes, which must be concatenated back together by the receiver. Both of these are concerned with the byte representation of options. Fact is, based on both RFCs one can say that an option may only appear once, but may be composed of multiple values. Because an option may appear only once logically in any case, we remove the AddOption and GetOption functions and leave only UpdateOption and GetOneOption. Also remove all additions & checks of the End option - the marshaling and unmarshaling code is exclusively responsible for that now.
Diffstat (limited to 'dhcpv4/bsdp/option_vendor_specific_information_test.go')
-rw-r--r--dhcpv4/bsdp/option_vendor_specific_information_test.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/dhcpv4/bsdp/option_vendor_specific_information_test.go b/dhcpv4/bsdp/option_vendor_specific_information_test.go
index 64977c4..ede8a0b 100644
--- a/dhcpv4/bsdp/option_vendor_specific_information_test.go
+++ b/dhcpv4/bsdp/option_vendor_specific_information_test.go
@@ -166,52 +166,6 @@ func TestOptVendorSpecificInformationString(t *testing.T) {
require.Equal(t, expectedString, o.String())
}
-func TestOptVendorSpecificInformationGetOptions(t *testing.T) {
- // No option
- o := &OptVendorSpecificInformation{
- []dhcpv4.Option{
- &OptMessageType{MessageTypeList},
- Version1_1,
- },
- }
- foundOpts := o.GetOption(OptionBootImageList)
- require.Empty(t, foundOpts, "should not get any options")
-
- // One option
- o = &OptVendorSpecificInformation{
- []dhcpv4.Option{
- &OptMessageType{MessageTypeList},
- Version1_1,
- },
- }
- foundOpts = o.GetOption(OptionMessageType)
- require.Equal(t, 1, len(foundOpts), "should only get one option")
- require.Equal(t, MessageTypeList, foundOpts[0].(*OptMessageType).Type)
-
- // Multiple options
- //
- // TODO: Remove this test when RFC 3396 is properly implemented. This
- // isn't a valid packet. RFC 2131, Section 4.1: "Options may appear
- // only once." RFC 3396 clarifies this to say that options will be
- // concatenated. I.e., in this case, the bytes would be:
- //
- // <versioncode> 4 1 1 0 1
- //
- // Which would obviously not be parsed by the Version parser, as it
- // only accepts two bytes.
- o = &OptVendorSpecificInformation{
- []dhcpv4.Option{
- &OptMessageType{MessageTypeList},
- Version1_1,
- Version1_0,
- },
- }
- foundOpts = o.GetOption(OptionVersion)
- require.Equal(t, 2, len(foundOpts), "should get two options")
- require.Equal(t, Version1_1, foundOpts[0].(Version))
- require.Equal(t, Version1_0, foundOpts[1].(Version))
-}
-
func TestOptVendorSpecificInformationGetOneOption(t *testing.T) {
// No option
o := &OptVendorSpecificInformation{
@@ -232,15 +186,4 @@ func TestOptVendorSpecificInformationGetOneOption(t *testing.T) {
}
foundOpt = o.GetOneOption(OptionMessageType)
require.Equal(t, MessageTypeList, foundOpt.(*OptMessageType).Type)
-
- // Multiple options
- o = &OptVendorSpecificInformation{
- []dhcpv4.Option{
- &OptMessageType{MessageTypeList},
- Version1_1,
- Version1_0,
- },
- }
- foundOpt = o.GetOneOption(OptionVersion)
- require.Equal(t, Version1_1, foundOpt.(Version))
}