diff options
Diffstat (limited to 'dhcpv6')
-rw-r--r-- | dhcpv6/dhcpv6.go | 36 | ||||
-rw-r--r-- | dhcpv6/dhcpv6_test.go | 26 |
2 files changed, 0 insertions, 62 deletions
diff --git a/dhcpv6/dhcpv6.go b/dhcpv6/dhcpv6.go index 0f3c7da..59d9733 100644 --- a/dhcpv6/dhcpv6.go +++ b/dhcpv6/dhcpv6.go @@ -5,9 +5,7 @@ package dhcpv6 import ( "fmt" "net" - "strings" - "github.com/insomniacslk/dhcp/iana" "github.com/u-root/uio/uio" ) @@ -181,40 +179,6 @@ func EncapsulateRelay(d DHCPv6, mType MessageType, linkAddr, peerAddr net.IP) (* return &outer, nil } -// IsUsingUEFI function takes a DHCPv6 message and returns true if -// the machine trying to netboot is using UEFI of false if it is not. -func IsUsingUEFI(msg *Message) bool { - // RFC 4578 says: - // As of the writing of this document, the following pre-boot - // architecture types have been requested. - // Type Architecture Name - // ---- ----------------- - // 0 Intel x86PC - // 1 NEC/PC98 - // 2 EFI Itanium - // 3 DEC Alpha - // 4 Arc x86 - // 5 Intel Lean Client - // 6 EFI IA32 - // 7 EFI BC - // 8 EFI Xscale - // 9 EFI x86-64 - if archTypes := msg.Options.ArchTypes(); archTypes != nil { - if archTypes.Contains(iana.EFI_BC) || archTypes.Contains(iana.EFI_X86_64) { - return true - } - } - if opt := msg.GetOneOption(OptionUserClass); opt != nil { - optuc := opt.(*OptUserClass) - for _, uc := range optuc.UserClasses { - if strings.Contains(string(uc), "EFI") { - return true - } - } - } - return false -} - // GetTransactionID returns a transactionID of a message or its inner message // in case of relay func GetTransactionID(packet DHCPv6) (TransactionID, error) { diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go index a329e0a..b1f952d 100644 --- a/dhcpv6/dhcpv6_test.go +++ b/dhcpv6/dhcpv6_test.go @@ -254,32 +254,6 @@ func TestNewMessageTypeSolicit(t *testing.T) { require.Equal(t, iaid, iana.IaId) } -func TestIsUsingUEFIArchTypeTrue(t *testing.T) { - msg := Message{} - msg.AddOption(OptClientArchType(iana.EFI_BC)) - require.True(t, IsUsingUEFI(&msg)) -} - -func TestIsUsingUEFIArchTypeFalse(t *testing.T) { - msg := Message{} - msg.AddOption(OptClientArchType(iana.INTEL_X86PC)) - require.False(t, IsUsingUEFI(&msg)) -} - -func TestIsUsingUEFIUserClassTrue(t *testing.T) { - msg := Message{} - opt := OptUserClass{UserClasses: [][]byte{[]byte("ipxeUEFI")}} - msg.AddOption(&opt) - require.True(t, IsUsingUEFI(&msg)) -} - -func TestIsUsingUEFIUserClassFalse(t *testing.T) { - msg := Message{} - opt := OptUserClass{UserClasses: [][]byte{[]byte("ipxeLegacy")}} - msg.AddOption(&opt) - require.False(t, IsUsingUEFI(&msg)) -} - func TestGetTransactionIDMessage(t *testing.T) { message, err := NewMessage() require.NoError(t, err) |