From 5f4fd5364109c80934b7837255ddde61f572fd69 Mon Sep 17 00:00:00 2001 From: cdadmin Date: Thu, 21 Dec 2017 12:59:56 -0500 Subject: [PATCH] Add proxy dhcp support --- netboot.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/netboot.c b/netboot.c index e5ef7d7..115663e 100644 --- a/netboot.c +++ b/netboot.c @@ -257,10 +257,20 @@ static EFI_STATUS parseDhcp4() { CHAR8 *template = (CHAR8 *)translate_slashes(DEFAULT_LOADER_CHAR); INTN template_len = strlen(template) + 1; + EFI_PXE_BASE_CODE_DHCPV4_PACKET* pkt_v4 = (EFI_PXE_BASE_CODE_DHCPV4_PACKET *)&pxe->Mode->DhcpAck.Dhcpv4; - INTN dir_len = strnlena(pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile, 127); + if(pxe->Mode->ProxyOfferReceived) { + /* + * Proxy should not have precedence. Check if DhcpAck + * contained boot info. + */ + if(pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile[0] == '\0') + pkt_v4 = &pxe->Mode->ProxyOffer.Dhcpv4; + } + + INTN dir_len = strnlena(pkt_v4->BootpBootFile, 127); INTN i; - UINT8 *dir = pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile; + UINT8 *dir = pkt_v4->BootpBootFile; for (i = dir_len; i >= 0; i--) { if (dir[i] == '/') @@ -281,7 +291,7 @@ static EFI_STATUS parseDhcp4() if (dir_len == 0 && dir[0] != '/' && template[0] == '/') template++; strcata(full_path, template); - memcpy(&tftp_addr.v4, pxe->Mode->DhcpAck.Dhcpv4.BootpSiAddr, 4); + memcpy(&tftp_addr.v4, pkt_v4->BootpSiAddr, 4); return EFI_SUCCESS; }