summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_archtype.go
diff options
context:
space:
mode:
authorPablo Mazzini <pmazzini@gmail.com>2018-08-12 16:17:11 +0200
committerPablo Mazzini <pmazzini@gmail.com>2018-08-13 11:52:28 +0200
commit72d70d68dfcbdbe112d9f82ead6d987898417f95 (patch)
treee36f9cfab0213ff4e43335966c57e7f73c0682bf /dhcpv4/option_archtype.go
parentb773f618967811e235b334516b0c40563c3a1464 (diff)
fix OptClientArchType
Diffstat (limited to 'dhcpv4/option_archtype.go')
-rw-r--r--dhcpv4/option_archtype.go42
1 files changed, 5 insertions, 37 deletions
diff --git a/dhcpv4/option_archtype.go b/dhcpv4/option_archtype.go
index 16ca98d..8eafc55 100644
--- a/dhcpv4/option_archtype.go
+++ b/dhcpv4/option_archtype.go
@@ -6,43 +6,14 @@ package dhcpv4
import (
"encoding/binary"
"fmt"
-)
-
-//ArchType encodes an architecture type in an uint16
-type ArchType uint16
-// see rfc4578
-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
+ "github.com/insomniacslk/dhcp/iana"
)
-// ArchTypeToStringMap maps an ArchType to a mnemonic name
-var ArchTypeToStringMap = map[ArchType]string{
- INTEL_X86PC: "Intel x86PC",
- NEC_PC98: "NEC/PC98",
- EFI_ITANIUM: "EFI Itanium",
- DEC_ALPHA: "DEC Alpha",
- ARC_X86: "Arc x86",
- INTEL_LEAN_CLIENT: "Intel Lean Client",
- EFI_IA32: "EFI IA32",
- EFI_BC: "EFI BC",
- EFI_XSCALE: "EFI Xscale",
- EFI_X86_64: "EFI x86-64",
-}
-
// OptClientArchType represents an option encapsulating the Client System
// Architecture Type option Definition.
type OptClientArchType struct {
- ArchTypes []ArchType
+ ArchTypes []iana.ArchType
}
// Code returns the option code.
@@ -71,10 +42,7 @@ func (o *OptClientArchType) Length() int {
func (o *OptClientArchType) String() string {
var archTypes string
for idx, at := range o.ArchTypes {
- name, ok := ArchTypeToStringMap[at]
- if !ok {
- name = "Unknown"
- }
+ name := iana.ArchTypeToString(at)
archTypes += name
if idx < len(o.ArchTypes)-1 {
archTypes += ", "
@@ -100,10 +68,10 @@ func ParseOptClientArchType(data []byte) (*OptClientArchType, error) {
if len(data) < 2+length {
return nil, ErrShortByteStream
}
- archTypes := make([]ArchType, 0, length%2)
+ archTypes := make([]iana.ArchType, 0, length%2)
for idx := 0; idx < length; idx += 2 {
b := data[2+idx : 2+idx+2]
- archTypes = append(archTypes, ArchType(binary.BigEndian.Uint16(b)))
+ archTypes = append(archTypes, iana.ArchType(binary.BigEndian.Uint16(b)))
}
return &OptClientArchType{ArchTypes: archTypes}, nil
}