From 9492662dae0651fd4d6698d35b58ade7300e149e Mon Sep 17 00:00:00 2001 From: Christopher Koch Date: Sat, 29 Dec 2018 09:16:15 -0800 Subject: dhcpv4: simplify marshaling options to binary. - Consolidate writing the option code and length to Options.Marshal rather than doing it in each individual option. - Use uio in marshaling code. --- dhcpv4/option_relay_agent_information.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'dhcpv4/option_relay_agent_information.go') diff --git a/dhcpv4/option_relay_agent_information.go b/dhcpv4/option_relay_agent_information.go index d6547fe..624e261 100644 --- a/dhcpv4/option_relay_agent_information.go +++ b/dhcpv4/option_relay_agent_information.go @@ -1,6 +1,10 @@ package dhcpv4 -import "fmt" +import ( + "fmt" + + "github.com/u-root/u-root/pkg/uio" +) // This option implements the relay agent information option // https://tools.ietf.org/html/rfc3046 @@ -28,11 +32,7 @@ func (o *OptRelayAgentInformation) Code() OptionCode { // ToBytes returns a serialized stream of bytes for this option. func (o *OptRelayAgentInformation) ToBytes() []byte { - ret := []byte{byte(o.Code()), byte(o.Length())} - for _, opt := range o.Options { - ret = append(ret, opt.ToBytes()...) - } - return ret + return uio.ToBigEndian(o.Options) } // String returns a human-readable string for this option. -- cgit v1.2.3