9bootpxe: continues the war against random DHCPv6 DUIDs
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.
This commit is contained in:
parent
fed50d79d3
commit
abc5a66c56
1 changed files with 25 additions and 1 deletions
|
@ -367,6 +367,7 @@ parsedhcp(EFI_PXE_BASE_CODE_DHCPV4_PACKET *dhcp)
|
||||||
char *x;
|
char *x;
|
||||||
int opt;
|
int opt;
|
||||||
int len;
|
int len;
|
||||||
|
uint type;
|
||||||
|
|
||||||
memset(mymac, 0, sizeof(mymac));
|
memset(mymac, 0, sizeof(mymac));
|
||||||
memset(serverip, 0, sizeof(serverip));
|
memset(serverip, 0, sizeof(serverip));
|
||||||
|
@ -389,8 +390,16 @@ parsedhcp(EFI_PXE_BASE_CODE_DHCPV4_PACKET *dhcp)
|
||||||
break;
|
break;
|
||||||
switch(opt){
|
switch(opt){
|
||||||
case 1: /* Client DUID */
|
case 1: /* Client DUID */
|
||||||
|
if(len < 4+6)
|
||||||
|
break;
|
||||||
|
type = p[0]<<24 | p[1]<<16 | p[2]<<8 | p[3];
|
||||||
|
switch(type){
|
||||||
|
case 0x00010001:
|
||||||
|
case 0x00030001:
|
||||||
memmove(mymac, p+len-6, 6);
|
memmove(mymac, p+len-6, 6);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 59: /* Boot File URL */
|
case 59: /* Boot File URL */
|
||||||
for(x = (char*)p; x < (char*)p+len; x++){
|
for(x = (char*)p; x < (char*)p+len; x++){
|
||||||
if(*x == '['){
|
if(*x == '['){
|
||||||
|
@ -402,6 +411,21 @@ parsedhcp(EFI_PXE_BASE_CODE_DHCPV4_PACKET *dhcp)
|
||||||
}
|
}
|
||||||
p += len;
|
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
|
int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue