diff options
-rw-r--r-- | dhcpv4/option_archtype.go | 6 | ||||
-rw-r--r-- | dhcpv4/option_archtype_test.go | 2 | ||||
-rw-r--r-- | dhcpv6/dhcpv6_test.go | 4 | ||||
-rw-r--r-- | dhcpv6/modifiers.go | 4 | ||||
-rw-r--r-- | dhcpv6/option_archtype.go | 4 | ||||
-rw-r--r-- | dhcpv6/option_archtype_test.go | 2 | ||||
-rw-r--r-- | iana/archtype.go | 39 |
7 files changed, 30 insertions, 31 deletions
diff --git a/dhcpv4/option_archtype.go b/dhcpv4/option_archtype.go index 2977d8a..c475174 100644 --- a/dhcpv4/option_archtype.go +++ b/dhcpv4/option_archtype.go @@ -13,7 +13,7 @@ import ( // OptClientArchType represents an option encapsulating the Client System // Architecture Type option Definition. type OptClientArchType struct { - ArchTypes []iana.ArchType + ArchTypes []iana.Arch } // Code returns the option code. @@ -50,9 +50,9 @@ func ParseOptClientArchType(data []byte) (*OptClientArchType, error) { return nil, fmt.Errorf("must have at least one archtype if option is present") } - archTypes := make([]iana.ArchType, 0, buf.Len()/2) + archTypes := make([]iana.Arch, 0, buf.Len()/2) for buf.Has(2) { - archTypes = append(archTypes, iana.ArchType(buf.Read16())) + archTypes = append(archTypes, iana.Arch(buf.Read16())) } return &OptClientArchType{ArchTypes: archTypes}, buf.FinError() } diff --git a/dhcpv4/option_archtype_test.go b/dhcpv4/option_archtype_test.go index 7be896e..60f8864 100644 --- a/dhcpv4/option_archtype_test.go +++ b/dhcpv4/option_archtype_test.go @@ -54,7 +54,7 @@ func TestOptClientArchTypeParseAndToBytesMultiple(t *testing.T) { func TestOptClientArchType(t *testing.T) { opt := OptClientArchType{ - ArchTypes: []iana.ArchType{iana.EFI_ITANIUM}, + ArchTypes: []iana.Arch{iana.EFI_ITANIUM}, } require.Equal(t, opt.Code(), OptionClientSystemArchitectureType) } diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go index 84cdb50..b1da1d8 100644 --- a/dhcpv6/dhcpv6_test.go +++ b/dhcpv6/dhcpv6_test.go @@ -293,14 +293,14 @@ func TestNewMessageTypeSolicitWithCID(t *testing.T) { func TestIsUsingUEFIArchTypeTrue(t *testing.T) { msg := DHCPv6Message{} - opt := OptClientArchType{ArchTypes: []iana.ArchType{iana.EFI_BC}} + opt := OptClientArchType{ArchTypes: []iana.Arch{iana.EFI_BC}} msg.AddOption(&opt) require.True(t, IsUsingUEFI(&msg)) } func TestIsUsingUEFIArchTypeFalse(t *testing.T) { msg := DHCPv6Message{} - opt := OptClientArchType{ArchTypes: []iana.ArchType{iana.INTEL_X86PC}} + opt := OptClientArchType{ArchTypes: []iana.Arch{iana.INTEL_X86PC}} msg.AddOption(&opt) require.False(t, IsUsingUEFI(&msg)) } diff --git a/dhcpv6/modifiers.go b/dhcpv6/modifiers.go index 16c71a3..a3d7986 100644 --- a/dhcpv6/modifiers.go +++ b/dhcpv6/modifiers.go @@ -57,9 +57,9 @@ func WithUserClass(uc []byte) Modifier { } // WithArchType adds an arch type option to the packet -func WithArchType(at iana.ArchType) Modifier { +func WithArchType(at iana.Arch) Modifier { return func(d DHCPv6) DHCPv6 { - ao := OptClientArchType{ArchTypes: []iana.ArchType{at}} + ao := OptClientArchType{ArchTypes: []iana.Arch{at}} d.AddOption(&ao) return d } diff --git a/dhcpv6/option_archtype.go b/dhcpv6/option_archtype.go index 636d10f..058754a 100644 --- a/dhcpv6/option_archtype.go +++ b/dhcpv6/option_archtype.go @@ -13,7 +13,7 @@ import ( // OptClientArchType represents an option CLIENT_ARCH_TYPE type OptClientArchType struct { - ArchTypes []iana.ArchType + ArchTypes []iana.Arch } func (op *OptClientArchType) Code() OptionCode { @@ -54,7 +54,7 @@ func ParseOptClientArchType(data []byte) (*OptClientArchType, error) { } for idx := 0; idx < len(data); idx += 2 { b := data[idx : idx+2] - opt.ArchTypes = append(opt.ArchTypes, iana.ArchType(binary.BigEndian.Uint16(b))) + opt.ArchTypes = append(opt.ArchTypes, iana.Arch(binary.BigEndian.Uint16(b))) } return &opt, nil } diff --git a/dhcpv6/option_archtype_test.go b/dhcpv6/option_archtype_test.go index d5b2b99..abf872d 100644 --- a/dhcpv6/option_archtype_test.go +++ b/dhcpv6/option_archtype_test.go @@ -38,7 +38,7 @@ func TestOptClientArchTypeParseAndToBytes(t *testing.T) { func TestOptClientArchType(t *testing.T) { opt := OptClientArchType{ - ArchTypes: []iana.ArchType{iana.EFI_ITANIUM}, + ArchTypes: []iana.Arch{iana.EFI_ITANIUM}, } require.Equal(t, 2, opt.Length()) require.Equal(t, OptionClientArchType, opt.Code()) diff --git a/iana/archtype.go b/iana/archtype.go index ca21490..510c6fc 100644 --- a/iana/archtype.go +++ b/iana/archtype.go @@ -1,24 +1,24 @@ package iana -//ArchType encodes an architecture type in an uint16 -type ArchType uint16 +// Arch encodes an architecture type per RFC 4578, Section 2.1. +type Arch uint16 -// see rfc4578 +// See RFC 4578. const ( - INTEL_X86PC ArchType = 0 - NEC_PC98 ArchType = 1 - EFI_ITANIUM ArchType = 2 - DEC_ALPHA ArchType = 3 - ARC_X86 ArchType = 4 - INTEL_LEAN_CLIENT ArchType = 5 - EFI_IA32 ArchType = 6 - EFI_BC ArchType = 7 - EFI_XSCALE ArchType = 8 - EFI_X86_64 ArchType = 9 + INTEL_X86PC Arch = 0 + NEC_PC98 Arch = 1 + EFI_ITANIUM Arch = 2 + DEC_ALPHA Arch = 3 + ARC_X86 Arch = 4 + INTEL_LEAN_CLIENT Arch = 5 + EFI_IA32 Arch = 6 + EFI_BC Arch = 7 + EFI_XSCALE Arch = 8 + EFI_X86_64 Arch = 9 ) -// ArchTypeToStringMap maps an ArchType to a mnemonic name -var ArchTypeToStringMap = map[ArchType]string{ +// archTypeToStringMap maps an Arch to a mnemonic name +var archTypeToStringMap = map[Arch]string{ INTEL_X86PC: "Intel x86PC", NEC_PC98: "NEC/PC98", EFI_ITANIUM: "EFI Itanium", @@ -31,11 +31,10 @@ var ArchTypeToStringMap = map[ArchType]string{ EFI_X86_64: "EFI x86-64", } - -// String returns a mnemonic name for a given architecture type -func (a ArchType) String() string { - if at := ArchTypeToStringMap[a]; at != "" { +// String returns a mnemonic name for a given architecture type. +func (a Arch) String() string { + if at := archTypeToStringMap[a]; at != "" { return at } - return "Unknown" + return "unknown" } |