1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
package dhcpv6
import (
"fmt"
"github.com/u-root/u-root/pkg/uio"
)
// see rfc4578
const (
NII_LANDESK_NOPXE = 0
NII_PXE_GEN_I = 1
NII_PXE_GEN_II = 2
NII_UNDI_NOEFI = 3
NII_UNDI_EFI_GEN_I = 4
NII_UNDI_EFI_GEN_II = 5
)
var niiToStringMap = map[uint8]string{
NII_LANDESK_NOPXE: "LANDesk service agent boot ROMs. No PXE",
NII_PXE_GEN_I: "First gen. PXE boot ROMs",
NII_PXE_GEN_II: "Second gen. PXE boot ROMs",
NII_UNDI_NOEFI: "UNDI 32/64 bit. UEFI drivers, no UEFI runtime",
NII_UNDI_EFI_GEN_I: "UNDI 32/64 bit. UEFI runtime 1st gen",
NII_UNDI_EFI_GEN_II: "UNDI 32/64 bit. UEFI runtime 2nd gen",
}
// OptNetworkInterfaceId implements the NIC ID option for network booting as
// defined by RFC 4578 Section 2.2 and RFC 5970 Section 3.4.
type OptNetworkInterfaceId struct {
type_ uint8
major, minor uint8 // revision number
}
func (op *OptNetworkInterfaceId) Code() OptionCode {
return OptionNII
}
func (op *OptNetworkInterfaceId) ToBytes() []byte {
buf := uio.NewBigEndianBuffer(nil)
buf.Write8(op.type_)
buf.Write8(op.major)
buf.Write8(op.minor)
return buf.Data()
}
func (op *OptNetworkInterfaceId) Type() uint8 {
return op.type_
}
func (op *OptNetworkInterfaceId) SetType(type_ uint8) {
op.type_ = type_
}
func (op *OptNetworkInterfaceId) Major() uint8 {
return op.major
}
func (op *OptNetworkInterfaceId) SetMajor(major uint8) {
op.major = major
}
func (op *OptNetworkInterfaceId) Minor() uint8 {
return op.minor
}
func (op *OptNetworkInterfaceId) SetMinor(minor uint8) {
op.minor = minor
}
func (op *OptNetworkInterfaceId) String() string {
typeName, ok := niiToStringMap[op.type_]
if !ok {
typeName = "Unknown"
}
return fmt.Sprintf("OptNetworkInterfaceId{type=%v, revision=%v.%v}",
typeName, op.major, op.minor,
)
}
// build an OptNetworkInterfaceId structure from a sequence of bytes.
// The input data does not include option code and length bytes.
func ParseOptNetworkInterfaceId(data []byte) (*OptNetworkInterfaceId, error) {
buf := uio.NewBigEndianBuffer(data)
var opt OptNetworkInterfaceId
opt.type_ = buf.Read8()
opt.major = buf.Read8()
opt.minor = buf.Read8()
return &opt, buf.FinError()
}
|