From 916e0d0fc6b84b1be09ed1bb16b8de09943a9921 Mon Sep 17 00:00:00 2001 From: Christopher Koch Date: Sun, 13 Jan 2019 15:52:18 -0500 Subject: 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. --- dhcpv4/ztpv4/ztp_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dhcpv4/ztpv4') diff --git a/dhcpv4/ztpv4/ztp_test.go b/dhcpv4/ztpv4/ztp_test.go index 9950bf5..680f15a 100644 --- a/dhcpv4/ztpv4/ztp_test.go +++ b/dhcpv4/ztpv4/ztp_test.go @@ -54,13 +54,13 @@ func TestParseV4VendorClass(t *testing.T) { } if tc.vc != "" { - packet.AddOption(&dhcpv4.OptClassIdentifier{ + packet.UpdateOption(&dhcpv4.OptClassIdentifier{ Identifier: tc.vc, }) } if tc.hostname != "" { - packet.AddOption(&dhcpv4.OptHostName{ + packet.UpdateOption(&dhcpv4.OptHostName{ HostName: tc.hostname, }) } -- cgit v1.2.3