diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2018-08-02 15:21:33 +0200 |
---|---|---|
committer | Pablo Mazzini <pmazzini@gmail.com> | 2018-08-02 19:11:56 +0200 |
commit | 1f8480c7ad48bab220f830c9c3ec02e43dae1d6e (patch) | |
tree | 9f53d4b1eedbe0f0e032fefa540d97868fa657b1 /dhcpv4/option_archtype.go | |
parent | de11326c564574a39b8b70dacbb44347b2985795 (diff) |
OptClientArchType: add comments
Diffstat (limited to 'dhcpv4/option_archtype.go')
-rw-r--r-- | dhcpv4/option_archtype.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/dhcpv4/option_archtype.go b/dhcpv4/option_archtype.go index eb5b365..3121d36 100644 --- a/dhcpv4/option_archtype.go +++ b/dhcpv4/option_archtype.go @@ -39,15 +39,18 @@ var ArchTypeToStringMap = map[ArchType]string{ EFI_X86_64: "EFI x86-64", } -// OptClientArchType represents an option CLIENT_ARCH_TYPE +// OptRouter represents an option encapsulating the Client System Architecture +// Type option Definition. type OptClientArchType struct { ArchTypes []ArchType } +// Code returns the option code. func (o *OptClientArchType) Code() OptionCode { return OptionClientSystemArchitectureType } +// ToBytes returns a serialized stream of bytes for this option. func (o *OptClientArchType) ToBytes() []byte { ret := []byte{byte(o.Code()), byte(o.Length())} for _, at := range o.ArchTypes { @@ -58,10 +61,13 @@ func (o *OptClientArchType) ToBytes() []byte { return ret } +// 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 for idx, at := range o.ArchTypes { @@ -77,9 +83,8 @@ func (o *OptClientArchType) String() string { return fmt.Sprintf("Client System Architecture Type -> %v", archTypes) } -// ParseOptClientArchType builds an OptClientArchType structure from -// a sequence of bytes The input data does not include option code and -// length bytes. +// ParseOptClientArchType returns a new OptClientArchType from a byte stream, +// or error if any. func ParseOptClientArchType(data []byte) (*OptClientArchType, error) { if len(data) < 2 { return nil, ErrShortByteStream |