From 6041d2048c13057fcefc318345d41eef26e51149 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 8 Apr 2020 23:48:09 +0200 Subject: 9bootpxe: simplify --- sys/src/boot/efi/pxe.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/sys/src/boot/efi/pxe.c b/sys/src/boot/efi/pxe.c index 8ae64272d..5c9993503 100644 --- a/sys/src/boot/efi/pxe.c +++ b/sys/src/boot/efi/pxe.c @@ -380,6 +380,20 @@ parsedhcp(EFI_PXE_BASE_CODE_DHCPV4_PACKET *dhcp) } /* DHCPv6 */ + + /* + * some UEFI implementations use random UUID based DUID instead of + * ethernet address, but use ethernet derived link-local addresses. + * so extract the MAC from our IPv6 address as a fallback. + */ + p = pxe->Mode->StationIp; + mymac[0] = p[8] ^ 2; + mymac[1] = p[9]; + mymac[2] = p[10]; + mymac[3] = p[13]; + mymac[4] = p[14]; + mymac[5] = p[15]; + e = (uchar*)dhcp + sizeof(*dhcp); p = (uchar*)dhcp + 4; while(p+4 <= e){ @@ -411,21 +425,6 @@ parsedhcp(EFI_PXE_BASE_CODE_DHCPV4_PACKET *dhcp) } p += len; } - - /* - * some UEFI implementations use random UUID based DUID instead of - * ethernet address, but use ethernet derived link-local addresses. - * so extract the MAC from our IPv6 address. - */ - if((mymac[0]|mymac[1]|mymac[2]|mymac[3]|mymac[4]|mymac[5]) == 0){ - p = pxe->Mode->StationIp; - mymac[0] = p[8] ^ 2; - mymac[1] = p[9]; - mymac[2] = p[10]; - mymac[3] = p[13]; - mymac[4] = p[14]; - mymac[5] = p[15]; - } } int -- cgit v1.2.3