File ovmf-NetworkPkg-Apply-uncrustify-changes-UefiPxeBcDxe-par.patch of Package ovmf.37685
From c5c6effe42ecde3ea0af567011898121154e5727 Mon Sep 17 00:00:00 2001
From: Chun-Yi Lee <jlee@suse.com>
Date: Fri, 7 Feb 2025 14:15:39 +0800
Subject: [PATCH] NetworkPkg: Apply uncrustify changes UefiPxeBcDxe part
Upstream git commit in edk2: d1050b9dff1cace252aff86630bfdb59dff5f507
This is the UefiPxeBcDxe part in 'd1050b9dff1c NetworkPkg: Apply uncrustify changes'
---
NetworkPkg/UefiPxeBcDxe/ComponentName.c | 27 +-
NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c | 392 +++++-----
NetworkPkg/UefiPxeBcDxe/PxeBcBoot.h | 35 +-
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c | 618 ++++++++-------
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h | 215 +++---
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 973 ++++++++++++------------
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h | 137 ++--
NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 365 +++++----
NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h | 7 +-
NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 692 +++++++++--------
NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h | 240 +++---
NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c | 570 +++++++-------
NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.h | 67 +-
NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 506 ++++++------
NetworkPkg/UefiPxeBcDxe/PxeBcSupport.h | 194 +++--
15 files changed, 2504 insertions(+), 2534 deletions(-)
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/ComponentName.c
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/ComponentName.c
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/ComponentName.c
@@ -56,7 +56,6 @@ PxeBcComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user-readable name of the controller
that is being managed by a driver.
@@ -135,11 +134,10 @@ PxeBcComponentNameGetControllerName (
OUT CHAR16 **ControllerName
);
-
//
// EFI Component Name Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName = {
PxeBcComponentNameGetDriverName,
PxeBcComponentNameGetControllerName,
"eng"
@@ -148,13 +146,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPON
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PxeBcComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PxeBcComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)PxeBcComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)PxeBcComponentNameGetControllerName,
"en"
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable[] = {
{
"eng;en",
L"UEFI PXE Base Code Driver"
@@ -165,7 +163,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICOD
}
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcControllerNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcControllerNameTable[] = {
{
"eng;en",
L"PXE Controller"
@@ -223,7 +221,7 @@ PxeBcComponentNameGetDriverName (
OUT CHAR16 **DriverName
)
{
- return LookupUnicodeString2(
+ return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mPxeBcDriverNameTable,
@@ -232,7 +230,6 @@ PxeBcComponentNameGetDriverName (
);
}
-
/**
Retrieves a Unicode string that is the user-readable name of the controller
that is being managed by a driver.
@@ -311,11 +308,11 @@ PxeBcComponentNameGetControllerName (
OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- EFI_HANDLE NicHandle;
- PXEBC_PRIVATE_PROTOCOL *Id;
+ EFI_STATUS Status;
+ EFI_HANDLE NicHandle;
+ PXEBC_PRIVATE_PROTOCOL *Id;
- if (ControllerHandle == NULL || ChildHandle != NULL) {
+ if ((ControllerHandle == NULL) || (ChildHandle != NULL)) {
return EFI_UNSUPPORTED;
}
@@ -333,7 +330,7 @@ PxeBcComponentNameGetControllerName (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiCallerIdGuid,
- (VOID **) &Id,
+ (VOID **)&Id,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
@@ -10,7 +10,6 @@
#include "PxeBcImpl.h"
-
/**
Display the string of the boot item.
@@ -22,27 +21,26 @@
**/
VOID
PxeBcDisplayBootItem (
- IN UINT8 *Str,
- IN UINT8 Len
+ IN UINT8 *Str,
+ IN UINT8 Len
)
{
- UINT8 Tmp;
+ UINT8 Tmp;
//
// Cut off the chars behind 70th.
//
- Len = (UINT8) MIN (PXEBC_DISPLAY_MAX_LINE, Len);
- Tmp = Str[Len];
- Str[Len] = 0;
+ Len = (UINT8)MIN (PXEBC_DISPLAY_MAX_LINE, Len);
+ Tmp = Str[Len];
+ Str[Len] = 0;
AsciiPrint ("%a \n", Str);
//
// Restore the original 70th char.
//
- Str[Len] = Tmp;
+ Str[Len] = Tmp;
}
-
/**
Select and maintain the boot prompt if needed.
@@ -57,22 +55,22 @@ PxeBcDisplayBootItem (
**/
EFI_STATUS
PxeBcSelectBootPrompt (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
- PXEBC_DHCP_PACKET_CACHE *Cache;
- PXEBC_VENDOR_OPTION *VendorOpt;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_EVENT TimeoutEvent;
- EFI_EVENT DescendEvent;
- EFI_INPUT_KEY InputKey;
- EFI_STATUS Status;
- UINT32 OfferType;
- UINT8 Timeout;
- UINT8 *Prompt;
- UINT8 PromptLen;
- INT32 SecCol;
- INT32 SecRow;
+ PXEBC_DHCP_PACKET_CACHE *Cache;
+ PXEBC_VENDOR_OPTION *VendorOpt;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_EVENT TimeoutEvent;
+ EFI_EVENT DescendEvent;
+ EFI_INPUT_KEY InputKey;
+ EFI_STATUS Status;
+ UINT32 OfferType;
+ UINT8 Timeout;
+ UINT8 *Prompt;
+ UINT8 PromptLen;
+ INT32 SecCol;
+ INT32 SecRow;
TimeoutEvent = NULL;
DescendEvent = NULL;
@@ -83,7 +81,7 @@ PxeBcSelectBootPrompt (
//
// Only DhcpPxe10 and ProxyPxe10 offer needs boot prompt.
//
- if (OfferType != PxeOfferTypeProxyPxe10 && OfferType != PxeOfferTypeDhcpPxe10) {
+ if ((OfferType != PxeOfferTypeProxyPxe10) && (OfferType != PxeOfferTypeDhcpPxe10)) {
return EFI_NOT_FOUND;
}
@@ -100,7 +98,8 @@ PxeBcSelectBootPrompt (
// - a boot file name has been presented in the initial DHCP or ProxyDHCP offer packet.
//
if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) &&
- Cache->Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
+ (Cache->Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL))
+ {
return EFI_ABORTED;
}
@@ -110,7 +109,7 @@ PxeBcSelectBootPrompt (
Timeout = VendorOpt->MenuPrompt->Timeout;
Prompt = VendorOpt->MenuPrompt->Prompt;
- PromptLen = (UINT8) (VendorOpt->MenuPromptLen - 1);
+ PromptLen = (UINT8)(VendorOpt->MenuPromptLen - 1);
//
// The valid scope of Timeout refers to PXE2.1 spec.
@@ -118,6 +117,7 @@ PxeBcSelectBootPrompt (
if (Timeout == 0) {
return EFI_TIMEOUT;
}
+
if (Timeout == 255) {
return EFI_SUCCESS;
}
@@ -185,46 +185,43 @@ PxeBcSelectBootPrompt (
gST->ConOut->SetCursorPosition (gST->ConOut, SecCol + PromptLen, SecRow);
AsciiPrint ("(%d) ", Timeout--);
}
+
if (gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey) == EFI_NOT_READY) {
gBS->Stall (10 * TICKS_PER_MS);
continue;
}
+
//
// Parse the input key by user.
// If <F8> or <Ctrl> + <M> is pressed, return success to display the boot menu.
//
if (InputKey.ScanCode == 0) {
-
switch (InputKey.UnicodeChar) {
+ case CTRL ('c'):
+ Status = EFI_ABORTED;
+ break;
- case CTRL ('c'):
- Status = EFI_ABORTED;
- break;
-
- case CTRL ('m'):
- case 'm':
- case 'M':
- Status = EFI_SUCCESS;
- break;
+ case CTRL ('m'):
+ case 'm':
+ case 'M':
+ Status = EFI_SUCCESS;
+ break;
- default:
- continue;
+ default:
+ continue;
}
-
} else {
-
switch (InputKey.ScanCode) {
+ case SCAN_F8:
+ Status = EFI_SUCCESS;
+ break;
- case SCAN_F8:
- Status = EFI_SUCCESS;
- break;
-
- case SCAN_ESC:
- Status = EFI_ABORTED;
- break;
+ case SCAN_ESC:
+ Status = EFI_ABORTED;
+ break;
- default:
- continue;
+ default:
+ continue;
}
}
@@ -234,12 +231,13 @@ PxeBcSelectBootPrompt (
//
// Reset the cursor on the screen.
//
- gST->ConOut->SetCursorPosition (gST->ConOut, 0 , SecRow + 1);
+ gST->ConOut->SetCursorPosition (gST->ConOut, 0, SecRow + 1);
ON_EXIT:
if (DescendEvent != NULL) {
gBS->CloseEvent (DescendEvent);
}
+
if (TimeoutEvent != NULL) {
gBS->CloseEvent (TimeoutEvent);
}
@@ -247,7 +245,6 @@ ON_EXIT:
return Status;
}
-
/**
Select the boot menu by user's input.
@@ -262,26 +259,26 @@ ON_EXIT:
**/
EFI_STATUS
PxeBcSelectBootMenu (
- IN PXEBC_PRIVATE_DATA *Private,
- OUT UINT16 *Type,
- IN BOOLEAN UseDefaultItem
+ IN PXEBC_PRIVATE_DATA *Private,
+ OUT UINT16 *Type,
+ IN BOOLEAN UseDefaultItem
)
{
- EFI_PXE_BASE_CODE_MODE *Mode;
- PXEBC_DHCP_PACKET_CACHE *Cache;
- PXEBC_VENDOR_OPTION *VendorOpt;
- EFI_INPUT_KEY InputKey;
- UINT32 OfferType;
- UINT8 MenuSize;
- UINT8 MenuNum;
- INT32 TopRow;
- UINT16 Select;
- UINT16 LastSelect;
- UINT8 Index;
- BOOLEAN Finish;
- CHAR8 Blank[PXEBC_DISPLAY_MAX_LINE];
- PXEBC_BOOT_MENU_ENTRY *MenuItem;
- PXEBC_BOOT_MENU_ENTRY *MenuArray[PXEBC_MENU_MAX_NUM];
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ PXEBC_DHCP_PACKET_CACHE *Cache;
+ PXEBC_VENDOR_OPTION *VendorOpt;
+ EFI_INPUT_KEY InputKey;
+ UINT32 OfferType;
+ UINT8 MenuSize;
+ UINT8 MenuNum;
+ INT32 TopRow;
+ UINT16 Select;
+ UINT16 LastSelect;
+ UINT8 Index;
+ BOOLEAN Finish;
+ CHAR8 Blank[PXEBC_DISPLAY_MAX_LINE];
+ PXEBC_BOOT_MENU_ENTRY *MenuItem;
+ PXEBC_BOOT_MENU_ENTRY *MenuArray[PXEBC_MENU_MAX_NUM];
Finish = FALSE;
Select = 0;
@@ -305,10 +302,10 @@ PxeBcSelectBootMenu (
//
// Display the boot menu on the screen.
//
- SetMem (Blank, sizeof(Blank), ' ');
+ SetMem (Blank, sizeof (Blank), ' ');
- MenuSize = VendorOpt->BootMenuLen;
- MenuItem = VendorOpt->BootMenu;
+ MenuSize = VendorOpt->BootMenuLen;
+ MenuItem = VendorOpt->BootMenu;
if (MenuSize == 0) {
return EFI_DEVICE_ERROR;
@@ -316,9 +313,9 @@ PxeBcSelectBootMenu (
while (MenuSize > 0 && Index < PXEBC_MENU_MAX_NUM) {
ASSERT (MenuItem != NULL);
- MenuArray[Index] = MenuItem;
- MenuSize = (UINT8) (MenuSize - (MenuItem->DescLen + 3));
- MenuItem = (PXEBC_BOOT_MENU_ENTRY *) ((UINT8 *) MenuItem + MenuItem->DescLen + 3);
+ MenuArray[Index] = MenuItem;
+ MenuSize = (UINT8)(MenuSize - (MenuItem->DescLen + 3));
+ MenuItem = (PXEBC_BOOT_MENU_ENTRY *)((UINT8 *)MenuItem + MenuItem->DescLen + 3);
Index++;
}
@@ -361,60 +358,62 @@ PxeBcSelectBootMenu (
if (InputKey.ScanCode == 0) {
switch (InputKey.UnicodeChar) {
- case CTRL ('c'):
- InputKey.ScanCode = SCAN_ESC;
- break;
+ case CTRL ('c'):
+ InputKey.ScanCode = SCAN_ESC;
+ break;
- case CTRL ('j'): /* linefeed */
- case CTRL ('m'): /* return */
- Finish = TRUE;
- break;
+ case CTRL ('j'): /* linefeed */
+ case CTRL ('m'): /* return */
+ Finish = TRUE;
+ break;
- case CTRL ('i'): /* tab */
- case ' ':
- case 'd':
- case 'D':
- InputKey.ScanCode = SCAN_DOWN;
- break;
+ case CTRL ('i'): /* tab */
+ case ' ':
+ case 'd':
+ case 'D':
+ InputKey.ScanCode = SCAN_DOWN;
+ break;
- case CTRL ('h'): /* backspace */
- case 'u':
- case 'U':
- InputKey.ScanCode = SCAN_UP;
- break;
+ case CTRL ('h'): /* backspace */
+ case 'u':
+ case 'U':
+ InputKey.ScanCode = SCAN_UP;
+ break;
- default:
- InputKey.ScanCode = 0;
+ default:
+ InputKey.ScanCode = 0;
}
}
switch (InputKey.ScanCode) {
- case SCAN_LEFT:
- case SCAN_UP:
- if (Select != 0) {
- Select--;
- }
- break;
+ case SCAN_LEFT:
+ case SCAN_UP:
+ if (Select != 0) {
+ Select--;
+ }
- case SCAN_DOWN:
- case SCAN_RIGHT:
- if (++Select == MenuNum) {
- Select--;
- }
- break;
+ break;
- case SCAN_PAGE_UP:
- case SCAN_HOME:
- Select = 0;
- break;
-
- case SCAN_PAGE_DOWN:
- case SCAN_END:
- Select = (UINT16) (MenuNum - 1);
- break;
+ case SCAN_DOWN:
+ case SCAN_RIGHT:
+ if (++Select == MenuNum) {
+ Select--;
+ }
- case SCAN_ESC:
- return EFI_ABORTED;
+ break;
+
+ case SCAN_PAGE_UP:
+ case SCAN_HOME:
+ Select = 0;
+ break;
+
+ case SCAN_PAGE_DOWN:
+ case SCAN_END:
+ Select = (UINT16)(MenuNum - 1);
+ break;
+
+ case SCAN_ESC:
+ return EFI_ABORTED;
}
//
@@ -441,7 +440,6 @@ PxeBcSelectBootMenu (
return EFI_SUCCESS;
}
-
/**
Parse out the boot information from the last Dhcp4 reply packet.
@@ -454,8 +452,8 @@ PxeBcSelectBootMenu (
**/
EFI_STATUS
PxeBcDhcp4BootInfo (
- IN OUT PXEBC_PRIVATE_DATA *Private,
- OUT UINT64 *BufferSize
+ IN OUT PXEBC_PRIVATE_DATA *Private,
+ OUT UINT64 *BufferSize
)
{
EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
@@ -493,7 +491,7 @@ PxeBcDhcp4BootInfo (
VendorOpt = &Cache4->VendorOpt;
if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) && IS_VALID_BOOT_SERVERS (VendorOpt->BitMap)) {
Entry = VendorOpt->BootSvr;
- if (VendorOpt->BootSvrLen >= sizeof (PXEBC_BOOT_SVR_ENTRY) && Entry->IpCnt > 0) {
+ if ((VendorOpt->BootSvrLen >= sizeof (PXEBC_BOOT_SVR_ENTRY)) && (Entry->IpCnt > 0)) {
CopyMem (
&Private->ServerIp,
&Entry->IpAddr[0],
@@ -501,6 +499,7 @@ PxeBcDhcp4BootInfo (
);
}
}
+
if (Private->ServerIp.Addr[0] == 0) {
//
// ServerIp.Addr[0] equals zero means we failed to get IP address from boot server list.
@@ -512,6 +511,7 @@ PxeBcDhcp4BootInfo (
sizeof (EFI_IPv4_ADDRESS)
);
}
+
if (Private->ServerIp.Addr[0] == 0) {
//
// Still failed , use the IP address from option 54.
@@ -533,7 +533,7 @@ PxeBcDhcp4BootInfo (
// Parse the boot file size by option.
//
CopyMem (&Value, Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN]->Data, sizeof (Value));
- Value = NTOHS (Value);
+ Value = NTOHS (Value);
//
// The field of boot file size is 512 bytes in unit.
//
@@ -559,7 +559,7 @@ PxeBcDhcp4BootInfo (
//
// Save the value of boot file size.
//
- Private->BootFileSize = (UINTN) *BufferSize;
+ Private->BootFileSize = (UINTN)*BufferSize;
//
// Display all the information: boot server address, boot file name and boot file size.
@@ -572,7 +572,6 @@ PxeBcDhcp4BootInfo (
return Status;
}
-
/**
Parse out the boot information from the last Dhcp6 reply packet.
@@ -586,8 +585,8 @@ PxeBcDhcp4BootInfo (
**/
EFI_STATUS
PxeBcDhcp6BootInfo (
- IN OUT PXEBC_PRIVATE_DATA *Private,
- OUT UINT64 *BufferSize
+ IN OUT PXEBC_PRIVATE_DATA *Private,
+ OUT UINT64 *BufferSize
)
{
EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
@@ -622,7 +621,6 @@ PxeBcDhcp6BootInfo (
return Status;
}
-
//
// Parse (m)tftp server ip address and bootfile name.
//
@@ -630,7 +628,7 @@ PxeBcDhcp6BootInfo (
Private,
&Private->BootFileName,
&Private->ServerIp.v6,
- (CHAR8 *) (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),
+ (CHAR8 *)(Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),
NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->OpLen)
);
if (EFI_ERROR (Status)) {
@@ -644,10 +642,11 @@ PxeBcDhcp6BootInfo (
//
// Parse it out if have the boot file parameter option.
//
- Status = PxeBcExtractBootFileParam ((CHAR8 *) Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_PARAM]->Data, &Value);
+ Status = PxeBcExtractBootFileParam ((CHAR8 *)Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_PARAM]->Data, &Value);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// The field of boot file size is 512 bytes in unit.
//
@@ -673,7 +672,7 @@ PxeBcDhcp6BootInfo (
//
// Save the value of boot file size.
//
- Private->BootFileSize = (UINTN) *BufferSize;
+ Private->BootFileSize = (UINTN)*BufferSize;
//
// Display all the information: boot server address, boot file name and boot file size.
@@ -686,7 +685,6 @@ PxeBcDhcp6BootInfo (
return Status;
}
-
/**
Extract the discover information and boot server entry from the
cached packets if unspecified.
@@ -706,17 +704,17 @@ PxeBcExtractDiscoverInfo (
IN PXEBC_PRIVATE_DATA *Private,
IN UINT16 Type,
IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO **DiscoverInfo,
- OUT PXEBC_BOOT_SVR_ENTRY **BootEntry,
- OUT EFI_PXE_BASE_CODE_SRVLIST **SrvList
+ OUT PXEBC_BOOT_SVR_ENTRY **BootEntry,
+ OUT EFI_PXE_BASE_CODE_SRVLIST **SrvList
)
{
- EFI_PXE_BASE_CODE_MODE *Mode;
- PXEBC_DHCP4_PACKET_CACHE *Cache4;
- PXEBC_VENDOR_OPTION *VendorOpt;
- PXEBC_BOOT_SVR_ENTRY *Entry;
- BOOLEAN IsFound;
- EFI_PXE_BASE_CODE_DISCOVER_INFO *Info;
- UINT16 Index;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ PXEBC_DHCP4_PACKET_CACHE *Cache4;
+ PXEBC_VENDOR_OPTION *VendorOpt;
+ PXEBC_BOOT_SVR_ENTRY *Entry;
+ BOOLEAN IsFound;
+ EFI_PXE_BASE_CODE_DISCOVER_INFO *Info;
+ UINT16 Index;
Mode = Private->PxeBc.Mode;
Info = *DiscoverInfo;
@@ -733,7 +731,7 @@ PxeBcExtractDiscoverInfo (
//
CopyMem (&Info->SrvList[0].IpAddr, &Private->ServerIp, sizeof (EFI_IP_ADDRESS));
- *SrvList = Info->SrvList;
+ *SrvList = Info->SrvList;
} else {
Entry = NULL;
IsFound = FALSE;
@@ -752,8 +750,8 @@ PxeBcExtractDiscoverInfo (
//
Info->UseMCast = (BOOLEAN) !IS_DISABLE_MCAST_DISCOVER (VendorOpt->DiscoverCtrl);
Info->UseBCast = (BOOLEAN) !IS_DISABLE_BCAST_DISCOVER (VendorOpt->DiscoverCtrl);
- Info->MustUseList = (BOOLEAN) IS_ENABLE_USE_SERVER_LIST (VendorOpt->DiscoverCtrl);
- Info->UseUCast = (BOOLEAN) IS_VALID_BOOT_SERVERS (VendorOpt->BitMap);
+ Info->MustUseList = (BOOLEAN)IS_ENABLE_USE_SERVER_LIST (VendorOpt->DiscoverCtrl);
+ Info->UseUCast = (BOOLEAN)IS_VALID_BOOT_SERVERS (VendorOpt->BitMap);
if (Info->UseMCast) {
//
@@ -767,11 +765,12 @@ PxeBcExtractDiscoverInfo (
if (Info->UseUCast) {
Entry = VendorOpt->BootSvr;
- while (((UINT8) (Entry - VendorOpt->BootSvr)) < VendorOpt->BootSvrLen) {
+ while (((UINT8)(Entry - VendorOpt->BootSvr)) < VendorOpt->BootSvrLen) {
if (Entry->Type == HTONS (Type)) {
IsFound = TRUE;
break;
}
+
Entry = GET_NEXT_BOOT_SVR_ENTRY (Entry);
}
@@ -785,6 +784,7 @@ PxeBcExtractDiscoverInfo (
if (*DiscoverInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (*DiscoverInfo, Info, sizeof (*Info));
Info = *DiscoverInfo;
}
@@ -792,7 +792,7 @@ PxeBcExtractDiscoverInfo (
for (Index = 0; Index < Info->IpCnt; Index++) {
CopyMem (&Info->SrvList[Index].IpAddr, &Entry->IpAddr[Index], sizeof (EFI_IPv4_ADDRESS));
Info->SrvList[Index].AcceptAnyResponse = !Info->MustUseList;
- Info->SrvList[Index].Type = NTOHS (Entry->Type);
+ Info->SrvList[Index].Type = NTOHS (Entry->Type);
}
}
@@ -803,7 +803,6 @@ PxeBcExtractDiscoverInfo (
return EFI_SUCCESS;
}
-
/**
Build the discover packet and send out for boot server.
@@ -823,13 +822,13 @@ PxeBcExtractDiscoverInfo (
**/
EFI_STATUS
PxeBcDiscoverBootServer (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT16 Type,
- IN UINT16 *Layer,
- IN BOOLEAN UseBis,
- IN EFI_IP_ADDRESS *DestIp,
- IN UINT16 IpCount,
- IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT16 Type,
+ IN UINT16 *Layer,
+ IN BOOLEAN UseBis,
+ IN EFI_IP_ADDRESS *DestIp,
+ IN UINT16 IpCount,
+ IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
)
{
if (Private->PxeBc.Mode->UsingIpv6) {
@@ -853,7 +852,6 @@ PxeBcDiscoverBootServer (
}
}
-
/**
Discover all the boot information for boot file.
@@ -868,8 +866,8 @@ PxeBcDiscoverBootServer (
**/
EFI_STATUS
PxeBcDiscoverBootFile (
- IN OUT PXEBC_PRIVATE_DATA *Private,
- OUT UINT64 *BufferSize
+ IN OUT PXEBC_PRIVATE_DATA *Private,
+ OUT UINT64 *BufferSize
)
{
EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
@@ -911,7 +909,6 @@ PxeBcDiscoverBootFile (
}
if (!EFI_ERROR (Status)) {
-
if (Type == EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP) {
//
// Local boot(PXE bootstrap server) need abort
@@ -923,7 +920,7 @@ PxeBcDiscoverBootFile (
// Start to discover the boot server to get (m)tftp server ip address, bootfile
// name and bootfile size.
//
- UseBis = (BOOLEAN) (Mode->BisSupported && Mode->BisDetected);
+ UseBis = (BOOLEAN)(Mode->BisSupported && Mode->BisDetected);
Status = PxeBc->Discover (PxeBc, Type, &Layer, UseBis, NULL);
if (EFI_ERROR (Status)) {
return Status;
@@ -947,6 +944,7 @@ PxeBcDiscoverBootFile (
Private->PxeReply.Dhcp4.Packet.Ack.Length
);
}
+
Mode->ProxyOfferReceived = TRUE;
}
}
@@ -963,7 +961,6 @@ PxeBcDiscoverBootFile (
return Status;
}
-
/**
Install PxeBaseCodeCallbackProtocol if not installed before.
@@ -976,8 +973,8 @@ PxeBcDiscoverBootFile (
**/
EFI_STATUS
PxeBcInstallCallback (
- IN OUT PXEBC_PRIVATE_DATA *Private,
- OUT BOOLEAN *NewMakeCallback
+ IN OUT PXEBC_PRIVATE_DATA *Private,
+ OUT BOOLEAN *NewMakeCallback
)
{
EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
@@ -990,10 +987,9 @@ PxeBcInstallCallback (
Status = gBS->HandleProtocol (
Private->Mode.UsingIpv6 ? Private->Ip6Nic->Controller : Private->Ip4Nic->Controller,
&gEfiPxeBaseCodeCallbackProtocolGuid,
- (VOID **) &Private->PxeBcCallback
+ (VOID **)&Private->PxeBcCallback
);
if (Status == EFI_UNSUPPORTED) {
-
CopyMem (
&Private->LoadFileCallback,
&gPxeBcCallBackTemplate,
@@ -1010,7 +1006,7 @@ PxeBcInstallCallback (
&Private->LoadFileCallback
);
- (*NewMakeCallback) = (BOOLEAN) (Status == EFI_SUCCESS);
+ (*NewMakeCallback) = (BOOLEAN)(Status == EFI_SUCCESS);
Status = PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL, NewMakeCallback);
if (EFI_ERROR (Status)) {
@@ -1022,7 +1018,6 @@ PxeBcInstallCallback (
return EFI_SUCCESS;
}
-
/**
Uninstall PxeBaseCodeCallbackProtocol.
@@ -1033,29 +1028,27 @@ PxeBcInstallCallback (
**/
VOID
PxeBcUninstallCallback (
- IN PXEBC_PRIVATE_DATA *Private,
- IN BOOLEAN NewMakeCallback
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN BOOLEAN NewMakeCallback
)
{
- EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
+ EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
PxeBc = &Private->PxeBc;
if (NewMakeCallback) {
-
NewMakeCallback = FALSE;
PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL, &NewMakeCallback);
gBS->UninstallProtocolInterface (
- Private->Mode.UsingIpv6 ? Private->Ip6Nic->Controller : Private->Ip4Nic->Controller,
- &gEfiPxeBaseCodeCallbackProtocolGuid,
- &Private->LoadFileCallback
- );
+ Private->Mode.UsingIpv6 ? Private->Ip6Nic->Controller : Private->Ip4Nic->Controller,
+ &gEfiPxeBaseCodeCallbackProtocolGuid,
+ &Private->LoadFileCallback
+ );
}
}
-
/**
Download one of boot file in the list, and it's special for IPv6.
@@ -1072,15 +1065,15 @@ PxeBcUninstallCallback (
**/
EFI_STATUS
PxeBcReadBootFileList (
- IN PXEBC_PRIVATE_DATA *Private,
- IN OUT UINT64 *BufferSize,
- IN VOID *Buffer OPTIONAL
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN OUT UINT64 *BufferSize,
+ IN VOID *Buffer OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
+ EFI_STATUS Status;
+ EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
- PxeBc = &Private->PxeBc;
+ PxeBc = &Private->PxeBc;
//
// Try to download the boot file if everything is ready.
@@ -1098,16 +1091,13 @@ PxeBcReadBootFileList (
NULL,
FALSE
);
-
-
} else {
- Status = EFI_BUFFER_TOO_SMALL;
+ Status = EFI_BUFFER_TOO_SMALL;
}
return Status;
}
-
/**
Load boot file into user buffer.
@@ -1124,17 +1114,17 @@ PxeBcReadBootFileList (
**/
EFI_STATUS
PxeBcLoadBootFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer OPTIONAL
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer OPTIONAL
)
{
- BOOLEAN NewMakeCallback;
- UINT64 RequiredSize;
- UINT64 CurrentSize;
- EFI_STATUS Status;
- EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
- EFI_PXE_BASE_CODE_MODE *PxeBcMode;
+ BOOLEAN NewMakeCallback;
+ UINT64 RequiredSize;
+ UINT64 CurrentSize;
+ EFI_STATUS Status;
+ EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
+ EFI_PXE_BASE_CODE_MODE *PxeBcMode;
NewMakeCallback = FALSE;
PxeBc = &Private->PxeBc;
@@ -1146,7 +1136,7 @@ PxeBcLoadBootFile (
// Install pxebc callback protocol if hasn't been installed yet.
//
Status = PxeBcInstallCallback (Private, &NewMakeCallback);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -1169,7 +1159,7 @@ PxeBcLoadBootFile (
//
// Get the right buffer size of the bootfile required.
//
- if (CurrentSize < RequiredSize || Buffer == NULL) {
+ if ((CurrentSize < RequiredSize) || (Buffer == NULL)) {
//
// It's buffer too small if the size of user buffer is smaller than the required.
//
@@ -1177,8 +1167,9 @@ PxeBcLoadBootFile (
Status = EFI_BUFFER_TOO_SMALL;
goto ON_EXIT;
}
+
CurrentSize = RequiredSize;
- } else if (RequiredSize == 0 && PxeBcMode->UsingIpv6) {
+ } else if ((RequiredSize == 0) && PxeBcMode->UsingIpv6) {
//
// Try to download another bootfile in list if failed to get the filesize of the last one.
// It's special for the case of IPv6.
@@ -1186,7 +1177,7 @@ PxeBcLoadBootFile (
Status = PxeBcReadBootFileList (Private, &CurrentSize, Buffer);
goto ON_EXIT;
}
- } else if (CurrentSize < Private->BootFileSize || Buffer == NULL ) {
+ } else if ((CurrentSize < Private->BootFileSize) || (Buffer == NULL)) {
//
// It's buffer too small if the size of user buffer is smaller than the required.
//
@@ -1221,13 +1212,13 @@ PxeBcLoadBootFile (
}
ON_EXIT:
- *BufferSize = (UINTN) CurrentSize;
- PxeBcUninstallCallback(Private, NewMakeCallback);
+ *BufferSize = (UINTN)CurrentSize;
+ PxeBcUninstallCallback (Private, NewMakeCallback);
if (Status == EFI_SUCCESS) {
AsciiPrint ("\n NBP file downloaded successfully.\n");
return EFI_SUCCESS;
- } else if (Status == EFI_BUFFER_TOO_SMALL && Buffer != NULL) {
+ } else if ((Status == EFI_BUFFER_TOO_SMALL) && (Buffer != NULL)) {
AsciiPrint ("\n PXE-E05: Buffer size is smaller than the requested file.\n");
} else if (Status == EFI_DEVICE_ERROR) {
AsciiPrint ("\n PXE-E07: Network device error.\n");
@@ -1253,4 +1244,3 @@ ON_EXIT:
return Status;
}
-
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.h
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.h
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.h
@@ -10,12 +10,11 @@
#ifndef __EFI_PXEBC_BOOT_H__
#define __EFI_PXEBC_BOOT_H__
-#define PXEBC_DISPLAY_MAX_LINE 70
-#define PXEBC_DEFAULT_UDP_OVERHEAD_SIZE 8
-#define PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE 4
-
-#define PXEBC_IS_SIZE_OVERFLOWED(x) ((sizeof (UINTN) < sizeof (UINT64)) && ((x) > 0xFFFFFFFF))
+#define PXEBC_DISPLAY_MAX_LINE 70
+#define PXEBC_DEFAULT_UDP_OVERHEAD_SIZE 8
+#define PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE 4
+#define PXEBC_IS_SIZE_OVERFLOWED(x) ((sizeof (UINTN) < sizeof (UINT64)) && ((x) > 0xFFFFFFFF))
/**
Extract the discover information and boot server entry from the
@@ -36,11 +35,10 @@ PxeBcExtractDiscoverInfo (
IN PXEBC_PRIVATE_DATA *Private,
IN UINT16 Type,
IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO **DiscoverInfo,
- OUT PXEBC_BOOT_SVR_ENTRY **BootEntry,
- OUT EFI_PXE_BASE_CODE_SRVLIST **SrvList
+ OUT PXEBC_BOOT_SVR_ENTRY **BootEntry,
+ OUT EFI_PXE_BASE_CODE_SRVLIST **SrvList
);
-
/**
Build the discover packet and send out for boot.
@@ -60,16 +58,15 @@ PxeBcExtractDiscoverInfo (
**/
EFI_STATUS
PxeBcDiscoverBootServer (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT16 Type,
- IN UINT16 *Layer,
- IN BOOLEAN UseBis,
- IN EFI_IP_ADDRESS *DestIp,
- IN UINT16 IpCount,
- IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT16 Type,
+ IN UINT16 *Layer,
+ IN BOOLEAN UseBis,
+ IN EFI_IP_ADDRESS *DestIp,
+ IN UINT16 IpCount,
+ IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
);
-
/**
Load boot file into user buffer.
@@ -86,9 +83,9 @@ PxeBcDiscoverBootServer (
**/
EFI_STATUS
PxeBcLoadBootFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer OPTIONAL
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer OPTIONAL
);
#endif
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
@@ -12,7 +12,7 @@
//
// This is a map from the interested DHCP4 option tags' index to the tag value.
//
-UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = {
+UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = {
DHCP4_TAG_BOOTFILE_LEN,
DHCP4_TAG_VENDOR,
DHCP4_TAG_OVERLOAD,
@@ -25,8 +25,7 @@ UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_T
//
// There are 4 times retries with the value of 4, 8, 16 and 32, refers to PXE2.1 spec.
//
-UINT32 mPxeDhcpTimeout[4] = {4, 8, 16, 32};
-
+UINT32 mPxeDhcpTimeout[4] = { 4, 8, 16, 32 };
/**
Parse a certain dhcp4 option by OptTag in Buffer, and return with start pointer.
@@ -41,19 +40,18 @@ UINT32 mPxeDhcpTimeout[4] = {4, 8, 16, 3
**/
EFI_DHCP4_PACKET_OPTION *
PxeBcParseDhcp4Options (
- IN UINT8 *Buffer,
- IN UINT32 Length,
- IN UINT8 OptTag
+ IN UINT8 *Buffer,
+ IN UINT32 Length,
+ IN UINT8 OptTag
)
{
- EFI_DHCP4_PACKET_OPTION *Option;
- UINT32 Offset;
+ EFI_DHCP4_PACKET_OPTION *Option;
+ UINT32 Offset;
- Option = (EFI_DHCP4_PACKET_OPTION *) Buffer;
- Offset = 0;
+ Option = (EFI_DHCP4_PACKET_OPTION *)Buffer;
+ Offset = 0;
while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
-
if (Option->OpCode == OptTag) {
//
// Found the required option.
@@ -70,7 +68,7 @@ PxeBcParseDhcp4Options (
Offset += Option->Length + 2;
}
- Option = (EFI_DHCP4_PACKET_OPTION *) (Buffer + Offset);
+ Option = (EFI_DHCP4_PACKET_OPTION *)(Buffer + Offset);
}
return NULL;
@@ -86,18 +84,18 @@ PxeBcParseDhcp4Options (
**/
VOID
PxeBcParseVendorOptions (
- IN EFI_DHCP4_PACKET_OPTION *Dhcp4Option,
- IN PXEBC_VENDOR_OPTION *VendorOption
+ IN EFI_DHCP4_PACKET_OPTION *Dhcp4Option,
+ IN PXEBC_VENDOR_OPTION *VendorOption
)
{
- UINT32 *BitMap;
- UINT8 VendorOptionLen;
- EFI_DHCP4_PACKET_OPTION *PxeOption;
- UINT8 Offset;
+ UINT32 *BitMap;
+ UINT8 VendorOptionLen;
+ EFI_DHCP4_PACKET_OPTION *PxeOption;
+ UINT8 Offset;
BitMap = VendorOption->BitMap;
VendorOptionLen = Dhcp4Option->Length;
- PxeOption = (EFI_DHCP4_PACKET_OPTION *) &Dhcp4Option->Data[0];
+ PxeOption = (EFI_DHCP4_PACKET_OPTION *)&Dhcp4Option->Data[0];
Offset = 0;
ASSERT (PxeOption != NULL);
@@ -107,84 +105,83 @@ PxeBcParseVendorOptions (
// Parse all the interesting PXE vendor options one by one.
//
switch (PxeOption->OpCode) {
+ case PXEBC_VENDOR_TAG_MTFTP_IP:
- case PXEBC_VENDOR_TAG_MTFTP_IP:
-
- CopyMem (&VendorOption->MtftpIp, PxeOption->Data, sizeof (EFI_IPv4_ADDRESS));
- break;
+ CopyMem (&VendorOption->MtftpIp, PxeOption->Data, sizeof (EFI_IPv4_ADDRESS));
+ break;
- case PXEBC_VENDOR_TAG_MTFTP_CPORT:
+ case PXEBC_VENDOR_TAG_MTFTP_CPORT:
- CopyMem (&VendorOption->MtftpCPort, PxeOption->Data, sizeof (VendorOption->MtftpCPort));
- break;
+ CopyMem (&VendorOption->MtftpCPort, PxeOption->Data, sizeof (VendorOption->MtftpCPort));
+ break;
- case PXEBC_VENDOR_TAG_MTFTP_SPORT:
+ case PXEBC_VENDOR_TAG_MTFTP_SPORT:
- CopyMem (&VendorOption->MtftpSPort, PxeOption->Data, sizeof (VendorOption->MtftpSPort));
- break;
+ CopyMem (&VendorOption->MtftpSPort, PxeOption->Data, sizeof (VendorOption->MtftpSPort));
+ break;
- case PXEBC_VENDOR_TAG_MTFTP_TIMEOUT:
+ case PXEBC_VENDOR_TAG_MTFTP_TIMEOUT:
- VendorOption->MtftpTimeout = *PxeOption->Data;
- break;
+ VendorOption->MtftpTimeout = *PxeOption->Data;
+ break;
- case PXEBC_VENDOR_TAG_MTFTP_DELAY:
+ case PXEBC_VENDOR_TAG_MTFTP_DELAY:
- VendorOption->MtftpDelay = *PxeOption->Data;
- break;
+ VendorOption->MtftpDelay = *PxeOption->Data;
+ break;
- case PXEBC_VENDOR_TAG_DISCOVER_CTRL:
+ case PXEBC_VENDOR_TAG_DISCOVER_CTRL:
- VendorOption->DiscoverCtrl = *PxeOption->Data;
- break;
+ VendorOption->DiscoverCtrl = *PxeOption->Data;
+ break;
- case PXEBC_VENDOR_TAG_DISCOVER_MCAST:
+ case PXEBC_VENDOR_TAG_DISCOVER_MCAST:
- CopyMem (&VendorOption->DiscoverMcastIp, PxeOption->Data, sizeof (EFI_IPv4_ADDRESS));
- break;
+ CopyMem (&VendorOption->DiscoverMcastIp, PxeOption->Data, sizeof (EFI_IPv4_ADDRESS));
+ break;
- case PXEBC_VENDOR_TAG_BOOT_SERVERS:
+ case PXEBC_VENDOR_TAG_BOOT_SERVERS:
- VendorOption->BootSvrLen = PxeOption->Length;
- VendorOption->BootSvr = (PXEBC_BOOT_SVR_ENTRY *) PxeOption->Data;
- break;
+ VendorOption->BootSvrLen = PxeOption->Length;
+ VendorOption->BootSvr = (PXEBC_BOOT_SVR_ENTRY *)PxeOption->Data;
+ break;
- case PXEBC_VENDOR_TAG_BOOT_MENU:
+ case PXEBC_VENDOR_TAG_BOOT_MENU:
- VendorOption->BootMenuLen = PxeOption->Length;
- VendorOption->BootMenu = (PXEBC_BOOT_MENU_ENTRY *) PxeOption->Data;
- break;
+ VendorOption->BootMenuLen = PxeOption->Length;
+ VendorOption->BootMenu = (PXEBC_BOOT_MENU_ENTRY *)PxeOption->Data;
+ break;
- case PXEBC_VENDOR_TAG_MENU_PROMPT:
+ case PXEBC_VENDOR_TAG_MENU_PROMPT:
- VendorOption->MenuPromptLen = PxeOption->Length;
- VendorOption->MenuPrompt = (PXEBC_MENU_PROMPT *) PxeOption->Data;
- break;
+ VendorOption->MenuPromptLen = PxeOption->Length;
+ VendorOption->MenuPrompt = (PXEBC_MENU_PROMPT *)PxeOption->Data;
+ break;
- case PXEBC_VENDOR_TAG_MCAST_ALLOC:
+ case PXEBC_VENDOR_TAG_MCAST_ALLOC:
- CopyMem (&VendorOption->McastIpBase, PxeOption->Data, sizeof (EFI_IPv4_ADDRESS));
- CopyMem (&VendorOption->McastIpBlock, PxeOption->Data + 4, sizeof (VendorOption->McastIpBlock));
- CopyMem (&VendorOption->McastIpRange, PxeOption->Data + 6, sizeof (VendorOption->McastIpRange));
- break;
+ CopyMem (&VendorOption->McastIpBase, PxeOption->Data, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&VendorOption->McastIpBlock, PxeOption->Data + 4, sizeof (VendorOption->McastIpBlock));
+ CopyMem (&VendorOption->McastIpRange, PxeOption->Data + 6, sizeof (VendorOption->McastIpRange));
+ break;
- case PXEBC_VENDOR_TAG_CREDENTIAL_TYPES:
+ case PXEBC_VENDOR_TAG_CREDENTIAL_TYPES:
- VendorOption->CredTypeLen = PxeOption->Length;
- VendorOption->CredType = (UINT32 *) PxeOption->Data;
- break;
+ VendorOption->CredTypeLen = PxeOption->Length;
+ VendorOption->CredType = (UINT32 *)PxeOption->Data;
+ break;
- case PXEBC_VENDOR_TAG_BOOT_ITEM:
+ case PXEBC_VENDOR_TAG_BOOT_ITEM:
- CopyMem (&VendorOption->BootSrvType, PxeOption->Data, sizeof (VendorOption->BootSrvType));
- CopyMem (&VendorOption->BootSrvLayer, PxeOption->Data + 2, sizeof (VendorOption->BootSrvLayer));
- break;
+ CopyMem (&VendorOption->BootSrvType, PxeOption->Data, sizeof (VendorOption->BootSrvType));
+ CopyMem (&VendorOption->BootSrvLayer, PxeOption->Data + 2, sizeof (VendorOption->BootSrvLayer));
+ break;
- default:
- //
- // Not interesting PXE vendor options.
- //
- break;
+ default:
+ //
+ // Not interesting PXE vendor options.
+ //
+ break;
}
//
@@ -198,14 +195,13 @@ PxeBcParseVendorOptions (
if (PxeOption->OpCode == DHCP4_TAG_PAD) {
Offset++;
} else {
- Offset = (UINT8) (Offset + PxeOption->Length + 2);
+ Offset = (UINT8)(Offset + PxeOption->Length + 2);
}
- PxeOption = (EFI_DHCP4_PACKET_OPTION *) (Dhcp4Option->Data + Offset);
+ PxeOption = (EFI_DHCP4_PACKET_OPTION *)(Dhcp4Option->Data + Offset);
}
}
-
/**
Build the options buffer for the DHCPv4 request packet.
@@ -226,34 +222,34 @@ PxeBcBuildDhcp4Options (
IN BOOLEAN NeedMsgType
)
{
- UINT32 Index;
- PXEBC_DHCP4_OPTION_ENTRY OptEnt;
- UINT16 Value;
+ UINT32 Index;
+ PXEBC_DHCP4_OPTION_ENTRY OptEnt;
+ UINT16 Value;
Index = 0;
- OptList[0] = (EFI_DHCP4_PACKET_OPTION *) Buffer;
+ OptList[0] = (EFI_DHCP4_PACKET_OPTION *)Buffer;
if (NeedMsgType) {
//
// Append message type.
//
- OptList[Index]->OpCode = DHCP4_TAG_MSG_TYPE;
- OptList[Index]->Length = 1;
- OptEnt.Mesg = (PXEBC_DHCP4_OPTION_MESG *) OptList[Index]->Data;
- OptEnt.Mesg->Type = PXEBC_DHCP4_MSG_TYPE_REQUEST;
+ OptList[Index]->OpCode = DHCP4_TAG_MSG_TYPE;
+ OptList[Index]->Length = 1;
+ OptEnt.Mesg = (PXEBC_DHCP4_OPTION_MESG *)OptList[Index]->Data;
+ OptEnt.Mesg->Type = PXEBC_DHCP4_MSG_TYPE_REQUEST;
Index++;
- OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
//
// Append max message size.
//
- OptList[Index]->OpCode = DHCP4_TAG_MAXMSG;
- OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE);
- OptEnt.MaxMesgSize = (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *) OptList[Index]->Data;
- Value = NTOHS (PXEBC_DHCP4_PACKET_MAX_SIZE);
+ OptList[Index]->OpCode = DHCP4_TAG_MAXMSG;
+ OptList[Index]->Length = (UINT8)sizeof (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE);
+ OptEnt.MaxMesgSize = (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *)OptList[Index]->Data;
+ Value = NTOHS (PXEBC_DHCP4_PACKET_MAX_SIZE);
CopyMem (&OptEnt.MaxMesgSize->Size, &Value, sizeof (UINT16));
Index++;
- OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
}
//
@@ -261,7 +257,7 @@ PxeBcBuildDhcp4Options (
//
OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST;
OptList[Index]->Length = 35;
- OptEnt.Para = (PXEBC_DHCP4_OPTION_PARA *) OptList[Index]->Data;
+ OptEnt.Para = (PXEBC_DHCP4_OPTION_PARA *)OptList[Index]->Data;
OptEnt.Para->ParaList[0] = DHCP4_TAG_NETMASK;
OptEnt.Para->ParaList[1] = DHCP4_TAG_TIME_OFFSET;
OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER;
@@ -298,19 +294,19 @@ PxeBcBuildDhcp4Options (
OptEnt.Para->ParaList[33] = 0x86;
OptEnt.Para->ParaList[34] = 0x87;
Index++;
- OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
//
// Append UUID/Guid-based client identifier option
//
- OptList[Index]->OpCode = DHCP4_TAG_UUID;
- OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UUID);
- OptEnt.Uuid = (PXEBC_DHCP4_OPTION_UUID *) OptList[Index]->Data;
- OptEnt.Uuid->Type = 0;
+ OptList[Index]->OpCode = DHCP4_TAG_UUID;
+ OptList[Index]->Length = (UINT8)sizeof (PXEBC_DHCP4_OPTION_UUID);
+ OptEnt.Uuid = (PXEBC_DHCP4_OPTION_UUID *)OptList[Index]->Data;
+ OptEnt.Uuid->Type = 0;
Index++;
- OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
- if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) OptEnt.Uuid->Guid))) {
+ if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *)OptEnt.Uuid->Guid))) {
//
// Zero the Guid to indicate NOT programable if failed to get system Guid.
//
@@ -321,9 +317,9 @@ PxeBcBuildDhcp4Options (
//
// Append client network device interface option
//
- OptList[Index]->OpCode = DHCP4_TAG_UNDI;
- OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UNDI);
- OptEnt.Undi = (PXEBC_DHCP4_OPTION_UNDI *) OptList[Index]->Data;
+ OptList[Index]->OpCode = DHCP4_TAG_UNDI;
+ OptList[Index]->Length = (UINT8)sizeof (PXEBC_DHCP4_OPTION_UNDI);
+ OptEnt.Undi = (PXEBC_DHCP4_OPTION_UNDI *)OptList[Index]->Data;
if (Private->Nii != NULL) {
OptEnt.Undi->Type = Private->Nii->Type;
@@ -341,20 +337,20 @@ PxeBcBuildDhcp4Options (
//
// Append client system architecture option
//
- OptList[Index]->OpCode = DHCP4_TAG_ARCH;
- OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_ARCH);
- OptEnt.Arch = (PXEBC_DHCP4_OPTION_ARCH *) OptList[Index]->Data;
- Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
+ OptList[Index]->OpCode = DHCP4_TAG_ARCH;
+ OptList[Index]->Length = (UINT8)sizeof (PXEBC_DHCP4_OPTION_ARCH);
+ OptEnt.Arch = (PXEBC_DHCP4_OPTION_ARCH *)OptList[Index]->Data;
+ Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
Index++;
- OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
//
// Append vendor class identify option
//
- OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
- OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_CLID);
- OptEnt.Clid = (PXEBC_DHCP4_OPTION_CLID *) OptList[Index]->Data;
+ OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
+ OptList[Index]->Length = (UINT8)sizeof (PXEBC_DHCP4_OPTION_CLID);
+ OptEnt.Clid = (PXEBC_DHCP4_OPTION_CLID *)OptList[Index]->Data;
CopyMem (
OptEnt.Clid,
DEFAULT_CLASS_ID_DATA,
@@ -377,7 +373,6 @@ PxeBcBuildDhcp4Options (
return Index;
}
-
/**
Create a template DHCPv4 packet as a seed.
@@ -387,32 +382,31 @@ PxeBcBuildDhcp4Options (
**/
VOID
PxeBcSeedDhcp4Packet (
- OUT EFI_DHCP4_PACKET *Seed,
- IN EFI_UDP4_PROTOCOL *Udp4
+ OUT EFI_DHCP4_PACKET *Seed,
+ IN EFI_UDP4_PROTOCOL *Udp4
)
{
- EFI_SIMPLE_NETWORK_MODE Mode;
- EFI_DHCP4_HEADER *Header;
+ EFI_SIMPLE_NETWORK_MODE Mode;
+ EFI_DHCP4_HEADER *Header;
//
// Get IfType and HwAddressSize from SNP mode data.
//
Udp4->GetModeData (Udp4, NULL, NULL, NULL, &Mode);
- Seed->Size = sizeof (EFI_DHCP4_PACKET);
- Seed->Length = sizeof (Seed->Dhcp4);
- Header = &Seed->Dhcp4.Header;
+ Seed->Size = sizeof (EFI_DHCP4_PACKET);
+ Seed->Length = sizeof (Seed->Dhcp4);
+ Header = &Seed->Dhcp4.Header;
ZeroMem (Header, sizeof (EFI_DHCP4_HEADER));
- Header->OpCode = PXEBC_DHCP4_OPCODE_REQUEST;
- Header->HwType = Mode.IfType;
- Header->HwAddrLen = (UINT8) Mode.HwAddressSize;
+ Header->OpCode = PXEBC_DHCP4_OPCODE_REQUEST;
+ Header->HwType = Mode.IfType;
+ Header->HwAddrLen = (UINT8)Mode.HwAddressSize;
CopyMem (Header->ClientHwAddr, &Mode.CurrentAddress, Header->HwAddrLen);
Seed->Dhcp4.Magik = PXEBC_DHCP4_MAGIC;
Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP;
}
-
/**
Cache the DHCPv4 packet.
@@ -425,8 +419,8 @@ PxeBcSeedDhcp4Packet (
**/
EFI_STATUS
PxeBcCacheDhcp4Packet (
- IN EFI_DHCP4_PACKET *Dst,
- IN EFI_DHCP4_PACKET *Src
+ IN EFI_DHCP4_PACKET *Dst,
+ IN EFI_DHCP4_PACKET *Src
)
{
if (Dst->Size < Src->Length) {
@@ -439,7 +433,6 @@ PxeBcCacheDhcp4Packet (
return EFI_SUCCESS;
}
-
/**
Parse the cached DHCPv4 packet, including all the options.
@@ -451,21 +444,21 @@ PxeBcCacheDhcp4Packet (
**/
EFI_STATUS
PxeBcParseDhcp4Packet (
- IN PXEBC_DHCP4_PACKET_CACHE *Cache4
+ IN PXEBC_DHCP4_PACKET_CACHE *Cache4
)
{
- EFI_DHCP4_PACKET *Offer;
- EFI_DHCP4_PACKET_OPTION **Options;
- EFI_DHCP4_PACKET_OPTION *Option;
- PXEBC_OFFER_TYPE OfferType;
- UINTN Index;
- BOOLEAN IsProxyOffer;
- BOOLEAN IsPxeOffer;
- UINT8 *Ptr8;
- BOOLEAN FileFieldOverloaded;
+ EFI_DHCP4_PACKET *Offer;
+ EFI_DHCP4_PACKET_OPTION **Options;
+ EFI_DHCP4_PACKET_OPTION *Option;
+ PXEBC_OFFER_TYPE OfferType;
+ UINTN Index;
+ BOOLEAN IsProxyOffer;
+ BOOLEAN IsPxeOffer;
+ UINT8 *Ptr8;
+ BOOLEAN FileFieldOverloaded;
- IsProxyOffer = FALSE;
- IsPxeOffer = FALSE;
+ IsProxyOffer = FALSE;
+ IsPxeOffer = FALSE;
FileFieldOverloaded = FALSE;
ZeroMem (Cache4->OptList, sizeof (Cache4->OptList));
@@ -485,6 +478,7 @@ PxeBcParseDhcp4Packet (
mInterestedDhcp4Tags[Index]
);
}
+
//
// Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132.
// If yes, try to parse options from the BootFileName field, then ServerName field.
@@ -496,18 +490,19 @@ PxeBcParseDhcp4Packet (
for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
if (Options[Index] == NULL) {
Options[Index] = PxeBcParseDhcp4Options (
- (UINT8 *) Offer->Dhcp4.Header.BootFileName,
+ (UINT8 *)Offer->Dhcp4.Header.BootFileName,
sizeof (Offer->Dhcp4.Header.BootFileName),
mInterestedDhcp4Tags[Index]
);
}
}
}
+
if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_SERVER_NAME) != 0) {
for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
if (Options[Index] == NULL) {
Options[Index] = PxeBcParseDhcp4Options (
- (UINT8 *) Offer->Dhcp4.Header.ServerName,
+ (UINT8 *)Offer->Dhcp4.Header.ServerName,
sizeof (Offer->Dhcp4.Header.ServerName),
mInterestedDhcp4Tags[Index]
);
@@ -528,7 +523,8 @@ PxeBcParseDhcp4Packet (
//
Option = Options[PXEBC_DHCP4_TAG_INDEX_CLASS_ID];
if ((Option != NULL) && (Option->Length >= 9) &&
- (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) == 0)) {
+ (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) == 0))
+ {
IsPxeOffer = TRUE;
}
@@ -536,7 +532,7 @@ PxeBcParseDhcp4Packet (
// Parse PXE vendor options in this offer, and store the contents/pointers.
//
Option = Options[PXEBC_DHCP4_TAG_INDEX_VENDOR];
- if (IsPxeOffer && Option != NULL) {
+ if (IsPxeOffer && (Option != NULL)) {
PxeBcParseVendorOptions (Option, &Cache4->VendorOpt);
}
@@ -550,33 +546,32 @@ PxeBcParseDhcp4Packet (
// RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is null
// terminated string. So force to append null terminated character at the end of string.
//
- Ptr8 = (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
+ Ptr8 = (UINT8 *)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length;
if (*(Ptr8 - 1) != '\0') {
*Ptr8 = '\0';
}
- } else if (!FileFieldOverloaded && Offer->Dhcp4.Header.BootFileName[0] != 0) {
+ } else if (!FileFieldOverloaded && (Offer->Dhcp4.Header.BootFileName[0] != 0)) {
//
// If the bootfile is not present and bootfilename is present in DHCPv4 packet, just parse it.
// Do not count dhcp option header here, or else will destroy the serverhostname.
//
Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *)
- (&Offer->Dhcp4.Header.BootFileName[0] -
- OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0]));
-
+ (&Offer->Dhcp4.Header.BootFileName[0] -
+ OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0]));
}
//
// Determine offer type of the DHCPv4 packet.
//
Option = Options[PXEBC_DHCP4_TAG_INDEX_MSG_TYPE];
- if (Option == NULL || Option->Data[0] == 0) {
+ if ((Option == NULL) || (Option->Data[0] == 0)) {
//
// It's a Bootp offer.
//
OfferType = PxeOfferTypeBootp;
- Option = Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE];
+ Option = Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE];
if (Option == NULL) {
//
// If the Bootp offer without bootfilename, discard it.
@@ -584,7 +579,6 @@ PxeBcParseDhcp4Packet (
return EFI_DEVICE_ERROR;
}
} else {
-
if (IS_VALID_DISCOVER_VENDOR_OPTION (Cache4->VendorOpt.BitMap)) {
//
// It's a PXE10 offer with PXEClient and discover vendor option.
@@ -614,7 +608,6 @@ PxeBcParseDhcp4Packet (
return EFI_SUCCESS;
}
-
/**
Cache the DHCPv4 ack packet, and parse it on demand.
@@ -628,9 +621,9 @@ PxeBcParseDhcp4Packet (
**/
EFI_STATUS
PxeBcCopyDhcp4Ack (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_DHCP4_PACKET *Ack,
- IN BOOLEAN Verified
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_DHCP4_PACKET *Ack,
+ IN BOOLEAN Verified
)
{
EFI_PXE_BASE_CODE_MODE *Mode;
@@ -655,7 +648,6 @@ PxeBcCopyDhcp4Ack (
return EFI_SUCCESS;
}
-
/**
Cache the DHCPv4 proxy offer packet according to the received order.
@@ -668,8 +660,8 @@ PxeBcCopyDhcp4Ack (
**/
EFI_STATUS
PxeBcCopyProxyOffer (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT32 OfferIndex
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT32 OfferIndex
)
{
EFI_PXE_BASE_CODE_MODE *Mode;
@@ -686,7 +678,7 @@ PxeBcCopyProxyOffer (
// Cache the proxy offer packet and parse it.
//
Status = PxeBcCacheDhcp4Packet (&Private->ProxyOffer.Dhcp4.Packet.Offer, Offer);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -701,7 +693,6 @@ PxeBcCopyProxyOffer (
return EFI_SUCCESS;
}
-
/**
Retry to request bootfile name by the BINL offer.
@@ -714,8 +705,8 @@ PxeBcCopyProxyOffer (
**/
EFI_STATUS
PxeBcRetryBinlOffer (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT32 Index
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT32 Index
)
{
EFI_DHCP4_PACKET *Offer;
@@ -725,8 +716,10 @@ PxeBcRetryBinlOffer (
EFI_DHCP4_PACKET *Reply;
ASSERT (Index < PXEBC_OFFER_MAX_NUM);
- ASSERT (Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpBinl ||
- Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeProxyBinl);
+ ASSERT (
+ Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpBinl ||
+ Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeProxyBinl
+ );
Offer = &Private->OfferBuffer[Index].Dhcp4.Packet.Offer;
@@ -775,9 +768,10 @@ PxeBcRetryBinlOffer (
return Status;
}
- if (Cache4->OfferType != PxeOfferTypeProxyPxe10 &&
- Cache4->OfferType != PxeOfferTypeProxyWfm11a &&
- Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL) {
+ if ((Cache4->OfferType != PxeOfferTypeProxyPxe10) &&
+ (Cache4->OfferType != PxeOfferTypeProxyWfm11a) &&
+ (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL))
+ {
//
// This BINL ack doesn't have discovery option set or multicast option set
// or bootfile name specified.
@@ -794,7 +788,6 @@ PxeBcRetryBinlOffer (
return EFI_SUCCESS;
}
-
/**
Cache all the received DHCPv4 offers, and set OfferIndex and OfferCount.
@@ -807,8 +800,8 @@ PxeBcRetryBinlOffer (
**/
EFI_STATUS
PxeBcCacheDhcp4Offer (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_DHCP4_PACKET *RcvdOffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_DHCP4_PACKET *RcvdOffer
)
{
PXEBC_DHCP4_PACKET_CACHE *Cache4;
@@ -824,7 +817,7 @@ PxeBcCacheDhcp4Offer (
// Cache the content of DHCPv4 packet firstly.
//
Status = PxeBcCacheDhcp4Packet (Offer, RcvdOffer);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -865,8 +858,9 @@ PxeBcCacheDhcp4Offer (
//
Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum;
Private->OfferCount[OfferType]++;
- } else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeProxyWfm11a) &&
- Private->OfferCount[OfferType] < 1) {
+ } else if (((OfferType == PxeOfferTypeProxyPxe10) || (OfferType == PxeOfferTypeProxyWfm11a)) &&
+ (Private->OfferCount[OfferType] < 1))
+ {
//
// Only cache the first PXE10/WFM11a offer, and discard the others.
//
@@ -889,7 +883,6 @@ PxeBcCacheDhcp4Offer (
return EFI_SUCCESS;
}
-
/**
Select an DHCPv4 offer, and record SelectIndex and SelectProxyType.
@@ -898,12 +891,12 @@ PxeBcCacheDhcp4Offer (
**/
VOID
PxeBcSelectDhcp4Offer (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
- UINT32 Index;
- UINT32 OfferIndex;
- EFI_DHCP4_PACKET *Offer;
+ UINT32 Index;
+ UINT32 OfferIndex;
+ EFI_DHCP4_PACKET *Offer;
Private->SelectIndex = 0;
@@ -916,43 +909,40 @@ PxeBcSelectDhcp4Offer (
// 1. DhcpPxe10 offer
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpPxe10][0] + 1;
-
} else if (Private->OfferCount[PxeOfferTypeDhcpWfm11a] > 0) {
//
// 2. DhcpWfm11a offer
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpWfm11a][0] + 1;
-
- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
- Private->OfferCount[PxeOfferTypeProxyPxe10] > 0) {
+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
+ (Private->OfferCount[PxeOfferTypeProxyPxe10] > 0))
+ {
//
// 3. DhcpOnly offer and ProxyPxe10 offer.
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
Private->SelectProxyType = PxeOfferTypeProxyPxe10;
-
- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
- Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0) {
+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
+ (Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0))
+ {
//
// 4. DhcpOnly offer and ProxyWfm11a offer.
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
Private->SelectProxyType = PxeOfferTypeProxyWfm11a;
-
} else if (Private->OfferCount[PxeOfferTypeDhcpBinl] > 0) {
//
// 5. DhcpBinl offer.
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpBinl][0] + 1;
-
- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
- Private->OfferCount[PxeOfferTypeProxyBinl] > 0) {
+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
+ (Private->OfferCount[PxeOfferTypeProxyBinl] > 0))
+ {
//
// 6. DhcpOnly offer and ProxyBinl offer.
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
Private->SelectProxyType = PxeOfferTypeProxyBinl;
-
} else {
//
// 7. DhcpOnly offer with bootfilename.
@@ -964,13 +954,15 @@ PxeBcSelectDhcp4Offer (
break;
}
}
+
//
// 8. Bootp offer with bootfilename.
//
OfferIndex = Private->OfferIndex[PxeOfferTypeBootp][0];
- if (Private->SelectIndex == 0 &&
- Private->OfferCount[PxeOfferTypeBootp] > 0 &&
- Private->OfferBuffer[OfferIndex].Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
+ if ((Private->SelectIndex == 0) &&
+ (Private->OfferCount[PxeOfferTypeBootp] > 0) &&
+ (Private->OfferBuffer[OfferIndex].Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL))
+ {
Private->SelectIndex = OfferIndex + 1;
}
}
@@ -979,7 +971,6 @@ PxeBcSelectDhcp4Offer (
// Select offer by received order.
//
for (Index = 0; Index < Private->OfferNum; Index++) {
-
Offer = &Private->OfferBuffer[Index].Dhcp4.Packet.Offer;
if (IS_PROXY_DHCP_OFFER (Offer)) {
@@ -990,8 +981,9 @@ PxeBcSelectDhcp4Offer (
}
if (!Private->IsProxyRecved &&
- Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpOnly &&
- Private->OfferBuffer[Index].Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL) {
+ (Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpOnly) &&
+ (Private->OfferBuffer[Index].Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL))
+ {
//
// Skip if DhcpOnly offer without any other proxy offers or bootfilename.
//
@@ -1007,7 +999,6 @@ PxeBcSelectDhcp4Offer (
}
}
-
/**
Handle the DHCPv4 offer packet.
@@ -1021,7 +1012,7 @@ PxeBcSelectDhcp4Offer (
**/
EFI_STATUS
PxeBcHandleDhcp4Offer (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
PXEBC_DHCP4_PACKET_CACHE *Cache4;
@@ -1036,11 +1027,11 @@ PxeBcHandleDhcp4Offer (
EFI_DHCP4_PACKET *Ack;
ASSERT (Private->SelectIndex > 0);
- SelectIndex = (UINT32) (Private->SelectIndex - 1);
+ SelectIndex = (UINT32)(Private->SelectIndex - 1);
ASSERT (SelectIndex < PXEBC_OFFER_MAX_NUM);
- Cache4 = &Private->OfferBuffer[SelectIndex].Dhcp4;
- Options = Cache4->OptList;
- Status = EFI_SUCCESS;
+ Cache4 = &Private->OfferBuffer[SelectIndex].Dhcp4;
+ Options = Cache4->OptList;
+ Status = EFI_SUCCESS;
if (Cache4->OfferType == PxeOfferTypeDhcpBinl) {
//
@@ -1050,7 +1041,6 @@ PxeBcHandleDhcp4Offer (
Status = EFI_NO_RESPONSE;
}
} else if (Cache4->OfferType == PxeOfferTypeDhcpOnly) {
-
if (Private->IsProxyRecved) {
//
// DhcpOnly offer is selected, so need try to request bootfile name.
@@ -1075,6 +1065,7 @@ PxeBcHandleDhcp4Offer (
break;
}
}
+
if (Index == Private->OfferCount[Private->SelectProxyType]) {
Status = EFI_NO_RESPONSE;
}
@@ -1117,7 +1108,7 @@ PxeBcHandleDhcp4Offer (
}
}
- if (!EFI_ERROR (Status) && Private->SelectProxyType != PxeOfferTypeProxyBinl) {
+ if (!EFI_ERROR (Status) && (Private->SelectProxyType != PxeOfferTypeProxyBinl)) {
//
// Success to try to request by a ProxyPxe10 or ProxyWfm11a offer, copy and parse it.
//
@@ -1152,13 +1143,13 @@ PxeBcHandleDhcp4Offer (
if (EFI_ERROR (Status)) {
return Status;
}
+
Mode->DhcpDiscoverValid = TRUE;
}
return Status;
}
-
/**
EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver
to intercept events that occurred in the configuration process.
@@ -1182,12 +1173,12 @@ PxeBcHandleDhcp4Offer (
EFI_STATUS
EFIAPI
PxeBcDhcp4CallBack (
- IN EFI_DHCP4_PROTOCOL *This,
- IN VOID *Context,
- IN EFI_DHCP4_STATE CurrentState,
- IN EFI_DHCP4_EVENT Dhcp4Event,
- IN EFI_DHCP4_PACKET *Packet OPTIONAL,
- OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN VOID *Context,
+ IN EFI_DHCP4_STATE CurrentState,
+ IN EFI_DHCP4_EVENT Dhcp4Event,
+ IN EFI_DHCP4_PACKET *Packet OPTIONAL,
+ OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -1201,15 +1192,16 @@ PxeBcDhcp4CallBack (
if ((Dhcp4Event != Dhcp4RcvdOffer) &&
(Dhcp4Event != Dhcp4SelectOffer) &&
(Dhcp4Event != Dhcp4SendDiscover) &&
- (Dhcp4Event != Dhcp4RcvdAck)) {
+ (Dhcp4Event != Dhcp4RcvdAck))
+ {
return EFI_SUCCESS;
}
ASSERT (Packet != NULL);
- Private = (PXEBC_PRIVATE_DATA *) Context;
- Mode = Private->PxeBc.Mode;
- Callback = Private->PxeBcCallback;
+ Private = (PXEBC_PRIVATE_DATA *)Context;
+ Mode = Private->PxeBc.Mode;
+ Callback = Private->PxeBcCallback;
//
// Override the Maximum DHCP Message Size.
@@ -1227,15 +1219,15 @@ PxeBcDhcp4CallBack (
//
// Callback to user if any packets sent or received.
//
- if (Dhcp4Event != Dhcp4SelectOffer && Callback != NULL) {
- Received = (BOOLEAN) (Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
- Status = Callback->Callback (
- Callback,
- Private->Function,
- Received,
- Packet->Length,
- (EFI_PXE_BASE_CODE_PACKET *) &Packet->Dhcp4
- );
+ if ((Dhcp4Event != Dhcp4SelectOffer) && (Callback != NULL)) {
+ Received = (BOOLEAN)(Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
+ Status = Callback->Callback (
+ Callback,
+ Private->Function,
+ Received,
+ Packet->Length,
+ (EFI_PXE_BASE_CODE_PACKET *)&Packet->Dhcp4
+ );
if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
return EFI_ABORTED;
}
@@ -1358,37 +1350,37 @@ PxeBcDhcp4CallBack (
**/
EFI_STATUS
PxeBcDhcp4Discover (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT16 Type,
- IN UINT16 *Layer,
- IN BOOLEAN UseBis,
- IN EFI_IP_ADDRESS *DestIp,
- IN UINT16 IpCount,
- IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT16 Type,
+ IN UINT16 *Layer,
+ IN BOOLEAN UseBis,
+ IN EFI_IP_ADDRESS *DestIp,
+ IN UINT16 IpCount,
+ IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
)
{
- EFI_PXE_BASE_CODE_UDP_PORT Sport;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_DHCP4_PROTOCOL *Dhcp4;
- EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN Token;
- BOOLEAN IsBCast;
- EFI_STATUS Status;
- UINT16 RepIndex;
- UINT16 SrvIndex;
- UINT16 TryIndex;
- EFI_DHCP4_LISTEN_POINT ListenPoint;
- EFI_DHCP4_PACKET *Response;
- UINT8 Buffer[PXEBC_DHCP4_OPTION_MAX_SIZE];
- EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_OPTION_MAX_NUM];
- UINT32 OptCount;
- EFI_DHCP4_PACKET_OPTION *PxeOpt;
- PXEBC_OPTION_BOOT_ITEM *PxeBootItem;
- UINT8 VendorOptLen;
- UINT32 Xid;
-
- Mode = Private->PxeBc.Mode;
- Dhcp4 = Private->Dhcp4;
- Status = EFI_SUCCESS;
+ EFI_PXE_BASE_CODE_UDP_PORT Sport;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_DHCP4_PROTOCOL *Dhcp4;
+ EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN Token;
+ BOOLEAN IsBCast;
+ EFI_STATUS Status;
+ UINT16 RepIndex;
+ UINT16 SrvIndex;
+ UINT16 TryIndex;
+ EFI_DHCP4_LISTEN_POINT ListenPoint;
+ EFI_DHCP4_PACKET *Response;
+ UINT8 Buffer[PXEBC_DHCP4_OPTION_MAX_SIZE];
+ EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_OPTION_MAX_NUM];
+ UINT32 OptCount;
+ EFI_DHCP4_PACKET_OPTION *PxeOpt;
+ PXEBC_OPTION_BOOT_ITEM *PxeBootItem;
+ UINT8 VendorOptLen;
+ UINT32 Xid;
+
+ Mode = Private->PxeBc.Mode;
+ Dhcp4 = Private->Dhcp4;
+ Status = EFI_SUCCESS;
ZeroMem (&Token, sizeof (EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN));
@@ -1403,7 +1395,7 @@ PxeBcDhcp4Discover (
IsBCast = FALSE;
}
- if (!UseBis && Layer != NULL) {
+ if (!UseBis && (Layer != NULL)) {
*Layer &= EFI_PXE_BASE_CODE_BOOT_LAYER_MASK;
}
@@ -1416,23 +1408,23 @@ PxeBcDhcp4Discover (
//
// Add vendor option of PXE_BOOT_ITEM
//
- VendorOptLen = (UINT8) ((sizeof (EFI_DHCP4_PACKET_OPTION) - 1) * 2 + sizeof (PXEBC_OPTION_BOOT_ITEM) + 1);
+ VendorOptLen = (UINT8)((sizeof (EFI_DHCP4_PACKET_OPTION) - 1) * 2 + sizeof (PXEBC_OPTION_BOOT_ITEM) + 1);
OptList[OptCount] = AllocateZeroPool (VendorOptLen);
if (OptList[OptCount] == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- OptList[OptCount]->OpCode = DHCP4_TAG_VENDOR;
- OptList[OptCount]->Length = (UINT8) (VendorOptLen - 2);
- PxeOpt = (EFI_DHCP4_PACKET_OPTION *) OptList[OptCount]->Data;
- PxeOpt->OpCode = PXEBC_VENDOR_TAG_BOOT_ITEM;
- PxeOpt->Length = (UINT8) sizeof (PXEBC_OPTION_BOOT_ITEM);
- PxeBootItem = (PXEBC_OPTION_BOOT_ITEM *) PxeOpt->Data;
- PxeBootItem->Type = HTONS (Type);
- PxeOpt->Data[PxeOpt->Length] = DHCP4_TAG_EOP;
+ OptList[OptCount]->OpCode = DHCP4_TAG_VENDOR;
+ OptList[OptCount]->Length = (UINT8)(VendorOptLen - 2);
+ PxeOpt = (EFI_DHCP4_PACKET_OPTION *)OptList[OptCount]->Data;
+ PxeOpt->OpCode = PXEBC_VENDOR_TAG_BOOT_ITEM;
+ PxeOpt->Length = (UINT8)sizeof (PXEBC_OPTION_BOOT_ITEM);
+ PxeBootItem = (PXEBC_OPTION_BOOT_ITEM *)PxeOpt->Data;
+ PxeBootItem->Type = HTONS (Type);
+ PxeOpt->Data[PxeOpt->Length] = DHCP4_TAG_EOP;
if (Layer != NULL) {
- PxeBootItem->Layer = HTONS (*Layer);
+ PxeBootItem->Layer = HTONS (*Layer);
}
OptCount++;
@@ -1477,7 +1469,7 @@ PxeBcDhcp4Discover (
//
Xid = NET_RANDOM (NetRandomInitSeed ());
Token.Packet->Dhcp4.Header.Xid = HTONL (Xid);
- Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16) ((IsBCast) ? 0x8000 : 0x0));
+ Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16)((IsBCast) ? 0x8000 : 0x0));
CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));
Token.RemotePort = Sport;
@@ -1491,20 +1483,19 @@ PxeBcDhcp4Discover (
CopyMem (&Token.GatewayAddress, &Private->GatewayIp, sizeof (EFI_IPv4_ADDRESS));
if (!IsBCast) {
- Token.ListenPointCount = 1;
- Token.ListenPoints = &ListenPoint;
- Token.ListenPoints[0].ListenPort = PXEBC_BS_DISCOVER_PORT;
- CopyMem (&Token.ListenPoints[0].ListenAddress, &Private->StationIp, sizeof(EFI_IPv4_ADDRESS));
- CopyMem (&Token.ListenPoints[0].SubnetMask, &Private->SubnetMask, sizeof(EFI_IPv4_ADDRESS));
+ Token.ListenPointCount = 1;
+ Token.ListenPoints = &ListenPoint;
+ Token.ListenPoints[0].ListenPort = PXEBC_BS_DISCOVER_PORT;
+ CopyMem (&Token.ListenPoints[0].ListenAddress, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&Token.ListenPoints[0].SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS));
}
//
// Send out the request packet to discover the bootfile.
//
for (TryIndex = 1; TryIndex <= PXEBC_BOOT_REQUEST_RETRIES; TryIndex++) {
-
- Token.TimeoutValue = (UINT16) (PXEBC_BOOT_REQUEST_TIMEOUT * TryIndex);
- Token.Packet->Dhcp4.Header.Seconds = (UINT16) (PXEBC_BOOT_REQUEST_TIMEOUT * (TryIndex - 1));
+ Token.TimeoutValue = (UINT16)(PXEBC_BOOT_REQUEST_TIMEOUT * TryIndex);
+ Token.Packet->Dhcp4.Header.Seconds = (UINT16)(PXEBC_BOOT_REQUEST_TIMEOUT * (TryIndex - 1));
Status = Dhcp4->TransmitReceive (Dhcp4, &Token);
if (Token.Status != EFI_TIMEOUT) {
@@ -1520,10 +1511,9 @@ PxeBcDhcp4Discover (
}
if (!EFI_ERROR (Status)) {
-
- RepIndex = 0;
- SrvIndex = 0;
- Response = Token.ResponseList;
+ RepIndex = 0;
+ SrvIndex = 0;
+ Response = Token.ResponseList;
//
// Find the right PXE Reply according to server address.
//
@@ -1531,7 +1521,7 @@ PxeBcDhcp4Discover (
if (Response->Length > PXEBC_DHCP4_PACKET_MAX_SIZE) {
SrvIndex = 0;
RepIndex++;
- Response = (EFI_DHCP4_PACKET *) ((UINT8 *) Response + Response->Size);
+ Response = (EFI_DHCP4_PACKET *)((UINT8 *)Response + Response->Size);
continue;
}
@@ -1539,10 +1529,13 @@ PxeBcDhcp4Discover (
if (SrvList[SrvIndex].AcceptAnyResponse) {
break;
}
+
if ((SrvList[SrvIndex].Type == Type) &&
- EFI_IP4_EQUAL (&Response->Dhcp4.Header.ServerAddr, &SrvList[SrvIndex].IpAddr)) {
+ EFI_IP4_EQUAL (&Response->Dhcp4.Header.ServerAddr, &SrvList[SrvIndex].IpAddr))
+ {
break;
}
+
SrvIndex++;
}
@@ -1552,7 +1545,7 @@ PxeBcDhcp4Discover (
SrvIndex = 0;
RepIndex++;
- Response = (EFI_DHCP4_PACKET *) ((UINT8 *) Response + Response->Size);
+ Response = (EFI_DHCP4_PACKET *)((UINT8 *)Response + Response->Size);
}
if (RepIndex < Token.ResponseCount) {
@@ -1562,13 +1555,14 @@ PxeBcDhcp4Discover (
//
if (Private->IsDoDiscover) {
Status = PxeBcCacheDhcp4Packet (&Private->PxeReply.Dhcp4.Packet.Ack, Response);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
+
CopyMem (&Mode->PxeDiscover, &Token.Packet->Dhcp4, Token.Packet->Length);
} else {
Status = PxeBcCacheDhcp4Packet (&Private->ProxyOffer.Dhcp4.Packet.Offer, Response);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
}
@@ -1579,14 +1573,17 @@ PxeBcDhcp4Discover (
Status = EFI_NOT_FOUND;
}
}
+
ON_EXIT:
if (Token.ResponseList != NULL) {
FreePool (Token.ResponseList);
}
+
if (Token.Packet != NULL) {
FreePool (Token.Packet);
}
+
return Status;
}
@@ -1601,40 +1598,40 @@ ON_EXIT:
**/
EFI_STATUS
PxeBcSetIp4Policy (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
- EFI_IP4_CONFIG2_POLICY Policy;
- UINTN DataSize;
+ EFI_STATUS Status;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
+ EFI_IP4_CONFIG2_POLICY Policy;
+ UINTN DataSize;
Ip4Config2 = Private->Ip4Config2;
- DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
- Status = Ip4Config2->GetData (
- Ip4Config2,
- Ip4Config2DataTypePolicy,
- &DataSize,
- &Policy
- );
+ DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
+ Status = Ip4Config2->GetData (
+ Ip4Config2,
+ Ip4Config2DataTypePolicy,
+ &DataSize,
+ &Policy
+ );
if (EFI_ERROR (Status)) {
return Status;
}
if (Policy != Ip4Config2PolicyStatic) {
Policy = Ip4Config2PolicyStatic;
- Status= Ip4Config2->SetData (
- Ip4Config2,
- Ip4Config2DataTypePolicy,
- sizeof (EFI_IP4_CONFIG2_POLICY),
- &Policy
- );
+ Status = Ip4Config2->SetData (
+ Ip4Config2,
+ Ip4Config2DataTypePolicy,
+ sizeof (EFI_IP4_CONFIG2_POLICY),
+ &Policy
+ );
if (EFI_ERROR (Status)) {
return Status;
}
}
- return EFI_SUCCESS;
+ return EFI_SUCCESS;
}
/**
@@ -1649,28 +1646,28 @@ PxeBcSetIp4Policy (
**/
EFI_STATUS
PxeBcDhcp4Dora (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_DHCP4_PROTOCOL *Dhcp4
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_DHCP4_PROTOCOL *Dhcp4
)
{
- EFI_PXE_BASE_CODE_MODE *PxeMode;
- EFI_DHCP4_CONFIG_DATA Config;
- EFI_DHCP4_MODE_DATA Mode;
- EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_OPTION_MAX_NUM];
- UINT8 Buffer[PXEBC_DHCP4_OPTION_MAX_SIZE];
- UINT32 OptCount;
- EFI_STATUS Status;
+ EFI_PXE_BASE_CODE_MODE *PxeMode;
+ EFI_DHCP4_CONFIG_DATA Config;
+ EFI_DHCP4_MODE_DATA Mode;
+ EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_OPTION_MAX_NUM];
+ UINT8 Buffer[PXEBC_DHCP4_OPTION_MAX_SIZE];
+ UINT32 OptCount;
+ EFI_STATUS Status;
ASSERT (Dhcp4 != NULL);
- Status = EFI_SUCCESS;
- PxeMode = Private->PxeBc.Mode;
+ Status = EFI_SUCCESS;
+ PxeMode = Private->PxeBc.Mode;
//
// Build option list for the request packet.
//
OptCount = PxeBcBuildDhcp4Options (Private, OptList, Buffer, FALSE);
- ASSERT (OptCount> 0);
+ ASSERT (OptCount > 0);
ZeroMem (&Mode, sizeof (EFI_DHCP4_MODE_DATA));
ZeroMem (&Config, sizeof (EFI_DHCP4_CONFIG_DATA));
@@ -1704,7 +1701,7 @@ PxeBcDhcp4Dora (
PxeMode->IcmpErrorReceived = TRUE;
}
- if (Status == EFI_TIMEOUT && Private->OfferNum > 0) {
+ if ((Status == EFI_TIMEOUT) && (Private->OfferNum > 0)) {
Status = EFI_NO_RESPONSE;
}
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
@@ -10,17 +10,17 @@
#ifndef __EFI_PXEBC_DHCP4_H__
#define __EFI_PXEBC_DHCP4_H__
-#define PXEBC_DHCP4_OPTION_MAX_NUM 16
-#define PXEBC_DHCP4_OPTION_MAX_SIZE 312
-#define PXEBC_DHCP4_PACKET_MAX_SIZE (sizeof (EFI_PXE_BASE_CODE_PACKET))
-#define PXEBC_DHCP4_S_PORT 67
-#define PXEBC_DHCP4_C_PORT 68
-#define PXEBC_BS_DOWNLOAD_PORT 69
-#define PXEBC_BS_DISCOVER_PORT 4011
-#define PXEBC_DHCP4_OPCODE_REQUEST 1
-#define PXEBC_DHCP4_OPCODE_REPLY 2
-#define PXEBC_DHCP4_MSG_TYPE_REQUEST 3
-#define PXEBC_DHCP4_MAGIC 0x63538263 // network byte order
+#define PXEBC_DHCP4_OPTION_MAX_NUM 16
+#define PXEBC_DHCP4_OPTION_MAX_SIZE 312
+#define PXEBC_DHCP4_PACKET_MAX_SIZE (sizeof (EFI_PXE_BASE_CODE_PACKET))
+#define PXEBC_DHCP4_S_PORT 67
+#define PXEBC_DHCP4_C_PORT 68
+#define PXEBC_BS_DOWNLOAD_PORT 69
+#define PXEBC_BS_DISCOVER_PORT 4011
+#define PXEBC_DHCP4_OPCODE_REQUEST 1
+#define PXEBC_DHCP4_OPCODE_REPLY 2
+#define PXEBC_DHCP4_MSG_TYPE_REQUEST 3
+#define PXEBC_DHCP4_MAGIC 0x63538263 // network byte order
//
// Sub-Options in Dhcp Vendor Option
@@ -39,24 +39,23 @@
#define PXEBC_VENDOR_TAG_CREDENTIAL_TYPES 12
#define PXEBC_VENDOR_TAG_BOOT_ITEM 71
-#define PXEBC_BOOT_REQUEST_TIMEOUT 1
-#define PXEBC_BOOT_REQUEST_RETRIES 4
-
-#define PXEBC_DHCP4_OVERLOAD_FILE 1
-#define PXEBC_DHCP4_OVERLOAD_SERVER_NAME 2
+#define PXEBC_BOOT_REQUEST_TIMEOUT 1
+#define PXEBC_BOOT_REQUEST_RETRIES 4
+#define PXEBC_DHCP4_OVERLOAD_FILE 1
+#define PXEBC_DHCP4_OVERLOAD_SERVER_NAME 2
//
// The array index of the DHCP4 option tag interested
//
-#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
-#define PXEBC_DHCP4_TAG_INDEX_VENDOR 1
-#define PXEBC_DHCP4_TAG_INDEX_OVERLOAD 2
-#define PXEBC_DHCP4_TAG_INDEX_MSG_TYPE 3
-#define PXEBC_DHCP4_TAG_INDEX_SERVER_ID 4
-#define PXEBC_DHCP4_TAG_INDEX_CLASS_ID 5
-#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE 6
-#define PXEBC_DHCP4_TAG_INDEX_MAX 7
+#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
+#define PXEBC_DHCP4_TAG_INDEX_VENDOR 1
+#define PXEBC_DHCP4_TAG_INDEX_OVERLOAD 2
+#define PXEBC_DHCP4_TAG_INDEX_MSG_TYPE 3
+#define PXEBC_DHCP4_TAG_INDEX_SERVER_ID 4
+#define PXEBC_DHCP4_TAG_INDEX_CLASS_ID 5
+#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE 6
+#define PXEBC_DHCP4_TAG_INDEX_MAX 7
//
// Dhcp4 and Dhcp6 share this definition, and corresponding
@@ -79,12 +78,12 @@ typedef enum {
PxeOfferTypeMax
} PXEBC_OFFER_TYPE;
-#define BIT(x) (1 << x)
-#define CTRL(x) (0x1F & (x))
-#define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:xxxxx:UNDI:003000"
-#define DEFAULT_UNDI_TYPE 1
-#define DEFAULT_UNDI_MAJOR 3
-#define DEFAULT_UNDI_MINOR 0
+#define BIT(x) (1 << x)
+#define CTRL(x) (0x1F & (x))
+#define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:xxxxx:UNDI:003000"
+#define DEFAULT_UNDI_TYPE 1
+#define DEFAULT_UNDI_MAJOR 3
+#define DEFAULT_UNDI_MINOR 0
#define MTFTP_VENDOR_OPTION_BIT_MAP \
(BIT (PXEBC_VENDOR_TAG_MTFTP_IP) | \
@@ -157,122 +156,120 @@ typedef enum {
#define IS_DISABLE_PROMPT_MENU(x) \
(((x) & BIT (3)) == BIT (3))
-
#pragma pack(1)
typedef struct {
- UINT8 ParaList[135];
+ UINT8 ParaList[135];
} PXEBC_DHCP4_OPTION_PARA;
typedef struct {
- UINT16 Size;
+ UINT16 Size;
} PXEBC_DHCP4_OPTION_MAX_MESG_SIZE;
typedef struct {
- UINT8 Type;
- UINT8 MajorVer;
- UINT8 MinorVer;
+ UINT8 Type;
+ UINT8 MajorVer;
+ UINT8 MinorVer;
} PXEBC_DHCP4_OPTION_UNDI;
typedef struct {
- UINT8 Type;
+ UINT8 Type;
} PXEBC_DHCP4_OPTION_MESG;
typedef struct {
- UINT16 Type;
+ UINT16 Type;
} PXEBC_DHCP4_OPTION_ARCH;
typedef struct {
- UINT8 ClassIdentifier[10];
- UINT8 ArchitecturePrefix[5];
- UINT8 ArchitectureType[5];
- UINT8 Lit3[1];
- UINT8 InterfaceName[4];
- UINT8 Lit4[1];
- UINT8 UndiMajor[3];
- UINT8 UndiMinor[3];
+ UINT8 ClassIdentifier[10];
+ UINT8 ArchitecturePrefix[5];
+ UINT8 ArchitectureType[5];
+ UINT8 Lit3[1];
+ UINT8 InterfaceName[4];
+ UINT8 Lit4[1];
+ UINT8 UndiMajor[3];
+ UINT8 UndiMinor[3];
} PXEBC_DHCP4_OPTION_CLID;
typedef struct {
- UINT8 Type;
- UINT8 Guid[16];
+ UINT8 Type;
+ UINT8 Guid[16];
} PXEBC_DHCP4_OPTION_UUID;
typedef struct {
- UINT16 Type;
- UINT16 Layer;
+ UINT16 Type;
+ UINT16 Layer;
} PXEBC_OPTION_BOOT_ITEM;
#pragma pack()
typedef union {
- PXEBC_DHCP4_OPTION_PARA *Para;
- PXEBC_DHCP4_OPTION_UNDI *Undi;
- PXEBC_DHCP4_OPTION_ARCH *Arch;
- PXEBC_DHCP4_OPTION_CLID *Clid;
- PXEBC_DHCP4_OPTION_UUID *Uuid;
- PXEBC_DHCP4_OPTION_MESG *Mesg;
- PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *MaxMesgSize;
+ PXEBC_DHCP4_OPTION_PARA *Para;
+ PXEBC_DHCP4_OPTION_UNDI *Undi;
+ PXEBC_DHCP4_OPTION_ARCH *Arch;
+ PXEBC_DHCP4_OPTION_CLID *Clid;
+ PXEBC_DHCP4_OPTION_UUID *Uuid;
+ PXEBC_DHCP4_OPTION_MESG *Mesg;
+ PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *MaxMesgSize;
} PXEBC_DHCP4_OPTION_ENTRY;
#pragma pack(1)
typedef struct {
- UINT16 Type;
- UINT8 IpCnt;
- EFI_IPv4_ADDRESS IpAddr[1];
+ UINT16 Type;
+ UINT8 IpCnt;
+ EFI_IPv4_ADDRESS IpAddr[1];
} PXEBC_BOOT_SVR_ENTRY;
typedef struct {
- UINT16 Type;
- UINT8 DescLen;
- UINT8 DescStr[1];
+ UINT16 Type;
+ UINT8 DescLen;
+ UINT8 DescStr[1];
} PXEBC_BOOT_MENU_ENTRY;
typedef struct {
- UINT8 Timeout;
- UINT8 Prompt[1];
+ UINT8 Timeout;
+ UINT8 Prompt[1];
} PXEBC_MENU_PROMPT;
#pragma pack()
typedef struct {
- UINT32 BitMap[8];
- EFI_IPv4_ADDRESS MtftpIp;
- UINT16 MtftpCPort;
- UINT16 MtftpSPort;
- UINT8 MtftpTimeout;
- UINT8 MtftpDelay;
- UINT8 DiscoverCtrl;
- EFI_IPv4_ADDRESS DiscoverMcastIp;
- EFI_IPv4_ADDRESS McastIpBase;
- UINT16 McastIpBlock;
- UINT16 McastIpRange;
- UINT16 BootSrvType;
- UINT16 BootSrvLayer;
- PXEBC_BOOT_SVR_ENTRY *BootSvr;
- UINT8 BootSvrLen;
- PXEBC_BOOT_MENU_ENTRY *BootMenu;
- UINT8 BootMenuLen;
- PXEBC_MENU_PROMPT *MenuPrompt;
- UINT8 MenuPromptLen;
- UINT32 *CredType;
- UINT8 CredTypeLen;
+ UINT32 BitMap[8];
+ EFI_IPv4_ADDRESS MtftpIp;
+ UINT16 MtftpCPort;
+ UINT16 MtftpSPort;
+ UINT8 MtftpTimeout;
+ UINT8 MtftpDelay;
+ UINT8 DiscoverCtrl;
+ EFI_IPv4_ADDRESS DiscoverMcastIp;
+ EFI_IPv4_ADDRESS McastIpBase;
+ UINT16 McastIpBlock;
+ UINT16 McastIpRange;
+ UINT16 BootSrvType;
+ UINT16 BootSrvLayer;
+ PXEBC_BOOT_SVR_ENTRY *BootSvr;
+ UINT8 BootSvrLen;
+ PXEBC_BOOT_MENU_ENTRY *BootMenu;
+ UINT8 BootMenuLen;
+ PXEBC_MENU_PROMPT *MenuPrompt;
+ UINT8 MenuPromptLen;
+ UINT32 *CredType;
+ UINT8 CredTypeLen;
} PXEBC_VENDOR_OPTION;
#define PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + PXEBC_DHCP4_PACKET_MAX_SIZE)
typedef union {
- EFI_DHCP4_PACKET Offer;
- EFI_DHCP4_PACKET Ack;
- UINT8 Buffer[PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE];
+ EFI_DHCP4_PACKET Offer;
+ EFI_DHCP4_PACKET Ack;
+ UINT8 Buffer[PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE];
} PXEBC_DHCP4_PACKET;
typedef struct {
- PXEBC_DHCP4_PACKET Packet;
- PXEBC_OFFER_TYPE OfferType;
- EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_TAG_INDEX_MAX];
- PXEBC_VENDOR_OPTION VendorOpt;
+ PXEBC_DHCP4_PACKET Packet;
+ PXEBC_OFFER_TYPE OfferType;
+ EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_TAG_INDEX_MAX];
+ PXEBC_VENDOR_OPTION VendorOpt;
} PXEBC_DHCP4_PACKET_CACHE;
-
/**
Create a template DHCPv4 packet as a seed.
@@ -282,11 +279,10 @@ typedef struct {
**/
VOID
PxeBcSeedDhcp4Packet (
- OUT EFI_DHCP4_PACKET *Seed,
- IN EFI_UDP4_PROTOCOL *Udp4
+ OUT EFI_DHCP4_PACKET *Seed,
+ IN EFI_UDP4_PROTOCOL *Udp4
);
-
/**
Parse the cached DHCPv4 packet, including all the options.
@@ -298,10 +294,9 @@ PxeBcSeedDhcp4Packet (
**/
EFI_STATUS
PxeBcParseDhcp4Packet (
- IN PXEBC_DHCP4_PACKET_CACHE *Cache4
+ IN PXEBC_DHCP4_PACKET_CACHE *Cache4
);
-
/**
Build and send out the request packet for the bootfile, and parse the reply.
@@ -321,13 +316,13 @@ PxeBcParseDhcp4Packet (
**/
EFI_STATUS
PxeBcDhcp4Discover (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT16 Type,
- IN UINT16 *Layer,
- IN BOOLEAN UseBis,
- IN EFI_IP_ADDRESS *DestIp,
- IN UINT16 IpCount,
- IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT16 Type,
+ IN UINT16 *Layer,
+ IN BOOLEAN UseBis,
+ IN EFI_IP_ADDRESS *DestIp,
+ IN UINT16 IpCount,
+ IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
);
/**
@@ -341,10 +336,9 @@ PxeBcDhcp4Discover (
**/
EFI_STATUS
PxeBcSetIp4Policy (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
);
-
/**
Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other PXE boot information.
@@ -357,9 +351,8 @@ PxeBcSetIp4Policy (
**/
EFI_STATUS
PxeBcDhcp4Dora (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_DHCP4_PROTOCOL *Dhcp4
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_DHCP4_PROTOCOL *Dhcp4
);
#endif
-
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -15,7 +15,9 @@
//
// ALL_DHCP_Relay_Agents_and_Servers address: FF02::1:2
//
-EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress = {{0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2}};
+EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress = {
+ { 0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2 }
+};
/**
Parse out a DHCPv6 option by OptTag, and find the position in buffer.
@@ -30,35 +32,32 @@ EFI_IPv6_ADDRESS mAllDhcpRelayAndServe
**/
EFI_DHCP6_PACKET_OPTION *
PxeBcParseDhcp6Options (
- IN UINT8 *Buffer,
- IN UINT32 Length,
- IN UINT16 OptTag
+ IN UINT8 *Buffer,
+ IN UINT32 Length,
+ IN UINT16 OptTag
)
{
- EFI_DHCP6_PACKET_OPTION *Option;
- UINT32 Offset;
+ EFI_DHCP6_PACKET_OPTION *Option;
+ UINT32 Offset;
- Option = (EFI_DHCP6_PACKET_OPTION *) Buffer;
- Offset = 0;
+ Option = (EFI_DHCP6_PACKET_OPTION *)Buffer;
+ Offset = 0;
//
// OpLen and OpCode here are both stored in network order.
//
while (Offset < Length) {
-
if (NTOHS (Option->OpCode) == OptTag) {
-
return Option;
}
- Offset += (NTOHS(Option->OpLen) + 4);
- Option = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset);
+ Offset += (NTOHS (Option->OpLen) + 4);
+ Option = (EFI_DHCP6_PACKET_OPTION *)(Buffer + Offset);
}
return NULL;
}
-
/**
Build the options buffer for the DHCPv6 request packet.
@@ -71,70 +70,70 @@ PxeBcParseDhcp6Options (
**/
UINT32
PxeBcBuildDhcp6Options (
- IN PXEBC_PRIVATE_DATA *Private,
- OUT EFI_DHCP6_PACKET_OPTION **OptList,
- IN UINT8 *Buffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ OUT EFI_DHCP6_PACKET_OPTION **OptList,
+ IN UINT8 *Buffer
)
{
- PXEBC_DHCP6_OPTION_ENTRY OptEnt;
- UINT32 Index;
- UINT16 Value;
+ PXEBC_DHCP6_OPTION_ENTRY OptEnt;
+ UINT32 Index;
+ UINT16 Value;
- Index = 0;
- OptList[0] = (EFI_DHCP6_PACKET_OPTION *) Buffer;
+ Index = 0;
+ OptList[0] = (EFI_DHCP6_PACKET_OPTION *)Buffer;
//
// Append client option request option
//
- OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
- OptList[Index]->OpLen = HTONS (8);
- OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]->Data;
- OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL);
- OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);
- OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS);
- OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS);
+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
+ OptList[Index]->OpLen = HTONS (8);
+ OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *)OptList[Index]->Data;
+ OptEnt.Oro->OpCode[0] = HTONS (DHCP6_OPT_BOOT_FILE_URL);
+ OptEnt.Oro->OpCode[1] = HTONS (DHCP6_OPT_BOOT_FILE_PARAM);
+ OptEnt.Oro->OpCode[2] = HTONS (DHCP6_OPT_DNS_SERVERS);
+ OptEnt.Oro->OpCode[3] = HTONS (DHCP6_OPT_VENDOR_CLASS);
Index++;
- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append client network device interface option
//
- OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
- OptList[Index]->OpLen = HTONS ((UINT16)3);
- OptEnt.Undi = (PXEBC_DHCP6_OPTION_UNDI *) OptList[Index]->Data;
+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
+ OptList[Index]->OpLen = HTONS ((UINT16)3);
+ OptEnt.Undi = (PXEBC_DHCP6_OPTION_UNDI *)OptList[Index]->Data;
if (Private->Nii != NULL) {
- OptEnt.Undi->Type = Private->Nii->Type;
- OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
- OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
+ OptEnt.Undi->Type = Private->Nii->Type;
+ OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
+ OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
} else {
- OptEnt.Undi->Type = DEFAULT_UNDI_TYPE;
- OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
- OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
+ OptEnt.Undi->Type = DEFAULT_UNDI_TYPE;
+ OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
+ OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
}
Index++;
- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append client system architecture option
//
- OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
- OptList[Index]->OpLen = HTONS ((UINT16) sizeof (PXEBC_DHCP6_OPTION_ARCH));
- OptEnt.Arch = (PXEBC_DHCP6_OPTION_ARCH *) OptList[Index]->Data;
- Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
+ OptList[Index]->OpLen = HTONS ((UINT16)sizeof (PXEBC_DHCP6_OPTION_ARCH));
+ OptEnt.Arch = (PXEBC_DHCP6_OPTION_ARCH *)OptList[Index]->Data;
+ Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
Index++;
- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append vendor class option to store the PXE class identifier.
//
OptList[Index]->OpCode = HTONS (DHCP6_OPT_VENDOR_CLASS);
- OptList[Index]->OpLen = HTONS ((UINT16) sizeof (PXEBC_DHCP6_OPTION_VENDOR_CLASS));
- OptEnt.VendorClass = (PXEBC_DHCP6_OPTION_VENDOR_CLASS *) OptList[Index]->Data;
+ OptList[Index]->OpLen = HTONS ((UINT16)sizeof (PXEBC_DHCP6_OPTION_VENDOR_CLASS));
+ OptEnt.VendorClass = (PXEBC_DHCP6_OPTION_VENDOR_CLASS *)OptList[Index]->Data;
OptEnt.VendorClass->Vendor = HTONL (PXEBC_DHCP6_ENTERPRISE_NUM);
- OptEnt.VendorClass->ClassLen = HTONS ((UINT16) sizeof (PXEBC_CLASS_ID));
+ OptEnt.VendorClass->ClassLen = HTONS ((UINT16)sizeof (PXEBC_CLASS_ID));
CopyMem (
&OptEnt.VendorClass->ClassId,
DEFAULT_CLASS_ID_DATA,
@@ -169,7 +168,6 @@ PxeBcBuildDhcp6Options (
return Index;
}
-
/**
Cache the DHCPv6 packet.
@@ -182,8 +180,8 @@ PxeBcBuildDhcp6Options (
**/
EFI_STATUS
PxeBcCacheDhcp6Packet (
- IN EFI_DHCP6_PACKET *Dst,
- IN EFI_DHCP6_PACKET *Src
+ IN EFI_DHCP6_PACKET *Dst,
+ IN EFI_DHCP6_PACKET *Src
)
{
if (Dst->Size < Src->Length) {
@@ -211,22 +209,22 @@ PxeBcCacheDhcp6Packet (
**/
EFI_STATUS
PxeBcDns6 (
- IN PXEBC_PRIVATE_DATA *Private,
- IN CHAR16 *HostName,
- OUT EFI_IPv6_ADDRESS *IpAddress
- )
-{
- EFI_STATUS Status;
- EFI_DNS6_PROTOCOL *Dns6;
- EFI_DNS6_CONFIG_DATA Dns6ConfigData;
- EFI_DNS6_COMPLETION_TOKEN Token;
- EFI_HANDLE Dns6Handle;
- EFI_IPv6_ADDRESS *DnsServerList;
- BOOLEAN IsDone;
-
- Dns6 = NULL;
- Dns6Handle = NULL;
- DnsServerList = Private->DnsServer;
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN CHAR16 *HostName,
+ OUT EFI_IPv6_ADDRESS *IpAddress
+ )
+{
+ EFI_STATUS Status;
+ EFI_DNS6_PROTOCOL *Dns6;
+ EFI_DNS6_CONFIG_DATA Dns6ConfigData;
+ EFI_DNS6_COMPLETION_TOKEN Token;
+ EFI_HANDLE Dns6Handle;
+ EFI_IPv6_ADDRESS *DnsServerList;
+ BOOLEAN IsDone;
+
+ Dns6 = NULL;
+ Dns6Handle = NULL;
+ DnsServerList = Private->DnsServer;
ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN));
//
@@ -245,7 +243,7 @@ PxeBcDns6 (
Status = gBS->OpenProtocol (
Dns6Handle,
&gEfiDns6ProtocolGuid,
- (VOID **) &Dns6,
+ (VOID **)&Dns6,
Private->Image,
Private->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -308,10 +306,12 @@ PxeBcDns6 (
Status = EFI_DEVICE_ERROR;
goto Exit;
}
- if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
+
+ if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
Status = EFI_DEVICE_ERROR;
goto Exit;
}
+
//
// We just return the first IPv6 address from DNS protocol.
//
@@ -325,10 +325,12 @@ Exit:
if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event);
}
+
if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList);
}
+
FreePool (Token.RspData.H2AData);
}
@@ -375,26 +377,26 @@ Exit:
**/
EFI_STATUS
PxeBcExtractBootFileUrl (
- IN PXEBC_PRIVATE_DATA *Private,
- OUT UINT8 **FileName,
- IN OUT EFI_IPv6_ADDRESS *SrvAddr,
- IN CHAR8 *BootFile,
- IN UINT16 Length
- )
-{
- UINT16 PrefixLen;
- CHAR8 *BootFileNamePtr;
- CHAR8 *BootFileName;
- UINT16 BootFileNameLen;
- CHAR8 *TmpStr;
- CHAR8 TmpChar;
- CHAR8 *ServerAddressOption;
- CHAR8 *ServerAddress;
- CHAR8 *ModeStr;
- CHAR16 *HostName;
- BOOLEAN IpExpressedUrl;
- UINTN Len;
- EFI_STATUS Status;
+ IN PXEBC_PRIVATE_DATA *Private,
+ OUT UINT8 **FileName,
+ IN OUT EFI_IPv6_ADDRESS *SrvAddr,
+ IN CHAR8 *BootFile,
+ IN UINT16 Length
+ )
+{
+ UINT16 PrefixLen;
+ CHAR8 *BootFileNamePtr;
+ CHAR8 *BootFileName;
+ UINT16 BootFileNameLen;
+ CHAR8 *TmpStr;
+ CHAR8 TmpChar;
+ CHAR8 *ServerAddressOption;
+ CHAR8 *ServerAddress;
+ CHAR8 *ModeStr;
+ CHAR16 *HostName;
+ BOOLEAN IpExpressedUrl;
+ UINTN Len;
+ EFI_STATUS Status;
IpExpressedUrl = TRUE;
//
@@ -417,17 +419,18 @@ PxeBcExtractBootFileUrl (
// As an example where the BOOTFILE_NAME is the EFI loader and
// SERVER_ADDRESS is the ASCII encoding of an IPV6 address.
//
- PrefixLen = (UINT16) AsciiStrLen (PXEBC_DHCP6_BOOT_FILE_URL_PREFIX);
+ PrefixLen = (UINT16)AsciiStrLen (PXEBC_DHCP6_BOOT_FILE_URL_PREFIX);
- if (Length <= PrefixLen ||
- CompareMem (BootFile, PXEBC_DHCP6_BOOT_FILE_URL_PREFIX, PrefixLen) != 0) {
+ if ((Length <= PrefixLen) ||
+ (CompareMem (BootFile, PXEBC_DHCP6_BOOT_FILE_URL_PREFIX, PrefixLen) != 0))
+ {
return EFI_NOT_FOUND;
}
BootFile = BootFile + PrefixLen;
- Length = (UINT16) (Length - PrefixLen);
+ Length = (UINT16)(Length - PrefixLen);
- TmpStr = (CHAR8 *) AllocateZeroPool (Length + 1);
+ TmpStr = (CHAR8 *)AllocateZeroPool (Length + 1);
if (TmpStr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -440,7 +443,7 @@ PxeBcExtractBootFileUrl (
//
ServerAddressOption = TmpStr;
if (*ServerAddressOption == PXEBC_ADDR_START_DELIMITER) {
- ServerAddressOption ++;
+ ServerAddressOption++;
ServerAddress = ServerAddressOption;
while (*ServerAddress != '\0' && *ServerAddress != PXEBC_ADDR_END_DELIMITER) {
ServerAddress++;
@@ -461,10 +464,9 @@ PxeBcExtractBootFileUrl (
FreePool (TmpStr);
return Status;
}
-
} else {
IpExpressedUrl = FALSE;
- ServerAddress = ServerAddressOption;
+ ServerAddress = ServerAddressOption;
while (*ServerAddress != '\0' && *ServerAddress != PXEBC_TFTP_URL_SEPARATOR) {
ServerAddress++;
}
@@ -473,14 +475,16 @@ PxeBcExtractBootFileUrl (
FreePool (TmpStr);
return EFI_INVALID_PARAMETER;
}
+
*ServerAddress = '\0';
- Len = AsciiStrSize (ServerAddressOption);
+ Len = AsciiStrSize (ServerAddressOption);
HostName = AllocateZeroPool (Len * sizeof (CHAR16));
if (HostName == NULL) {
FreePool (TmpStr);
return EFI_OUT_OF_RESOURCES;
}
+
AsciiStrToUnicodeStrS (
ServerAddressOption,
HostName,
@@ -490,7 +494,7 @@ PxeBcExtractBootFileUrl (
//
// Perform DNS resolution.
//
- Status = PxeBcDns6 (Private,HostName, SrvAddr);
+ Status = PxeBcDns6 (Private, HostName, SrvAddr);
if (EFI_ERROR (Status)) {
FreePool (TmpStr);
return Status;
@@ -500,23 +504,24 @@ PxeBcExtractBootFileUrl (
//
// Get the part of BOOTFILE_NAME string.
//
- BootFileNamePtr = (CHAR8*)((UINTN)ServerAddress + 1);
+ BootFileNamePtr = (CHAR8 *)((UINTN)ServerAddress + 1);
if (IpExpressedUrl) {
if (*BootFileNamePtr != PXEBC_TFTP_URL_SEPARATOR) {
FreePool (TmpStr);
return EFI_INVALID_PARAMETER;
}
+
++BootFileNamePtr;
}
- BootFileNameLen = (UINT16)(Length - (UINT16) ((UINTN)BootFileNamePtr - (UINTN)TmpStr) + 1);
- if (BootFileNameLen != 0 || FileName != NULL) {
+ BootFileNameLen = (UINT16)(Length - (UINT16)((UINTN)BootFileNamePtr - (UINTN)TmpStr) + 1);
+ if ((BootFileNameLen != 0) || (FileName != NULL)) {
//
// Remove trailing mode=octet if present and ignore. All other modes are
// invalid for netboot6, so reject them.
//
ModeStr = AsciiStrStr (BootFileNamePtr, ";mode=octet");
- if (ModeStr != NULL && *(ModeStr + AsciiStrLen (";mode=octet")) == '\0') {
+ if ((ModeStr != NULL) && (*(ModeStr + AsciiStrLen (";mode=octet")) == '\0')) {
*ModeStr = '\0';
} else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) {
FreePool (TmpStr);
@@ -526,30 +531,32 @@ PxeBcExtractBootFileUrl (
//
// Extract boot file name from URL.
//
- BootFileName = (CHAR8 *) AllocateZeroPool (BootFileNameLen);
+ BootFileName = (CHAR8 *)AllocateZeroPool (BootFileNameLen);
if (BootFileName == NULL) {
FreePool (TmpStr);
return EFI_OUT_OF_RESOURCES;
}
- *FileName = (UINT8*) BootFileName;
+
+ *FileName = (UINT8 *)BootFileName;
//
// Decode percent-encoding in boot file name.
//
while (*BootFileNamePtr != '\0') {
if (*BootFileNamePtr == '%') {
- TmpChar = *(BootFileNamePtr+ 3);
+ TmpChar = *(BootFileNamePtr+ 3);
*(BootFileNamePtr+ 3) = '\0';
- *BootFileName = (UINT8) AsciiStrHexToUintn ((CHAR8*)(BootFileNamePtr + 1));
+ *BootFileName = (UINT8)AsciiStrHexToUintn ((CHAR8 *)(BootFileNamePtr + 1));
BootFileName++;
*(BootFileNamePtr+ 3) = TmpChar;
- BootFileNamePtr += 3;
+ BootFileNamePtr += 3;
} else {
*BootFileName = *BootFileNamePtr;
BootFileName++;
BootFileNamePtr++;
}
}
+
*BootFileName = '\0';
}
@@ -558,7 +565,6 @@ PxeBcExtractBootFileUrl (
return EFI_SUCCESS;
}
-
/**
Parse the Boot File Parameter option.
@@ -571,14 +577,14 @@ PxeBcExtractBootFileUrl (
**/
EFI_STATUS
PxeBcExtractBootFileParam (
- IN CHAR8 *BootFilePara,
- OUT UINT16 *BootFileSize
+ IN CHAR8 *BootFilePara,
+ OUT UINT16 *BootFileSize
)
{
- UINT16 Length;
- UINT8 Index;
- UINT8 Digit;
- UINT32 Size;
+ UINT16 Length;
+ UINT8 Index;
+ UINT8 Digit;
+ UINT32 Size;
CopyMem (&Length, BootFilePara, sizeof (UINT16));
Length = NTOHS (Length);
@@ -586,7 +592,7 @@ PxeBcExtractBootFileParam (
//
// The BootFile Size should be 1~5 byte ASCII strings
//
- if (Length < 1 || Length > 5) {
+ if ((Length < 1) || (Length > 5)) {
return EFI_NOT_FOUND;
}
@@ -608,11 +614,10 @@ PxeBcExtractBootFileParam (
return EFI_NOT_FOUND;
}
- *BootFileSize = (UINT16) Size;
+ *BootFileSize = (UINT16)Size;
return EFI_SUCCESS;
}
-
/**
Parse the cached DHCPv6 packet, including all the options.
@@ -627,15 +632,15 @@ PxeBcParseDhcp6Packet (
IN PXEBC_DHCP6_PACKET_CACHE *Cache6
)
{
- EFI_DHCP6_PACKET *Offer;
- EFI_DHCP6_PACKET_OPTION **Options;
- EFI_DHCP6_PACKET_OPTION *Option;
- PXEBC_OFFER_TYPE OfferType;
- BOOLEAN IsProxyOffer;
- BOOLEAN IsPxeOffer;
- UINT32 Offset;
- UINT32 Length;
- UINT32 EnterpriseNum;
+ EFI_DHCP6_PACKET *Offer;
+ EFI_DHCP6_PACKET_OPTION **Options;
+ EFI_DHCP6_PACKET_OPTION *Option;
+ PXEBC_OFFER_TYPE OfferType;
+ BOOLEAN IsProxyOffer;
+ BOOLEAN IsPxeOffer;
+ UINT32 Offset;
+ UINT32 Length;
+ UINT32 EnterpriseNum;
IsProxyOffer = TRUE;
IsPxeOffer = FALSE;
@@ -644,15 +649,14 @@ PxeBcParseDhcp6Packet (
ZeroMem (Cache6->OptList, sizeof (Cache6->OptList));
- Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option);
- Offset = 0;
- Length = GET_DHCP6_OPTION_SIZE (Offer);
+ Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option);
+ Offset = 0;
+ Length = GET_DHCP6_OPTION_SIZE (Offer);
//
// OpLen and OpCode here are both stored in network order, since they are from original packet.
//
while (Offset < Length) {
-
if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) {
Options[PXEBC_DHCP6_IDX_IA_NA] = Option;
} else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) {
@@ -669,7 +673,7 @@ PxeBcParseDhcp6Packet (
}
Offset += (NTOHS (Option->OpLen) + 4);
- Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option + Offset);
+ Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option + Offset);
}
//
@@ -683,7 +687,7 @@ PxeBcParseDhcp6Packet (
NTOHS (Option->OpLen),
DHCP6_OPT_STATUS_CODE
);
- if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) {
+ if (((Option != NULL) && (Option->Data[0] == 0)) || (Option == NULL)) {
IsProxyOffer = FALSE;
}
}
@@ -692,12 +696,13 @@ PxeBcParseDhcp6Packet (
// The offer with "PXEClient" is a pxe offer.
//
Option = Options[PXEBC_DHCP6_IDX_VENDOR_CLASS];
- EnterpriseNum = HTONL(PXEBC_DHCP6_ENTERPRISE_NUM);
+ EnterpriseNum = HTONL (PXEBC_DHCP6_ENTERPRISE_NUM);
- if (Option != NULL &&
- NTOHS(Option->OpLen) >= 13 &&
- CompareMem (Option->Data, &EnterpriseNum, sizeof (UINT32)) == 0 &&
- CompareMem (&Option->Data[6], DEFAULT_CLASS_ID_DATA, 9) == 0) {
+ if ((Option != NULL) &&
+ (NTOHS (Option->OpLen) >= 13) &&
+ (CompareMem (Option->Data, &EnterpriseNum, sizeof (UINT32)) == 0) &&
+ (CompareMem (&Option->Data[6], DEFAULT_CLASS_ID_DATA, 9) == 0))
+ {
IsPxeOffer = TRUE;
}
@@ -721,7 +726,6 @@ PxeBcParseDhcp6Packet (
return EFI_SUCCESS;
}
-
/**
Cache the DHCPv6 ack packet, and parse it on demand.
@@ -735,9 +739,9 @@ PxeBcParseDhcp6Packet (
**/
EFI_STATUS
PxeBcCopyDhcp6Ack (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_DHCP6_PACKET *Ack,
- IN BOOLEAN Verified
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_DHCP6_PACKET *Ack,
+ IN BOOLEAN Verified
)
{
EFI_PXE_BASE_CODE_MODE *Mode;
@@ -762,7 +766,6 @@ PxeBcCopyDhcp6Ack (
return EFI_SUCCESS;
}
-
/**
Cache the DHCPv6 proxy offer packet according to the received order.
@@ -775,12 +778,12 @@ PxeBcCopyDhcp6Ack (
**/
EFI_STATUS
PxeBcCopyDhcp6Proxy (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT32 OfferIndex
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT32 OfferIndex
)
{
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_DHCP6_PACKET *Offer;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_DHCP6_PACKET *Offer;
EFI_STATUS Status;
ASSERT (OfferIndex < Private->OfferNum);
@@ -793,9 +796,10 @@ PxeBcCopyDhcp6Proxy (
// Cache the proxy offer packet and parse it.
//
Status = PxeBcCacheDhcp6Packet (&Private->ProxyOffer.Dhcp6.Packet.Offer, Offer);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
+
PxeBcParseDhcp6Packet (&Private->ProxyOffer.Dhcp6);
//
@@ -820,33 +824,33 @@ PxeBcCopyDhcp6Proxy (
**/
UINT8 *
PxeBcDhcp6SeekOption (
- IN UINT8 *Buf,
- IN UINT32 SeekLen,
- IN UINT16 OptType
+ IN UINT8 *Buf,
+ IN UINT32 SeekLen,
+ IN UINT16 OptType
)
{
- UINT8 *Cursor;
- UINT8 *Option;
- UINT16 DataLen;
- UINT16 OpCode;
+ UINT8 *Cursor;
+ UINT8 *Option;
+ UINT16 DataLen;
+ UINT16 OpCode;
Option = NULL;
Cursor = Buf;
while (Cursor < Buf + SeekLen) {
- OpCode = ReadUnaligned16 ((UINT16 *) Cursor);
+ OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
if (OpCode == HTONS (OptType)) {
Option = Cursor;
break;
}
- DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2)));
+
+ DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
Cursor += (DataLen + 4);
}
return Option;
}
-
/**
Build and send out the request packet for the bootfile, and parse the reply.
@@ -861,34 +865,34 @@ PxeBcDhcp6SeekOption (
**/
EFI_STATUS
PxeBcRequestBootService (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT32 Index
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT32 Index
)
{
- EFI_PXE_BASE_CODE_UDP_PORT SrcPort;
- EFI_PXE_BASE_CODE_UDP_PORT DestPort;
- EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
- EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover;
- UINTN DiscoverLen;
- EFI_DHCP6_PACKET *Request;
- UINTN RequestLen;
- EFI_DHCP6_PACKET *Reply;
- UINT8 *RequestOpt;
- UINT8 *DiscoverOpt;
- UINTN ReadSize;
- UINT16 OpFlags;
- UINT16 OpCode;
- UINT16 OpLen;
- EFI_STATUS Status;
- EFI_DHCP6_PACKET *IndexOffer;
- UINT8 *Option;
-
- PxeBc = &Private->PxeBc;
- Request = Private->Dhcp6Request;
- IndexOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;
- SrcPort = PXEBC_BS_DISCOVER_PORT;
- DestPort = PXEBC_BS_DISCOVER_PORT;
- OpFlags = 0;
+ EFI_PXE_BASE_CODE_UDP_PORT SrcPort;
+ EFI_PXE_BASE_CODE_UDP_PORT DestPort;
+ EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
+ EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover;
+ UINTN DiscoverLen;
+ EFI_DHCP6_PACKET *Request;
+ UINTN RequestLen;
+ EFI_DHCP6_PACKET *Reply;
+ UINT8 *RequestOpt;
+ UINT8 *DiscoverOpt;
+ UINTN ReadSize;
+ UINT16 OpFlags;
+ UINT16 OpCode;
+ UINT16 OpLen;
+ EFI_STATUS Status;
+ EFI_DHCP6_PACKET *IndexOffer;
+ UINT8 *Option;
+
+ PxeBc = &Private->PxeBc;
+ Request = Private->Dhcp6Request;
+ IndexOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;
+ SrcPort = PXEBC_BS_DISCOVER_PORT;
+ DestPort = PXEBC_BS_DISCOVER_PORT;
+ OpFlags = 0;
if (Request == NULL) {
return EFI_DEVICE_ERROR;
@@ -925,19 +929,20 @@ PxeBcRequestBootService (
//
// Add Server ID Option.
//
- OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen);
+ OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)Option)->OpLen);
CopyMem (DiscoverOpt, Option, OpLen + 4);
DiscoverOpt += (OpLen + 4);
DiscoverLen += (OpLen + 4);
}
while (RequestLen < Request->Length) {
- OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode);
- OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpLen);
- if (OpCode != EFI_DHCP6_IA_TYPE_NA &&
- OpCode != EFI_DHCP6_IA_TYPE_TA &&
- OpCode != DHCP6_OPT_SERVER_ID
- ) {
+ OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpCode);
+ OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpLen);
+ if ((OpCode != EFI_DHCP6_IA_TYPE_NA) &&
+ (OpCode != EFI_DHCP6_IA_TYPE_TA) &&
+ (OpCode != DHCP6_OPT_SERVER_ID)
+ )
+ {
//
// Copy all the options except IA option and Server ID
//
@@ -945,6 +950,7 @@ PxeBcRequestBootService (
DiscoverOpt += (OpLen + 4);
DiscoverLen += (OpLen + 4);
}
+
RequestOpt += (OpLen + 4);
RequestLen += (OpLen + 4);
}
@@ -959,7 +965,7 @@ PxeBcRequestBootService (
);
if (Option != NULL) {
CalcElapsedTime (Private);
- WriteUnaligned16 ((UINT16*)(Option + 4), HTONS((UINT16) Private->ElapsedTime));
+ WriteUnaligned16 ((UINT16 *)(Option + 4), HTONS ((UINT16)Private->ElapsedTime));
}
Status = PxeBc->UdpWrite (
@@ -973,7 +979,7 @@ PxeBcRequestBootService (
NULL,
NULL,
&DiscoverLen,
- (VOID *) Discover
+ (VOID *)Discover
);
if (EFI_ERROR (Status)) {
@@ -984,8 +990,8 @@ PxeBcRequestBootService (
// Cache the right PXE reply packet here, set valid flag later.
// Especially for PXE discover packet, store it into mode data here.
//
- Reply = &Private->ProxyOffer.Dhcp6.Packet.Offer;
- ReadSize = (UINTN) Reply->Size;
+ Reply = &Private->ProxyOffer.Dhcp6.Packet.Offer;
+ ReadSize = (UINTN)Reply->Size;
//
// Start Udp6Read instance
@@ -1005,7 +1011,7 @@ PxeBcRequestBootService (
NULL,
NULL,
&ReadSize,
- (VOID *) &Reply->Dhcp6
+ (VOID *)&Reply->Dhcp6
);
//
// Stop Udp6Read instance
@@ -1019,7 +1025,7 @@ PxeBcRequestBootService (
//
// Update length
//
- Reply->Length = (UINT32) ReadSize;
+ Reply->Length = (UINT32)ReadSize;
return EFI_SUCCESS;
@@ -1031,7 +1037,6 @@ ON_ERROR:
return Status;
}
-
/**
Retry to request bootfile name by the BINL offer.
@@ -1054,8 +1059,10 @@ PxeBcRetryDhcp6Binl (
EFI_STATUS Status;
ASSERT (Index < PXEBC_OFFER_MAX_NUM);
- ASSERT (Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeDhcpBinl ||
- Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl);
+ ASSERT (
+ Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeDhcpBinl ||
+ Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl
+ );
Mode = Private->PxeBc.Mode;
Private->IsDoDiscover = FALSE;
@@ -1078,7 +1085,7 @@ PxeBcRetryDhcp6Binl (
Private,
&Private->BootFileName,
&Private->ServerIp.v6,
- (CHAR8 *) (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),
+ (CHAR8 *)(Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),
NTOHS (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->OpLen)
);
if (EFI_ERROR (Status)) {
@@ -1101,9 +1108,10 @@ PxeBcRetryDhcp6Binl (
return Status;
}
- if (Cache6->OfferType != PxeOfferTypeProxyPxe10 &&
- Cache6->OfferType != PxeOfferTypeProxyWfm11a &&
- Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) {
+ if ((Cache6->OfferType != PxeOfferTypeProxyPxe10) &&
+ (Cache6->OfferType != PxeOfferTypeProxyWfm11a) &&
+ (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL))
+ {
//
// This BINL ack doesn't have discovery option set or multicast option set
// or bootfile name specified.
@@ -1121,7 +1129,6 @@ PxeBcRetryDhcp6Binl (
return EFI_SUCCESS;
}
-
/**
Cache all the received DHCPv6 offers, and set OfferIndex and OfferCount.
@@ -1133,8 +1140,8 @@ PxeBcRetryDhcp6Binl (
**/
EFI_STATUS
PxeBcCacheDhcp6Offer (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_DHCP6_PACKET *RcvdOffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_DHCP6_PACKET *RcvdOffer
)
{
PXEBC_DHCP6_PACKET_CACHE *Cache6;
@@ -1179,8 +1186,9 @@ PxeBcCacheDhcp6Offer (
//
Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum;
Private->OfferCount[OfferType]++;
- } else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeProxyWfm11a) &&
- Private->OfferCount[OfferType] < 1) {
+ } else if (((OfferType == PxeOfferTypeProxyPxe10) || (OfferType == PxeOfferTypeProxyWfm11a)) &&
+ (Private->OfferCount[OfferType] < 1))
+ {
//
// Only cache the first PXE10/WFM11a offer, and discard the others.
//
@@ -1202,7 +1210,6 @@ PxeBcCacheDhcp6Offer (
return EFI_SUCCESS;
}
-
/**
Select an DHCPv6 offer, and record SelectIndex and SelectProxyType.
@@ -1211,12 +1218,12 @@ PxeBcCacheDhcp6Offer (
**/
VOID
PxeBcSelectDhcp6Offer (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
- UINT32 Index;
- UINT32 OfferIndex;
- PXEBC_OFFER_TYPE OfferType;
+ UINT32 Index;
+ UINT32 OfferIndex;
+ PXEBC_OFFER_TYPE OfferType;
Private->SelectIndex = 0;
@@ -1229,43 +1236,40 @@ PxeBcSelectDhcp6Offer (
// 1. DhcpPxe10 offer
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpPxe10][0] + 1;
-
} else if (Private->OfferCount[PxeOfferTypeDhcpWfm11a] > 0) {
//
// 2. DhcpWfm11a offer
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpWfm11a][0] + 1;
-
- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
- Private->OfferCount[PxeOfferTypeProxyPxe10] > 0) {
+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
+ (Private->OfferCount[PxeOfferTypeProxyPxe10] > 0))
+ {
//
// 3. DhcpOnly offer and ProxyPxe10 offer.
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
Private->SelectProxyType = PxeOfferTypeProxyPxe10;
-
- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
- Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0) {
+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
+ (Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0))
+ {
//
// 4. DhcpOnly offer and ProxyWfm11a offer.
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
Private->SelectProxyType = PxeOfferTypeProxyWfm11a;
-
} else if (Private->OfferCount[PxeOfferTypeDhcpBinl] > 0) {
//
// 5. DhcpBinl offer.
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpBinl][0] + 1;
-
- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
- Private->OfferCount[PxeOfferTypeProxyBinl] > 0) {
+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
+ (Private->OfferCount[PxeOfferTypeProxyBinl] > 0))
+ {
//
// 6. DhcpOnly offer and ProxyBinl offer.
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
Private->SelectProxyType = PxeOfferTypeProxyBinl;
-
} else {
//
// 7. DhcpOnly offer with bootfilename.
@@ -1283,7 +1287,6 @@ PxeBcSelectDhcp6Offer (
// Select offer by received order.
//
for (Index = 0; Index < Private->OfferNum; Index++) {
-
OfferType = Private->OfferBuffer[Index].Dhcp6.OfferType;
if (IS_PROXY_OFFER (OfferType)) {
@@ -1294,8 +1297,9 @@ PxeBcSelectDhcp6Offer (
}
if (!Private->IsProxyRecved &&
- OfferType == PxeOfferTypeDhcpOnly &&
- Private->OfferBuffer[Index].Dhcp6.OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) {
+ (OfferType == PxeOfferTypeDhcpOnly) &&
+ (Private->OfferBuffer[Index].Dhcp6.OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL))
+ {
//
// Skip if DhcpOnly offer without any other proxy offers or bootfilename.
//
@@ -1308,7 +1312,6 @@ PxeBcSelectDhcp6Offer (
}
}
-
/**
Handle the DHCPv6 offer packet.
@@ -1322,21 +1325,21 @@ PxeBcSelectDhcp6Offer (
**/
EFI_STATUS
PxeBcHandleDhcp6Offer (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
- PXEBC_DHCP6_PACKET_CACHE *Cache6;
- EFI_STATUS Status;
- PXEBC_OFFER_TYPE OfferType;
- UINT32 ProxyIndex;
- UINT32 SelectIndex;
- UINT32 Index;
+ PXEBC_DHCP6_PACKET_CACHE *Cache6;
+ EFI_STATUS Status;
+ PXEBC_OFFER_TYPE OfferType;
+ UINT32 ProxyIndex;
+ UINT32 SelectIndex;
+ UINT32 Index;
ASSERT (Private->SelectIndex > 0);
- SelectIndex = (UINT32) (Private->SelectIndex - 1);
+ SelectIndex = (UINT32)(Private->SelectIndex - 1);
ASSERT (SelectIndex < PXEBC_OFFER_MAX_NUM);
- Cache6 = &Private->OfferBuffer[SelectIndex].Dhcp6;
- Status = EFI_SUCCESS;
+ Cache6 = &Private->OfferBuffer[SelectIndex].Dhcp6;
+ Status = EFI_SUCCESS;
//
// First try to cache DNS server address if DHCP6 offer provides.
@@ -1346,6 +1349,7 @@ PxeBcHandleDhcp6Offer (
if (Private->DnsServer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS));
}
@@ -1357,7 +1361,6 @@ PxeBcHandleDhcp6Offer (
Status = EFI_NO_RESPONSE;
}
} else if (Cache6->OfferType == PxeOfferTypeDhcpOnly) {
-
if (Private->IsProxyRecved) {
//
// DhcpOnly offer is selected, so need try to request bootfilename.
@@ -1375,12 +1378,12 @@ PxeBcHandleDhcp6Offer (
// Try all the cached ProxyBinl offer one by one to request bootfilename.
//
for (Index = 0; Index < Private->OfferCount[Private->SelectProxyType]; Index++) {
-
ProxyIndex = Private->OfferIndex[Private->SelectProxyType][Index];
if (!EFI_ERROR (PxeBcRetryDhcp6Binl (Private, ProxyIndex))) {
break;
}
}
+
if (Index == Private->OfferCount[Private->SelectProxyType]) {
Status = EFI_NO_RESPONSE;
}
@@ -1397,7 +1400,6 @@ PxeBcHandleDhcp6Offer (
Status = EFI_NO_RESPONSE;
for (Index = 0; Index < Private->OfferNum; Index++) {
-
OfferType = Private->OfferBuffer[Index].Dhcp6.OfferType;
if (!IS_PROXY_OFFER (OfferType)) {
@@ -1423,7 +1425,7 @@ PxeBcHandleDhcp6Offer (
}
}
- if (!EFI_ERROR (Status) && Private->SelectProxyType != PxeOfferTypeProxyBinl) {
+ if (!EFI_ERROR (Status) && (Private->SelectProxyType != PxeOfferTypeProxyBinl)) {
//
// Success to try to request by a ProxyPxe10 or ProxyWfm11a offer, copy and parse it.
//
@@ -1441,14 +1443,13 @@ PxeBcHandleDhcp6Offer (
//
// All PXE boot information is ready by now.
//
- Status = PxeBcCopyDhcp6Ack (Private, &Private->DhcpAck.Dhcp6.Packet.Ack, TRUE);
+ Status = PxeBcCopyDhcp6Ack (Private, &Private->DhcpAck.Dhcp6.Packet.Ack, TRUE);
Private->PxeBc.Mode->DhcpDiscoverValid = TRUE;
}
return Status;
}
-
/**
Unregister the address by Ip6Config protocol.
@@ -1457,7 +1458,7 @@ PxeBcHandleDhcp6Offer (
**/
VOID
PxeBcUnregisterIp6Address (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
if (Private->Ip6Policy != PXEBC_IP6_POLICY_MAX) {
@@ -1485,18 +1486,18 @@ PxeBcUnregisterIp6Address (
**/
EFI_STATUS
PxeBcCheckRouteTable (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINTN TimeOutInSecond,
- OUT EFI_IPv6_ADDRESS *GatewayAddr
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINTN TimeOutInSecond,
+ OUT EFI_IPv6_ADDRESS *GatewayAddr
)
{
- EFI_STATUS Status;
- EFI_IP6_PROTOCOL *Ip6;
- EFI_IP6_MODE_DATA Ip6ModeData;
- UINTN Index;
- EFI_EVENT TimeOutEvt;
- UINTN RetryCount;
- BOOLEAN GatewayIsFound;
+ EFI_STATUS Status;
+ EFI_IP6_PROTOCOL *Ip6;
+ EFI_IP6_MODE_DATA Ip6ModeData;
+ UINTN Index;
+ EFI_EVENT TimeOutEvt;
+ UINTN RetryCount;
+ BOOLEAN GatewayIsFound;
ASSERT (GatewayAddr != NULL);
ASSERT (Private != NULL);
@@ -1527,23 +1528,28 @@ PxeBcCheckRouteTable (
if (Ip6ModeData.AddressList != NULL) {
FreePool (Ip6ModeData.AddressList);
}
+
if (Ip6ModeData.GroupTable != NULL) {
FreePool (Ip6ModeData.GroupTable);
}
+
if (Ip6ModeData.RouteTable != NULL) {
FreePool (Ip6ModeData.RouteTable);
}
+
if (Ip6ModeData.NeighborCache != NULL) {
FreePool (Ip6ModeData.NeighborCache);
}
+
if (Ip6ModeData.PrefixTable != NULL) {
FreePool (Ip6ModeData.PrefixTable);
}
+
if (Ip6ModeData.IcmpTypeList != NULL) {
FreePool (Ip6ModeData.IcmpTypeList);
}
- if (GatewayIsFound || RetryCount == TimeOutInSecond) {
+ if (GatewayIsFound || (RetryCount == TimeOutInSecond)) {
break;
}
@@ -1569,6 +1575,7 @@ PxeBcCheckRouteTable (
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
+
while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
Ip6->Poll (Ip6);
}
@@ -1600,29 +1607,29 @@ ON_EXIT:
**/
EFI_STATUS
PxeBcRegisterIp6Address (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_IPv6_ADDRESS *Address
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_IPv6_ADDRESS *Address
)
{
- EFI_IP6_PROTOCOL *Ip6;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
- EFI_IP6_CONFIG_POLICY Policy;
- EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr;
- EFI_IPv6_ADDRESS GatewayAddr;
- UINTN DataSize;
- EFI_EVENT MappedEvt;
- EFI_STATUS Status;
- BOOLEAN NoGateway;
- EFI_IPv6_ADDRESS *Ip6Addr;
- UINTN Index;
-
- Status = EFI_SUCCESS;
- MappedEvt = NULL;
- Ip6Addr = NULL;
- DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
- Ip6Cfg = Private->Ip6Cfg;
- Ip6 = Private->Ip6;
- NoGateway = FALSE;
+ EFI_IP6_PROTOCOL *Ip6;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
+ EFI_IP6_CONFIG_POLICY Policy;
+ EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr;
+ EFI_IPv6_ADDRESS GatewayAddr;
+ UINTN DataSize;
+ EFI_EVENT MappedEvt;
+ EFI_STATUS Status;
+ BOOLEAN NoGateway;
+ EFI_IPv6_ADDRESS *Ip6Addr;
+ UINTN Index;
+
+ Status = EFI_SUCCESS;
+ MappedEvt = NULL;
+ Ip6Addr = NULL;
+ DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
+ Ip6Cfg = Private->Ip6Cfg;
+ Ip6 = Private->Ip6;
+ NoGateway = FALSE;
ZeroMem (&CfgAddr, sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS));
CopyMem (&CfgAddr.Address, Address, sizeof (EFI_IPv6_ADDRESS));
@@ -1648,7 +1655,7 @@ PxeBcRegisterIp6Address (
Status = Ip6Cfg->SetData (
Ip6Cfg,
Ip6ConfigDataTypePolicy,
- sizeof(EFI_IP6_CONFIG_POLICY),
+ sizeof (EFI_IP6_CONFIG_POLICY),
&Policy
);
if (EFI_ERROR (Status)) {
@@ -1674,22 +1681,22 @@ PxeBcRegisterIp6Address (
}
Private->IsAddressOk = FALSE;
- Status = Ip6Cfg->RegisterDataNotify (
- Ip6Cfg,
- Ip6ConfigDataTypeManualAddress,
- MappedEvt
- );
- if (EFI_ERROR(Status)) {
+ Status = Ip6Cfg->RegisterDataNotify (
+ Ip6Cfg,
+ Ip6ConfigDataTypeManualAddress,
+ MappedEvt
+ );
+ if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
Status = Ip6Cfg->SetData (
Ip6Cfg,
Ip6ConfigDataTypeManualAddress,
- sizeof(EFI_IP6_CONFIG_MANUAL_ADDRESS),
+ sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS),
&CfgAddr
);
- if (EFI_ERROR(Status) && Status != EFI_NOT_READY) {
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
goto ON_EXIT;
} else if (Status == EFI_NOT_READY) {
//
@@ -1698,17 +1705,18 @@ PxeBcRegisterIp6Address (
while (!Private->IsAddressOk) {
Ip6->Poll (Ip6);
}
+
//
// Check whether the IP6 address setting is successed.
//
DataSize = 0;
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeManualAddress,
- &DataSize,
- NULL
- );
- if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) {
+ Status = Ip6Cfg->GetData (
+ Ip6Cfg,
+ Ip6ConfigDataTypeManualAddress,
+ &DataSize,
+ NULL
+ );
+ if ((Status != EFI_BUFFER_TOO_SMALL) || (DataSize == 0)) {
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
@@ -1717,11 +1725,12 @@ PxeBcRegisterIp6Address (
if (Ip6Addr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
Status = Ip6Cfg->GetData (
Ip6Cfg,
Ip6ConfigDataTypeManualAddress,
&DataSize,
- (VOID*) Ip6Addr
+ (VOID *)Ip6Addr
);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
@@ -1733,6 +1742,7 @@ PxeBcRegisterIp6Address (
break;
}
}
+
if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) {
Status = EFI_ABORTED;
goto ON_EXIT;
@@ -1763,9 +1773,11 @@ ON_EXIT:
);
gBS->CloseEvent (MappedEvt);
}
+
if (Ip6Addr != NULL) {
FreePool (Ip6Addr);
}
+
return Status;
}
@@ -1780,16 +1792,16 @@ ON_EXIT:
**/
EFI_STATUS
PxeBcSetIp6Policy (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
- EFI_IP6_CONFIG_POLICY Policy;
- EFI_STATUS Status;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
- UINTN DataSize;
+ EFI_IP6_CONFIG_POLICY Policy;
+ EFI_STATUS Status;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
+ UINTN DataSize;
- Ip6Cfg = Private->Ip6Cfg;
- DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
+ Ip6Cfg = Private->Ip6Cfg;
+ DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
//
// Get and store the current policy of IP6 driver.
@@ -1809,7 +1821,7 @@ PxeBcSetIp6Policy (
Status = Ip6Cfg->SetData (
Ip6Cfg,
Ip6ConfigDataTypePolicy,
- sizeof(EFI_IP6_CONFIG_POLICY),
+ sizeof (EFI_IP6_CONFIG_POLICY),
&Policy
);
if (EFI_ERROR (Status)) {
@@ -1834,11 +1846,11 @@ PxeBcSetIp6Policy (
**/
EFI_STATUS
PxeBcSetIp6Address (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- EFI_DHCP6_PROTOCOL *Dhcp6;
+ EFI_STATUS Status;
+ EFI_DHCP6_PROTOCOL *Dhcp6;
Dhcp6 = Private->Dhcp6;
@@ -1885,47 +1897,48 @@ PxeBcSetIp6Address (
EFI_STATUS
EFIAPI
PxeBcDhcp6CallBack (
- IN EFI_DHCP6_PROTOCOL *This,
- IN VOID *Context,
- IN EFI_DHCP6_STATE CurrentState,
- IN EFI_DHCP6_EVENT Dhcp6Event,
- IN EFI_DHCP6_PACKET *Packet,
- OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL
+ IN EFI_DHCP6_PROTOCOL *This,
+ IN VOID *Context,
+ IN EFI_DHCP6_STATE CurrentState,
+ IN EFI_DHCP6_EVENT Dhcp6Event,
+ IN EFI_DHCP6_PACKET *Packet,
+ OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
- EFI_DHCP6_PACKET *SelectAd;
- EFI_STATUS Status;
- BOOLEAN Received;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
+ EFI_DHCP6_PACKET *SelectAd;
+ EFI_STATUS Status;
+ BOOLEAN Received;
if ((Dhcp6Event != Dhcp6RcvdAdvertise) &&
(Dhcp6Event != Dhcp6SelectAdvertise) &&
(Dhcp6Event != Dhcp6SendSolicit) &&
(Dhcp6Event != Dhcp6SendRequest) &&
- (Dhcp6Event != Dhcp6RcvdReply)) {
+ (Dhcp6Event != Dhcp6RcvdReply))
+ {
return EFI_SUCCESS;
}
ASSERT (Packet != NULL);
- Private = (PXEBC_PRIVATE_DATA *) Context;
- Mode = Private->PxeBc.Mode;
- Callback = Private->PxeBcCallback;
+ Private = (PXEBC_PRIVATE_DATA *)Context;
+ Mode = Private->PxeBc.Mode;
+ Callback = Private->PxeBcCallback;
//
// Callback to user when any traffic ocurred if has.
//
- if (Dhcp6Event != Dhcp6SelectAdvertise && Callback != NULL) {
- Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
- Status = Callback->Callback (
- Callback,
- Private->Function,
- Received,
- Packet->Length,
- (EFI_PXE_BASE_CODE_PACKET *) &Packet->Dhcp6
- );
+ if ((Dhcp6Event != Dhcp6SelectAdvertise) && (Callback != NULL)) {
+ Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
+ Status = Callback->Callback (
+ Callback,
+ Private->Function,
+ Received,
+ Packet->Length,
+ (EFI_PXE_BASE_CODE_PACKET *)&Packet->Dhcp6
+ );
if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
return EFI_ABORTED;
}
@@ -1934,108 +1947,114 @@ PxeBcDhcp6CallBack (
Status = EFI_SUCCESS;
switch (Dhcp6Event) {
+ case Dhcp6SendSolicit:
+ if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
+ //
+ // If the to be sent packet exceeds the maximum length, abort the DHCP process.
+ //
+ Status = EFI_ABORTED;
+ break;
+ }
- case Dhcp6SendSolicit:
- if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
//
- // If the to be sent packet exceeds the maximum length, abort the DHCP process.
+ // Record the first Solicate msg time
//
- Status = EFI_ABORTED;
- break;
- }
-
- //
- // Record the first Solicate msg time
- //
- if (Private->SolicitTimes == 0) {
- CalcElapsedTime (Private);
- Private->SolicitTimes++;
- }
- //
- // Cache the dhcp discover packet to mode data directly.
- //
- CopyMem (&Mode->DhcpDiscover.Dhcpv4, &Packet->Dhcp6, Packet->Length);
- break;
+ if (Private->SolicitTimes == 0) {
+ CalcElapsedTime (Private);
+ Private->SolicitTimes++;
+ }
- case Dhcp6RcvdAdvertise:
- Status = EFI_NOT_READY;
- if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
//
- // Ignore the incoming packets which exceed the maximum length.
+ // Cache the dhcp discover packet to mode data directly.
//
+ CopyMem (&Mode->DhcpDiscover.Dhcpv4, &Packet->Dhcp6, Packet->Length);
break;
- }
- if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) {
+
+ case Dhcp6RcvdAdvertise:
+ Status = EFI_NOT_READY;
+ if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
+ //
+ // Ignore the incoming packets which exceed the maximum length.
+ //
+ break;
+ }
+
+ if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) {
+ //
+ // Cache the dhcp offers to OfferBuffer[] for select later, and record
+ // the OfferIndex and OfferCount.
+ //
+ PxeBcCacheDhcp6Offer (Private, Packet);
+ }
+
+ break;
+
+ case Dhcp6SendRequest:
+ if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
+ //
+ // If the to be sent packet exceeds the maximum length, abort the DHCP process.
+ //
+ Status = EFI_ABORTED;
+ break;
+ }
+
//
- // Cache the dhcp offers to OfferBuffer[] for select later, and record
- // the OfferIndex and OfferCount.
+ // Store the request packet as seed packet for discover.
//
- PxeBcCacheDhcp6Offer (Private, Packet);
- }
- break;
+ if (Private->Dhcp6Request != NULL) {
+ FreePool (Private->Dhcp6Request);
+ }
+
+ Private->Dhcp6Request = AllocateZeroPool (Packet->Size);
+ if (Private->Dhcp6Request != NULL) {
+ CopyMem (Private->Dhcp6Request, Packet, Packet->Size);
+ }
- case Dhcp6SendRequest:
- if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
+ break;
+
+ case Dhcp6SelectAdvertise:
//
- // If the to be sent packet exceeds the maximum length, abort the DHCP process.
+ // Select offer by the default policy or by order, and record the SelectIndex
+ // and SelectProxyType.
//
- Status = EFI_ABORTED;
- break;
- }
+ PxeBcSelectDhcp6Offer (Private);
- //
- // Store the request packet as seed packet for discover.
- //
- if (Private->Dhcp6Request != NULL) {
- FreePool (Private->Dhcp6Request);
- }
- Private->Dhcp6Request = AllocateZeroPool (Packet->Size);
- if (Private->Dhcp6Request != NULL) {
- CopyMem (Private->Dhcp6Request, Packet, Packet->Size);
- }
- break;
+ if (Private->SelectIndex == 0) {
+ Status = EFI_ABORTED;
+ } else {
+ ASSERT (NewPacket != NULL);
+ SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
+ *NewPacket = AllocateZeroPool (SelectAd->Size);
+ ASSERT (*NewPacket != NULL);
+ if (*NewPacket == NULL) {
+ return EFI_ABORTED;
+ }
- case Dhcp6SelectAdvertise:
- //
- // Select offer by the default policy or by order, and record the SelectIndex
- // and SelectProxyType.
- //
- PxeBcSelectDhcp6Offer (Private);
+ CopyMem (*NewPacket, SelectAd, SelectAd->Size);
+ }
- if (Private->SelectIndex == 0) {
- Status = EFI_ABORTED;
- } else {
- ASSERT (NewPacket != NULL);
- SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
- *NewPacket = AllocateZeroPool (SelectAd->Size);
- ASSERT (*NewPacket != NULL);
- if (*NewPacket == NULL) {
- return EFI_ABORTED;
+ break;
+
+ case Dhcp6RcvdReply:
+ //
+ // Cache the dhcp ack to Private->Dhcp6Ack, but it's not the final ack in mode data
+ // without verification.
+ //
+ ASSERT (Private->SelectIndex != 0);
+ Status = PxeBcCopyDhcp6Ack (Private, Packet, FALSE);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ABORTED;
}
- CopyMem (*NewPacket, SelectAd, SelectAd->Size);
- }
- break;
- case Dhcp6RcvdReply:
- //
- // Cache the dhcp ack to Private->Dhcp6Ack, but it's not the final ack in mode data
- // without verification.
- //
- ASSERT (Private->SelectIndex != 0);
- Status = PxeBcCopyDhcp6Ack (Private, Packet, FALSE);
- if (EFI_ERROR (Status)) {
- Status = EFI_ABORTED;
- }
- break;
+ break;
- default:
- ASSERT (0);
+ default:
+ ASSERT (0);
}
return Status;
}
-
/**
Build and send out the request packet for the bootfile, and parse the reply.
@@ -2053,37 +2072,37 @@ PxeBcDhcp6CallBack (
**/
EFI_STATUS
PxeBcDhcp6Discover (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT16 Type,
- IN UINT16 *Layer,
- IN BOOLEAN UseBis,
- IN EFI_IP_ADDRESS *DestIp
- )
-{
- EFI_PXE_BASE_CODE_UDP_PORT SrcPort;
- EFI_PXE_BASE_CODE_UDP_PORT DestPort;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
- EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover;
- UINTN DiscoverLen;
- EFI_DHCP6_PACKET *Request;
- UINTN RequestLen;
- EFI_DHCP6_PACKET *Reply;
- UINT8 *RequestOpt;
- UINT8 *DiscoverOpt;
- UINTN ReadSize;
- UINT16 OpCode;
- UINT16 OpLen;
- UINT32 Xid;
- EFI_STATUS Status;
-
- PxeBc = &Private->PxeBc;
- Mode = PxeBc->Mode;
- Request = Private->Dhcp6Request;
- SrcPort = PXEBC_BS_DISCOVER_PORT;
- DestPort = PXEBC_BS_DISCOVER_PORT;
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT16 Type,
+ IN UINT16 *Layer,
+ IN BOOLEAN UseBis,
+ IN EFI_IP_ADDRESS *DestIp
+ )
+{
+ EFI_PXE_BASE_CODE_UDP_PORT SrcPort;
+ EFI_PXE_BASE_CODE_UDP_PORT DestPort;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
+ EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover;
+ UINTN DiscoverLen;
+ EFI_DHCP6_PACKET *Request;
+ UINTN RequestLen;
+ EFI_DHCP6_PACKET *Reply;
+ UINT8 *RequestOpt;
+ UINT8 *DiscoverOpt;
+ UINTN ReadSize;
+ UINT16 OpCode;
+ UINT16 OpLen;
+ UINT32 Xid;
+ EFI_STATUS Status;
+
+ PxeBc = &Private->PxeBc;
+ Mode = PxeBc->Mode;
+ Request = Private->Dhcp6Request;
+ SrcPort = PXEBC_BS_DISCOVER_PORT;
+ DestPort = PXEBC_BS_DISCOVER_PORT;
- if (!UseBis && Layer != NULL) {
+ if (!UseBis && (Layer != NULL)) {
*Layer &= EFI_PXE_BASE_CODE_BOOT_LAYER_MASK;
}
@@ -2108,10 +2127,11 @@ PxeBcDhcp6Discover (
RequestLen = DiscoverLen;
while (RequestLen < Request->Length) {
- OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode);
- OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpLen);
- if (OpCode != EFI_DHCP6_IA_TYPE_NA &&
- OpCode != EFI_DHCP6_IA_TYPE_TA) {
+ OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpCode);
+ OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpLen);
+ if ((OpCode != EFI_DHCP6_IA_TYPE_NA) &&
+ (OpCode != EFI_DHCP6_IA_TYPE_TA))
+ {
//
// Copy all the options except IA option.
//
@@ -2119,6 +2139,7 @@ PxeBcDhcp6Discover (
DiscoverOpt += (OpLen + 4);
DiscoverLen += (OpLen + 4);
}
+
RequestOpt += (OpLen + 4);
RequestLen += (OpLen + 4);
}
@@ -2134,7 +2155,7 @@ PxeBcDhcp6Discover (
NULL,
NULL,
&DiscoverLen,
- (VOID *) Discover
+ (VOID *)Discover
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
@@ -2150,7 +2171,8 @@ PxeBcDhcp6Discover (
} else {
Reply = &Private->ProxyOffer.Dhcp6.Packet.Offer;
}
- ReadSize = (UINTN) Reply->Size;
+
+ ReadSize = (UINTN)Reply->Size;
//
// Start Udp6Read instance
@@ -2170,7 +2192,7 @@ PxeBcDhcp6Discover (
NULL,
NULL,
&ReadSize,
- (VOID *) &Reply->Dhcp6
+ (VOID *)&Reply->Dhcp6
);
//
// Stop Udp6Read instance
@@ -2190,7 +2212,6 @@ ON_ERROR:
return Status;
}
-
/**
Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
@@ -2203,35 +2224,35 @@ ON_ERROR:
**/
EFI_STATUS
PxeBcDhcp6Sarr (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_DHCP6_PROTOCOL *Dhcp6
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_DHCP6_PROTOCOL *Dhcp6
)
{
- EFI_PXE_BASE_CODE_MODE *PxeMode;
- EFI_DHCP6_CONFIG_DATA Config;
- EFI_DHCP6_MODE_DATA Mode;
- EFI_DHCP6_RETRANSMISSION *Retransmit;
- EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_OPTION_MAX_NUM];
- UINT8 Buffer[PXEBC_DHCP6_OPTION_MAX_SIZE];
- UINT32 OptCount;
- EFI_STATUS Status;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
- EFI_STATUS TimerStatus;
- EFI_EVENT Timer;
- UINT64 GetMappingTimeOut;
- UINTN DataSize;
- EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
-
- Status = EFI_SUCCESS;
- PxeMode = Private->PxeBc.Mode;
- Ip6Cfg = Private->Ip6Cfg;
- Timer = NULL;
+ EFI_PXE_BASE_CODE_MODE *PxeMode;
+ EFI_DHCP6_CONFIG_DATA Config;
+ EFI_DHCP6_MODE_DATA Mode;
+ EFI_DHCP6_RETRANSMISSION *Retransmit;
+ EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_OPTION_MAX_NUM];
+ UINT8 Buffer[PXEBC_DHCP6_OPTION_MAX_SIZE];
+ UINT32 OptCount;
+ EFI_STATUS Status;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
+ EFI_STATUS TimerStatus;
+ EFI_EVENT Timer;
+ UINT64 GetMappingTimeOut;
+ UINTN DataSize;
+ EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
+
+ Status = EFI_SUCCESS;
+ PxeMode = Private->PxeBc.Mode;
+ Ip6Cfg = Private->Ip6Cfg;
+ Timer = NULL;
//
// Build option list for the request packet.
//
- OptCount = PxeBcBuildDhcp6Options (Private, OptList, Buffer);
- ASSERT (OptCount> 0);
+ OptCount = PxeBcBuildDhcp6Options (Private, OptList, Buffer);
+ ASSERT (OptCount > 0);
Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
if (Retransmit == NULL) {
@@ -2274,7 +2295,6 @@ PxeBcDhcp6Sarr (
ZeroMem (Private->OfferCount, sizeof (Private->OfferCount));
ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex));
-
//
// Start DHCPv6 S.A.R.R. process to acquire IPv6 address.
//
@@ -2290,12 +2310,12 @@ PxeBcDhcp6Sarr (
// Get Duplicate Address Detection Transmits count.
//
DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS);
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeDupAddrDetectTransmits,
- &DataSize,
- &DadXmits
- );
+ Status = Ip6Cfg->GetData (
+ Ip6Cfg,
+ Ip6ConfigDataTypeDupAddrDetectTransmits,
+ &DataSize,
+ &DadXmits
+ );
if (EFI_ERROR (Status)) {
Dhcp6->Configure (Dhcp6, NULL);
return Status;
@@ -2308,7 +2328,7 @@ PxeBcDhcp6Sarr (
}
GetMappingTimeOut = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + PXEBC_DAD_ADDITIONAL_DELAY;
- Status = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut);
+ Status = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut);
if (EFI_ERROR (Status)) {
gBS->CloseEvent (Timer);
Dhcp6->Configure (Dhcp6, NULL);
@@ -2316,7 +2336,6 @@ PxeBcDhcp6Sarr (
}
do {
-
TimerStatus = gBS->CheckEvent (Timer);
if (!EFI_ERROR (TimerStatus)) {
Status = Dhcp6->Start (Dhcp6);
@@ -2325,10 +2344,12 @@ PxeBcDhcp6Sarr (
gBS->CloseEvent (Timer);
}
+
if (EFI_ERROR (Status)) {
if (Status == EFI_ICMP_ERROR) {
PxeMode->IcmpErrorReceived = TRUE;
}
+
Dhcp6->Configure (Dhcp6, NULL);
return Status;
}
@@ -2354,9 +2375,11 @@ PxeBcDhcp6Sarr (
if (Mode.ClientId != NULL) {
FreePool (Mode.ClientId);
}
+
if (Mode.Ia != NULL) {
FreePool (Mode.Ia);
}
+
//
// Check the selected offer whether BINL retry is needed.
//
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h
@@ -10,25 +10,24 @@
#ifndef __EFI_PXEBC_DHCP6_H__
#define __EFI_PXEBC_DHCP6_H__
-#define PXEBC_DHCP6_OPTION_MAX_NUM 16
-#define PXEBC_DHCP6_OPTION_MAX_SIZE 312
-#define PXEBC_DHCP6_PACKET_MAX_SIZE (sizeof (EFI_PXE_BASE_CODE_PACKET))
-#define PXEBC_IP6_POLICY_MAX 0xff
-#define PXEBC_IP6_ROUTE_TABLE_TIMEOUT 10
-
-#define PXEBC_DHCP6_S_PORT 547
-#define PXEBC_DHCP6_C_PORT 546
-
-#define PXEBC_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's
-#define PXEBC_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes.
-
-
-#define PXEBC_DHCP6_IDX_IA_NA 0
-#define PXEBC_DHCP6_IDX_BOOT_FILE_URL 1
-#define PXEBC_DHCP6_IDX_BOOT_FILE_PARAM 2
-#define PXEBC_DHCP6_IDX_VENDOR_CLASS 3
-#define PXEBC_DHCP6_IDX_DNS_SERVER 4
-#define PXEBC_DHCP6_IDX_MAX 5
+#define PXEBC_DHCP6_OPTION_MAX_NUM 16
+#define PXEBC_DHCP6_OPTION_MAX_SIZE 312
+#define PXEBC_DHCP6_PACKET_MAX_SIZE (sizeof (EFI_PXE_BASE_CODE_PACKET))
+#define PXEBC_IP6_POLICY_MAX 0xff
+#define PXEBC_IP6_ROUTE_TABLE_TIMEOUT 10
+
+#define PXEBC_DHCP6_S_PORT 547
+#define PXEBC_DHCP6_C_PORT 546
+
+#define PXEBC_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's
+#define PXEBC_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes.
+
+#define PXEBC_DHCP6_IDX_IA_NA 0
+#define PXEBC_DHCP6_IDX_BOOT_FILE_URL 1
+#define PXEBC_DHCP6_IDX_BOOT_FILE_PARAM 2
+#define PXEBC_DHCP6_IDX_VENDOR_CLASS 3
+#define PXEBC_DHCP6_IDX_DNS_SERVER 4
+#define PXEBC_DHCP6_IDX_MAX 5
#define PXEBC_DHCP6_BOOT_FILE_URL_PREFIX "tftp://"
#define PXEBC_TFTP_URL_SEPARATOR '/'
@@ -47,71 +46,67 @@
(Type) == PxeOfferTypeProxyPxe10 || \
(Type) == PxeOfferTypeProxyWfm11a)
-
#pragma pack(1)
typedef struct {
- UINT16 OpCode[256];
+ UINT16 OpCode[256];
} PXEBC_DHCP6_OPTION_ORO;
typedef struct {
- UINT8 Type;
- UINT8 MajorVer;
- UINT8 MinorVer;
+ UINT8 Type;
+ UINT8 MajorVer;
+ UINT8 MinorVer;
} PXEBC_DHCP6_OPTION_UNDI;
typedef struct {
- UINT16 Type;
+ UINT16 Type;
} PXEBC_DHCP6_OPTION_ARCH;
typedef struct {
- UINT8 ClassIdentifier[10];
- UINT8 ArchitecturePrefix[5];
- UINT8 ArchitectureType[5];
- UINT8 Lit3[1];
- UINT8 InterfaceName[4];
- UINT8 Lit4[1];
- UINT8 UndiMajor[3];
- UINT8 UndiMinor[3];
+ UINT8 ClassIdentifier[10];
+ UINT8 ArchitecturePrefix[5];
+ UINT8 ArchitectureType[5];
+ UINT8 Lit3[1];
+ UINT8 InterfaceName[4];
+ UINT8 Lit4[1];
+ UINT8 UndiMajor[3];
+ UINT8 UndiMinor[3];
} PXEBC_CLASS_ID;
typedef struct {
- UINT32 Vendor;
- UINT16 ClassLen;
- PXEBC_CLASS_ID ClassId;
+ UINT32 Vendor;
+ UINT16 ClassLen;
+ PXEBC_CLASS_ID ClassId;
} PXEBC_DHCP6_OPTION_VENDOR_CLASS;
#pragma pack()
typedef union {
- PXEBC_DHCP6_OPTION_ORO *Oro;
- PXEBC_DHCP6_OPTION_UNDI *Undi;
- PXEBC_DHCP6_OPTION_ARCH *Arch;
- PXEBC_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
+ PXEBC_DHCP6_OPTION_ORO *Oro;
+ PXEBC_DHCP6_OPTION_UNDI *Undi;
+ PXEBC_DHCP6_OPTION_ARCH *Arch;
+ PXEBC_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
} PXEBC_DHCP6_OPTION_ENTRY;
typedef struct {
- LIST_ENTRY Link;
- EFI_DHCP6_PACKET_OPTION *Option;
- UINT8 Precedence;
+ LIST_ENTRY Link;
+ EFI_DHCP6_PACKET_OPTION *Option;
+ UINT8 Precedence;
} PXEBC_DHCP6_OPTION_NODE;
#define PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + PXEBC_DHCP6_PACKET_MAX_SIZE)
typedef union {
- EFI_DHCP6_PACKET Offer;
- EFI_DHCP6_PACKET Ack;
- UINT8 Buffer[PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE];
+ EFI_DHCP6_PACKET Offer;
+ EFI_DHCP6_PACKET Ack;
+ UINT8 Buffer[PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE];
} PXEBC_DHCP6_PACKET;
typedef struct {
- PXEBC_DHCP6_PACKET Packet;
- PXEBC_OFFER_TYPE OfferType;
- EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_IDX_MAX];
+ PXEBC_DHCP6_PACKET Packet;
+ PXEBC_OFFER_TYPE OfferType;
+ EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_IDX_MAX];
} PXEBC_DHCP6_PACKET_CACHE;
-
-
-
/**
Parse the Boot File URL option.
@@ -128,14 +123,13 @@ typedef struct {
**/
EFI_STATUS
PxeBcExtractBootFileUrl (
- IN PXEBC_PRIVATE_DATA *Private,
- OUT UINT8 **FileName,
- IN OUT EFI_IPv6_ADDRESS *SrvAddr,
- IN CHAR8 *BootFile,
- IN UINT16 Length
+ IN PXEBC_PRIVATE_DATA *Private,
+ OUT UINT8 **FileName,
+ IN OUT EFI_IPv6_ADDRESS *SrvAddr,
+ IN CHAR8 *BootFile,
+ IN UINT16 Length
);
-
/**
Parse the Boot File Parameter option.
@@ -148,11 +142,10 @@ PxeBcExtractBootFileUrl (
**/
EFI_STATUS
PxeBcExtractBootFileParam (
- IN CHAR8 *BootFilePara,
- OUT UINT16 *BootFileSize
+ IN CHAR8 *BootFilePara,
+ OUT UINT16 *BootFileSize
);
-
/**
Parse the cached DHCPv6 packet, including all the options.
@@ -167,7 +160,6 @@ PxeBcParseDhcp6Packet (
IN PXEBC_DHCP6_PACKET_CACHE *Cache6
);
-
/**
Register the ready address by Ip6Config protocol.
@@ -180,11 +172,10 @@ PxeBcParseDhcp6Packet (
**/
EFI_STATUS
PxeBcRegisterIp6Address (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_IPv6_ADDRESS *Address
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_IPv6_ADDRESS *Address
);
-
/**
Unregister the address by Ip6Config protocol.
@@ -193,10 +184,9 @@ PxeBcRegisterIp6Address (
**/
VOID
PxeBcUnregisterIp6Address (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
);
-
/**
Build and send out the request packet for the bootfile, and parse the reply.
@@ -214,11 +204,11 @@ PxeBcUnregisterIp6Address (
**/
EFI_STATUS
PxeBcDhcp6Discover (
- IN PXEBC_PRIVATE_DATA *Private,
- IN UINT16 Type,
- IN UINT16 *Layer,
- IN BOOLEAN UseBis,
- IN EFI_IP_ADDRESS *DestIp
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN UINT16 Type,
+ IN UINT16 *Layer,
+ IN BOOLEAN UseBis,
+ IN EFI_IP_ADDRESS *DestIp
);
/**
@@ -232,7 +222,7 @@ PxeBcDhcp6Discover (
**/
EFI_STATUS
PxeBcSetIp6Policy (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
);
/**
@@ -246,7 +236,7 @@ PxeBcSetIp6Policy (
**/
EFI_STATUS
PxeBcSetIp6Address (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
);
/**
@@ -261,9 +251,8 @@ PxeBcSetIp6Address (
**/
EFI_STATUS
PxeBcDhcp6Sarr (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_DHCP6_PROTOCOL *Dhcp6
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_DHCP6_PROTOCOL *Dhcp6
);
#endif
-
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
@@ -10,8 +10,7 @@
#include "PxeBcImpl.h"
-
-EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = {
PxeBcIp4DriverBindingSupported,
PxeBcIp4DriverBindingStart,
PxeBcIp4DriverBindingStop,
@@ -20,7 +19,7 @@ EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4Dri
NULL
};
-EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = {
PxeBcIp6DriverBindingSupported,
PxeBcIp6DriverBindingStart,
PxeBcIp6DriverBindingStop,
@@ -39,10 +38,10 @@ EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6Dri
**/
EFI_HANDLE
PxeBcGetNicByIp4Children (
- IN EFI_HANDLE ControllerHandle
+ IN EFI_HANDLE ControllerHandle
)
{
- EFI_HANDLE NicHandle;
+ EFI_HANDLE NicHandle;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid);
if (NicHandle == NULL) {
@@ -64,7 +63,6 @@ PxeBcGetNicByIp4Children (
return NicHandle;
}
-
/**
Get the Nic handle using any child handle in the IPv6 stack.
@@ -75,10 +73,10 @@ PxeBcGetNicByIp4Children (
**/
EFI_HANDLE
PxeBcGetNicByIp6Children (
- IN EFI_HANDLE ControllerHandle
+ IN EFI_HANDLE ControllerHandle
)
{
- EFI_HANDLE NicHandle;
+ EFI_HANDLE NicHandle;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid);
if (NicHandle == NULL) {
@@ -97,7 +95,6 @@ PxeBcGetNicByIp6Children (
return NicHandle;
}
-
/**
Destroy the opened instances based on IPv4.
@@ -111,7 +108,7 @@ PxeBcDestroyIp4Children (
IN PXEBC_PRIVATE_DATA *Private
)
{
- ASSERT(Private != NULL);
+ ASSERT (Private != NULL);
if (Private->ArpChild != NULL) {
//
@@ -175,11 +172,11 @@ PxeBcDestroyIp4Children (
// Close Udp4 for PxeBc->UdpRead and destroy the instance.
//
gBS->CloseProtocol (
- Private->Udp4ReadChild,
- &gEfiUdp4ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Udp4ReadChild,
+ &gEfiUdp4ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -194,11 +191,11 @@ PxeBcDestroyIp4Children (
// Close Mtftp4 for PxeBc->Mtftp4 and destroy the instance.
//
gBS->CloseProtocol (
- Private->Mtftp4Child,
- &gEfiMtftp4ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Mtftp4Child,
+ &gEfiMtftp4ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -213,11 +210,11 @@ PxeBcDestroyIp4Children (
// Close Dhcp4 for PxeBc->Dhcp4 and destroy the instance.
//
gBS->CloseProtocol (
- Private->Dhcp4Child,
- &gEfiDhcp4ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Dhcp4Child,
+ &gEfiDhcp4ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -267,19 +264,19 @@ PxeBcDestroyIp4Children (
Private->Snp
);
}
+
FreePool (Private->Ip4Nic);
}
- Private->ArpChild = NULL;
- Private->Ip4Child = NULL;
- Private->Udp4WriteChild = NULL;
- Private->Udp4ReadChild = NULL;
- Private->Mtftp4Child = NULL;
- Private->Dhcp4Child = NULL;
- Private->Ip4Nic = NULL;
+ Private->ArpChild = NULL;
+ Private->Ip4Child = NULL;
+ Private->Udp4WriteChild = NULL;
+ Private->Udp4ReadChild = NULL;
+ Private->Mtftp4Child = NULL;
+ Private->Dhcp4Child = NULL;
+ Private->Ip4Nic = NULL;
}
-
/**
Destroy the opened instances based on IPv6.
@@ -293,18 +290,18 @@ PxeBcDestroyIp6Children (
IN PXEBC_PRIVATE_DATA *Private
)
{
- ASSERT(Private != NULL);
+ ASSERT (Private != NULL);
if (Private->Ip6Child != NULL) {
//
// Close Ip6 for Ip6->Ip6Config and destroy the instance.
//
gBS->CloseProtocol (
- Private->Ip6Child,
- &gEfiIp6ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Ip6Child,
+ &gEfiIp6ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -337,11 +334,11 @@ PxeBcDestroyIp6Children (
// Close Udp6 for PxeBc->UdpRead and destroy the instance.
//
gBS->CloseProtocol (
- Private->Udp6ReadChild,
- &gEfiUdp6ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Udp6ReadChild,
+ &gEfiUdp6ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
This->DriverBindingHandle,
@@ -355,11 +352,11 @@ PxeBcDestroyIp6Children (
// Close Mtftp6 for PxeBc->Mtftp and destroy the instance.
//
gBS->CloseProtocol (
- Private->Mtftp6Child,
- &gEfiMtftp6ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Mtftp6Child,
+ &gEfiMtftp6ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -374,11 +371,11 @@ PxeBcDestroyIp6Children (
// Close Dhcp6 for PxeBc->Dhcp and destroy the instance.
//
gBS->CloseProtocol (
- Private->Dhcp6Child,
- &gEfiDhcp6ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Dhcp6Child,
+ &gEfiDhcp6ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -427,6 +424,7 @@ PxeBcDestroyIp6Children (
Private->Snp
);
}
+
FreePool (Private->Ip6Nic);
}
@@ -452,20 +450,20 @@ PxeBcDestroyIp6Children (
**/
EFI_STATUS
PxeBcCheckIpv6Support (
- IN EFI_HANDLE ControllerHandle,
- IN PXEBC_PRIVATE_DATA *Private,
- OUT BOOLEAN *Ipv6Support
+ IN EFI_HANDLE ControllerHandle,
+ IN PXEBC_PRIVATE_DATA *Private,
+ OUT BOOLEAN *Ipv6Support
)
{
- EFI_HANDLE Handle;
- EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
- EFI_STATUS Status;
- EFI_GUID *InfoTypesBuffer;
- UINTN InfoTypeBufferCount;
- UINTN TypeIndex;
- BOOLEAN Supported;
- VOID *InfoBlock;
- UINTN InfoBlockSize;
+ EFI_HANDLE Handle;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ EFI_STATUS Status;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypeBufferCount;
+ UINTN TypeIndex;
+ BOOLEAN Supported;
+ VOID *InfoBlock;
+ UINTN InfoBlockSize;
ASSERT (Private != NULL && Ipv6Support != NULL);
@@ -493,16 +491,16 @@ PxeBcCheckIpv6Support (
Status = gBS->HandleProtocol (
Handle,
&gEfiAdapterInformationProtocolGuid,
- (VOID *) &Aip
+ (VOID *)&Aip
);
- if (EFI_ERROR (Status) || Aip == NULL) {
+ if (EFI_ERROR (Status) || (Aip == NULL)) {
return EFI_NOT_FOUND;
}
InfoTypesBuffer = NULL;
InfoTypeBufferCount = 0;
- Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
- if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
+ Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
+ if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
FreePool (InfoTypesBuffer);
return EFI_NOT_FOUND;
}
@@ -525,16 +523,15 @@ PxeBcCheckIpv6Support (
//
InfoBlock = NULL;
InfoBlockSize = 0;
- Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
- if (EFI_ERROR (Status) || InfoBlock == NULL) {
+ Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
+ if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
FreePool (InfoBlock);
return EFI_NOT_FOUND;
}
- *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support;
+ *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support;
FreePool (InfoBlock);
return EFI_SUCCESS;
-
}
/**
@@ -555,14 +552,14 @@ PxeBcCreateIp4Children (
IN PXEBC_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- IPv4_DEVICE_PATH Ip4Node;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_UDP4_CONFIG_DATA *Udp4CfgData;
- EFI_IP4_CONFIG_DATA *Ip4CfgData;
- EFI_IP4_MODE_DATA Ip4ModeData;
- PXEBC_PRIVATE_PROTOCOL *Id;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ EFI_STATUS Status;
+ IPv4_DEVICE_PATH Ip4Node;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_UDP4_CONFIG_DATA *Udp4CfgData;
+ EFI_IP4_CONFIG_DATA *Ip4CfgData;
+ EFI_IP4_MODE_DATA Ip4ModeData;
+ PXEBC_PRIVATE_PROTOCOL *Id;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
if (Private->Ip4Nic != NULL) {
//
@@ -587,7 +584,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid,
- (VOID **) &Private->Dhcp4,
+ (VOID **)&Private->Dhcp4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -612,7 +609,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Mtftp4Child,
&gEfiMtftp4ProtocolGuid,
- (VOID **) &Private->Mtftp4,
+ (VOID **)&Private->Mtftp4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -637,7 +634,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Udp4ReadChild,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Private->Udp4Read,
+ (VOID **)&Private->Udp4Read,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -662,7 +659,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Udp4WriteChild,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Private->Udp4Write,
+ (VOID **)&Private->Udp4Write,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -687,7 +684,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->ArpChild,
&gEfiArpProtocolGuid,
- (VOID **) &Private->Arp,
+ (VOID **)&Private->Arp,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -712,7 +709,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Ip4Child,
&gEfiIp4ProtocolGuid,
- (VOID **) &Private->Ip4,
+ (VOID **)&Private->Ip4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -739,13 +736,13 @@ PxeBcCreateIp4Children (
Private->Ip4Nic->Private = Private;
Private->Ip4Nic->Signature = PXEBC_VIRTUAL_NIC_SIGNATURE;
- //
+ //
// Locate Ip4->Ip4Config2 and store it for set IPv4 Policy.
//
Status = gBS->HandleProtocol (
ControllerHandle,
&gEfiIp4Config2ProtocolGuid,
- (VOID **) &Private->Ip4Config2
+ (VOID **)&Private->Ip4Config2
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
@@ -814,7 +811,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Ip4Nic->Controller,
&gEfiSimpleNetworkProtocolGuid,
- (VOID **) &Snp,
+ (VOID **)&Snp,
This->DriverBindingHandle,
Private->Ip4Nic->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE
@@ -831,7 +828,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
- (VOID **) &Id,
+ (VOID **)&Id,
This->DriverBindingHandle,
Private->Ip4Nic->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -843,9 +840,9 @@ PxeBcCreateIp4Children (
//
// Set default configure data for Udp4Read and Ip4 instance.
//
- Mode = Private->PxeBc.Mode;
- Udp4CfgData = &Private->Udp4CfgData;
- Ip4CfgData = &Private->Ip4CfgData;
+ Mode = Private->PxeBc.Mode;
+ Udp4CfgData = &Private->Udp4CfgData;
+ Ip4CfgData = &Private->Ip4CfgData;
Udp4CfgData->AcceptBroadcast = FALSE;
Udp4CfgData->AcceptAnyPort = TRUE;
@@ -855,12 +852,12 @@ PxeBcCreateIp4Children (
Udp4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
Udp4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
- Ip4CfgData->AcceptIcmpErrors = TRUE;
- Ip4CfgData->DefaultProtocol = EFI_IP_PROTO_ICMP;
- Ip4CfgData->TypeOfService = Mode->ToS;
- Ip4CfgData->TimeToLive = Mode->TTL;
- Ip4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
- Ip4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
+ Ip4CfgData->AcceptIcmpErrors = TRUE;
+ Ip4CfgData->DefaultProtocol = EFI_IP_PROTO_ICMP;
+ Ip4CfgData->TypeOfService = Mode->ToS;
+ Ip4CfgData->TimeToLive = Mode->TTL;
+ Ip4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
+ Ip4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
return EFI_SUCCESS;
@@ -869,7 +866,6 @@ ON_ERROR:
return Status;
}
-
/**
Create the opened instances based on IPv6.
@@ -888,14 +884,14 @@ PxeBcCreateIp6Children (
IN PXEBC_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- IPv6_DEVICE_PATH Ip6Node;
- EFI_UDP6_CONFIG_DATA *Udp6CfgData;
- EFI_IP6_CONFIG_DATA *Ip6CfgData;
- EFI_IP6_MODE_DATA Ip6ModeData;
- PXEBC_PRIVATE_PROTOCOL *Id;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- UINTN Index;
+ EFI_STATUS Status;
+ IPv6_DEVICE_PATH Ip6Node;
+ EFI_UDP6_CONFIG_DATA *Udp6CfgData;
+ EFI_IP6_CONFIG_DATA *Ip6CfgData;
+ EFI_IP6_MODE_DATA Ip6ModeData;
+ PXEBC_PRIVATE_PROTOCOL *Id;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ UINTN Index;
if (Private->Ip6Nic != NULL) {
//
@@ -929,7 +925,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Dhcp6Child,
&gEfiDhcp6ProtocolGuid,
- (VOID **) &Private->Dhcp6,
+ (VOID **)&Private->Dhcp6,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -964,7 +960,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Mtftp6Child,
&gEfiMtftp6ProtocolGuid,
- (VOID **) &Private->Mtftp6,
+ (VOID **)&Private->Mtftp6,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -989,7 +985,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Udp6ReadChild,
&gEfiUdp6ProtocolGuid,
- (VOID **) &Private->Udp6Read,
+ (VOID **)&Private->Udp6Read,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1014,7 +1010,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Udp6WriteChild,
&gEfiUdp6ProtocolGuid,
- (VOID **) &Private->Udp6Write,
+ (VOID **)&Private->Udp6Write,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1039,7 +1035,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Ip6Child,
&gEfiIp6ProtocolGuid,
- (VOID **) &Private->Ip6,
+ (VOID **)&Private->Ip6,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1088,7 +1084,7 @@ PxeBcCreateIp6Children (
Status = gBS->HandleProtocol (
ControllerHandle,
&gEfiIp6ConfigProtocolGuid,
- (VOID **) &Private->Ip6Cfg
+ (VOID **)&Private->Ip6Cfg
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
@@ -1098,9 +1094,9 @@ PxeBcCreateIp6Children (
// Create a device path node for Ipv6 virtual nic, and append it.
//
ZeroMem (&Ip6Node, sizeof (IPv6_DEVICE_PATH));
- Ip6Node.Header.Type = MESSAGING_DEVICE_PATH;
- Ip6Node.Header.SubType = MSG_IPv6_DP;
- Ip6Node.PrefixLength = IP6_PREFIX_LENGTH;
+ Ip6Node.Header.Type = MESSAGING_DEVICE_PATH;
+ Ip6Node.Header.SubType = MSG_IPv6_DP;
+ Ip6Node.PrefixLength = IP6_PREFIX_LENGTH;
SetDevicePathNodeLength (&Ip6Node.Header, sizeof (Ip6Node));
@@ -1157,7 +1153,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Ip6Nic->Controller,
&gEfiSimpleNetworkProtocolGuid,
- (VOID **) &Snp,
+ (VOID **)&Snp,
This->DriverBindingHandle,
Private->Ip6Nic->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE
@@ -1174,7 +1170,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
- (VOID **) &Id,
+ (VOID **)&Id,
This->DriverBindingHandle,
Private->Ip6Nic->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -1192,15 +1188,15 @@ PxeBcCreateIp6Children (
//
// Fail to get the data whether UNDI supports IPv6. Set default value.
//
- Private->Mode.Ipv6Available = TRUE;
+ Private->Mode.Ipv6Available = TRUE;
}
if (!Private->Mode.Ipv6Available) {
goto ON_ERROR;
}
- Udp6CfgData = &Private->Udp6CfgData;
- Ip6CfgData = &Private->Ip6CfgData;
+ Udp6CfgData = &Private->Udp6CfgData;
+ Ip6CfgData = &Private->Ip6CfgData;
Udp6CfgData->AcceptAnyPort = TRUE;
Udp6CfgData->AllowDuplicatePort = TRUE;
@@ -1208,11 +1204,11 @@ PxeBcCreateIp6Children (
Udp6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
Udp6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
- Ip6CfgData->AcceptIcmpErrors = TRUE;
- Ip6CfgData->DefaultProtocol = IP6_ICMP;
- Ip6CfgData->HopLimit = PXEBC_DEFAULT_HOPLIMIT;
- Ip6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
- Ip6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
+ Ip6CfgData->AcceptIcmpErrors = TRUE;
+ Ip6CfgData->DefaultProtocol = IP6_ICMP;
+ Ip6CfgData->HopLimit = PXEBC_DEFAULT_HOPLIMIT;
+ Ip6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
+ Ip6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
return EFI_SUCCESS;
@@ -1221,7 +1217,6 @@ ON_ERROR:
return Status;
}
-
/**
The entry point for UefiPxeBc driver that installs the driver
binding and component name protocol on its image.
@@ -1236,13 +1231,13 @@ ON_ERROR:
EFI_STATUS
EFIAPI
PxeBcDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
- if ((PcdGet8(PcdIPv4PXESupport) == PXE_DISABLED) && (PcdGet8(PcdIPv6PXESupport) == PXE_DISABLED)) {
+ if ((PcdGet8 (PcdIPv4PXESupport) == PXE_DISABLED) && (PcdGet8 (PcdIPv6PXESupport) == PXE_DISABLED)) {
return EFI_UNSUPPORTED;
}
@@ -1300,20 +1295,22 @@ PxeBcSupported (
IN UINT8 IpVersion
)
{
- EFI_STATUS Status;
- EFI_GUID *DhcpServiceBindingGuid;
- EFI_GUID *MtftpServiceBindingGuid;
+ EFI_STATUS Status;
+ EFI_GUID *DhcpServiceBindingGuid;
+ EFI_GUID *MtftpServiceBindingGuid;
if (IpVersion == IP_VERSION_4) {
- if (PcdGet8(PcdIPv4PXESupport) == PXE_DISABLED) {
+ if (PcdGet8 (PcdIPv4PXESupport) == PXE_DISABLED) {
return EFI_UNSUPPORTED;
}
+
DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
MtftpServiceBindingGuid = &gEfiMtftp4ServiceBindingProtocolGuid;
} else {
- if (PcdGet8(PcdIPv6PXESupport) == PXE_DISABLED) {
+ if (PcdGet8 (PcdIPv6PXESupport) == PXE_DISABLED) {
return EFI_UNSUPPORTED;
}
+
DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid;
MtftpServiceBindingGuid = &gEfiMtftp6ServiceBindingProtocolGuid;
}
@@ -1322,22 +1319,22 @@ PxeBcSupported (
// Try to open the Mtftp and Dhcp protocol to test whether IP stack is ready.
//
Status = gBS->OpenProtocol (
- ControllerHandle,
- DhcpServiceBindingGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
+ ControllerHandle,
+ DhcpServiceBindingGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
- ControllerHandle,
- MtftpServiceBindingGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
+ ControllerHandle,
+ MtftpServiceBindingGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
}
//
@@ -1375,20 +1372,20 @@ PxeBcStart (
IN UINT8 IpVersion
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_STATUS Status;
- PXEBC_PRIVATE_PROTOCOL *Id;
- BOOLEAN FirstStart;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ PXEBC_PRIVATE_PROTOCOL *Id;
+ BOOLEAN FirstStart;
FirstStart = FALSE;
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiCallerIdGuid,
- (VOID **) &Id,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ (VOID **)&Id,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
//
// Skip the initialization if the driver has been started already.
@@ -1425,7 +1422,7 @@ PxeBcStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &Private->DevicePath,
+ (VOID **)&Private->DevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1441,7 +1438,7 @@ PxeBcStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
- (VOID **) &Private->Nii,
+ (VOID **)&Private->Nii,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1469,7 +1466,7 @@ PxeBcStart (
//
// Try to locate SNP protocol.
//
- NetLibGetSnpHandle(ControllerHandle, &Private->Snp);
+ NetLibGetSnpHandle (ControllerHandle, &Private->Snp);
}
if (IpVersion == IP_VERSION_4) {
@@ -1483,6 +1480,7 @@ PxeBcStart (
//
Status = PxeBcCreateIp6Children (This, ControllerHandle, Private);
}
+
if (EFI_ERROR (Status)) {
//
// Failed to start PXE driver if IPv4 and IPv6 stack are both not available.
@@ -1508,14 +1506,13 @@ ON_ERROR:
PxeBcDestroyIp6Children (This, Private);
}
- if (FirstStart && Private != NULL) {
+ if (FirstStart && (Private != NULL)) {
FreePool (Private);
}
return Status;
}
-
/**
Stop this driver on ControllerHandle. This is the worker function for
PxeBcIp4(6)DriverBindingStop.
@@ -1542,12 +1539,12 @@ PxeBcStop (
IN UINT8 IpVersion
)
{
- PXEBC_PRIVATE_DATA *Private;
- PXEBC_VIRTUAL_NIC *VirtualNic;
- EFI_LOAD_FILE_PROTOCOL *LoadFile;
- EFI_STATUS Status;
- EFI_HANDLE NicHandle;
- PXEBC_PRIVATE_PROTOCOL *Id;
+ PXEBC_PRIVATE_DATA *Private;
+ PXEBC_VIRTUAL_NIC *VirtualNic;
+ EFI_LOAD_FILE_PROTOCOL *LoadFile;
+ EFI_STATUS Status;
+ EFI_HANDLE NicHandle;
+ PXEBC_PRIVATE_PROTOCOL *Id;
Private = NULL;
NicHandle = NULL;
@@ -1558,7 +1555,7 @@ PxeBcStop (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiLoadFileProtocolGuid,
- (VOID **) &LoadFile,
+ (VOID **)&LoadFile,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1572,6 +1569,7 @@ PxeBcStop (
} else {
NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);
}
+
if (NicHandle == NULL) {
return EFI_SUCCESS;
}
@@ -1582,7 +1580,7 @@ PxeBcStop (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiCallerIdGuid,
- (VOID **) &Id,
+ (VOID **)&Id,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1590,8 +1588,8 @@ PxeBcStop (
if (EFI_ERROR (Status)) {
return Status;
}
- Private = PXEBC_PRIVATE_DATA_FROM_ID (Id);
+ Private = PXEBC_PRIVATE_DATA_FROM_ID (Id);
} else {
//
// It's a virtual handle with LoadFileProtocol.
@@ -1599,7 +1597,7 @@ PxeBcStop (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiLoadFileProtocolGuid,
- (VOID **) &LoadFile,
+ (VOID **)&LoadFile,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1617,20 +1615,19 @@ PxeBcStop (
// Stop functionality of PXE Base Code protocol
//
Status = Private->PxeBc.Stop (&Private->PxeBc);
- if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
+ if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
return Status;
}
-
- if (Private->Ip4Nic != NULL && IpVersion == IP_VERSION_4) {
+ if ((Private->Ip4Nic != NULL) && (IpVersion == IP_VERSION_4)) {
PxeBcDestroyIp4Children (This, Private);
}
- if (Private->Ip6Nic != NULL && IpVersion == IP_VERSION_6) {
+ if ((Private->Ip6Nic != NULL) && (IpVersion == IP_VERSION_6)) {
PxeBcDestroyIp6Children (This, Private);
}
- if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
+ if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
gBS->UninstallProtocolInterface (
NicHandle,
&gEfiCallerIdGuid,
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h
@@ -10,8 +10,8 @@
#ifndef __EFI_PXEBC_DRIVER_H__
#define __EFI_PXEBC_DRIVER_H__
-extern EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2;
+extern EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2;
/**
Test to see if this driver supports ControllerHandle. This service
@@ -64,7 +64,6 @@ PxeBcIp4DriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
-
/**
Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to
@@ -171,5 +170,5 @@ PxeBcIp6DriverBindingStop (
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
-#endif
+#endif
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -9,7 +9,6 @@
#include "PxeBcImpl.h"
-
/**
Enables the use of the PXE Base Code Protocol functions.
@@ -42,8 +41,8 @@
EFI_STATUS
EFIAPI
EfiPxeBcStart (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN BOOLEAN UseIpv6
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN BOOLEAN UseIpv6
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -65,9 +64,9 @@ EfiPxeBcStart (
//
// Detect whether using IPv6 or not, and set it into mode data.
//
- if (UseIpv6 && Mode->Ipv6Available && Mode->Ipv6Supported && Private->Ip6Nic != NULL) {
+ if (UseIpv6 && Mode->Ipv6Available && Mode->Ipv6Supported && (Private->Ip6Nic != NULL)) {
Mode->UsingIpv6 = TRUE;
- } else if (!UseIpv6 && Private->Ip4Nic != NULL) {
+ } else if (!UseIpv6 && (Private->Ip4Nic != NULL)) {
Mode->UsingIpv6 = FALSE;
} else {
return EFI_UNSUPPORTED;
@@ -90,7 +89,7 @@ EfiPxeBcStart (
// Configure block size for TFTP as a default value to handle all link layers.
//
Private->BlockSize = Private->Ip6MaxPacketSize -
- PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE;
+ PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE;
//
// PXE over IPv6 starts here, initialize the fields and list header.
@@ -108,13 +107,13 @@ EfiPxeBcStart (
// Create event and set status for token to capture ICMP6 error message.
//
Private->Icmp6Token.Status = EFI_NOT_READY;
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- PxeBcIcmp6ErrorUpdate,
- Private,
- &Private->Icmp6Token.Event
- );
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ PxeBcIcmp6ErrorUpdate,
+ Private,
+ &Private->Icmp6Token.Event
+ );
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
@@ -143,7 +142,7 @@ EfiPxeBcStart (
// Configure block size for TFTP as a default value to handle all link layers.
//
Private->BlockSize = Private->Ip4MaxPacketSize -
- PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE;
+ PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE;
//
// PXE over IPv4 starts here, initialize the fields.
@@ -188,23 +187,23 @@ EfiPxeBcStart (
// Create event and set status for token to capture ICMP error message.
//
Private->Icmp6Token.Status = EFI_NOT_READY;
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- PxeBcIcmpErrorUpdate,
- Private,
- &Private->IcmpToken.Event
- );
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ PxeBcIcmpErrorUpdate,
+ Private,
+ &Private->IcmpToken.Event
+ );
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
//
- //DHCP4 service allows only one of its children to be configured in
- //the active state, If the DHCP4 D.O.R.A started by IP4 auto
- //configuration and has not been completed, the Dhcp4 state machine
- //will not be in the right state for the PXE to start a new round D.O.R.A.
- //so we need to switch it's policy to static.
+ // DHCP4 service allows only one of its children to be configured in
+ // the active state, If the DHCP4 D.O.R.A started by IP4 auto
+ // configuration and has not been completed, the Dhcp4 state machine
+ // will not be in the right state for the PXE to start a new round D.O.R.A.
+ // so we need to switch its policy to static.
//
Status = PxeBcSetIp4Policy (Private);
if (EFI_ERROR (Status)) {
@@ -216,7 +215,7 @@ EfiPxeBcStart (
// If PcdTftpBlockSize is set to non-zero, override the default value.
//
if (PcdGet64 (PcdTftpBlockSize) != 0) {
- Private->BlockSize = (UINTN) PcdGet64 (PcdTftpBlockSize);
+ Private->BlockSize = (UINTN)PcdGet64 (PcdTftpBlockSize);
}
//
@@ -244,6 +243,7 @@ ON_ERROR:
gBS->CloseEvent (Private->Icmp6Token.Event);
Private->Icmp6Token.Event = NULL;
}
+
Private->Udp6Read->Configure (Private->Udp6Read, NULL);
Private->Ip6->Configure (Private->Ip6, NULL);
} else {
@@ -251,17 +251,19 @@ ON_ERROR:
gBS->CloseEvent (Private->ArpUpdateEvent);
Private->ArpUpdateEvent = NULL;
}
+
if (Private->IcmpToken.Event != NULL) {
gBS->CloseEvent (Private->IcmpToken.Event);
Private->IcmpToken.Event = NULL;
}
+
Private->Udp4Read->Configure (Private->Udp4Read, NULL);
Private->Ip4->Configure (Private->Ip4, NULL);
}
+
return Status;
}
-
/**
Disable the use of the PXE Base Code Protocol functions.
@@ -282,7 +284,7 @@ ON_ERROR:
EFI_STATUS
EFIAPI
EfiPxeBcStop (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -321,10 +323,12 @@ EfiPxeBcStop (
gBS->CloseEvent (Private->Icmp6Token.Event);
Private->Icmp6Token.Event = NULL;
}
+
if (Private->Dhcp6Request != NULL) {
FreePool (Private->Dhcp6Request);
Private->Dhcp6Request = NULL;
}
+
if (Private->BootFileName != NULL) {
FreePool (Private->BootFileName);
Private->BootFileName = NULL;
@@ -348,10 +352,12 @@ EfiPxeBcStop (
gBS->CloseEvent (Private->ArpUpdateEvent);
Private->ArpUpdateEvent = NULL;
}
+
if (Private->IcmpToken.Event != NULL) {
gBS->CloseEvent (Private->IcmpToken.Event);
Private->IcmpToken.Event = NULL;
}
+
Private->BootFileName = NULL;
}
@@ -378,7 +384,6 @@ EfiPxeBcStop (
return EFI_SUCCESS;
}
-
/**
Attempts to complete a DHCPv4 D.O.R.A. (discover / offer / request / acknowledge) or DHCPv6
S.A.R.R (solicit / advertise / request / reply) sequence.
@@ -410,8 +415,8 @@ EfiPxeBcStop (
EFI_STATUS
EFIAPI
EfiPxeBcDhcp (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN BOOLEAN SortOffers
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN BOOLEAN SortOffers
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -437,7 +442,6 @@ EfiPxeBcDhcp (
}
if (Mode->UsingIpv6) {
-
//
// Stop Udp6Read instance
//
@@ -448,7 +452,6 @@ EfiPxeBcDhcp (
//
Status = PxeBcDhcp6Sarr (Private, Private->Dhcp6);
} else {
-
//
// Stop Udp4Read instance
//
@@ -468,18 +471,18 @@ EfiPxeBcDhcp (
} else {
Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);
}
+
//
// Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP
// receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
//
- ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
+ ZeroMem (&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;
This->SetIpFilter (This, &IpFilter);
return Status;
}
-
/**
Attempts to complete the PXE Boot Server and/or boot image discovery sequence.
@@ -534,15 +537,15 @@ EfiPxeBcDiscover (
IN EFI_PXE_BASE_CODE_DISCOVER_INFO *Info OPTIONAL
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_PXE_BASE_CODE_DISCOVER_INFO DefaultInfo;
- EFI_PXE_BASE_CODE_SRVLIST *SrvList;
- PXEBC_BOOT_SVR_ENTRY *BootSvrEntry;
- UINT16 Index;
- EFI_STATUS Status;
- EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
- EFI_PXE_BASE_CODE_DISCOVER_INFO *NewCreatedInfo;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_PXE_BASE_CODE_DISCOVER_INFO DefaultInfo;
+ EFI_PXE_BASE_CODE_SRVLIST *SrvList;
+ PXEBC_BOOT_SVR_ENTRY *BootSvrEntry;
+ UINT16 Index;
+ EFI_STATUS Status;
+ EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
+ EFI_PXE_BASE_CODE_DISCOVER_INFO *NewCreatedInfo;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -569,13 +572,11 @@ EfiPxeBcDiscover (
}
if (Mode->UsingIpv6) {
-
//
// Stop Udp6Read instance
//
Private->Udp6Read->Configure (Private->Udp6Read, NULL);
} else {
-
//
// Stop Udp4Read instance
//
@@ -592,7 +593,8 @@ EfiPxeBcDiscover (
//
if (!Mode->PxeDiscoverValid ||
!Mode->PxeReplyReceived ||
- (!Mode->PxeBisReplyReceived && UseBis)) {
+ (!Mode->PxeBisReplyReceived && UseBis))
+ {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
@@ -605,16 +607,16 @@ EfiPxeBcDiscover (
SrvList[0].AcceptAnyResponse = FALSE;
CopyMem (&SrvList->IpAddr, &Private->ServerIp, sizeof (EFI_IP_ADDRESS));
-
} else if (Info == NULL) {
//
// 2. Extract the discover information from the cached packets if unspecified.
//
NewCreatedInfo = &DefaultInfo;
- Status = PxeBcExtractDiscoverInfo (Private, Type, &NewCreatedInfo, &BootSvrEntry, &SrvList);
+ Status = PxeBcExtractDiscoverInfo (Private, Type, &NewCreatedInfo, &BootSvrEntry, &SrvList);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
+
ASSERT (NewCreatedInfo != NULL);
Info = NewCreatedInfo;
} else {
@@ -629,6 +631,7 @@ EfiPxeBcDiscover (
break;
}
}
+
if (Index != Info->IpCnt) {
//
// It's invalid if the first server doesn't accecpt any response
@@ -644,7 +647,8 @@ EfiPxeBcDiscover (
// Info and BootSvrEntry/SrvList are all ready by now, so execute discover by UniCast/BroadCast/MultiCast.
//
if ((!Info->UseUCast && !Info->UseBCast && !Info->UseMCast) ||
- (Info->MustUseList && Info->IpCnt == 0)) {
+ (Info->MustUseList && (Info->IpCnt == 0)))
+ {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
@@ -664,7 +668,6 @@ EfiPxeBcDiscover (
Info->IpCnt,
SrvList
);
-
} else if (Info->UseBCast) {
//
// Do discover by broadcast, but only valid for IPv4.
@@ -679,7 +682,6 @@ EfiPxeBcDiscover (
Info->IpCnt,
SrvList
);
-
} else if (Info->UseUCast) {
//
// Do discover by unicast.
@@ -702,7 +704,7 @@ EfiPxeBcDiscover (
Info->IpCnt,
SrvList
);
- }
+ }
}
if (!EFI_ERROR (Status)) {
@@ -736,7 +738,7 @@ EfiPxeBcDiscover (
ON_EXIT:
- if (NewCreatedInfo != NULL && NewCreatedInfo != &DefaultInfo) {
+ if ((NewCreatedInfo != NULL) && (NewCreatedInfo != &DefaultInfo)) {
FreePool (NewCreatedInfo);
}
@@ -750,14 +752,13 @@ ON_EXIT:
// Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP
// receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
//
- ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
+ ZeroMem (&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;
This->SetIpFilter (This, &IpFilter);
return Status;
}
-
/**
Used to perform TFTP and MTFTP services.
@@ -824,60 +825,62 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiPxeBcMtftp (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
- IN OUT VOID *BufferPtr OPTIONAL,
- IN BOOLEAN Overwrite,
- IN OUT UINT64 *BufferSize,
- IN UINTN *BlockSize OPTIONAL,
- IN EFI_IP_ADDRESS *ServerIp,
- IN UINT8 *Filename,
- IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
- IN BOOLEAN DontUseBuffer
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
+ IN OUT VOID *BufferPtr OPTIONAL,
+ IN BOOLEAN Overwrite,
+ IN OUT UINT64 *BufferSize,
+ IN UINTN *BlockSize OPTIONAL,
+ IN EFI_IP_ADDRESS *ServerIp,
+ IN UINT8 *Filename,
+ IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
+ IN BOOLEAN DontUseBuffer
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_MTFTP4_CONFIG_DATA Mtftp4Config;
- EFI_MTFTP6_CONFIG_DATA Mtftp6Config;
- VOID *Config;
- EFI_STATUS Status;
- EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
- UINTN WindowSize;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_MTFTP4_CONFIG_DATA Mtftp4Config;
+ EFI_MTFTP6_CONFIG_DATA Mtftp6Config;
+ VOID *Config;
+ EFI_STATUS Status;
+ EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
+ UINTN WindowSize;
if ((This == NULL) ||
(Filename == NULL) ||
(BufferSize == NULL) ||
(ServerIp == NULL) ||
- ((BlockSize != NULL) && (*BlockSize < PXE_MTFTP_DEFAULT_BLOCK_SIZE))) {
+ ((BlockSize != NULL) && (*BlockSize < PXE_MTFTP_DEFAULT_BLOCK_SIZE)))
+ {
return EFI_INVALID_PARAMETER;
}
- if (Operation == EFI_PXE_BASE_CODE_TFTP_READ_FILE ||
- Operation == EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY ||
- Operation == EFI_PXE_BASE_CODE_MTFTP_READ_FILE ||
- Operation == EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY) {
- if (BufferPtr == NULL && !DontUseBuffer) {
+ if ((Operation == EFI_PXE_BASE_CODE_TFTP_READ_FILE) ||
+ (Operation == EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY) ||
+ (Operation == EFI_PXE_BASE_CODE_MTFTP_READ_FILE) ||
+ (Operation == EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY))
+ {
+ if ((BufferPtr == NULL) && !DontUseBuffer) {
return EFI_INVALID_PARAMETER;
}
}
- Config = NULL;
- Status = EFI_DEVICE_ERROR;
- Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
- Mode = Private->PxeBc.Mode;
+ Config = NULL;
+ Status = EFI_DEVICE_ERROR;
+ Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
+ Mode = Private->PxeBc.Mode;
//
// Get PcdPxeTftpWindowSize.
//
- WindowSize = (UINTN) PcdGet64 (PcdPxeTftpWindowSize);
+ WindowSize = (UINTN)PcdGet64 (PcdPxeTftpWindowSize);
if (Mode->UsingIpv6) {
if (!NetIp6IsValidUnicast (&ServerIp->v6)) {
return EFI_INVALID_PARAMETER;
}
} else {
- if (IP4_IS_UNSPECIFIED (NTOHL (ServerIp->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (ServerIp->Addr[0]))) {
+ if (IP4_IS_UNSPECIFIED (NTOHL (ServerIp->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (ServerIp->Addr[0]))) {
return EFI_INVALID_PARAMETER;
}
}
@@ -887,9 +890,9 @@ EfiPxeBcMtftp (
// Set configuration data for Mtftp6 instance.
//
ZeroMem (&Mtftp6Config, sizeof (EFI_MTFTP6_CONFIG_DATA));
- Config = &Mtftp6Config;
- Mtftp6Config.TimeoutValue = PXEBC_MTFTP_TIMEOUT;
- Mtftp6Config.TryCount = PXEBC_MTFTP_RETRIES;
+ Config = &Mtftp6Config;
+ Mtftp6Config.TimeoutValue = PXEBC_MTFTP_TIMEOUT;
+ Mtftp6Config.TryCount = PXEBC_MTFTP_RETRIES;
CopyMem (&Mtftp6Config.StationIp, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Mtftp6Config.ServerIp, &ServerIp->v6, sizeof (EFI_IPv6_ADDRESS));
//
@@ -919,83 +922,82 @@ EfiPxeBcMtftp (
Mode->IcmpErrorReceived = FALSE;
switch (Operation) {
+ case EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE:
+ //
+ // Send TFTP request to get file size.
+ //
+ Status = PxeBcTftpGetFileSize (
+ Private,
+ Config,
+ Filename,
+ BlockSize,
+ (WindowSize > 1) ? &WindowSize : NULL,
+ BufferSize
+ );
- case EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE:
- //
- // Send TFTP request to get file size.
- //
- Status = PxeBcTftpGetFileSize (
- Private,
- Config,
- Filename,
- BlockSize,
- (WindowSize > 1) ? &WindowSize : NULL,
- BufferSize
- );
-
- break;
+ break;
- case EFI_PXE_BASE_CODE_TFTP_READ_FILE:
- //
- // Send TFTP request to read file.
- //
- Status = PxeBcTftpReadFile (
- Private,
- Config,
- Filename,
- BlockSize,
- (WindowSize > 1) ? &WindowSize : NULL,
- BufferPtr,
- BufferSize,
- DontUseBuffer
- );
+ case EFI_PXE_BASE_CODE_TFTP_READ_FILE:
+ //
+ // Send TFTP request to read file.
+ //
+ Status = PxeBcTftpReadFile (
+ Private,
+ Config,
+ Filename,
+ BlockSize,
+ (WindowSize > 1) ? &WindowSize : NULL,
+ BufferPtr,
+ BufferSize,
+ DontUseBuffer
+ );
- break;
+ break;
- case EFI_PXE_BASE_CODE_TFTP_WRITE_FILE:
- //
- // Send TFTP request to write file.
- //
- Status = PxeBcTftpWriteFile (
- Private,
- Config,
- Filename,
- Overwrite,
- BlockSize,
- BufferPtr,
- BufferSize
- );
+ case EFI_PXE_BASE_CODE_TFTP_WRITE_FILE:
+ //
+ // Send TFTP request to write file.
+ //
+ Status = PxeBcTftpWriteFile (
+ Private,
+ Config,
+ Filename,
+ Overwrite,
+ BlockSize,
+ BufferPtr,
+ BufferSize
+ );
- break;
+ break;
- case EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY:
- //
- // Send TFTP request to read directory.
- //
- Status = PxeBcTftpReadDirectory (
- Private,
- Config,
- Filename,
- BlockSize,
- (WindowSize > 1) ? &WindowSize : NULL,
- BufferPtr,
- BufferSize,
- DontUseBuffer
- );
+ case EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY:
+ //
+ // Send TFTP request to read directory.
+ //
+ Status = PxeBcTftpReadDirectory (
+ Private,
+ Config,
+ Filename,
+ BlockSize,
+ (WindowSize > 1) ? &WindowSize : NULL,
+ BufferPtr,
+ BufferSize,
+ DontUseBuffer
+ );
- break;
+ break;
- case EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE:
- case EFI_PXE_BASE_CODE_MTFTP_READ_FILE:
- case EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY:
- Status = EFI_UNSUPPORTED;
+ case EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE:
+ case EFI_PXE_BASE_CODE_MTFTP_READ_FILE:
+ case EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY:
+ Status = EFI_UNSUPPORTED;
- break;
+ break;
- default:
- Status = EFI_INVALID_PARAMETER;
+ default:
+ Status = EFI_INVALID_PARAMETER;
- break;
+ break;
}
if (Status == EFI_ICMP_ERROR) {
@@ -1010,18 +1012,18 @@ EfiPxeBcMtftp (
} else {
Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);
}
+
//
// Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP
// receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
//
- ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
+ ZeroMem (&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;
This->SetIpFilter (This, &IpFilter);
return Status;
}
-
/**
Writes a UDP packet to the network interface.
@@ -1062,27 +1064,27 @@ EfiPxeBcMtftp (
EFI_STATUS
EFIAPI
EfiPxeBcUdpWrite (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN UINT16 OpFlags,
- IN EFI_IP_ADDRESS *DestIp,
- IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort,
- IN EFI_IP_ADDRESS *GatewayIp OPTIONAL,
- IN EFI_IP_ADDRESS *SrcIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL,
- IN UINTN *HeaderSize OPTIONAL,
- IN VOID *HeaderPtr OPTIONAL,
- IN UINTN *BufferSize,
- IN VOID *BufferPtr
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN UINT16 OpFlags,
+ IN EFI_IP_ADDRESS *DestIp,
+ IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort,
+ IN EFI_IP_ADDRESS *GatewayIp OPTIONAL,
+ IN EFI_IP_ADDRESS *SrcIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL,
+ IN UINTN *HeaderSize OPTIONAL,
+ IN VOID *HeaderPtr OPTIONAL,
+ IN UINTN *BufferSize,
+ IN VOID *BufferPtr
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_UDP4_SESSION_DATA Udp4Session;
- EFI_UDP6_SESSION_DATA Udp6Session;
- EFI_STATUS Status;
- BOOLEAN DoNotFragment;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_UDP4_SESSION_DATA Udp4Session;
+ EFI_UDP6_SESSION_DATA Udp6Session;
+ EFI_STATUS Status;
+ BOOLEAN DoNotFragment;
- if (This == NULL || DestIp == NULL || DestPort == NULL) {
+ if ((This == NULL) || (DestIp == NULL) || (DestPort == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1095,19 +1097,20 @@ EfiPxeBcUdpWrite (
DoNotFragment = TRUE;
}
- if (!Mode->UsingIpv6 && GatewayIp != NULL && Mode->SubnetMask.Addr[0] != 0 &&
- !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), EFI_NTOHL(Mode->SubnetMask))) {
+ if (!Mode->UsingIpv6 && (GatewayIp != NULL) && (Mode->SubnetMask.Addr[0] != 0) &&
+ !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), EFI_NTOHL (Mode->SubnetMask)))
+ {
//
// Gateway is provided but it's not a unicast IPv4 address, while it will be ignored for IPv6.
//
return EFI_INVALID_PARAMETER;
}
- if (HeaderSize != NULL && (*HeaderSize == 0 || HeaderPtr == NULL)) {
+ if ((HeaderSize != NULL) && ((*HeaderSize == 0) || (HeaderPtr == NULL))) {
return EFI_INVALID_PARAMETER;
}
- if (BufferSize == NULL || (*BufferSize != 0 && BufferPtr == NULL)) {
+ if ((BufferSize == NULL) || ((*BufferSize != 0) && (BufferPtr == NULL))) {
return EFI_INVALID_PARAMETER;
}
@@ -1115,12 +1118,13 @@ EfiPxeBcUdpWrite (
return EFI_NOT_STARTED;
}
- if (!Private->IsAddressOk && SrcIp == NULL) {
+ if (!Private->IsAddressOk && (SrcIp == NULL)) {
return EFI_INVALID_PARAMETER;
}
- if (Private->CurSrcPort == 0 ||
- (SrcPort != NULL && *SrcPort != Private->CurSrcPort)) {
+ if ((Private->CurSrcPort == 0) ||
+ ((SrcPort != NULL) && (*SrcPort != Private->CurSrcPort)))
+ {
//
// Reconfigure UDPv4/UDPv6 for UdpWrite if the source port changed.
//
@@ -1173,6 +1177,7 @@ EfiPxeBcUdpWrite (
if (SrcIp != NULL) {
CopyMem (&Udp6Session.SourceAddress, SrcIp, sizeof (EFI_IPv6_ADDRESS));
}
+
if (SrcPort != NULL) {
Udp6Session.SourcePort = *SrcPort;
}
@@ -1196,9 +1201,11 @@ EfiPxeBcUdpWrite (
if (SrcIp != NULL) {
CopyMem (&Udp4Session.SourceAddress, SrcIp, sizeof (EFI_IPv4_ADDRESS));
}
+
if (SrcPort != NULL) {
Udp4Session.SourcePort = *SrcPort;
}
+
//
// Override the gateway information if user specified.
//
@@ -1206,7 +1213,7 @@ EfiPxeBcUdpWrite (
Private->Udp4Write,
&Udp4Session,
Private->UdpTimeOutEvent,
- (EFI_IPv4_ADDRESS *) GatewayIp,
+ (EFI_IPv4_ADDRESS *)GatewayIp,
HeaderSize,
HeaderPtr,
BufferSize,
@@ -1216,7 +1223,6 @@ EfiPxeBcUdpWrite (
gBS->SetTimer (Private->UdpTimeOutEvent, TimerCancel, 0);
-
//
// Reset the UdpWrite instance.
//
@@ -1229,7 +1235,6 @@ EfiPxeBcUdpWrite (
return Status;
}
-
/**
Reads a UDP packet from the network interface.
+
@@ -1270,34 +1275,34 @@ EfiPxeBcUdpWrite (
EFI_STATUS
EFIAPI
EfiPxeBcUdpRead (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN UINT16 OpFlags,
- IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
- IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL,
- IN UINTN *HeaderSize OPTIONAL,
- IN VOID *HeaderPtr OPTIONAL,
- IN OUT UINTN *BufferSize,
- IN VOID *BufferPtr
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN UINT16 OpFlags,
+ IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
+ IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL,
+ IN UINTN *HeaderSize OPTIONAL,
+ IN VOID *HeaderPtr OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ IN VOID *BufferPtr
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_UDP4_COMPLETION_TOKEN Udp4Token;
- EFI_UDP6_COMPLETION_TOKEN Udp6Token;
- EFI_UDP4_RECEIVE_DATA *Udp4Rx;
- EFI_UDP6_RECEIVE_DATA *Udp6Rx;
- EFI_STATUS Status;
- BOOLEAN IsDone;
- BOOLEAN IsMatched;
- UINTN CopiedLen;
- UINTN HeaderLen;
- UINTN HeaderCopiedLen;
- UINTN BufferCopiedLen;
- UINT32 FragmentLength;
- UINTN FragmentIndex;
- UINT8 *FragmentBuffer;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_UDP4_COMPLETION_TOKEN Udp4Token;
+ EFI_UDP6_COMPLETION_TOKEN Udp6Token;
+ EFI_UDP4_RECEIVE_DATA *Udp4Rx;
+ EFI_UDP6_RECEIVE_DATA *Udp6Rx;
+ EFI_STATUS Status;
+ BOOLEAN IsDone;
+ BOOLEAN IsMatched;
+ UINTN CopiedLen;
+ UINTN HeaderLen;
+ UINTN HeaderCopiedLen;
+ UINTN BufferCopiedLen;
+ UINT32 FragmentLength;
+ UINTN FragmentIndex;
+ UINT8 *FragmentBuffer;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1310,13 +1315,14 @@ EfiPxeBcUdpRead (
Udp4Rx = NULL;
Udp6Rx = NULL;
- if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0 && DestPort == NULL) ||
- ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) == 0 && SrcIp == NULL) ||
- ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) == 0 && SrcPort == NULL)) {
+ if ((((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0) && (DestPort == NULL)) ||
+ (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) == 0) && (SrcIp == NULL)) ||
+ (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) == 0) && (SrcPort == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
- if ((HeaderSize != NULL && *HeaderSize == 0) || (HeaderSize != NULL && HeaderPtr == NULL)) {
+ if (((HeaderSize != NULL) && (*HeaderSize == 0)) || ((HeaderSize != NULL) && (HeaderPtr == NULL))) {
return EFI_INVALID_PARAMETER;
}
@@ -1396,16 +1402,18 @@ EfiPxeBcUdpRead (
}
}
- if (Status == EFI_ICMP_ERROR ||
- Status == EFI_NETWORK_UNREACHABLE ||
- Status == EFI_HOST_UNREACHABLE ||
- Status == EFI_PROTOCOL_UNREACHABLE ||
- Status == EFI_PORT_UNREACHABLE) {
+ if ((Status == EFI_ICMP_ERROR) ||
+ (Status == EFI_NETWORK_UNREACHABLE) ||
+ (Status == EFI_HOST_UNREACHABLE) ||
+ (Status == EFI_PROTOCOL_UNREACHABLE) ||
+ (Status == EFI_PORT_UNREACHABLE))
+ {
//
// Get different return status for icmp error from Udp, refers to UEFI spec.
//
Mode->IcmpErrorReceived = TRUE;
}
+
gBS->SetTimer (Private->UdpTimeOutEvent, TimerCancel, 0);
if (IsMatched) {
@@ -1427,6 +1435,7 @@ EfiPxeBcUdpRead (
if (HeaderSize != NULL) {
*HeaderSize = HeaderLen;
}
+
*BufferSize = Udp6Rx->DataLength - HeaderLen;
HeaderCopiedLen = 0;
@@ -1438,30 +1447,31 @@ EfiPxeBcUdpRead (
//
// Copy the header part of received data.
//
- CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuffer, FragmentLength);
+ CopyMem ((UINT8 *)HeaderPtr + HeaderCopiedLen, FragmentBuffer, FragmentLength);
HeaderCopiedLen += FragmentLength;
} else if (HeaderCopiedLen < HeaderLen) {
//
// Copy the header part of received data.
//
CopiedLen = HeaderLen - HeaderCopiedLen;
- CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuffer, CopiedLen);
+ CopyMem ((UINT8 *)HeaderPtr + HeaderCopiedLen, FragmentBuffer, CopiedLen);
HeaderCopiedLen += CopiedLen;
//
// Copy the other part of received data.
//
- CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuffer + CopiedLen, FragmentLength - CopiedLen);
+ CopyMem ((UINT8 *)BufferPtr + BufferCopiedLen, FragmentBuffer + CopiedLen, FragmentLength - CopiedLen);
BufferCopiedLen += (FragmentLength - CopiedLen);
} else {
//
// Copy the other part of received data.
//
- CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuffer, FragmentLength);
+ CopyMem ((UINT8 *)BufferPtr + BufferCopiedLen, FragmentBuffer, FragmentLength);
BufferCopiedLen += FragmentLength;
}
}
}
+
//
// Recycle the receiving buffer after copy to user.
//
@@ -1481,6 +1491,7 @@ EfiPxeBcUdpRead (
if (HeaderSize != NULL) {
*HeaderSize = HeaderLen;
}
+
*BufferSize = Udp4Rx->DataLength - HeaderLen;
HeaderCopiedLen = 0;
@@ -1492,30 +1503,31 @@ EfiPxeBcUdpRead (
//
// Copy the header part of received data.
//
- CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuffer, FragmentLength);
+ CopyMem ((UINT8 *)HeaderPtr + HeaderCopiedLen, FragmentBuffer, FragmentLength);
HeaderCopiedLen += FragmentLength;
} else if (HeaderCopiedLen < HeaderLen) {
//
// Copy the header part of received data.
//
CopiedLen = HeaderLen - HeaderCopiedLen;
- CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuffer, CopiedLen);
+ CopyMem ((UINT8 *)HeaderPtr + HeaderCopiedLen, FragmentBuffer, CopiedLen);
HeaderCopiedLen += CopiedLen;
//
// Copy the other part of received data.
//
- CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuffer + CopiedLen, FragmentLength - CopiedLen);
+ CopyMem ((UINT8 *)BufferPtr + BufferCopiedLen, FragmentBuffer + CopiedLen, FragmentLength - CopiedLen);
BufferCopiedLen += (FragmentLength - CopiedLen);
} else {
//
// Copy the other part of received data.
//
- CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuffer, FragmentLength);
+ CopyMem ((UINT8 *)BufferPtr + BufferCopiedLen, FragmentBuffer, FragmentLength);
BufferCopiedLen += FragmentLength;
}
}
}
+
//
// Recycle the receiving buffer after copy to user.
//
@@ -1534,7 +1546,6 @@ EfiPxeBcUdpRead (
return Status;
}
-
/**
Updates the IP receive filters of a network device and enables software filtering.
@@ -1570,22 +1581,22 @@ EfiPxeBcUdpRead (
EFI_STATUS
EFIAPI
EfiPxeBcSetIpFilter (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter
)
{
- EFI_STATUS Status;
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_UDP4_CONFIG_DATA *Udp4Cfg;
- EFI_UDP6_CONFIG_DATA *Udp6Cfg;
- UINTN Index;
- BOOLEAN NeedPromiscuous;
- BOOLEAN AcceptPromiscuous;
- BOOLEAN AcceptBroadcast;
- BOOLEAN MultiCastUpdate;
+ EFI_STATUS Status;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_UDP4_CONFIG_DATA *Udp4Cfg;
+ EFI_UDP6_CONFIG_DATA *Udp6Cfg;
+ UINTN Index;
+ BOOLEAN NeedPromiscuous;
+ BOOLEAN AcceptPromiscuous;
+ BOOLEAN AcceptBroadcast;
+ BOOLEAN MultiCastUpdate;
- if (This == NULL || NewFilter == NULL) {
+ if ((This == NULL) || (NewFilter == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1601,22 +1612,26 @@ EfiPxeBcSetIpFilter (
for (Index = 0; Index < NewFilter->IpCnt; Index++) {
ASSERT (Index < EFI_PXE_BASE_CODE_MAX_IPCNT);
if (!Mode->UsingIpv6 &&
- IP4_IS_LOCAL_BROADCAST (EFI_IP4 (NewFilter->IpList[Index].v4))) {
+ IP4_IS_LOCAL_BROADCAST (EFI_IP4 (NewFilter->IpList[Index].v4)))
+ {
//
// IPv4 broadcast address should not be in IP filter.
//
return EFI_INVALID_PARAMETER;
}
+
if (Mode->UsingIpv6) {
- if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0 &&
- NetIp6IsValidUnicast (&NewFilter->IpList[Index].v6)) {
+ if (((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) &&
+ NetIp6IsValidUnicast (&NewFilter->IpList[Index].v6))
+ {
NeedPromiscuous = TRUE;
}
- } else if ((EFI_NTOHL(Mode->StationIp) != 0) &&
- (EFI_NTOHL(Mode->SubnetMask) != 0) &&
- IP4_NET_EQUAL(EFI_NTOHL(Mode->StationIp), EFI_NTOHL(NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask.v4)) &&
- NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask)) &&
- ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0)) {
+ } else if ((EFI_NTOHL (Mode->StationIp) != 0) &&
+ (EFI_NTOHL (Mode->SubnetMask) != 0) &&
+ IP4_NET_EQUAL (EFI_NTOHL (Mode->StationIp), EFI_NTOHL (NewFilter->IpList[Index].v4), EFI_NTOHL (Mode->SubnetMask.v4)) &&
+ NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), EFI_NTOHL (Mode->SubnetMask)) &&
+ ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0))
+ {
NeedPromiscuous = TRUE;
}
}
@@ -1626,8 +1641,9 @@ EfiPxeBcSetIpFilter (
MultiCastUpdate = FALSE;
if (NeedPromiscuous ||
- (NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != 0 ||
- (NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0) {
+ ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != 0) ||
+ ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0))
+ {
//
// Configure UDPv4/UDPv6 as promiscuous mode to receive all packets.
//
@@ -1636,7 +1652,7 @@ EfiPxeBcSetIpFilter (
//
// Configure UDPv4 to receive all broadcast packets.
//
- AcceptBroadcast = TRUE;
+ AcceptBroadcast = TRUE;
}
//
@@ -1661,7 +1677,8 @@ EfiPxeBcSetIpFilter (
//
Udp4Cfg = &Private->Udp4CfgData;
if ((AcceptPromiscuous != Udp4Cfg->AcceptPromiscuous) ||
- (AcceptBroadcast != Udp4Cfg->AcceptBroadcast) || MultiCastUpdate) {
+ (AcceptBroadcast != Udp4Cfg->AcceptBroadcast) || MultiCastUpdate)
+ {
//
// Clear the UDP4 instance configuration, all joined groups will be left
// during the operation.
@@ -1673,7 +1690,7 @@ EfiPxeBcSetIpFilter (
//
Udp4Cfg->AcceptPromiscuous = AcceptPromiscuous;
Udp4Cfg->AcceptBroadcast = AcceptBroadcast;
- Status = Private->Udp4Read->Configure (Private->Udp4Read, Udp4Cfg);
+ Status = Private->Udp4Read->Configure (Private->Udp4Read, Udp4Cfg);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1711,7 +1728,7 @@ EfiPxeBcSetIpFilter (
// Configure the UDP instance with the new configuration.
//
Udp6Cfg->AcceptPromiscuous = AcceptPromiscuous;
- Status = Private->Udp6Read->Configure (Private->Udp6Read, Udp6Cfg);
+ Status = Private->Udp6Read->Configure (Private->Udp6Read, Udp6Cfg);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1743,7 +1760,6 @@ EfiPxeBcSetIpFilter (
return Status;
}
-
/**
Uses the ARP protocol to resolve a MAC address. It is not supported for IPv6.
@@ -1772,9 +1788,9 @@ EfiPxeBcSetIpFilter (
EFI_STATUS
EFIAPI
EfiPxeBcArp (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN EFI_IP_ADDRESS *IpAddr,
- IN EFI_MAC_ADDRESS *MacAddr OPTIONAL
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN EFI_IP_ADDRESS *IpAddr,
+ IN EFI_MAC_ADDRESS *MacAddr OPTIONAL
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -1785,7 +1801,7 @@ EfiPxeBcArp (
EFI_MAC_ADDRESS ZeroMac;
BOOLEAN IsResolved;
- if (This == NULL || IpAddr == NULL) {
+ if ((This == NULL) || (IpAddr == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1839,7 +1855,7 @@ EfiPxeBcArp (
// If AutoArp is TRUE, try to send Arp request on initiative.
//
Status = Private->Arp->Request (Private->Arp, &IpAddr->v4, ResolvedEvent, &TempMac);
- if (EFI_ERROR (Status) && Status != EFI_NOT_READY) {
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
goto ON_EXIT;
}
@@ -1848,6 +1864,7 @@ EfiPxeBcArp (
break;
}
}
+
if (CompareMem (&TempMac, &ZeroMac, sizeof (EFI_MAC_ADDRESS)) != 0) {
Status = EFI_SUCCESS;
} else {
@@ -1858,7 +1875,7 @@ EfiPxeBcArp (
//
// Copy the Mac address to user if needed.
//
- if (MacAddr != NULL && !EFI_ERROR (Status)) {
+ if ((MacAddr != NULL) && !EFI_ERROR (Status)) {
CopyMem (MacAddr, &TempMac, sizeof (EFI_MAC_ADDRESS));
}
@@ -1866,10 +1883,10 @@ ON_EXIT:
if (ResolvedEvent != NULL) {
gBS->CloseEvent (ResolvedEvent);
}
+
return Status;
}
-
/**
Updates the parameters that affect the operation of the PXE Base Code Protocol.
@@ -1905,12 +1922,12 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiPxeBcSetParameters (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN BOOLEAN *NewAutoArp OPTIONAL,
- IN BOOLEAN *NewSendGUID OPTIONAL,
- IN UINT8 *NewTTL OPTIONAL,
- IN UINT8 *NewToS OPTIONAL,
- IN BOOLEAN *NewMakeCallback OPTIONAL
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN BOOLEAN *NewAutoArp OPTIONAL,
+ IN BOOLEAN *NewSendGUID OPTIONAL,
+ IN UINT8 *NewTTL OPTIONAL,
+ IN UINT8 *NewToS OPTIONAL,
+ IN BOOLEAN *NewMakeCallback OPTIONAL
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -1937,7 +1954,7 @@ EfiPxeBcSetParameters (
Status = gBS->HandleProtocol (
Mode->UsingIpv6 ? Private->Ip6Nic->Controller : Private->Ip4Nic->Controller,
&gEfiPxeBaseCodeCallbackProtocolGuid,
- (VOID **) &Private->PxeBcCallback
+ (VOID **)&Private->PxeBcCallback
);
if (EFI_ERROR (Status) || (Private->PxeBcCallback->Callback == NULL)) {
@@ -1946,6 +1963,7 @@ EfiPxeBcSetParameters (
} else {
Private->PxeBcCallback = NULL;
}
+
Mode->MakeCallbacks = *NewMakeCallback;
}
@@ -1972,7 +1990,6 @@ EfiPxeBcSetParameters (
return EFI_SUCCESS;
}
-
/**
Updates the station IP address and/or subnet mask values of a network device.
@@ -1997,9 +2014,9 @@ EfiPxeBcSetParameters (
EFI_STATUS
EFIAPI
EfiPxeBcSetStationIP (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN EFI_IP_ADDRESS *NewStationIp OPTIONAL,
- IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN EFI_IP_ADDRESS *NewStationIp OPTIONAL,
+ IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL
)
{
EFI_STATUS Status;
@@ -2010,7 +2027,7 @@ EfiPxeBcSetStationIP (
return EFI_INVALID_PARAMETER;
}
- if (NewStationIp != NULL && !NetIp6IsValidUnicast (&NewStationIp->v6)) {
+ if ((NewStationIp != NULL) && !NetIp6IsValidUnicast (&NewStationIp->v6)) {
return EFI_INVALID_PARAMETER;
}
@@ -2019,15 +2036,17 @@ EfiPxeBcSetStationIP (
Status = EFI_SUCCESS;
if (!Mode->UsingIpv6 &&
- NewSubnetMask != NULL &&
- !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask->Addr[0]))) {
+ (NewSubnetMask != NULL) &&
+ !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask->Addr[0])))
+ {
return EFI_INVALID_PARAMETER;
}
- if (!Mode->UsingIpv6 && NewStationIp != NULL) {
- if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) ||
- IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) ||
- (NewSubnetMask != NULL && NewSubnetMask->Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) {
+ if (!Mode->UsingIpv6 && (NewStationIp != NULL)) {
+ if (IP4_IS_UNSPECIFIED (NTOHL (NewStationIp->Addr[0])) ||
+ IP4_IS_LOCAL_BROADCAST (NTOHL (NewStationIp->Addr[0])) ||
+ ((NewSubnetMask != NULL) && (NewSubnetMask->Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))))
+ {
return EFI_INVALID_PARAMETER;
}
}
@@ -2036,7 +2055,7 @@ EfiPxeBcSetStationIP (
return EFI_NOT_STARTED;
}
- if (Mode->UsingIpv6 && NewStationIp != NULL) {
+ if (Mode->UsingIpv6 && (NewStationIp != NULL)) {
//
// Set the IPv6 address by Ip6Config protocol.
//
@@ -2051,9 +2070,9 @@ EfiPxeBcSetStationIP (
CopyMem (&Private->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS));
}
- if (!Mode->UsingIpv6 && NewSubnetMask != NULL) {
+ if (!Mode->UsingIpv6 && (NewSubnetMask != NULL)) {
CopyMem (&Mode->SubnetMask, NewSubnetMask, sizeof (EFI_IP_ADDRESS));
- CopyMem (&Private->SubnetMask ,NewSubnetMask, sizeof (EFI_IP_ADDRESS));
+ CopyMem (&Private->SubnetMask, NewSubnetMask, sizeof (EFI_IP_ADDRESS));
}
Status = PxeBcFlushStationIp (Private, NewStationIp, NewSubnetMask);
@@ -2065,7 +2084,6 @@ ON_EXIT:
return Status;
}
-
/**
Updates the contents of the cached DHCP and Discover packets.
@@ -2101,19 +2119,19 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiPxeBcSetPackets (
- IN EFI_PXE_BASE_CODE_PROTOCOL *This,
- IN BOOLEAN *NewDhcpDiscoverValid OPTIONAL,
- IN BOOLEAN *NewDhcpAckReceived OPTIONAL,
- IN BOOLEAN *NewProxyOfferReceived OPTIONAL,
- IN BOOLEAN *NewPxeDiscoverValid OPTIONAL,
- IN BOOLEAN *NewPxeReplyReceived OPTIONAL,
- IN BOOLEAN *NewPxeBisReplyReceived OPTIONAL,
- IN EFI_PXE_BASE_CODE_PACKET *NewDhcpDiscover OPTIONAL,
- IN EFI_PXE_BASE_CODE_PACKET *NewDhcpAck OPTIONAL,
- IN EFI_PXE_BASE_CODE_PACKET *NewProxyOffer OPTIONAL,
- IN EFI_PXE_BASE_CODE_PACKET *NewPxeDiscover OPTIONAL,
- IN EFI_PXE_BASE_CODE_PACKET *NewPxeReply OPTIONAL,
- IN EFI_PXE_BASE_CODE_PACKET *NewPxeBisReply OPTIONAL
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN BOOLEAN *NewDhcpDiscoverValid OPTIONAL,
+ IN BOOLEAN *NewDhcpAckReceived OPTIONAL,
+ IN BOOLEAN *NewProxyOfferReceived OPTIONAL,
+ IN BOOLEAN *NewPxeDiscoverValid OPTIONAL,
+ IN BOOLEAN *NewPxeReplyReceived OPTIONAL,
+ IN BOOLEAN *NewPxeBisReplyReceived OPTIONAL,
+ IN EFI_PXE_BASE_CODE_PACKET *NewDhcpDiscover OPTIONAL,
+ IN EFI_PXE_BASE_CODE_PACKET *NewDhcpAck OPTIONAL,
+ IN EFI_PXE_BASE_CODE_PACKET *NewProxyOffer OPTIONAL,
+ IN EFI_PXE_BASE_CODE_PACKET *NewPxeDiscover OPTIONAL,
+ IN EFI_PXE_BASE_CODE_PACKET *NewPxeReply OPTIONAL,
+ IN EFI_PXE_BASE_CODE_PACKET *NewPxeBisReply OPTIONAL
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -2198,7 +2216,6 @@ EFI_PXE_BASE_CODE_PROTOCOL gPxeBcProtoc
NULL
};
-
/**
Callback function that is invoked when the PXE Base Code Protocol is about to transmit, has
received, or is waiting to receive a packet.
@@ -2236,8 +2253,8 @@ EfiPxeLoadFileCallback (
IN EFI_PXE_BASE_CODE_PACKET *PacketPtr OPTIONAL
)
{
- EFI_INPUT_KEY Key;
- EFI_STATUS Status;
+ EFI_INPUT_KEY Key;
+ EFI_STATUS Status;
//
// Catch Ctrl-C or ESC to abort.
@@ -2245,43 +2262,43 @@ EfiPxeLoadFileCallback (
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (!EFI_ERROR (Status)) {
-
- if (Key.ScanCode == SCAN_ESC || Key.UnicodeChar == (0x1F & 'c')) {
-
+ if ((Key.ScanCode == SCAN_ESC) || (Key.UnicodeChar == (0x1F & 'c'))) {
return EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT;
}
}
+
//
// No print if receive packet
//
if (Received) {
return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
}
+
//
// Print only for three functions
//
switch (Function) {
-
- case EFI_PXE_BASE_CODE_FUNCTION_MTFTP:
- //
- // Print only for open MTFTP packets, not every MTFTP packets
- //
- if (PacketLength != 0 && PacketPtr != NULL) {
- if (PacketPtr->Raw[0x1C] != 0x00 || PacketPtr->Raw[0x1D] != 0x01) {
- return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
+ case EFI_PXE_BASE_CODE_FUNCTION_MTFTP:
+ //
+ // Print only for open MTFTP packets, not every MTFTP packets
+ //
+ if ((PacketLength != 0) && (PacketPtr != NULL)) {
+ if ((PacketPtr->Raw[0x1C] != 0x00) || (PacketPtr->Raw[0x1D] != 0x01)) {
+ return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
+ }
}
- }
- break;
- case EFI_PXE_BASE_CODE_FUNCTION_DHCP:
- case EFI_PXE_BASE_CODE_FUNCTION_DISCOVER:
- break;
+ break;
- default:
- return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
+ case EFI_PXE_BASE_CODE_FUNCTION_DHCP:
+ case EFI_PXE_BASE_CODE_FUNCTION_DISCOVER:
+ break;
+
+ default:
+ return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
}
- if (PacketLength != 0 && PacketPtr != NULL) {
+ if ((PacketLength != 0) && (PacketPtr != NULL)) {
//
// Print '.' when transmit a packet
//
@@ -2291,12 +2308,11 @@ EfiPxeLoadFileCallback (
return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
}
-EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL gPxeBcCallBackTemplate = {
+EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL gPxeBcCallBackTemplate = {
EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION,
EfiPxeLoadFileCallback
};
-
/**
Causes the driver to load a specified file.
@@ -2328,11 +2344,11 @@ EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL gPxe
EFI_STATUS
EFIAPI
EfiPxeLoadFile (
- IN EFI_LOAD_FILE_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN BOOLEAN BootPolicy,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer OPTIONAL
+ IN EFI_LOAD_FILE_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN BOOLEAN BootPolicy,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer OPTIONAL
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -2342,7 +2358,7 @@ EfiPxeLoadFile (
EFI_STATUS Status;
EFI_STATUS MediaStatus;
- if (This == NULL || BufferSize == NULL || FilePath == NULL || !IsDevicePathEnd (FilePath)) {
+ if ((This == NULL) || (BufferSize == NULL) || (FilePath == NULL) || !IsDevicePathEnd (FilePath)) {
return EFI_INVALID_PARAMETER;
}
@@ -2379,7 +2395,7 @@ EfiPxeLoadFile (
// Start Pxe Base Code to initialize PXE boot.
//
Status = PxeBc->Start (PxeBc, UsingIpv6);
- if (Status == EFI_ALREADY_STARTED && UsingIpv6 != PxeBc->Mode->UsingIpv6) {
+ if ((Status == EFI_ALREADY_STARTED) && (UsingIpv6 != PxeBc->Mode->UsingIpv6)) {
//
// PxeBc protocol has already been started but not on the required IP version, restart it.
//
@@ -2388,13 +2404,15 @@ EfiPxeLoadFile (
Status = PxeBc->Start (PxeBc, UsingIpv6);
}
}
- if (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED) {
+
+ if ((Status == EFI_SUCCESS) || (Status == EFI_ALREADY_STARTED)) {
Status = PxeBcLoadBootFile (Private, BufferSize, Buffer);
}
- if (Status != EFI_SUCCESS &&
- Status != EFI_UNSUPPORTED &&
- Status != EFI_BUFFER_TOO_SMALL) {
+ if ((Status != EFI_SUCCESS) &&
+ (Status != EFI_UNSUPPORTED) &&
+ (Status != EFI_BUFFER_TOO_SMALL))
+ {
//
// There are three cases, which needn't stop pxebc here.
// 1. success to download file.
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
@@ -49,9 +49,9 @@
#include <Library/DevicePathLib.h>
#include <Library/PcdLib.h>
-typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
-typedef struct _PXEBC_PRIVATE_PROTOCOL PXEBC_PRIVATE_PROTOCOL;
-typedef struct _PXEBC_VIRTUAL_NIC PXEBC_VIRTUAL_NIC;
+typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
+typedef struct _PXEBC_PRIVATE_PROTOCOL PXEBC_PRIVATE_PROTOCOL;
+typedef struct _PXEBC_VIRTUAL_NIC PXEBC_VIRTUAL_NIC;
#include "PxeBcDriver.h"
#include "PxeBcDhcp4.h"
@@ -60,131 +60,131 @@ typedef struct _PXEBC_VIRTUAL_NIC PXEB
#include "PxeBcBoot.h"
#include "PxeBcSupport.h"
-#define PXEBC_DEFAULT_HOPLIMIT 64
-#define PXEBC_DEFAULT_LIFETIME 50000 // 50 ms, unit is microsecond
-#define PXEBC_UDP_TIMEOUT 30000000 // 3 seconds, unit is 100nanosecond
-#define PXEBC_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
-#define PXEBC_MTFTP_TIMEOUT 4
-#define PXEBC_MTFTP_RETRIES 6
-#define PXEBC_DHCP_RETRIES 4 // refers to mPxeDhcpTimeout, also by PXE2.1 spec.
-#define PXEBC_MENU_MAX_NUM 24
-#define PXEBC_OFFER_MAX_NUM 16
-
-#define PXEBC_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
-
-#define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
-#define PXEBC_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'V')
-#define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
-#define PXEBC_PRIVATE_DATA_FROM_ID(a) CR (a, PXEBC_PRIVATE_DATA, Id, PXEBC_PRIVATE_DATA_SIGNATURE)
-#define PXEBC_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, PXEBC_VIRTUAL_NIC, LoadFile, PXEBC_VIRTUAL_NIC_SIGNATURE)
+#define PXEBC_DEFAULT_HOPLIMIT 64
+#define PXEBC_DEFAULT_LIFETIME 50000 // 50 ms, unit is microsecond
+#define PXEBC_UDP_TIMEOUT 30000000 // 3 seconds, unit is 100nanosecond
+#define PXEBC_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
+#define PXEBC_MTFTP_TIMEOUT 4
+#define PXEBC_MTFTP_RETRIES 6
+#define PXEBC_DHCP_RETRIES 4 // refers to mPxeDhcpTimeout, also by PXE2.1 spec.
+#define PXEBC_MENU_MAX_NUM 24
+#define PXEBC_OFFER_MAX_NUM 16
+
+#define PXEBC_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
+
+#define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
+#define PXEBC_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'V')
+#define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
+#define PXEBC_PRIVATE_DATA_FROM_ID(a) CR (a, PXEBC_PRIVATE_DATA, Id, PXEBC_PRIVATE_DATA_SIGNATURE)
+#define PXEBC_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, PXEBC_VIRTUAL_NIC, LoadFile, PXEBC_VIRTUAL_NIC_SIGNATURE)
-#define PXE_ENABLED 0x01
-#define PXE_DISABLED 0x00
+#define PXE_ENABLED 0x01
+#define PXE_DISABLED 0x00
typedef union {
- PXEBC_DHCP4_PACKET_CACHE Dhcp4;
- PXEBC_DHCP6_PACKET_CACHE Dhcp6;
+ PXEBC_DHCP4_PACKET_CACHE Dhcp4;
+ PXEBC_DHCP6_PACKET_CACHE Dhcp6;
} PXEBC_DHCP_PACKET_CACHE;
struct _PXEBC_PRIVATE_PROTOCOL {
- UINT64 Reserved;
+ UINT64 Reserved;
};
struct _PXEBC_VIRTUAL_NIC {
- UINT32 Signature;
- EFI_HANDLE Controller;
- EFI_LOAD_FILE_PROTOCOL LoadFile;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- PXEBC_PRIVATE_DATA *Private;
+ UINT32 Signature;
+ EFI_HANDLE Controller;
+ EFI_LOAD_FILE_PROTOCOL LoadFile;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ PXEBC_PRIVATE_DATA *Private;
};
struct _PXEBC_PRIVATE_DATA {
- UINT32 Signature;
- EFI_HANDLE Controller;
- EFI_HANDLE Image;
-
- PXEBC_PRIVATE_PROTOCOL Id;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
-
- PXEBC_VIRTUAL_NIC *Ip4Nic;
- PXEBC_VIRTUAL_NIC *Ip6Nic;
-
- EFI_HANDLE ArpChild;
- EFI_HANDLE Ip4Child;
- EFI_HANDLE Dhcp4Child;
- EFI_HANDLE Mtftp4Child;
- EFI_HANDLE Udp4ReadChild;
- EFI_HANDLE Udp4WriteChild;
-
- EFI_ARP_PROTOCOL *Arp;
- EFI_IP4_PROTOCOL *Ip4;
- EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
- EFI_DHCP4_PROTOCOL *Dhcp4;
- EFI_MTFTP4_PROTOCOL *Mtftp4;
- EFI_UDP4_PROTOCOL *Udp4Read;
- EFI_UDP4_PROTOCOL *Udp4Write;
-
- EFI_HANDLE Ip6Child;
- EFI_HANDLE Dhcp6Child;
- EFI_HANDLE Mtftp6Child;
- EFI_HANDLE Udp6ReadChild;
- EFI_HANDLE Udp6WriteChild;
-
- EFI_IP6_PROTOCOL *Ip6;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
- EFI_DHCP6_PROTOCOL *Dhcp6;
- EFI_MTFTP6_PROTOCOL *Mtftp6;
- EFI_UDP6_PROTOCOL *Udp6Read;
- EFI_UDP6_PROTOCOL *Udp6Write;
- EFI_DNS6_PROTOCOL *Dns6;
-
- EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
- EFI_PXE_BASE_CODE_PROTOCOL PxeBc;
- EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback;
- EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *PxeBcCallback;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- EFI_PXE_BASE_CODE_MODE Mode;
- EFI_PXE_BASE_CODE_FUNCTION Function;
- UINT32 Ip6Policy;
- UINT32 SolicitTimes;
- UINT64 ElapsedTime;
-
- EFI_UDP4_CONFIG_DATA Udp4CfgData;
- EFI_UDP6_CONFIG_DATA Udp6CfgData;
- EFI_IP4_CONFIG_DATA Ip4CfgData;
- EFI_IP6_CONFIG_DATA Ip6CfgData;
-
- EFI_EVENT UdpTimeOutEvent;
- EFI_EVENT ArpUpdateEvent;
- EFI_IP4_COMPLETION_TOKEN IcmpToken;
- EFI_IP6_COMPLETION_TOKEN Icmp6Token;
-
- BOOLEAN IsAddressOk;
- BOOLEAN IsOfferSorted;
- BOOLEAN IsProxyRecved;
- BOOLEAN IsDoDiscover;
-
- EFI_IP_ADDRESS TmpStationIp;
- EFI_IP_ADDRESS StationIp;
- EFI_IP_ADDRESS SubnetMask;
- EFI_IP_ADDRESS GatewayIp;
- EFI_IP_ADDRESS ServerIp;
- EFI_IPv6_ADDRESS *DnsServer;
- UINT16 CurSrcPort;
- UINT32 IaId;
-
- UINT32 Ip4MaxPacketSize;
- UINT32 Ip6MaxPacketSize;
- UINT8 *BootFileName;
- UINTN BootFileSize;
- UINTN BlockSize;
-
- PXEBC_DHCP_PACKET_CACHE ProxyOffer;
- PXEBC_DHCP_PACKET_CACHE DhcpAck;
- PXEBC_DHCP_PACKET_CACHE PxeReply;
- EFI_DHCP6_PACKET *Dhcp6Request;
- EFI_DHCP4_PACKET SeedPacket;
+ UINT32 Signature;
+ EFI_HANDLE Controller;
+ EFI_HANDLE Image;
+
+ PXEBC_PRIVATE_PROTOCOL Id;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+
+ PXEBC_VIRTUAL_NIC *Ip4Nic;
+ PXEBC_VIRTUAL_NIC *Ip6Nic;
+
+ EFI_HANDLE ArpChild;
+ EFI_HANDLE Ip4Child;
+ EFI_HANDLE Dhcp4Child;
+ EFI_HANDLE Mtftp4Child;
+ EFI_HANDLE Udp4ReadChild;
+ EFI_HANDLE Udp4WriteChild;
+
+ EFI_ARP_PROTOCOL *Arp;
+ EFI_IP4_PROTOCOL *Ip4;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
+ EFI_DHCP4_PROTOCOL *Dhcp4;
+ EFI_MTFTP4_PROTOCOL *Mtftp4;
+ EFI_UDP4_PROTOCOL *Udp4Read;
+ EFI_UDP4_PROTOCOL *Udp4Write;
+
+ EFI_HANDLE Ip6Child;
+ EFI_HANDLE Dhcp6Child;
+ EFI_HANDLE Mtftp6Child;
+ EFI_HANDLE Udp6ReadChild;
+ EFI_HANDLE Udp6WriteChild;
+
+ EFI_IP6_PROTOCOL *Ip6;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
+ EFI_DHCP6_PROTOCOL *Dhcp6;
+ EFI_MTFTP6_PROTOCOL *Mtftp6;
+ EFI_UDP6_PROTOCOL *Udp6Read;
+ EFI_UDP6_PROTOCOL *Udp6Write;
+ EFI_DNS6_PROTOCOL *Dns6;
+
+ EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
+ EFI_PXE_BASE_CODE_PROTOCOL PxeBc;
+ EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback;
+ EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *PxeBcCallback;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ EFI_PXE_BASE_CODE_MODE Mode;
+ EFI_PXE_BASE_CODE_FUNCTION Function;
+ UINT32 Ip6Policy;
+ UINT32 SolicitTimes;
+ UINT64 ElapsedTime;
+
+ EFI_UDP4_CONFIG_DATA Udp4CfgData;
+ EFI_UDP6_CONFIG_DATA Udp6CfgData;
+ EFI_IP4_CONFIG_DATA Ip4CfgData;
+ EFI_IP6_CONFIG_DATA Ip6CfgData;
+
+ EFI_EVENT UdpTimeOutEvent;
+ EFI_EVENT ArpUpdateEvent;
+ EFI_IP4_COMPLETION_TOKEN IcmpToken;
+ EFI_IP6_COMPLETION_TOKEN Icmp6Token;
+
+ BOOLEAN IsAddressOk;
+ BOOLEAN IsOfferSorted;
+ BOOLEAN IsProxyRecved;
+ BOOLEAN IsDoDiscover;
+
+ EFI_IP_ADDRESS TmpStationIp;
+ EFI_IP_ADDRESS StationIp;
+ EFI_IP_ADDRESS SubnetMask;
+ EFI_IP_ADDRESS GatewayIp;
+ EFI_IP_ADDRESS ServerIp;
+ EFI_IPv6_ADDRESS *DnsServer;
+ UINT16 CurSrcPort;
+ UINT32 IaId;
+
+ UINT32 Ip4MaxPacketSize;
+ UINT32 Ip6MaxPacketSize;
+ UINT8 *BootFileName;
+ UINTN BootFileSize;
+ UINTN BlockSize;
+
+ PXEBC_DHCP_PACKET_CACHE ProxyOffer;
+ PXEBC_DHCP_PACKET_CACHE DhcpAck;
+ PXEBC_DHCP_PACKET_CACHE PxeReply;
+ EFI_DHCP6_PACKET *Dhcp6Request;
+ EFI_DHCP4_PACKET SeedPacket;
//
// OfferIndex records the index of DhcpOffer[] buffer, and OfferCount records the num of each type of offer.
@@ -213,12 +213,12 @@ struct _PXEBC_PRIVATE_DATA {
// (OfferIndex is 0-based.)
//
//
- UINT32 SelectIndex;
- UINT32 SelectProxyType;
- PXEBC_DHCP_PACKET_CACHE OfferBuffer[PXEBC_OFFER_MAX_NUM];
- UINT32 OfferNum;
- UINT32 OfferCount[PxeOfferTypeMax];
- UINT32 OfferIndex[PxeOfferTypeMax][PXEBC_OFFER_MAX_NUM];
+ UINT32 SelectIndex;
+ UINT32 SelectProxyType;
+ PXEBC_DHCP_PACKET_CACHE OfferBuffer[PXEBC_OFFER_MAX_NUM];
+ UINT32 OfferNum;
+ UINT32 OfferCount[PxeOfferTypeMax];
+ UINT32 OfferIndex[PxeOfferTypeMax][PXEBC_OFFER_MAX_NUM];
};
extern EFI_PXE_BASE_CODE_PROTOCOL gPxeBcProtocolTemplate;
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c
@@ -9,7 +9,7 @@
#include "PxeBcImpl.h"
-CHAR8 *mMtftpOptions[PXE_MTFTP_OPTION_MAXIMUM_INDEX] = {
+CHAR8 *mMtftpOptions[PXE_MTFTP_OPTION_MAXIMUM_INDEX] = {
"blksize",
"timeout",
"tsize",
@@ -17,7 +17,6 @@ CHAR8 *mMtftpOptions[PXE_MTFTP_OPTION_MA
"windowsize"
};
-
/**
This is a callback function when packets are received or transmitted in Mtftp driver.
@@ -39,30 +38,30 @@ CHAR8 *mMtftpOptions[PXE_MTFTP_OPTION_MA
EFI_STATUS
EFIAPI
PxeBcMtftp6CheckPacket (
- IN EFI_MTFTP6_PROTOCOL *This,
- IN EFI_MTFTP6_TOKEN *Token,
- IN UINT16 PacketLen,
- IN EFI_MTFTP6_PACKET *Packet
+ IN EFI_MTFTP6_PROTOCOL *This,
+ IN EFI_MTFTP6_TOKEN *Token,
+ IN UINT16 PacketLen,
+ IN EFI_MTFTP6_PACKET *Packet
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
- EFI_STATUS Status;
-
- Private = (PXEBC_PRIVATE_DATA *) Token->Context;
- Callback = Private->PxeBcCallback;
- Status = EFI_SUCCESS;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
+ EFI_STATUS Status;
+
+ Private = (PXEBC_PRIVATE_DATA *)Token->Context;
+ Callback = Private->PxeBcCallback;
+ Status = EFI_SUCCESS;
if (Packet->OpCode == EFI_MTFTP6_OPCODE_ERROR) {
//
// Store the tftp error message into mode data and set the received flag.
//
Private->Mode.TftpErrorReceived = TRUE;
- Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode;
+ Private->Mode.TftpError.ErrorCode = (UINT8)Packet->Error.ErrorCode;
AsciiStrnCpyS (
Private->Mode.TftpError.ErrorString,
PXE_MTFTP_ERROR_STRING_LENGTH,
- (CHAR8 *) Packet->Error.ErrorMessage,
+ (CHAR8 *)Packet->Error.ErrorMessage,
PXE_MTFTP_ERROR_STRING_LENGTH - 1
);
Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
@@ -73,12 +72,12 @@ PxeBcMtftp6CheckPacket (
// Callback to user if has when received any tftp packet.
//
Status = Callback->Callback (
- Callback,
- Private->Function,
- TRUE,
- PacketLen,
- (EFI_PXE_BASE_CODE_PACKET *) Packet
- );
+ Callback,
+ Private->Function,
+ TRUE,
+ PacketLen,
+ (EFI_PXE_BASE_CODE_PACKET *)Packet
+ );
if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
//
// User wants to abort current process if not EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE.
@@ -95,7 +94,6 @@ PxeBcMtftp6CheckPacket (
return Status;
}
-
/**
This function is to get the size of a file using Tftp.
@@ -114,23 +112,23 @@ PxeBcMtftp6CheckPacket (
**/
EFI_STATUS
PxeBcMtftp6GetFileSize (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_MTFTP6_CONFIG_DATA *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN OUT UINT64 *BufferSize
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_MTFTP6_CONFIG_DATA *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN OUT UINT64 *BufferSize
)
{
- EFI_MTFTP6_PROTOCOL *Mtftp6;
- EFI_MTFTP6_OPTION ReqOpt[3];
- EFI_MTFTP6_PACKET *Packet;
- EFI_MTFTP6_OPTION *Option;
- UINT32 PktLen;
- UINT8 OptBuf[PXE_MTFTP_OPTBUF_MAXNUM_INDEX];
- UINTN OptBufSize;
- UINT32 OptCnt;
- EFI_STATUS Status;
+ EFI_MTFTP6_PROTOCOL *Mtftp6;
+ EFI_MTFTP6_OPTION ReqOpt[3];
+ EFI_MTFTP6_PACKET *Packet;
+ EFI_MTFTP6_OPTION *Option;
+ UINT32 PktLen;
+ UINT8 OptBuf[PXE_MTFTP_OPTBUF_MAXNUM_INDEX];
+ UINTN OptBufSize;
+ UINT32 OptCnt;
+ EFI_STATUS Status;
*BufferSize = 0;
Status = EFI_DEVICE_ERROR;
@@ -150,22 +148,22 @@ PxeBcMtftp6GetFileSize (
//
// Build the required options for get info.
//
- ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX];
+ ReqOpt[0].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX];
PxeBcUintnToAscDec (0, OptBuf, OptBufSize);
- ReqOpt[0].ValueStr = OptBuf;
+ ReqOpt[0].ValueStr = OptBuf;
if (BlockSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
- ReqOpt[OptCnt].ValueStr = (UINT8 *) (ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[OptCnt-1].ValueStr) + 1);
- OptBufSize -= (AsciiStrLen ((CHAR8 *) ReqOpt[OptCnt-1].ValueStr) + 1);
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
+ ReqOpt[OptCnt].ValueStr = (UINT8 *)(ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);
+ OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);
PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, OptBufSize);
OptCnt++;
}
if (WindowSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
- ReqOpt[OptCnt].ValueStr = (UINT8 *) (ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[OptCnt-1].ValueStr) + 1);
- OptBufSize -= (AsciiStrLen ((CHAR8 *) ReqOpt[OptCnt-1].ValueStr) + 1);
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
+ ReqOpt[OptCnt].ValueStr = (UINT8 *)(ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);
+ OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);
PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, OptBufSize);
OptCnt++;
}
@@ -175,7 +173,7 @@ PxeBcMtftp6GetFileSize (
NULL,
Filename,
NULL,
- (UINT8) OptCnt,
+ (UINT8)OptCnt,
ReqOpt,
&PktLen,
&Packet
@@ -186,15 +184,16 @@ PxeBcMtftp6GetFileSize (
// Store the tftp error message into mode data and set the received flag.
//
Private->Mode.TftpErrorReceived = TRUE;
- Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode;
+ Private->Mode.TftpError.ErrorCode = (UINT8)Packet->Error.ErrorCode;
AsciiStrnCpyS (
Private->Mode.TftpError.ErrorString,
PXE_MTFTP_ERROR_STRING_LENGTH,
- (CHAR8 *) Packet->Error.ErrorMessage,
+ (CHAR8 *)Packet->Error.ErrorMessage,
PXE_MTFTP_ERROR_STRING_LENGTH - 1
);
Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
}
+
goto ON_ERROR;
}
@@ -206,7 +205,7 @@ PxeBcMtftp6GetFileSize (
Mtftp6,
PktLen,
Packet,
- (UINT32 *) &OptCnt,
+ (UINT32 *)&OptCnt,
&Option
);
if (EFI_ERROR (Status)) {
@@ -218,24 +217,26 @@ PxeBcMtftp6GetFileSize (
//
Status = EFI_NOT_FOUND;
while (OptCnt != 0) {
- if (AsciiStrnCmp ((CHAR8 *) Option[OptCnt - 1].OptionStr, "tsize", 5) == 0) {
- *BufferSize = AsciiStrDecimalToUint64 ((CHAR8 *) (Option[OptCnt - 1].ValueStr));
+ if (AsciiStrnCmp ((CHAR8 *)Option[OptCnt - 1].OptionStr, "tsize", 5) == 0) {
+ *BufferSize = AsciiStrDecimalToUint64 ((CHAR8 *)(Option[OptCnt - 1].ValueStr));
Status = EFI_SUCCESS;
}
+
OptCnt--;
}
+
FreePool (Option);
ON_ERROR:
if (Packet != NULL) {
FreePool (Packet);
}
+
Mtftp6->Configure (Mtftp6, NULL);
return Status;
}
-
/**
This function is to get data of a file using Tftp.
@@ -255,23 +256,23 @@ ON_ERROR:
**/
EFI_STATUS
PxeBcMtftp6ReadFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_MTFTP6_CONFIG_DATA *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize,
- IN BOOLEAN DontUseBuffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_MTFTP6_CONFIG_DATA *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize,
+ IN BOOLEAN DontUseBuffer
)
{
- EFI_MTFTP6_PROTOCOL *Mtftp6;
- EFI_MTFTP6_TOKEN Token;
- EFI_MTFTP6_OPTION ReqOpt[2];
- UINT32 OptCnt;
- UINT8 BlksizeBuf[10];
- UINT8 WindowsizeBuf[10];
- EFI_STATUS Status;
+ EFI_MTFTP6_PROTOCOL *Mtftp6;
+ EFI_MTFTP6_TOKEN Token;
+ EFI_MTFTP6_OPTION ReqOpt[2];
+ UINT32 OptCnt;
+ UINT8 BlksizeBuf[10];
+ UINT8 WindowsizeBuf[10];
+ EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp6 = Private->Mtftp6;
@@ -284,34 +285,33 @@ PxeBcMtftp6ReadFile (
}
if (BlockSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[OptCnt].ValueStr = BlksizeBuf;
PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, sizeof (BlksizeBuf));
OptCnt++;
}
if (WindowSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
ReqOpt[OptCnt].ValueStr = WindowsizeBuf;
PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, sizeof (WindowsizeBuf));
OptCnt++;
}
-
- Token.Event = NULL;
- Token.OverrideData = NULL;
- Token.Filename = Filename;
- Token.ModeStr = NULL;
- Token.OptionCount = OptCnt;
- Token.OptionList = ReqOpt;
- Token.Context = Private;
+ Token.Event = NULL;
+ Token.OverrideData = NULL;
+ Token.Filename = Filename;
+ Token.ModeStr = NULL;
+ Token.OptionCount = OptCnt;
+ Token.OptionList = ReqOpt;
+ Token.Context = Private;
if (DontUseBuffer) {
- Token.BufferSize = 0;
- Token.Buffer = NULL;
+ Token.BufferSize = 0;
+ Token.Buffer = NULL;
} else {
- Token.BufferSize = *BufferSize;
- Token.Buffer = BufferPtr;
+ Token.BufferSize = *BufferSize;
+ Token.Buffer = BufferPtr;
}
Token.CheckPacket = PxeBcMtftp6CheckPacket;
@@ -329,7 +329,6 @@ PxeBcMtftp6ReadFile (
return Status;
}
-
/**
This function is used to write the data of a file using Tftp.
@@ -348,21 +347,21 @@ PxeBcMtftp6ReadFile (
**/
EFI_STATUS
PxeBcMtftp6WriteFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_MTFTP6_CONFIG_DATA *Config,
- IN UINT8 *Filename,
- IN BOOLEAN Overwrite,
- IN UINTN *BlockSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_MTFTP6_CONFIG_DATA *Config,
+ IN UINT8 *Filename,
+ IN BOOLEAN Overwrite,
+ IN UINTN *BlockSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize
)
{
- EFI_MTFTP6_PROTOCOL *Mtftp6;
- EFI_MTFTP6_TOKEN Token;
- EFI_MTFTP6_OPTION ReqOpt[1];
- UINT32 OptCnt;
- UINT8 OptBuf[128];
- EFI_STATUS Status;
+ EFI_MTFTP6_PROTOCOL *Mtftp6;
+ EFI_MTFTP6_TOKEN Token;
+ EFI_MTFTP6_OPTION ReqOpt[1];
+ UINT32 OptCnt;
+ UINT8 OptBuf[128];
+ EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp6 = Private->Mtftp6;
@@ -375,7 +374,7 @@ PxeBcMtftp6WriteFile (
}
if (BlockSize != NULL) {
- ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
+ ReqOpt[0].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[0].ValueStr = OptBuf;
PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
OptCnt++;
@@ -404,7 +403,6 @@ PxeBcMtftp6WriteFile (
return Status;
}
-
/**
This function is to read the data (file) from a directory using Tftp.
@@ -424,23 +422,23 @@ PxeBcMtftp6WriteFile (
**/
EFI_STATUS
PxeBcMtftp6ReadDirectory (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_MTFTP6_CONFIG_DATA *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize,
- IN BOOLEAN DontUseBuffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_MTFTP6_CONFIG_DATA *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize,
+ IN BOOLEAN DontUseBuffer
)
{
- EFI_MTFTP6_PROTOCOL *Mtftp6;
- EFI_MTFTP6_TOKEN Token;
- EFI_MTFTP6_OPTION ReqOpt[2];
- UINT32 OptCnt;
- UINT8 BlksizeBuf[10];
- UINT8 WindowsizeBuf[10];
- EFI_STATUS Status;
+ EFI_MTFTP6_PROTOCOL *Mtftp6;
+ EFI_MTFTP6_TOKEN Token;
+ EFI_MTFTP6_OPTION ReqOpt[2];
+ UINT32 OptCnt;
+ UINT8 BlksizeBuf[10];
+ UINT8 WindowsizeBuf[10];
+ EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp6 = Private->Mtftp6;
@@ -453,33 +451,33 @@ PxeBcMtftp6ReadDirectory (
}
if (BlockSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[OptCnt].ValueStr = BlksizeBuf;
PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, sizeof (BlksizeBuf));
OptCnt++;
}
if (WindowSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
ReqOpt[OptCnt].ValueStr = WindowsizeBuf;
PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, sizeof (WindowsizeBuf));
OptCnt++;
}
- Token.Event = NULL;
- Token.OverrideData = NULL;
- Token.Filename = Filename;
- Token.ModeStr = NULL;
- Token.OptionCount = OptCnt;
- Token.OptionList = ReqOpt;
- Token.Context = Private;
+ Token.Event = NULL;
+ Token.OverrideData = NULL;
+ Token.Filename = Filename;
+ Token.ModeStr = NULL;
+ Token.OptionCount = OptCnt;
+ Token.OptionList = ReqOpt;
+ Token.Context = Private;
if (DontUseBuffer) {
- Token.BufferSize = 0;
- Token.Buffer = NULL;
+ Token.BufferSize = 0;
+ Token.Buffer = NULL;
} else {
- Token.BufferSize = *BufferSize;
- Token.Buffer = BufferPtr;
+ Token.BufferSize = *BufferSize;
+ Token.Buffer = BufferPtr;
}
Token.CheckPacket = PxeBcMtftp6CheckPacket;
@@ -497,7 +495,6 @@ PxeBcMtftp6ReadDirectory (
return Status;
}
-
/**
This is a callback function when packets are received or transmitted in Mtftp driver.
@@ -519,30 +516,30 @@ PxeBcMtftp6ReadDirectory (
EFI_STATUS
EFIAPI
PxeBcMtftp4CheckPacket (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_TOKEN *Token,
- IN UINT16 PacketLen,
- IN EFI_MTFTP4_PACKET *Packet
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token,
+ IN UINT16 PacketLen,
+ IN EFI_MTFTP4_PACKET *Packet
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
- EFI_STATUS Status;
-
- Private = (PXEBC_PRIVATE_DATA *) Token->Context;
- Callback = Private->PxeBcCallback;
- Status = EFI_SUCCESS;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
+ EFI_STATUS Status;
+
+ Private = (PXEBC_PRIVATE_DATA *)Token->Context;
+ Callback = Private->PxeBcCallback;
+ Status = EFI_SUCCESS;
if (Packet->OpCode == EFI_MTFTP4_OPCODE_ERROR) {
//
// Store the tftp error message into mode data and set the received flag.
//
Private->Mode.TftpErrorReceived = TRUE;
- Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode;
+ Private->Mode.TftpError.ErrorCode = (UINT8)Packet->Error.ErrorCode;
AsciiStrnCpyS (
Private->Mode.TftpError.ErrorString,
PXE_MTFTP_ERROR_STRING_LENGTH,
- (CHAR8 *) Packet->Error.ErrorMessage,
+ (CHAR8 *)Packet->Error.ErrorMessage,
PXE_MTFTP_ERROR_STRING_LENGTH - 1
);
Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
@@ -553,12 +550,12 @@ PxeBcMtftp4CheckPacket (
// Callback to user if has when received any tftp packet.
//
Status = Callback->Callback (
- Callback,
- Private->Function,
- TRUE,
- PacketLen,
- (EFI_PXE_BASE_CODE_PACKET *) Packet
- );
+ Callback,
+ Private->Function,
+ TRUE,
+ PacketLen,
+ (EFI_PXE_BASE_CODE_PACKET *)Packet
+ );
if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
//
// User wants to abort current process if not EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE.
@@ -575,7 +572,6 @@ PxeBcMtftp4CheckPacket (
return Status;
}
-
/**
This function is to get size of a file using Tftp.
@@ -594,23 +590,23 @@ PxeBcMtftp4CheckPacket (
**/
EFI_STATUS
PxeBcMtftp4GetFileSize (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_MTFTP4_CONFIG_DATA *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN OUT UINT64 *BufferSize
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_MTFTP4_CONFIG_DATA *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN OUT UINT64 *BufferSize
)
{
- EFI_MTFTP4_PROTOCOL *Mtftp4;
- EFI_MTFTP4_OPTION ReqOpt[3];
- EFI_MTFTP4_PACKET *Packet;
- EFI_MTFTP4_OPTION *Option;
- UINT32 PktLen;
- UINT8 OptBuf[PXE_MTFTP_OPTBUF_MAXNUM_INDEX];
- UINTN OptBufSize;
- UINT32 OptCnt;
- EFI_STATUS Status;
+ EFI_MTFTP4_PROTOCOL *Mtftp4;
+ EFI_MTFTP4_OPTION ReqOpt[3];
+ EFI_MTFTP4_PACKET *Packet;
+ EFI_MTFTP4_OPTION *Option;
+ UINT32 PktLen;
+ UINT8 OptBuf[PXE_MTFTP_OPTBUF_MAXNUM_INDEX];
+ UINTN OptBufSize;
+ UINT32 OptCnt;
+ EFI_STATUS Status;
*BufferSize = 0;
Status = EFI_DEVICE_ERROR;
@@ -630,22 +626,22 @@ PxeBcMtftp4GetFileSize (
//
// Build the required options for get info.
//
- ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX];
+ ReqOpt[0].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX];
PxeBcUintnToAscDec (0, OptBuf, OptBufSize);
- ReqOpt[0].ValueStr = OptBuf;
+ ReqOpt[0].ValueStr = OptBuf;
if (BlockSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
- ReqOpt[OptCnt].ValueStr = (UINT8 *) (ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[OptCnt-1].ValueStr) + 1);
- OptBufSize -= (AsciiStrLen ((CHAR8 *) ReqOpt[OptCnt-1].ValueStr) + 1);
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
+ ReqOpt[OptCnt].ValueStr = (UINT8 *)(ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);
+ OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);
PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, OptBufSize);
OptCnt++;
}
if (WindowSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
- ReqOpt[OptCnt].ValueStr = (UINT8 *) (ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[OptCnt-1].ValueStr) + 1);
- OptBufSize -= (AsciiStrLen ((CHAR8 *) ReqOpt[OptCnt-1].ValueStr) + 1);
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
+ ReqOpt[OptCnt].ValueStr = (UINT8 *)(ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);
+ OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);
PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, OptBufSize);
OptCnt++;
}
@@ -655,7 +651,7 @@ PxeBcMtftp4GetFileSize (
NULL,
Filename,
NULL,
- (UINT8) OptCnt,
+ (UINT8)OptCnt,
ReqOpt,
&PktLen,
&Packet
@@ -666,15 +662,16 @@ PxeBcMtftp4GetFileSize (
// Store the tftp error message into mode data and set the received flag.
//
Private->Mode.TftpErrorReceived = TRUE;
- Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode;
+ Private->Mode.TftpError.ErrorCode = (UINT8)Packet->Error.ErrorCode;
AsciiStrnCpyS (
Private->Mode.TftpError.ErrorString,
PXE_MTFTP_ERROR_STRING_LENGTH,
- (CHAR8 *) Packet->Error.ErrorMessage,
+ (CHAR8 *)Packet->Error.ErrorMessage,
PXE_MTFTP_ERROR_STRING_LENGTH - 1
);
Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
}
+
goto ON_ERROR;
}
@@ -686,7 +683,7 @@ PxeBcMtftp4GetFileSize (
Mtftp4,
PktLen,
Packet,
- (UINT32 *) &OptCnt,
+ (UINT32 *)&OptCnt,
&Option
);
if (EFI_ERROR (Status)) {
@@ -698,24 +695,26 @@ PxeBcMtftp4GetFileSize (
//
Status = EFI_NOT_FOUND;
while (OptCnt != 0) {
- if (AsciiStrnCmp ((CHAR8 *) Option[OptCnt - 1].OptionStr, "tsize", 5) == 0) {
- *BufferSize = AsciiStrDecimalToUint64 ((CHAR8 *) (Option[OptCnt - 1].ValueStr));
+ if (AsciiStrnCmp ((CHAR8 *)Option[OptCnt - 1].OptionStr, "tsize", 5) == 0) {
+ *BufferSize = AsciiStrDecimalToUint64 ((CHAR8 *)(Option[OptCnt - 1].ValueStr));
Status = EFI_SUCCESS;
}
+
OptCnt--;
}
+
FreePool (Option);
ON_ERROR:
if (Packet != NULL) {
FreePool (Packet);
}
+
Mtftp4->Configure (Mtftp4, NULL);
return Status;
}
-
/**
This function is to read the data of a file using Tftp.
@@ -735,23 +734,23 @@ ON_ERROR:
**/
EFI_STATUS
PxeBcMtftp4ReadFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_MTFTP4_CONFIG_DATA *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize,
- IN BOOLEAN DontUseBuffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_MTFTP4_CONFIG_DATA *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize,
+ IN BOOLEAN DontUseBuffer
)
{
- EFI_MTFTP4_PROTOCOL *Mtftp4;
- EFI_MTFTP4_TOKEN Token;
- EFI_MTFTP4_OPTION ReqOpt[2];
- UINT32 OptCnt;
- UINT8 BlksizeBuf[10];
- UINT8 WindowsizeBuf[10];
- EFI_STATUS Status;
+ EFI_MTFTP4_PROTOCOL *Mtftp4;
+ EFI_MTFTP4_TOKEN Token;
+ EFI_MTFTP4_OPTION ReqOpt[2];
+ UINT32 OptCnt;
+ UINT8 BlksizeBuf[10];
+ UINT8 WindowsizeBuf[10];
+ EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp4 = Private->Mtftp4;
@@ -764,33 +763,33 @@ PxeBcMtftp4ReadFile (
}
if (BlockSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[OptCnt].ValueStr = BlksizeBuf;
PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, sizeof (BlksizeBuf));
OptCnt++;
}
if (WindowSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
ReqOpt[OptCnt].ValueStr = WindowsizeBuf;
PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, sizeof (WindowsizeBuf));
OptCnt++;
}
- Token.Event = NULL;
- Token.OverrideData = NULL;
- Token.Filename = Filename;
- Token.ModeStr = NULL;
- Token.OptionCount = OptCnt;
- Token.OptionList = ReqOpt;
- Token.Context = Private;
+ Token.Event = NULL;
+ Token.OverrideData = NULL;
+ Token.Filename = Filename;
+ Token.ModeStr = NULL;
+ Token.OptionCount = OptCnt;
+ Token.OptionList = ReqOpt;
+ Token.Context = Private;
if (DontUseBuffer) {
- Token.BufferSize = 0;
- Token.Buffer = NULL;
+ Token.BufferSize = 0;
+ Token.Buffer = NULL;
} else {
- Token.BufferSize = *BufferSize;
- Token.Buffer = BufferPtr;
+ Token.BufferSize = *BufferSize;
+ Token.Buffer = BufferPtr;
}
Token.CheckPacket = PxeBcMtftp4CheckPacket;
@@ -808,7 +807,6 @@ PxeBcMtftp4ReadFile (
return Status;
}
-
/**
This function is to write the data of a file using Tftp.
@@ -827,34 +825,34 @@ PxeBcMtftp4ReadFile (
**/
EFI_STATUS
PxeBcMtftp4WriteFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_MTFTP4_CONFIG_DATA *Config,
- IN UINT8 *Filename,
- IN BOOLEAN Overwrite,
- IN UINTN *BlockSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_MTFTP4_CONFIG_DATA *Config,
+ IN UINT8 *Filename,
+ IN BOOLEAN Overwrite,
+ IN UINTN *BlockSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize
)
{
- EFI_MTFTP4_PROTOCOL *Mtftp4;
- EFI_MTFTP4_TOKEN Token;
- EFI_MTFTP4_OPTION ReqOpt[1];
- UINT32 OptCnt;
- UINT8 OptBuf[128];
- EFI_STATUS Status;
+ EFI_MTFTP4_PROTOCOL *Mtftp4;
+ EFI_MTFTP4_TOKEN Token;
+ EFI_MTFTP4_OPTION ReqOpt[1];
+ UINT32 OptCnt;
+ UINT8 OptBuf[128];
+ EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp4 = Private->Mtftp4;
OptCnt = 0;
Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
- Status = Mtftp4->Configure (Mtftp4, Config);
+ Status = Mtftp4->Configure (Mtftp4, Config);
if (EFI_ERROR (Status)) {
return Status;
}
if (BlockSize != NULL) {
- ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
+ ReqOpt[0].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[0].ValueStr = OptBuf;
PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
OptCnt++;
@@ -883,7 +881,6 @@ PxeBcMtftp4WriteFile (
return Status;
}
-
/**
This function is to get data (file) from a directory using Tftp.
@@ -903,23 +900,23 @@ PxeBcMtftp4WriteFile (
**/
EFI_STATUS
PxeBcMtftp4ReadDirectory (
- IN PXEBC_PRIVATE_DATA *Private,
- IN EFI_MTFTP4_CONFIG_DATA *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize,
- IN BOOLEAN DontUseBuffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN EFI_MTFTP4_CONFIG_DATA *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize,
+ IN BOOLEAN DontUseBuffer
)
{
- EFI_MTFTP4_PROTOCOL *Mtftp4;
- EFI_MTFTP4_TOKEN Token;
- EFI_MTFTP4_OPTION ReqOpt[2];
- UINT32 OptCnt;
- UINT8 BlksizeBuf[10];
- UINT8 WindowsizeBuf[10];
- EFI_STATUS Status;
+ EFI_MTFTP4_PROTOCOL *Mtftp4;
+ EFI_MTFTP4_TOKEN Token;
+ EFI_MTFTP4_OPTION ReqOpt[2];
+ UINT32 OptCnt;
+ UINT8 BlksizeBuf[10];
+ UINT8 WindowsizeBuf[10];
+ EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp4 = Private->Mtftp4;
@@ -932,33 +929,33 @@ PxeBcMtftp4ReadDirectory (
}
if (BlockSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[OptCnt].ValueStr = BlksizeBuf;
PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, sizeof (BlksizeBuf));
OptCnt++;
}
if (WindowSize != NULL) {
- ReqOpt[OptCnt].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
+ ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX];
ReqOpt[OptCnt].ValueStr = WindowsizeBuf;
PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, sizeof (WindowsizeBuf));
OptCnt++;
}
- Token.Event = NULL;
- Token.OverrideData = NULL;
- Token.Filename = Filename;
- Token.ModeStr = NULL;
- Token.OptionCount = OptCnt;
- Token.OptionList = ReqOpt;
- Token.Context = Private;
+ Token.Event = NULL;
+ Token.OverrideData = NULL;
+ Token.Filename = Filename;
+ Token.ModeStr = NULL;
+ Token.OptionCount = OptCnt;
+ Token.OptionList = ReqOpt;
+ Token.Context = Private;
if (DontUseBuffer) {
- Token.BufferSize = 0;
- Token.Buffer = NULL;
+ Token.BufferSize = 0;
+ Token.Buffer = NULL;
} else {
- Token.BufferSize = *BufferSize;
- Token.Buffer = BufferPtr;
+ Token.BufferSize = *BufferSize;
+ Token.Buffer = BufferPtr;
}
Token.CheckPacket = PxeBcMtftp4CheckPacket;
@@ -976,7 +973,6 @@ PxeBcMtftp4ReadDirectory (
return Status;
}
-
/**
This function is wrapper to get the file size using TFTP.
@@ -995,18 +991,18 @@ PxeBcMtftp4ReadDirectory (
**/
EFI_STATUS
PxeBcTftpGetFileSize (
- IN PXEBC_PRIVATE_DATA *Private,
- IN VOID *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN OUT UINT64 *BufferSize
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN VOID *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN OUT UINT64 *BufferSize
)
{
if (Private->PxeBc.Mode->UsingIpv6) {
return PxeBcMtftp6GetFileSize (
Private,
- (EFI_MTFTP6_CONFIG_DATA *) Config,
+ (EFI_MTFTP6_CONFIG_DATA *)Config,
Filename,
BlockSize,
WindowSize,
@@ -1015,7 +1011,7 @@ PxeBcTftpGetFileSize (
} else {
return PxeBcMtftp4GetFileSize (
Private,
- (EFI_MTFTP4_CONFIG_DATA *) Config,
+ (EFI_MTFTP4_CONFIG_DATA *)Config,
Filename,
BlockSize,
WindowSize,
@@ -1024,7 +1020,6 @@ PxeBcTftpGetFileSize (
}
}
-
/**
This function is a wrapper to get file using TFTP.
@@ -1044,20 +1039,20 @@ PxeBcTftpGetFileSize (
**/
EFI_STATUS
PxeBcTftpReadFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN VOID *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize,
- IN BOOLEAN DontUseBuffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN VOID *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize,
+ IN BOOLEAN DontUseBuffer
)
{
if (Private->PxeBc.Mode->UsingIpv6) {
return PxeBcMtftp6ReadFile (
Private,
- (EFI_MTFTP6_CONFIG_DATA *) Config,
+ (EFI_MTFTP6_CONFIG_DATA *)Config,
Filename,
BlockSize,
WindowSize,
@@ -1068,7 +1063,7 @@ PxeBcTftpReadFile (
} else {
return PxeBcMtftp4ReadFile (
Private,
- (EFI_MTFTP4_CONFIG_DATA *) Config,
+ (EFI_MTFTP4_CONFIG_DATA *)Config,
Filename,
BlockSize,
WindowSize,
@@ -1079,7 +1074,6 @@ PxeBcTftpReadFile (
}
}
-
/**
This function is a wrapper to write file using TFTP.
@@ -1098,19 +1092,19 @@ PxeBcTftpReadFile (
**/
EFI_STATUS
PxeBcTftpWriteFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN VOID *Config,
- IN UINT8 *Filename,
- IN BOOLEAN Overwrite,
- IN UINTN *BlockSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN VOID *Config,
+ IN UINT8 *Filename,
+ IN BOOLEAN Overwrite,
+ IN UINTN *BlockSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize
)
{
if (Private->PxeBc.Mode->UsingIpv6) {
return PxeBcMtftp6WriteFile (
Private,
- (EFI_MTFTP6_CONFIG_DATA *) Config,
+ (EFI_MTFTP6_CONFIG_DATA *)Config,
Filename,
Overwrite,
BlockSize,
@@ -1120,7 +1114,7 @@ PxeBcTftpWriteFile (
} else {
return PxeBcMtftp4WriteFile (
Private,
- (EFI_MTFTP4_CONFIG_DATA *) Config,
+ (EFI_MTFTP4_CONFIG_DATA *)Config,
Filename,
Overwrite,
BlockSize,
@@ -1130,7 +1124,6 @@ PxeBcTftpWriteFile (
}
}
-
/**
This function is a wrapper to get the data (file) from a directory using TFTP.
@@ -1150,20 +1143,20 @@ PxeBcTftpWriteFile (
**/
EFI_STATUS
PxeBcTftpReadDirectory (
- IN PXEBC_PRIVATE_DATA *Private,
- IN VOID *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize,
- IN BOOLEAN DontUseBuffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN VOID *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize,
+ IN BOOLEAN DontUseBuffer
)
{
if (Private->PxeBc.Mode->UsingIpv6) {
return PxeBcMtftp6ReadDirectory (
Private,
- (EFI_MTFTP6_CONFIG_DATA *) Config,
+ (EFI_MTFTP6_CONFIG_DATA *)Config,
Filename,
BlockSize,
WindowSize,
@@ -1174,7 +1167,7 @@ PxeBcTftpReadDirectory (
} else {
return PxeBcMtftp4ReadDirectory (
Private,
- (EFI_MTFTP4_CONFIG_DATA *) Config,
+ (EFI_MTFTP4_CONFIG_DATA *)Config,
Filename,
BlockSize,
WindowSize,
@@ -1184,4 +1177,3 @@ PxeBcTftpReadDirectory (
);
}
}
-
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.h
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.h
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.h
@@ -18,9 +18,8 @@
#define PXE_MTFTP_OPTION_MAXIMUM_INDEX 5
#define PXE_MTFTP_OPTBUF_MAXNUM_INDEX 128
-#define PXE_MTFTP_ERROR_STRING_LENGTH 127 // refer to definition of struct EFI_PXE_BASE_CODE_TFTP_ERROR.
-#define PXE_MTFTP_DEFAULT_BLOCK_SIZE 512 // refer to rfc-1350.
-
+#define PXE_MTFTP_ERROR_STRING_LENGTH 127 // refer to definition of struct EFI_PXE_BASE_CODE_TFTP_ERROR.
+#define PXE_MTFTP_DEFAULT_BLOCK_SIZE 512 // refer to rfc-1350.
/**
This function is wrapper to get the file size using TFTP.
@@ -40,15 +39,14 @@
**/
EFI_STATUS
PxeBcTftpGetFileSize (
- IN PXEBC_PRIVATE_DATA *Private,
- IN VOID *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN OUT UINT64 *BufferSize
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN VOID *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN OUT UINT64 *BufferSize
);
-
/**
This function is a wrapper to get a file using TFTP.
@@ -68,17 +66,16 @@ PxeBcTftpGetFileSize (
**/
EFI_STATUS
PxeBcTftpReadFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN VOID *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize,
- IN BOOLEAN DontUseBuffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN VOID *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize,
+ IN BOOLEAN DontUseBuffer
);
-
/**
This function is a wrapper to put file with TFTP.
@@ -97,16 +94,15 @@ PxeBcTftpReadFile (
**/
EFI_STATUS
PxeBcTftpWriteFile (
- IN PXEBC_PRIVATE_DATA *Private,
- IN VOID *Config,
- IN UINT8 *Filename,
- IN BOOLEAN Overwrite,
- IN UINTN *BlockSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN VOID *Config,
+ IN UINT8 *Filename,
+ IN BOOLEAN Overwrite,
+ IN UINTN *BlockSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize
);
-
/**
This function is a wrapper to get the data (file) from a directory using TFTP.
@@ -126,13 +122,14 @@ PxeBcTftpWriteFile (
**/
EFI_STATUS
PxeBcTftpReadDirectory (
- IN PXEBC_PRIVATE_DATA *Private,
- IN VOID *Config,
- IN UINT8 *Filename,
- IN UINTN *BlockSize,
- IN UINTN *WindowSize,
- IN UINT8 *BufferPtr,
- IN OUT UINT64 *BufferSize,
- IN BOOLEAN DontUseBuffer
+ IN PXEBC_PRIVATE_DATA *Private,
+ IN VOID *Config,
+ IN UINT8 *Filename,
+ IN UINTN *BlockSize,
+ IN UINTN *WindowSize,
+ IN UINT8 *BufferPtr,
+ IN OUT UINT64 *BufferSize,
+ IN BOOLEAN DontUseBuffer
);
+
#endif
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -61,8 +61,8 @@ PxeBcFlushStationIp (
// Reconfigure the ARP instance with station Ip address.
//
ArpConfigData.SwAddressType = 0x0800;
- ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);
- ArpConfigData.StationAddress = StationIp;
+ ArpConfigData.SwAddressLength = (UINT8)sizeof (EFI_IPv4_ADDRESS);
+ ArpConfigData.StationAddress = StationIp;
Private->Arp->Configure (Private->Arp, NULL);
Private->Arp->Configure (Private->Arp, &ArpConfigData);
@@ -82,7 +82,7 @@ PxeBcFlushStationIp (
CopyMem (&Private->Ip4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS));
}
- if (StationIp != NULL && SubnetMask != NULL) {
+ if ((StationIp != NULL) && (SubnetMask != NULL)) {
//
// Updated the route table.
//
@@ -92,7 +92,7 @@ PxeBcFlushStationIp (
Mode->RouteTable[0].GwAddr.Addr[0] = 0;
}
- if (StationIp != NULL || SubnetMask != NULL) {
+ if ((StationIp != NULL) || (SubnetMask != NULL)) {
//
// Reconfigure the Ip4 instance to capture background ICMP packets with new station Ip address.
//
@@ -112,7 +112,6 @@ ON_EXIT:
return Status;
}
-
/**
Notify the callback function when an event is triggered.
@@ -123,14 +122,13 @@ ON_EXIT:
VOID
EFIAPI
PxeBcCommonNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- *((BOOLEAN *) Context) = TRUE;
+ *((BOOLEAN *)Context) = TRUE;
}
-
/**
Do arp resolution from arp cache in PxeBcMode.
@@ -145,12 +143,12 @@ PxeBcCommonNotify (
**/
BOOLEAN
PxeBcCheckArpCache (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN EFI_IPv4_ADDRESS *Ip4Addr,
- OUT EFI_MAC_ADDRESS *MacAddress
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN EFI_IPv4_ADDRESS *Ip4Addr,
+ OUT EFI_MAC_ADDRESS *MacAddress
)
{
- UINT32 Index;
+ UINT32 Index;
ASSERT (!Mode->UsingIpv6);
@@ -171,7 +169,6 @@ PxeBcCheckArpCache (
return FALSE;
}
-
/**
Update the arp cache periodically.
@@ -182,8 +179,8 @@ PxeBcCheckArpCache (
VOID
EFIAPI
PxeBcArpCacheUpdate (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -194,7 +191,7 @@ PxeBcArpCacheUpdate (
UINT32 Index;
EFI_STATUS Status;
- Private = (PXEBC_PRIVATE_DATA *) Context;
+ Private = (PXEBC_PRIVATE_DATA *)Context;
Mode = Private->PxeBc.Mode;
ASSERT (!Mode->UsingIpv6);
@@ -228,14 +225,13 @@ PxeBcArpCacheUpdate (
);
CopyMem (
&Mode->ArpCache[Index].MacAddr,
- (UINT8 *) (ArpEntry + 1) + ArpEntry->SwAddressLength,
+ (UINT8 *)(ArpEntry + 1) + ArpEntry->SwAddressLength,
ArpEntry->HwAddressLength
);
- ArpEntry = (EFI_ARP_FIND_DATA *) ((UINT8 *) ArpEntry + EntryLength);
+ ArpEntry = (EFI_ARP_FIND_DATA *)((UINT8 *)ArpEntry + EntryLength);
}
}
-
/**
Notify function to handle the received ICMP message in DPC.
@@ -245,20 +241,20 @@ PxeBcArpCacheUpdate (
VOID
EFIAPI
PxeBcIcmpErrorDpcHandle (
- IN VOID *Context
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- EFI_IP4_RECEIVE_DATA *RxData;
- EFI_IP4_PROTOCOL *Ip4;
- PXEBC_PRIVATE_DATA *Private;
- EFI_PXE_BASE_CODE_MODE *Mode;
- UINT8 Type;
- UINTN Index;
- UINT32 CopiedLen;
- UINT8 *IcmpError;
+ EFI_STATUS Status;
+ EFI_IP4_RECEIVE_DATA *RxData;
+ EFI_IP4_PROTOCOL *Ip4;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ UINT8 Type;
+ UINTN Index;
+ UINT32 CopiedLen;
+ UINT8 *IcmpError;
- Private = (PXEBC_PRIVATE_DATA *) Context;
+ Private = (PXEBC_PRIVATE_DATA *)Context;
Mode = &Private->Mode;
Status = Private->IcmpToken.Status;
RxData = Private->IcmpToken.Packet.RxData;
@@ -284,10 +280,11 @@ PxeBcIcmpErrorDpcHandle (
goto ON_RECYCLE;
}
- if (EFI_IP4 (RxData->Header->SourceAddress) != 0 &&
+ if ((EFI_IP4 (RxData->Header->SourceAddress) != 0) &&
(NTOHL (Mode->SubnetMask.Addr[0]) != 0) &&
- IP4_NET_EQUAL (NTOHL(Mode->StationIp.Addr[0]), EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) &&
- !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0]))) {
+ IP4_NET_EQUAL (NTOHL (Mode->StationIp.Addr[0]), EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) &&
+ !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])))
+ {
//
// The source address of the received packet should be a valid unicast address.
//
@@ -306,13 +303,14 @@ PxeBcIcmpErrorDpcHandle (
//
ASSERT (RxData->Header->Protocol == EFI_IP_PROTO_ICMP);
- Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
+ Type = *((UINT8 *)RxData->FragmentTable[0].FragmentBuffer);
- if (Type != ICMP_DEST_UNREACHABLE &&
- Type != ICMP_SOURCE_QUENCH &&
- Type != ICMP_REDIRECT &&
- Type != ICMP_TIME_EXCEEDED &&
- Type != ICMP_PARAMETER_PROBLEM) {
+ if ((Type != ICMP_DEST_UNREACHABLE) &&
+ (Type != ICMP_SOURCE_QUENCH) &&
+ (Type != ICMP_REDIRECT) &&
+ (Type != ICMP_TIME_EXCEEDED) &&
+ (Type != ICMP_PARAMETER_PROBLEM))
+ {
//
// The type of the receveid ICMP message should be ICMP_ERROR_MESSAGE.
//
@@ -323,7 +321,7 @@ PxeBcIcmpErrorDpcHandle (
// Copy the right ICMP error message into mode data.
//
CopiedLen = 0;
- IcmpError = (UINT8 *) &Mode->IcmpError;
+ IcmpError = (UINT8 *)&Mode->IcmpError;
for (Index = 0; Index < RxData->FragmentCount; Index++) {
CopiedLen += RxData->FragmentTable[Index].FragmentLength;
@@ -340,6 +338,7 @@ PxeBcIcmpErrorDpcHandle (
CopiedLen - sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR)
);
}
+
IcmpError += CopiedLen;
}
@@ -351,7 +350,6 @@ ON_EXIT:
Ip4->Receive (Ip4, &Private->IcmpToken);
}
-
/**
Callback function to update the latest ICMP6 error message.
@@ -362,14 +360,13 @@ ON_EXIT:
VOID
EFIAPI
PxeBcIcmpErrorUpdate (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
QueueDpc (TPL_CALLBACK, PxeBcIcmpErrorDpcHandle, Context);
}
-
/**
Notify function to handle the received ICMP6 message in DPC.
@@ -379,7 +376,7 @@ PxeBcIcmpErrorUpdate (
VOID
EFIAPI
PxeBcIcmp6ErrorDpcHandle (
- IN VOID *Context
+ IN VOID *Context
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -392,7 +389,7 @@ PxeBcIcmp6ErrorDpcHandle (
UINT32 CopiedLen;
UINT8 *Icmp6Error;
- Private = (PXEBC_PRIVATE_DATA *) Context;
+ Private = (PXEBC_PRIVATE_DATA *)Context;
Mode = &Private->Mode;
Status = Private->Icmp6Token.Status;
RxData = Private->Icmp6Token.Packet.RxData;
@@ -426,7 +423,8 @@ PxeBcIcmp6ErrorDpcHandle (
}
if (!NetIp6IsUnspecifiedAddr (&Mode->StationIp.v6) &&
- !EFI_IP6_EQUAL (&RxData->Header->DestinationAddress, &Mode->StationIp.v6)) {
+ !EFI_IP6_EQUAL (&RxData->Header->DestinationAddress, &Mode->StationIp.v6))
+ {
//
// The destination address of the received packet should be equal to the host address.
//
@@ -438,12 +436,13 @@ PxeBcIcmp6ErrorDpcHandle (
//
ASSERT (RxData->Header->NextHeader == IP6_ICMP);
- Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
+ Type = *((UINT8 *)RxData->FragmentTable[0].FragmentBuffer);
- if (Type != ICMP_V6_DEST_UNREACHABLE &&
- Type != ICMP_V6_PACKET_TOO_BIG &&
- Type != ICMP_V6_TIME_EXCEEDED &&
- Type != ICMP_V6_PARAMETER_PROBLEM) {
+ if ((Type != ICMP_V6_DEST_UNREACHABLE) &&
+ (Type != ICMP_V6_PACKET_TOO_BIG) &&
+ (Type != ICMP_V6_TIME_EXCEEDED) &&
+ (Type != ICMP_V6_PARAMETER_PROBLEM))
+ {
//
// The type of the receveid packet should be an ICMP6 error message.
//
@@ -454,7 +453,7 @@ PxeBcIcmp6ErrorDpcHandle (
// Copy the right ICMP6 error message into mode data.
//
CopiedLen = 0;
- Icmp6Error = (UINT8 *) &Mode->IcmpError;
+ Icmp6Error = (UINT8 *)&Mode->IcmpError;
for (Index = 0; Index < RxData->FragmentCount; Index++) {
CopiedLen += RxData->FragmentTable[Index].FragmentLength;
@@ -471,6 +470,7 @@ PxeBcIcmp6ErrorDpcHandle (
CopiedLen - sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR)
);
}
+
Icmp6Error += CopiedLen;
}
@@ -482,7 +482,6 @@ ON_EXIT:
Ip6->Receive (Ip6, &Private->Icmp6Token);
}
-
/**
Callback function to update the latest ICMP6 error message.
@@ -493,14 +492,13 @@ ON_EXIT:
VOID
EFIAPI
PxeBcIcmp6ErrorUpdate (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
QueueDpc (TPL_CALLBACK, PxeBcIcmp6ErrorDpcHandle, Context);
}
-
/**
This function is to configure a UDPv4 instance for UdpWrite.
@@ -563,7 +561,7 @@ PxeBcConfigUdp4Write (
}
}
- if (!EFI_ERROR (Status) && *SrcPort == 0) {
+ if (!EFI_ERROR (Status) && (*SrcPort == 0)) {
Udp4->GetModeData (Udp4, &Udp4CfgData, NULL, NULL, NULL);
*SrcPort = Udp4CfgData.StationPort;
}
@@ -571,7 +569,6 @@ PxeBcConfigUdp4Write (
return Status;
}
-
/**
This function is to configure a UDPv6 instance for UdpWrite.
@@ -613,7 +610,7 @@ PxeBcConfigUdp6Write (
return Status;
}
- if (!EFI_ERROR (Status) && *SrcPort == 0) {
+ if (!EFI_ERROR (Status) && (*SrcPort == 0)) {
Udp6->GetModeData (Udp6, &CfgData, NULL, NULL, NULL);
*SrcPort = CfgData.StationPort;
}
@@ -621,7 +618,6 @@ PxeBcConfigUdp6Write (
return Status;
}
-
/**
This function is to configure a UDPv4 instance for UdpWrite.
@@ -642,54 +638,54 @@ PxeBcConfigUdp6Write (
**/
EFI_STATUS
PxeBcUdp4Write (
- IN EFI_UDP4_PROTOCOL *Udp4,
- IN EFI_UDP4_SESSION_DATA *Session,
- IN EFI_EVENT TimeoutEvent,
- IN EFI_IPv4_ADDRESS *Gateway OPTIONAL,
- IN UINTN *HeaderSize OPTIONAL,
- IN VOID *HeaderPtr OPTIONAL,
- IN UINTN *BufferSize,
- IN VOID *BufferPtr
- )
-{
- EFI_UDP4_COMPLETION_TOKEN Token;
- EFI_UDP4_TRANSMIT_DATA *TxData;
- UINT32 TxLength;
- UINT32 FragCount;
- UINT32 DataLength;
- BOOLEAN IsDone;
- EFI_STATUS Status;
+ IN EFI_UDP4_PROTOCOL *Udp4,
+ IN EFI_UDP4_SESSION_DATA *Session,
+ IN EFI_EVENT TimeoutEvent,
+ IN EFI_IPv4_ADDRESS *Gateway OPTIONAL,
+ IN UINTN *HeaderSize OPTIONAL,
+ IN VOID *HeaderPtr OPTIONAL,
+ IN UINTN *BufferSize,
+ IN VOID *BufferPtr
+ )
+{
+ EFI_UDP4_COMPLETION_TOKEN Token;
+ EFI_UDP4_TRANSMIT_DATA *TxData;
+ UINT32 TxLength;
+ UINT32 FragCount;
+ UINT32 DataLength;
+ BOOLEAN IsDone;
+ EFI_STATUS Status;
//
// Arrange one fragment buffer for data, and another fragment buffer for header if has.
//
FragCount = (HeaderSize != NULL) ? 2 : 1;
TxLength = sizeof (EFI_UDP4_TRANSMIT_DATA) + (FragCount - 1) * sizeof (EFI_UDP4_FRAGMENT_DATA);
- TxData = (EFI_UDP4_TRANSMIT_DATA *) AllocateZeroPool (TxLength);
+ TxData = (EFI_UDP4_TRANSMIT_DATA *)AllocateZeroPool (TxLength);
if (TxData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
TxData->FragmentCount = FragCount;
- TxData->FragmentTable[FragCount - 1].FragmentLength = (UINT32) *BufferSize;
+ TxData->FragmentTable[FragCount - 1].FragmentLength = (UINT32)*BufferSize;
TxData->FragmentTable[FragCount - 1].FragmentBuffer = BufferPtr;
- DataLength = (UINT32) *BufferSize;
+ DataLength = (UINT32)*BufferSize;
if (HeaderSize != NULL) {
- TxData->FragmentTable[0].FragmentLength = (UINT32) *HeaderSize;
+ TxData->FragmentTable[0].FragmentLength = (UINT32)*HeaderSize;
TxData->FragmentTable[0].FragmentBuffer = HeaderPtr;
- DataLength += (UINT32) *HeaderSize;
+ DataLength += (UINT32)*HeaderSize;
}
if (Gateway != NULL) {
- TxData->GatewayAddress = Gateway;
+ TxData->GatewayAddress = Gateway;
}
- TxData->UdpSessionData = Session;
- TxData->DataLength = DataLength;
- Token.Packet.TxData = TxData;
- Token.Status = EFI_NOT_READY;
- IsDone = FALSE;
+ TxData->UdpSessionData = Session;
+ TxData->DataLength = DataLength;
+ Token.Packet.TxData = TxData;
+ Token.Status = EFI_NOT_READY;
+ IsDone = FALSE;
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
@@ -712,7 +708,8 @@ PxeBcUdp4Write (
//
while (!IsDone &&
Token.Status == EFI_NOT_READY &&
- EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
+ EFI_ERROR (gBS->CheckEvent (TimeoutEvent)))
+ {
Udp4->Poll (Udp4);
}
@@ -722,12 +719,12 @@ ON_EXIT:
if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event);
}
+
FreePool (TxData);
return Status;
}
-
/**
This function is to configure a UDPv4 instance for UdpWrite.
@@ -747,49 +744,49 @@ ON_EXIT:
**/
EFI_STATUS
PxeBcUdp6Write (
- IN EFI_UDP6_PROTOCOL *Udp6,
- IN EFI_UDP6_SESSION_DATA *Session,
- IN EFI_EVENT TimeoutEvent,
- IN UINTN *HeaderSize OPTIONAL,
- IN VOID *HeaderPtr OPTIONAL,
- IN UINTN *BufferSize,
- IN VOID *BufferPtr
- )
-{
- EFI_UDP6_COMPLETION_TOKEN Token;
- EFI_UDP6_TRANSMIT_DATA *TxData;
- UINT32 TxLength;
- UINT32 FragCount;
- UINT32 DataLength;
- BOOLEAN IsDone;
- EFI_STATUS Status;
+ IN EFI_UDP6_PROTOCOL *Udp6,
+ IN EFI_UDP6_SESSION_DATA *Session,
+ IN EFI_EVENT TimeoutEvent,
+ IN UINTN *HeaderSize OPTIONAL,
+ IN VOID *HeaderPtr OPTIONAL,
+ IN UINTN *BufferSize,
+ IN VOID *BufferPtr
+ )
+{
+ EFI_UDP6_COMPLETION_TOKEN Token;
+ EFI_UDP6_TRANSMIT_DATA *TxData;
+ UINT32 TxLength;
+ UINT32 FragCount;
+ UINT32 DataLength;
+ BOOLEAN IsDone;
+ EFI_STATUS Status;
//
// Arrange one fragment buffer for data, and another fragment buffer for header if has.
//
FragCount = (HeaderSize != NULL) ? 2 : 1;
TxLength = sizeof (EFI_UDP6_TRANSMIT_DATA) + (FragCount - 1) * sizeof (EFI_UDP6_FRAGMENT_DATA);
- TxData = (EFI_UDP6_TRANSMIT_DATA *) AllocateZeroPool (TxLength);
+ TxData = (EFI_UDP6_TRANSMIT_DATA *)AllocateZeroPool (TxLength);
if (TxData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
TxData->FragmentCount = FragCount;
- TxData->FragmentTable[FragCount - 1].FragmentLength = (UINT32) *BufferSize;
+ TxData->FragmentTable[FragCount - 1].FragmentLength = (UINT32)*BufferSize;
TxData->FragmentTable[FragCount - 1].FragmentBuffer = BufferPtr;
- DataLength = (UINT32) *BufferSize;
+ DataLength = (UINT32)*BufferSize;
if (HeaderSize != NULL) {
- TxData->FragmentTable[0].FragmentLength = (UINT32) *HeaderSize;
+ TxData->FragmentTable[0].FragmentLength = (UINT32)*HeaderSize;
TxData->FragmentTable[0].FragmentBuffer = HeaderPtr;
- DataLength += (UINT32) *HeaderSize;
+ DataLength += (UINT32)*HeaderSize;
}
- TxData->UdpSessionData = Session;
- TxData->DataLength = DataLength;
- Token.Packet.TxData = TxData;
- Token.Status = EFI_NOT_READY;
- IsDone = FALSE;
+ TxData->UdpSessionData = Session;
+ TxData->DataLength = DataLength;
+ Token.Packet.TxData = TxData;
+ Token.Status = EFI_NOT_READY;
+ IsDone = FALSE;
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
@@ -812,7 +809,8 @@ PxeBcUdp6Write (
//
while (!IsDone &&
Token.Status == EFI_NOT_READY &&
- EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
+ EFI_ERROR (gBS->CheckEvent (TimeoutEvent)))
+ {
Udp6->Poll (Udp6);
}
@@ -822,12 +820,12 @@ ON_EXIT:
if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event);
}
+
FreePool (TxData);
return Status;
}
-
/**
Check the received packet using the Ip filter.
@@ -841,13 +839,13 @@ ON_EXIT:
**/
BOOLEAN
PxeBcCheckByIpFilter (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN UINT16 OpFlags
)
{
- EFI_IP_ADDRESS DestinationIp;
- UINTN Index;
+ EFI_IP_ADDRESS DestinationIp;
+ UINTN Index;
if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER) == 0) {
return TRUE;
@@ -863,7 +861,7 @@ PxeBcCheckByIpFilter (
if (Mode->UsingIpv6) {
CopyMem (
&DestinationIp,
- &((EFI_UDP6_SESSION_DATA *) Session)->DestinationAddress,
+ &((EFI_UDP6_SESSION_DATA *)Session)->DestinationAddress,
sizeof (EFI_IPv6_ADDRESS)
);
NTOHLLL (&DestinationIp.v6);
@@ -871,27 +869,30 @@ PxeBcCheckByIpFilter (
ZeroMem (&DestinationIp, sizeof (EFI_IP_ADDRESS));
CopyMem (
&DestinationIp,
- &((EFI_UDP4_SESSION_DATA *) Session)->DestinationAddress,
+ &((EFI_UDP4_SESSION_DATA *)Session)->DestinationAddress,
sizeof (EFI_IPv4_ADDRESS)
);
EFI_NTOHL (DestinationIp);
}
- if ((Mode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0 &&
+ if (((Mode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0) &&
(IP4_IS_MULTICAST (DestinationIp.Addr[0]) ||
- IP6_IS_MULTICAST (&DestinationIp))) {
+ IP6_IS_MULTICAST (&DestinationIp)))
+ {
return TRUE;
}
- if ((Mode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) != 0 &&
- IP4_IS_LOCAL_BROADCAST (DestinationIp.Addr[0])) {
+ if (((Mode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) != 0) &&
+ IP4_IS_LOCAL_BROADCAST (DestinationIp.Addr[0]))
+ {
ASSERT (!Mode->UsingIpv6);
return TRUE;
}
- if ((Mode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0 &&
+ if (((Mode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) &&
(EFI_IP4_EQUAL (&Mode->StationIp.v4, &DestinationIp) ||
- EFI_IP6_EQUAL (&Mode->StationIp.v6, &DestinationIp))) {
+ EFI_IP6_EQUAL (&Mode->StationIp.v6, &DestinationIp)))
+ {
//
// Matched if the dest address is equal to the station address.
//
@@ -901,7 +902,8 @@ PxeBcCheckByIpFilter (
for (Index = 0; Index < Mode->IpFilter.IpCnt; Index++) {
ASSERT (Index < EFI_PXE_BASE_CODE_MAX_IPCNT);
if (EFI_IP4_EQUAL (&Mode->IpFilter.IpList[Index].v4, &DestinationIp) ||
- EFI_IP6_EQUAL (&Mode->IpFilter.IpList[Index].v6, &DestinationIp)) {
+ EFI_IP6_EQUAL (&Mode->IpFilter.IpList[Index].v6, &DestinationIp))
+ {
//
// Matched if the dest address is equal to any of address in the filter list.
//
@@ -912,7 +914,6 @@ PxeBcCheckByIpFilter (
return FALSE;
}
-
/**
Filter the received packet using the destination Ip.
@@ -927,10 +928,10 @@ PxeBcCheckByIpFilter (
**/
BOOLEAN
PxeBcCheckByDestIp (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN OUT EFI_IP_ADDRESS *DestIp,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN OUT EFI_IP_ADDRESS *DestIp,
+ IN UINT16 OpFlags
)
{
if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP) != 0) {
@@ -952,18 +953,20 @@ PxeBcCheckByDestIp (
sizeof (EFI_IPv4_ADDRESS)
);
}
-
}
+
return TRUE;
- } else if (DestIp != NULL &&
+ } else if ((DestIp != NULL) &&
(EFI_IP4_EQUAL (DestIp, &((EFI_UDP4_SESSION_DATA *)Session)->DestinationAddress) ||
- EFI_IP6_EQUAL (DestIp, &((EFI_UDP6_SESSION_DATA *)Session)->DestinationAddress))) {
+ EFI_IP6_EQUAL (DestIp, &((EFI_UDP6_SESSION_DATA *)Session)->DestinationAddress)))
+ {
//
// The destination address in the received packet is matched if present.
//
return TRUE;
} else if (EFI_IP4_EQUAL (&Mode->StationIp, &((EFI_UDP4_SESSION_DATA *)Session)->DestinationAddress) ||
- EFI_IP6_EQUAL (&Mode->StationIp, &((EFI_UDP6_SESSION_DATA *)Session)->DestinationAddress)) {
+ EFI_IP6_EQUAL (&Mode->StationIp, &((EFI_UDP6_SESSION_DATA *)Session)->DestinationAddress))
+ {
//
// The destination address in the received packet is equal to the host address.
//
@@ -973,7 +976,6 @@ PxeBcCheckByDestIp (
return FALSE;
}
-
/**
Check the received packet using the destination port.
@@ -988,18 +990,18 @@ PxeBcCheckByDestIp (
**/
BOOLEAN
PxeBcCheckByDestPort (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN OUT UINT16 *DestPort,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN OUT UINT16 *DestPort,
+ IN UINT16 OpFlags
)
{
- UINT16 Port;
+ UINT16 Port;
if (Mode->UsingIpv6) {
- Port = ((EFI_UDP6_SESSION_DATA *) Session)->DestinationPort;
+ Port = ((EFI_UDP6_SESSION_DATA *)Session)->DestinationPort;
} else {
- Port = ((EFI_UDP4_SESSION_DATA *) Session)->DestinationPort;
+ Port = ((EFI_UDP4_SESSION_DATA *)Session)->DestinationPort;
}
if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) != 0) {
@@ -1009,8 +1011,9 @@ PxeBcCheckByDestPort (
if (DestPort != NULL) {
*DestPort = Port;
}
+
return TRUE;
- } else if (DestPort != NULL && *DestPort == Port) {
+ } else if ((DestPort != NULL) && (*DestPort == Port)) {
//
// The destination port in the received packet is matched if present.
//
@@ -1020,7 +1023,6 @@ PxeBcCheckByDestPort (
return FALSE;
}
-
/**
Filter the received packet using the source Ip.
@@ -1035,10 +1037,10 @@ PxeBcCheckByDestPort (
**/
BOOLEAN
PxeBcFilterBySrcIp (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN OUT EFI_IP_ADDRESS *SrcIp,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN OUT EFI_IP_ADDRESS *SrcIp,
+ IN UINT16 OpFlags
)
{
if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) != 0) {
@@ -1060,12 +1062,13 @@ PxeBcFilterBySrcIp (
sizeof (EFI_IPv4_ADDRESS)
);
}
-
}
+
return TRUE;
- } else if (SrcIp != NULL &&
+ } else if ((SrcIp != NULL) &&
(EFI_IP4_EQUAL (SrcIp, &((EFI_UDP4_SESSION_DATA *)Session)->SourceAddress) ||
- EFI_IP6_EQUAL (SrcIp, &((EFI_UDP6_SESSION_DATA *)Session)->SourceAddress))) {
+ EFI_IP6_EQUAL (SrcIp, &((EFI_UDP6_SESSION_DATA *)Session)->SourceAddress)))
+ {
//
// The source address in the received packet is matched if present.
//
@@ -1075,7 +1078,6 @@ PxeBcFilterBySrcIp (
return FALSE;
}
-
/**
Filter the received packet using the source port.
@@ -1090,18 +1092,18 @@ PxeBcFilterBySrcIp (
**/
BOOLEAN
PxeBcFilterBySrcPort (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN OUT UINT16 *SrcPort,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN OUT UINT16 *SrcPort,
+ IN UINT16 OpFlags
)
{
- UINT16 Port;
+ UINT16 Port;
if (Mode->UsingIpv6) {
- Port = ((EFI_UDP6_SESSION_DATA *) Session)->SourcePort;
+ Port = ((EFI_UDP6_SESSION_DATA *)Session)->SourcePort;
} else {
- Port = ((EFI_UDP4_SESSION_DATA *) Session)->SourcePort;
+ Port = ((EFI_UDP4_SESSION_DATA *)Session)->SourcePort;
}
if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) != 0) {
@@ -1111,8 +1113,9 @@ PxeBcFilterBySrcPort (
if (SrcPort != NULL) {
*SrcPort = Port;
}
+
return TRUE;
- } else if (SrcPort != NULL && *SrcPort == Port) {
+ } else if ((SrcPort != NULL) && (*SrcPort == Port)) {
//
// The source port in the received packet is matched if present.
//
@@ -1122,7 +1125,6 @@ PxeBcFilterBySrcPort (
return FALSE;
}
-
/**
This function is to receive packet using Udp4Read.
@@ -1144,22 +1146,22 @@ PxeBcFilterBySrcPort (
**/
EFI_STATUS
PxeBcUdp4Read (
- IN EFI_UDP4_PROTOCOL *Udp4,
- IN EFI_UDP4_COMPLETION_TOKEN *Token,
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN EFI_EVENT TimeoutEvent,
- IN UINT16 OpFlags,
- IN BOOLEAN *IsDone,
- OUT BOOLEAN *IsMatched,
- IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
- IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
- )
-{
- EFI_UDP4_RECEIVE_DATA *RxData;
- EFI_UDP4_SESSION_DATA *Session;
- EFI_STATUS Status;
+ IN EFI_UDP4_PROTOCOL *Udp4,
+ IN EFI_UDP4_COMPLETION_TOKEN *Token,
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN EFI_EVENT TimeoutEvent,
+ IN UINT16 OpFlags,
+ IN BOOLEAN *IsDone,
+ OUT BOOLEAN *IsMatched,
+ IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
+ IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
+ )
+{
+ EFI_UDP4_RECEIVE_DATA *RxData;
+ EFI_UDP4_SESSION_DATA *Session;
+ EFI_STATUS Status;
Token->Status = EFI_NOT_READY;
*IsDone = FALSE;
@@ -1174,16 +1176,18 @@ PxeBcUdp4Read (
//
while (!(*IsDone) &&
Token->Status == EFI_NOT_READY &&
- EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
+ EFI_ERROR (gBS->CheckEvent (TimeoutEvent)))
+ {
//
// Poll the token utill reply/ICMPv6 error message received or timeout.
//
Udp4->Poll (Udp4);
- if (Token->Status == EFI_ICMP_ERROR ||
- Token->Status == EFI_NETWORK_UNREACHABLE ||
- Token->Status == EFI_HOST_UNREACHABLE ||
- Token->Status == EFI_PROTOCOL_UNREACHABLE ||
- Token->Status == EFI_PORT_UNREACHABLE) {
+ if ((Token->Status == EFI_ICMP_ERROR) ||
+ (Token->Status == EFI_NETWORK_UNREACHABLE) ||
+ (Token->Status == EFI_HOST_UNREACHABLE) ||
+ (Token->Status == EFI_PROTOCOL_UNREACHABLE) ||
+ (Token->Status == EFI_PORT_UNREACHABLE))
+ {
break;
}
}
@@ -1194,8 +1198,8 @@ PxeBcUdp4Read (
//
// check whether this packet matches the filters
//
- RxData = Token->Packet.RxData;
- Session = &RxData->UdpSession;
+ RxData = Token->Packet.RxData;
+ Session = &RxData->UdpSession;
*IsMatched = PxeBcCheckByIpFilter (Mode, Session, OpFlags);
@@ -1226,7 +1230,6 @@ PxeBcUdp4Read (
return Status;
}
-
/**
This function is to receive packets using Udp6Read.
@@ -1248,22 +1251,22 @@ PxeBcUdp4Read (
**/
EFI_STATUS
PxeBcUdp6Read (
- IN EFI_UDP6_PROTOCOL *Udp6,
- IN EFI_UDP6_COMPLETION_TOKEN *Token,
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN EFI_EVENT TimeoutEvent,
- IN UINT16 OpFlags,
- IN BOOLEAN *IsDone,
- OUT BOOLEAN *IsMatched,
- IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
- IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
- )
-{
- EFI_UDP6_RECEIVE_DATA *RxData;
- EFI_UDP6_SESSION_DATA *Session;
- EFI_STATUS Status;
+ IN EFI_UDP6_PROTOCOL *Udp6,
+ IN EFI_UDP6_COMPLETION_TOKEN *Token,
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN EFI_EVENT TimeoutEvent,
+ IN UINT16 OpFlags,
+ IN BOOLEAN *IsDone,
+ OUT BOOLEAN *IsMatched,
+ IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
+ IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
+ )
+{
+ EFI_UDP6_RECEIVE_DATA *RxData;
+ EFI_UDP6_SESSION_DATA *Session;
+ EFI_STATUS Status;
Token->Status = EFI_NOT_READY;
*IsDone = FALSE;
@@ -1278,16 +1281,18 @@ PxeBcUdp6Read (
//
while (!(*IsDone) &&
Token->Status == EFI_NOT_READY &&
- EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
+ EFI_ERROR (gBS->CheckEvent (TimeoutEvent)))
+ {
//
// Poll the token utill reply/ICMPv6 error message received or timeout.
//
Udp6->Poll (Udp6);
- if (Token->Status == EFI_ICMP_ERROR ||
- Token->Status == EFI_NETWORK_UNREACHABLE ||
- Token->Status == EFI_HOST_UNREACHABLE ||
- Token->Status == EFI_PROTOCOL_UNREACHABLE ||
- Token->Status == EFI_PORT_UNREACHABLE) {
+ if ((Token->Status == EFI_ICMP_ERROR) ||
+ (Token->Status == EFI_NETWORK_UNREACHABLE) ||
+ (Token->Status == EFI_HOST_UNREACHABLE) ||
+ (Token->Status == EFI_PROTOCOL_UNREACHABLE) ||
+ (Token->Status == EFI_PORT_UNREACHABLE))
+ {
break;
}
}
@@ -1298,8 +1303,8 @@ PxeBcUdp6Read (
//
// check whether this packet matches the filters
//
- RxData = Token->Packet.RxData;
- Session = &RxData->UdpSession;
+ RxData = Token->Packet.RxData;
+ Session = &RxData->UdpSession;
*IsMatched = PxeBcCheckByIpFilter (Mode, Session, OpFlags);
@@ -1330,7 +1335,6 @@ PxeBcUdp6Read (
return Status;
}
-
/**
This function is to display the IPv4 address.
@@ -1339,10 +1343,10 @@ PxeBcUdp6Read (
**/
VOID
PxeBcShowIp4Addr (
- IN EFI_IPv4_ADDRESS *Ip
+ IN EFI_IPv4_ADDRESS *Ip
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < 4; Index++) {
AsciiPrint ("%d", Ip->Addr[Index]);
@@ -1352,7 +1356,6 @@ PxeBcShowIp4Addr (
}
}
-
/**
This function is to display the IPv6 address.
@@ -1361,23 +1364,25 @@ PxeBcShowIp4Addr (
**/
VOID
PxeBcShowIp6Addr (
- IN EFI_IPv6_ADDRESS *Ip
+ IN EFI_IPv6_ADDRESS *Ip
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < 16; Index++) {
-
if (Ip->Addr[Index] != 0) {
AsciiPrint ("%x", Ip->Addr[Index]);
}
+
Index++;
if (Index > 15) {
return;
}
+
if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
AsciiPrint ("0");
}
+
AsciiPrint ("%x", Ip->Addr[Index]);
if (Index < 15) {
AsciiPrint (":");
@@ -1385,7 +1390,6 @@ PxeBcShowIp6Addr (
}
}
-
/**
This function is to convert UINTN to ASCII string with the required formatting.
@@ -1396,21 +1400,20 @@ PxeBcShowIp6Addr (
**/
VOID
PxeBcUintnToAscDecWithFormat (
- IN UINTN Number,
- IN UINT8 *Buffer,
- IN INTN Length
+ IN UINTN Number,
+ IN UINT8 *Buffer,
+ IN INTN Length
)
{
- UINTN Remainder;
+ UINTN Remainder;
- for (; Length > 0; Length--) {
- Remainder = Number % 10;
- Number /= 10;
- Buffer[Length - 1] = (UINT8) ('0' + Remainder);
+ for ( ; Length > 0; Length--) {
+ Remainder = Number % 10;
+ Number /= 10;
+ Buffer[Length - 1] = (UINT8)('0' + Remainder);
}
}
-
/**
This function is to convert a UINTN to a ASCII string, and return the
actual length of the buffer.
@@ -1424,32 +1427,31 @@ PxeBcUintnToAscDecWithFormat (
**/
UINTN
PxeBcUintnToAscDec (
- IN UINTN Number,
- IN UINT8 *Buffer,
- IN UINTN BufferSize
+ IN UINTN Number,
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize
)
{
- UINTN Index;
- UINTN Length;
- CHAR8 TempStr[64];
+ UINTN Index;
+ UINTN Length;
+ CHAR8 TempStr[64];
- Index = 63;
- TempStr[Index] = 0;
+ Index = 63;
+ TempStr[Index] = 0;
do {
Index--;
- TempStr[Index] = (CHAR8) ('0' + (Number % 10));
- Number = (UINTN) (Number / 10);
+ TempStr[Index] = (CHAR8)('0' + (Number % 10));
+ Number = (UINTN)(Number / 10);
} while (Number != 0);
- AsciiStrCpyS ((CHAR8 *) Buffer, BufferSize, &TempStr[Index]);
+ AsciiStrCpyS ((CHAR8 *)Buffer, BufferSize, &TempStr[Index]);
- Length = AsciiStrLen ((CHAR8 *) Buffer);
+ Length = AsciiStrLen ((CHAR8 *)Buffer);
return Length;
}
-
/**
This function is to convert unicode hex number to a UINT8.
@@ -1462,22 +1464,22 @@ PxeBcUintnToAscDec (
**/
EFI_STATUS
PxeBcUniHexToUint8 (
- OUT UINT8 *Digit,
- IN CHAR16 Char
+ OUT UINT8 *Digit,
+ IN CHAR16 Char
)
{
if ((Char >= L'0') && (Char <= L'9')) {
- *Digit = (UINT8) (Char - L'0');
+ *Digit = (UINT8)(Char - L'0');
return EFI_SUCCESS;
}
if ((Char >= L'A') && (Char <= L'F')) {
- *Digit = (UINT8) (Char - L'A' + 0x0A);
+ *Digit = (UINT8)(Char - L'A' + 0x0A);
return EFI_SUCCESS;
}
if ((Char >= L'a') && (Char <= L'f')) {
- *Digit = (UINT8) (Char - L'a' + 0x0A);
+ *Digit = (UINT8)(Char - L'a' + 0x0A);
return EFI_SUCCESS;
}
@@ -1492,12 +1494,12 @@ PxeBcUniHexToUint8 (
**/
VOID
CalcElapsedTime (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
)
{
- EFI_TIME Time;
- UINT64 CurrentStamp;
- UINT64 ElapsedTimeValue;
+ EFI_TIME Time;
+ UINT64 CurrentStamp;
+ UINT64 ElapsedTimeValue;
//
// Generate a time stamp of the centiseconds from 1900/1/1, assume 30day/month.
@@ -1529,6 +1531,7 @@ CalcElapsedTime (
if (ElapsedTimeValue > 0xffff) {
ElapsedTimeValue = 0xffff;
}
+
//
// Save the elapsed time
//
Index: edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.h
===================================================================
--- edk2-edk2-stable201911.orig/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.h
+++ edk2-edk2-stable201911/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.h
@@ -10,15 +10,12 @@
#ifndef __EFI_PXEBC_SUPPORT_H__
#define __EFI_PXEBC_SUPPORT_H__
-
-#define ICMP_DEST_UNREACHABLE 3
-#define ICMP_SOURCE_QUENCH 4
-#define ICMP_REDIRECT 5
-#define ICMP_ECHO_REQUEST 8
-#define ICMP_TIME_EXCEEDED 11
-#define ICMP_PARAMETER_PROBLEM 12
-
-
+#define ICMP_DEST_UNREACHABLE 3
+#define ICMP_SOURCE_QUENCH 4
+#define ICMP_REDIRECT 5
+#define ICMP_ECHO_REQUEST 8
+#define ICMP_TIME_EXCEEDED 11
+#define ICMP_PARAMETER_PROBLEM 12
/**
Flush the previous configration using the new station Ip address.
@@ -49,11 +46,10 @@ PxeBcFlushStationIp (
VOID
EFIAPI
PxeBcCommonNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
-
/**
Perform arp resolution from the arp cache in PxeBcMode.
@@ -68,12 +64,11 @@ PxeBcCommonNotify (
**/
BOOLEAN
PxeBcCheckArpCache (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN EFI_IPv4_ADDRESS *Ip4Addr,
- OUT EFI_MAC_ADDRESS *MacAddress
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN EFI_IPv4_ADDRESS *Ip4Addr,
+ OUT EFI_MAC_ADDRESS *MacAddress
);
-
/**
Update arp cache periodically.
@@ -84,11 +79,10 @@ PxeBcCheckArpCache (
VOID
EFIAPI
PxeBcArpCacheUpdate (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
-
/**
xxx
@@ -99,11 +93,10 @@ PxeBcArpCacheUpdate (
VOID
EFIAPI
PxeBcIcmpErrorUpdate (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
-
/**
xxx
@@ -114,11 +107,10 @@ PxeBcIcmpErrorUpdate (
VOID
EFIAPI
PxeBcIcmp6ErrorUpdate (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
-
/**
This function is to configure a UDPv4 instance for UdpWrite.
@@ -148,7 +140,6 @@ PxeBcConfigUdp4Write (
IN UINT8 ToS
);
-
/**
This function is to configure a UDPv6 instance for UdpWrite.
@@ -187,17 +178,16 @@ PxeBcConfigUdp6Write (
**/
EFI_STATUS
PxeBcUdp4Write (
- IN EFI_UDP4_PROTOCOL *Udp4,
- IN EFI_UDP4_SESSION_DATA *Session,
- IN EFI_EVENT TimeoutEvent,
- IN EFI_IPv4_ADDRESS *Gateway OPTIONAL,
- IN UINTN *HeaderSize OPTIONAL,
- IN VOID *HeaderPtr OPTIONAL,
- IN UINTN *BufferSize,
- IN VOID *BufferPtr
+ IN EFI_UDP4_PROTOCOL *Udp4,
+ IN EFI_UDP4_SESSION_DATA *Session,
+ IN EFI_EVENT TimeoutEvent,
+ IN EFI_IPv4_ADDRESS *Gateway OPTIONAL,
+ IN UINTN *HeaderSize OPTIONAL,
+ IN VOID *HeaderPtr OPTIONAL,
+ IN UINTN *BufferSize,
+ IN VOID *BufferPtr
);
-
/**
This function is to configure a UDPv6 instance for UdpWrite.
@@ -217,16 +207,15 @@ PxeBcUdp4Write (
**/
EFI_STATUS
PxeBcUdp6Write (
- IN EFI_UDP6_PROTOCOL *Udp6,
- IN EFI_UDP6_SESSION_DATA *Session,
- IN EFI_EVENT TimeoutEvent,
- IN UINTN *HeaderSize OPTIONAL,
- IN VOID *HeaderPtr OPTIONAL,
- IN UINTN *BufferSize,
- IN VOID *BufferPtr
+ IN EFI_UDP6_PROTOCOL *Udp6,
+ IN EFI_UDP6_SESSION_DATA *Session,
+ IN EFI_EVENT TimeoutEvent,
+ IN UINTN *HeaderSize OPTIONAL,
+ IN VOID *HeaderPtr OPTIONAL,
+ IN UINTN *BufferSize,
+ IN VOID *BufferPtr
);
-
/**
Check the received packet with the Ip filter.
@@ -240,12 +229,11 @@ PxeBcUdp6Write (
**/
BOOLEAN
PxeBcCheckByIpFilter (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN UINT16 OpFlags
);
-
/**
Filter the received packet with the destination Ip.
@@ -260,13 +248,12 @@ PxeBcCheckByIpFilter (
**/
BOOLEAN
PxeBcCheckByDestIp (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN OUT EFI_IP_ADDRESS *DestIp,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN OUT EFI_IP_ADDRESS *DestIp,
+ IN UINT16 OpFlags
);
-
/**
Check the received packet with the destination port.
@@ -281,13 +268,12 @@ PxeBcCheckByDestIp (
**/
BOOLEAN
PxeBcCheckByDestPort (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN OUT UINT16 *DestPort,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN OUT UINT16 *DestPort,
+ IN UINT16 OpFlags
);
-
/**
Filter the received packet with the source Ip.
@@ -302,13 +288,12 @@ PxeBcCheckByDestPort (
**/
BOOLEAN
PxeBcFilterBySrcIp (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN OUT EFI_IP_ADDRESS *SrcIp,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN OUT EFI_IP_ADDRESS *SrcIp,
+ IN UINT16 OpFlags
);
-
/**
Filter the received packet with the source port.
@@ -323,13 +308,12 @@ PxeBcFilterBySrcIp (
**/
BOOLEAN
PxeBcFilterBySrcPort (
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN VOID *Session,
- IN OUT UINT16 *SrcPort,
- IN UINT16 OpFlags
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN VOID *Session,
+ IN OUT UINT16 *SrcPort,
+ IN UINT16 OpFlags
);
-
/**
This function is to receive packet with Udp4Read.
@@ -351,20 +335,19 @@ PxeBcFilterBySrcPort (
**/
EFI_STATUS
PxeBcUdp4Read (
- IN EFI_UDP4_PROTOCOL *Udp4,
- IN EFI_UDP4_COMPLETION_TOKEN *Token,
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN EFI_EVENT TimeoutEvent,
- IN UINT16 OpFlags,
- IN BOOLEAN *IsDone,
- OUT BOOLEAN *IsMatched,
- IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
- IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
+ IN EFI_UDP4_PROTOCOL *Udp4,
+ IN EFI_UDP4_COMPLETION_TOKEN *Token,
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN EFI_EVENT TimeoutEvent,
+ IN UINT16 OpFlags,
+ IN BOOLEAN *IsDone,
+ OUT BOOLEAN *IsMatched,
+ IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
+ IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
);
-
/**
This function is to receive packet with Udp6Read.
@@ -386,20 +369,19 @@ PxeBcUdp4Read (
**/
EFI_STATUS
PxeBcUdp6Read (
- IN EFI_UDP6_PROTOCOL *Udp6,
- IN EFI_UDP6_COMPLETION_TOKEN *Token,
- IN EFI_PXE_BASE_CODE_MODE *Mode,
- IN EFI_EVENT TimeoutEvent,
- IN UINT16 OpFlags,
- IN BOOLEAN *IsDone,
- OUT BOOLEAN *IsMatched,
- IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
- IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
- IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
+ IN EFI_UDP6_PROTOCOL *Udp6,
+ IN EFI_UDP6_COMPLETION_TOKEN *Token,
+ IN EFI_PXE_BASE_CODE_MODE *Mode,
+ IN EFI_EVENT TimeoutEvent,
+ IN UINT16 OpFlags,
+ IN BOOLEAN *IsDone,
+ OUT BOOLEAN *IsMatched,
+ IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
+ IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
);
-
/**
This function is to display the IPv4 address.
@@ -408,10 +390,9 @@ PxeBcUdp6Read (
**/
VOID
PxeBcShowIp4Addr (
- IN EFI_IPv4_ADDRESS *Ip
+ IN EFI_IPv4_ADDRESS *Ip
);
-
/**
This function is to display the IPv6 address.
@@ -420,10 +401,9 @@ PxeBcShowIp4Addr (
**/
VOID
PxeBcShowIp6Addr (
- IN EFI_IPv6_ADDRESS *Ip
+ IN EFI_IPv6_ADDRESS *Ip
);
-
/**
This function is to convert UINTN to ASCII string with required format.
@@ -434,12 +414,11 @@ PxeBcShowIp6Addr (
**/
VOID
PxeBcUintnToAscDecWithFormat (
- IN UINTN Number,
- IN UINT8 *Buffer,
- IN INTN Length
+ IN UINTN Number,
+ IN UINT8 *Buffer,
+ IN INTN Length
);
-
/**
This function is to convert a UINTN to a ASCII string, and return the
actual length of the buffer.
@@ -453,9 +432,9 @@ PxeBcUintnToAscDecWithFormat (
**/
UINTN
PxeBcUintnToAscDec (
- IN UINTN Number,
- IN UINT8 *Buffer,
- IN UINTN BufferSize
+ IN UINTN Number,
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize
);
/**
@@ -470,8 +449,8 @@ PxeBcUintnToAscDec (
**/
EFI_STATUS
PxeBcUniHexToUint8 (
- OUT UINT8 *Digit,
- IN CHAR16 Char
+ OUT UINT8 *Digit,
+ IN CHAR16 Char
);
/**
@@ -482,7 +461,7 @@ PxeBcUniHexToUint8 (
**/
VOID
CalcElapsedTime (
- IN PXEBC_PRIVATE_DATA *Private
+ IN PXEBC_PRIVATE_DATA *Private
);
/**
@@ -495,7 +474,7 @@ CalcElapsedTime (
**/
EFI_HANDLE
PxeBcGetNicByIp4Children (
- IN EFI_HANDLE ControllerHandle
+ IN EFI_HANDLE ControllerHandle
);
/**
@@ -508,6 +487,7 @@ PxeBcGetNicByIp4Children (
**/
EFI_HANDLE
PxeBcGetNicByIp6Children (
- IN EFI_HANDLE ControllerHandle
+ IN EFI_HANDLE ControllerHandle
);
+
#endif