NetworkPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the NetworkPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:07 -08:00
committed by mergify[bot]
parent 2f88bd3a12
commit d1050b9dff
294 changed files with 29888 additions and 30440 deletions

View File

@ -116,7 +116,7 @@ NicNameToIndex (
Str++; Str++;
} }
return (UINT16) StrDecimalToUintn (Name + 3); return (UINT16)StrDecimalToUintn (Name + 3);
} }
/** /**
@ -177,7 +177,7 @@ OpenVlanConfigProtocol (
gBS->OpenProtocol ( gBS->OpenProtocol (
Handle, Handle,
&gEfiVlanConfigProtocolGuid, &gEfiVlanConfigProtocolGuid,
(VOID **) &VlanConfig, (VOID **)&VlanConfig,
mImageHandle, mImageHandle,
Handle, Handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -227,7 +227,7 @@ ShowNicVlanInfo (
VlanConfig = OpenVlanConfigProtocol (Handle); VlanConfig = OpenVlanConfigProtocol (Handle);
if (VlanConfig == NULL) { if (VlanConfig == NULL) {
return ; return;
} }
MacStr = NULL; MacStr = NULL;
@ -295,11 +295,11 @@ DisplayVlan (
// //
NicHandle = NicNameToHandle (Name); NicHandle = NicNameToHandle (Name);
if (NicHandle == NULL) { if (NicHandle == NULL) {
return ; return;
} }
ShowNicVlanInfo (NicHandle, 0); ShowNicVlanInfo (NicHandle, 0);
return ; return;
} }
// //
@ -307,7 +307,7 @@ DisplayVlan (
// //
LocateNicHandleBuffer (&NumberOfHandles, &HandleBuffer); LocateNicHandleBuffer (&NumberOfHandles, &HandleBuffer);
if (NumberOfHandles == 0) { if (NumberOfHandles == 0) {
return ; return;
} }
for (Index = 0; Index < NumberOfHandles; Index++) { for (Index = 0; Index < NumberOfHandles; Index++) {
@ -345,7 +345,7 @@ StrToVlanId (
return INVALID_VLAN_ID; return INVALID_VLAN_ID;
} }
return (UINT16) StrDecimalToUintn (String); return (UINT16)StrDecimalToUintn (String);
} }
/** /**
@ -376,12 +376,12 @@ AddVlan (
if (ParamStr == NULL) { if (ParamStr == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_IF), mHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_IF), mHiiHandle);
return ; return;
} }
StrPtr = AllocateCopyPool (StrSize (ParamStr), ParamStr); StrPtr = AllocateCopyPool (StrSize (ParamStr), ParamStr);
if (StrPtr == NULL) { if (StrPtr == NULL) {
return ; return;
} }
Name = StrPtr; Name = StrPtr;
@ -459,7 +459,7 @@ AddVlan (
// //
// Set VLAN // Set VLAN
// //
Status = VlanConfig->Set (VlanConfig, (UINT16) VlanId, (UINT8) Priority); Status = VlanConfig->Set (VlanConfig, (UINT16)VlanId, (UINT8)Priority);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_SET_FAIL), mHiiHandle, Status); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_SET_FAIL), mHiiHandle, Status);
goto Exit; goto Exit;
@ -468,7 +468,7 @@ AddVlan (
// //
// Connect the VLAN device. // Connect the VLAN device.
// //
VlanHandle = NetLibGetVlanHandle (Handle, (UINT16) VlanId); VlanHandle = NetLibGetVlanHandle (Handle, (UINT16)VlanId);
if (VlanHandle != NULL) { if (VlanHandle != NULL) {
gBS->ConnectController (VlanHandle, NULL, NULL, TRUE); gBS->ConnectController (VlanHandle, NULL, NULL, TRUE);
} }
@ -508,12 +508,12 @@ DeleteVlan (
if (ParamStr == NULL) { if (ParamStr == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_IF), mHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_IF), mHiiHandle);
return ; return;
} }
StrPtr = AllocateCopyPool (StrSize (ParamStr), ParamStr); StrPtr = AllocateCopyPool (StrSize (ParamStr), ParamStr);
if (StrPtr == NULL) { if (StrPtr == NULL) {
return ; return;
} }
Name = StrPtr; Name = StrPtr;
@ -541,7 +541,7 @@ DeleteVlan (
// //
// Check VLAN ID // Check VLAN ID
// //
if (VlanIdStr == NULL || *VlanIdStr == 0) { if ((VlanIdStr == NULL) || (*VlanIdStr == 0)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_VID), mHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_VID), mHiiHandle);
goto Exit; goto Exit;
} }
@ -555,7 +555,7 @@ DeleteVlan (
// //
// Delete VLAN. // Delete VLAN.
// //
Status = VlanConfig->Remove (VlanConfig, (UINT16) VlanId); Status = VlanConfig->Remove (VlanConfig, (UINT16)VlanId);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NOT_FOUND), mHiiHandle); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NOT_FOUND), mHiiHandle);
@ -619,7 +619,7 @@ VlanConfigMain (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ImageHandle, ImageHandle,
&gEfiHiiPackageListProtocolGuid, &gEfiHiiPackageListProtocolGuid,
(VOID **) &PackageList, (VOID **)&PackageList,
ImageHandle, ImageHandle,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -654,19 +654,19 @@ VlanConfigMain (
if (ShellCommandLineGetFlag (List, L"-l")) { if (ShellCommandLineGetFlag (List, L"-l")) {
Str = ShellCommandLineGetValue (List, L"-l"); Str = ShellCommandLineGetValue (List, L"-l");
DisplayVlan ((CHAR16 *) Str); DisplayVlan ((CHAR16 *)Str);
goto Exit; goto Exit;
} }
if (ShellCommandLineGetFlag (List, L"-a")) { if (ShellCommandLineGetFlag (List, L"-a")) {
Str = ShellCommandLineGetValue (List, L"-a"); Str = ShellCommandLineGetValue (List, L"-a");
AddVlan ((CHAR16 *) Str); AddVlan ((CHAR16 *)Str);
goto Exit; goto Exit;
} }
if (ShellCommandLineGetFlag (List, L"-d")) { if (ShellCommandLineGetFlag (List, L"-d")) {
Str = ShellCommandLineGetValue (List, L"-d"); Str = ShellCommandLineGetValue (List, L"-d");
DeleteVlan ((CHAR16 *) Str); DeleteVlan ((CHAR16 *)Str);
goto Exit; goto Exit;
} }

View File

@ -18,7 +18,6 @@ EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = {
NULL NULL
}; };
/** /**
Create and initialize the arp service context data. Create and initialize the arp service context data.
@ -176,7 +175,6 @@ ERROR_EXIT:
return Status; return Status;
} }
/** /**
Clean the arp service context data. Clean the arp service context data.
@ -226,7 +224,7 @@ ArpCleanService (
// //
// Destroy the mnp child. // Destroy the mnp child.
// //
NetLibDestroyServiceChild( NetLibDestroyServiceChild (
ArpService->ControllerHandle, ArpService->ControllerHandle,
ArpService->ImageHandle, ArpService->ImageHandle,
&gEfiManagedNetworkServiceBindingProtocolGuid, &gEfiManagedNetworkServiceBindingProtocolGuid,
@ -255,12 +253,12 @@ ArpDestroyChildEntryInHandleBuffer (
ARP_INSTANCE_DATA *Instance; ARP_INSTANCE_DATA *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
if (Entry == NULL || Context == NULL) { if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Instance = NET_LIST_USER_STRUCT_S (Entry, ARP_INSTANCE_DATA, List, ARP_INSTANCE_DATA_SIGNATURE); Instance = NET_LIST_USER_STRUCT_S (Entry, ARP_INSTANCE_DATA, List, ARP_INSTANCE_DATA_SIGNATURE);
ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context;
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
} }
@ -334,7 +332,6 @@ ArpDriverBindingSupported (
return Status; return Status;
} }
/** /**
Start this driver on ControllerHandle. Start this driver on ControllerHandle.
@ -380,7 +377,7 @@ ArpDriverBindingStart (
// //
// Allocate a zero pool for ArpService. // Allocate a zero pool for ArpService.
// //
ArpService = AllocateZeroPool (sizeof(ARP_SERVICE_DATA)); ArpService = AllocateZeroPool (sizeof (ARP_SERVICE_DATA));
if (ArpService == NULL) { if (ArpService == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -427,7 +424,6 @@ ERROR:
return Status; return Status;
} }
/** /**
Stop this driver on ControllerHandle. Stop this driver on ControllerHandle.
@ -576,7 +572,7 @@ ArpServiceBindingCreateChild (
// //
// Allocate memory for the instance context data. // Allocate memory for the instance context data.
// //
Instance = AllocateZeroPool (sizeof(ARP_INSTANCE_DATA)); Instance = AllocateZeroPool (sizeof (ARP_INSTANCE_DATA));
if (Instance == NULL) { if (Instance == NULL) {
DEBUG ((DEBUG_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n")); DEBUG ((DEBUG_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n"));
@ -615,7 +611,7 @@ ArpServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ArpService->MnpChildHandle, ArpService->MnpChildHandle,
&gEfiManagedNetworkProtocolGuid, &gEfiManagedNetworkProtocolGuid,
(VOID **) &Mnp, (VOID **)&Mnp,
gArpDriverBinding.DriverBindingHandle, gArpDriverBinding.DriverBindingHandle,
Instance->Handle, Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -637,7 +633,6 @@ ArpServiceBindingCreateChild (
ERROR: ERROR:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->CloseProtocol ( gBS->CloseProtocol (
ArpService->MnpChildHandle, ArpService->MnpChildHandle,
&gEfiManagedNetworkProtocolGuid, &gEfiManagedNetworkProtocolGuid,
@ -661,7 +656,6 @@ ERROR:
return Status; return Status;
} }
/** /**
Destroys a child handle with a protocol installed on it. Destroys a child handle with a protocol installed on it.
@ -746,8 +740,11 @@ ArpServiceBindingDestroyChild (
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n", DEBUG ((
Status)); DEBUG_ERROR,
"ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",
Status
));
Instance->InDestroy = FALSE; Instance->InDestroy = FALSE;
return Status; return Status;

View File

@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _ARP_DRIVER_H_ #ifndef _ARP_DRIVER_H_
#define _ARP_DRIVER_H_ #define _ARP_DRIVER_H_
#include <Uefi.h> #include <Uefi.h>
#include <Protocol/Arp.h> #include <Protocol/Arp.h>
@ -21,7 +20,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h> #include <Library/UefiLib.h>
// //
// Global variables // Global variables
// //
@ -32,6 +30,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2;
// //
// Function prototypes for the Driver Binding Protocol // Function prototypes for the Driver Binding Protocol
// //
/** /**
Tests to see if this driver supports a given controller. Tests to see if this driver supports a given controller.
@ -199,10 +198,10 @@ ArpServiceBindingDestroyChild (
IN EFI_HANDLE ChildHandle IN EFI_HANDLE ChildHandle
); );
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user readable name of the driver. Retrieves a Unicode string that is the user readable name of the driver.
@ -250,7 +249,6 @@ ArpComponentNameGetDriverName (
OUT CHAR16 **DriverName OUT CHAR16 **DriverName
); );
/** /**
Retrieves a Unicode string that is the user readable name of the controller Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -329,6 +327,4 @@ ArpComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
#endif #endif

View File

@ -21,7 +21,6 @@ EFI_ARP_PROTOCOL mEfiArpProtocolTemplate = {
ArpCancel ArpCancel
}; };
/** /**
Initialize the instance context data. Initialize the instance context data.
@ -51,7 +50,6 @@ ArpInitInstance (
InitializeListHead (&Instance->List); InitializeListHead (&Instance->List);
} }
/** /**
Process the Arp packets received from Mnp, the procedure conforms to RFC826. Process the Arp packets received from Mnp, the procedure conforms to RFC826.
@ -119,7 +117,7 @@ ArpOnFrameRcvdDpc (
// //
// Convert the byte order of the multi-byte fields. // Convert the byte order of the multi-byte fields.
// //
Head = (ARP_HEAD *) RxData->PacketData; Head = (ARP_HEAD *)RxData->PacketData;
Head->HwType = NTOHS (Head->HwType); Head->HwType = NTOHS (Head->HwType);
Head->ProtoType = NTOHS (Head->ProtoType); Head->ProtoType = NTOHS (Head->ProtoType);
Head->OpCode = NTOHS (Head->OpCode); Head->OpCode = NTOHS (Head->OpCode);
@ -130,7 +128,8 @@ ArpOnFrameRcvdDpc (
if ((Head->HwType != ArpService->SnpMode.IfType) || if ((Head->HwType != ArpService->SnpMode.IfType) ||
(Head->HwAddrLen != ArpService->SnpMode.HwAddressSize) || (Head->HwAddrLen != ArpService->SnpMode.HwAddressSize) ||
(RxData->ProtocolType != ARP_ETHER_PROTO_TYPE)) { (RxData->ProtocolType != ARP_ETHER_PROTO_TYPE))
{
// //
// The hardware type or the hardware address length doesn't match. // The hardware type or the hardware address length doesn't match.
// There is a sanity check for the protocol type too. // There is a sanity check for the protocol type too.
@ -183,7 +182,8 @@ ArpOnFrameRcvdDpc (
if ((Instance->Configured) && if ((Instance->Configured) &&
(Head->ProtoType == ConfigData->SwAddressType) && (Head->ProtoType == ConfigData->SwAddressType) &&
(Head->ProtoAddrLen == ConfigData->SwAddressLength)) { (Head->ProtoAddrLen == ConfigData->SwAddressLength))
{
// //
// The protocol type is matched for the received arp packet. // The protocol type is matched for the received arp packet.
// //
@ -192,7 +192,8 @@ ArpOnFrameRcvdDpc (
(VOID *)ArpAddress.TargetProtoAddr, (VOID *)ArpAddress.TargetProtoAddr,
ConfigData->StationAddress, ConfigData->StationAddress,
ConfigData->SwAddressLength ConfigData->SwAddressLength
)) { ))
{
// //
// The arp driver has the target address required by the received arp packet. // The arp driver has the target address required by the received arp packet.
// //
@ -306,9 +307,14 @@ RESTART_RECEIVE:
DEBUG_CODE_BEGIN (); DEBUG_CODE_BEGIN ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "ArpOnFrameRcvd: ArpService->Mnp->Receive " DEBUG ((
"failed, %r\n.", Status)); DEBUG_ERROR,
"ArpOnFrameRcvd: ArpService->Mnp->Receive "
"failed, %r\n.",
Status
));
} }
DEBUG_CODE_END (); DEBUG_CODE_END ();
} }
@ -362,6 +368,7 @@ ArpOnFrameSentDpc (
if (EFI_ERROR (TxToken->Status)) { if (EFI_ERROR (TxToken->Status)) {
DEBUG ((DEBUG_ERROR, "ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status)); DEBUG ((DEBUG_ERROR, "ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status));
} }
DEBUG_CODE_END (); DEBUG_CODE_END ();
// //
@ -396,7 +403,6 @@ ArpOnFrameSent (
QueueDpc (TPL_CALLBACK, ArpOnFrameSentDpc, Context); QueueDpc (TPL_CALLBACK, ArpOnFrameSentDpc, Context);
} }
/** /**
Process the arp cache olding and drive the retrying arp requests. Process the arp cache olding and drive the retrying arp requests.
@ -449,7 +455,7 @@ ArpTimerHandler (
// //
// resend the ARP request. // resend the ARP request.
// //
ASSERT (!IsListEmpty(&CacheEntry->UserRequestList)); ASSERT (!IsListEmpty (&CacheEntry->UserRequestList));
ContextEntry = CacheEntry->UserRequestList.ForwardLink; ContextEntry = CacheEntry->UserRequestList.ForwardLink;
RequestContext = NET_LIST_USER_STRUCT (ContextEntry, USER_REQUEST_CONTEXT, List); RequestContext = NET_LIST_USER_STRUCT (ContextEntry, USER_REQUEST_CONTEXT, List);
@ -524,7 +530,6 @@ ArpTimerHandler (
} }
} }
/** /**
Match the two NET_ARP_ADDRESSes. Match the two NET_ARP_ADDRESSes.
@ -543,7 +548,8 @@ ArpMatchAddress (
ASSERT (AddressOne != NULL && AddressTwo != NULL); ASSERT (AddressOne != NULL && AddressTwo != NULL);
if ((AddressOne->Type != AddressTwo->Type) || if ((AddressOne->Type != AddressTwo->Type) ||
(AddressOne->Length != AddressTwo->Length)) { (AddressOne->Length != AddressTwo->Length))
{
// //
// Either Type or Length doesn't match. // Either Type or Length doesn't match.
// //
@ -555,7 +561,8 @@ ArpMatchAddress (
AddressOne->AddressPtr, AddressOne->AddressPtr,
AddressTwo->AddressPtr, AddressTwo->AddressPtr,
AddressOne->Length AddressOne->Length
) != 0)) { ) != 0))
{
// //
// The address is not the same. // The address is not the same.
// //
@ -565,7 +572,6 @@ ArpMatchAddress (
return TRUE; return TRUE;
} }
/** /**
Find the CacheEntry which matches the requirements in the specified CacheTable. Find the CacheEntry which matches the requirements in the specified CacheTable.
@ -637,7 +643,6 @@ ArpFindNextCacheEntryInTable (
return NULL; return NULL;
} }
/** /**
Find the CacheEntry, using ProtocolAddress or HardwareAddress or both, as the keyword, Find the CacheEntry, using ProtocolAddress or HardwareAddress or both, as the keyword,
in the DeniedCacheTable. in the DeniedCacheTable.
@ -698,7 +703,6 @@ ArpFindDeniedCacheEntry (
return CacheEntry; return CacheEntry;
} }
/** /**
Allocate a cache entry and initialize it. Allocate a cache entry and initialize it.
@ -765,7 +769,6 @@ ArpAllocCacheEntry (
return CacheEntry; return CacheEntry;
} }
/** /**
Turn the CacheEntry into the resolved status. Turn the CacheEntry into the resolved status.
@ -797,7 +800,8 @@ ArpAddressResolved (
Context = NET_LIST_USER_STRUCT (Entry, USER_REQUEST_CONTEXT, List); Context = NET_LIST_USER_STRUCT (Entry, USER_REQUEST_CONTEXT, List);
if (((Instance == NULL) || (Context->Instance == Instance)) && if (((Instance == NULL) || (Context->Instance == Instance)) &&
((UserEvent == NULL) || (Context->UserRequestEvent == UserEvent))) { ((UserEvent == NULL) || (Context->UserRequestEvent == UserEvent)))
{
// //
// Copy the address to the user-provided buffer and notify the user. // Copy the address to the user-provided buffer and notify the user.
// //
@ -826,7 +830,6 @@ ArpAddressResolved (
return Count; return Count;
} }
/** /**
Fill the addresses in the CacheEntry using the information passed in by Fill the addresses in the CacheEntry using the information passed in by
HwAddr and SwAddr. HwAddr and SwAddr.
@ -881,7 +884,6 @@ ArpFillAddressInCacheEntry (
} }
} }
/** /**
Configure the instance using the ConfigData. ConfigData is already validated. Configure the instance using the ConfigData. ConfigData is already validated.
@ -912,7 +914,6 @@ ArpConfigureInstance (
OldConfigData = &Instance->ConfigData; OldConfigData = &Instance->ConfigData;
if (ConfigData != NULL) { if (ConfigData != NULL) {
if (Instance->Configured) { if (Instance->Configured) {
// //
// The instance is configured, check the unchangeable fields. // The instance is configured, check the unchangeable fields.
@ -923,7 +924,8 @@ ArpConfigureInstance (
OldConfigData->StationAddress, OldConfigData->StationAddress,
ConfigData->StationAddress, ConfigData->StationAddress,
OldConfigData->SwAddressLength OldConfigData->SwAddressLength
) != 0)) { ) != 0))
{
// //
// Deny the unallowed changes. // Deny the unallowed changes.
// //
@ -952,8 +954,11 @@ ArpConfigureInstance (
OldConfigData->StationAddress = AllocatePool (OldConfigData->SwAddressLength); OldConfigData->StationAddress = AllocatePool (OldConfigData->SwAddressLength);
if (OldConfigData->StationAddress == NULL) { if (OldConfigData->StationAddress == NULL) {
DEBUG ((DEBUG_ERROR, "ArpConfigInstance: AllocatePool for the StationAddress " DEBUG ((
"failed.\n")); DEBUG_ERROR,
"ArpConfigInstance: AllocatePool for the StationAddress "
"failed.\n"
));
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -1006,7 +1011,6 @@ ArpConfigureInstance (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Send out an arp frame using the CacheEntry and the ArpOpCode. Send out an arp frame using the CacheEntry and the ArpOpCode.
@ -1042,7 +1046,7 @@ ArpSendFrame (
// //
// Allocate memory for the TxToken. // Allocate memory for the TxToken.
// //
TxToken = AllocatePool (sizeof(EFI_MANAGED_NETWORK_COMPLETION_TOKEN)); TxToken = AllocatePool (sizeof (EFI_MANAGED_NETWORK_COMPLETION_TOKEN));
if (TxToken == NULL) { if (TxToken == NULL) {
DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxToken failed.\n")); DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxToken failed.\n"));
return; return;
@ -1070,7 +1074,7 @@ ArpSendFrame (
// //
// Allocate memory for the TxData used in the TxToken. // Allocate memory for the TxData used in the TxToken.
// //
TxData = AllocatePool (sizeof(EFI_MANAGED_NETWORK_TRANSMIT_DATA)); TxData = AllocatePool (sizeof (EFI_MANAGED_NETWORK_TRANSMIT_DATA));
if (TxData == NULL) { if (TxData == NULL) {
DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxData failed.\n")); DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxData failed.\n"));
goto CLEAN_EXIT; goto CLEAN_EXIT;
@ -1109,6 +1113,7 @@ ArpSendFrame (
SnpMode->HwAddressSize SnpMode->HwAddressSize
); );
} }
TmpPtr += SnpMode->HwAddressSize; TmpPtr += SnpMode->HwAddressSize;
// //
@ -1126,7 +1131,7 @@ ArpSendFrame (
// //
// The ARP Head. // The ARP Head.
// //
ArpHead = (ARP_HEAD *) TmpPtr; ArpHead = (ARP_HEAD *)TmpPtr;
ArpHead->HwType = HTONS ((UINT16)SnpMode->IfType); ArpHead->HwType = HTONS ((UINT16)SnpMode->IfType);
ArpHead->ProtoType = HTONS (ConfigData->SwAddressType); ArpHead->ProtoType = HTONS (ConfigData->SwAddressType);
ArpHead->HwAddrLen = (UINT8)SnpMode->HwAddressSize; ArpHead->HwAddrLen = (UINT8)SnpMode->HwAddressSize;
@ -1172,7 +1177,7 @@ ArpSendFrame (
TxData->SourceAddress = NULL; TxData->SourceAddress = NULL;
TxData->ProtocolType = 0; TxData->ProtocolType = 0;
TxData->DataLength = TotalLength - SnpMode->MediaHeaderSize; TxData->DataLength = TotalLength - SnpMode->MediaHeaderSize;
TxData->HeaderLength = (UINT16) SnpMode->MediaHeaderSize; TxData->HeaderLength = (UINT16)SnpMode->MediaHeaderSize;
TxData->FragmentCount = 1; TxData->FragmentCount = 1;
TxData->FragmentTable[0].FragmentBuffer = Packet; TxData->FragmentTable[0].FragmentBuffer = Packet;
@ -1212,7 +1217,6 @@ CLEAN_EXIT:
FreePool (TxToken); FreePool (TxToken);
} }
/** /**
Delete the cache entries in the specified CacheTable, using the BySwAddress, Delete the cache entries in the specified CacheTable, using the BySwAddress,
SwAddressType, AddressBuffer combination as the matching key, if Force is TRUE, SwAddressType, AddressBuffer combination as the matching key, if Force is TRUE,
@ -1265,7 +1269,8 @@ ArpDeleteCacheEntryInTable (
AddressBuffer, AddressBuffer,
CacheEntry->Addresses[Protocol].AddressPtr, CacheEntry->Addresses[Protocol].AddressPtr,
CacheEntry->Addresses[Protocol].Length CacheEntry->Addresses[Protocol].Length
) == 0)) { ) == 0))
{
// //
// Address matched. // Address matched.
// //
@ -1278,7 +1283,8 @@ ArpDeleteCacheEntryInTable (
AddressBuffer, AddressBuffer,
CacheEntry->Addresses[Hardware].AddressPtr, CacheEntry->Addresses[Hardware].AddressPtr,
CacheEntry->Addresses[Hardware].Length CacheEntry->Addresses[Hardware].Length
) == 0)) { ) == 0))
{
// //
// Address matched. // Address matched.
// //
@ -1303,7 +1309,6 @@ MATCHED:
return Count; return Count;
} }
/** /**
Delete cache entries in all the cache tables. Delete cache entries in all the cache tables.
@ -1357,7 +1362,6 @@ ArpDeleteCacheEntry (
return Count; return Count;
} }
/** /**
Cancel the arp request. Cancel the arp request.
@ -1396,7 +1400,8 @@ ArpCancelRequest (
TargetSwAddress, TargetSwAddress,
CacheEntry->Addresses[Protocol].AddressPtr, CacheEntry->Addresses[Protocol].AddressPtr,
CacheEntry->Addresses[Protocol].Length CacheEntry->Addresses[Protocol].Length
) == 0)) { ) == 0))
{
// //
// This request entry matches the TargetSwAddress or all requests are to be // This request entry matches the TargetSwAddress or all requests are to be
// cancelled as TargetSwAddress is NULL. // cancelled as TargetSwAddress is NULL.
@ -1416,7 +1421,6 @@ ArpCancelRequest (
return Count; return Count;
} }
/** /**
Find the cache entry in the cache table. Find the cache entry in the cache table.
@ -1572,7 +1576,7 @@ ArpFindCacheEntry (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
FoundCount = (UINT32) NetMapGetCount (&FoundEntries); FoundCount = (UINT32)NetMapGetCount (&FoundEntries);
if (FoundCount == 0) { if (FoundCount == 0) {
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
goto CLEAN_EXIT; goto CLEAN_EXIT;

View File

@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _ARP_IMPL_H_ #ifndef _ARP_IMPL_H_
#define _ARP_IMPL_H_ #define _ARP_IMPL_H_
#include <Uefi.h> #include <Uefi.h>
#include <Protocol/Arp.h> #include <Protocol/Arp.h>

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "ArpImpl.h" #include "ArpImpl.h"
/** /**
This function is used to assign a station address to the ARP cache for this instance This function is used to assign a station address to the ARP cache for this instance
of the ARP driver. of the ARP driver.
@ -55,7 +54,8 @@ ArpConfigure (
if ((ConfigData != NULL) && if ((ConfigData != NULL) &&
((ConfigData->SwAddressLength == 0) || ((ConfigData->SwAddressLength == 0) ||
(ConfigData->StationAddress == NULL) || (ConfigData->StationAddress == NULL) ||
(ConfigData->SwAddressType <= 1500))) { (ConfigData->SwAddressType <= 1500)))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -73,7 +73,6 @@ ArpConfigure (
return Status; return Status;
} }
/** /**
This function is used to insert entries into the ARP cache. This function is used to insert entries into the ARP cache.
@ -144,7 +143,8 @@ ArpAdd (
if (((!DenyFlag) && ((TargetHwAddress == NULL) || (TargetSwAddress == NULL))) || if (((!DenyFlag) && ((TargetHwAddress == NULL) || (TargetSwAddress == NULL))) ||
(DenyFlag && (TargetHwAddress != NULL) && (TargetSwAddress != NULL)) || (DenyFlag && (TargetHwAddress != NULL) && (TargetSwAddress != NULL)) ||
((TargetHwAddress == NULL) && (TargetSwAddress == NULL))) { ((TargetHwAddress == NULL) && (TargetSwAddress == NULL)))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -162,7 +162,7 @@ ArpAdd (
// Fill the hardware address part in the MatchAddress. // Fill the hardware address part in the MatchAddress.
// //
MatchAddress[Hardware].Type = SnpMode->IfType; MatchAddress[Hardware].Type = SnpMode->IfType;
MatchAddress[Hardware].Length = (UINT8) SnpMode->HwAddressSize; MatchAddress[Hardware].Length = (UINT8)SnpMode->HwAddressSize;
MatchAddress[Hardware].AddressPtr = TargetHwAddress; MatchAddress[Hardware].AddressPtr = TargetHwAddress;
// //
@ -271,7 +271,6 @@ UNLOCK_EXIT:
return Status; return Status;
} }
/** /**
This function searches the ARP cache for matching entries and allocates a buffer into This function searches the ARP cache for matching entries and allocates a buffer into
which those entries are copied. which those entries are copied.
@ -324,7 +323,8 @@ ArpFind (
if ((This == NULL) || if ((This == NULL) ||
(!Refresh && (EntryCount == NULL) && (EntryLength == NULL)) || (!Refresh && (EntryCount == NULL) && (EntryLength == NULL)) ||
((Entries != NULL) && ((EntryLength == NULL) || (EntryCount == NULL)))) { ((Entries != NULL) && ((EntryLength == NULL) || (EntryCount == NULL))))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -354,7 +354,6 @@ ArpFind (
return Status; return Status;
} }
/** /**
This function removes specified ARP cache entries. This function removes specified ARP cache entries.
@ -406,7 +405,6 @@ ArpDelete (
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS; return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
} }
/** /**
This function delete all dynamic entries from the ARP cache that match the specified This function delete all dynamic entries from the ARP cache that match the specified
software protocol type. software protocol type.
@ -451,7 +449,6 @@ ArpFlush (
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS; return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
} }
/** /**
This function tries to resolve the TargetSwAddress and optionally returns a This function tries to resolve the TargetSwAddress and optionally returns a
TargetHwAddress if it already exists in the ARP cache. TargetHwAddress if it already exists in the ARP cache.
@ -509,7 +506,8 @@ ArpRequest (
if ((TargetSwAddress == NULL) || if ((TargetSwAddress == NULL) ||
((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) && ((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) &&
IP4_IS_LOCAL_BROADCAST (*((UINT32 *)TargetSwAddress)))) { IP4_IS_LOCAL_BROADCAST (*((UINT32 *)TargetSwAddress))))
{
// //
// Return the hardware broadcast address. // Return the hardware broadcast address.
// //
@ -519,7 +517,8 @@ ArpRequest (
} }
if ((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) && if ((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) &&
IP4_IS_MULTICAST (NTOHL (*((UINT32 *)TargetSwAddress)))) { IP4_IS_MULTICAST (NTOHL (*((UINT32 *)TargetSwAddress))))
{
// //
// If the software address is an IPv4 multicast address, invoke Mnp to // If the software address is an IPv4 multicast address, invoke Mnp to
// resolve the address. // resolve the address.
@ -588,7 +587,7 @@ ArpRequest (
// //
// Create a request context for this arp request. // Create a request context for this arp request.
// //
RequestContext = AllocatePool (sizeof(USER_REQUEST_CONTEXT)); RequestContext = AllocatePool (sizeof (USER_REQUEST_CONTEXT));
if (RequestContext == NULL) { if (RequestContext == NULL) {
DEBUG ((DEBUG_ERROR, "ArpRequest: Allocate memory for RequestContext failed.\n")); DEBUG ((DEBUG_ERROR, "ArpRequest: Allocate memory for RequestContext failed.\n"));
@ -612,7 +611,6 @@ ArpRequest (
NULL NULL
); );
if (CacheEntry != NULL) { if (CacheEntry != NULL) {
CacheEntry->NextRetryTime = Instance->ConfigData.RetryTimeOut; CacheEntry->NextRetryTime = Instance->ConfigData.RetryTimeOut;
CacheEntry->RetryCount = Instance->ConfigData.RetryCount; CacheEntry->RetryCount = Instance->ConfigData.RetryCount;
} else { } else {
@ -668,7 +666,6 @@ SIGNAL_USER:
return Status; return Status;
} }
/** /**
This function aborts the previous ARP request (identified by This, TargetSwAddress This function aborts the previous ARP request (identified by This, TargetSwAddress
and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request(). and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().
@ -710,7 +707,8 @@ ArpCancel (
if ((This == NULL) || if ((This == NULL) ||
((TargetSwAddress != NULL) && (ResolvedEvent == NULL)) || ((TargetSwAddress != NULL) && (ResolvedEvent == NULL)) ||
((TargetSwAddress == NULL) && (ResolvedEvent != NULL))) { ((TargetSwAddress == NULL) && (ResolvedEvent != NULL)))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "ArpDriver.h" #include "ArpDriver.h"
// //
// EFI Component Name Protocol // EFI Component Name Protocol
// //
@ -22,12 +21,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gArpComponentName = {
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ArpComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)ArpComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ArpComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)ArpComponentNameGetControllerName,
"en" "en"
}; };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = {
{ "eng;en", L"ARP Network Service Driver" }, { "eng;en", L"ARP Network Service Driver" },
{ NULL, NULL } { NULL, NULL }

View File

@ -5,12 +5,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include "Dhcp4Impl.h" #include "Dhcp4Impl.h"
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user readable name of the driver. Retrieves a Unicode string that is the user readable name of the driver.
@ -58,7 +58,6 @@ DhcpComponentNameGetDriverName (
OUT CHAR16 **DriverName OUT CHAR16 **DriverName
); );
/** /**
Retrieves a Unicode string that is the user readable name of the controller Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -137,7 +136,6 @@ DhcpComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
// //
// EFI Component Name Protocol // EFI Component Name Protocol
// //
@ -151,12 +149,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName =
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) DhcpComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)DhcpComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) DhcpComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)DhcpComponentNameGetControllerName,
"en" "en"
}; };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] = {
{ {
"eng;en", "eng;en",

View File

@ -53,7 +53,6 @@ Dhcp4DriverEntryPoint (
); );
} }
/** /**
Test to see if this driver supports ControllerHandle. This service Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In is called by the EFI boot service ConnectController(). In
@ -94,8 +93,6 @@ Dhcp4DriverBindingSupported (
return Status; return Status;
} }
/** /**
Configure the default UDP child to receive all the DHCP traffics Configure the default UDP child to receive all the DHCP traffics
on this network interface. on this network interface.
@ -134,11 +131,9 @@ DhcpConfigUdpIo (
ZeroMem (&UdpConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); ZeroMem (&UdpConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
ZeroMem (&UdpConfigData.RemoteAddress, sizeof (EFI_IPv4_ADDRESS)); ZeroMem (&UdpConfigData.RemoteAddress, sizeof (EFI_IPv4_ADDRESS));
return UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, &UdpConfigData);; return UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, &UdpConfigData);
} }
/** /**
Destroy the DHCP service. The Dhcp4 service may be partly initialized, Destroy the DHCP service. The Dhcp4 service may be partly initialized,
or partly destroyed. If a resource is destroyed, it is marked as so in or partly destroyed. If a resource is destroyed, it is marked as so in
@ -171,8 +166,6 @@ Dhcp4CloseService (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Create a new DHCP service binding instance for the controller. Create a new DHCP service binding instance for the controller.
@ -244,7 +237,7 @@ Dhcp4CreateService (
goto ON_ERROR; goto ON_ERROR;
} }
DhcpSb->HwLen = (UINT8) DhcpSb->UdpIo->SnpMode.HwAddressSize; DhcpSb->HwLen = (UINT8)DhcpSb->UdpIo->SnpMode.HwAddressSize;
DhcpSb->HwType = DhcpSb->UdpIo->SnpMode.IfType; DhcpSb->HwType = DhcpSb->UdpIo->SnpMode.IfType;
CopyMem (&DhcpSb->Mac, &DhcpSb->UdpIo->SnpMode.CurrentAddress, sizeof (DhcpSb->Mac)); CopyMem (&DhcpSb->Mac, &DhcpSb->UdpIo->SnpMode.CurrentAddress, sizeof (DhcpSb->Mac));
@ -258,7 +251,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Start this driver on ControllerHandle. This service is called by the Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make EFI boot service ConnectController(). In order to make
@ -309,6 +301,7 @@ Dhcp4DriverBindingStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
ASSERT (DhcpSb != NULL); ASSERT (DhcpSb != NULL);
// //
@ -319,6 +312,7 @@ Dhcp4DriverBindingStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
Status = gBS->SetTimer (DhcpSb->Timer, TimerPeriodic, TICKS_PER_SECOND); Status = gBS->SetTimer (DhcpSb->Timer, TimerPeriodic, TICKS_PER_SECOND);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -367,17 +361,16 @@ Dhcp4DestroyChildEntry (
DHCP_PROTOCOL *Instance; DHCP_PROTOCOL *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
if (Entry == NULL || Context == NULL) { if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP_PROTOCOL, Link, DHCP_PROTOCOL_SIGNATURE); Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP_PROTOCOL, Link, DHCP_PROTOCOL_SIGNATURE);
ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context;
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
} }
/** /**
Stop this driver on ControllerHandle. This service is called by the Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to EFI boot service DisconnectController(). In order to
@ -425,7 +418,7 @@ Dhcp4DriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiDhcp4ServiceBindingProtocolGuid, &gEfiDhcp4ServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
NicHandle, NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -447,16 +440,16 @@ Dhcp4DriverBindingStop (
ServiceBinding, ServiceBinding,
&ListLength &ListLength
); );
if (EFI_ERROR (Status) || ListLength != 0) { if (EFI_ERROR (Status) || (ListLength != 0)) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
} }
if (NumberOfChildren == 0 && !IsListEmpty (&DhcpSb->Children)) { if ((NumberOfChildren == 0) && !IsListEmpty (&DhcpSb->Children)) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
if (NumberOfChildren == 0 && IsListEmpty (&DhcpSb->Children)) { if ((NumberOfChildren == 0) && IsListEmpty (&DhcpSb->Children)) {
// //
// Destroy the service itself if no child instance left. // Destroy the service itself if no child instance left.
// //
@ -474,6 +467,7 @@ Dhcp4DriverBindingStop (
FreeUnicodeStringTable (gDhcpControllerNameTable); FreeUnicodeStringTable (gDhcpControllerNameTable);
gDhcpControllerNameTable = NULL; gDhcpControllerNameTable = NULL;
} }
FreePool (DhcpSb); FreePool (DhcpSb);
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -482,7 +476,6 @@ Dhcp4DriverBindingStop (
return Status; return Status;
} }
/** /**
Initialize a new DHCP instance. Initialize a new DHCP instance.
@ -510,7 +503,6 @@ DhcpInitProtocol (
NetbufQueInit (&Instance->ResponseQueue); NetbufQueInit (&Instance->ResponseQueue);
} }
/** /**
Creates a child handle and installs a protocol. Creates a child handle and installs a protocol.
@ -579,7 +571,7 @@ Dhcp4ServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
DhcpSb->UdpIo->UdpHandle, DhcpSb->UdpIo->UdpHandle,
&gEfiUdp4ProtocolGuid, &gEfiUdp4ProtocolGuid,
(VOID **) &Udp4, (VOID **)&Udp4,
gDhcp4DriverBinding.DriverBindingHandle, gDhcp4DriverBinding.DriverBindingHandle,
Instance->Handle, Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -606,7 +598,6 @@ Dhcp4ServiceBindingCreateChild (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Destroys a child handle with a protocol installed on it. Destroys a child handle with a protocol installed on it.
@ -648,7 +639,7 @@ Dhcp4ServiceBindingDestroyChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiDhcp4ProtocolGuid, &gEfiDhcp4ProtocolGuid,
(VOID **) &Dhcp, (VOID **)&Dhcp,
gDhcp4DriverBinding.DriverBindingHandle, gDhcp4DriverBinding.DriverBindingHandle,
ChildHandle, ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL

View File

@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include "Dhcp4Impl.h" #include "Dhcp4Impl.h"
/** /**
@ -374,7 +373,7 @@ EfiDhcp4GetModeData (
// Caller can use GetModeData to retrieve current DHCP states // Caller can use GetModeData to retrieve current DHCP states
// no matter whether it is the active child or not. // no matter whether it is the active child or not.
// //
Dhcp4ModeData->State = (EFI_DHCP4_STATE) DhcpSb->DhcpState; Dhcp4ModeData->State = (EFI_DHCP4_STATE)DhcpSb->DhcpState;
CopyMem (&Dhcp4ModeData->ConfigData, &DhcpSb->ActiveConfig, sizeof (Dhcp4ModeData->ConfigData)); CopyMem (&Dhcp4ModeData->ConfigData, &DhcpSb->ActiveConfig, sizeof (Dhcp4ModeData->ConfigData));
CopyMem (&Dhcp4ModeData->ClientMacAddress, &DhcpSb->Mac, sizeof (Dhcp4ModeData->ClientMacAddress)); CopyMem (&Dhcp4ModeData->ClientMacAddress, &DhcpSb->Mac, sizeof (Dhcp4ModeData->ClientMacAddress));
@ -404,7 +403,6 @@ EfiDhcp4GetModeData (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Free the resource related to the configure parameters. Free the resource related to the configure parameters.
DHCP driver will make a copy of the user's configure DHCP driver will make a copy of the user's configure
@ -441,7 +439,6 @@ DhcpCleanConfigure (
ZeroMem (Config, sizeof (EFI_DHCP4_CONFIG_DATA)); ZeroMem (Config, sizeof (EFI_DHCP4_CONFIG_DATA));
} }
/** /**
Allocate memory for configure parameter such as timeout value for Dst, Allocate memory for configure parameter such as timeout value for Dst,
then copy the configure parameter from Src to Dst. then copy the configure parameter from Src to Dst.
@ -536,7 +533,6 @@ ON_ERROR:
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
/** /**
Give up the control of the DHCP service to let other child Give up the control of the DHCP service to let other child
resume. Don't change the service's DHCP state and the Client resume. Don't change the service's DHCP state and the Client
@ -575,7 +571,6 @@ DhcpYieldControl (
Config->CallbackContext = NULL; Config->CallbackContext = NULL;
} }
/** /**
Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver. Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver.
@ -654,7 +649,7 @@ EfiDhcp4Configure (
} }
CopyMem (&Ip, &Dhcp4CfgData->ClientAddress, sizeof (IP4_ADDR)); CopyMem (&Ip, &Dhcp4CfgData->ClientAddress, sizeof (IP4_ADDR));
if (IP4_IS_LOCAL_BROADCAST(NTOHL (Ip))) { if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
@ -675,8 +670,8 @@ EfiDhcp4Configure (
if ((DhcpSb->DhcpState != Dhcp4Stopped) && if ((DhcpSb->DhcpState != Dhcp4Stopped) &&
(DhcpSb->DhcpState != Dhcp4Init) && (DhcpSb->DhcpState != Dhcp4Init) &&
(DhcpSb->DhcpState != Dhcp4InitReboot) && (DhcpSb->DhcpState != Dhcp4InitReboot) &&
(DhcpSb->DhcpState != Dhcp4Bound)) { (DhcpSb->DhcpState != Dhcp4Bound))
{
goto ON_EXIT; goto ON_EXIT;
} }
@ -712,7 +707,6 @@ EfiDhcp4Configure (
DhcpSb->ServiceState = DHCP_CONFIGED; DhcpSb->ServiceState = DHCP_CONFIGED;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} else if (DhcpSb->ActiveChild == Instance) { } else if (DhcpSb->ActiveChild == Instance) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
DhcpYieldControl (DhcpSb); DhcpYieldControl (DhcpSb);
@ -723,7 +717,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Starts the DHCP configuration process. Starts the DHCP configuration process.
@ -820,7 +813,6 @@ EfiDhcp4Start (
goto ON_ERROR; goto ON_ERROR;
} }
Instance->CompletionEvent = CompletionEvent; Instance->CompletionEvent = CompletionEvent;
// //
@ -843,7 +835,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Extends the lease time by sending a request packet. Extends the lease time by sending a request packet.
@ -946,7 +937,7 @@ EfiDhcp4RenewRebind (
DhcpSb->Selected, DhcpSb->Selected,
DhcpSb->Para, DhcpSb->Para,
DHCP_MSG_REQUEST, DHCP_MSG_REQUEST,
(UINT8 *) "Extra renew/rebind by the application" (UINT8 *)"Extra renew/rebind by the application"
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -963,7 +954,6 @@ EfiDhcp4RenewRebind (
if (CompletionEvent == NULL) { if (CompletionEvent == NULL) {
while (DhcpSb->IoStatus == EFI_ALREADY_STARTED) { while (DhcpSb->IoStatus == EFI_ALREADY_STARTED) {
DhcpSb->UdpIo->Protocol.Udp4->Poll (DhcpSb->UdpIo->Protocol.Udp4); DhcpSb->UdpIo->Protocol.Udp4->Poll (DhcpSb->UdpIo->Protocol.Udp4);
} }
return DhcpSb->IoStatus; return DhcpSb->IoStatus;
@ -976,7 +966,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Releases the current address configuration. Releases the current address configuration.
@ -1053,7 +1042,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Stops the current address configuration. Stops the current address configuration.
@ -1104,7 +1092,6 @@ EfiDhcp4Stop (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Builds a DHCP packet, given the options to be appended or deleted or replaced. Builds a DHCP packet, given the options to be appended or deleted or replaced.
@ -1152,15 +1139,15 @@ EfiDhcp4Build (
} }
if ((SeedPacket == NULL) || (SeedPacket->Dhcp4.Magik != DHCP_OPTION_MAGIC) || if ((SeedPacket == NULL) || (SeedPacket->Dhcp4.Magik != DHCP_OPTION_MAGIC) ||
EFI_ERROR (DhcpValidateOptions (SeedPacket, NULL))) { EFI_ERROR (DhcpValidateOptions (SeedPacket, NULL)))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (((DeleteCount == 0) && (AppendCount == 0)) || if (((DeleteCount == 0) && (AppendCount == 0)) ||
((DeleteCount != 0) && (DeleteList == NULL)) || ((DeleteCount != 0) && (DeleteList == NULL)) ||
((AppendCount != 0) && (AppendList == NULL))) { ((AppendCount != 0) && (AppendList == NULL)))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1201,7 +1188,7 @@ Dhcp4InstanceConfigUdpIo (
INTN Class; INTN Class;
IP4_ADDR SubnetMask; IP4_ADDR SubnetMask;
Instance = (DHCP_PROTOCOL *) Context; Instance = (DHCP_PROTOCOL *)Context;
DhcpSb = Instance->Service; DhcpSb = Instance->Service;
Token = Instance->Token; Token = Instance->Token;
@ -1284,7 +1271,7 @@ Dhcp4InstanceCreateUdpIo (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Instance->UdpIo->UdpHandle, Instance->UdpIo->UdpHandle,
&gEfiUdp4ProtocolGuid, &gEfiUdp4ProtocolGuid,
(VOID **) &Udp4, (VOID **)&Udp4,
Instance->Service->Image, Instance->Service->Image,
Instance->Handle, Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -1293,6 +1280,7 @@ Dhcp4InstanceCreateUdpIo (
UdpIoFreeIo (Instance->UdpIo); UdpIoFreeIo (Instance->UdpIo);
Instance->UdpIo = NULL; Instance->UdpIo = NULL;
} }
return Status; return Status;
} }
} }
@ -1341,14 +1329,14 @@ PxeDhcpInput (
EFI_STATUS Status; EFI_STATUS Status;
Wrap = NULL; Wrap = NULL;
Instance = (DHCP_PROTOCOL *) Context; Instance = (DHCP_PROTOCOL *)Context;
Token = Instance->Token; Token = Instance->Token;
// //
// Don't restart receive if error occurs or DHCP is destroyed. // Don't restart receive if error occurs or DHCP is destroyed.
// //
if (EFI_ERROR (IoStatus)) { if (EFI_ERROR (IoStatus)) {
return ; return;
} }
ASSERT (UdpPacket != NULL); ASSERT (UdpPacket != NULL);
@ -1370,12 +1358,12 @@ PxeDhcpInput (
goto RESTART; goto RESTART;
} }
Packet = (EFI_DHCP4_PACKET *) NetbufAllocSpace (Wrap, Len, NET_BUF_TAIL); Packet = (EFI_DHCP4_PACKET *)NetbufAllocSpace (Wrap, Len, NET_BUF_TAIL);
ASSERT (Packet != NULL); ASSERT (Packet != NULL);
Packet->Size = Len; Packet->Size = Len;
Head = &Packet->Dhcp4.Header; Head = &Packet->Dhcp4.Header;
Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *) Head); Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *)Head);
if (Packet->Length != UdpPacket->TotalSize) { if (Packet->Length != UdpPacket->TotalSize) {
goto RESTART; goto RESTART;
@ -1386,7 +1374,8 @@ PxeDhcpInput (
// //
if ((Head->OpCode != BOOTP_REPLY) || if ((Head->OpCode != BOOTP_REPLY) ||
(Head->Xid != Token->Packet->Dhcp4.Header.Xid) || (Head->Xid != Token->Packet->Dhcp4.Header.Xid) ||
(CompareMem (&Token->Packet->Dhcp4.Header.ClientHwAddr[0], Head->ClientHwAddr, Head->HwAddrLen) != 0)) { (CompareMem (&Token->Packet->Dhcp4.Header.ClientHwAddr[0], Head->ClientHwAddr, Head->HwAddrLen) != 0))
{
goto RESTART; goto RESTART;
} }
@ -1395,8 +1384,8 @@ PxeDhcpInput (
// //
if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) && if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) &&
(Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) && (Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) &&
EFI_ERROR (DhcpValidateOptions (Packet, NULL))) { EFI_ERROR (DhcpValidateOptions (Packet, NULL)))
{
goto RESTART; goto RESTART;
} }
@ -1437,7 +1426,7 @@ PxeDhcpDone (
Token->ResponseCount = Instance->ResponseQueue.BufNum; Token->ResponseCount = Instance->ResponseQueue.BufNum;
if (Token->ResponseCount != 0) { if (Token->ResponseCount != 0) {
Token->ResponseList = (EFI_DHCP4_PACKET *) AllocatePool (Instance->ResponseQueue.BufSize); Token->ResponseList = (EFI_DHCP4_PACKET *)AllocatePool (Instance->ResponseQueue.BufSize);
if (Token->ResponseList == NULL) { if (Token->ResponseList == NULL) {
Token->Status = EFI_OUT_OF_RESOURCES; Token->Status = EFI_OUT_OF_RESOURCES;
goto SIGNAL_USER; goto SIGNAL_USER;
@ -1446,7 +1435,7 @@ PxeDhcpDone (
// //
// Copy the received DHCP responses. // Copy the received DHCP responses.
// //
NetbufQueCopy (&Instance->ResponseQueue, 0, Instance->ResponseQueue.BufSize, (UINT8 *) Token->ResponseList); NetbufQueCopy (&Instance->ResponseQueue, 0, Instance->ResponseQueue.BufSize, (UINT8 *)Token->ResponseList);
Token->Status = EFI_SUCCESS; Token->Status = EFI_SUCCESS;
} else { } else {
Token->ResponseList = NULL; Token->ResponseList = NULL;
@ -1474,7 +1463,6 @@ SIGNAL_USER:
} }
} }
/** /**
Transmits a DHCP formatted packet and optionally waits for responses. Transmits a DHCP formatted packet and optionally waits for responses.
@ -1532,7 +1520,8 @@ EfiDhcp4TransmitReceive (
((Token->ListenPointCount != 0) && (Token->ListenPoints == NULL)) || ((Token->ListenPointCount != 0) && (Token->ListenPoints == NULL)) ||
EFI_ERROR (DhcpValidateOptions (Token->Packet, NULL)) || EFI_ERROR (DhcpValidateOptions (Token->Packet, NULL)) ||
EFI_IP4_EQUAL (&Token->RemoteAddress, &mZeroIp4Addr) EFI_IP4_EQUAL (&Token->RemoteAddress, &mZeroIp4Addr)
) { )
{
// //
// The DHCP packet isn't well-formed, the Transaction ID is already used, // The DHCP packet isn't well-formed, the Transaction ID is already used,
// the timeout value is zero, the ListenPoint is invalid, or the // the timeout value is zero, the ListenPoint is invalid, or the
@ -1575,7 +1564,7 @@ EfiDhcp4TransmitReceive (
// //
// Wrap the DHCP packet into a net buffer. // Wrap the DHCP packet into a net buffer.
// //
Frag.Bulk = (UINT8 *) &Token->Packet->Dhcp4; Frag.Bulk = (UINT8 *)&Token->Packet->Dhcp4;
Frag.Len = Token->Packet->Length; Frag.Len = Token->Packet->Length;
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL); Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
if (Wrap == NULL) { if (Wrap == NULL) {
@ -1667,7 +1656,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Callback function for DhcpIterateOptions. This callback sets the Callback function for DhcpIterateOptions. This callback sets the
EFI_DHCP4_PACKET_OPTION array in the DHCP_PARSE_CONTEXT to point EFI_DHCP4_PACKET_OPTION array in the DHCP_PARSE_CONTEXT to point
@ -1691,7 +1679,7 @@ Dhcp4ParseCheckOption (
{ {
DHCP_PARSE_CONTEXT *Parse; DHCP_PARSE_CONTEXT *Parse;
Parse = (DHCP_PARSE_CONTEXT *) Context; Parse = (DHCP_PARSE_CONTEXT *)Context;
Parse->Index++; Parse->Index++;
if (Parse->Index <= Parse->OptionCount) { if (Parse->Index <= Parse->OptionCount) {
@ -1706,7 +1694,6 @@ Dhcp4ParseCheckOption (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Parses the packed DHCP option data. Parses the packed DHCP option data.
@ -1755,8 +1742,8 @@ EfiDhcp4Parse (
if ((Packet->Size < Packet->Length + 2 * sizeof (UINT32)) || if ((Packet->Size < Packet->Length + 2 * sizeof (UINT32)) ||
(Packet->Dhcp4.Magik != DHCP_OPTION_MAGIC) || (Packet->Dhcp4.Magik != DHCP_OPTION_MAGIC) ||
EFI_ERROR (DhcpValidateOptions (Packet, NULL))) { EFI_ERROR (DhcpValidateOptions (Packet, NULL)))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1798,5 +1785,5 @@ SetElapsedTime (
IN DHCP_PROTOCOL *Instance IN DHCP_PROTOCOL *Instance
) )
{ {
WriteUnaligned16 (Elapsed, HTONS(Instance->ElaspedTime)); WriteUnaligned16 (Elapsed, HTONS (Instance->ElaspedTime));
} }

View File

@ -14,8 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __EFI_DHCP4_IMPL_H__ #ifndef __EFI_DHCP4_IMPL_H__
#define __EFI_DHCP4_IMPL_H__ #define __EFI_DHCP4_IMPL_H__
#include <Uefi.h> #include <Uefi.h>
#include <Protocol/Dhcp4.h> #include <Protocol/Dhcp4.h>
@ -50,7 +48,6 @@ typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
#define DHCP_CONFIGED 1 #define DHCP_CONFIGED 1
#define DHCP_DESTROY 2 #define DHCP_DESTROY 2
struct _DHCP_PROTOCOL { struct _DHCP_PROTOCOL {
UINT32 Signature; UINT32 Signature;
EFI_DHCP4_PROTOCOL Dhcp4Protocol; EFI_DHCP4_PROTOCOL Dhcp4Protocol;

View File

@ -6,12 +6,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include "Dhcp4Impl.h" #include "Dhcp4Impl.h"
UINT32 mDhcp4DefaultTimeout[4] = { 4, 8, 16, 32 }; UINT32 mDhcp4DefaultTimeout[4] = { 4, 8, 16, 32 };
/** /**
Send an initial DISCOVER or REQUEST message according to the Send an initial DISCOVER or REQUEST message according to the
DHCP service's current state. DHCP service's current state.
@ -34,7 +32,7 @@ DhcpInitRequest (
// //
// Clear initial time to make sure that elapsed-time is set to 0 for first Discover or REQUEST message. // Clear initial time to make sure that elapsed-time is set to 0 for first Discover or REQUEST message.
// //
DhcpSb->ActiveChild->ElaspedTime= 0; DhcpSb->ActiveChild->ElaspedTime = 0;
if (DhcpSb->DhcpState == Dhcp4Init) { if (DhcpSb->DhcpState == Dhcp4Init) {
DhcpSetState (DhcpSb, Dhcp4Selecting, FALSE); DhcpSetState (DhcpSb, Dhcp4Selecting, FALSE);
@ -57,7 +55,6 @@ DhcpInitRequest (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Call user provided callback function, and return the value the Call user provided callback function, and return the value the
function returns. If the user doesn't provide a callback, a function returns. If the user doesn't provide a callback, a
@ -109,7 +106,7 @@ DhcpCallUser (
Status = Config->Dhcp4Callback ( Status = Config->Dhcp4Callback (
&DhcpSb->ActiveChild->Dhcp4Protocol, &DhcpSb->ActiveChild->Dhcp4Protocol,
Config->CallbackContext, Config->CallbackContext,
(EFI_DHCP4_STATE) DhcpSb->DhcpState, (EFI_DHCP4_STATE)DhcpSb->DhcpState,
Event, Event,
Packet, Packet,
NewPacket NewPacket
@ -127,7 +124,6 @@ DhcpCallUser (
return EFI_ABORTED; return EFI_ABORTED;
} }
/** /**
Notify the user about the operation result. Notify the user about the operation result.
@ -144,28 +140,26 @@ DhcpNotifyUser (
DHCP_PROTOCOL *Child; DHCP_PROTOCOL *Child;
if ((Child = DhcpSb->ActiveChild) == NULL) { if ((Child = DhcpSb->ActiveChild) == NULL) {
return ; return;
} }
if ((Child->CompletionEvent != NULL) && if ((Child->CompletionEvent != NULL) &&
((Which == DHCP_NOTIFY_COMPLETION) || (Which == DHCP_NOTIFY_ALL)) ((Which == DHCP_NOTIFY_COMPLETION) || (Which == DHCP_NOTIFY_ALL))
) { )
{
gBS->SignalEvent (Child->CompletionEvent); gBS->SignalEvent (Child->CompletionEvent);
Child->CompletionEvent = NULL; Child->CompletionEvent = NULL;
} }
if ((Child->RenewRebindEvent != NULL) && if ((Child->RenewRebindEvent != NULL) &&
((Which == DHCP_NOTIFY_RENEWREBIND) || (Which == DHCP_NOTIFY_ALL)) ((Which == DHCP_NOTIFY_RENEWREBIND) || (Which == DHCP_NOTIFY_ALL))
) { )
{
gBS->SignalEvent (Child->RenewRebindEvent); gBS->SignalEvent (Child->RenewRebindEvent);
Child->RenewRebindEvent = NULL; Child->RenewRebindEvent = NULL;
} }
} }
/** /**
Set the DHCP state. If CallUser is true, it will try to notify Set the DHCP state. If CallUser is true, it will try to notify
the user before change the state by DhcpNotifyUser. It returns the user before change the state by DhcpNotifyUser. It returns
@ -195,13 +189,10 @@ DhcpSetState (
if (State == Dhcp4Renewing) { if (State == Dhcp4Renewing) {
Status = DhcpCallUser (DhcpSb, Dhcp4EnterRenewing, NULL, NULL); Status = DhcpCallUser (DhcpSb, Dhcp4EnterRenewing, NULL, NULL);
} else if (State == Dhcp4Rebinding) { } else if (State == Dhcp4Rebinding) {
Status = DhcpCallUser (DhcpSb, Dhcp4EnterRebinding, NULL, NULL); Status = DhcpCallUser (DhcpSb, Dhcp4EnterRebinding, NULL, NULL);
} else if (State == Dhcp4Bound) { } else if (State == Dhcp4Bound) {
Status = DhcpCallUser (DhcpSb, Dhcp4BoundCompleted, NULL, NULL); Status = DhcpCallUser (DhcpSb, Dhcp4BoundCompleted, NULL, NULL);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -231,7 +222,6 @@ DhcpSetState (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Set the retransmit timer for the packet. It will select from either Set the retransmit timer for the packet. It will select from either
the discover timeouts/request timeouts or the default timeout values. the discover timeouts/request timeouts or the default timeout values.
@ -298,7 +288,6 @@ DhcpComputeLease (
} }
} }
/** /**
Configure a UDP IO port to use the acquired lease address. Configure a UDP IO port to use the acquired lease address.
DHCP driver needs this port to unicast packet to the server DHCP driver needs this port to unicast packet to the server
@ -325,7 +314,7 @@ DhcpConfigLeaseIoPort (
EFI_STATUS Status; EFI_STATUS Status;
IP4_ADDR Ip; IP4_ADDR Ip;
DhcpSb = (DHCP_SERVICE *) Context; DhcpSb = (DHCP_SERVICE *)Context;
UdpConfigData.AcceptBroadcast = FALSE; UdpConfigData.AcceptBroadcast = FALSE;
UdpConfigData.AcceptPromiscuous = FALSE; UdpConfigData.AcceptPromiscuous = FALSE;
@ -370,7 +359,6 @@ DhcpConfigLeaseIoPort (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Update the lease states when a new lease is acquired. It will not only Update the lease states when a new lease is acquired. It will not only
save the acquired the address and lease time, it will also create a UDP save the acquired the address and lease time, it will also create a UDP
@ -426,7 +414,6 @@ DhcpLeaseAcquired (
return DhcpSetState (DhcpSb, Dhcp4Bound, TRUE); return DhcpSetState (DhcpSb, Dhcp4Bound, TRUE);
} }
/** /**
Clean up the DHCP related states, IoStatus isn't reset. Clean up the DHCP related states, IoStatus isn't reset.
@ -486,7 +473,6 @@ DhcpCleanLease (
DhcpCleanConfigure (&DhcpSb->ActiveConfig); DhcpCleanConfigure (&DhcpSb->ActiveConfig);
} }
/** /**
Select a offer among all the offers collected. If the offer selected is Select a offer among all the offers collected. If the offer selected is
of BOOTP, the lease is recorded and user notified. If the offer is of of BOOTP, the lease is recorded and user notified. If the offer is of
@ -524,7 +510,7 @@ DhcpChooseOffer (
Selected = DhcpSb->LastOffer; Selected = DhcpSb->LastOffer;
if ((NewPacket != NULL) && !EFI_ERROR (DhcpValidateOptions (NewPacket, NULL))) { if ((NewPacket != NULL) && !EFI_ERROR (DhcpValidateOptions (NewPacket, NULL))) {
TempPacket = (EFI_DHCP4_PACKET *) AllocatePool (NewPacket->Size); TempPacket = (EFI_DHCP4_PACKET *)AllocatePool (NewPacket->Size);
if (TempPacket != NULL) { if (TempPacket != NULL) {
CopyMem (TempPacket, NewPacket, NewPacket->Size); CopyMem (TempPacket, NewPacket, NewPacket->Size);
FreePool (Selected); FreePool (Selected);
@ -565,7 +551,6 @@ DhcpChooseOffer (
return DhcpSendMessage (DhcpSb, Selected, DhcpSb->Para, DHCP_MSG_REQUEST, NULL); return DhcpSendMessage (DhcpSb, Selected, DhcpSb->Para, DHCP_MSG_REQUEST, NULL);
} }
/** /**
Terminate the current address acquire. All the allocated resources Terminate the current address acquire. All the allocated resources
are released. Be careful when calling this function. A rule related are released. Be careful when calling this function. A rule related
@ -594,7 +579,6 @@ DhcpEndSession (
DhcpNotifyUser (DhcpSb, DHCP_NOTIFY_ALL); DhcpNotifyUser (DhcpSb, DHCP_NOTIFY_ALL);
} }
/** /**
Handle packets in DHCP select state. Handle packets in DHCP select state.
@ -626,7 +610,8 @@ DhcpHandleSelect (
// //
if (!DHCP_IS_BOOTP (Para) && if (!DHCP_IS_BOOTP (Para) &&
((Para->DhcpType != DHCP_MSG_OFFER) || (Para->ServerId == 0)) ((Para->DhcpType != DHCP_MSG_OFFER) || (Para->ServerId == 0))
) { )
{
goto ON_EXIT; goto ON_EXIT;
} }
@ -646,14 +631,12 @@ DhcpHandleSelect (
DhcpSb->LastOffer = Packet; DhcpSb->LastOffer = Packet;
return DhcpChooseOffer (DhcpSb); return DhcpChooseOffer (DhcpSb);
} else if (Status == EFI_NOT_READY) { } else if (Status == EFI_NOT_READY) {
if (DhcpSb->LastOffer != NULL) { if (DhcpSb->LastOffer != NULL) {
FreePool (DhcpSb->LastOffer); FreePool (DhcpSb->LastOffer);
} }
DhcpSb->LastOffer = Packet; DhcpSb->LastOffer = Packet;
} else if (Status == EFI_ABORTED) { } else if (Status == EFI_ABORTED) {
// //
// DhcpInput will end the session upon error return. Remember // DhcpInput will end the session upon error return. Remember
@ -669,7 +652,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Handle packets in DHCP request state. Handle packets in DHCP request state.
@ -705,8 +687,8 @@ DhcpHandleRequest (
if (DHCP_IS_BOOTP (Para) || if (DHCP_IS_BOOTP (Para) ||
(Para->ServerId != DhcpSb->Para->ServerId) || (Para->ServerId != DhcpSb->Para->ServerId) ||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK)) ((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
) { )
{
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
goto ON_EXIT; goto ON_EXIT;
} }
@ -727,14 +709,14 @@ DhcpHandleRequest (
Message = NULL; Message = NULL;
if (!EFI_IP4_EQUAL (&Head->YourAddr, &Selected->YourAddr)) { if (!EFI_IP4_EQUAL (&Head->YourAddr, &Selected->YourAddr)) {
Message = (UINT8 *) "Lease confirmed isn't the same as that in the offer"; Message = (UINT8 *)"Lease confirmed isn't the same as that in the offer";
goto REJECT; goto REJECT;
} }
Status = DhcpCallUser (DhcpSb, Dhcp4RcvdAck, Packet, NULL); Status = DhcpCallUser (DhcpSb, Dhcp4RcvdAck, Packet, NULL);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Message = (UINT8 *) "Lease is denied upon received ACK"; Message = (UINT8 *)"Lease is denied upon received ACK";
goto REJECT; goto REJECT;
} }
@ -744,7 +726,7 @@ DhcpHandleRequest (
Status = DhcpLeaseAcquired (DhcpSb); Status = DhcpLeaseAcquired (DhcpSb);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Message = (UINT8 *) "Lease is denied upon entering bound"; Message = (UINT8 *)"Lease is denied upon entering bound";
goto REJECT; goto REJECT;
} }
@ -762,7 +744,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Handle packets in DHCP renew/rebound state. Handle packets in DHCP renew/rebound state.
@ -797,8 +778,8 @@ DhcpHandleRenewRebind (
if (DHCP_IS_BOOTP (Para) || if (DHCP_IS_BOOTP (Para) ||
(Para->ServerId != DhcpSb->Para->ServerId) || (Para->ServerId != DhcpSb->Para->ServerId) ||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK)) ((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
) { )
{
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
goto ON_EXIT; goto ON_EXIT;
} }
@ -846,7 +827,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Handle packets in DHCP reboot state. Handle packets in DHCP reboot state.
@ -876,8 +856,8 @@ DhcpHandleReboot (
// //
if (DHCP_IS_BOOTP (Para) || if (DHCP_IS_BOOTP (Para) ||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK)) ((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
) { )
{
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
goto ON_EXIT; goto ON_EXIT;
} }
@ -932,7 +912,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Handle the received DHCP packets. This function drives the DHCP Handle the received DHCP packets. This function drives the DHCP
state machine. state machine.
@ -960,16 +939,16 @@ DhcpInput (
UINT32 Len; UINT32 Len;
Packet = NULL; Packet = NULL;
DhcpSb = (DHCP_SERVICE *) Context; DhcpSb = (DHCP_SERVICE *)Context;
// //
// Don't restart receive if error occurs or DHCP is destroyed. // Don't restart receive if error occurs or DHCP is destroyed.
// //
if (EFI_ERROR (IoStatus)) { if (EFI_ERROR (IoStatus)) {
return ; return;
} else if (DhcpSb->ServiceState == DHCP_DESTROY) { } else if (DhcpSb->ServiceState == DHCP_DESTROY) {
NetbufFree (UdpPacket); NetbufFree (UdpPacket);
return ; return;
} }
ASSERT (UdpPacket != NULL); ASSERT (UdpPacket != NULL);
@ -989,7 +968,7 @@ DhcpInput (
// Copy the DHCP message to a continuous memory block // Copy the DHCP message to a continuous memory block
// //
Len = sizeof (EFI_DHCP4_PACKET) + UdpPacket->TotalSize - sizeof (EFI_DHCP4_HEADER); Len = sizeof (EFI_DHCP4_PACKET) + UdpPacket->TotalSize - sizeof (EFI_DHCP4_HEADER);
Packet = (EFI_DHCP4_PACKET *) AllocatePool (Len); Packet = (EFI_DHCP4_PACKET *)AllocatePool (Len);
if (Packet == NULL) { if (Packet == NULL) {
goto RESTART; goto RESTART;
@ -997,7 +976,7 @@ DhcpInput (
Packet->Size = Len; Packet->Size = Len;
Head = &Packet->Dhcp4.Header; Head = &Packet->Dhcp4.Header;
Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *) Head); Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *)Head);
if (Packet->Length != UdpPacket->TotalSize) { if (Packet->Length != UdpPacket->TotalSize) {
goto RESTART; goto RESTART;
@ -1008,7 +987,8 @@ DhcpInput (
// //
if ((Head->OpCode != BOOTP_REPLY) || if ((Head->OpCode != BOOTP_REPLY) ||
(NTOHL (Head->Xid) != DhcpSb->Xid) || (NTOHL (Head->Xid) != DhcpSb->Xid) ||
(CompareMem (DhcpSb->ClientAddressSendOut, Head->ClientHwAddr, Head->HwAddrLen) != 0)) { (CompareMem (DhcpSb->ClientAddressSendOut, Head->ClientHwAddr, Head->HwAddrLen) != 0))
{
goto RESTART; goto RESTART;
} }
@ -1018,8 +998,8 @@ DhcpInput (
Para = NULL; Para = NULL;
if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) && if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) &&
(Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) && (Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) &&
EFI_ERROR (DhcpValidateOptions (Packet, &Para))) { EFI_ERROR (DhcpValidateOptions (Packet, &Para)))
{
goto RESTART; goto RESTART;
} }
@ -1073,7 +1053,7 @@ DhcpInput (
NetbufFree (UdpPacket); NetbufFree (UdpPacket);
UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0); UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0);
DhcpEndSession (DhcpSb, Status); DhcpEndSession (DhcpSb, Status);
return ; return;
} }
RESTART: RESTART:
@ -1111,8 +1091,6 @@ DhcpOnPacketSent (
NetbufFree (Packet); NetbufFree (Packet);
} }
/** /**
Build and transmit a DHCP message according to the current states. Build and transmit a DHCP message according to the current states.
This function implement the Table 5. of RFC 2131. Always transits This function implement the Table 5. of RFC 2131. Always transits
@ -1163,7 +1141,7 @@ DhcpSendMessage (
Len = sizeof (EFI_DHCP4_PACKET) + 128 + DhcpSb->UserOptionLen; Len = sizeof (EFI_DHCP4_PACKET) + 128 + DhcpSb->UserOptionLen;
if (Msg != NULL) { if (Msg != NULL) {
Len += (UINT32)AsciiStrLen ((CHAR8 *) Msg); Len += (UINT32)AsciiStrLen ((CHAR8 *)Msg);
} }
Packet = AllocatePool (Len); Packet = AllocatePool (Len);
@ -1192,7 +1170,7 @@ DhcpSendMessage (
Head->HwType = DhcpSb->HwType; Head->HwType = DhcpSb->HwType;
Head->HwAddrLen = DhcpSb->HwLen; Head->HwAddrLen = DhcpSb->HwLen;
Head->Xid = HTONL (DhcpSb->Xid); Head->Xid = HTONL (DhcpSb->Xid);
Head->Reserved = HTONS (0x8000); //Server, broadcast the message please. Head->Reserved = HTONS (0x8000); // Server, broadcast the message please.
EFI_IP4 (Head->ClientAddr) = HTONL (DhcpSb->ClientAddr); EFI_IP4 (Head->ClientAddr) = HTONL (DhcpSb->ClientAddr);
CopyMem (Head->ClientHwAddr, DhcpSb->Mac.Addr, DhcpSb->HwLen); CopyMem (Head->ClientHwAddr, DhcpSb->Mac.Addr, DhcpSb->HwLen);
@ -1205,7 +1183,7 @@ DhcpSendMessage (
// //
Head->Seconds = DhcpSb->LastPacket->Dhcp4.Header.Seconds; Head->Seconds = DhcpSb->LastPacket->Dhcp4.Header.Seconds;
} else { } else {
SetElapsedTime(&Head->Seconds, DhcpSb->ActiveChild); SetElapsedTime (&Head->Seconds, DhcpSb->ActiveChild);
} }
// //
@ -1223,12 +1201,12 @@ DhcpSendMessage (
// //
if ((Type == DHCP_MSG_DECLINE) || (Type == DHCP_MSG_RELEASE) || if ((Type == DHCP_MSG_DECLINE) || (Type == DHCP_MSG_RELEASE) ||
((Type == DHCP_MSG_REQUEST) && (DhcpSb->DhcpState == Dhcp4Requesting)) ((Type == DHCP_MSG_REQUEST) && (DhcpSb->DhcpState == Dhcp4Requesting))
) { )
{
ASSERT ((Para != NULL) && (Para->ServerId != 0)); ASSERT ((Para != NULL) && (Para->ServerId != 0));
IpAddr = HTONL (Para->ServerId); IpAddr = HTONL (Para->ServerId);
Buf = DhcpAppendOption (Buf, DHCP4_TAG_SERVER_ID, 4, (UINT8 *) &IpAddr); Buf = DhcpAppendOption (Buf, DHCP4_TAG_SERVER_ID, 4, (UINT8 *)&IpAddr);
} }
// //
@ -1242,19 +1220,17 @@ DhcpSendMessage (
if (Type == DHCP_MSG_REQUEST) { if (Type == DHCP_MSG_REQUEST) {
if (DhcpSb->DhcpState == Dhcp4Rebooting) { if (DhcpSb->DhcpState == Dhcp4Rebooting) {
IpAddr = EFI_IP4 (Config->ClientAddress); IpAddr = EFI_IP4 (Config->ClientAddress);
} else if (DhcpSb->DhcpState == Dhcp4Requesting) { } else if (DhcpSb->DhcpState == Dhcp4Requesting) {
ASSERT (SeedHead != NULL); ASSERT (SeedHead != NULL);
IpAddr = EFI_IP4 (SeedHead->YourAddr); IpAddr = EFI_IP4 (SeedHead->YourAddr);
} }
} else if (Type == DHCP_MSG_DECLINE) { } else if (Type == DHCP_MSG_DECLINE) {
ASSERT (SeedHead != NULL); ASSERT (SeedHead != NULL);
IpAddr = EFI_IP4 (SeedHead->YourAddr); IpAddr = EFI_IP4 (SeedHead->YourAddr);
} }
if (IpAddr != 0) { if (IpAddr != 0) {
Buf = DhcpAppendOption (Buf, DHCP4_TAG_REQUEST_IP, 4, (UINT8 *) &IpAddr); Buf = DhcpAppendOption (Buf, DHCP4_TAG_REQUEST_IP, 4, (UINT8 *)&IpAddr);
} }
// //
@ -1264,15 +1240,15 @@ DhcpSendMessage (
// //
if ((Type != DHCP_MSG_DECLINE) && (Type != DHCP_MSG_RELEASE)) { if ((Type != DHCP_MSG_DECLINE) && (Type != DHCP_MSG_RELEASE)) {
MaxMsg = HTONS (0xFF00); MaxMsg = HTONS (0xFF00);
Buf = DhcpAppendOption (Buf, DHCP4_TAG_MAXMSG, 2, (UINT8 *) &MaxMsg); Buf = DhcpAppendOption (Buf, DHCP4_TAG_MAXMSG, 2, (UINT8 *)&MaxMsg);
} }
// //
// Append the user's message if it isn't NULL // Append the user's message if it isn't NULL
// //
if (Msg != NULL) { if (Msg != NULL) {
Len = MIN ((UINT32) AsciiStrLen ((CHAR8 *) Msg), 255); Len = MIN ((UINT32)AsciiStrLen ((CHAR8 *)Msg), 255);
Buf = DhcpAppendOption (Buf, DHCP4_TAG_MESSAGE, (UINT16) Len, Msg); Buf = DhcpAppendOption (Buf, DHCP4_TAG_MESSAGE, (UINT16)Len, Msg);
} }
// //
@ -1285,7 +1261,8 @@ DhcpSendMessage (
// if it is a DHCP decline or DHCP release . // if it is a DHCP decline or DHCP release .
// //
if (((Type == DHCP_MSG_DECLINE) || (Type == DHCP_MSG_RELEASE)) && if (((Type == DHCP_MSG_DECLINE) || (Type == DHCP_MSG_RELEASE)) &&
(Config->OptionList[Index]->OpCode != DHCP4_TAG_CLIENT_ID)) { (Config->OptionList[Index]->OpCode != DHCP4_TAG_CLIENT_ID))
{
continue; continue;
} }
@ -1299,7 +1276,7 @@ DhcpSendMessage (
} }
*(Buf++) = DHCP4_TAG_EOP; *(Buf++) = DHCP4_TAG_EOP;
Packet->Length += (UINT32) (Buf - Packet->Dhcp4.Option); Packet->Length += (UINT32)(Buf - Packet->Dhcp4.Option);
// //
// OK, the message is built, call the user to override it. // OK, the message is built, call the user to override it.
@ -1309,10 +1286,8 @@ DhcpSendMessage (
if (Type == DHCP_MSG_DISCOVER) { if (Type == DHCP_MSG_DISCOVER) {
Status = DhcpCallUser (DhcpSb, Dhcp4SendDiscover, Packet, &NewPacket); Status = DhcpCallUser (DhcpSb, Dhcp4SendDiscover, Packet, &NewPacket);
} else if (Type == DHCP_MSG_REQUEST) { } else if (Type == DHCP_MSG_REQUEST) {
Status = DhcpCallUser (DhcpSb, Dhcp4SendRequest, Packet, &NewPacket); Status = DhcpCallUser (DhcpSb, Dhcp4SendRequest, Packet, &NewPacket);
} else if (Type == DHCP_MSG_DECLINE) { } else if (Type == DHCP_MSG_DECLINE) {
Status = DhcpCallUser (DhcpSb, Dhcp4SendDecline, Packet, &NewPacket); Status = DhcpCallUser (DhcpSb, Dhcp4SendDecline, Packet, &NewPacket);
} }
@ -1339,7 +1314,7 @@ DhcpSendMessage (
// //
// Wrap it into a netbuf then send it. // Wrap it into a netbuf then send it.
// //
Frag.Bulk = (UINT8 *) &Packet->Dhcp4.Header; Frag.Bulk = (UINT8 *)&Packet->Dhcp4.Header;
Frag.Len = Packet->Length; Frag.Len = Packet->Length;
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL); Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
@ -1393,7 +1368,6 @@ DhcpSendMessage (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Retransmit a saved packet. Only DISCOVER and REQUEST messages Retransmit a saved packet. Only DISCOVER and REQUEST messages
will be retransmitted. will be retransmitted.
@ -1421,13 +1395,13 @@ DhcpRetransmit (
// For REQUEST message in Dhcp4Requesting state, do not change the secs fields. // For REQUEST message in Dhcp4Requesting state, do not change the secs fields.
// //
if (DhcpSb->DhcpState != Dhcp4Requesting) { if (DhcpSb->DhcpState != Dhcp4Requesting) {
SetElapsedTime(&DhcpSb->LastPacket->Dhcp4.Header.Seconds, DhcpSb->ActiveChild); SetElapsedTime (&DhcpSb->LastPacket->Dhcp4.Header.Seconds, DhcpSb->ActiveChild);
} }
// //
// Wrap it into a netbuf then send it. // Wrap it into a netbuf then send it.
// //
Frag.Bulk = (UINT8 *) &DhcpSb->LastPacket->Dhcp4.Header; Frag.Bulk = (UINT8 *)&DhcpSb->LastPacket->Dhcp4.Header;
Frag.Len = DhcpSb->LastPacket->Length; Frag.Len = DhcpSb->LastPacket->Length;
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL); Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
@ -1469,7 +1443,6 @@ DhcpRetransmit (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Each DHCP service has three timer. Two of them are count down timer. Each DHCP service has three timer. Two of them are count down timer.
One for the packet retransmission. The other is to collect the offers. One for the packet retransmission. The other is to collect the offers.
@ -1494,13 +1467,13 @@ DhcpOnTimerTick (
DHCP_PROTOCOL *Instance; DHCP_PROTOCOL *Instance;
EFI_STATUS Status; EFI_STATUS Status;
DhcpSb = (DHCP_SERVICE *) Context; DhcpSb = (DHCP_SERVICE *)Context;
Instance = DhcpSb->ActiveChild; Instance = DhcpSb->ActiveChild;
// //
// 0xffff is the maximum supported value for elapsed time according to RFC. // 0xffff is the maximum supported value for elapsed time according to RFC.
// //
if (Instance != NULL && Instance->ElaspedTime < 0xffff) { if ((Instance != NULL) && (Instance->ElaspedTime < 0xffff)) {
Instance->ElaspedTime++; Instance->ElaspedTime++;
} }
@ -1508,15 +1481,13 @@ DhcpOnTimerTick (
// Check the retransmit timer // Check the retransmit timer
// //
if ((DhcpSb->PacketToLive > 0) && (--DhcpSb->PacketToLive == 0)) { if ((DhcpSb->PacketToLive > 0) && (--DhcpSb->PacketToLive == 0)) {
// //
// Select offer at each timeout if any offer received. // Select offer at each timeout if any offer received.
// //
if (DhcpSb->DhcpState == Dhcp4Selecting && DhcpSb->LastOffer != NULL) { if ((DhcpSb->DhcpState == Dhcp4Selecting) && (DhcpSb->LastOffer != NULL)) {
Status = DhcpChooseOffer (DhcpSb); Status = DhcpChooseOffer (DhcpSb);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
if (DhcpSb->LastOffer != NULL) { if (DhcpSb->LastOffer != NULL) {
FreePool (DhcpSb->LastOffer); FreePool (DhcpSb->LastOffer);
DhcpSb->LastOffer = NULL; DhcpSb->LastOffer = NULL;
@ -1532,9 +1503,7 @@ DhcpOnTimerTick (
// //
DhcpRetransmit (DhcpSb); DhcpRetransmit (DhcpSb);
DhcpSetTransmitTimer (DhcpSb); DhcpSetTransmitTimer (DhcpSb);
} else if (DHCP_CONNECTED (DhcpSb->DhcpState)) { } else if (DHCP_CONNECTED (DhcpSb->DhcpState)) {
// //
// Retransmission failed, if the DHCP request is initiated by // Retransmission failed, if the DHCP request is initiated by
// user, adjust the current state according to the lease life. // user, adjust the current state according to the lease life.
@ -1545,16 +1514,12 @@ DhcpOnTimerTick (
if (DhcpSb->LeaseLife < DhcpSb->T1) { if (DhcpSb->LeaseLife < DhcpSb->T1) {
Status = DhcpSetState (DhcpSb, Dhcp4Bound, FALSE); Status = DhcpSetState (DhcpSb, Dhcp4Bound, FALSE);
} else if (DhcpSb->LeaseLife < DhcpSb->T2) { } else if (DhcpSb->LeaseLife < DhcpSb->T2) {
Status = DhcpSetState (DhcpSb, Dhcp4Renewing, FALSE); Status = DhcpSetState (DhcpSb, Dhcp4Renewing, FALSE);
} else if (DhcpSb->LeaseLife < DhcpSb->Lease) { } else if (DhcpSb->LeaseLife < DhcpSb->Lease) {
Status = DhcpSetState (DhcpSb, Dhcp4Rebinding, FALSE); Status = DhcpSetState (DhcpSb, Dhcp4Rebinding, FALSE);
} else { } else {
goto END_SESSION; goto END_SESSION;
} }
DhcpSb->IoStatus = EFI_TIMEOUT; DhcpSb->IoStatus = EFI_TIMEOUT;
@ -1577,7 +1542,7 @@ DhcpOnTimerTick (
// requesting extra renew/rebind. Adjust the state after that. // requesting extra renew/rebind. Adjust the state after that.
// //
if (DhcpSb->ExtraRefresh != 0) { if (DhcpSb->ExtraRefresh != 0) {
return ; return;
} }
if (DhcpSb->LeaseLife == DhcpSb->Lease) { if (DhcpSb->LeaseLife == DhcpSb->Lease) {
@ -1585,7 +1550,6 @@ DhcpOnTimerTick (
// Lease expires, end the session // Lease expires, end the session
// //
goto END_SESSION; goto END_SESSION;
} else if (DhcpSb->LeaseLife == DhcpSb->T2) { } else if (DhcpSb->LeaseLife == DhcpSb->T2) {
// //
// T2 expires, transit to rebinding then send a REQUEST to any server // T2 expires, transit to rebinding then send a REQUEST to any server
@ -1595,7 +1559,7 @@ DhcpOnTimerTick (
} }
if (Instance != NULL) { if (Instance != NULL) {
Instance->ElaspedTime= 0; Instance->ElaspedTime = 0;
} }
Status = DhcpSendMessage ( Status = DhcpSendMessage (
@ -1609,7 +1573,6 @@ DhcpOnTimerTick (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto END_SESSION; goto END_SESSION;
} }
} else if (DhcpSb->LeaseLife == DhcpSb->T1) { } else if (DhcpSb->LeaseLife == DhcpSb->T1) {
// //
// T1 expires, transit to renewing, then send a REQUEST to the server // T1 expires, transit to renewing, then send a REQUEST to the server
@ -1619,7 +1582,7 @@ DhcpOnTimerTick (
} }
if (Instance != NULL) { if (Instance != NULL) {
Instance->ElaspedTime= 0; Instance->ElaspedTime = 0;
} }
Status = DhcpSendMessage ( Status = DhcpSendMessage (
@ -1643,15 +1606,15 @@ ON_EXIT:
NET_LIST_FOR_EACH_SAFE (Entry, Next, &DhcpSb->Children) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &DhcpSb->Children) {
Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link); Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link);
Instance->Timeout--; Instance->Timeout--;
if (Instance->Timeout == 0 && Instance->Token != NULL) { if ((Instance->Timeout == 0) && (Instance->Token != NULL)) {
PxeDhcpDone (Instance); PxeDhcpDone (Instance);
} }
} }
return ; return;
END_SESSION: END_SESSION:
DhcpEndSession (DhcpSb, EFI_TIMEOUT); DhcpEndSession (DhcpSb, EFI_TIMEOUT);
return ; return;
} }

View File

@ -18,8 +18,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#define DHCP_WAIT_OFFER 3 // Time to wait the offers #define DHCP_WAIT_OFFER 3 // Time to wait the offers
#define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default. #define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default.
#define DHCP_SERVER_PORT 67 #define DHCP_SERVER_PORT 67

View File

@ -14,94 +14,93 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// DHCP_OPTION_FORMAT structure. /// DHCP_OPTION_FORMAT structure.
/// ///
DHCP_OPTION_FORMAT DhcpOptionFormats[] = { DHCP_OPTION_FORMAT DhcpOptionFormats[] = {
{DHCP4_TAG_NETMASK, DHCP_OPTION_IP, 1, 1 , TRUE}, { DHCP4_TAG_NETMASK, DHCP_OPTION_IP, 1, 1, TRUE },
{DHCP4_TAG_TIME_OFFSET, DHCP_OPTION_INT32, 1, 1 , FALSE}, { DHCP4_TAG_TIME_OFFSET, DHCP_OPTION_INT32, 1, 1, FALSE },
{DHCP4_TAG_ROUTER, DHCP_OPTION_IP, 1, -1 , TRUE}, { DHCP4_TAG_ROUTER, DHCP_OPTION_IP, 1, -1, TRUE },
{DHCP4_TAG_TIME_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_TIME_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_NAME_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_NAME_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_DNS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_DNS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_LOG_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_LOG_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_COOKIE_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_COOKIE_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_LPR_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_LPR_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_IMPRESS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_IMPRESS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_RL_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_RL_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_HOSTNAME, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_HOSTNAME, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_BOOTFILE_LEN, DHCP_OPTION_INT16, 1, 1 , FALSE}, { DHCP4_TAG_BOOTFILE_LEN, DHCP_OPTION_INT16, 1, 1, FALSE },
{DHCP4_TAG_DUMP, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_DUMP, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_DOMAINNAME, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_DOMAINNAME, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_SWAP_SERVER, DHCP_OPTION_IP, 1, 1 , FALSE}, { DHCP4_TAG_SWAP_SERVER, DHCP_OPTION_IP, 1, 1, FALSE },
{DHCP4_TAG_ROOTPATH, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_ROOTPATH, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_EXTEND_PATH, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_EXTEND_PATH, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_IPFORWARD, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_IPFORWARD, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_NONLOCAL_SRR, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_NONLOCAL_SRR, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_POLICY_SRR, DHCP_OPTION_IPPAIR, 1, -1 , FALSE}, { DHCP4_TAG_POLICY_SRR, DHCP_OPTION_IPPAIR, 1, -1, FALSE },
{DHCP4_TAG_EMTU, DHCP_OPTION_INT16, 1, 1 , FALSE}, { DHCP4_TAG_EMTU, DHCP_OPTION_INT16, 1, 1, FALSE },
{DHCP4_TAG_TTL, DHCP_OPTION_INT8, 1, 1 , FALSE}, { DHCP4_TAG_TTL, DHCP_OPTION_INT8, 1, 1, FALSE },
{DHCP4_TAG_PATHMTU_AGE, DHCP_OPTION_INT32, 1, 1 , FALSE}, { DHCP4_TAG_PATHMTU_AGE, DHCP_OPTION_INT32, 1, 1, FALSE },
{DHCP4_TAG_PATHMTU_PLATEAU,DHCP_OPTION_INT16, 1, -1 , FALSE}, { DHCP4_TAG_PATHMTU_PLATEAU, DHCP_OPTION_INT16, 1, -1, FALSE },
{DHCP4_TAG_IFMTU, DHCP_OPTION_INT16, 1, 1 , FALSE}, { DHCP4_TAG_IFMTU, DHCP_OPTION_INT16, 1, 1, FALSE },
{DHCP4_TAG_SUBNET_LOCAL, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_SUBNET_LOCAL, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_BROADCAST, DHCP_OPTION_IP, 1, 1 , FALSE}, { DHCP4_TAG_BROADCAST, DHCP_OPTION_IP, 1, 1, FALSE },
{DHCP4_TAG_DISCOVER_MASK, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_DISCOVER_MASK, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_SUPPLY_MASK, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_SUPPLY_MASK, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_DISCOVER_ROUTE, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_DISCOVER_ROUTE, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_ROUTER_SOLICIT, DHCP_OPTION_IP, 1, 1 , FALSE}, { DHCP4_TAG_ROUTER_SOLICIT, DHCP_OPTION_IP, 1, 1, FALSE },
{DHCP4_TAG_STATIC_ROUTE, DHCP_OPTION_IPPAIR, 1, -1 , FALSE}, { DHCP4_TAG_STATIC_ROUTE, DHCP_OPTION_IPPAIR, 1, -1, FALSE },
{DHCP4_TAG_TRAILER, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_TRAILER, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_ARPAGE, DHCP_OPTION_INT32, 1, 1 , FALSE}, { DHCP4_TAG_ARPAGE, DHCP_OPTION_INT32, 1, 1, FALSE },
{DHCP4_TAG_ETHER_ENCAP, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_ETHER_ENCAP, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_TCP_TTL, DHCP_OPTION_INT8, 1, 1 , FALSE}, { DHCP4_TAG_TCP_TTL, DHCP_OPTION_INT8, 1, 1, FALSE },
{DHCP4_TAG_KEEP_INTERVAL, DHCP_OPTION_INT32, 1, 1 , FALSE}, { DHCP4_TAG_KEEP_INTERVAL, DHCP_OPTION_INT32, 1, 1, FALSE },
{DHCP4_TAG_KEEP_GARBAGE, DHCP_OPTION_SWITCH, 1, 1 , FALSE}, { DHCP4_TAG_KEEP_GARBAGE, DHCP_OPTION_SWITCH, 1, 1, FALSE },
{DHCP4_TAG_NIS_DOMAIN, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_NIS_DOMAIN, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_NIS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_NIS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_NTP_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_NTP_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_VENDOR, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_VENDOR, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_NBNS, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_NBNS, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_NBDD, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_NBDD, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_NBTYPE, DHCP_OPTION_INT8, 1, 1 , FALSE}, { DHCP4_TAG_NBTYPE, DHCP_OPTION_INT8, 1, 1, FALSE },
{DHCP4_TAG_NBSCOPE, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_NBSCOPE, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_XFONT, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_XFONT, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_XDM, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_XDM, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_REQUEST_IP, DHCP_OPTION_IP, 1, 1 , FALSE}, { DHCP4_TAG_REQUEST_IP, DHCP_OPTION_IP, 1, 1, FALSE },
{DHCP4_TAG_LEASE, DHCP_OPTION_INT32, 1, 1 , TRUE}, { DHCP4_TAG_LEASE, DHCP_OPTION_INT32, 1, 1, TRUE },
{DHCP4_TAG_OVERLOAD, DHCP_OPTION_INT8, 1, 1 , TRUE}, { DHCP4_TAG_OVERLOAD, DHCP_OPTION_INT8, 1, 1, TRUE },
{DHCP4_TAG_MSG_TYPE, DHCP_OPTION_INT8, 1, 1 , TRUE}, { DHCP4_TAG_MSG_TYPE, DHCP_OPTION_INT8, 1, 1, TRUE },
{DHCP4_TAG_SERVER_ID, DHCP_OPTION_IP, 1, 1 , TRUE}, { DHCP4_TAG_SERVER_ID, DHCP_OPTION_IP, 1, 1, TRUE },
{DHCP4_TAG_PARA_LIST, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_PARA_LIST, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_MESSAGE, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_MESSAGE, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_MAXMSG, DHCP_OPTION_INT16, 1, 1 , FALSE}, { DHCP4_TAG_MAXMSG, DHCP_OPTION_INT16, 1, 1, FALSE },
{DHCP4_TAG_T1, DHCP_OPTION_INT32, 1, 1 , TRUE}, { DHCP4_TAG_T1, DHCP_OPTION_INT32, 1, 1, TRUE },
{DHCP4_TAG_T2, DHCP_OPTION_INT32, 1, 1 , TRUE}, { DHCP4_TAG_T2, DHCP_OPTION_INT32, 1, 1, TRUE },
{DHCP4_TAG_VENDOR_CLASS_ID,DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_VENDOR_CLASS_ID, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_CLIENT_ID, DHCP_OPTION_INT8, 2, -1 , FALSE}, { DHCP4_TAG_CLIENT_ID, DHCP_OPTION_INT8, 2, -1, FALSE },
{DHCP4_TAG_NISPLUS, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_NISPLUS, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_NISPLUS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_NISPLUS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_TFTP, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_TFTP, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_BOOTFILE, DHCP_OPTION_INT8, 1, -1 , FALSE}, { DHCP4_TAG_BOOTFILE, DHCP_OPTION_INT8, 1, -1, FALSE },
{DHCP4_TAG_MOBILEIP, DHCP_OPTION_IP, 0, -1 , FALSE}, { DHCP4_TAG_MOBILEIP, DHCP_OPTION_IP, 0, -1, FALSE },
{DHCP4_TAG_SMTP, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_SMTP, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_POP3, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_POP3, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_NNTP, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_NNTP, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_WWW, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_WWW, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_FINGER, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_FINGER, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_IRC, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_IRC, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_STTALK, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_STTALK, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_STDA, DHCP_OPTION_IP, 1, -1 , FALSE}, { DHCP4_TAG_STDA, DHCP_OPTION_IP, 1, -1, FALSE },
{DHCP4_TAG_CLASSLESS_ROUTE,DHCP_OPTION_INT8, 5, -1 , FALSE}, { DHCP4_TAG_CLASSLESS_ROUTE, DHCP_OPTION_INT8, 5, -1, FALSE },
}; };
/** /**
Binary search the DhcpOptionFormats array to find the format Binary search the DhcpOptionFormats array to find the format
information about a specific option. information about a specific option.
@ -140,7 +139,6 @@ DhcpFindOptionFormat (
return NULL; return NULL;
} }
/** /**
Validate whether a single DHCP option is valid according to its format. Validate whether a single DHCP option is valid according to its format.
@ -201,7 +199,8 @@ DhcpOptionIsValid (
if (((Format->MinOccur != -1) && (Occur < Format->MinOccur)) || if (((Format->MinOccur != -1) && (Occur < Format->MinOccur)) ||
((Format->MaxOccur != -1) && (Occur > Format->MaxOccur)) ((Format->MaxOccur != -1) && (Occur > Format->MaxOccur))
) { )
{
return FALSE; return FALSE;
} }
@ -219,7 +218,6 @@ DhcpOptionIsValid (
return TRUE; return TRUE;
} }
/** /**
Extract the client interested options, all the parameters are Extract the client interested options, all the parameters are
converted to host byte order. converted to host byte order.
@ -263,6 +261,7 @@ DhcpGetParameter (
if ((Para->Overload < 1) || (Para->Overload > 3)) { if ((Para->Overload < 1) || (Para->Overload > 3)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
break; break;
case DHCP4_TAG_MSG_TYPE: case DHCP4_TAG_MSG_TYPE:
@ -271,6 +270,7 @@ DhcpGetParameter (
if ((Para->DhcpType < 1) || (Para->DhcpType > 9)) { if ((Para->DhcpType < 1) || (Para->DhcpType > 9)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
break; break;
case DHCP4_TAG_SERVER_ID: case DHCP4_TAG_SERVER_ID:
@ -289,7 +289,6 @@ DhcpGetParameter (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Inspect all the options in a single buffer. DHCP options may be contained Inspect all the options in a single buffer. DHCP options may be contained
in several buffers, such as the BOOTP options filed, boot file or server in several buffers, such as the BOOTP options filed, boot file or server
@ -364,7 +363,6 @@ DhcpIterateBufferOptions (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
/** /**
Iterate through a DHCP message to visit each option. First inspect Iterate through a DHCP message to visit each option. First inspect
all the options in the OPTION field. Then if overloaded, inspect all the options in the OPTION field. Then if overloaded, inspect
@ -406,7 +404,7 @@ DhcpIterateOptions (
if ((Overload == DHCP_OVERLOAD_FILENAME) || (Overload == DHCP_OVERLOAD_BOTH)) { if ((Overload == DHCP_OVERLOAD_FILENAME) || (Overload == DHCP_OVERLOAD_BOTH)) {
Status = DhcpIterateBufferOptions ( Status = DhcpIterateBufferOptions (
(UINT8 *) Packet->Dhcp4.Header.BootFileName, (UINT8 *)Packet->Dhcp4.Header.BootFileName,
128, 128,
Check, Check,
Context, Context,
@ -420,7 +418,7 @@ DhcpIterateOptions (
if ((Overload == DHCP_OVERLOAD_SVRNAME) || (Overload == DHCP_OVERLOAD_BOTH)) { if ((Overload == DHCP_OVERLOAD_SVRNAME) || (Overload == DHCP_OVERLOAD_BOTH)) {
Status = DhcpIterateBufferOptions ( Status = DhcpIterateBufferOptions (
(UINT8 *) Packet->Dhcp4.Header.ServerName, (UINT8 *)Packet->Dhcp4.Header.ServerName,
64, 64,
Check, Check,
Context, Context,
@ -435,7 +433,6 @@ DhcpIterateOptions (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Call back function to DhcpIterateOptions to compute each option's Call back function to DhcpIterateOptions to compute each option's
length. It just adds the data length of all the occurrences of this length. It just adds the data length of all the occurrences of this
@ -460,13 +457,12 @@ DhcpGetOptionLen (
{ {
DHCP_OPTION_COUNT *OpCount; DHCP_OPTION_COUNT *OpCount;
OpCount = (DHCP_OPTION_COUNT *) Context; OpCount = (DHCP_OPTION_COUNT *)Context;
OpCount[Tag].Offset = (UINT16) (OpCount[Tag].Offset + Len); OpCount[Tag].Offset = (UINT16)(OpCount[Tag].Offset + Len);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Call back function to DhcpIterateOptions to consolidate each option's Call back function to DhcpIterateOptions to consolidate each option's
data. There are maybe several occurrence of the same option. data. There are maybe several occurrence of the same option.
@ -494,7 +490,7 @@ DhcpFillOption (
UINT8 *Buf; UINT8 *Buf;
UINT8 Index; UINT8 Index;
OptContext = (DHCP_OPTION_CONTEXT *) Context; OptContext = (DHCP_OPTION_CONTEXT *)Context;
OptCount = OptContext->OpCount; OptCount = OptContext->OpCount;
Index = OptCount[Tag].Index; Index = OptCount[Tag].Index;
@ -508,12 +504,11 @@ DhcpFillOption (
CopyMem (Buf + OptCount[Tag].Offset, Data, Len); CopyMem (Buf + OptCount[Tag].Offset, Data, Len);
OptCount[Tag].Offset = (UINT16) (OptCount[Tag].Offset + Len); OptCount[Tag].Offset = (UINT16)(OptCount[Tag].Offset + Len);
Options[Index].Len = (UINT16) (Options[Index].Len + Len); Options[Index].Len = (UINT16)(Options[Index].Len + Len);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Parse the options of a DHCP packet. It supports RFC 3396: Encoding Parse the options of a DHCP packet. It supports RFC 3396: Encoding
Long Options in DHCP. That is, it will combine all the option value Long Options in DHCP. That is, it will combine all the option value
@ -585,10 +580,10 @@ DhcpParseOption (
for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) { for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) {
if (OptCount[Index].Offset != 0) { if (OptCount[Index].Offset != 0) {
OptCount[Index].Index = (UINT8) OptNum; OptCount[Index].Index = (UINT8)OptNum;
TotalLen = (UINT16) (TotalLen + OptCount[Index].Offset); TotalLen = (UINT16)(TotalLen + OptCount[Index].Offset);
OptCount[Index].Offset = (UINT16) (TotalLen - OptCount[Index].Offset); OptCount[Index].Offset = (UINT16)(TotalLen - OptCount[Index].Offset);
OptNum++; OptNum++;
} }
@ -605,7 +600,7 @@ DhcpParseOption (
// Allocate a buffer to hold the DHCP options, and after that, a // Allocate a buffer to hold the DHCP options, and after that, a
// continuous buffer to put all the options' data. // continuous buffer to put all the options' data.
// //
Options = AllocateZeroPool ((UINTN) (OptNum * sizeof (DHCP_OPTION)) + TotalLen); Options = AllocateZeroPool ((UINTN)(OptNum * sizeof (DHCP_OPTION)) + TotalLen);
if (Options == NULL) { if (Options == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -614,7 +609,7 @@ DhcpParseOption (
Context.OpCount = OptCount; Context.OpCount = OptCount;
Context.Options = Options; Context.Options = Options;
Context.Buf = (UINT8 *) (Options + OptNum); Context.Buf = (UINT8 *)(Options + OptNum);
Status = DhcpIterateOptions (Packet, DhcpFillOption, &Context); Status = DhcpIterateOptions (Packet, DhcpFillOption, &Context);
@ -630,7 +625,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Validate the packet's options. If necessary, allocate Validate the packet's options. If necessary, allocate
and fill in the interested parameters. and fill in the interested parameters.
@ -668,6 +662,7 @@ DhcpValidateOptions (
if (EFI_ERROR (Status) || (Count == 0)) { if (EFI_ERROR (Status) || (Count == 0)) {
return Status; return Status;
} }
ASSERT (AllOption != NULL); ASSERT (AllOption != NULL);
Updated = FALSE; Updated = FALSE;
@ -716,8 +711,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Append an option to the memory, if the option is longer than Append an option to the memory, if the option is longer than
255 bytes, splits it into several options. 255 bytes, splits it into several options.
@ -747,8 +740,8 @@ DhcpAppendOption (
Len = MIN (255, DataLen - Index * 255); Len = MIN (255, DataLen - Index * 255);
*(Buf++) = Tag; *(Buf++) = Tag;
*(Buf++) = (UINT8) Len; *(Buf++) = (UINT8)Len;
CopyMem (Buf, Data + Index * 255, (UINTN) Len); CopyMem (Buf, Data + Index * 255, (UINTN)Len);
Buf += Len; Buf += Len;
} }
@ -756,7 +749,6 @@ DhcpAppendOption (
return Buf; return Buf;
} }
/** /**
Build a new DHCP packet from a seed packet. Options may be deleted or Build a new DHCP packet from a seed packet. Options may be deleted or
appended. The caller should free the NewPacket when finished using it. appended. The caller should free the NewPacket when finished using it.
@ -804,7 +796,7 @@ DhcpBuild (
} }
for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) { for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) {
Mark[Index].Tag = (UINT8) Index; Mark[Index].Tag = (UINT8)Index;
Mark[Index].Len = 0; Mark[Index].Len = 0;
} }
@ -820,7 +812,7 @@ DhcpBuild (
} }
if (SeedOptions != NULL) { if (SeedOptions != NULL) {
for (Index = 0; Index < (UINT32) Count; Index++) { for (Index = 0; Index < (UINT32)Count; Index++) {
Mark[SeedOptions[Index].Tag] = SeedOptions[Index]; Mark[SeedOptions[Index].Tag] = SeedOptions[Index];
} }
} }
@ -855,7 +847,7 @@ DhcpBuild (
} }
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
Packet = (EFI_DHCP4_PACKET *) AllocatePool (Len); Packet = (EFI_DHCP4_PACKET *)AllocatePool (Len);
if (Packet == NULL) { if (Packet == NULL) {
goto ON_ERROR; goto ON_ERROR;
@ -875,7 +867,7 @@ DhcpBuild (
*(Buf++) = DHCP4_TAG_EOP; *(Buf++) = DHCP4_TAG_EOP;
Packet->Length = sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32) Packet->Length = sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)
+ (UINT32) (Buf - Packet->Dhcp4.Option); + (UINT32)(Buf - Packet->Dhcp4.Option);
*NewPacket = Packet; *NewPacket = Packet;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;

View File

@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define DHCP_OPTION_MAGIC 0x63538263 // Network byte order #define DHCP_OPTION_MAGIC 0x63538263 // Network byte order
#define DHCP_MAX_OPTIONS 256 #define DHCP_MAX_OPTIONS 256
// //
// DHCP option types, this is used to validate the DHCP options. // DHCP option types, this is used to validate the DHCP options.
// //

View File

@ -9,7 +9,6 @@
#include "Dhcp6Impl.h" #include "Dhcp6Impl.h"
/** /**
Retrieves a Unicode string that is the user-readable name of the driver. Retrieves a Unicode string that is the user-readable name of the driver.
@ -57,7 +56,6 @@ Dhcp6ComponentNameGetDriverName (
OUT CHAR16 **DriverName OUT CHAR16 **DriverName
); );
/** /**
Retrieves a Unicode string that is the user-readable name of the controller Retrieves a Unicode string that is the user-readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -136,7 +134,6 @@ Dhcp6ComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
// //
// EFI Component Name Protocol // EFI Component Name Protocol
// //
@ -150,8 +147,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp6ComponentName
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Dhcp6ComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Dhcp6ComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Dhcp6ComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Dhcp6ComponentNameGetControllerName,
"en" "en"
}; };
@ -278,12 +275,14 @@ UpdateName (
if (Dhcp6ModeData.Ia->State > Dhcp6Rebinding) { if (Dhcp6ModeData.Ia->State > Dhcp6Rebinding) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
HandleName = mDhcp6ControllerName[Dhcp6ModeData.Ia->State]; HandleName = mDhcp6ControllerName[Dhcp6ModeData.Ia->State];
} }
if (Dhcp6ModeData.Ia != NULL) { if (Dhcp6ModeData.Ia != NULL) {
FreePool (Dhcp6ModeData.Ia); FreePool (Dhcp6ModeData.Ia);
} }
if (Dhcp6ModeData.ClientId != NULL) { if (Dhcp6ModeData.ClientId != NULL) {
FreePool (Dhcp6ModeData.ClientId); FreePool (Dhcp6ModeData.ClientId);
} }
@ -439,4 +438,3 @@ Dhcp6ComponentNameGetControllerName (
(BOOLEAN)(This == &gDhcp6ComponentName) (BOOLEAN)(This == &gDhcp6ComponentName)
); );
} }

View File

@ -10,7 +10,6 @@
#include "Dhcp6Impl.h" #include "Dhcp6Impl.h"
EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = { EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = {
Dhcp6DriverBindingSupported, Dhcp6DriverBindingSupported,
Dhcp6DriverBindingStart, Dhcp6DriverBindingStart,
@ -70,10 +69,9 @@ Dhcp6ConfigureUdpIo (
Config->StationPort = DHCP6_PORT_CLIENT; Config->StationPort = DHCP6_PORT_CLIENT;
Config->RemotePort = 0; Config->RemotePort = 0;
return Udp6->Configure (Udp6, Config);; return Udp6->Configure (Udp6, Config);
} }
/** /**
Destroy the Dhcp6 service. The Dhcp6 service may be partly initialized, Destroy the Dhcp6 service. The Dhcp6 service may be partly initialized,
or partly destroyed. If a resource is destroyed, it is marked as such in or partly destroyed. If a resource is destroyed, it is marked as such in
@ -103,7 +101,6 @@ Dhcp6DestroyService (
FreePool (Service); FreePool (Service);
} }
/** /**
Create a new Dhcp6 service for the Nic controller. Create a new Dhcp6 service for the Nic controller.
@ -164,7 +161,7 @@ Dhcp6CreateService (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
Controller, Controller,
&gEfiIp6ConfigProtocolGuid, &gEfiIp6ConfigProtocolGuid,
(VOID **) &Dhcp6Srv->Ip6Cfg (VOID **)&Dhcp6Srv->Ip6Cfg
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (Dhcp6Srv); FreePool (Dhcp6Srv);
@ -206,7 +203,6 @@ Dhcp6CreateService (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Destroy the Dhcp6 instance and recycle the resources. Destroy the Dhcp6 instance and recycle the resources.
@ -239,6 +235,7 @@ Dhcp6DestroyInstance (
if (Instance->IaCb.Ia->ReplyPacket != NULL) { if (Instance->IaCb.Ia->ReplyPacket != NULL) {
FreePool (Instance->IaCb.Ia->ReplyPacket); FreePool (Instance->IaCb.Ia->ReplyPacket);
} }
FreePool (Instance->IaCb.Ia); FreePool (Instance->IaCb.Ia);
} }
@ -253,7 +250,6 @@ Dhcp6DestroyInstance (
FreePool (Instance); FreePool (Instance);
} }
/** /**
Create the Dhcp6 instance and initialize it. Create the Dhcp6 instance and initialize it.
@ -340,17 +336,16 @@ Dhcp6DestroyChildEntry (
DHCP6_INSTANCE *Instance; DHCP6_INSTANCE *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
if (Entry == NULL || Context == NULL) { if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP6_INSTANCE, Link, DHCP6_INSTANCE_SIGNATURE); Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP6_INSTANCE, Link, DHCP6_INSTANCE_SIGNATURE);
ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context;
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
} }
/** /**
Entry point of the DHCP6 driver to install various protocols. Entry point of the DHCP6 driver to install various protocols.
@ -378,7 +373,6 @@ Dhcp6DriverEntryPoint (
); );
} }
/** /**
Test to see if this driver supports ControllerHandle. This service Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In is called by the EFI boot service ConnectController(). In
@ -414,7 +408,6 @@ Dhcp6DriverBindingSupported (
); );
} }
/** /**
Start this driver on ControllerHandle. This service is called by the Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make EFI boot service ConnectController(). In order to make
@ -490,7 +483,6 @@ Dhcp6DriverBindingStart (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Stop this driver on ControllerHandle. This service is called by the Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to EFI boot service DisconnectController(). In order to
@ -538,7 +530,7 @@ Dhcp6DriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiDhcp6ServiceBindingProtocolGuid, &gEfiDhcp6ServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
NicHandle, NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -560,16 +552,16 @@ Dhcp6DriverBindingStop (
ServiceBinding, ServiceBinding,
&ListLength &ListLength
); );
if (EFI_ERROR (Status) || ListLength != 0) { if (EFI_ERROR (Status) || (ListLength != 0)) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
} }
if (NumberOfChildren == 0 && !IsListEmpty (&Service->Child)) { if ((NumberOfChildren == 0) && !IsListEmpty (&Service->Child)) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
if (NumberOfChildren == 0 && IsListEmpty (&Service->Child)) { if ((NumberOfChildren == 0) && IsListEmpty (&Service->Child)) {
// //
// Destroy the service itself if no child instance left. // Destroy the service itself if no child instance left.
// //
@ -590,7 +582,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Creates a child handle and installs a protocol. Creates a child handle and installs a protocol.
@ -621,7 +612,7 @@ Dhcp6ServiceBindingCreateChild (
DHCP6_INSTANCE *Instance; DHCP6_INSTANCE *Instance;
VOID *Udp6; VOID *Udp6;
if (This == NULL || ChildHandle == NULL) { if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -670,14 +661,13 @@ Dhcp6ServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Service->UdpIo->UdpHandle, Service->UdpIo->UdpHandle,
&gEfiUdp6ProtocolGuid, &gEfiUdp6ProtocolGuid,
(VOID **) &Udp6, (VOID **)&Udp6,
gDhcp6DriverBinding.DriverBindingHandle, gDhcp6DriverBinding.DriverBindingHandle,
Instance->Handle, Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
Instance->Handle, Instance->Handle,
&gEfiDhcp6ProtocolGuid, &gEfiDhcp6ProtocolGuid,
@ -704,7 +694,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Destroys a child handle with a protocol installed on it. Destroys a child handle with a protocol installed on it.
@ -736,7 +725,7 @@ Dhcp6ServiceBindingDestroyChild (
DHCP6_SERVICE *Service; DHCP6_SERVICE *Service;
DHCP6_INSTANCE *Instance; DHCP6_INSTANCE *Instance;
if (This == NULL || ChildHandle == NULL) { if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -746,7 +735,7 @@ Dhcp6ServiceBindingDestroyChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiDhcp6ProtocolGuid, &gEfiDhcp6ProtocolGuid,
(VOID **) &Dhcp6, (VOID **)&Dhcp6,
gDhcp6DriverBinding.DriverBindingHandle, gDhcp6DriverBinding.DriverBindingHandle,
ChildHandle, ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL

View File

@ -14,7 +14,9 @@
// //
// ALL_DHCP_Relay_Agents_and_Servers address: FF02::1:2 // 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 }
};
EFI_DHCP6_PROTOCOL gDhcp6ProtocolTemplate = { EFI_DHCP6_PROTOCOL gDhcp6ProtocolTemplate = {
EfiDhcp6GetModeData, EfiDhcp6GetModeData,
@ -119,7 +121,7 @@ EfiDhcp6Start (
// //
// Register receive callback for the stateful exchange process. // Register receive callback for the stateful exchange process.
// //
Status = UdpIoRecvDatagram( Status = UdpIoRecvDatagram (
Service->UdpIo, Service->UdpIo,
Dhcp6ReceivePacket, Dhcp6ReceivePacket,
Service, Service,
@ -136,10 +138,10 @@ EfiDhcp6Start (
// Poll udp out of the net tpl if synchronous call. // Poll udp out of the net tpl if synchronous call.
// //
if (Instance->Config->IaInfoEvent == NULL) { if (Instance->Config->IaInfoEvent == NULL) {
while (Instance->UdpSts == EFI_ALREADY_STARTED) { while (Instance->UdpSts == EFI_ALREADY_STARTED) {
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6); Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
} }
return Instance->UdpSts; return Instance->UdpSts;
} }
@ -151,7 +153,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Stops the DHCPv6 standard S.A.R.R. process. Stops the DHCPv6 standard S.A.R.R. process.
@ -200,10 +201,11 @@ EfiDhcp6Stop (
// //
// No valid REPLY message received yet, cleanup this instance directly. // No valid REPLY message received yet, cleanup this instance directly.
// //
if (Instance->IaCb.Ia->State == Dhcp6Init || if ((Instance->IaCb.Ia->State == Dhcp6Init) ||
Instance->IaCb.Ia->State == Dhcp6Selecting || (Instance->IaCb.Ia->State == Dhcp6Selecting) ||
Instance->IaCb.Ia->State == Dhcp6Requesting (Instance->IaCb.Ia->State == Dhcp6Requesting)
) { )
{
goto ON_EXIT; goto ON_EXIT;
} }
@ -227,6 +229,7 @@ EfiDhcp6Stop (
while (Instance->UdpSts == EFI_ALREADY_STARTED) { while (Instance->UdpSts == EFI_ALREADY_STARTED) {
Udp6->Poll (Udp6); Udp6->Poll (Udp6);
} }
Status = Instance->UdpSts; Status = Instance->UdpSts;
} }
@ -241,7 +244,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Returns the current operating mode data for the Dhcp6 instance. Returns the current operating mode data for the Dhcp6 instance.
@ -272,14 +274,14 @@ EfiDhcp6GetModeData (
UINT32 IaSize; UINT32 IaSize;
UINT32 IdSize; UINT32 IdSize;
if (This == NULL || (Dhcp6ModeData == NULL && Dhcp6ConfigData == NULL)) { if ((This == NULL) || ((Dhcp6ModeData == NULL) && (Dhcp6ConfigData == NULL))) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Instance = DHCP6_INSTANCE_FROM_THIS (This); Instance = DHCP6_INSTANCE_FROM_THIS (This);
Service = Instance->Service; Service = Instance->Service;
if (Instance->Config == NULL && Dhcp6ConfigData != NULL) { if ((Instance->Config == NULL) && (Dhcp6ConfigData != NULL)) {
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
@ -291,7 +293,7 @@ EfiDhcp6GetModeData (
// User needs a copy of instance config data. // User needs a copy of instance config data.
// //
if (Dhcp6ConfigData != NULL) { if (Dhcp6ConfigData != NULL) {
ZeroMem (Dhcp6ConfigData, sizeof(EFI_DHCP6_CONFIG_DATA)); ZeroMem (Dhcp6ConfigData, sizeof (EFI_DHCP6_CONFIG_DATA));
// //
// Duplicate config data, including all reference buffers. // Duplicate config data, including all reference buffers.
// //
@ -347,6 +349,7 @@ EfiDhcp6GetModeData (
if (Dhcp6ModeData->Ia->ReplyPacket == NULL) { if (Dhcp6ModeData->Ia->ReplyPacket == NULL) {
goto ON_ERROR; goto ON_ERROR;
} }
CopyMem ( CopyMem (
Dhcp6ModeData->Ia->ReplyPacket, Dhcp6ModeData->Ia->ReplyPacket,
Ia->ReplyPacket, Ia->ReplyPacket,
@ -365,15 +368,16 @@ ON_ERROR:
if (Dhcp6ConfigData != NULL) { if (Dhcp6ConfigData != NULL) {
Dhcp6CleanupConfigData (Dhcp6ConfigData); Dhcp6CleanupConfigData (Dhcp6ConfigData);
} }
if (Dhcp6ModeData != NULL) { if (Dhcp6ModeData != NULL) {
Dhcp6CleanupModeData (Dhcp6ModeData); Dhcp6CleanupModeData (Dhcp6ModeData);
} }
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
/** /**
Initializes, changes, or resets the operational settings for the Dhcp6 instance. Initializes, changes, or resets the operational settings for the Dhcp6 instance.
@ -428,36 +432,40 @@ EfiDhcp6Configure (
// Check the parameter of configure data. // Check the parameter of configure data.
// //
if (Dhcp6CfgData != NULL) { if (Dhcp6CfgData != NULL) {
if (Dhcp6CfgData->OptionCount > 0 && Dhcp6CfgData->OptionList == NULL) { if ((Dhcp6CfgData->OptionCount > 0) && (Dhcp6CfgData->OptionList == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Dhcp6CfgData->OptionList != NULL) { if (Dhcp6CfgData->OptionList != NULL) {
for (Index = 0; Index < Dhcp6CfgData->OptionCount; Index++) { for (Index = 0; Index < Dhcp6CfgData->OptionCount; Index++) {
if (Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptClientId || if ((Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptClientId) ||
Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptRapidCommit || (Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptRapidCommit) ||
Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptReconfigureAccept || (Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptReconfigureAccept) ||
Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptIana || (Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptIana) ||
Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptIata (Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptIata)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
} }
if (Dhcp6CfgData->IaDescriptor.Type != EFI_DHCP6_IA_TYPE_NA && if ((Dhcp6CfgData->IaDescriptor.Type != EFI_DHCP6_IA_TYPE_NA) &&
Dhcp6CfgData->IaDescriptor.Type != EFI_DHCP6_IA_TYPE_TA (Dhcp6CfgData->IaDescriptor.Type != EFI_DHCP6_IA_TYPE_TA)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Dhcp6CfgData->IaInfoEvent == NULL && Dhcp6CfgData->SolicitRetransmission == NULL) { if ((Dhcp6CfgData->IaInfoEvent == NULL) && (Dhcp6CfgData->SolicitRetransmission == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Dhcp6CfgData->SolicitRetransmission != NULL && if ((Dhcp6CfgData->SolicitRetransmission != NULL) &&
Dhcp6CfgData->SolicitRetransmission->Mrc == 0 && (Dhcp6CfgData->SolicitRetransmission->Mrc == 0) &&
Dhcp6CfgData->SolicitRetransmission->Mrd == 0 (Dhcp6CfgData->SolicitRetransmission->Mrd == 0)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -466,10 +474,11 @@ EfiDhcp6Configure (
// //
NET_LIST_FOR_EACH (Entry, &Service->Child) { NET_LIST_FOR_EACH (Entry, &Service->Child) {
Other = NET_LIST_USER_STRUCT (Entry, DHCP6_INSTANCE, Link); Other = NET_LIST_USER_STRUCT (Entry, DHCP6_INSTANCE, Link);
if (Other->IaCb.Ia != NULL && if ((Other->IaCb.Ia != NULL) &&
Other->IaCb.Ia->Descriptor.Type == Dhcp6CfgData->IaDescriptor.Type && (Other->IaCb.Ia->Descriptor.Type == Dhcp6CfgData->IaDescriptor.Type) &&
Other->IaCb.Ia->Descriptor.IaId == Dhcp6CfgData->IaDescriptor.IaId (Other->IaCb.Ia->Descriptor.IaId == Dhcp6CfgData->IaDescriptor.IaId)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
@ -496,7 +505,7 @@ EfiDhcp6Configure (
} }
Status = Dhcp6CopyConfigData (Instance->Config, Dhcp6CfgData); Status = Dhcp6CopyConfigData (Instance->Config, Dhcp6CfgData);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
FreePool (Instance->Config); FreePool (Instance->Config);
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -506,21 +515,20 @@ EfiDhcp6Configure (
// Initialize the Ia descriptor from the config data, and leave the other // Initialize the Ia descriptor from the config data, and leave the other
// fields of the Ia as default value 0. // fields of the Ia as default value 0.
// //
Instance->IaCb.Ia = AllocateZeroPool (sizeof(EFI_DHCP6_IA)); Instance->IaCb.Ia = AllocateZeroPool (sizeof (EFI_DHCP6_IA));
if (Instance->IaCb.Ia == NULL) { if (Instance->IaCb.Ia == NULL) {
Dhcp6CleanupConfigData (Instance->Config); Dhcp6CleanupConfigData (Instance->Config);
FreePool (Instance->Config); FreePool (Instance->Config);
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem ( CopyMem (
&Instance->IaCb.Ia->Descriptor, &Instance->IaCb.Ia->Descriptor,
&Dhcp6CfgData->IaDescriptor, &Dhcp6CfgData->IaDescriptor,
sizeof(EFI_DHCP6_IA_DESCRIPTOR) sizeof (EFI_DHCP6_IA_DESCRIPTOR)
); );
} else { } else {
if (Instance->Config == NULL) { if (Instance->Config == NULL) {
ASSERT (Instance->IaCb.Ia == NULL); ASSERT (Instance->IaCb.Ia == NULL);
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
@ -548,7 +556,6 @@ EfiDhcp6Configure (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Request configuration information without the assignment of any Request configuration information without the assignment of any
Ia addresses of the client. Ia addresses of the client.
@ -612,21 +619,21 @@ EfiDhcp6InfoRequest (
EFI_STATUS TimerStatus; EFI_STATUS TimerStatus;
UINTN GetMappingTimeOut; UINTN GetMappingTimeOut;
if (This == NULL || OptionRequest == NULL || Retransmission == NULL || ReplyCallback == NULL) { if ((This == NULL) || (OptionRequest == NULL) || (Retransmission == NULL) || (ReplyCallback == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Retransmission != NULL && Retransmission->Mrc == 0 && Retransmission->Mrd == 0) { if ((Retransmission != NULL) && (Retransmission->Mrc == 0) && (Retransmission->Mrd == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (OptionCount > 0 && OptionList == NULL) { if ((OptionCount > 0) && (OptionList == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (OptionList != NULL) { if (OptionList != NULL) {
for (Index = 0; Index < OptionCount; Index++) { for (Index = 0; Index < OptionCount; Index++) {
if (OptionList[Index]->OpCode == Dhcp6OptClientId || OptionList[Index]->OpCode == Dhcp6OptRequestOption) { if ((OptionList[Index]->OpCode == Dhcp6OptClientId) || (OptionList[Index]->OpCode == Dhcp6OptRequestOption)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
@ -651,8 +658,8 @@ EfiDhcp6InfoRequest (
// The link local address is not ready, wait for some time and restart // The link local address is not ready, wait for some time and restart
// the DHCP6 information request process. // the DHCP6 information request process.
// //
Status = Dhcp6GetMappingTimeOut(Service->Ip6Cfg, &GetMappingTimeOut); Status = Dhcp6GetMappingTimeOut (Service->Ip6Cfg, &GetMappingTimeOut);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -689,6 +696,7 @@ EfiDhcp6InfoRequest (
gBS->CloseEvent (Timer); gBS->CloseEvent (Timer);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -697,17 +705,16 @@ EfiDhcp6InfoRequest (
// Poll udp out of the net tpl if synchronous call. // Poll udp out of the net tpl if synchronous call.
// //
if (TimeoutEvent == NULL) { if (TimeoutEvent == NULL) {
while (Instance->UdpSts == EFI_ALREADY_STARTED) { while (Instance->UdpSts == EFI_ALREADY_STARTED) {
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6); Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
} }
return Instance->UdpSts; return Instance->UdpSts;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Manually extend the valid and preferred lifetimes for the IPv6 addresses Manually extend the valid and preferred lifetimes for the IPv6 addresses
of the configured IA and update other configuration parameters by sending a of the configured IA and update other configuration parameters by sending a
@ -784,9 +791,10 @@ EfiDhcp6RenewRebind (
// //
// The instance has already entered renewing or rebinding state. // The instance has already entered renewing or rebinding state.
// //
if ((Instance->IaCb.Ia->State == Dhcp6Rebinding && RebindRequest) || if (((Instance->IaCb.Ia->State == Dhcp6Rebinding) && RebindRequest) ||
(Instance->IaCb.Ia->State == Dhcp6Renewing && !RebindRequest) ((Instance->IaCb.Ia->State == Dhcp6Renewing) && !RebindRequest)
) { )
{
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
@ -809,7 +817,7 @@ EfiDhcp6RenewRebind (
// //
// Register receive callback for the stateful exchange process. // Register receive callback for the stateful exchange process.
// //
Status = UdpIoRecvDatagram( Status = UdpIoRecvDatagram (
Service->UdpIo, Service->UdpIo,
Dhcp6ReceivePacket, Dhcp6ReceivePacket,
Service, Service,
@ -826,10 +834,10 @@ EfiDhcp6RenewRebind (
// Poll udp out of the net tpl if synchronous call. // Poll udp out of the net tpl if synchronous call.
// //
if (Instance->Config->IaInfoEvent == NULL) { if (Instance->Config->IaInfoEvent == NULL) {
while (Instance->UdpSts == EFI_ALREADY_STARTED) { while (Instance->UdpSts == EFI_ALREADY_STARTED) {
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6); Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
} }
return Instance->UdpSts; return Instance->UdpSts;
} }
@ -841,7 +849,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Inform that one or more addresses assigned by a server are already Inform that one or more addresses assigned by a server are already
in use by another node. in use by another node.
@ -888,7 +895,7 @@ EfiDhcp6Decline (
DHCP6_INSTANCE *Instance; DHCP6_INSTANCE *Instance;
DHCP6_SERVICE *Service; DHCP6_SERVICE *Service;
if (This == NULL || AddressCount == 0 || Addresses == NULL) { if ((This == NULL) || (AddressCount == 0) || (Addresses == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -913,7 +920,7 @@ EfiDhcp6Decline (
// //
Status = Dhcp6CheckAddress (Instance->IaCb.Ia, AddressCount, Addresses); Status = Dhcp6CheckAddress (Instance->IaCb.Ia, AddressCount, Addresses);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -943,7 +950,7 @@ EfiDhcp6Decline (
// //
// Register receive callback for the stateful exchange process. // Register receive callback for the stateful exchange process.
// //
Status = UdpIoRecvDatagram( Status = UdpIoRecvDatagram (
Service->UdpIo, Service->UdpIo,
Dhcp6ReceivePacket, Dhcp6ReceivePacket,
Service, Service,
@ -961,10 +968,10 @@ EfiDhcp6Decline (
// Poll udp out of the net tpl if synchronous call. // Poll udp out of the net tpl if synchronous call.
// //
if (Instance->Config->IaInfoEvent == NULL) { if (Instance->Config->IaInfoEvent == NULL) {
while (Instance->UdpSts == EFI_ALREADY_STARTED) { while (Instance->UdpSts == EFI_ALREADY_STARTED) {
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6); Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
} }
return Instance->UdpSts; return Instance->UdpSts;
} }
@ -975,12 +982,12 @@ ON_ERROR:
if (DecIa != NULL) { if (DecIa != NULL) {
FreePool (DecIa); FreePool (DecIa);
} }
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
/** /**
Release one or more addresses associated with the configured Ia Release one or more addresses associated with the configured Ia
for current instance. for current instance.
@ -1029,7 +1036,7 @@ EfiDhcp6Release (
DHCP6_INSTANCE *Instance; DHCP6_INSTANCE *Instance;
DHCP6_SERVICE *Service; DHCP6_SERVICE *Service;
if (This == NULL || (AddressCount != 0 && Addresses == NULL)) { if ((This == NULL) || ((AddressCount != 0) && (Addresses == NULL))) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1054,7 +1061,7 @@ EfiDhcp6Release (
// //
Status = Dhcp6CheckAddress (Instance->IaCb.Ia, AddressCount, Addresses); Status = Dhcp6CheckAddress (Instance->IaCb.Ia, AddressCount, Addresses);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -1084,7 +1091,7 @@ EfiDhcp6Release (
// //
// Register receive callback for the stateful exchange process. // Register receive callback for the stateful exchange process.
// //
Status = UdpIoRecvDatagram( Status = UdpIoRecvDatagram (
Service->UdpIo, Service->UdpIo,
Dhcp6ReceivePacket, Dhcp6ReceivePacket,
Service, Service,
@ -1105,6 +1112,7 @@ EfiDhcp6Release (
while (Instance->UdpSts == EFI_ALREADY_STARTED) { while (Instance->UdpSts == EFI_ALREADY_STARTED) {
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6); Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
} }
return Instance->UdpSts; return Instance->UdpSts;
} }
@ -1115,12 +1123,12 @@ ON_ERROR:
if (RelIa != NULL) { if (RelIa != NULL) {
FreePool (RelIa); FreePool (RelIa);
} }
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
/** /**
Parse the option data in the Dhcp6 packet. Parse the option data in the Dhcp6 packet.
@ -1152,15 +1160,15 @@ EfiDhcp6Parse (
UINT8 *Start; UINT8 *Start;
UINT8 *End; UINT8 *End;
if (This == NULL || Packet == NULL || OptionCount == NULL) { if ((This == NULL) || (Packet == NULL) || (OptionCount == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (*OptionCount != 0 && PacketOptionList == NULL) { if ((*OptionCount != 0) && (PacketOptionList == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Packet->Length > Packet->Size || Packet->Length < sizeof (EFI_DHCP6_HEADER)) { if ((Packet->Length > Packet->Size) || (Packet->Length < sizeof (EFI_DHCP6_HEADER))) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1185,7 +1193,7 @@ EfiDhcp6Parse (
// Calculate the number of option in the packet. // Calculate the number of option in the packet.
// //
while (Start < End) { while (Start < End) {
DataLen = ((EFI_DHCP6_PACKET_OPTION *) Start)->OpLen; DataLen = ((EFI_DHCP6_PACKET_OPTION *)Start)->OpLen;
Start += (NTOHS (DataLen) + 4); Start += (NTOHS (DataLen) + 4);
OptCnt++; OptCnt++;
} }
@ -1208,13 +1216,11 @@ EfiDhcp6Parse (
Start = Packet->Dhcp6.Option; Start = Packet->Dhcp6.Option;
while (Start < End) { while (Start < End) {
PacketOptionList[OptCnt] = (EFI_DHCP6_PACKET_OPTION *)Start;
PacketOptionList[OptCnt] = (EFI_DHCP6_PACKET_OPTION *) Start; DataLen = ((EFI_DHCP6_PACKET_OPTION *)Start)->OpLen;
DataLen = ((EFI_DHCP6_PACKET_OPTION *) Start)->OpLen;
Start += (NTOHS (DataLen) + 4); Start += (NTOHS (DataLen) + 4);
OptCnt++; OptCnt++;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -10,7 +10,6 @@
#ifndef __EFI_DHCP6_IMPL_H__ #ifndef __EFI_DHCP6_IMPL_H__
#define __EFI_DHCP6_IMPL_H__ #define __EFI_DHCP6_IMPL_H__
#include <Uefi.h> #include <Uefi.h>
#include <IndustryStandard/Dhcp.h> #include <IndustryStandard/Dhcp.h>
@ -33,7 +32,6 @@
#include <Library/PrintLib.h> #include <Library/PrintLib.h>
#include <Guid/ZeroGuid.h> #include <Guid/ZeroGuid.h>
typedef struct _DHCP6_IA_CB DHCP6_IA_CB; typedef struct _DHCP6_IA_CB DHCP6_IA_CB;
typedef struct _DHCP6_INF_CB DHCP6_INF_CB; typedef struct _DHCP6_INF_CB DHCP6_INF_CB;
typedef struct _DHCP6_TX_CB DHCP6_TX_CB; typedef struct _DHCP6_TX_CB DHCP6_TX_CB;

View File

@ -10,7 +10,6 @@
#include "Dhcp6Impl.h" #include "Dhcp6Impl.h"
/** /**
Enqueue the packet into the retry list in case of timeout. Enqueue the packet into the retry list in case of timeout.
@ -203,7 +202,7 @@ Dhcp6EnqueueRetry (
// //
// Unexpected message type. // Unexpected message type.
// //
FreePool(TxCb); FreePool (TxCb);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -215,7 +214,6 @@ Dhcp6EnqueueRetry (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Dequeue the packet from retry list if reply received or timeout at last. Dequeue the packet from retry list if reply received or timeout at last.
@ -244,26 +242,22 @@ Dhcp6DequeueRetry (
// Seek the retransmit node in the retransmit list by packet xid. // Seek the retransmit node in the retransmit list by packet xid.
// //
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) { NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link); TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link);
ASSERT(TxCb->TxPacket); ASSERT (TxCb->TxPacket);
if (TxCb->Xid == PacketXid) { if (TxCb->Xid == PacketXid) {
if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) { if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) {
// //
// Seek the info-request node in the info-request list by packet xid. // Seek the info-request node in the info-request list by packet xid.
// //
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) { NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) {
InfCb = NET_LIST_USER_STRUCT (Entry, DHCP6_INF_CB, Link); InfCb = NET_LIST_USER_STRUCT (Entry, DHCP6_INF_CB, Link);
if (InfCb->Xid == PacketXid) { if (InfCb->Xid == PacketXid) {
// //
// Remove the info-request node, and signal the event if timeout. // Remove the info-request node, and signal the event if timeout.
// //
if (InfCb->TimeoutEvent != NULL && NeedSignal) { if ((InfCb->TimeoutEvent != NULL) && NeedSignal) {
gBS->SignalEvent (InfCb->TimeoutEvent); gBS->SignalEvent (InfCb->TimeoutEvent);
} }
@ -272,11 +266,12 @@ Dhcp6DequeueRetry (
} }
} }
} }
// //
// Remove the retransmit node. // Remove the retransmit node.
// //
RemoveEntryList (&TxCb->Link); RemoveEntryList (&TxCb->Link);
ASSERT(TxCb->TxPacket); ASSERT (TxCb->TxPacket);
FreePool (TxCb->TxPacket); FreePool (TxCb->TxPacket);
FreePool (TxCb); FreePool (TxCb);
return EFI_SUCCESS; return EFI_SUCCESS;
@ -286,7 +281,6 @@ Dhcp6DequeueRetry (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/** /**
Clean up the specific nodes in the retry list. Clean up the specific nodes in the retry list.
@ -308,12 +302,10 @@ Dhcp6CleanupRetry (
// //
// Clean up all the stateful messages from the retransmit list. // Clean up all the stateful messages from the retransmit list.
// //
if (Scope == DHCP6_PACKET_STATEFUL || Scope == DHCP6_PACKET_ALL) { if ((Scope == DHCP6_PACKET_STATEFUL) || (Scope == DHCP6_PACKET_ALL)) {
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) { NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link); TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link);
ASSERT(TxCb->TxPacket); ASSERT (TxCb->TxPacket);
if (TxCb->TxPacket->Dhcp6.Header.MessageType != Dhcp6MsgInfoRequest) { if (TxCb->TxPacket->Dhcp6.Header.MessageType != Dhcp6MsgInfoRequest) {
RemoveEntryList (&TxCb->Link); RemoveEntryList (&TxCb->Link);
@ -326,15 +318,13 @@ Dhcp6CleanupRetry (
// //
// Clean up all the stateless messages from the retransmit list. // Clean up all the stateless messages from the retransmit list.
// //
if (Scope == DHCP6_PACKET_STATELESS || Scope == DHCP6_PACKET_ALL) { if ((Scope == DHCP6_PACKET_STATELESS) || (Scope == DHCP6_PACKET_ALL)) {
// //
// Clean up all the retransmit list for stateless messages. // Clean up all the retransmit list for stateless messages.
// //
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) { NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link); TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link);
ASSERT(TxCb->TxPacket); ASSERT (TxCb->TxPacket);
if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) { if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) {
RemoveEntryList (&TxCb->Link); RemoveEntryList (&TxCb->Link);
@ -347,12 +337,12 @@ Dhcp6CleanupRetry (
// Clean up all the info-request messages list. // Clean up all the info-request messages list.
// //
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) { NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) {
InfCb = NET_LIST_USER_STRUCT (Entry, DHCP6_INF_CB, Link); InfCb = NET_LIST_USER_STRUCT (Entry, DHCP6_INF_CB, Link);
if (InfCb->TimeoutEvent != NULL) { if (InfCb->TimeoutEvent != NULL) {
gBS->SignalEvent (InfCb->TimeoutEvent); gBS->SignalEvent (InfCb->TimeoutEvent);
} }
RemoveEntryList (&InfCb->Link); RemoveEntryList (&InfCb->Link);
FreePool (InfCb); FreePool (InfCb);
} }
@ -402,8 +392,8 @@ Dhcp6CleanupSession (
UINTN Index; UINTN Index;
EFI_DHCP6_IA *Ia; EFI_DHCP6_IA *Ia;
ASSERT(Instance->Config); ASSERT (Instance->Config);
ASSERT(Instance->IaCb.Ia); ASSERT (Instance->IaCb.Ia);
// //
// Clean up the retransmit list for stateful messages. // Clean up the retransmit list for stateful messages.
@ -461,7 +451,6 @@ Dhcp6CleanupSession (
} }
} }
/** /**
Callback to user when Dhcp6 transmit/receive occurs. Callback to user when Dhcp6 transmit/receive occurs.
@ -500,7 +489,6 @@ Dhcp6CallbackUser (
// Callback to user with the new message if has. // Callback to user with the new message if has.
// //
if (Callback != NULL) { if (Callback != NULL) {
Status = Callback ( Status = Callback (
&Instance->Dhcp6, &Instance->Dhcp6,
Context, Context,
@ -522,7 +510,6 @@ Dhcp6CallbackUser (
return Status; return Status;
} }
/** /**
Update Ia according to the new reply message. Update Ia according to the new reply message.
@ -611,23 +598,24 @@ Dhcp6UpdateIaInfo (
// The inner options still start with 2 bytes option-code and 2 bytes option-len. // The inner options still start with 2 bytes option-code and 2 bytes option-len.
// //
if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) { if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) {
T1 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 8))); T1 = NTOHL (ReadUnaligned32 ((UINT32 *)(Option + 8)));
T2 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 12))); T2 = NTOHL (ReadUnaligned32 ((UINT32 *)(Option + 12)));
// //
// Refer to RFC3155 Chapter 22.4. If a client receives an IA_NA with T1 greater than T2, // Refer to RFC3155 Chapter 22.4. If a client receives an IA_NA with T1 greater than T2,
// and both T1 and T2 are greater than 0, the client discards the IA_NA option and processes // and both T1 and T2 are greater than 0, the client discards the IA_NA option and processes
// the remainder of the message as though the server had not included the invalid IA_NA option. // the remainder of the message as though the server had not included the invalid IA_NA option.
// //
if (T1 > T2 && T2 > 0) { if ((T1 > T2) && (T2 > 0)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
IaInnerOpt = Option + 16; IaInnerOpt = Option + 16;
IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 2))) - 12); IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(Option + 2))) - 12);
} else { } else {
T1 = 0; T1 = 0;
T2 = 0; T2 = 0;
IaInnerOpt = Option + 8; IaInnerOpt = Option + 8;
IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 2))) - 4); IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(Option + 2))) - 4);
} }
// //
@ -653,7 +641,7 @@ Dhcp6UpdateIaInfo (
Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode); Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode);
if (Option != NULL) { if (Option != NULL) {
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 4))); StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(Option + 4)));
if (StsCode != Dhcp6StsSuccess) { if (StsCode != Dhcp6StsSuccess) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -673,8 +661,6 @@ Dhcp6UpdateIaInfo (
return Status; return Status;
} }
/** /**
Seek StatusCode Option in package. A Status Code option may appear in the Seek StatusCode Option in package. A Status Code option may appear in the
options field of a DHCP message and/or in the options field of another option. options field of a DHCP message and/or in the options field of another option.
@ -710,7 +696,7 @@ Dhcp6SeekStsOption (
); );
if (*Option != NULL) { if (*Option != NULL) {
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 4))); StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(*Option + 4)));
if (StsCode != Dhcp6StsSuccess) { if (StsCode != Dhcp6StsSuccess) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -771,10 +757,10 @@ Dhcp6SeekStsOption (
// //
if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) { if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) {
IaInnerOpt = *Option + 16; IaInnerOpt = *Option + 16;
IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 2))) - 12); IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(*Option + 2))) - 12);
} else { } else {
IaInnerOpt = *Option + 8; IaInnerOpt = *Option + 8;
IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 2))) - 4); IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(*Option + 2))) - 4);
} }
// //
@ -798,7 +784,7 @@ Dhcp6SeekStsOption (
// //
*Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode); *Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode);
if (*Option != NULL) { if (*Option != NULL) {
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 4))); StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(*Option + 4)));
if (StsCode != Dhcp6StsSuccess) { if (StsCode != Dhcp6StsSuccess) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -807,7 +793,6 @@ Dhcp6SeekStsOption (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Transmit Dhcp6 message by udpio. Transmit Dhcp6 message by udpio.
@ -838,7 +823,7 @@ Dhcp6TransmitPacket (
// //
// Wrap it into a netbuf then send it. // Wrap it into a netbuf then send it.
// //
Frag.Bulk = (UINT8 *) &Packet->Dhcp6.Header; Frag.Bulk = (UINT8 *)&Packet->Dhcp6.Header;
Frag.Len = Packet->Length; Frag.Len = Packet->Length;
// //
@ -899,7 +884,6 @@ Dhcp6TransmitPacket (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Create the solicit message and send it. Create the solicit message and send it.
@ -985,9 +969,8 @@ Dhcp6SendSolicitMsg (
// Append user-defined when configurate Dhcp6 service. // Append user-defined when configurate Dhcp6 service.
// //
for (Index = 0; Index < Instance->Config->OptionCount; Index++) { for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
UserOpt = Instance->Config->OptionList[Index]; UserOpt = Instance->Config->OptionList[Index];
Cursor = Dhcp6AppendOption( Cursor = Dhcp6AppendOption (
Cursor, Cursor,
UserOpt->OpCode, UserOpt->OpCode,
UserOpt->OpLen, UserOpt->OpLen,
@ -998,7 +981,7 @@ Dhcp6SendSolicitMsg (
// //
// Determine the size/length of packet. // Determine the size/length of packet.
// //
Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); Packet->Length += (UINT32)(Cursor - Packet->Dhcp6.Option);
ASSERT (Packet->Size > Packet->Length + 8); ASSERT (Packet->Size > Packet->Length + 8);
// //
@ -1061,7 +1044,6 @@ Dhcp6InitSolicitMsg (
return Dhcp6SendSolicitMsg (Instance); return Dhcp6SendSolicitMsg (Instance);
} }
/** /**
Create the request message and send it. Create the request message and send it.
@ -1091,15 +1073,15 @@ Dhcp6SendRequestMsg (
UINTN Index; UINTN Index;
UINT16 Length; UINT16 Length;
ASSERT(Instance->AdSelect != NULL); ASSERT (Instance->AdSelect != NULL);
ASSERT(Instance->Config != NULL); ASSERT (Instance->Config != NULL);
ASSERT(Instance->IaCb.Ia != NULL); ASSERT (Instance->IaCb.Ia != NULL);
ASSERT(Instance->Service != NULL); ASSERT (Instance->Service != NULL);
Service = Instance->Service; Service = Instance->Service;
ClientId = Service->ClientId; ClientId = Service->ClientId;
ASSERT(ClientId != NULL); ASSERT (ClientId != NULL);
// //
// Get the server Id from the selected advertisement message. // Get the server Id from the selected advertisement message.
@ -1113,7 +1095,7 @@ Dhcp6SendRequestMsg (
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
ServerId = (EFI_DHCP6_DUID *) (Option + 2); ServerId = (EFI_DHCP6_DUID *)(Option + 2);
// //
// Calculate the added length of customized option list. // Calculate the added length of customized option list.
@ -1174,9 +1156,8 @@ Dhcp6SendRequestMsg (
// Append user-defined when configurate Dhcp6 service. // Append user-defined when configurate Dhcp6 service.
// //
for (Index = 0; Index < Instance->Config->OptionCount; Index++) { for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
UserOpt = Instance->Config->OptionList[Index]; UserOpt = Instance->Config->OptionList[Index];
Cursor = Dhcp6AppendOption( Cursor = Dhcp6AppendOption (
Cursor, Cursor,
UserOpt->OpCode, UserOpt->OpCode,
UserOpt->OpLen, UserOpt->OpLen,
@ -1187,7 +1168,7 @@ Dhcp6SendRequestMsg (
// //
// Determine the size/length of packet. // Determine the size/length of packet.
// //
Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); Packet->Length += (UINT32)(Cursor - Packet->Dhcp6.Option);
ASSERT (Packet->Size > Packet->Length + 8); ASSERT (Packet->Size > Packet->Length + 8);
// //
@ -1223,7 +1204,6 @@ Dhcp6SendRequestMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
} }
/** /**
Create the decline message and send it. Create the decline message and send it.
@ -1279,7 +1259,7 @@ Dhcp6SendDeclineMsg (
// //
// EFI_DHCP6_DUID contains a length field of 2 bytes. // EFI_DHCP6_DUID contains a length field of 2 bytes.
// //
ServerId = (EFI_DHCP6_DUID *) (Option + 2); ServerId = (EFI_DHCP6_DUID *)(Option + 2);
// //
// Create the Dhcp6 packet and initialize common fields. // Create the Dhcp6 packet and initialize common fields.
@ -1325,7 +1305,7 @@ Dhcp6SendDeclineMsg (
// //
// Determine the size/length of packet. // Determine the size/length of packet.
// //
Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); Packet->Length += (UINT32)(Cursor - Packet->Dhcp6.Option);
ASSERT (Packet->Size > Packet->Length + 8); ASSERT (Packet->Size > Packet->Length + 8);
// //
@ -1361,7 +1341,6 @@ Dhcp6SendDeclineMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
} }
/** /**
Create the release message and send it. Create the release message and send it.
@ -1391,15 +1370,15 @@ Dhcp6SendReleaseMsg (
UINT16 *Elapsed; UINT16 *Elapsed;
UINT16 Length; UINT16 Length;
ASSERT(Instance->Config); ASSERT (Instance->Config);
ASSERT(Instance->IaCb.Ia); ASSERT (Instance->IaCb.Ia);
Service = Instance->Service; Service = Instance->Service;
ClientId = Service->ClientId; ClientId = Service->ClientId;
LastReply = Instance->IaCb.Ia->ReplyPacket; LastReply = Instance->IaCb.Ia->ReplyPacket;
ASSERT(ClientId); ASSERT (ClientId);
ASSERT(LastReply); ASSERT (LastReply);
// //
// Get the server Id from the last reply message. // Get the server Id from the last reply message.
@ -1413,7 +1392,7 @@ Dhcp6SendReleaseMsg (
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
ServerId = (EFI_DHCP6_DUID *) (Option + 2); ServerId = (EFI_DHCP6_DUID *)(Option + 2);
// //
// Create the Dhcp6 packet and initialize common fields. // Create the Dhcp6 packet and initialize common fields.
@ -1462,7 +1441,7 @@ Dhcp6SendReleaseMsg (
// //
// Determine the size/length of packet // Determine the size/length of packet
// //
Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); Packet->Length += (UINT32)(Cursor - Packet->Dhcp6.Option);
ASSERT (Packet->Size > Packet->Length + 8); ASSERT (Packet->Size > Packet->Length + 8);
// //
@ -1494,7 +1473,6 @@ Dhcp6SendReleaseMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
} }
/** /**
Create the renew/rebind message and send it. Create the renew/rebind message and send it.
@ -1530,13 +1508,13 @@ Dhcp6SendRenewRebindMsg (
UINTN Index; UINTN Index;
UINT16 Length; UINT16 Length;
ASSERT(Instance->Config); ASSERT (Instance->Config);
ASSERT(Instance->IaCb.Ia); ASSERT (Instance->IaCb.Ia);
Service = Instance->Service; Service = Instance->Service;
ClientId = Service->ClientId; ClientId = Service->ClientId;
ASSERT(ClientId); ASSERT (ClientId);
// //
// Calculate the added length of customized option list. // Calculate the added length of customized option list.
@ -1604,7 +1582,7 @@ Dhcp6SendRenewRebindMsg (
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
ServerId = (EFI_DHCP6_DUID *) (Option + 2); ServerId = (EFI_DHCP6_DUID *)(Option + 2);
Cursor = Dhcp6AppendOption ( Cursor = Dhcp6AppendOption (
Cursor, Cursor,
@ -1618,9 +1596,8 @@ Dhcp6SendRenewRebindMsg (
// Append user-defined when configurate Dhcp6 service. // Append user-defined when configurate Dhcp6 service.
// //
for (Index = 0; Index < Instance->Config->OptionCount; Index++) { for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
UserOpt = Instance->Config->OptionList[Index]; UserOpt = Instance->Config->OptionList[Index];
Cursor = Dhcp6AppendOption( Cursor = Dhcp6AppendOption (
Cursor, Cursor,
UserOpt->OpCode, UserOpt->OpCode,
UserOpt->OpLen, UserOpt->OpLen,
@ -1631,7 +1608,7 @@ Dhcp6SendRenewRebindMsg (
// //
// Determine the size/length of packet. // Determine the size/length of packet.
// //
Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); Packet->Length += (UINT32)(Cursor - Packet->Dhcp6.Option);
ASSERT (Packet->Size > Packet->Length + 8); ASSERT (Packet->Size > Packet->Length + 8);
// //
@ -1719,7 +1696,7 @@ Dhcp6StartInfoRequest (
// //
// Create and initialize the control block for the info-request. // Create and initialize the control block for the info-request.
// //
InfCb = AllocateZeroPool (sizeof(DHCP6_INF_CB)); InfCb = AllocateZeroPool (sizeof (DHCP6_INF_CB));
if (InfCb == NULL) { if (InfCb == NULL) {
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
@ -1752,7 +1729,7 @@ Dhcp6StartInfoRequest (
// //
// Register receive callback for the stateless exchange process. // Register receive callback for the stateless exchange process.
// //
Status = UdpIoRecvDatagram( Status = UdpIoRecvDatagram (
Service->UdpIo, Service->UdpIo,
Dhcp6ReceivePacket, Dhcp6ReceivePacket,
Service, Service,
@ -1814,13 +1791,13 @@ Dhcp6SendInfoRequestMsg (
UINTN Index; UINTN Index;
UINT16 Length; UINT16 Length;
ASSERT(OptionRequest); ASSERT (OptionRequest);
Service = Instance->Service; Service = Instance->Service;
ClientId = Service->ClientId; ClientId = Service->ClientId;
UserLen = NTOHS (OptionRequest->OpLen) + 4; UserLen = NTOHS (OptionRequest->OpLen) + 4;
ASSERT(ClientId); ASSERT (ClientId);
// //
// Calculate the added length of customized option list. // Calculate the added length of customized option list.
@ -1876,9 +1853,8 @@ Dhcp6SendInfoRequestMsg (
// Append user-defined when configurate Dhcp6 service. // Append user-defined when configurate Dhcp6 service.
// //
for (Index = 0; Index < OptionCount; Index++) { for (Index = 0; Index < OptionCount; Index++) {
UserOpt = OptionList[Index]; UserOpt = OptionList[Index];
Cursor = Dhcp6AppendOption( Cursor = Dhcp6AppendOption (
Cursor, Cursor,
UserOpt->OpCode, UserOpt->OpCode,
UserOpt->OpLen, UserOpt->OpLen,
@ -1889,7 +1865,7 @@ Dhcp6SendInfoRequestMsg (
// //
// Determine the size/length of packet. // Determine the size/length of packet.
// //
Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); Packet->Length += (UINT32)(Cursor - Packet->Dhcp6.Option);
ASSERT (Packet->Size > Packet->Length + 8); ASSERT (Packet->Size > Packet->Length + 8);
// //
@ -1913,7 +1889,6 @@ Dhcp6SendInfoRequestMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, Retransmission); return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, Retransmission);
} }
/** /**
Create the Confirm message and send it. Create the Confirm message and send it.
@ -2013,7 +1988,7 @@ Dhcp6SendConfirmMsg (
// //
// Determine the size/length of packet. // Determine the size/length of packet.
// //
Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); Packet->Length += (UINT32)(Cursor - Packet->Dhcp6.Option);
ASSERT (Packet->Size > Packet->Length + 8); ASSERT (Packet->Size > Packet->Length + 8);
// //
@ -2049,8 +2024,6 @@ Dhcp6SendConfirmMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
} }
/** /**
Handle with the Dhcp6 reply message. Handle with the Dhcp6 reply message.
@ -2096,7 +2069,7 @@ Dhcp6HandleReplyMsg (
Dhcp6OptRapidCommit Dhcp6OptRapidCommit
); );
if ((Option != NULL && !Instance->Config->RapidCommit) || (Option == NULL && Instance->Config->RapidCommit)) { if (((Option != NULL) && !Instance->Config->RapidCommit) || ((Option == NULL) && Instance->Config->RapidCommit)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -2104,11 +2077,11 @@ Dhcp6HandleReplyMsg (
// As to a valid reply packet in response to a request/renew/rebind packet, // As to a valid reply packet in response to a request/renew/rebind packet,
// ignore the packet if not contains the Ia option // ignore the packet if not contains the Ia option
// //
if (Instance->IaCb.Ia->State == Dhcp6Requesting || if ((Instance->IaCb.Ia->State == Dhcp6Requesting) ||
Instance->IaCb.Ia->State == Dhcp6Renewing || (Instance->IaCb.Ia->State == Dhcp6Renewing) ||
Instance->IaCb.Ia->State == Dhcp6Rebinding (Instance->IaCb.Ia->State == Dhcp6Rebinding)
) { )
{
Option = Dhcp6SeekIaOption ( Option = Dhcp6SeekIaOption (
Packet->Dhcp6.Option, Packet->Dhcp6.Option,
Packet->Length, Packet->Length,
@ -2133,8 +2106,7 @@ Dhcp6HandleReplyMsg (
// the client considers the decline/release event completed regardless of the // the client considers the decline/release event completed regardless of the
// status code. // status code.
// //
if (Instance->IaCb.Ia->State == Dhcp6Declining || Instance->IaCb.Ia->State == Dhcp6Releasing) { if ((Instance->IaCb.Ia->State == Dhcp6Declining) || (Instance->IaCb.Ia->State == Dhcp6Releasing)) {
if (Instance->IaCb.Ia->IaAddressCount != 0) { if (Instance->IaCb.Ia->IaAddressCount != 0) {
Instance->IaCb.Ia->State = Dhcp6Bound; Instance->IaCb.Ia->State = Dhcp6Bound;
} else { } else {
@ -2235,12 +2207,11 @@ Dhcp6HandleReplyMsg (
} }
goto ON_EXIT; goto ON_EXIT;
} else if (Option != NULL) { } else if (Option != NULL) {
// //
// Any error status code option is found. // Any error status code option is found.
// //
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 4))); StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(Option + 4)));
switch (StsCode) { switch (StsCode) {
case Dhcp6StsUnspecFail: case Dhcp6StsUnspecFail:
// //
@ -2259,6 +2230,7 @@ Dhcp6HandleReplyMsg (
FreePool (Instance->Unicast); FreePool (Instance->Unicast);
Instance->Unicast = NULL; Instance->Unicast = NULL;
} }
break; break;
case Dhcp6StsNotOnLink: case Dhcp6StsNotOnLink:
@ -2279,19 +2251,21 @@ Dhcp6HandleReplyMsg (
return Status; return Status;
} }
} }
break; break;
case Dhcp6StsNoBinding: case Dhcp6StsNoBinding:
if (Instance->IaCb.Ia->State == Dhcp6Renewing || Instance->IaCb.Ia->State == Dhcp6Rebinding) { if ((Instance->IaCb.Ia->State == Dhcp6Renewing) || (Instance->IaCb.Ia->State == Dhcp6Rebinding)) {
// //
// Refer to RFC3315 Chapter 18.1.8, for each IA in the original Renew or Rebind message, the client // Refer to RFC3315 Chapter 18.1.8, for each IA in the original Renew or Rebind message, the client
// sends a Request message if the IA contained a Status Code option with the NoBinding status. // sends a Request message if the IA contained a Status Code option with the NoBinding status.
// //
Status = Dhcp6SendRequestMsg(Instance); Status = Dhcp6SendRequestMsg (Instance);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
} }
break; break;
default: default:
@ -2306,7 +2280,7 @@ Dhcp6HandleReplyMsg (
ON_EXIT: ON_EXIT:
if (!EFI_ERROR(Status)) { if (!EFI_ERROR (Status)) {
Status = Dhcp6DequeueRetry ( Status = Dhcp6DequeueRetry (
Instance, Instance,
Packet->Dhcp6.Header.TransactionId, Packet->Dhcp6.Header.TransactionId,
@ -2317,7 +2291,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Select the appointed Dhcp6 advertisement message. Select the appointed Dhcp6 advertisement message.
@ -2361,7 +2334,7 @@ Dhcp6SelectAdvertiseMsg (
FALSE FALSE
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -2369,21 +2342,20 @@ Dhcp6SelectAdvertiseMsg (
// Check whether there is server unicast option in the selected advertise // Check whether there is server unicast option in the selected advertise
// packet, and update it. // packet, and update it.
// //
Option = Dhcp6SeekOption( Option = Dhcp6SeekOption (
AdSelect->Dhcp6.Option, AdSelect->Dhcp6.Option,
AdSelect->Length - 4, AdSelect->Length - 4,
Dhcp6OptServerUnicast Dhcp6OptServerUnicast
); );
if (Option != NULL) { if (Option != NULL) {
Instance->Unicast = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS));
Instance->Unicast = AllocateZeroPool (sizeof(EFI_IPv6_ADDRESS));
if (Instance->Unicast == NULL) { if (Instance->Unicast == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (Instance->Unicast, Option + 4, sizeof(EFI_IPv6_ADDRESS)); CopyMem (Instance->Unicast, Option + 4, sizeof (EFI_IPv6_ADDRESS));
} }
// //
@ -2401,7 +2373,6 @@ Dhcp6SelectAdvertiseMsg (
return Dhcp6SendRequestMsg (Instance); return Dhcp6SendRequestMsg (Instance);
} }
/** /**
Handle with the Dhcp6 advertisement message. Handle with the Dhcp6 advertisement message.
@ -2424,8 +2395,8 @@ Dhcp6HandleAdvertiseMsg (
UINT8 *Option; UINT8 *Option;
BOOLEAN Timeout; BOOLEAN Timeout;
ASSERT(Instance->Config); ASSERT (Instance->Config);
ASSERT(Instance->IaCb.Ia); ASSERT (Instance->IaCb.Ia);
Timeout = FALSE; Timeout = FALSE;
@ -2435,14 +2406,13 @@ Dhcp6HandleAdvertiseMsg (
// this reply message. Or else, process the advertise messages as normal. // this reply message. Or else, process the advertise messages as normal.
// See details in the section-17.1.4 of rfc-3315. // See details in the section-17.1.4 of rfc-3315.
// //
Option = Dhcp6SeekOption( Option = Dhcp6SeekOption (
Packet->Dhcp6.Option, Packet->Dhcp6.Option,
Packet->Length - 4, Packet->Length - 4,
Dhcp6OptRapidCommit Dhcp6OptRapidCommit
); );
if (Option != NULL && Instance->Config->RapidCommit && Packet->Dhcp6.Header.MessageType == Dhcp6MsgReply) { if ((Option != NULL) && Instance->Config->RapidCommit && (Packet->Dhcp6.Header.MessageType == Dhcp6MsgReply)) {
return Dhcp6HandleReplyMsg (Instance, Packet); return Dhcp6HandleReplyMsg (Instance, Packet);
} }
@ -2490,12 +2460,11 @@ Dhcp6HandleAdvertiseMsg (
CopyMem (Instance->AdSelect, Packet, Packet->Size); CopyMem (Instance->AdSelect, Packet, Packet->Size);
Instance->AdPref = 0xff; Instance->AdPref = 0xff;
} else if (Status == EFI_NOT_READY) { } else if (Status == EFI_NOT_READY) {
// //
// Not_ready means user wants to continue to receive more advertise packets. // Not_ready means user wants to continue to receive more advertise packets.
// //
if (Instance->AdPref == 0xff && Instance->AdSelect == NULL) { if ((Instance->AdPref == 0xff) && (Instance->AdSelect == NULL)) {
// //
// It's a tricky point. The timer routine set adpref as 0xff if the first // It's a tricky point. The timer routine set adpref as 0xff if the first
// rt timeout and no advertisement received, which means any advertisement // rt timeout and no advertisement received, which means any advertisement
@ -2508,13 +2477,13 @@ Dhcp6HandleAdvertiseMsg (
// Check whether the current packet has a 255 preference option or not. // Check whether the current packet has a 255 preference option or not.
// Take non-preference option as 0 value. // Take non-preference option as 0 value.
// //
Option = Dhcp6SeekOption( Option = Dhcp6SeekOption (
Packet->Dhcp6.Option, Packet->Dhcp6.Option,
Packet->Length - 4, Packet->Length - 4,
Dhcp6OptPreference Dhcp6OptPreference
); );
if (Instance->AdSelect == NULL || (Option != NULL && *(Option + 4) > Instance->AdPref)) { if ((Instance->AdSelect == NULL) || ((Option != NULL) && (*(Option + 4) > Instance->AdPref))) {
// //
// No advertisements received before or preference is more than other // No advertisements received before or preference is more than other
// advertisements received before. Then store the new packet and the // advertisements received before. Then store the new packet and the
@ -2541,7 +2510,6 @@ Dhcp6HandleAdvertiseMsg (
// preference is less than other advertisements received before. // preference is less than other advertisements received before.
// Leave the packet alone. // Leave the packet alone.
} }
} else { } else {
// //
// Other error status means termination. // Other error status means termination.
@ -2554,14 +2522,13 @@ Dhcp6HandleAdvertiseMsg (
// RT has elapsed, or get a highest preference 255 advertise. // RT has elapsed, or get a highest preference 255 advertise.
// See details in the section-17.1.2 of rfc-3315. // See details in the section-17.1.2 of rfc-3315.
// //
if (Instance->AdPref == 0xff || Timeout) { if ((Instance->AdPref == 0xff) || Timeout) {
Status = Dhcp6SelectAdvertiseMsg (Instance, Instance->AdSelect); Status = Dhcp6SelectAdvertiseMsg (Instance, Instance->AdSelect);
} }
return Status; return Status;
} }
/** /**
The Dhcp6 stateful exchange process routine. The Dhcp6 stateful exchange process routine.
@ -2595,27 +2562,27 @@ Dhcp6HandleStateful (
// //
// Discard the packet if not advertisement or reply packet. // Discard the packet if not advertisement or reply packet.
// //
if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgAdvertise && Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) { if ((Packet->Dhcp6.Header.MessageType != Dhcp6MsgAdvertise) && (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply)) {
goto ON_CONTINUE; goto ON_CONTINUE;
} }
// //
// Check whether include client Id or not. // Check whether include client Id or not.
// //
Option = Dhcp6SeekOption( Option = Dhcp6SeekOption (
Packet->Dhcp6.Option, Packet->Dhcp6.Option,
Packet->Length - 4, Packet->Length - 4,
Dhcp6OptClientId Dhcp6OptClientId
); );
if (Option == NULL || CompareMem (Option + 4, ClientId->Duid, ClientId->Length) != 0) { if ((Option == NULL) || (CompareMem (Option + 4, ClientId->Duid, ClientId->Length) != 0)) {
goto ON_CONTINUE; goto ON_CONTINUE;
} }
// //
// Check whether include server Id or not. // Check whether include server Id or not.
// //
Option = Dhcp6SeekOption( Option = Dhcp6SeekOption (
Packet->Dhcp6.Option, Packet->Dhcp6.Option,
Packet->Length - 4, Packet->Length - 4,
Dhcp6OptServerId Dhcp6OptServerId
@ -2649,6 +2616,7 @@ Dhcp6HandleStateful (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
break; break;
default: default:
// //
@ -2673,7 +2641,6 @@ ON_EXIT:
} }
} }
/** /**
The Dhcp6 stateless exchange process routine. The Dhcp6 stateless exchange process routine.
@ -2776,7 +2743,6 @@ ON_EXIT:
} }
} }
/** /**
The receive callback function for Dhcp6 exchange process. The receive callback function for Dhcp6 exchange process.
@ -2812,14 +2778,14 @@ Dhcp6ReceivePacket (
ASSERT (Udp6Wrap != NULL); ASSERT (Udp6Wrap != NULL);
ASSERT (Context != NULL); ASSERT (Context != NULL);
Service = (DHCP6_SERVICE *) Context; Service = (DHCP6_SERVICE *)Context;
Instance = NULL; Instance = NULL;
Packet = NULL; Packet = NULL;
IsDispatched = FALSE; IsDispatched = FALSE;
IsStateless = FALSE; IsStateless = FALSE;
if (EFI_ERROR (IoStatus)) { if (EFI_ERROR (IoStatus)) {
return ; return;
} }
if (Udp6Wrap->TotalSize < sizeof (EFI_DHCP6_HEADER)) { if (Udp6Wrap->TotalSize < sizeof (EFI_DHCP6_HEADER)) {
@ -2830,7 +2796,7 @@ Dhcp6ReceivePacket (
// Copy the net buffer received from upd6 to a Dhcp6 packet. // Copy the net buffer received from upd6 to a Dhcp6 packet.
// //
Size = sizeof (EFI_DHCP6_PACKET) + Udp6Wrap->TotalSize; Size = sizeof (EFI_DHCP6_PACKET) + Udp6Wrap->TotalSize;
Packet = (EFI_DHCP6_PACKET *) AllocateZeroPool (Size); Packet = (EFI_DHCP6_PACKET *)AllocateZeroPool (Size);
if (Packet == NULL) { if (Packet == NULL) {
goto ON_CONTINUE; goto ON_CONTINUE;
@ -2838,7 +2804,7 @@ Dhcp6ReceivePacket (
Packet->Size = Size; Packet->Size = Size;
Head = &Packet->Dhcp6.Header; Head = &Packet->Dhcp6.Header;
Packet->Length = NetbufCopy (Udp6Wrap, 0, Udp6Wrap->TotalSize, (UINT8 *) Head); Packet->Length = NetbufCopy (Udp6Wrap, 0, Udp6Wrap->TotalSize, (UINT8 *)Head);
if (Packet->Length == 0) { if (Packet->Length == 0) {
goto ON_CONTINUE; goto ON_CONTINUE;
@ -2848,11 +2814,9 @@ Dhcp6ReceivePacket (
// Dispatch packet to right instance by transaction id. // Dispatch packet to right instance by transaction id.
// //
NET_LIST_FOR_EACH_SAFE (Entry1, Next1, &Service->Child) { NET_LIST_FOR_EACH_SAFE (Entry1, Next1, &Service->Child) {
Instance = NET_LIST_USER_STRUCT (Entry1, DHCP6_INSTANCE, Link); Instance = NET_LIST_USER_STRUCT (Entry1, DHCP6_INSTANCE, Link);
NET_LIST_FOR_EACH_SAFE (Entry2, Next2, &Instance->TxList) { NET_LIST_FOR_EACH_SAFE (Entry2, Next2, &Instance->TxList) {
TxCb = NET_LIST_USER_STRUCT (Entry2, DHCP6_TX_CB, Link); TxCb = NET_LIST_USER_STRUCT (Entry2, DHCP6_TX_CB, Link);
if (Packet->Dhcp6.Header.TransactionId == TxCb->Xid) { if (Packet->Dhcp6.Header.TransactionId == TxCb->Xid) {
@ -2863,6 +2827,7 @@ Dhcp6ReceivePacket (
if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) { if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) {
IsStateless = TRUE; IsStateless = TRUE;
} }
IsDispatched = TRUE; IsDispatched = TRUE;
break; break;
} }
@ -2963,10 +2928,10 @@ Dhcp6LinkMovDetect (
if (!MediaPresent && Instance->MediaPresent) { if (!MediaPresent && Instance->MediaPresent) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
/** /**
The timer routine of the Dhcp6 instance for each second. The timer routine of the Dhcp6 instance for each second.
@ -2991,14 +2956,13 @@ Dhcp6OnTimerTick (
ASSERT (Context != NULL); ASSERT (Context != NULL);
Instance = (DHCP6_INSTANCE *) Context; Instance = (DHCP6_INSTANCE *)Context;
// //
// 1. Loop the tx list, count live time of every tx packet to check whether // 1. Loop the tx list, count live time of every tx packet to check whether
// need re-transmit or not. // need re-transmit or not.
// //
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) { NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link); TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link);
TxCb->TickTime++; TxCb->TickTime++;
@ -3007,7 +2971,7 @@ Dhcp6OnTimerTick (
// //
// Handle the first rt in the transmission of solicit specially. // Handle the first rt in the transmission of solicit specially.
// //
if ((TxCb->RetryCnt == 0 || TxCb->SolicitRetry) && TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgSolicit) { if (((TxCb->RetryCnt == 0) || TxCb->SolicitRetry) && (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgSolicit)) {
if (Instance->AdSelect == NULL) { if (Instance->AdSelect == NULL) {
// //
// Set adpref as 0xff here to indicate select any advertisement // Set adpref as 0xff here to indicate select any advertisement
@ -3024,9 +2988,11 @@ Dhcp6OnTimerTick (
} else if (EFI_ERROR (Status)) { } else if (EFI_ERROR (Status)) {
TxCb->RetryCnt++; TxCb->RetryCnt++;
} }
return; return;
} }
} }
// //
// Increase the retry count for the packet and add up the total loss time. // Increase the retry count for the packet and add up the total loss time.
// //
@ -3036,7 +3002,7 @@ Dhcp6OnTimerTick (
// //
// Check whether overflow the max retry count limit for this packet // Check whether overflow the max retry count limit for this packet
// //
if (TxCb->RetryCtl.Mrc != 0 && TxCb->RetryCtl.Mrc < TxCb->RetryCnt) { if ((TxCb->RetryCtl.Mrc != 0) && (TxCb->RetryCtl.Mrc < TxCb->RetryCnt)) {
Status = EFI_NO_RESPONSE; Status = EFI_NO_RESPONSE;
goto ON_CLOSE; goto ON_CLOSE;
} }
@ -3044,7 +3010,7 @@ Dhcp6OnTimerTick (
// //
// Check whether overflow the max retry duration for this packet // Check whether overflow the max retry duration for this packet
// //
if (TxCb->RetryCtl.Mrd != 0 && TxCb->RetryCtl.Mrd <= TxCb->RetryLos) { if ((TxCb->RetryCtl.Mrd != 0) && (TxCb->RetryCtl.Mrd <= TxCb->RetryLos)) {
Status = EFI_NO_RESPONSE; Status = EFI_NO_RESPONSE;
goto ON_CLOSE; goto ON_CLOSE;
} }
@ -3061,7 +3027,7 @@ Dhcp6OnTimerTick (
TRUE TRUE
); );
if (TxCb->RetryCtl.Mrt != 0 && TxCb->RetryCtl.Mrt < TxCb->RetryExp) { if ((TxCb->RetryCtl.Mrt != 0) && (TxCb->RetryCtl.Mrt < TxCb->RetryExp)) {
TxCb->RetryExp = Dhcp6CalculateExpireTime ( TxCb->RetryExp = Dhcp6CalculateExpireTime (
TxCb->RetryCtl.Mrt, TxCb->RetryCtl.Mrt,
TRUE, TRUE,
@ -3074,7 +3040,7 @@ Dhcp6OnTimerTick (
// duration time. // duration time.
// //
LossTime = TxCb->RetryLos + TxCb->RetryExp; LossTime = TxCb->RetryLos + TxCb->RetryExp;
if (TxCb->RetryCtl.Mrd != 0 && TxCb->RetryCtl.Mrd < LossTime) { if ((TxCb->RetryCtl.Mrd != 0) && (TxCb->RetryCtl.Mrd < LossTime)) {
TxCb->RetryExp = TxCb->RetryCtl.Mrd - TxCb->RetryLos; TxCb->RetryExp = TxCb->RetryCtl.Mrd - TxCb->RetryLos;
} }
@ -3100,22 +3066,19 @@ Dhcp6OnTimerTick (
// //
IaCb = &Instance->IaCb; IaCb = &Instance->IaCb;
if (Instance->Config == NULL || IaCb->Ia == NULL) { if ((Instance->Config == NULL) || (IaCb->Ia == NULL)) {
return; return;
} }
if (IaCb->Ia->State == Dhcp6Bound || IaCb->Ia->State == Dhcp6Renewing || IaCb->Ia->State == Dhcp6Rebinding) { if ((IaCb->Ia->State == Dhcp6Bound) || (IaCb->Ia->State == Dhcp6Renewing) || (IaCb->Ia->State == Dhcp6Rebinding)) {
IaCb->LeaseTime++; IaCb->LeaseTime++;
if (IaCb->LeaseTime > IaCb->T2 && IaCb->Ia->State == Dhcp6Bound) { if ((IaCb->LeaseTime > IaCb->T2) && (IaCb->Ia->State == Dhcp6Bound)) {
// //
// Exceed t2, send rebind packet to extend the Ia lease. // Exceed t2, send rebind packet to extend the Ia lease.
// //
Dhcp6SendRenewRebindMsg (Instance, TRUE); Dhcp6SendRenewRebindMsg (Instance, TRUE);
} else if ((IaCb->LeaseTime > IaCb->T1) && (IaCb->Ia->State == Dhcp6Bound)) {
} else if (IaCb->LeaseTime > IaCb->T1 && IaCb->Ia->State == Dhcp6Bound) {
// //
// Exceed t1, send renew packet to extend the Ia lease. // Exceed t1, send renew packet to extend the Ia lease.
// //
@ -3133,28 +3096,32 @@ Dhcp6OnTimerTick (
return; return;
ON_CLOSE: ON_CLOSE:
if (Dhcp6IsValidTxCb (Instance, TxCb) && if (Dhcp6IsValidTxCb (Instance, TxCb) &&
TxCb->TxPacket != NULL && (TxCb->TxPacket != NULL) &&
(TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest || ((TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) ||
TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew || (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew) ||
TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm) (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm))
) { )
{
// //
// The failure of renew/Confirm will still switch to the bound state. // The failure of renew/Confirm will still switch to the bound state.
// //
if ((TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew) || if ((TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew) ||
(TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm)) { (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm))
{
ASSERT (Instance->IaCb.Ia); ASSERT (Instance->IaCb.Ia);
Instance->IaCb.Ia->State = Dhcp6Bound; Instance->IaCb.Ia->State = Dhcp6Bound;
} }
// //
// The failure of info-request will return no response. // The failure of info-request will return no response.
// //
if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) { if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) {
Instance->UdpSts = EFI_NO_RESPONSE; Instance->UdpSts = EFI_NO_RESPONSE;
} }
Dhcp6DequeueRetry ( Dhcp6DequeueRetry (
Instance, Instance,
TxCb->Xid, TxCb->Xid,

View File

@ -10,7 +10,6 @@
#ifndef __EFI_DHCP6_IO_H__ #ifndef __EFI_DHCP6_IO_H__
#define __EFI_DHCP6_IO_H__ #define __EFI_DHCP6_IO_H__
/** /**
Clean up the specific nodes in the retry list. Clean up the specific nodes in the retry list.

View File

@ -10,7 +10,6 @@
#include "Dhcp6Impl.h" #include "Dhcp6Impl.h"
/** /**
Generate client Duid in the format of Duid-llt. Generate client Duid in the format of Duid-llt.
@ -31,12 +30,11 @@ Dhcp6GenerateClientId (
UINT32 Stamp; UINT32 Stamp;
EFI_GUID Uuid; EFI_GUID Uuid;
// //
// Attempt to get client Id from variable to keep it constant. // Attempt to get client Id from variable to keep it constant.
// See details in section-9 of rfc-3315. // See details in section-9 of rfc-3315.
// //
GetVariable2 (L"ClientId", &gEfiDhcp6ServiceBindingProtocolGuid, (VOID**)&Duid, NULL); GetVariable2 (L"ClientId", &gEfiDhcp6ServiceBindingProtocolGuid, (VOID **)&Duid, NULL);
if (Duid != NULL) { if (Duid != NULL) {
return Duid; return Duid;
} }
@ -84,17 +82,15 @@ Dhcp6GenerateClientId (
// //
// sizeof (Duid-type + UUID-size) = 18 bytes // sizeof (Duid-type + UUID-size) = 18 bytes
// //
Duid->Length = (UINT16) (18); Duid->Length = (UINT16)(18);
// //
// Set the Duid-type and copy UUID. // Set the Duid-type and copy UUID.
// //
WriteUnaligned16 ((UINT16 *) (Duid->Duid), HTONS (Dhcp6DuidTypeUuid)); WriteUnaligned16 ((UINT16 *)(Duid->Duid), HTONS (Dhcp6DuidTypeUuid));
CopyMem (Duid->Duid + 2, &Uuid, sizeof(EFI_GUID));
CopyMem (Duid->Duid + 2, &Uuid, sizeof (EFI_GUID));
} else { } else {
// //
// //
// The format of DUID-LLT: // The format of DUID-LLT:
@ -133,14 +129,14 @@ Dhcp6GenerateClientId (
// //
// sizeof (Duid-type + hardware-type + time) = 8 bytes // sizeof (Duid-type + hardware-type + time) = 8 bytes
// //
Duid->Length = (UINT16) (Mode->HwAddressSize + 8); Duid->Length = (UINT16)(Mode->HwAddressSize + 8);
// //
// Set the Duid-type, hardware-type, time and copy the hardware address. // Set the Duid-type, hardware-type, time and copy the hardware address.
// //
WriteUnaligned16 ((UINT16 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid)), HTONS (Dhcp6DuidTypeLlt)); WriteUnaligned16 ((UINT16 *)((UINT8 *)Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid)), HTONS (Dhcp6DuidTypeLlt));
WriteUnaligned16 ((UINT16 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 2), HTONS (NET_IFTYPE_ETHERNET)); WriteUnaligned16 ((UINT16 *)((UINT8 *)Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 2), HTONS (NET_IFTYPE_ETHERNET));
WriteUnaligned32 ((UINT32 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 4), HTONL (Stamp)); WriteUnaligned32 ((UINT32 *)((UINT8 *)Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 4), HTONL (Stamp));
CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize); CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);
} }
@ -150,7 +146,7 @@ Dhcp6GenerateClientId (
&gEfiDhcp6ServiceBindingProtocolGuid, &gEfiDhcp6ServiceBindingProtocolGuid,
(EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS), (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS),
Duid->Length + 2, Duid->Length + 2,
(VOID *) Duid (VOID *)Duid
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (Duid); FreePool (Duid);
@ -160,7 +156,6 @@ Dhcp6GenerateClientId (
return Duid; return Duid;
} }
/** /**
Copy the Dhcp6 configure data. Copy the Dhcp6 configure data.
@ -187,7 +182,6 @@ Dhcp6CopyConfigData (
// Allocate another buffer for solicitretransmission, and copy it. // Allocate another buffer for solicitretransmission, and copy it.
// //
if (SorCfg->SolicitRetransmission != NULL) { if (SorCfg->SolicitRetransmission != NULL) {
DstCfg->SolicitRetransmission = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION)); DstCfg->SolicitRetransmission = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
if (DstCfg->SolicitRetransmission == NULL) { if (DstCfg->SolicitRetransmission == NULL) {
@ -204,8 +198,7 @@ Dhcp6CopyConfigData (
); );
} }
if (SorCfg->OptionList != NULL && SorCfg->OptionCount != 0) { if ((SorCfg->OptionList != NULL) && (SorCfg->OptionCount != 0)) {
OptionListSize = SorCfg->OptionCount * sizeof (EFI_DHCP6_PACKET_OPTION *); OptionListSize = SorCfg->OptionCount * sizeof (EFI_DHCP6_PACKET_OPTION *);
DstCfg->OptionList = AllocateZeroPool (OptionListSize); DstCfg->OptionList = AllocateZeroPool (OptionListSize);
@ -217,7 +210,6 @@ Dhcp6CopyConfigData (
} }
for (Index = 0; Index < SorCfg->OptionCount; Index++) { for (Index = 0; Index < SorCfg->OptionCount; Index++) {
OptionSize = NTOHS (SorCfg->OptionList[Index]->OpLen) + 4; OptionSize = NTOHS (SorCfg->OptionList[Index]->OpLen) + 4;
DstCfg->OptionList[Index] = AllocateZeroPool (OptionSize); DstCfg->OptionList[Index] = AllocateZeroPool (OptionSize);
@ -239,7 +231,6 @@ Dhcp6CopyConfigData (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Clean up the configure data. Clean up the configure data.
@ -264,6 +255,7 @@ Dhcp6CleanupConfigData (
FreePool (CfgData->OptionList[Index]); FreePool (CfgData->OptionList[Index]);
} }
} }
FreePool (CfgData->OptionList); FreePool (CfgData->OptionList);
} }
@ -274,7 +266,6 @@ Dhcp6CleanupConfigData (
ZeroMem (CfgData, sizeof (EFI_DHCP6_CONFIG_DATA)); ZeroMem (CfgData, sizeof (EFI_DHCP6_CONFIG_DATA));
} }
/** /**
Clean up the mode data. Clean up the mode data.
@ -296,17 +287,16 @@ Dhcp6CleanupModeData (
} }
if (ModeData->Ia != NULL) { if (ModeData->Ia != NULL) {
if (ModeData->Ia->ReplyPacket != NULL) { if (ModeData->Ia->ReplyPacket != NULL) {
FreePool (ModeData->Ia->ReplyPacket); FreePool (ModeData->Ia->ReplyPacket);
} }
FreePool (ModeData->Ia); FreePool (ModeData->Ia);
} }
ZeroMem (ModeData, sizeof (EFI_DHCP6_MODE_DATA)); ZeroMem (ModeData, sizeof (EFI_DHCP6_MODE_DATA));
} }
/** /**
Calculate the expire time by the algorithm defined in rfc. Calculate the expire time by the algorithm defined in rfc.
@ -335,8 +325,8 @@ Dhcp6CalculateExpireTime (
// //
gRT->GetTime (&Time, NULL); gRT->GetTime (&Time, NULL);
Seed = ((Time.Nanosecond >> 10) & DHCP6_10_BIT_MASK); Seed = ((Time.Nanosecond >> 10) & DHCP6_10_BIT_MASK);
Signed = (BOOLEAN) ((((Time.Nanosecond >> 9) & 0x01) != 0) ? TRUE : FALSE); Signed = (BOOLEAN)((((Time.Nanosecond >> 9) & 0x01) != 0) ? TRUE : FALSE);
Signed = (BOOLEAN) (NeedSigned ? Signed : FALSE); Signed = (BOOLEAN)(NeedSigned ? Signed : FALSE);
// //
// Calculate expire by the following algo: // Calculate expire by the following algo:
@ -348,20 +338,13 @@ Dhcp6CalculateExpireTime (
// The (Seed / 0x3ff / 10) is used to a random range (0, 0.1). // The (Seed / 0x3ff / 10) is used to a random range (0, 0.1).
// //
if (IsFirstRt && Signed) { if (IsFirstRt && Signed) {
Expire = Base - (UINT32)(Base * Seed / DHCP6_10_BIT_MASK / 10);
Expire = Base - (UINT32) (Base * Seed / DHCP6_10_BIT_MASK / 10);
} else if (IsFirstRt && !Signed) { } else if (IsFirstRt && !Signed) {
Expire = Base + (UINT32)(Base * Seed / DHCP6_10_BIT_MASK / 10);
Expire = Base + (UINT32) (Base * Seed / DHCP6_10_BIT_MASK / 10);
} else if (!IsFirstRt && Signed) { } else if (!IsFirstRt && Signed) {
Expire = 2 * Base - (UINT32)(Base * Seed / DHCP6_10_BIT_MASK / 10);
Expire = 2 * Base - (UINT32) (Base * Seed / DHCP6_10_BIT_MASK / 10);
} else { } else {
Expire = 2 * Base + (UINT32)(Base * Seed / DHCP6_10_BIT_MASK / 10);
Expire = 2 * Base + (UINT32) (Base * Seed / DHCP6_10_BIT_MASK / 10);
} }
Expire = (Expire != 0) ? Expire : 1; Expire = (Expire != 0) ? Expire : 1;
@ -369,7 +352,6 @@ Dhcp6CalculateExpireTime (
return Expire; return Expire;
} }
/** /**
Calculate the lease time by the algorithm defined in rfc. Calculate the lease time by the algorithm defined in rfc.
@ -387,7 +369,7 @@ Dhcp6CalculateLeaseTime (
ASSERT (IaCb->Ia->IaAddressCount > 0); ASSERT (IaCb->Ia->IaAddressCount > 0);
MinLt = (UINT32) (-1); MinLt = (UINT32)(-1);
MaxLt = 0; MaxLt = 0;
// //
@ -409,7 +391,6 @@ Dhcp6CalculateLeaseTime (
IaCb->LeaseTime = 0; IaCb->LeaseTime = 0;
} }
/** /**
Check whether the addresses are all included by the configured Ia. Check whether the addresses are all included by the configured Ia.
@ -437,17 +418,15 @@ Dhcp6CheckAddress (
// will return success if address count is zero, which means all addresses. // will return success if address count is zero, which means all addresses.
// //
for (Index1 = 0; Index1 < AddressCount; Index1++) { for (Index1 = 0; Index1 < AddressCount; Index1++) {
Found = FALSE; Found = FALSE;
for (Index2 = 0; Index2 < Ia->IaAddressCount; Index2++) { for (Index2 = 0; Index2 < Ia->IaAddressCount; Index2++) {
if (CompareMem ( if (CompareMem (
&Addresses[Index1], &Addresses[Index1],
&Ia->IaAddress[Index2], &Ia->IaAddress[Index2],
sizeof (EFI_IPv6_ADDRESS) sizeof (EFI_IPv6_ADDRESS)
) == 0) { ) == 0)
{
Found = TRUE; Found = TRUE;
break; break;
} }
@ -461,7 +440,6 @@ Dhcp6CheckAddress (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Deprive the addresses from current Ia, and generate another eliminated Ia. Deprive the addresses from current Ia, and generate another eliminated Ia.
@ -521,16 +499,15 @@ Dhcp6DepriveAddress (
// Move the addresses from the Ia of instance to the deprived Ia. // Move the addresses from the Ia of instance to the deprived Ia.
// //
for (Index1 = 0; Index1 < AddressCount; Index1++) { for (Index1 = 0; Index1 < AddressCount; Index1++) {
Found = FALSE; Found = FALSE;
for (Index2 = 0; Index2 < Ia->IaAddressCount; Index2++) { for (Index2 = 0; Index2 < Ia->IaAddressCount; Index2++) {
if (CompareMem ( if (CompareMem (
&Addresses[Index1], &Addresses[Index1],
&Ia->IaAddress[Index2], &Ia->IaAddress[Index2],
sizeof (EFI_IPv6_ADDRESS) sizeof (EFI_IPv6_ADDRESS)
) == 0) { ) == 0)
{
// //
// Copy the deprived address to the copy of Ia // Copy the deprived address to the copy of Ia
// //
@ -549,10 +526,12 @@ Dhcp6DepriveAddress (
(Ia->IaAddressCount - Index2 - 1) * sizeof (EFI_DHCP6_IA_ADDRESS) (Ia->IaAddressCount - Index2 - 1) * sizeof (EFI_DHCP6_IA_ADDRESS)
); );
} }
Found = TRUE; Found = TRUE;
break; break;
} }
} }
ASSERT (Found == TRUE); ASSERT (Found == TRUE);
} }
@ -562,7 +541,6 @@ Dhcp6DepriveAddress (
return IaCopy; return IaCopy;
} }
/** /**
The dummy ext buffer free callback routine. The dummy ext buffer free callback routine.
@ -577,7 +555,6 @@ Dhcp6DummyExtFree (
{ {
} }
/** /**
The callback routine once message transmitted. The callback routine once message transmitted.
@ -599,7 +576,6 @@ Dhcp6OnTransmitted (
NetbufFree (Wrap); NetbufFree (Wrap);
} }
/** /**
Append the option to Buf, and move Buf to the end. Append the option to Buf, and move Buf to the end.
@ -633,9 +609,9 @@ Dhcp6AppendOption (
ASSERT (OptLen != 0); ASSERT (OptLen != 0);
WriteUnaligned16 ((UINT16 *) Buf, OptType); WriteUnaligned16 ((UINT16 *)Buf, OptType);
Buf += 2; Buf += 2;
WriteUnaligned16 ((UINT16 *) Buf, OptLen); WriteUnaligned16 ((UINT16 *)Buf, OptLen);
Buf += 2; Buf += 2;
CopyMem (Buf, Data, NTOHS (OptLen)); CopyMem (Buf, Data, NTOHS (OptLen));
Buf += NTOHS (OptLen); Buf += NTOHS (OptLen);
@ -658,9 +634,8 @@ Dhcp6AppendIaAddrOption (
IN OUT UINT8 *Buf, IN OUT UINT8 *Buf,
IN EFI_DHCP6_IA_ADDRESS *IaAddr, IN EFI_DHCP6_IA_ADDRESS *IaAddr,
IN UINT32 MessageType IN UINT32 MessageType
) )
{ {
// The format of the IA Address option is: // The format of the IA Address option is:
// //
// 0 1 2 3 // 0 1 2 3
@ -685,14 +660,14 @@ Dhcp6AppendIaAddrOption (
// //
// Fill the value of Ia Address option type // Fill the value of Ia Address option type
// //
WriteUnaligned16 ((UINT16 *) Buf, HTONS (Dhcp6OptIaAddr)); WriteUnaligned16 ((UINT16 *)Buf, HTONS (Dhcp6OptIaAddr));
Buf += 2; Buf += 2;
WriteUnaligned16 ((UINT16 *) Buf, HTONS (sizeof (EFI_DHCP6_IA_ADDRESS))); WriteUnaligned16 ((UINT16 *)Buf, HTONS (sizeof (EFI_DHCP6_IA_ADDRESS)));
Buf += 2; Buf += 2;
CopyMem (Buf, &IaAddr->IpAddress, sizeof(EFI_IPv6_ADDRESS)); CopyMem (Buf, &IaAddr->IpAddress, sizeof (EFI_IPv6_ADDRESS));
Buf += sizeof(EFI_IPv6_ADDRESS); Buf += sizeof (EFI_IPv6_ADDRESS);
// //
// Fill the value of preferred-lifetime and valid-lifetime. // Fill the value of preferred-lifetime and valid-lifetime.
@ -700,19 +675,20 @@ Dhcp6AppendIaAddrOption (
// should set to 0 when initiate a Confirm message. // should set to 0 when initiate a Confirm message.
// //
if (MessageType != Dhcp6MsgConfirm) { if (MessageType != Dhcp6MsgConfirm) {
WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->PreferredLifetime)); WriteUnaligned32 ((UINT32 *)Buf, HTONL (IaAddr->PreferredLifetime));
} }
Buf += 4; Buf += 4;
if (MessageType != Dhcp6MsgConfirm) { if (MessageType != Dhcp6MsgConfirm) {
WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->ValidLifetime)); WriteUnaligned32 ((UINT32 *)Buf, HTONL (IaAddr->ValidLifetime));
} }
Buf += 4; Buf += 4;
return Buf; return Buf;
} }
/** /**
Append the appointed Ia option to Buf, and move Buf to the end. Append the appointed Ia option to Buf, and move Buf to the end.
@ -760,28 +736,28 @@ Dhcp6AppendIaOption (
// //
// Fill the value of Ia option type // Fill the value of Ia option type
// //
WriteUnaligned16 ((UINT16 *) Buf, HTONS (Ia->Descriptor.Type)); WriteUnaligned16 ((UINT16 *)Buf, HTONS (Ia->Descriptor.Type));
Buf += 2; Buf += 2;
// //
// Fill the len of Ia option later, keep the pointer first // Fill the len of Ia option later, keep the pointer first
// //
Len = (UINT16 *) Buf; Len = (UINT16 *)Buf;
Buf += 2; Buf += 2;
// //
// Fill the value of iaid // Fill the value of iaid
// //
WriteUnaligned32 ((UINT32 *) Buf, HTONL (Ia->Descriptor.IaId)); WriteUnaligned32 ((UINT32 *)Buf, HTONL (Ia->Descriptor.IaId));
Buf += 4; Buf += 4;
// //
// Fill the value of t1 and t2 if iana, keep it 0xffffffff if no specified. // Fill the value of t1 and t2 if iana, keep it 0xffffffff if no specified.
// //
if (Ia->Descriptor.Type == Dhcp6OptIana) { if (Ia->Descriptor.Type == Dhcp6OptIana) {
WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T1 != 0) ? T1 : 0xffffffff)); WriteUnaligned32 ((UINT32 *)Buf, HTONL ((T1 != 0) ? T1 : 0xffffffff));
Buf += 4; Buf += 4;
WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T2 != 0) ? T2 : 0xffffffff)); WriteUnaligned32 ((UINT32 *)Buf, HTONL ((T2 != 0) ? T2 : 0xffffffff));
Buf += 4; Buf += 4;
} }
@ -789,14 +765,14 @@ Dhcp6AppendIaOption (
// Fill all the addresses belong to the Ia // Fill all the addresses belong to the Ia
// //
for (Index = 0; Index < Ia->IaAddressCount; Index++) { for (Index = 0; Index < Ia->IaAddressCount; Index++) {
AddrOpt = (UINT8 *) Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS); AddrOpt = (UINT8 *)Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS);
Buf = Dhcp6AppendIaAddrOption (Buf, (EFI_DHCP6_IA_ADDRESS *) AddrOpt, MessageType); Buf = Dhcp6AppendIaAddrOption (Buf, (EFI_DHCP6_IA_ADDRESS *)AddrOpt, MessageType);
} }
// //
// Fill the value of Ia option length // Fill the value of Ia option length
// //
*Len = HTONS ((UINT16) (Buf - (UINT8 *) Len - 2)); *Len = HTONS ((UINT16)(Buf - (UINT8 *)Len - 2));
return Buf; return Buf;
} }
@ -833,21 +809,21 @@ Dhcp6AppendETOption (
// //
// Fill the value of elapsed-time option type. // Fill the value of elapsed-time option type.
// //
WriteUnaligned16 ((UINT16 *) Buf, HTONS (Dhcp6OptElapsedTime)); WriteUnaligned16 ((UINT16 *)Buf, HTONS (Dhcp6OptElapsedTime));
Buf += 2; Buf += 2;
// //
// Fill the len of elapsed-time option, which is fixed. // Fill the len of elapsed-time option, which is fixed.
// //
WriteUnaligned16 ((UINT16 *) Buf, HTONS(2)); WriteUnaligned16 ((UINT16 *)Buf, HTONS (2));
Buf += 2; Buf += 2;
// //
// Fill in elapsed time value with 0 value for now. The actual value is // Fill in elapsed time value with 0 value for now. The actual value is
// filled in later just before the packet is transmitted. // filled in later just before the packet is transmitted.
// //
WriteUnaligned16 ((UINT16 *) Buf, HTONS(0)); WriteUnaligned16 ((UINT16 *)Buf, HTONS (0));
*Elapsed = (UINT16 *) Buf; *Elapsed = (UINT16 *)Buf;
Buf += 2; Buf += 2;
return Buf; return Buf;
@ -879,7 +855,7 @@ SetElapsedTime (
((((UINT32)(Time.Year - 2000) * 360 + (Time.Month - 1) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Second, ((((UINT32)(Time.Year - 2000) * 360 + (Time.Month - 1) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Second,
100 100
) + ) +
DivU64x32( DivU64x32 (
Time.Nanosecond, Time.Nanosecond,
10000000 10000000
); );
@ -902,9 +878,9 @@ SetElapsedTime (
ElapsedTimeValue = 0xffff; ElapsedTimeValue = 0xffff;
} }
} }
WriteUnaligned16 (Elapsed, HTONS((UINT16) ElapsedTimeValue));
}
WriteUnaligned16 (Elapsed, HTONS ((UINT16)ElapsedTimeValue));
}
/** /**
Seek the address of the first byte of the option header. Seek the address of the first byte of the option header.
@ -936,19 +912,19 @@ Dhcp6SeekOption (
// The format of Dhcp6 option refers to Dhcp6AppendOption(). // The format of Dhcp6 option refers to Dhcp6AppendOption().
// //
while (Cursor < Buf + SeekLen) { while (Cursor < Buf + SeekLen) {
OpCode = ReadUnaligned16 ((UINT16 *) Cursor); OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
if (OpCode == HTONS (OptType)) { if (OpCode == HTONS (OptType)) {
Option = Cursor; Option = Cursor;
break; break;
} }
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2)));
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
Cursor += (DataLen + 4); Cursor += (DataLen + 4);
} }
return Option; return Option;
} }
/** /**
Seek the address of the first byte of the Ia option header. Seek the address of the first byte of the Ia option header.
@ -980,13 +956,14 @@ Dhcp6SeekIaOption (
Cursor = Buf; Cursor = Buf;
while (Cursor < Buf + SeekLen) { while (Cursor < Buf + SeekLen) {
OpCode = ReadUnaligned16 ((UINT16 *) Cursor); OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
IaId = ReadUnaligned32 ((UINT32 *) (Cursor + 4)); IaId = ReadUnaligned32 ((UINT32 *)(Cursor + 4));
if (OpCode == HTONS (IaDesc->Type) && IaId == HTONL (IaDesc->IaId)) { if ((OpCode == HTONS (IaDesc->Type)) && (IaId == HTONL (IaDesc->IaId))) {
Option = Cursor; Option = Cursor;
break; break;
} }
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2)));
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
Cursor += (DataLen + 4); Cursor += (DataLen + 4);
} }
@ -1015,10 +992,11 @@ Dhcp6AddrIsInCurrentIa (
ASSERT (IaAddr != NULL && CurrentIa != NULL); ASSERT (IaAddr != NULL && CurrentIa != NULL);
for (Index = 0; Index < CurrentIa->IaAddressCount; Index++) { for (Index = 0; Index < CurrentIa->IaAddressCount; Index++) {
if (EFI_IP6_EQUAL(&IaAddr->IpAddress, &CurrentIa->IaAddress[Index].IpAddress)) { if (EFI_IP6_EQUAL (&IaAddr->IpAddress, &CurrentIa->IaAddress[Index].IpAddress)) {
return TRUE; return TRUE;
} }
} }
return FALSE; return FALSE;
} }
@ -1086,26 +1064,28 @@ Dhcp6ParseAddrOption (
// Refer to RFC3315 Chapter 18.1.8, we need to update lifetimes for any addresses in the IA option // Refer to RFC3315 Chapter 18.1.8, we need to update lifetimes for any addresses in the IA option
// that the client already has recorded in the IA, and discard the Ia address option with 0 valid time. // that the client already has recorded in the IA, and discard the Ia address option with 0 valid time.
// //
OpCode = ReadUnaligned16 ((UINT16 *) Cursor); OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
PreferredLt = NTOHL (ReadUnaligned32 ((UINT32 *) (Cursor + 20))); PreferredLt = NTOHL (ReadUnaligned32 ((UINT32 *)(Cursor + 20)));
ValidLt = NTOHL (ReadUnaligned32 ((UINT32 *) (Cursor + 24))); ValidLt = NTOHL (ReadUnaligned32 ((UINT32 *)(Cursor + 24)));
IaAddr = (EFI_DHCP6_IA_ADDRESS *) (Cursor + 4); IaAddr = (EFI_DHCP6_IA_ADDRESS *)(Cursor + 4);
if (OpCode == HTONS (Dhcp6OptIaAddr) && ValidLt >= PreferredLt && if ((OpCode == HTONS (Dhcp6OptIaAddr)) && (ValidLt >= PreferredLt) &&
(Dhcp6AddrIsInCurrentIa(IaAddr, CurrentIa) || ValidLt !=0)) { (Dhcp6AddrIsInCurrentIa (IaAddr, CurrentIa) || (ValidLt != 0)))
{
if (AddrBuf != NULL) { if (AddrBuf != NULL) {
CopyMem (AddrBuf, IaAddr, sizeof (EFI_DHCP6_IA_ADDRESS)); CopyMem (AddrBuf, IaAddr, sizeof (EFI_DHCP6_IA_ADDRESS));
AddrBuf->PreferredLifetime = PreferredLt; AddrBuf->PreferredLifetime = PreferredLt;
AddrBuf->ValidLifetime = ValidLt; AddrBuf->ValidLifetime = ValidLt;
AddrBuf = (EFI_DHCP6_IA_ADDRESS *) ((UINT8 *) AddrBuf + sizeof (EFI_DHCP6_IA_ADDRESS)); AddrBuf = (EFI_DHCP6_IA_ADDRESS *)((UINT8 *)AddrBuf + sizeof (EFI_DHCP6_IA_ADDRESS));
} }
(*AddrNum)++; (*AddrNum)++;
} }
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2)));
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
Cursor += (DataLen + 4); Cursor += (DataLen + 4);
} }
} }
/** /**
Create a control block for the Ia according to the corresponding options. Create a control block for the Ia according to the corresponding options.
@ -1172,8 +1152,8 @@ Dhcp6GenerateIaCb (
if (Instance->IaCb.Ia->ReplyPacket != NULL) { if (Instance->IaCb.Ia->ReplyPacket != NULL) {
FreePool (Instance->IaCb.Ia->ReplyPacket); FreePool (Instance->IaCb.Ia->ReplyPacket);
} }
FreePool (Instance->IaCb.Ia);
FreePool (Instance->IaCb.Ia);
ZeroMem (&Instance->IaCb, sizeof (DHCP6_IA_CB)); ZeroMem (&Instance->IaCb, sizeof (DHCP6_IA_CB));
@ -1193,7 +1173,6 @@ Dhcp6GenerateIaCb (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Cache the current IA configuration information. Cache the current IA configuration information.
@ -1223,8 +1202,10 @@ Dhcp6CacheIa (
if (Instance->CacheIa == NULL) { if (Instance->CacheIa == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (Instance->CacheIa, Ia, IaSize); CopyMem (Instance->CacheIa, Ia, IaSize);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -1271,7 +1252,7 @@ Dhcp6AppendCacheIa (
} }
NewIa->IaAddressCount += CacheIa->IaAddressCount; NewIa->IaAddressCount += CacheIa->IaAddressCount;
Ptr = (UINT8*)&NewIa->IaAddress[Ia->IaAddressCount]; Ptr = (UINT8 *)&NewIa->IaAddress[Ia->IaAddressCount];
CopyMem (Ptr, CacheIa->IaAddress, CacheIa->IaAddressCount * sizeof (EFI_DHCP6_IA_ADDRESS)); CopyMem (Ptr, CacheIa->IaAddress, CacheIa->IaAddressCount * sizeof (EFI_DHCP6_IA_ADDRESS));
// //
@ -1303,7 +1284,7 @@ Dhcp6GetMappingTimeOut (
UINTN DataSize; UINTN DataSize;
EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits; EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
if (Ip6Cfg == NULL || TimeOut == NULL) { if ((Ip6Cfg == NULL) || (TimeOut == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }

View File

@ -10,7 +10,6 @@
#ifndef __EFI_DHCP6_UTILITY_H__ #ifndef __EFI_DHCP6_UTILITY_H__
#define __EFI_DHCP6_UTILITY_H__ #define __EFI_DHCP6_UTILITY_H__
#define DHCP6_10_BIT_MASK 0x3ff #define DHCP6_10_BIT_MASK 0x3ff
#define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds #define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
@ -310,7 +309,6 @@ Dhcp6GenerateIaCb (
IN UINT32 T2 IN UINT32 T2
); );
/** /**
Cache the current IA configuration information. Cache the current IA configuration information.
@ -325,7 +323,6 @@ Dhcp6CacheIa (
IN DHCP6_INSTANCE *Instance IN DHCP6_INSTANCE *Instance
); );
/** /**
Append CacheIa to the current IA. Meanwhile, clear CacheIa.ValidLifetime to 0. Append CacheIa to the current IA. Meanwhile, clear CacheIa.ValidLifetime to 0.
@ -351,4 +348,5 @@ Dhcp6GetMappingTimeOut (
IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg, IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg,
OUT UINTN *TimeOut OUT UINTN *TimeOut
); );
#endif #endif

View File

@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user-readable name of the EFI Driver. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@ -91,7 +92,6 @@ DnsComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
/// ///
/// Component Name Protocol instance /// Component Name Protocol instance
/// ///
@ -107,8 +107,8 @@ EFI_COMPONENT_NAME_PROTOCOL gDnsComponentName = {
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME2_PROTOCOL gDnsComponentName2 = { EFI_COMPONENT_NAME2_PROTOCOL gDnsComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) DnsComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)DnsComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) DnsComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)DnsComponentNameGetControllerName,
"en" "en"
}; };
@ -208,6 +208,7 @@ UpdateDns4Name (
if (ModeData.DnsCacheList != NULL) { if (ModeData.DnsCacheList != NULL) {
FreePool (ModeData.DnsCacheList); FreePool (ModeData.DnsCacheList);
} }
if (ModeData.DnsServerList != NULL) { if (ModeData.DnsServerList != NULL) {
FreePool (ModeData.DnsServerList); FreePool (ModeData.DnsServerList);
} }
@ -255,7 +256,7 @@ UpdateDns6Name (
EFI_STATUS Status; EFI_STATUS Status;
CHAR16 HandleName[128]; CHAR16 HandleName[128];
EFI_DNS6_MODE_DATA ModeData; EFI_DNS6_MODE_DATA ModeData;
CHAR16 Address[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"]; CHAR16 Address[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
if (Dns6 == NULL) { if (Dns6 == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -274,6 +275,7 @@ UpdateDns6Name (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
UnicodeSPrint ( UnicodeSPrint (
HandleName, HandleName,
sizeof (HandleName), sizeof (HandleName),
@ -285,6 +287,7 @@ UpdateDns6Name (
if (ModeData.DnsCacheList != NULL) { if (ModeData.DnsCacheList != NULL) {
FreePool (ModeData.DnsCacheList); FreePool (ModeData.DnsCacheList);
} }
if (ModeData.DnsServerList != NULL) { if (ModeData.DnsServerList != NULL) {
FreePool (ModeData.DnsServerList); FreePool (ModeData.DnsServerList);
} }

View File

@ -34,7 +34,7 @@ DnsInitSeedPacket (
ZeroMem (Header, sizeof (EFI_DHCP4_HEADER)); ZeroMem (Header, sizeof (EFI_DHCP4_HEADER));
Header->OpCode = DHCP4_OPCODE_REQUEST; Header->OpCode = DHCP4_OPCODE_REQUEST;
Header->HwType = InterfaceInfo->IfType; Header->HwType = InterfaceInfo->IfType;
Header->HwAddrLen = (UINT8) InterfaceInfo->HwAddressSize; Header->HwAddrLen = (UINT8)InterfaceInfo->HwAddressSize;
CopyMem (Header->ClientHwAddr, &(InterfaceInfo->HwAddress), Header->HwAddrLen); CopyMem (Header->ClientHwAddr, &(InterfaceInfo->HwAddress), Header->HwAddrLen);
Seed->Dhcp4.Magik = DHCP4_MAGIC; Seed->Dhcp4.Magik = DHCP4_MAGIC;
@ -56,10 +56,10 @@ DhcpCommonNotify (
) )
{ {
if ((Event == NULL) || (Context == NULL)) { if ((Event == NULL) || (Context == NULL)) {
return ; return;
} }
*((BOOLEAN *) Context) = TRUE; *((BOOLEAN *)Context) = TRUE;
} }
/** /**
@ -119,7 +119,6 @@ ParseDhcp4Ack (
// Get DNS server addresses // Get DNS server addresses
// //
if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) { if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) {
if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) { if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
break; break;
@ -131,7 +130,7 @@ ParseDhcp4Ack (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
for (Count=0; Count < ServerCount; Count++) { for (Count = 0; Count < ServerCount; Count++) {
CopyMem (ServerList + Count, &OptionList[Index]->Data[4 * Count], sizeof (EFI_IPv4_ADDRESS)); CopyMem (ServerList + Count, &OptionList[Index]->Data[4 * Count], sizeof (EFI_IPv4_ADDRESS));
} }
@ -201,7 +200,7 @@ ParseDhcp6Ack (
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
DnsServerInfor = (DNS6_SERVER_INFOR *) Context; DnsServerInfor = (DNS6_SERVER_INFOR *)Context;
for (Index = 0; Index < OptionCount; Index++) { for (Index = 0; Index < OptionCount; Index++) {
OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode); OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode);
@ -211,7 +210,6 @@ ParseDhcp6Ack (
// Get DNS server addresses from this reply packet. // Get DNS server addresses from this reply packet.
// //
if (OptionList[Index]->OpCode == DHCP6_TAG_DNS_SERVER) { if (OptionList[Index]->OpCode == DHCP6_TAG_DNS_SERVER) {
if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) { if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
gBS->FreePool (OptionList); gBS->FreePool (OptionList);
@ -225,7 +223,7 @@ ParseDhcp6Ack (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
for (Count=0; Count < ServerCount; Count++) { for (Count = 0; Count < ServerCount; Count++) {
CopyMem (ServerList + Count, &OptionList[Index]->Data[16 * Count], sizeof (EFI_IPv6_ADDRESS)); CopyMem (ServerList + Count, &OptionList[Index]->Data[16 * Count], sizeof (EFI_IPv6_ADDRESS));
} }
@ -237,7 +235,6 @@ ParseDhcp6Ack (
gBS->FreePool (OptionList); gBS->FreePool (OptionList);
return Status; return Status;
} }
/** /**
@ -295,7 +292,7 @@ GetDns4ServerFromDhcp4 (
Data = NULL; Data = NULL;
InterfaceInfo = NULL; InterfaceInfo = NULL;
ZeroMem ((UINT8 *) ParaList, sizeof (ParaList)); ZeroMem ((UINT8 *)ParaList, sizeof (ParaList));
ZeroMem (&MnpConfigData, sizeof (EFI_MANAGED_NETWORK_CONFIG_DATA)); ZeroMem (&MnpConfigData, sizeof (EFI_MANAGED_NETWORK_CONFIG_DATA));
@ -332,7 +329,7 @@ GetDns4ServerFromDhcp4 (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
MnpChildHandle, MnpChildHandle,
&gEfiManagedNetworkProtocolGuid, &gEfiManagedNetworkProtocolGuid,
(VOID **) &Mnp, (VOID **)&Mnp,
Image, Image,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -352,7 +349,7 @@ GetDns4ServerFromDhcp4 (
MnpConfigData.EnableReceiveTimestamps = FALSE; MnpConfigData.EnableReceiveTimestamps = FALSE;
MnpConfigData.DisableBackgroundPolling = FALSE; MnpConfigData.DisableBackgroundPolling = FALSE;
Status = Mnp->Configure(Mnp, &MnpConfigData); Status = Mnp->Configure (Mnp, &MnpConfigData);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -373,7 +370,7 @@ GetDns4ServerFromDhcp4 (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dhcp4Handle, Dhcp4Handle,
&gEfiDhcp4ProtocolGuid, &gEfiDhcp4ProtocolGuid,
(VOID **) &Dhcp4, (VOID **)&Dhcp4,
Image, Image,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -385,13 +382,13 @@ GetDns4ServerFromDhcp4 (
// //
// Get Ip4Config2 instance info. // Get Ip4Config2 instance info.
// //
Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeInterfaceInfo, &DataSize, Data); Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeInterfaceInfo, &DataSize, Data);
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -470,7 +467,7 @@ GetDns4ServerFromDhcp4 (
Status = Dhcp4->Build (Dhcp4, &SeedPacket, 0, NULL, 2, ParaList, &Token.Packet); Status = Dhcp4->Build (Dhcp4, &SeedPacket, 0, NULL, 2, ParaList, &Token.Packet);
Token.Packet->Dhcp4.Header.Xid = HTONL(NET_RANDOM (NetRandomInitSeed ())); Token.Packet->Dhcp4.Header.Xid = HTONL (NET_RANDOM (NetRandomInitSeed ()));
Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16)0x8000); Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16)0x8000);
@ -651,7 +648,7 @@ GetDns6ServerFromDhcp6 (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dhcp6Handle, Dhcp6Handle,
&gEfiDhcp6ProtocolGuid, &gEfiDhcp6ProtocolGuid,
(VOID **) &Dhcp6, (VOID **)&Dhcp6,
Image, Image,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -753,6 +750,4 @@ ON_EXIT:
); );
return Status; return Status;
} }

View File

@ -27,7 +27,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define DHCP4_TAG_PARA_LIST 55 #define DHCP4_TAG_PARA_LIST 55
#define DHCP4_TAG_DNS_SERVER 6 #define DHCP4_TAG_DNS_SERVER 6
#define DHCP6_TAG_DNS_REQUEST 6 #define DHCP6_TAG_DNS_REQUEST 6
#define DHCP6_TAG_DNS_SERVER 23 #define DHCP6_TAG_DNS_SERVER 23

View File

@ -61,7 +61,7 @@ DnsDestroyInstance (
Dns6InstanceCancelToken (Instance, NULL); Dns6InstanceCancelToken (Instance, NULL);
} }
if (Instance->UdpIo!= NULL) { if (Instance->UdpIo != NULL) {
UdpIoFreeIo (Instance->UdpIo); UdpIoFreeIo (Instance->UdpIo);
} }
@ -146,14 +146,14 @@ DnsDestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren; UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer; EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) { if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Instance = NET_LIST_USER_STRUCT_S (Entry, DNS_INSTANCE, Link, DNS_INSTANCE_SIGNATURE); Instance = NET_LIST_USER_STRUCT_S (Entry, DNS_INSTANCE, Link, DNS_INSTANCE_SIGNATURE);
ServiceBinding = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; ServiceBinding = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
NumberOfChildren = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; NumberOfChildren = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
ChildHandleBuffer = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; ChildHandleBuffer = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) { if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -299,6 +299,7 @@ DnsCreateService (
if (DnsSb->TimerToGetMap != NULL) { if (DnsSb->TimerToGetMap != NULL) {
gBS->CloseEvent (DnsSb->TimerToGetMap); gBS->CloseEvent (DnsSb->TimerToGetMap);
} }
FreePool (DnsSb); FreePool (DnsSb);
return Status; return Status;
} }
@ -315,6 +316,7 @@ DnsCreateService (
if (DnsSb->TimerToGetMap != NULL) { if (DnsSb->TimerToGetMap != NULL) {
gBS->CloseEvent (DnsSb->TimerToGetMap); gBS->CloseEvent (DnsSb->TimerToGetMap);
} }
gBS->CloseEvent (DnsSb->Timer); gBS->CloseEvent (DnsSb->Timer);
FreePool (DnsSb); FreePool (DnsSb);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
@ -355,7 +357,7 @@ DnsUnload (
// //
// Disconnect the driver specified by ImageHandle // Disconnect the driver specified by ImageHandle
// //
Status = NetLibDefaultUnload(ImageHandle); Status = NetLibDefaultUnload (ImageHandle);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -493,20 +495,20 @@ DnsDriverEntryPoint (
return Status; return Status;
Error4: Error4:
gBS->CloseEvent (mDriverData->Timer); gBS->CloseEvent (mDriverData->Timer);
Error3: Error3:
FreePool (mDriverData); FreePool (mDriverData);
Error2: Error2:
EfiLibUninstallDriverBindingComponentName2 ( EfiLibUninstallDriverBindingComponentName2 (
&gDns6DriverBinding, &gDns6DriverBinding,
&gDnsComponentName, &gDnsComponentName,
&gDnsComponentName2 &gDnsComponentName2
); );
Error1: Error1:
EfiLibUninstallDriverBindingComponentName2 ( EfiLibUninstallDriverBindingComponentName2 (
&gDns4DriverBinding, &gDns4DriverBinding,
&gDnsComponentName, &gDnsComponentName,
@ -733,7 +735,7 @@ Dns4DriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiDns4ServiceBindingProtocolGuid, &gEfiDns4ServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
NicHandle, NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -760,7 +762,7 @@ Dns4DriverBindingStop (
); );
} }
if (NumberOfChildren == 0 && IsListEmpty (&DnsSb->Dns4ChildrenList)) { if ((NumberOfChildren == 0) && IsListEmpty (&DnsSb->Dns4ChildrenList)) {
gBS->UninstallProtocolInterface ( gBS->UninstallProtocolInterface (
NicHandle, NicHandle,
&gEfiDns4ServiceBindingProtocolGuid, &gEfiDns4ServiceBindingProtocolGuid,
@ -998,7 +1000,7 @@ Dns6DriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiDns6ServiceBindingProtocolGuid, &gEfiDns6ServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
NicHandle, NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -1025,7 +1027,7 @@ Dns6DriverBindingStop (
); );
} }
if (NumberOfChildren == 0 && IsListEmpty (&DnsSb->Dns6ChildrenList)) { if ((NumberOfChildren == 0) && IsListEmpty (&DnsSb->Dns6ChildrenList)) {
gBS->UninstallProtocolInterface ( gBS->UninstallProtocolInterface (
NicHandle, NicHandle,
&gEfiDns6ServiceBindingProtocolGuid, &gEfiDns6ServiceBindingProtocolGuid,
@ -1087,6 +1089,7 @@ Dns4ServiceBindingCreateChild (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
ASSERT (Instance != NULL); ASSERT (Instance != NULL);
// //
@ -1110,7 +1113,7 @@ Dns4ServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
DnsSb->ConnectUdp->UdpHandle, DnsSb->ConnectUdp->UdpHandle,
&gEfiUdp4ProtocolGuid, &gEfiUdp4ProtocolGuid,
(VOID **) &Udp4, (VOID **)&Udp4,
gDns4DriverBinding.DriverBindingHandle, gDns4DriverBinding.DriverBindingHandle,
Instance->ChildHandle, Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -1132,7 +1135,7 @@ Dns4ServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Instance->UdpIo->UdpHandle, Instance->UdpIo->UdpHandle,
&gEfiUdp4ProtocolGuid, &gEfiUdp4ProtocolGuid,
(VOID **) &Udp4, (VOID **)&Udp4,
gDns4DriverBinding.DriverBindingHandle, gDns4DriverBinding.DriverBindingHandle,
Instance->ChildHandle, Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -1218,7 +1221,7 @@ Dns4ServiceBindingDestroyChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiDns4ProtocolGuid, &gEfiDns4ProtocolGuid,
(VOID **) &Dns4, (VOID **)&Dns4,
gDns4DriverBinding.DriverBindingHandle, gDns4DriverBinding.DriverBindingHandle,
ChildHandle, ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -1330,6 +1333,7 @@ Dns6ServiceBindingCreateChild (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
ASSERT (Instance != NULL); ASSERT (Instance != NULL);
// //
@ -1353,7 +1357,7 @@ Dns6ServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
DnsSb->ConnectUdp->UdpHandle, DnsSb->ConnectUdp->UdpHandle,
&gEfiUdp6ProtocolGuid, &gEfiUdp6ProtocolGuid,
(VOID **) &Udp6, (VOID **)&Udp6,
gDns6DriverBinding.DriverBindingHandle, gDns6DriverBinding.DriverBindingHandle,
Instance->ChildHandle, Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -1375,7 +1379,7 @@ Dns6ServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Instance->UdpIo->UdpHandle, Instance->UdpIo->UdpHandle,
&gEfiUdp6ProtocolGuid, &gEfiUdp6ProtocolGuid,
(VOID **) &Udp6, (VOID **)&Udp6,
gDns6DriverBinding.DriverBindingHandle, gDns6DriverBinding.DriverBindingHandle,
Instance->ChildHandle, Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -1461,7 +1465,7 @@ Dns6ServiceBindingDestroyChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiDns6ProtocolGuid, &gEfiDns6ProtocolGuid,
(VOID **) &Dns6, (VOID **)&Dns6,
gDns6DriverBinding.DriverBindingHandle, gDns6DriverBinding.DriverBindingHandle,
ChildHandle, ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL

View File

@ -103,7 +103,6 @@ extern DNS_DRIVER_DATA *mDriverData;
#define DNS_INSTANCE_FROM_THIS_PROTOCOL6(a) \ #define DNS_INSTANCE_FROM_THIS_PROTOCOL6(a) \
CR (a, DNS_INSTANCE, Dns6, DNS_INSTANCE_SIGNATURE) CR (a, DNS_INSTANCE, Dns6, DNS_INSTANCE_SIGNATURE)
/** /**
Destroy the DNS instance and recycle the resources. Destroy the DNS instance and recycle the resources.
@ -594,5 +593,4 @@ Dns6ServiceBindingDestroyChild (
IN EFI_HANDLE ChildHandle IN EFI_HANDLE ChildHandle
); );
#endif #endif

View File

@ -29,7 +29,7 @@ Dns4RemoveTokenEntry (
// //
// Find the TokenEntry first. // Find the TokenEntry first.
// //
Item = NetMapFindKey (TokenMap, (VOID *) TokenEntry); Item = NetMapFindKey (TokenMap, (VOID *)TokenEntry);
if (Item != NULL) { if (Item != NULL) {
// //
@ -64,7 +64,7 @@ Dns6RemoveTokenEntry (
// //
// Find the TokenEntry first. // Find the TokenEntry first.
// //
Item = NetMapFindKey (TokenMap, (VOID *) TokenEntry); Item = NetMapFindKey (TokenMap, (VOID *)TokenEntry);
if (Item != NULL) { if (Item != NULL) {
// //
@ -115,8 +115,8 @@ Dns4CancelTokens (
// If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in // If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in
// Item->Value. // Item->Value.
// //
Packet = (NET_BUF *) (Item->Value); Packet = (NET_BUF *)(Item->Value);
UdpIo = (UDP_IO *) (*((UINTN *) &Packet->ProtoData[0])); UdpIo = (UDP_IO *)(*((UINTN *)&Packet->ProtoData[0]));
UdpIoCancelSentDatagram (UdpIo, Packet); UdpIoCancelSentDatagram (UdpIo, Packet);
} }
@ -124,7 +124,7 @@ Dns4CancelTokens (
// //
// Remove TokenEntry from Dns4TxTokens. // Remove TokenEntry from Dns4TxTokens.
// //
TokenEntry = (DNS4_TOKEN_ENTRY *) Item->Key; TokenEntry = (DNS4_TOKEN_ENTRY *)Item->Key;
if (Dns4RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) { if (Dns4RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) {
TokenEntry->Token->Status = EFI_ABORTED; TokenEntry->Token->Status = EFI_ABORTED;
gBS->SignalEvent (TokenEntry->Token->Event); gBS->SignalEvent (TokenEntry->Token->Event);
@ -175,8 +175,8 @@ Dns6CancelTokens (
// If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in // If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in
// Item->Value. // Item->Value.
// //
Packet = (NET_BUF *) (Item->Value); Packet = (NET_BUF *)(Item->Value);
UdpIo = (UDP_IO *) (*((UINTN *) &Packet->ProtoData[0])); UdpIo = (UDP_IO *)(*((UINTN *)&Packet->ProtoData[0]));
UdpIoCancelSentDatagram (UdpIo, Packet); UdpIoCancelSentDatagram (UdpIo, Packet);
} }
@ -184,7 +184,7 @@ Dns6CancelTokens (
// //
// Remove TokenEntry from Dns6TxTokens. // Remove TokenEntry from Dns6TxTokens.
// //
TokenEntry = (DNS6_TOKEN_ENTRY *) Item->Key; TokenEntry = (DNS6_TOKEN_ENTRY *)Item->Key;
if (Dns6RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) { if (Dns6RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) {
TokenEntry->Token->Status = EFI_ABORTED; TokenEntry->Token->Status = EFI_ABORTED;
gBS->SignalEvent (TokenEntry->Token->Event); gBS->SignalEvent (TokenEntry->Token->Event);
@ -223,7 +223,7 @@ GetDns4TokenEntry (
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) { NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
*TokenEntry = (DNS4_TOKEN_ENTRY *) (Item->Key); *TokenEntry = (DNS4_TOKEN_ENTRY *)(Item->Key);
if ((*TokenEntry)->Token == Token) { if ((*TokenEntry)->Token == Token) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -259,13 +259,13 @@ GetDns6TokenEntry (
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) { NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
*TokenEntry = (DNS6_TOKEN_ENTRY *) (Item->Key); *TokenEntry = (DNS6_TOKEN_ENTRY *)(Item->Key);
if ((*TokenEntry)->Token == Token) { if ((*TokenEntry)->Token == Token) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
*TokenEntry =NULL; *TokenEntry = NULL;
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -293,7 +293,7 @@ Dns4InstanceCancelToken (
TokenEntry = NULL; TokenEntry = NULL;
if(Token != NULL ) { if (Token != NULL ) {
Status = GetDns4TokenEntry (&Instance->Dns4TxTokens, Token, &TokenEntry); Status = GetDns4TokenEntry (&Instance->Dns4TxTokens, Token, &TokenEntry);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -315,6 +315,7 @@ Dns4InstanceCancelToken (
if (NetMapIsEmpty (&Instance->Dns4TxTokens)) { if (NetMapIsEmpty (&Instance->Dns4TxTokens)) {
Instance->UdpIo->Protocol.Udp4->Cancel (Instance->UdpIo->Protocol.Udp4, &Instance->UdpIo->RecvRequest->Token.Udp4); Instance->UdpIo->Protocol.Udp4->Cancel (Instance->UdpIo->Protocol.Udp4, &Instance->UdpIo->RecvRequest->Token.Udp4);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -350,7 +351,7 @@ Dns6InstanceCancelToken (
TokenEntry = NULL; TokenEntry = NULL;
if(Token != NULL ) { if (Token != NULL ) {
Status = GetDns6TokenEntry (&Instance->Dns6TxTokens, Token, &TokenEntry); Status = GetDns6TokenEntry (&Instance->Dns6TxTokens, Token, &TokenEntry);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -372,6 +373,7 @@ Dns6InstanceCancelToken (
if (NetMapIsEmpty (&Instance->Dns6TxTokens)) { if (NetMapIsEmpty (&Instance->Dns6TxTokens)) {
Instance->UdpIo->Protocol.Udp6->Cancel (Instance->UdpIo->Protocol.Udp6, &Instance->UdpIo->RecvRequest->Token.Udp6); Instance->UdpIo->Protocol.Udp6->Cancel (Instance->UdpIo->Protocol.Udp6, &Instance->UdpIo->RecvRequest->Token.Udp6);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -563,10 +565,10 @@ Dns4GetMapping (
Udp->Poll (Udp); Udp->Poll (Udp);
if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) && if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) &&
Ip4Mode.IsConfigured) { Ip4Mode.IsConfigured)
{
Udp->Configure (Udp, NULL); Udp->Configure (Udp, NULL);
return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS); return (BOOLEAN)(Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
} }
} }
@ -776,8 +778,9 @@ UpdateDns4Cache (
// //
NET_LIST_FOR_EACH_SAFE (Entry, Next, Dns4CacheList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, Dns4CacheList) {
Item = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink); Item = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);
if (StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0 && \ if ((StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0) && \
CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS)) == 0) { (CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS)) == 0))
{
// //
// This is the Dns cache entry // This is the Dns cache entry
// //
@ -874,8 +877,9 @@ UpdateDns6Cache (
// //
NET_LIST_FOR_EACH_SAFE (Entry, Next, Dns6CacheList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, Dns6CacheList) {
Item = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink); Item = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);
if (StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0 && \ if ((StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0) && \
CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS)) == 0) { (CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS)) == 0))
{
// //
// This is the Dns cache entry // This is the Dns cache entry
// //
@ -1079,20 +1083,20 @@ IsValidDnsResponse (
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) { NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
*Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); *Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
Packet = (NET_BUF *) ((*Item)->Value); Packet = (NET_BUF *)((*Item)->Value);
if (Packet == NULL) { if (Packet == NULL) {
continue; continue;
} else { } else {
TxString = NetbufGetByte (Packet, 0, NULL); TxString = NetbufGetByte (Packet, 0, NULL);
ASSERT (TxString != NULL); ASSERT (TxString != NULL);
DnsHeader = (DNS_HEADER *) TxString; DnsHeader = (DNS_HEADER *)TxString;
QueryName = (CHAR8 *) (TxString + sizeof (*DnsHeader)); QueryName = (CHAR8 *)(TxString + sizeof (*DnsHeader));
QuerySection = (DNS_QUERY_SECTION *) (QueryName + AsciiStrLen (QueryName) + 1); QuerySection = (DNS_QUERY_SECTION *)(QueryName + AsciiStrLen (QueryName) + 1);
if (NTOHS (DnsHeader->Identification) == Identification && if ((NTOHS (DnsHeader->Identification) == Identification) &&
NTOHS (QuerySection->Type) == Type && (NTOHS (QuerySection->Type) == Type) &&
NTOHS (QuerySection->Class) == Class) { (NTOHS (QuerySection->Class) == Class))
{
return TRUE; return TRUE;
} }
} }
@ -1191,7 +1195,7 @@ ParseDnsResponse (
// //
// Get header // Get header
// //
DnsHeader = (DNS_HEADER *) RxString; DnsHeader = (DNS_HEADER *)RxString;
DnsHeader->Identification = NTOHS (DnsHeader->Identification); DnsHeader->Identification = NTOHS (DnsHeader->Identification);
DnsHeader->Flags.Uint16 = NTOHS (DnsHeader->Flags.Uint16); DnsHeader->Flags.Uint16 = NTOHS (DnsHeader->Flags.Uint16);
@ -1212,9 +1216,9 @@ ParseDnsResponse (
// //
// Get Query name // Get Query name
// //
QueryName = (CHAR8 *) (RxString + sizeof (*DnsHeader)); QueryName = (CHAR8 *)(RxString + sizeof (*DnsHeader));
QueryNameLen = (UINT32) AsciiStrLen (QueryName) + 1; QueryNameLen = (UINT32)AsciiStrLen (QueryName) + 1;
// //
// Check whether the remaining packet length is available or not. // Check whether the remaining packet length is available or not.
@ -1229,7 +1233,7 @@ ParseDnsResponse (
// //
// Get query section // Get query section
// //
QuerySection = (DNS_QUERY_SECTION *) (QueryName + QueryNameLen); QuerySection = (DNS_QUERY_SECTION *)(QueryName + QueryNameLen);
QuerySection->Type = NTOHS (QuerySection->Type); QuerySection->Type = NTOHS (QuerySection->Type);
QuerySection->Class = NTOHS (QuerySection->Class); QuerySection->Class = NTOHS (QuerySection->Class);
@ -1245,13 +1249,15 @@ ParseDnsResponse (
QuerySection->Type, QuerySection->Type,
QuerySection->Class, QuerySection->Class,
&Item &Item
)) { ))
{
*Completed = FALSE; *Completed = FALSE;
Status = EFI_ABORTED; Status = EFI_ABORTED;
goto ON_EXIT; goto ON_EXIT;
} }
ASSERT (Item != NULL); ASSERT (Item != NULL);
Dns4TokenEntry = (DNS4_TOKEN_ENTRY *) (Item->Key); Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(Item->Key);
} else { } else {
if (!IsValidDnsResponse ( if (!IsValidDnsResponse (
&Instance->Dns6TxTokens, &Instance->Dns6TxTokens,
@ -1259,20 +1265,23 @@ ParseDnsResponse (
QuerySection->Type, QuerySection->Type,
QuerySection->Class, QuerySection->Class,
&Item &Item
)) { ))
{
*Completed = FALSE; *Completed = FALSE;
Status = EFI_ABORTED; Status = EFI_ABORTED;
goto ON_EXIT; goto ON_EXIT;
} }
ASSERT (Item != NULL); ASSERT (Item != NULL);
Dns6TokenEntry = (DNS6_TOKEN_ENTRY *) (Item->Key); Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(Item->Key);
} }
// //
// Continue Check Some Errors. // Continue Check Some Errors.
// //
if (DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR || DnsHeader->AnswersNum < 1 || \ if ((DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR) || (DnsHeader->AnswersNum < 1) || \
DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE) { (DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE))
{
// //
// The domain name referenced in the query does not exist. // The domain name referenced in the query does not exist.
// //
@ -1300,6 +1309,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
Dns4TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD)); Dns4TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD));
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList == NULL) { if (Dns4TokenEntry->Token->RspData.GLookupData->RRList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -1315,6 +1325,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
Dns4TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv4_ADDRESS)); Dns4TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv4_ADDRESS));
if (Dns4TokenEntry->Token->RspData.H2AData->IpList == NULL) { if (Dns4TokenEntry->Token->RspData.H2AData->IpList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -1337,6 +1348,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
Dns6TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD)); Dns6TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD));
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList == NULL) { if (Dns6TokenEntry->Token->RspData.GLookupData->RRList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -1352,6 +1364,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
Dns6TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv6_ADDRESS)); Dns6TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv6_ADDRESS));
if (Dns6TokenEntry->Token->RspData.H2AData->IpList == NULL) { if (Dns6TokenEntry->Token->RspData.H2AData->IpList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -1369,7 +1382,7 @@ ParseDnsResponse (
// //
// Get Answer name // Get Answer name
// //
AnswerName = (CHAR8 *) QuerySection + sizeof (*QuerySection); AnswerName = (CHAR8 *)QuerySection + sizeof (*QuerySection);
// //
// Processing AnswerSection. // Processing AnswerSection.
@ -1389,7 +1402,7 @@ ParseDnsResponse (
// //
// Answer name should be PTR, else EFI_UNSUPPORTED returned. // Answer name should be PTR, else EFI_UNSUPPORTED returned.
// //
if ((*(UINT8 *) AnswerName & 0xC0) != 0xC0) { if ((*(UINT8 *)AnswerName & 0xC0) != 0xC0) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto ON_EXIT; goto ON_EXIT;
} }
@ -1397,7 +1410,7 @@ ParseDnsResponse (
// //
// Get Answer section. // Get Answer section.
// //
AnswerSection = (DNS_ANSWER_SECTION *) (AnswerName + sizeof (UINT16)); AnswerSection = (DNS_ANSWER_SECTION *)(AnswerName + sizeof (UINT16));
AnswerSection->Type = NTOHS (AnswerSection->Type); AnswerSection->Type = NTOHS (AnswerSection->Type);
AnswerSection->Class = NTOHS (AnswerSection->Class); AnswerSection->Class = NTOHS (AnswerSection->Class);
AnswerSection->Ttl = NTOHL (AnswerSection->Ttl); AnswerSection->Ttl = NTOHL (AnswerSection->Ttl);
@ -1417,9 +1430,9 @@ ParseDnsResponse (
// //
// Check whether it's the GeneralLookUp querying. // Check whether it's the GeneralLookUp querying.
// //
if (Instance->Service->IpVersion == IP_VERSION_4 && Dns4TokenEntry->GeneralLookUp) { if ((Instance->Service->IpVersion == IP_VERSION_4) && Dns4TokenEntry->GeneralLookUp) {
Dns4RR = Dns4TokenEntry->Token->RspData.GLookupData->RRList; Dns4RR = Dns4TokenEntry->Token->RspData.GLookupData->RRList;
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
// //
// Fill the ResourceRecord. // Fill the ResourceRecord.
@ -1429,6 +1442,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Dns4RR[RRCount].QName, QueryName, AsciiStrLen (QueryName)); CopyMem (Dns4RR[RRCount].QName, QueryName, AsciiStrLen (QueryName));
Dns4RR[RRCount].QType = AnswerSection->Type; Dns4RR[RRCount].QType = AnswerSection->Type;
Dns4RR[RRCount].QClass = AnswerSection->Class; Dns4RR[RRCount].QClass = AnswerSection->Class;
@ -1439,13 +1453,14 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Dns4RR[RRCount].RData, AnswerData, Dns4RR[RRCount].DataLength); CopyMem (Dns4RR[RRCount].RData, AnswerData, Dns4RR[RRCount].DataLength);
RRCount ++; RRCount++;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} else if (Instance->Service->IpVersion == IP_VERSION_6 && Dns6TokenEntry->GeneralLookUp) { } else if ((Instance->Service->IpVersion == IP_VERSION_6) && Dns6TokenEntry->GeneralLookUp) {
Dns6RR = Dns6TokenEntry->Token->RspData.GLookupData->RRList; Dns6RR = Dns6TokenEntry->Token->RspData.GLookupData->RRList;
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
// //
// Fill the ResourceRecord. // Fill the ResourceRecord.
@ -1455,6 +1470,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Dns6RR[RRCount].QName, QueryName, AsciiStrLen (QueryName)); CopyMem (Dns6RR[RRCount].QName, QueryName, AsciiStrLen (QueryName));
Dns6RR[RRCount].QType = AnswerSection->Type; Dns6RR[RRCount].QType = AnswerSection->Type;
Dns6RR[RRCount].QClass = AnswerSection->Class; Dns6RR[RRCount].QClass = AnswerSection->Class;
@ -1465,9 +1481,10 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Dns6RR[RRCount].RData, AnswerData, Dns6RR[RRCount].DataLength); CopyMem (Dns6RR[RRCount].RData, AnswerData, Dns6RR[RRCount].DataLength);
RRCount ++; RRCount++;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} else { } else {
// //
@ -1487,7 +1504,7 @@ ParseDnsResponse (
} }
HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList; HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList;
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS)); CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS));
// //
@ -1498,20 +1515,23 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
Dns4CacheEntry->HostName = AllocateZeroPool (2 * (StrLen(Dns4TokenEntry->QueryHostName) + 1));
Dns4CacheEntry->HostName = AllocateZeroPool (2 * (StrLen (Dns4TokenEntry->QueryHostName) + 1));
if (Dns4CacheEntry->HostName == NULL) { if (Dns4CacheEntry->HostName == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Dns4CacheEntry->HostName, Dns4TokenEntry->QueryHostName, 2 * (StrLen(Dns4TokenEntry->QueryHostName) + 1));
CopyMem (Dns4CacheEntry->HostName, Dns4TokenEntry->QueryHostName, 2 * (StrLen (Dns4TokenEntry->QueryHostName) + 1));
Dns4CacheEntry->IpAddress = AllocateZeroPool (sizeof (EFI_IPv4_ADDRESS)); Dns4CacheEntry->IpAddress = AllocateZeroPool (sizeof (EFI_IPv4_ADDRESS));
if (Dns4CacheEntry->IpAddress == NULL) { if (Dns4CacheEntry->IpAddress == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Dns4CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv4_ADDRESS)); CopyMem (Dns4CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv4_ADDRESS));
if (CNameTtl != 0 && AnswerSection->Ttl != 0) { if ((CNameTtl != 0) && (AnswerSection->Ttl != 0)) {
Dns4CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl); Dns4CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl);
} else { } else {
Dns4CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl); Dns4CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);
@ -1531,7 +1551,7 @@ ParseDnsResponse (
FreePool (Dns4CacheEntry); FreePool (Dns4CacheEntry);
Dns4CacheEntry = NULL; Dns4CacheEntry = NULL;
IpCount ++; IpCount++;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
break; break;
case DNS_TYPE_AAAA: case DNS_TYPE_AAAA:
@ -1546,7 +1566,7 @@ ParseDnsResponse (
} }
HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList; HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList;
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS));
// //
@ -1557,20 +1577,23 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
Dns6CacheEntry->HostName = AllocateZeroPool (2 * (StrLen(Dns6TokenEntry->QueryHostName) + 1));
Dns6CacheEntry->HostName = AllocateZeroPool (2 * (StrLen (Dns6TokenEntry->QueryHostName) + 1));
if (Dns6CacheEntry->HostName == NULL) { if (Dns6CacheEntry->HostName == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Dns6CacheEntry->HostName, Dns6TokenEntry->QueryHostName, 2 * (StrLen(Dns6TokenEntry->QueryHostName) + 1));
CopyMem (Dns6CacheEntry->HostName, Dns6TokenEntry->QueryHostName, 2 * (StrLen (Dns6TokenEntry->QueryHostName) + 1));
Dns6CacheEntry->IpAddress = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS)); Dns6CacheEntry->IpAddress = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS));
if (Dns6CacheEntry->IpAddress == NULL) { if (Dns6CacheEntry->IpAddress == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Dns6CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv6_ADDRESS)); CopyMem (Dns6CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv6_ADDRESS));
if (CNameTtl != 0 && AnswerSection->Ttl != 0) { if ((CNameTtl != 0) && (AnswerSection->Ttl != 0)) {
Dns6CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl); Dns6CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl);
} else { } else {
Dns6CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl); Dns6CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);
@ -1590,7 +1613,7 @@ ParseDnsResponse (
FreePool (Dns6CacheEntry); FreePool (Dns6CacheEntry);
Dns6CacheEntry = NULL; Dns6CacheEntry = NULL;
IpCount ++; IpCount++;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
break; break;
case DNS_TYPE_CNAME: case DNS_TYPE_CNAME:
@ -1610,8 +1633,8 @@ ParseDnsResponse (
// //
// Find next one // Find next one
// //
AnswerName = (CHAR8 *) AnswerSection + sizeof (*AnswerSection) + AnswerSection->DataLength; AnswerName = (CHAR8 *)AnswerSection + sizeof (*AnswerSection) + AnswerSection->DataLength;
AnswerSectionNum ++; AnswerSectionNum++;
} }
if (Instance->Service->IpVersion == IP_VERSION_4) { if (Instance->Service->IpVersion == IP_VERSION_4) {
@ -1646,8 +1669,8 @@ ON_COMPLETE:
// //
// Parsing is complete, free the sending packet and signal Event here. // Parsing is complete, free the sending packet and signal Event here.
// //
if (Item != NULL && Item->Value != NULL) { if ((Item != NULL) && (Item->Value != NULL)) {
NetbufFree ((NET_BUF *) (Item->Value)); NetbufFree ((NET_BUF *)(Item->Value));
} }
if (Instance->Service->IpVersion == IP_VERSION_4) { if (Instance->Service->IpVersion == IP_VERSION_4) {
@ -1678,7 +1701,7 @@ ON_EXIT:
if (Dns4TokenEntry->Token->RspData.GLookupData != NULL) { if (Dns4TokenEntry->Token->RspData.GLookupData != NULL) {
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList != NULL) { if (Dns4TokenEntry->Token->RspData.GLookupData->RRList != NULL) {
while (RRCount != 0) { while (RRCount != 0) {
RRCount --; RRCount--;
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) { if (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) {
FreePool (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName); FreePool (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName);
} }
@ -1694,7 +1717,7 @@ ON_EXIT:
FreePool (Dns4TokenEntry->Token->RspData.GLookupData); FreePool (Dns4TokenEntry->Token->RspData.GLookupData);
} }
} else { } else {
if (QuerySection->Type == DNS_TYPE_A && Dns4TokenEntry->Token->RspData.H2AData != NULL) { if ((QuerySection->Type == DNS_TYPE_A) && (Dns4TokenEntry->Token->RspData.H2AData != NULL)) {
if (Dns4TokenEntry->Token->RspData.H2AData->IpList != NULL) { if (Dns4TokenEntry->Token->RspData.H2AData->IpList != NULL) {
FreePool (Dns4TokenEntry->Token->RspData.H2AData->IpList); FreePool (Dns4TokenEntry->Token->RspData.H2AData->IpList);
} }
@ -1710,7 +1733,7 @@ ON_EXIT:
if (Dns6TokenEntry->Token->RspData.GLookupData != NULL) { if (Dns6TokenEntry->Token->RspData.GLookupData != NULL) {
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList != NULL) { if (Dns6TokenEntry->Token->RspData.GLookupData->RRList != NULL) {
while (RRCount != 0) { while (RRCount != 0) {
RRCount --; RRCount--;
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) { if (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) {
FreePool (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName); FreePool (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName);
} }
@ -1726,7 +1749,7 @@ ON_EXIT:
FreePool (Dns6TokenEntry->Token->RspData.GLookupData); FreePool (Dns6TokenEntry->Token->RspData.GLookupData);
} }
} else { } else {
if (QuerySection->Type == DNS_TYPE_AAAA && Dns6TokenEntry->Token->RspData.H2AData != NULL) { if ((QuerySection->Type == DNS_TYPE_AAAA) && (Dns6TokenEntry->Token->RspData.H2AData != NULL)) {
if (Dns6TokenEntry->Token->RspData.H2AData->IpList != NULL) { if (Dns6TokenEntry->Token->RspData.H2AData->IpList != NULL) {
FreePool (Dns6TokenEntry->Token->RspData.H2AData->IpList); FreePool (Dns6TokenEntry->Token->RspData.H2AData->IpList);
} }
@ -1791,7 +1814,7 @@ DnsOnPacketReceived (
BOOLEAN Completed; BOOLEAN Completed;
Instance = (DNS_INSTANCE *) Context; Instance = (DNS_INSTANCE *)Context;
NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE); NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE);
RcvString = NULL; RcvString = NULL;
@ -1851,7 +1874,7 @@ DnsOnPacketSent (
Dns4TokenEntry = NULL; Dns4TokenEntry = NULL;
Dns6TokenEntry = NULL; Dns6TokenEntry = NULL;
Instance = (DNS_INSTANCE *) Context; Instance = (DNS_INSTANCE *)Context;
NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE); NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE);
if (Instance->Service->IpVersion == IP_VERSION_4) { if (Instance->Service->IpVersion == IP_VERSION_4) {
@ -1953,8 +1976,8 @@ ConstructDNSQuery (
// //
// Fill header // Fill header
// //
DnsHeader = (DNS_HEADER *) Frag.Bulk; DnsHeader = (DNS_HEADER *)Frag.Bulk;
DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed()); DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed ());
DnsHeader->Flags.Uint16 = 0x0000; DnsHeader->Flags.Uint16 = 0x0000;
DnsHeader->Flags.Bits.RD = 1; DnsHeader->Flags.Bits.RD = 1;
DnsHeader->Flags.Bits.OpCode = DNS_FLAGS_OPCODE_STANDARD; DnsHeader->Flags.Bits.OpCode = DNS_FLAGS_OPCODE_STANDARD;
@ -1977,14 +2000,14 @@ ConstructDNSQuery (
// Fill Query name // Fill Query name
// //
CopyMem (Frag.Bulk + Frag.Len, QueryName, AsciiStrLen (QueryName)); CopyMem (Frag.Bulk + Frag.Len, QueryName, AsciiStrLen (QueryName));
Frag.Len = (UINT32) (Frag.Len + AsciiStrLen (QueryName)); Frag.Len = (UINT32)(Frag.Len + AsciiStrLen (QueryName));
*(Frag.Bulk + Frag.Len) = 0; *(Frag.Bulk + Frag.Len) = 0;
Frag.Len ++; Frag.Len++;
// //
// Rest query section // Rest query section
// //
DnsQuery = (DNS_QUERY_SECTION *) (Frag.Bulk + Frag.Len); DnsQuery = (DNS_QUERY_SECTION *)(Frag.Bulk + Frag.Len);
DnsQuery->Type = HTONS (Type); DnsQuery->Type = HTONS (Type);
DnsQuery->Class = HTONS (Class); DnsQuery->Class = HTONS (Class);
@ -2003,7 +2026,7 @@ ConstructDNSQuery (
// //
// Store the UdpIo in ProtoData. // Store the UdpIo in ProtoData.
// //
*((UINTN *) &((*Packet)->ProtoData[0])) = (UINTN) (Instance->UdpIo); *((UINTN *)&((*Packet)->ProtoData[0])) = (UINTN)(Instance->UdpIo);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -2082,8 +2105,7 @@ DnsOnTimerRetransmit (
Dns4TokenEntry = NULL; Dns4TokenEntry = NULL;
Dns6TokenEntry = NULL; Dns6TokenEntry = NULL;
Service = (DNS_SERVICE *) Context; Service = (DNS_SERVICE *)Context;
if (Service->IpVersion == IP_VERSION_4) { if (Service->IpVersion == IP_VERSION_4) {
// //
@ -2097,7 +2119,7 @@ DnsOnTimerRetransmit (
while (EntryNetMap != &Instance->Dns4TxTokens.Used) { while (EntryNetMap != &Instance->Dns4TxTokens.Used) {
ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link); ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link);
Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(ItemNetMap->Key); Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(ItemNetMap->Key);
if (Dns4TokenEntry->PacketToLive == 0 || (--Dns4TokenEntry->PacketToLive > 0)) { if ((Dns4TokenEntry->PacketToLive == 0) || (--Dns4TokenEntry->PacketToLive > 0)) {
EntryNetMap = EntryNetMap->ForwardLink; EntryNetMap = EntryNetMap->ForwardLink;
continue; continue;
} }
@ -2140,8 +2162,8 @@ DnsOnTimerRetransmit (
EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink; EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink;
while (EntryNetMap != &Instance->Dns6TxTokens.Used) { while (EntryNetMap != &Instance->Dns6TxTokens.Used) {
ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link); ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link);
Dns6TokenEntry = (DNS6_TOKEN_ENTRY *) (ItemNetMap->Key); Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(ItemNetMap->Key);
if (Dns6TokenEntry->PacketToLive == 0 || (--Dns6TokenEntry->PacketToLive > 0)) { if ((Dns6TokenEntry->PacketToLive == 0) || (--Dns6TokenEntry->PacketToLive > 0)) {
EntryNetMap = EntryNetMap->ForwardLink; EntryNetMap = EntryNetMap->ForwardLink;
continue; continue;
} }
@ -2151,7 +2173,7 @@ DnsOnTimerRetransmit (
// otherwise exit the transfer. // otherwise exit the transfer.
// //
if (++Dns6TokenEntry->RetryCounting <= Dns6TokenEntry->Token->RetryCount) { if (++Dns6TokenEntry->RetryCounting <= Dns6TokenEntry->Token->RetryCount) {
DnsRetransmit (Instance, (NET_BUF *) ItemNetMap->Value); DnsRetransmit (Instance, (NET_BUF *)ItemNetMap->Value);
EntryNetMap = EntryNetMap->ForwardLink; EntryNetMap = EntryNetMap->ForwardLink;
} else { } else {
// //
@ -2166,7 +2188,7 @@ DnsOnTimerRetransmit (
// Free the sending packet. // Free the sending packet.
// //
if (ItemNetMap->Value != NULL) { if (ItemNetMap->Value != NULL) {
NetbufFree ((NET_BUF *) (ItemNetMap->Value)); NetbufFree ((NET_BUF *)(ItemNetMap->Value));
} }
EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink; EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink;
@ -2242,4 +2264,3 @@ DnsOnTimerUpdate (
} }
} }
} }

View File

@ -127,14 +127,14 @@ typedef struct {
union _DNS_FLAGS { union _DNS_FLAGS {
struct { struct {
UINT16 RCode:4; UINT16 RCode : 4;
UINT16 Zero:3; UINT16 Zero : 3;
UINT16 RA:1; UINT16 RA : 1;
UINT16 RD:1; UINT16 RD : 1;
UINT16 TC:1; UINT16 TC : 1;
UINT16 AA:1; UINT16 AA : 1;
UINT16 OpCode:4; UINT16 OpCode : 4;
UINT16 QR:1; UINT16 QR : 1;
} Bits; } Bits;
UINT16 Uint16; UINT16 Uint16;
}; };
@ -173,7 +173,6 @@ typedef struct {
#define DNS4_DOMAIN L"in-addr.arpa" #define DNS4_DOMAIN L"in-addr.arpa"
#define DNS6_DOMAIN L"IP6.ARPA" #define DNS6_DOMAIN L"IP6.ARPA"
#pragma pack() #pragma pack()
/** /**
@ -710,7 +709,6 @@ DnsOnTimerUpdate (
IN VOID *Context IN VOID *Context
); );
/** /**
Retrieve mode data of this DNS instance. Retrieve mode data of this DNS instance.
@ -954,7 +952,6 @@ Dns4Cancel (
IN EFI_DNS4_COMPLETION_TOKEN *Token IN EFI_DNS4_COMPLETION_TOKEN *Token
); );
/** /**
Retrieve mode data of this DNS instance. Retrieve mode data of this DNS instance.

View File

@ -73,7 +73,6 @@ Dns4GetModeData (
CacheList = NULL; CacheList = NULL;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
if ((This == NULL) || (DnsModeData == NULL)) { if ((This == NULL) || (DnsModeData == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -103,7 +102,7 @@ Dns4GetModeData (
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4ServerList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4ServerList) {
Index++; Index++;
} }
DnsModeData->DnsServerCount = (UINT32) Index; DnsModeData->DnsServerCount = (UINT32)Index;
ServerList = AllocatePool (sizeof (EFI_IPv4_ADDRESS) * DnsModeData->DnsServerCount); ServerList = AllocatePool (sizeof (EFI_IPv4_ADDRESS) * DnsModeData->DnsServerCount);
if (ServerList == NULL) { if (ServerList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -122,11 +121,11 @@ Dns4GetModeData (
// //
// Get the DnsCacheCount and DnsCacheList // Get the DnsCacheCount and DnsCacheList
// //
Index =0; Index = 0;
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {
Index++; Index++;
} }
DnsModeData->DnsCacheCount = (UINT32) Index; DnsModeData->DnsCacheCount = (UINT32)Index;
CacheList = AllocatePool (sizeof (EFI_DNS4_CACHE_ENTRY) * DnsModeData->DnsCacheCount); CacheList = AllocatePool (sizeof (EFI_DNS4_CACHE_ENTRY) * DnsModeData->DnsCacheCount);
if (CacheList == NULL) { if (CacheList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -135,7 +134,7 @@ Dns4GetModeData (
goto ON_EXIT; goto ON_EXIT;
} }
Index =0; Index = 0;
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {
CacheItem = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink); CacheItem = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);
CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof (EFI_DNS4_CACHE_ENTRY)); CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof (EFI_DNS4_CACHE_ENTRY));
@ -193,13 +192,14 @@ Dns4Configure (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
ServerList = NULL; ServerList = NULL;
if (This == NULL || if ((This == NULL) ||
(DnsConfigData != NULL && ((DnsConfigData->DnsServerListCount != 0 && DnsConfigData->DnsServerList == NULL) || ((DnsConfigData != NULL) && (((DnsConfigData->DnsServerListCount != 0) && (DnsConfigData->DnsServerList == NULL)) ||
(DnsConfigData->DnsServerListCount == 0 && DnsConfigData->DnsServerList != NULL)))) { ((DnsConfigData->DnsServerListCount == 0) && (DnsConfigData->DnsServerList != NULL)))))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (DnsConfigData != NULL && DnsConfigData->Protocol != DNS_PROTOCOL_UDP) { if ((DnsConfigData != NULL) && (DnsConfigData->Protocol != DNS_PROTOCOL_UDP)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -213,8 +213,8 @@ Dns4Configure (
// //
// Reset the Instance if ConfigData is NULL // Reset the Instance if ConfigData is NULL
// //
if (!NetMapIsEmpty(&Instance->Dns4TxTokens)) { if (!NetMapIsEmpty (&Instance->Dns4TxTokens)) {
Dns4InstanceCancelToken(Instance, NULL); Dns4InstanceCancelToken (Instance, NULL);
} }
if (Instance->UdpIo != NULL) { if (Instance->UdpIo != NULL) {
@ -224,6 +224,7 @@ Dns4Configure (
if (Instance->Dns4CfgData.DnsServerList != NULL) { if (Instance->Dns4CfgData.DnsServerList != NULL) {
FreePool (Instance->Dns4CfgData.DnsServerList); FreePool (Instance->Dns4CfgData.DnsServerList);
} }
ZeroMem (&Instance->Dns4CfgData, sizeof (EFI_DNS4_CONFIG_DATA)); ZeroMem (&Instance->Dns4CfgData, sizeof (EFI_DNS4_CONFIG_DATA));
Instance->State = DNS_STATE_UNCONFIGED; Instance->State = DNS_STATE_UNCONFIGED;
@ -238,7 +239,8 @@ Dns4Configure (
Netmask = NTOHL (Netmask); Netmask = NTOHL (Netmask);
if (!DnsConfigData->UseDefaultSetting && if (!DnsConfigData->UseDefaultSetting &&
((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Ip, Netmask))))) { ((!IP4_IS_VALID_NETMASK (Netmask) || ((Netmask != 0) && !NetIp4IsUnicast (Ip, Netmask)))))
{
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
@ -263,7 +265,7 @@ Dns4Configure (
return Status; return Status;
} }
ASSERT(ServerList != NULL); ASSERT (ServerList != NULL);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK); OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@ -281,6 +283,7 @@ Dns4Configure (
FreePool (Instance->Dns4CfgData.DnsServerList); FreePool (Instance->Dns4CfgData.DnsServerList);
Instance->Dns4CfgData.DnsServerList = NULL; Instance->Dns4CfgData.DnsServerList = NULL;
} }
goto ON_EXIT; goto ON_EXIT;
} }
@ -293,6 +296,7 @@ Dns4Configure (
FreePool (Instance->Dns4CfgData.DnsServerList); FreePool (Instance->Dns4CfgData.DnsServerList);
Instance->Dns4CfgData.DnsServerList = NULL; Instance->Dns4CfgData.DnsServerList = NULL;
} }
goto ON_EXIT; goto ON_EXIT;
} }
@ -359,7 +363,7 @@ Dns4HostNameToIp (
// //
// Validate the parameters // Validate the parameters
// //
if ((This == NULL) || (HostName == NULL) || Token == NULL) { if ((This == NULL) || (HostName == NULL) || (Token == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -430,7 +434,7 @@ Dns4HostNameToIp (
Index = 0; Index = 0;
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {
Item = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink); Item = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);
if ((UINT32)Index < Token->RspData.H2AData->IpCount && StrCmp (HostName, Item->DnsCache.HostName) == 0) { if (((UINT32)Index < Token->RspData.H2AData->IpCount) && (StrCmp (HostName, Item->DnsCache.HostName) == 0)) {
CopyMem ((Token->RspData.H2AData->IpList) + Index, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS)); CopyMem ((Token->RspData.H2AData->IpList) + Index, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS));
Index++; Index++;
} }
@ -451,7 +455,7 @@ Dns4HostNameToIp (
// //
// Construct DNS TokenEntry. // Construct DNS TokenEntry.
// //
TokenEntry = AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY)); TokenEntry = AllocateZeroPool (sizeof (DNS4_TOKEN_ENTRY));
if (TokenEntry == NULL) { if (TokenEntry == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -614,7 +618,7 @@ Dns4GeneralLookUp (
// //
// Validate the parameters // Validate the parameters
// //
if ((This == NULL) || (QName == NULL) || Token == NULL) { if ((This == NULL) || (QName == NULL) || (Token == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -655,7 +659,7 @@ Dns4GeneralLookUp (
// //
// Construct DNS TokenEntry. // Construct DNS TokenEntry.
// //
TokenEntry = AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY)); TokenEntry = AllocateZeroPool (sizeof (DNS4_TOKEN_ENTRY));
if (TokenEntry == NULL) { if (TokenEntry == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -752,7 +756,7 @@ Dns4UpdateDnsCache (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
if (DnsCacheEntry.HostName == NULL || DnsCacheEntry.IpAddress == NULL || DnsCacheEntry.Timeout == 0) { if ((DnsCacheEntry.HostName == NULL) || (DnsCacheEntry.IpAddress == NULL) || (DnsCacheEntry.Timeout == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -951,8 +955,8 @@ Dns6GetModeData (
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6ServerList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6ServerList) {
Index++; Index++;
} }
DnsModeData->DnsServerCount = (UINT32) Index; DnsModeData->DnsServerCount = (UINT32)Index;
ServerList = AllocatePool (sizeof(EFI_IPv6_ADDRESS) * DnsModeData->DnsServerCount); ServerList = AllocatePool (sizeof (EFI_IPv6_ADDRESS) * DnsModeData->DnsServerCount);
if (ServerList == NULL) { if (ServerList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
Dns6CleanConfigure (&DnsModeData->DnsConfigData); Dns6CleanConfigure (&DnsModeData->DnsConfigData);
@ -970,12 +974,12 @@ Dns6GetModeData (
// //
// Get the DnsCacheCount and DnsCacheList // Get the DnsCacheCount and DnsCacheList
// //
Index =0; Index = 0;
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {
Index++; Index++;
} }
DnsModeData->DnsCacheCount = (UINT32) Index; DnsModeData->DnsCacheCount = (UINT32)Index;
CacheList = AllocatePool (sizeof(EFI_DNS6_CACHE_ENTRY) * DnsModeData->DnsCacheCount); CacheList = AllocatePool (sizeof (EFI_DNS6_CACHE_ENTRY) * DnsModeData->DnsCacheCount);
if (CacheList == NULL) { if (CacheList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
Dns6CleanConfigure (&DnsModeData->DnsConfigData); Dns6CleanConfigure (&DnsModeData->DnsConfigData);
@ -983,7 +987,7 @@ Dns6GetModeData (
goto ON_EXIT; goto ON_EXIT;
} }
Index =0; Index = 0;
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {
CacheItem = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink); CacheItem = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);
CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof (EFI_DNS6_CACHE_ENTRY)); CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof (EFI_DNS6_CACHE_ENTRY));
@ -1037,13 +1041,14 @@ Dns6Configure (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
ServerList = NULL; ServerList = NULL;
if (This == NULL || if ((This == NULL) ||
(DnsConfigData != NULL && ((DnsConfigData->DnsServerCount != 0 && DnsConfigData->DnsServerList == NULL) || ((DnsConfigData != NULL) && (((DnsConfigData->DnsServerCount != 0) && (DnsConfigData->DnsServerList == NULL)) ||
(DnsConfigData->DnsServerCount == 0 && DnsConfigData->DnsServerList != NULL)))) { ((DnsConfigData->DnsServerCount == 0) && (DnsConfigData->DnsServerList != NULL)))))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (DnsConfigData != NULL && DnsConfigData->Protocol != DNS_PROTOCOL_UDP) { if ((DnsConfigData != NULL) && (DnsConfigData->Protocol != DNS_PROTOCOL_UDP)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -1057,8 +1062,8 @@ Dns6Configure (
// //
// Reset the Instance if ConfigData is NULL // Reset the Instance if ConfigData is NULL
// //
if (!NetMapIsEmpty(&Instance->Dns6TxTokens)) { if (!NetMapIsEmpty (&Instance->Dns6TxTokens)) {
Dns6InstanceCancelToken(Instance, NULL); Dns6InstanceCancelToken (Instance, NULL);
} }
if (Instance->UdpIo != NULL) { if (Instance->UdpIo != NULL) {
@ -1068,6 +1073,7 @@ Dns6Configure (
if (Instance->Dns6CfgData.DnsServerList != NULL) { if (Instance->Dns6CfgData.DnsServerList != NULL) {
FreePool (Instance->Dns6CfgData.DnsServerList); FreePool (Instance->Dns6CfgData.DnsServerList);
} }
ZeroMem (&Instance->Dns6CfgData, sizeof (EFI_DNS6_CONFIG_DATA)); ZeroMem (&Instance->Dns6CfgData, sizeof (EFI_DNS6_CONFIG_DATA));
Instance->State = DNS_STATE_UNCONFIGED; Instance->State = DNS_STATE_UNCONFIGED;
@ -1089,7 +1095,7 @@ Dns6Configure (
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
// //
//The DNS instance will retrieve DNS server from DHCP Server. // The DNS instance will retrieve DNS server from DHCP Server.
// //
Status = GetDns6ServerFromDhcp6 ( Status = GetDns6ServerFromDhcp6 (
Instance->Service->ImageHandle, Instance->Service->ImageHandle,
@ -1101,7 +1107,7 @@ Dns6Configure (
goto ON_EXIT; goto ON_EXIT;
} }
ASSERT(ServerList != NULL); ASSERT (ServerList != NULL);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK); OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@ -1121,6 +1127,7 @@ Dns6Configure (
FreePool (Instance->Dns6CfgData.DnsServerList); FreePool (Instance->Dns6CfgData.DnsServerList);
Instance->Dns6CfgData.DnsServerList = NULL; Instance->Dns6CfgData.DnsServerList = NULL;
} }
goto ON_EXIT; goto ON_EXIT;
} }
@ -1133,6 +1140,7 @@ Dns6Configure (
FreePool (Instance->Dns6CfgData.DnsServerList); FreePool (Instance->Dns6CfgData.DnsServerList);
Instance->Dns6CfgData.DnsServerList = NULL; Instance->Dns6CfgData.DnsServerList = NULL;
} }
goto ON_EXIT; goto ON_EXIT;
} }
@ -1201,7 +1209,7 @@ Dns6HostNameToIp (
// //
// Validate the parameters // Validate the parameters
// //
if ((This == NULL) || (HostName == NULL) || Token == NULL) { if ((This == NULL) || (HostName == NULL) || (Token == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1272,7 +1280,7 @@ Dns6HostNameToIp (
Index = 0; Index = 0;
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {
Item = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink); Item = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);
if ((UINT32)Index < Token->RspData.H2AData->IpCount && StrCmp (HostName, Item->DnsCache.HostName) == 0) { if (((UINT32)Index < Token->RspData.H2AData->IpCount) && (StrCmp (HostName, Item->DnsCache.HostName) == 0)) {
CopyMem ((Token->RspData.H2AData->IpList) + Index, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS)); CopyMem ((Token->RspData.H2AData->IpList) + Index, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS));
Index++; Index++;
} }
@ -1459,7 +1467,7 @@ Dns6GeneralLookUp (
// //
// Validate the parameters // Validate the parameters
// //
if ((This == NULL) || (QName == NULL) || Token == NULL) { if ((This == NULL) || (QName == NULL) || (Token == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1500,7 +1508,7 @@ Dns6GeneralLookUp (
// //
// Construct DNS TokenEntry. // Construct DNS TokenEntry.
// //
TokenEntry = AllocateZeroPool (sizeof(DNS6_TOKEN_ENTRY)); TokenEntry = AllocateZeroPool (sizeof (DNS6_TOKEN_ENTRY));
if (TokenEntry == NULL) { if (TokenEntry == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -1598,7 +1606,7 @@ Dns6UpdateDnsCache (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
if (DnsCacheEntry.HostName == NULL || DnsCacheEntry.IpAddress == NULL || DnsCacheEntry.Timeout == 0) { if ((DnsCacheEntry.HostName == NULL) || (DnsCacheEntry.IpAddress == NULL) || (DnsCacheEntry.Timeout == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1726,4 +1734,3 @@ Dns6Cancel (
return Status; return Status;
} }

View File

@ -39,7 +39,7 @@ UINTN mMaxDpcQueueDepth = 0;
// If the free list is empty and a DPC is queued, the free list is grown by allocating // If the free list is empty and a DPC is queued, the free list is grown by allocating
// an additional set of DPC entries. // an additional set of DPC entries.
// //
LIST_ENTRY mDpcEntryFreeList = INITIALIZE_LIST_HEAD_VARIABLE(mDpcEntryFreeList); LIST_ENTRY mDpcEntryFreeList = INITIALIZE_LIST_HEAD_VARIABLE (mDpcEntryFreeList);
// //
// An array of DPC queues. A DPC queue is allocated for every level EFI_TPL value. // An array of DPC queues. A DPC queue is allocated for every level EFI_TPL value.
@ -81,7 +81,7 @@ DpcQueueDpc (
// //
// Make sure DpcTpl is valid // Make sure DpcTpl is valid
// //
if (DpcTpl < TPL_APPLICATION || DpcTpl > TPL_HIGH_LEVEL) { if ((DpcTpl < TPL_APPLICATION) || (DpcTpl > TPL_HIGH_LEVEL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -265,7 +265,7 @@ DpcDispatchDpc (
// //
// Invoke the DPC passing in its context // Invoke the DPC passing in its context
// //
(DpcEntry->DpcProcedure) (DpcEntry->DpcContext); (DpcEntry->DpcProcedure)(DpcEntry->DpcContext);
// //
// At least one DPC has been invoked, so set the return status to EFI_SUCCESS // At least one DPC has been invoked, so set the return status to EFI_SUCCESS

View File

@ -77,4 +77,3 @@ DpcDispatchDpc (
); );
#endif #endif

View File

@ -42,6 +42,7 @@ HttpBootUpdateDevicePath (
if (Node == NULL) { if (Node == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH; Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv4.Header.SubType = MSG_IPv4_DP; Node->Ipv4.Header.SubType = MSG_IPv4_DP;
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH)); SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
@ -56,6 +57,7 @@ HttpBootUpdateDevicePath (
if (Node == NULL) { if (Node == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH; Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.SubType = MSG_IPv6_DP; Node->Ipv6.Header.SubType = MSG_IPv6_DP;
SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH)); SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
@ -68,7 +70,7 @@ HttpBootUpdateDevicePath (
CopyMem (&Node->Ipv6.GatewayIpAddress, &Private->GatewayIp.v6, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Node->Ipv6.GatewayIpAddress, &Private->GatewayIp.v6, sizeof (EFI_IPv6_ADDRESS));
} }
TmpIpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); TmpIpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node); FreePool (Node);
if (TmpIpDevicePath == NULL) { if (TmpIpDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -84,13 +86,14 @@ HttpBootUpdateDevicePath (
FreePool (TmpIpDevicePath); FreePool (TmpIpDevicePath);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Node->DevPath.Type = MESSAGING_DEVICE_PATH; Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_DNS_DP; Node->DevPath.SubType = MSG_DNS_DP;
SetDevicePathNodeLength (Node, Length); SetDevicePathNodeLength (Node, Length);
Node->Dns.IsIPv6 = Private->UsingIpv6 ? 0x01 : 0x00; Node->Dns.IsIPv6 = Private->UsingIpv6 ? 0x01 : 0x00;
CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv6), Private->DnsServerIp, Private->DnsServerCount * sizeof (EFI_IP_ADDRESS)); CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv6), Private->DnsServerIp, Private->DnsServerCount * sizeof (EFI_IP_ADDRESS));
TmpDnsDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); TmpDnsDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node); FreePool (Node);
FreePool (TmpIpDevicePath); FreePool (TmpIpDevicePath);
TmpIpDevicePath = NULL; TmpIpDevicePath = NULL;
@ -108,24 +111,28 @@ HttpBootUpdateDevicePath (
if (TmpIpDevicePath != NULL) { if (TmpIpDevicePath != NULL) {
FreePool (TmpIpDevicePath); FreePool (TmpIpDevicePath);
} }
if (TmpDnsDevicePath != NULL) { if (TmpDnsDevicePath != NULL) {
FreePool (TmpDnsDevicePath); FreePool (TmpDnsDevicePath);
} }
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Node->DevPath.Type = MESSAGING_DEVICE_PATH; Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP; Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, Length); SetDevicePathNodeLength (Node, Length);
CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), Private->BootFileUri, AsciiStrSize (Private->BootFileUri)); CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), Private->BootFileUri, AsciiStrSize (Private->BootFileUri));
if (TmpDnsDevicePath != NULL) { if (TmpDnsDevicePath != NULL) {
NewDevicePath = AppendDevicePathNode (TmpDnsDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); NewDevicePath = AppendDevicePathNode (TmpDnsDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (TmpDnsDevicePath); FreePool (TmpDnsDevicePath);
} else { } else {
ASSERT (TmpIpDevicePath != NULL); ASSERT (TmpIpDevicePath != NULL);
NewDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); NewDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (TmpIpDevicePath); FreePool (TmpIpDevicePath);
} }
FreePool (Node); FreePool (Node);
if (NewDevicePath == NULL) { if (NewDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -160,6 +167,7 @@ HttpBootUpdateDevicePath (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
FreePool (Private->Ip6Nic->DevicePath); FreePool (Private->Ip6Nic->DevicePath);
Private->Ip6Nic->DevicePath = NewDevicePath; Private->Ip6Nic->DevicePath = NewDevicePath;
} }
@ -209,15 +217,17 @@ HttpBootDhcp4ExtractUriInfo (
// //
if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) { (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns))
{
HttpOffer = SelectOffer; HttpOffer = SelectOffer;
} else { } else {
ASSERT (Private->SelectProxyType != HttpOfferTypeMax); ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0]; ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4; HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;
} }
Private->BootFileUriParser = HttpOffer->UriParser; Private->BootFileUriParser = HttpOffer->UriParser;
Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data; Private->BootFileUri = (CHAR8 *)HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;
} else { } else {
// //
// In Home environment the BootFileUri comes from the FilePath. // In Home environment the BootFileUri comes from the FilePath.
@ -237,12 +247,14 @@ HttpBootDhcp4ExtractUriInfo (
} else if (Status == EFI_ACCESS_DENIED) { } else if (Status == EFI_ACCESS_DENIED) {
AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n"); AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n");
} }
return Status; return Status;
} }
if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) { (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns))
{
Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER]; Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER];
ASSERT (Option != NULL); ASSERT (Option != NULL);
@ -257,7 +269,7 @@ HttpBootDhcp4ExtractUriInfo (
} }
for (DnsServerIndex = 0; DnsServerIndex < Private->DnsServerCount; DnsServerIndex++) { for (DnsServerIndex = 0; DnsServerIndex < Private->DnsServerCount; DnsServerIndex++) {
CopyMem (&(Private->DnsServerIp[DnsServerIndex].v4), &(((EFI_IPv4_ADDRESS *) Option->Data)[DnsServerIndex]), sizeof (EFI_IPv4_ADDRESS)); CopyMem (&(Private->DnsServerIp[DnsServerIndex].v4), &(((EFI_IPv4_ADDRESS *)Option->Data)[DnsServerIndex]), sizeof (EFI_IPv4_ADDRESS));
} }
// //
@ -283,7 +295,7 @@ HttpBootDhcp4ExtractUriInfo (
Private->BootFileUriParser, Private->BootFileUriParser,
&Private->Port &Private->Port
); );
if (EFI_ERROR (Status) || Private->Port == 0) { if (EFI_ERROR (Status) || (Private->Port == 0)) {
Private->Port = 80; Private->Port = 80;
} }
@ -295,7 +307,7 @@ HttpBootDhcp4ExtractUriInfo (
// Update the device path to include the boot resource information. // Update the device path to include the boot resource information.
// //
Status = HttpBootUpdateDevicePath (Private); Status = HttpBootUpdateDevicePath (Private);
if (EFI_ERROR (Status) && Private->DnsServerIp != NULL) { if (EFI_ERROR (Status) && (Private->DnsServerIp != NULL)) {
FreePool (Private->DnsServerIp); FreePool (Private->DnsServerIp);
Private->DnsServerIp = NULL; Private->DnsServerIp = NULL;
} }
@ -349,15 +361,17 @@ HttpBootDhcp6ExtractUriInfo (
// //
if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) { (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns))
{
HttpOffer = SelectOffer; HttpOffer = SelectOffer;
} else { } else {
ASSERT (Private->SelectProxyType != HttpOfferTypeMax); ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0]; ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6; HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;
} }
Private->BootFileUriParser = HttpOffer->UriParser; Private->BootFileUriParser = HttpOffer->UriParser;
Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data; Private->BootFileUri = (CHAR8 *)HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;
} else { } else {
// //
// In Home environment the BootFileUri comes from the FilePath. // In Home environment the BootFileUri comes from the FilePath.
@ -377,6 +391,7 @@ HttpBootDhcp6ExtractUriInfo (
} else if (Status == EFI_ACCESS_DENIED) { } else if (Status == EFI_ACCESS_DENIED) {
AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n"); AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n");
} }
return Status; return Status;
} }
@ -398,7 +413,8 @@ HttpBootDhcp6ExtractUriInfo (
if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) { (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns))
{
Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER]; Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];
ASSERT (Option != NULL); ASSERT (Option != NULL);
@ -413,7 +429,7 @@ HttpBootDhcp6ExtractUriInfo (
} }
for (DnsServerIndex = 0; DnsServerIndex < Private->DnsServerCount; DnsServerIndex++) { for (DnsServerIndex = 0; DnsServerIndex < Private->DnsServerCount; DnsServerIndex++) {
CopyMem (&(Private->DnsServerIp[DnsServerIndex].v6), &(((EFI_IPv6_ADDRESS *) Option->Data)[DnsServerIndex]), sizeof (EFI_IPv6_ADDRESS)); CopyMem (&(Private->DnsServerIp[DnsServerIndex].v6), &(((EFI_IPv6_ADDRESS *)Option->Data)[DnsServerIndex]), sizeof (EFI_IPv6_ADDRESS));
} }
// //
@ -483,7 +499,7 @@ HttpBootDhcp6ExtractUriInfo (
Private->BootFileUriParser, Private->BootFileUriParser,
&Private->Port &Private->Port
); );
if (EFI_ERROR (Status) || Private->Port == 0) { if (EFI_ERROR (Status) || (Private->Port == 0)) {
Private->Port = 80; Private->Port = 80;
} }
@ -510,7 +526,6 @@ Error:
return Status; return Status;
} }
/** /**
Discover all the boot information for boot file. Discover all the boot information for boot file.
@ -565,17 +580,19 @@ HttpBootHttpIoCallback (
{ {
HTTP_BOOT_PRIVATE_DATA *Private; HTTP_BOOT_PRIVATE_DATA *Private;
EFI_STATUS Status; EFI_STATUS Status;
Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
if (Private->HttpBootCallback != NULL) { if (Private->HttpBootCallback != NULL) {
Status = Private->HttpBootCallback->Callback ( Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback, Private->HttpBootCallback,
EventType == HttpIoRequest ? HttpBootHttpRequest : HttpBootHttpResponse, EventType == HttpIoRequest ? HttpBootHttpRequest : HttpBootHttpResponse,
EventType == HttpIoRequest ? FALSE : TRUE, EventType == HttpIoRequest ? FALSE : TRUE,
sizeof (EFI_HTTP_MESSAGE), sizeof (EFI_HTTP_MESSAGE),
(VOID *) Message (VOID *)Message
); );
return Status; return Status;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -625,7 +642,7 @@ HttpBootCreateHttpIo (
Private->UsingIpv6 ? IP_VERSION_6 : IP_VERSION_4, Private->UsingIpv6 ? IP_VERSION_6 : IP_VERSION_4,
&ConfigData, &ConfigData,
HttpBootHttpIoCallback, HttpBootHttpIoCallback,
(VOID *) Private, (VOID *)Private,
&Private->HttpIo &Private->HttpIo
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -660,6 +677,7 @@ HttpBootFreeCache (
if (Cache->RequestData->Url != NULL) { if (Cache->RequestData->Url != NULL) {
FreePool (Cache->RequestData->Url); FreePool (Cache->RequestData->Url);
} }
FreePool (Cache->RequestData); FreePool (Cache->RequestData);
} }
@ -672,6 +690,7 @@ HttpBootFreeCache (
FreePool (Cache->ResponseData->Headers[Index].FieldName); FreePool (Cache->ResponseData->Headers[Index].FieldName);
FreePool (Cache->ResponseData->Headers[Index].FieldValue); FreePool (Cache->ResponseData->Headers[Index].FieldValue);
} }
FreePool (Cache->ResponseData->Headers); FreePool (Cache->ResponseData->Headers);
} }
} }
@ -684,6 +703,7 @@ HttpBootFreeCache (
if (EntityData->Block != NULL) { if (EntityData->Block != NULL) {
FreePool (EntityData->Block); FreePool (EntityData->Block);
} }
RemoveEntryList (&EntityData->Link); RemoveEntryList (&EntityData->Link);
FreePool (EntityData); FreePool (EntityData);
} }
@ -747,7 +767,7 @@ HttpBootGetFileFromCache (
HTTP_BOOT_ENTITY_DATA *EntityData; HTTP_BOOT_ENTITY_DATA *EntityData;
UINTN CopyedSize; UINTN CopyedSize;
if (Uri == NULL || BufferSize == NULL || Buffer == NULL || ImageType == NULL) { if ((Uri == NULL) || (BufferSize == NULL) || (Buffer == NULL) || (ImageType == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -758,7 +778,8 @@ HttpBootGetFileFromCache (
// //
if ((Cache->RequestData != NULL) && if ((Cache->RequestData != NULL) &&
(Cache->RequestData->Url != NULL) && (Cache->RequestData->Url != NULL) &&
(StrCmp (Uri, Cache->RequestData->Url) == 0)) { (StrCmp (Uri, Cache->RequestData->Url) == 0))
{
// //
// Hit in cache, record image type. // Hit in cache, record image type.
// //
@ -831,7 +852,7 @@ HttpBootGetBootFileCallback (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
CallbackData = (HTTP_BOOT_CALLBACK_DATA *) Context; CallbackData = (HTTP_BOOT_CALLBACK_DATA *)Context;
HttpBootCallback = CallbackData->Private->HttpBootCallback; HttpBootCallback = CallbackData->Private->HttpBootCallback;
if (HttpBootCallback != NULL) { if (HttpBootCallback != NULL) {
Status = HttpBootCallback->Callback ( Status = HttpBootCallback->Callback (
@ -845,6 +866,7 @@ HttpBootGetBootFileCallback (
return Status; return Status;
} }
} }
// //
// Copy data if caller has provided a buffer. // Copy data if caller has provided a buffer.
// //
@ -865,14 +887,17 @@ HttpBootGetBootFileCallback (
if (NewEntityData == NULL) { if (NewEntityData == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
if (CallbackData->NewBlock) { if (CallbackData->NewBlock) {
NewEntityData->Block = CallbackData->Block; NewEntityData->Block = CallbackData->Block;
CallbackData->Block = NULL; CallbackData->Block = NULL;
} }
NewEntityData->DataLength = Length; NewEntityData->DataLength = Length;
NewEntityData->DataStart = (UINT8*) Data; NewEntityData->DataStart = (UINT8 *)Data;
InsertTailList (&CallbackData->Cache->EntityDataList, &NewEntityData->Link); InsertTailList (&CallbackData->Cache->EntityDataList, &NewEntityData->Link);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -930,11 +955,11 @@ HttpBootGetBootFile (
ASSERT (Private != NULL); ASSERT (Private != NULL);
ASSERT (Private->HttpCreated); ASSERT (Private->HttpCreated);
if (BufferSize == NULL || ImageType == NULL) { if ((BufferSize == NULL) || (ImageType == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (*BufferSize != 0 && Buffer == NULL) { if ((*BufferSize != 0) && (Buffer == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -946,8 +971,9 @@ HttpBootGetBootFile (
if (Url == NULL) { if (Url == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize); AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);
if (!HeaderOnly && Buffer != NULL) { if (!HeaderOnly && (Buffer != NULL)) {
Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType); Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType);
if (Status != EFI_NOT_FOUND) { if (Status != EFI_NOT_FOUND) {
FreePool (Url); FreePool (Url);
@ -969,6 +995,7 @@ HttpBootGetBootFile (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ERROR_1; goto ERROR_1;
} }
Cache->ImageType = ImageTypeMax; Cache->ImageType = ImageTypeMax;
InitializeListHead (&Cache->EntityDataList); InitializeListHead (&Cache->EntityDataList);
} }
@ -1001,6 +1028,7 @@ HttpBootGetBootFile (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ERROR_3; goto ERROR_3;
} }
Status = HttpIoSetHeader ( Status = HttpIoSetHeader (
HttpIoHeader, HttpIoHeader,
HTTP_HEADER_HOST, HTTP_HEADER_HOST,
@ -1043,6 +1071,7 @@ HttpBootGetBootFile (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ERROR_3; goto ERROR_3;
} }
RequestData->Method = HeaderOnly ? HttpMethodHead : HttpMethodGet; RequestData->Method = HeaderOnly ? HttpMethodHead : HttpMethodGet;
RequestData->Url = Url; RequestData->Url = Url;
@ -1076,11 +1105,12 @@ HttpBootGetBootFile (
// //
// 3.1 First step, use zero BodyLength to only receive the response headers. // 3.1 First step, use zero BodyLength to only receive the response headers.
// //
ResponseData = AllocateZeroPool (sizeof(HTTP_IO_RESPONSE_DATA)); ResponseData = AllocateZeroPool (sizeof (HTTP_IO_RESPONSE_DATA));
if (ResponseData == NULL) { if (ResponseData == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ERROR_4; goto ERROR_4;
} }
Status = HttpIoRecvResponse ( Status = HttpIoRecvResponse (
&Private->HttpIo, &Private->HttpIo,
TRUE, TRUE,
@ -1092,6 +1122,7 @@ HttpBootGetBootFile (
HttpBootPrintErrorMessage (StatusCode); HttpBootPrintErrorMessage (StatusCode);
Status = ResponseData->Status; Status = ResponseData->Status;
} }
goto ERROR_5; goto ERROR_5;
} }
@ -1134,7 +1165,7 @@ HttpBootGetBootFile (
ResponseData->HeaderCount, ResponseData->HeaderCount,
ResponseData->Headers, ResponseData->Headers,
HttpBootGetBootFileCallback, HttpBootGetBootFileCallback,
(VOID*) &Context, (VOID *)&Context,
&Parser &Parser
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -1169,7 +1200,7 @@ HttpBootGetBootFile (
// //
ReceivedSize = 0; ReceivedSize = 0;
while (ReceivedSize < ContentLength) { while (ReceivedSize < ContentLength) {
ResponseBody.Body = (CHAR8*) Buffer + ReceivedSize; ResponseBody.Body = (CHAR8 *)Buffer + ReceivedSize;
ResponseBody.BodyLength = *BufferSize - ReceivedSize; ResponseBody.BodyLength = *BufferSize - ReceivedSize;
Status = HttpIoRecvResponse ( Status = HttpIoRecvResponse (
&Private->HttpIo, &Private->HttpIo,
@ -1180,8 +1211,10 @@ HttpBootGetBootFile (
if (EFI_ERROR (ResponseBody.Status)) { if (EFI_ERROR (ResponseBody.Status)) {
Status = ResponseBody.Status; Status = ResponseBody.Status;
} }
goto ERROR_6; goto ERROR_6;
} }
ReceivedSize += ResponseBody.BodyLength; ReceivedSize += ResponseBody.BodyLength;
if (Private->HttpBootCallback != NULL) { if (Private->HttpBootCallback != NULL) {
Status = Private->HttpBootCallback->Callback ( Status = Private->HttpBootCallback->Callback (
@ -1209,19 +1242,20 @@ HttpBootGetBootFile (
// Otherwise a buffer, the buffer in Block will be cached and we should allocate a new before // Otherwise a buffer, the buffer in Block will be cached and we should allocate a new before
// every HttpIoRecvResponse(). // every HttpIoRecvResponse().
// //
if (Block == NULL || Context.BufferSize == 0) { if ((Block == NULL) || (Context.BufferSize == 0)) {
Block = AllocatePool (HTTP_BOOT_BLOCK_SIZE); Block = AllocatePool (HTTP_BOOT_BLOCK_SIZE);
if (Block == NULL) { if (Block == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ERROR_6; goto ERROR_6;
} }
Context.NewBlock = TRUE; Context.NewBlock = TRUE;
Context.Block = Block; Context.Block = Block;
} else { } else {
Context.NewBlock = FALSE; Context.NewBlock = FALSE;
} }
ResponseBody.Body = (CHAR8*) Block; ResponseBody.Body = (CHAR8 *)Block;
ResponseBody.BodyLength = HTTP_BOOT_BLOCK_SIZE; ResponseBody.BodyLength = HTTP_BOOT_BLOCK_SIZE;
Status = HttpIoRecvResponse ( Status = HttpIoRecvResponse (
&Private->HttpIo, &Private->HttpIo,
@ -1232,6 +1266,7 @@ HttpBootGetBootFile (
if (EFI_ERROR (ResponseBody.Status)) { if (EFI_ERROR (ResponseBody.Status)) {
Status = ResponseBody.Status; Status = ResponseBody.Status;
} }
goto ERROR_6; goto ERROR_6;
} }
@ -1263,6 +1298,7 @@ HttpBootGetBootFile (
} else { } else {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
*BufferSize = ContentLength; *BufferSize = ContentLength;
// //
@ -1283,25 +1319,30 @@ ERROR_6:
if (Parser != NULL) { if (Parser != NULL) {
HttpFreeMsgParser (Parser); HttpFreeMsgParser (Parser);
} }
if (Context.Block != NULL) { if (Context.Block != NULL) {
FreePool (Context.Block); FreePool (Context.Block);
} }
HttpBootFreeCache (Cache); HttpBootFreeCache (Cache);
ERROR_5: ERROR_5:
if (ResponseData != NULL) { if (ResponseData != NULL) {
FreePool (ResponseData); FreePool (ResponseData);
} }
ERROR_4: ERROR_4:
if (RequestData != NULL) { if (RequestData != NULL) {
FreePool (RequestData); FreePool (RequestData);
} }
ERROR_3: ERROR_3:
HttpIoFreeHeader (HttpIoHeader); HttpIoFreeHeader (HttpIoHeader);
ERROR_2: ERROR_2:
if (Cache != NULL) { if (Cache != NULL) {
FreePool (Cache); FreePool (Cache);
} }
ERROR_1: ERROR_1:
if (Url != NULL) { if (Url != NULL) {
FreePool (Url); FreePool (Url);

View File

@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName = { EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName = {
(EFI_COMPONENT_NAME_GET_DRIVER_NAME) HttpBootDxeComponentNameGetDriverName, (EFI_COMPONENT_NAME_GET_DRIVER_NAME)HttpBootDxeComponentNameGetDriverName,
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)HttpBootDxeComponentNameGetControllerName, (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)HttpBootDxeComponentNameGetControllerName,
"eng" "eng"
}; };
@ -81,7 +81,7 @@ HttpBootDxeComponentNameGetDriverName (
This->SupportedLanguages, This->SupportedLanguages,
mHttpBootDxeDriverNameTable, mHttpBootDxeDriverNameTable,
DriverName, DriverName,
(BOOLEAN) (This != &gHttpBootDxeComponentName2) (BOOLEAN)(This != &gHttpBootDxeComponentName2)
); );
} }
@ -139,13 +139,13 @@ HttpBootDxeComponentNameGetControllerName (
EFI_HANDLE NicHandle; EFI_HANDLE NicHandle;
UINT32 *Id; UINT32 *Id;
if (ControllerHandle == NULL || ChildHandle != NULL) { if ((ControllerHandle == NULL) || (ChildHandle != NULL)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
NicHandle = HttpBootGetNicByIp4Children (ControllerHandle); NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);
if (NicHandle == NULL) { if (NicHandle == NULL) {
NicHandle = HttpBootGetNicByIp6Children(ControllerHandle); NicHandle = HttpBootGetNicByIp6Children (ControllerHandle);
if (NicHandle == NULL) { if (NicHandle == NULL) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -157,7 +157,7 @@ HttpBootDxeComponentNameGetControllerName (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
NULL, NULL,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -173,5 +173,4 @@ HttpBootDxeComponentNameGetControllerName (
ControllerName, ControllerName,
(BOOLEAN)(This != &gHttpBootDxeComponentName2) (BOOLEAN)(This != &gHttpBootDxeComponentName2)
); );
} }

View File

@ -55,7 +55,8 @@ HttpBootAddBootOption (
if (Uri[Index] == L':') { if (Uri[Index] == L':') {
break; break;
} }
if (Uri[Index] >= L'A' && Uri[Index] <= L'Z') {
if ((Uri[Index] >= L'A') && (Uri[Index] <= L'Z')) {
Uri[Index] -= (CHAR16)(L'A' - L'a'); Uri[Index] -= (CHAR16)(L'A' - L'a');
} }
} }
@ -77,6 +78,7 @@ HttpBootAddBootOption (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH; Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv4.Header.SubType = MSG_IPv4_DP; Node->Ipv4.Header.SubType = MSG_IPv4_DP;
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH)); SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
@ -86,15 +88,18 @@ HttpBootAddBootOption (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH; Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.SubType = MSG_IPv6_DP; Node->Ipv6.Header.SubType = MSG_IPv6_DP;
SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH)); SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
} }
TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node); FreePool (Node);
if (TmpDevicePath == NULL) { if (TmpDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Update the URI node with the input boot file URI. // Update the URI node with the input boot file URI.
// //
@ -106,11 +111,12 @@ HttpBootAddBootOption (
FreePool (TmpDevicePath); FreePool (TmpDevicePath);
goto ON_EXIT; goto ON_EXIT;
} }
Node->DevPath.Type = MESSAGING_DEVICE_PATH; Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP; Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, Length); SetDevicePathNodeLength (Node, Length);
CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, AsciiStrSize (AsciiUri)); CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, AsciiStrSize (AsciiUri));
NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node); FreePool (Node);
FreePool (TmpDevicePath); FreePool (TmpDevicePath);
if (NewDevicePath == NULL) { if (NewDevicePath == NULL) {
@ -135,7 +141,7 @@ HttpBootAddBootOption (
goto ON_EXIT; goto ON_EXIT;
} }
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1); Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
EfiBootManagerFreeLoadOption (&NewOption); EfiBootManagerFreeLoadOption (&NewOption);
ON_EXIT: ON_EXIT:
@ -235,7 +241,7 @@ HttpBootFormExtractConfig (
BOOLEAN AllocatedRequest; BOOLEAN AllocatedRequest;
UINTN Size; UINTN Size;
if (Progress == NULL || Results == NULL) { if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -270,6 +276,7 @@ HttpBootFormExtractConfig (
if (ConfigRequest == NULL) { if (ConfigRequest == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
AllocatedRequest = TRUE; AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr); FreePool (ConfigRequestHdr);
@ -278,7 +285,7 @@ HttpBootFormExtractConfig (
Status = gHiiConfigRouting->BlockToConfig ( Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting, gHiiConfigRouting,
ConfigRequest, ConfigRequest,
(UINT8 *) &CallbackInfo->HttpBootNvData, (UINT8 *)&CallbackInfo->HttpBootNvData,
BufferSize, BufferSize,
Results, Results,
Progress Progress
@ -291,6 +298,7 @@ HttpBootFormExtractConfig (
FreePool (ConfigRequest); FreePool (ConfigRequest);
ConfigRequest = NULL; ConfigRequest = NULL;
} }
// //
// Set Progress string to the original request string. // Set Progress string to the original request string.
// //
@ -359,6 +367,7 @@ HttpBootFormRouteConfig (
if (Progress == NULL) { if (Progress == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
*Progress = Configuration; *Progress = Configuration;
if (Configuration == NULL) { if (Configuration == NULL) {
@ -382,7 +391,7 @@ HttpBootFormRouteConfig (
Status = gHiiConfigRouting->ConfigToBlock ( Status = gHiiConfigRouting->ConfigToBlock (
gHiiConfigRouting, gHiiConfigRouting,
Configuration, Configuration,
(UINT8 *) &CallbackInfo->HttpBootNvData, (UINT8 *)&CallbackInfo->HttpBootNvData,
&BufferSize, &BufferSize,
Progress Progress
); );
@ -451,7 +460,7 @@ HttpBootFormCallback (
AsciiUri = NULL; AsciiUri = NULL;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
if (This == NULL || Value == NULL) { if ((This == NULL) || (Value == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -467,7 +476,7 @@ HttpBootFormCallback (
// Get user input URI string // Get user input URI string
// //
Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL); Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
if(Uri == NULL) { if (Uri == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -488,7 +497,6 @@ HttpBootFormCallback (
Status = HttpBootCheckUriScheme (AsciiUri); Status = HttpBootCheckUriScheme (AsciiUri);
if (Status == EFI_INVALID_PARAMETER) { if (Status == EFI_INVALID_PARAMETER) {
DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status)); DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
CreatePopUp ( CreatePopUp (
@ -499,7 +507,6 @@ HttpBootFormCallback (
NULL NULL
); );
} else if (Status == EFI_ACCESS_DENIED) { } else if (Status == EFI_ACCESS_DENIED) {
DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status)); DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
CreatePopUp ( CreatePopUp (
@ -570,7 +577,7 @@ HttpBootConfigFormInit (
SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH)); SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode ( CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
Private->ParentDevicePath, Private->ParentDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode (EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
); );
if (CallbackInfo->HiiVendorDevicePath == NULL) { if (CallbackInfo->HiiVendorDevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -660,7 +667,7 @@ HttpBootConfigFormUnload (
{ {
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo; HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
if (Private->Ip4Nic != NULL || Private->Ip6Nic != NULL) { if ((Private->Ip4Nic != NULL) || (Private->Ip6Nic != NULL)) {
// //
// Only unload the configuration form when both IP4 and IP6 stack are stopped. // Only unload the configuration form when both IP4 and IP6 stack are stopped.
// //

View File

@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _HTTP_BOOT_CONFIG_H_ #ifndef _HTTP_BOOT_CONFIG_H_
#define _HTTP_BOOT_CONFIG_H_ #define _HTTP_BOOT_CONFIG_H_
#include "HttpBootConfigNVDataStruc.h" #include "HttpBootConfigNVDataStruc.h"
typedef struct _HTTP_BOOT_FORM_CALLBACK_INFO HTTP_BOOT_FORM_CALLBACK_INFO; typedef struct _HTTP_BOOT_FORM_CALLBACK_INFO HTTP_BOOT_FORM_CALLBACK_INFO;

View File

@ -40,5 +40,4 @@ typedef struct _HTTP_BOOT_CONFIG_IFR_NVDATA {
} HTTP_BOOT_CONFIG_IFR_NVDATA; } HTTP_BOOT_CONFIG_IFR_NVDATA;
#pragma pack() #pragma pack()
#endif #endif

View File

@ -24,7 +24,7 @@ UINT8 mInterestedDhcp4Tags[HTTP_BOOT_DHCP4_TAG_INDEX_MAX] = {
// //
// There are 4 times retries with the value of 4, 8, 16 and 32, refers to UEFI 2.5 spec. // There are 4 times retries with the value of 4, 8, 16 and 32, refers to UEFI 2.5 spec.
// //
UINT32 mHttpDhcpTimeout[4] = {4, 8, 16, 32}; UINT32 mHttpDhcpTimeout[4] = { 4, 8, 16, 32 };
/** /**
Build the options buffer for the DHCPv4 request packet. Build the options buffer for the DHCPv4 request packet.
@ -48,14 +48,14 @@ HttpBootBuildDhcp4Options (
UINT32 Index; UINT32 Index;
Index = 0; Index = 0;
OptList[0] = (EFI_DHCP4_PACKET_OPTION *) Buffer; OptList[0] = (EFI_DHCP4_PACKET_OPTION *)Buffer;
// //
// Append parameter request list option. // Append parameter request list option.
// //
OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST; OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST;
OptList[Index]->Length = 27; OptList[Index]->Length = 27;
OptEnt.Para = (HTTP_BOOT_DHCP4_OPTION_PARA *) OptList[Index]->Data; OptEnt.Para = (HTTP_BOOT_DHCP4_OPTION_PARA *)OptList[Index]->Data;
OptEnt.Para->ParaList[0] = DHCP4_TAG_NETMASK; OptEnt.Para->ParaList[0] = DHCP4_TAG_NETMASK;
OptEnt.Para->ParaList[1] = DHCP4_TAG_TIME_OFFSET; OptEnt.Para->ParaList[1] = DHCP4_TAG_TIME_OFFSET;
OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER; OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER;
@ -89,15 +89,16 @@ HttpBootBuildDhcp4Options (
// Append UUID/Guid-based client identifier option // Append UUID/Guid-based client identifier option
// //
OptList[Index]->OpCode = DHCP4_TAG_UUID; OptList[Index]->OpCode = DHCP4_TAG_UUID;
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_UUID); OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_UUID);
OptEnt.Uuid = (HTTP_BOOT_DHCP4_OPTION_UUID *) OptList[Index]->Data; OptEnt.Uuid = (HTTP_BOOT_DHCP4_OPTION_UUID *)OptList[Index]->Data;
OptEnt.Uuid->Type = 0; OptEnt.Uuid->Type = 0;
if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) OptEnt.Uuid->Guid))) { if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *)OptEnt.Uuid->Guid))) {
// //
// Zero the Guid to indicate NOT programmable if failed to get system Guid. // Zero the Guid to indicate NOT programmable if failed to get system Guid.
// //
ZeroMem (OptEnt.Uuid->Guid, sizeof (EFI_GUID)); ZeroMem (OptEnt.Uuid->Guid, sizeof (EFI_GUID));
} }
Index++; Index++;
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]); OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
@ -105,8 +106,8 @@ HttpBootBuildDhcp4Options (
// Append client network device interface option // Append client network device interface option
// //
OptList[Index]->OpCode = DHCP4_TAG_UNDI; OptList[Index]->OpCode = DHCP4_TAG_UNDI;
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_UNDI); OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_UNDI);
OptEnt.Undi = (HTTP_BOOT_DHCP4_OPTION_UNDI *) OptList[Index]->Data; OptEnt.Undi = (HTTP_BOOT_DHCP4_OPTION_UNDI *)OptList[Index]->Data;
if (Private->Nii != NULL) { if (Private->Nii != NULL) {
OptEnt.Undi->Type = Private->Nii->Type; OptEnt.Undi->Type = Private->Nii->Type;
@ -125,8 +126,8 @@ HttpBootBuildDhcp4Options (
// Append client system architecture option // Append client system architecture option
// //
OptList[Index]->OpCode = DHCP4_TAG_ARCH; OptList[Index]->OpCode = DHCP4_TAG_ARCH;
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_ARCH); OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_ARCH);
OptEnt.Arch = (HTTP_BOOT_DHCP4_OPTION_ARCH *) OptList[Index]->Data; OptEnt.Arch = (HTTP_BOOT_DHCP4_OPTION_ARCH *)OptList[Index]->Data;
Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE); Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16)); CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
Index++; Index++;
@ -136,8 +137,8 @@ HttpBootBuildDhcp4Options (
// Append vendor class identify option // Append vendor class identify option
// //
OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID; OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_CLID); OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_CLID);
OptEnt.Clid = (HTTP_BOOT_DHCP4_OPTION_CLID *) OptList[Index]->Data; OptEnt.Clid = (HTTP_BOOT_DHCP4_OPTION_CLID *)OptList[Index]->Data;
CopyMem ( CopyMem (
OptEnt.Clid, OptEnt.Clid,
DEFAULT_CLASS_ID_DATA, DEFAULT_CLASS_ID_DATA,
@ -181,11 +182,10 @@ HttpBootParseDhcp4Options (
EFI_DHCP4_PACKET_OPTION *Option; EFI_DHCP4_PACKET_OPTION *Option;
UINT32 Offset; UINT32 Offset;
Option = (EFI_DHCP4_PACKET_OPTION *) Buffer; Option = (EFI_DHCP4_PACKET_OPTION *)Buffer;
Offset = 0; Offset = 0;
while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) { while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
if (Option->OpCode == OptTag) { if (Option->OpCode == OptTag) {
// //
// Found the required option. // Found the required option.
@ -202,7 +202,7 @@ HttpBootParseDhcp4Options (
Offset += Option->Length + 2; Offset += Option->Length + 2;
} }
Option = (EFI_DHCP4_PACKET_OPTION *) (Buffer + Offset); Option = (EFI_DHCP4_PACKET_OPTION *)(Buffer + Offset);
} }
return NULL; return NULL;
@ -284,6 +284,7 @@ HttpBootParseDhcp4Packet (
mInterestedDhcp4Tags[Index] mInterestedDhcp4Tags[Index]
); );
} }
// //
// Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132. // 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. // If yes, try to parse options from the BootFileName field, then ServerName field.
@ -295,18 +296,19 @@ HttpBootParseDhcp4Packet (
for (Index = 0; Index < HTTP_BOOT_DHCP4_TAG_INDEX_MAX; Index++) { for (Index = 0; Index < HTTP_BOOT_DHCP4_TAG_INDEX_MAX; Index++) {
if (Options[Index] == NULL) { if (Options[Index] == NULL) {
Options[Index] = HttpBootParseDhcp4Options ( Options[Index] = HttpBootParseDhcp4Options (
(UINT8 *) Offer->Dhcp4.Header.BootFileName, (UINT8 *)Offer->Dhcp4.Header.BootFileName,
sizeof (Offer->Dhcp4.Header.BootFileName), sizeof (Offer->Dhcp4.Header.BootFileName),
mInterestedDhcp4Tags[Index] mInterestedDhcp4Tags[Index]
); );
} }
} }
} }
if ((Option->Data[0] & HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME) != 0) { if ((Option->Data[0] & HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME) != 0) {
for (Index = 0; Index < HTTP_BOOT_DHCP4_TAG_INDEX_MAX; Index++) { for (Index = 0; Index < HTTP_BOOT_DHCP4_TAG_INDEX_MAX; Index++) {
if (Options[Index] == NULL) { if (Options[Index] == NULL) {
Options[Index] = HttpBootParseDhcp4Options ( Options[Index] = HttpBootParseDhcp4Options (
(UINT8 *) Offer->Dhcp4.Header.ServerName, (UINT8 *)Offer->Dhcp4.Header.ServerName,
sizeof (Offer->Dhcp4.Header.ServerName), sizeof (Offer->Dhcp4.Header.ServerName),
mInterestedDhcp4Tags[Index] mInterestedDhcp4Tags[Index]
); );
@ -327,7 +329,8 @@ HttpBootParseDhcp4Packet (
// //
Option = Options[HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID]; Option = Options[HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID];
if ((Option != NULL) && (Option->Length >= 10) && if ((Option != NULL) && (Option->Length >= 10) &&
(CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 10) == 0)) { (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 10) == 0))
{
IsHttpOffer = TRUE; IsHttpOffer = TRUE;
} }
@ -350,12 +353,12 @@ HttpBootParseDhcp4Packet (
// RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is null // 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. // terminated string. So force to append null terminated character at the end of string.
// //
Ptr8 = (UINT8*)&Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data[0]; Ptr8 = (UINT8 *)&Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
Ptr8 += Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Length; Ptr8 += Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Length;
if (*(Ptr8 - 1) != '\0') { if (*(Ptr8 - 1) != '\0') {
*Ptr8 = '\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. // 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. // Do not count dhcp option header here, or else will destroy the serverhostname.
@ -368,7 +371,7 @@ HttpBootParseDhcp4Packet (
// //
// Http offer must have a boot URI. // Http offer must have a boot URI.
// //
if (IsHttpOffer && Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE] == NULL) { if (IsHttpOffer && (Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE] == NULL)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -377,8 +380,8 @@ HttpBootParseDhcp4Packet (
// //
if (IsHttpOffer) { if (IsHttpOffer) {
Status = HttpParseUrl ( Status = HttpParseUrl (
(CHAR8*) Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data, (CHAR8 *)Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
(UINT32) AsciiStrLen ((CHAR8*) Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data), (UINT32)AsciiStrLen ((CHAR8 *)Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data),
FALSE, FALSE,
&Cache4->UriParser &Cache4->UriParser
); );
@ -387,7 +390,7 @@ HttpBootParseDhcp4Packet (
} }
Status = HttpUrlGetIp4 ( Status = HttpUrlGetIp4 (
(CHAR8*) Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data, (CHAR8 *)Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
Cache4->UriParser, Cache4->UriParser,
&IpAddr &IpAddr
); );
@ -411,7 +414,6 @@ HttpBootParseDhcp4Packet (
OfferType = HttpOfferTypeProxyNameUri; OfferType = HttpOfferTypeProxyNameUri;
} }
} }
} else { } else {
if (!IsProxyOffer) { if (!IsProxyOffer) {
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly; OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
@ -419,6 +421,7 @@ HttpBootParseDhcp4Packet (
if (Cache4->UriParser != NULL) { if (Cache4->UriParser != NULL) {
FreePool (Cache4->UriParser); FreePool (Cache4->UriParser);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
} }
@ -500,26 +503,16 @@ HttpBootSelectDhcpOffer (
// The offer with DNS server address takes priority here. // The offer with DNS server address takes priority here.
// //
if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0) { if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) { } else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) { } else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) { } else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) { } else if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;
} }
} else { } else {
// //
// We are in corporate environment. // We are in corporate environment.
@ -532,45 +525,35 @@ HttpBootSelectDhcpOffer (
// Priority6: HttpOfferTypeDhcpDns + HttpOfferTypeDhcpNameUri // Priority6: HttpOfferTypeDhcpDns + HttpOfferTypeDhcpNameUri
// //
if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) { if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) { } else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {
}else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;
} else if ((Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) &&
} else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0 && (Private->OfferCount[HttpOfferTypeProxyIpUri] > 0))
Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) { {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;
Private->SelectProxyType = HttpOfferTypeProxyIpUri; Private->SelectProxyType = HttpOfferTypeProxyIpUri;
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 && (Private->OfferCount[HttpOfferTypeProxyIpUri] > 0))
Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) { {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
Private->SelectProxyType = HttpOfferTypeProxyIpUri; Private->SelectProxyType = HttpOfferTypeProxyIpUri;
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 && (Private->OfferCount[HttpOfferTypeProxyNameUri] > 0))
Private->OfferCount[HttpOfferTypeProxyNameUri] > 0) { {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
Private->SelectProxyType = HttpOfferTypeProxyNameUri; Private->SelectProxyType = HttpOfferTypeProxyNameUri;
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 && (Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0))
Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0) { {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1; Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
Private->SelectProxyType = HttpOfferTypeDhcpNameUri; Private->SelectProxyType = HttpOfferTypeDhcpNameUri;
} }
} }
} }
/** /**
EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver
to intercept events that occurred in the configuration process. to intercept events that occurred in the configuration process.
@ -612,11 +595,12 @@ HttpBootDhcp4CallBack (
(Dhcp4Event != Dhcp4RcvdOffer) && (Dhcp4Event != Dhcp4RcvdOffer) &&
(Dhcp4Event != Dhcp4SendRequest) && (Dhcp4Event != Dhcp4SendRequest) &&
(Dhcp4Event != Dhcp4RcvdAck) && (Dhcp4Event != Dhcp4RcvdAck) &&
(Dhcp4Event != Dhcp4SelectOffer)) { (Dhcp4Event != Dhcp4SelectOffer))
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Private = (HTTP_BOOT_PRIVATE_DATA *) Context; Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
// //
// Override the Maximum DHCP Message Size. // Override the Maximum DHCP Message Size.
@ -634,8 +618,8 @@ HttpBootDhcp4CallBack (
// //
// Callback to user if any packets sent or received. // Callback to user if any packets sent or received.
// //
if (Private->HttpBootCallback != NULL && Dhcp4Event != Dhcp4SelectOffer) { if ((Private->HttpBootCallback != NULL) && (Dhcp4Event != Dhcp4SelectOffer)) {
Received = (BOOLEAN) (Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck); Received = (BOOLEAN)(Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
Status = Private->HttpBootCallback->Callback ( Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback, Private->HttpBootCallback,
HttpBootDhcp4, HttpBootDhcp4,
@ -658,6 +642,7 @@ HttpBootDhcp4CallBack (
// //
break; break;
} }
if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) { if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
// //
// Cache the DHCPv4 offers to OfferBuffer[] for select later, and record // Cache the DHCPv4 offers to OfferBuffer[] for select later, and record
@ -666,6 +651,7 @@ HttpBootDhcp4CallBack (
// //
HttpBootCacheDhcp4Offer (Private, Packet); HttpBootCacheDhcp4Offer (Private, Packet);
} }
break; break;
case Dhcp4SelectOffer: case Dhcp4SelectOffer:
@ -680,6 +666,7 @@ HttpBootDhcp4CallBack (
} else { } else {
*NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer; *NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer;
} }
break; break;
default: default:
@ -761,7 +748,6 @@ HttpBootRegisterIp4Dns (
); );
} }
/** /**
This function will switch the IP4 configuration policy to Static. This function will switch the IP4 configuration policy to Static.
@ -796,7 +782,7 @@ HttpBootSetIp4Policy (
if (Policy != Ip4Config2PolicyStatic) { if (Policy != Ip4Config2PolicyStatic) {
Policy = Ip4Config2PolicyStatic; Policy = Ip4Config2PolicyStatic;
Status= Ip4Config2->SetData ( Status = Ip4Config2->SetData (
Ip4Config2, Ip4Config2,
Ip4Config2DataTypePolicy, Ip4Config2DataTypePolicy,
sizeof (EFI_IP4_CONFIG2_POLICY), sizeof (EFI_IP4_CONFIG2_POLICY),
@ -846,7 +832,7 @@ HttpBootDhcp4Dora (
OptCount = HttpBootBuildDhcp4Options (Private, OptList, Buffer); OptCount = HttpBootBuildDhcp4Options (Private, OptList, Buffer);
ASSERT (OptCount > 0); ASSERT (OptCount > 0);
ZeroMem (&Config, sizeof(Config)); ZeroMem (&Config, sizeof (Config));
Config.OptionCount = OptCount; Config.OptionCount = OptCount;
Config.OptionList = OptList; Config.OptionList = OptList;
Config.Dhcp4Callback = HttpBootDhcp4CallBack; Config.Dhcp4Callback = HttpBootDhcp4CallBack;

View File

@ -30,18 +30,18 @@ HttpBootBuildDhcp6Options (
UINT32 Index; UINT32 Index;
Index = 0; Index = 0;
OptList[0] = (EFI_DHCP6_PACKET_OPTION *) Buffer; OptList[0] = (EFI_DHCP6_PACKET_OPTION *)Buffer;
// //
// Append client option request option // Append client option request option
// //
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO); OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
OptList[Index]->OpLen = HTONS (8); OptList[Index]->OpLen = HTONS (8);
OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *) OptList[Index]->Data; OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *)OptList[Index]->Data;
OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL); OptEnt.Oro->OpCode[0] = HTONS (DHCP6_OPT_BOOT_FILE_URL);
OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM); OptEnt.Oro->OpCode[1] = HTONS (DHCP6_OPT_BOOT_FILE_PARAM);
OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS); OptEnt.Oro->OpCode[2] = HTONS (DHCP6_OPT_DNS_SERVERS);
OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS); OptEnt.Oro->OpCode[3] = HTONS (DHCP6_OPT_VENDOR_CLASS);
Index++; Index++;
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
@ -50,7 +50,7 @@ HttpBootBuildDhcp6Options (
// //
OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI); OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
OptList[Index]->OpLen = HTONS ((UINT16)3); OptList[Index]->OpLen = HTONS ((UINT16)3);
OptEnt.Undi = (HTTP_BOOT_DHCP6_OPTION_UNDI *) OptList[Index]->Data; OptEnt.Undi = (HTTP_BOOT_DHCP6_OPTION_UNDI *)OptList[Index]->Data;
if (Private->Nii != NULL) { if (Private->Nii != NULL) {
OptEnt.Undi->Type = Private->Nii->Type; OptEnt.Undi->Type = Private->Nii->Type;
@ -69,8 +69,8 @@ HttpBootBuildDhcp6Options (
// Append client system architecture option // Append client system architecture option
// //
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH); OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH)); OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH));
OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *) OptList[Index]->Data; OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *)OptList[Index]->Data;
Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE); Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16)); CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
Index++; Index++;
@ -80,10 +80,10 @@ HttpBootBuildDhcp6Options (
// Append vendor class identify option. // Append vendor class identify option.
// //
OptList[Index]->OpCode = HTONS (DHCP6_OPT_VENDOR_CLASS); OptList[Index]->OpCode = HTONS (DHCP6_OPT_VENDOR_CLASS);
OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS)); OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS));
OptEnt.VendorClass = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *) OptList[Index]->Data; OptEnt.VendorClass = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *)OptList[Index]->Data;
OptEnt.VendorClass->Vendor = HTONL (HTTP_BOOT_DHCP6_ENTERPRISE_NUM); OptEnt.VendorClass->Vendor = HTONL (HTTP_BOOT_DHCP6_ENTERPRISE_NUM);
OptEnt.VendorClass->ClassLen = HTONS ((UINT16) sizeof (HTTP_BOOT_CLASS_ID)); OptEnt.VendorClass->ClassLen = HTONS ((UINT16)sizeof (HTTP_BOOT_CLASS_ID));
CopyMem ( CopyMem (
&OptEnt.VendorClass->ClassId, &OptEnt.VendorClass->ClassId,
DEFAULT_CLASS_ID_DATA, DEFAULT_CLASS_ID_DATA,
@ -139,25 +139,22 @@ HttpBootParseDhcp6Options (
EFI_DHCP6_PACKET_OPTION *Option; EFI_DHCP6_PACKET_OPTION *Option;
UINT32 Offset; UINT32 Offset;
Option = (EFI_DHCP6_PACKET_OPTION *) Buffer; Option = (EFI_DHCP6_PACKET_OPTION *)Buffer;
Offset = 0; Offset = 0;
// //
// OpLen and OpCode here are both stored in network order. // OpLen and OpCode here are both stored in network order.
// //
while (Offset < Length) { while (Offset < Length) {
if (NTOHS (Option->OpCode) == OptTag) { if (NTOHS (Option->OpCode) == OptTag) {
return Option; return Option;
} }
Offset += (NTOHS(Option->OpLen) + 4); Offset += (NTOHS (Option->OpLen) + 4);
Option = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset); Option = (EFI_DHCP6_PACKET_OPTION *)(Buffer + Offset);
} }
return NULL; return NULL;
} }
/** /**
@ -196,7 +193,7 @@ HttpBootParseDhcp6Packet (
ZeroMem (Cache6->OptList, sizeof (Cache6->OptList)); ZeroMem (Cache6->OptList, sizeof (Cache6->OptList));
Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option); Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option);
Offset = 0; Offset = 0;
Length = GET_DHCP6_OPTION_SIZE (Offer); Length = GET_DHCP6_OPTION_SIZE (Offer);
@ -204,7 +201,6 @@ HttpBootParseDhcp6Packet (
// OpLen and OpCode here are both stored in network order, since they are from original packet. // OpLen and OpCode here are both stored in network order, since they are from original packet.
// //
while (Offset < Length) { while (Offset < Length) {
if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) { if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) {
Options[HTTP_BOOT_DHCP6_IDX_IA_NA] = Option; Options[HTTP_BOOT_DHCP6_IDX_IA_NA] = Option;
} else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) { } else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) {
@ -221,8 +217,9 @@ HttpBootParseDhcp6Packet (
} }
Offset += (NTOHS (Option->OpLen) + 4); Offset += (NTOHS (Option->OpLen) + 4);
Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option + Offset); Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option + Offset);
} }
// //
// The offer with assigned client address is NOT a proxy offer. // The offer with assigned client address is NOT a proxy offer.
// An ia_na option, embedded with valid ia_addr option and a status_code of success. // An ia_na option, embedded with valid ia_addr option and a status_code of success.
@ -234,7 +231,7 @@ HttpBootParseDhcp6Packet (
NTOHS (Option->OpLen), NTOHS (Option->OpLen),
DHCP6_OPT_STATUS_CODE DHCP6_OPT_STATUS_CODE
); );
if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) { if (((Option != NULL) && (Option->Data[0] == 0)) || (Option == NULL)) {
IsProxyOffer = FALSE; IsProxyOffer = FALSE;
} }
} }
@ -244,9 +241,10 @@ HttpBootParseDhcp6Packet (
// //
Option = Options[HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS]; Option = Options[HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS];
if (Option != NULL && if ((Option != NULL) &&
NTOHS(Option->OpLen) >= 16 && (NTOHS (Option->OpLen) >= 16) &&
CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0) { (CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0))
{
IsHttpOffer = TRUE; IsHttpOffer = TRUE;
} }
@ -261,7 +259,7 @@ HttpBootParseDhcp6Packet (
// //
// Http offer must have a boot URI. // Http offer must have a boot URI.
// //
if (IsHttpOffer && Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL) { if (IsHttpOffer && (Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -270,8 +268,8 @@ HttpBootParseDhcp6Packet (
// //
if (IsHttpOffer) { if (IsHttpOffer) {
Status = HttpParseUrl ( Status = HttpParseUrl (
(CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data, (CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
(UINT32) AsciiStrLen ((CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data), (UINT32)AsciiStrLen ((CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data),
FALSE, FALSE,
&Cache6->UriParser &Cache6->UriParser
); );
@ -280,7 +278,7 @@ HttpBootParseDhcp6Packet (
} }
Status = HttpUrlGetIp6 ( Status = HttpUrlGetIp6 (
(CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data, (CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
Cache6->UriParser, Cache6->UriParser,
&IpAddr &IpAddr
); );
@ -304,7 +302,6 @@ HttpBootParseDhcp6Packet (
OfferType = HttpOfferTypeProxyNameUri; OfferType = HttpOfferTypeProxyNameUri;
} }
} }
} else { } else {
if (!IsProxyOffer) { if (!IsProxyOffer) {
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly; OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
@ -370,7 +367,7 @@ HttpBootCacheDhcp6Offer (
// //
// Cache the content of DHCPv6 packet firstly. // Cache the content of DHCPv6 packet firstly.
// //
Status = HttpBootCacheDhcp6Packet(Offer, RcvdOffer); Status = HttpBootCacheDhcp6Packet (Offer, RcvdOffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -434,16 +431,17 @@ HttpBootDhcp6CallBack (
(Dhcp6Event != Dhcp6RcvdAdvertise) && (Dhcp6Event != Dhcp6RcvdAdvertise) &&
(Dhcp6Event != Dhcp6SendRequest) && (Dhcp6Event != Dhcp6SendRequest) &&
(Dhcp6Event != Dhcp6RcvdReply) && (Dhcp6Event != Dhcp6RcvdReply) &&
(Dhcp6Event != Dhcp6SelectAdvertise)) { (Dhcp6Event != Dhcp6SelectAdvertise))
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }
ASSERT (Packet != NULL); ASSERT (Packet != NULL);
Private = (HTTP_BOOT_PRIVATE_DATA *) Context; Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
if (Private->HttpBootCallback != NULL && Dhcp6Event != Dhcp6SelectAdvertise) { if ((Private->HttpBootCallback != NULL) && (Dhcp6Event != Dhcp6SelectAdvertise)) {
Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply); Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
Status = Private->HttpBootCallback->Callback ( Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback, Private->HttpBootCallback,
HttpBootDhcp6, HttpBootDhcp6,
@ -455,8 +453,8 @@ HttpBootDhcp6CallBack (
return EFI_ABORTED; return EFI_ABORTED;
} }
} }
switch (Dhcp6Event) {
switch (Dhcp6Event) {
case Dhcp6RcvdAdvertise: case Dhcp6RcvdAdvertise:
Status = EFI_NOT_READY; Status = EFI_NOT_READY;
if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) { if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) {
@ -465,6 +463,7 @@ HttpBootDhcp6CallBack (
// //
break; break;
} }
if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) { if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
// //
// Cache the dhcp offers to OfferBuffer[] for select later, and record // Cache the dhcp offers to OfferBuffer[] for select later, and record
@ -473,6 +472,7 @@ HttpBootDhcp6CallBack (
// //
HttpBootCacheDhcp6Offer (Private, Packet); HttpBootCacheDhcp6Offer (Private, Packet);
} }
break; break;
case Dhcp6SelectAdvertise: case Dhcp6SelectAdvertise:
@ -491,8 +491,10 @@ HttpBootDhcp6CallBack (
if (*NewPacket == NULL) { if (*NewPacket == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (*NewPacket, SelectAd, SelectAd->Size); CopyMem (*NewPacket, SelectAd, SelectAd->Size);
} }
break; break;
default: default:
@ -562,23 +564,28 @@ HttpBootCheckRouteTable (
if (Ip6ModeData.AddressList != NULL) { if (Ip6ModeData.AddressList != NULL) {
FreePool (Ip6ModeData.AddressList); FreePool (Ip6ModeData.AddressList);
} }
if (Ip6ModeData.GroupTable != NULL) { if (Ip6ModeData.GroupTable != NULL) {
FreePool (Ip6ModeData.GroupTable); FreePool (Ip6ModeData.GroupTable);
} }
if (Ip6ModeData.RouteTable != NULL) { if (Ip6ModeData.RouteTable != NULL) {
FreePool (Ip6ModeData.RouteTable); FreePool (Ip6ModeData.RouteTable);
} }
if (Ip6ModeData.NeighborCache != NULL) { if (Ip6ModeData.NeighborCache != NULL) {
FreePool (Ip6ModeData.NeighborCache); FreePool (Ip6ModeData.NeighborCache);
} }
if (Ip6ModeData.PrefixTable != NULL) { if (Ip6ModeData.PrefixTable != NULL) {
FreePool (Ip6ModeData.PrefixTable); FreePool (Ip6ModeData.PrefixTable);
} }
if (Ip6ModeData.IcmpTypeList != NULL) { if (Ip6ModeData.IcmpTypeList != NULL) {
FreePool (Ip6ModeData.IcmpTypeList); FreePool (Ip6ModeData.IcmpTypeList);
} }
if (GatewayIsFound || RetryCount == TimeOutInSecond) { if (GatewayIsFound || (RetryCount == TimeOutInSecond)) {
break; break;
} }
@ -604,6 +611,7 @@ HttpBootCheckRouteTable (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) { while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
Ip6->Poll (Ip6); Ip6->Poll (Ip6);
} }
@ -663,13 +671,14 @@ HttpBootSetIp6Policy (
Status = Ip6Config->SetData ( Status = Ip6Config->SetData (
Ip6Config, Ip6Config,
Ip6ConfigDataTypePolicy, Ip6ConfigDataTypePolicy,
sizeof(EFI_IP6_CONFIG_POLICY), sizeof (EFI_IP6_CONFIG_POLICY),
&Policy &Policy
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -736,7 +745,7 @@ HttpBootSetIp6Gateway (
sizeof (EFI_IPv6_ADDRESS), sizeof (EFI_IPv6_ADDRESS),
&Private->GatewayIp.v6 &Private->GatewayIp.v6
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
} }
@ -756,7 +765,7 @@ HttpBootSetIp6Gateway (
EFI_STATUS EFI_STATUS
HttpBootSetIp6Address ( HttpBootSetIp6Address (
IN HTTP_BOOT_PRIVATE_DATA *Private IN HTTP_BOOT_PRIVATE_DATA *Private
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_IP6_PROTOCOL *Ip6; EFI_IP6_PROTOCOL *Ip6;
@ -811,7 +820,7 @@ HttpBootSetIp6Address (
Status = Ip6Cfg->SetData ( Status = Ip6Cfg->SetData (
Ip6Cfg, Ip6Cfg,
Ip6ConfigDataTypePolicy, Ip6ConfigDataTypePolicy,
sizeof(EFI_IP6_CONFIG_POLICY), sizeof (EFI_IP6_CONFIG_POLICY),
&Policy &Policy
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -840,7 +849,7 @@ HttpBootSetIp6Address (
Ip6ConfigDataTypeManualAddress, Ip6ConfigDataTypeManualAddress,
MappedEvt MappedEvt
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -850,7 +859,7 @@ HttpBootSetIp6Address (
sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS), sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS),
&CfgAddr &CfgAddr
); );
if (EFI_ERROR (Status) && Status != EFI_NOT_READY) { if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
goto ON_EXIT; goto ON_EXIT;
} else if (Status == EFI_NOT_READY) { } else if (Status == EFI_NOT_READY) {
// //
@ -859,6 +868,7 @@ HttpBootSetIp6Address (
while (!IsAddressOk) { while (!IsAddressOk) {
Ip6->Poll (Ip6); Ip6->Poll (Ip6);
} }
// //
// Check whether the Ip6 Address setting is successed. // Check whether the Ip6 Address setting is successed.
// //
@ -869,7 +879,7 @@ HttpBootSetIp6Address (
&DataSize, &DataSize,
NULL NULL
); );
if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) { if ((Status != EFI_BUFFER_TOO_SMALL) || (DataSize == 0)) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto ON_EXIT; goto ON_EXIT;
} }
@ -878,22 +888,24 @@ HttpBootSetIp6Address (
if (Ip6Addr == NULL) { if (Ip6Addr == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Status = Ip6Cfg->GetData ( Status = Ip6Cfg->GetData (
Ip6Cfg, Ip6Cfg,
Ip6ConfigDataTypeManualAddress, Ip6ConfigDataTypeManualAddress,
&DataSize, &DataSize,
(VOID *) Ip6Addr (VOID *)Ip6Addr
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto ON_EXIT; goto ON_EXIT;
} }
for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index ++) { for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index++) {
if (CompareMem (Ip6Addr + Index, &CfgAddr, sizeof (EFI_IPv6_ADDRESS)) == 0) { if (CompareMem (Ip6Addr + Index, &CfgAddr, sizeof (EFI_IPv6_ADDRESS)) == 0) {
break; break;
} }
} }
if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) { if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
goto ON_EXIT; goto ON_EXIT;
@ -947,7 +959,7 @@ HttpBootDhcp6Sarr (
// Build options list for the request packet. // Build options list for the request packet.
// //
OptCount = HttpBootBuildDhcp6Options (Private, OptList, Buffer); OptCount = HttpBootBuildDhcp6Options (Private, OptList, Buffer);
ASSERT (OptCount >0); ASSERT (OptCount > 0);
Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION)); Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
if (Retransmit == NULL) { if (Retransmit == NULL) {
@ -980,6 +992,7 @@ HttpBootDhcp6Sarr (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Initialize the record fields for DHCPv6 offer in private data. // Initialize the record fields for DHCPv6 offer in private data.
// //
@ -1021,12 +1034,11 @@ ON_EXIT:
if (Mode.ClientId != NULL) { if (Mode.ClientId != NULL) {
FreePool (Mode.ClientId); FreePool (Mode.ClientId);
} }
if (Mode.Ia != NULL) { if (Mode.Ia != NULL) {
FreePool (Mode.Ia); FreePool (Mode.Ia);
} }
} }
return Status; return Status;
} }

View File

@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef __EFI_HTTP_BOOT_DHCP6_H__ #ifndef __EFI_HTTP_BOOT_DHCP6_H__
#define __EFI_HTTP_BOOT_DHCP6_H__ #define __EFI_HTTP_BOOT_DHCP6_H__

View File

@ -29,8 +29,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
NULL NULL
}; };
/** /**
Check whether UNDI protocol supports IPv6. Check whether UNDI protocol supports IPv6.
@ -79,16 +77,16 @@ HttpBootCheckIpv6Support (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
Handle, Handle,
&gEfiAdapterInformationProtocolGuid, &gEfiAdapterInformationProtocolGuid,
(VOID *) &Aip (VOID *)&Aip
); );
if (EFI_ERROR (Status) || Aip == NULL) { if (EFI_ERROR (Status) || (Aip == NULL)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
InfoTypesBuffer = NULL; InfoTypesBuffer = NULL;
InfoTypeBufferCount = 0; InfoTypeBufferCount = 0;
Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) { if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
FreePool (InfoTypesBuffer); FreePool (InfoTypesBuffer);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -112,12 +110,12 @@ HttpBootCheckIpv6Support (
InfoBlock = NULL; InfoBlock = NULL;
InfoBlockSize = 0; InfoBlockSize = 0;
Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize); Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
if (EFI_ERROR (Status) || InfoBlock == NULL) { if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
FreePool (InfoBlock); FreePool (InfoBlock);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
*Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support; *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support;
FreePool (InfoBlock); FreePool (InfoBlock);
return EFI_SUCCESS; return EFI_SUCCESS;
@ -155,13 +153,12 @@ HttpBootDestroyIp4Children (
); );
} }
if (Private->Ip6Nic == NULL && Private->HttpCreated) { if ((Private->Ip6Nic == NULL) && Private->HttpCreated) {
HttpIoDestroyIo (&Private->HttpIo); HttpIoDestroyIo (&Private->HttpIo);
Private->HttpCreated = FALSE; Private->HttpCreated = FALSE;
} }
if (Private->Ip4Nic != NULL) { if (Private->Ip4Nic != NULL) {
gBS->CloseProtocol ( gBS->CloseProtocol (
Private->Controller, Private->Controller,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
@ -180,7 +177,6 @@ HttpBootDestroyIp4Children (
FreePool (Private->Ip4Nic); FreePool (Private->Ip4Nic);
Private->Ip4Nic = NULL; Private->Ip4Nic = NULL;
} }
} }
/** /**
@ -231,13 +227,12 @@ HttpBootDestroyIp6Children (
); );
} }
if (Private->Ip4Nic == NULL && Private->HttpCreated) { if ((Private->Ip4Nic == NULL) && Private->HttpCreated) {
HttpIoDestroyIo(&Private->HttpIo); HttpIoDestroyIo (&Private->HttpIo);
Private->HttpCreated = FALSE; Private->HttpCreated = FALSE;
} }
if (Private->Ip6Nic != NULL) { if (Private->Ip6Nic != NULL) {
gBS->CloseProtocol ( gBS->CloseProtocol (
Private->Controller, Private->Controller,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
@ -349,7 +344,6 @@ HttpBootIp4DxeDriverBindingSupported (
return Status; return Status;
} }
/** /**
Starts a device controller or a bus controller. Starts a device controller or a bus controller.
@ -405,14 +399,14 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id); Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
} else { } else {
FirstStart = TRUE; FirstStart = TRUE;
@ -423,6 +417,7 @@ HttpBootIp4DxeDriverBindingStart (
if (Private == NULL) { if (Private == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE; Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
Private->Controller = ControllerHandle; Private->Controller = ControllerHandle;
InitializeListHead (&Private->CacheList); InitializeListHead (&Private->CacheList);
@ -432,7 +427,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31, &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
(VOID **) &Private->Nii, (VOID **)&Private->Nii,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -447,7 +442,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
(VOID **) &Private->ParentDevicePath, (VOID **)&Private->ParentDevicePath,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -477,7 +472,6 @@ HttpBootIp4DxeDriverBindingStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
} }
if (Private->Ip4Nic != NULL) { if (Private->Ip4Nic != NULL) {
@ -492,6 +486,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR; goto ON_ERROR;
} }
Private->Ip4Nic->Private = Private; Private->Ip4Nic->Private = Private;
Private->Ip4Nic->ImageHandle = This->DriverBindingHandle; Private->Ip4Nic->ImageHandle = This->DriverBindingHandle;
Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE; Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
@ -512,7 +507,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Private->Dhcp4Child, Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid, &gEfiDhcp4ProtocolGuid,
(VOID **) &Private->Dhcp4, (VOID **)&Private->Dhcp4,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -527,7 +522,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiIp4Config2ProtocolGuid, &gEfiIp4Config2ProtocolGuid,
(VOID **) &Private->Ip4Config2, (VOID **)&Private->Ip4Config2,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -544,11 +539,12 @@ HttpBootIp4DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR; goto ON_ERROR;
} }
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH; Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv4.Header.SubType = MSG_IPv4_DP; Node->Ipv4.Header.SubType = MSG_IPv4_DP;
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH)); SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
Node->Ipv4.StaticIpAddress = FALSE; Node->Ipv4.StaticIpAddress = FALSE;
DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node); FreePool (Node);
if (DevicePath == NULL) { if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -563,10 +559,11 @@ HttpBootIp4DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR; goto ON_ERROR;
} }
Node->DevPath.Type = MESSAGING_DEVICE_PATH; Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP; Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL)); SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
Private->Ip4Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); Private->Ip4Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node); FreePool (Node);
FreePool (DevicePath); FreePool (DevicePath);
if (Private->Ip4Nic->DevicePath == NULL) { if (Private->Ip4Nic->DevicePath == NULL) {
@ -597,7 +594,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
This->DriverBindingHandle, This->DriverBindingHandle,
Private->Ip4Nic->Controller, Private->Ip4Nic->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -629,7 +626,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Stops a device controller or a bus controller. Stops a device controller or a bus controller.
@ -677,7 +673,7 @@ HttpBootIp4DxeDriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiLoadFileProtocolGuid, &gEfiLoadFileProtocolGuid,
(VOID **) &LoadFile, (VOID **)&LoadFile,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -697,7 +693,7 @@ HttpBootIp4DxeDriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -705,6 +701,7 @@ HttpBootIp4DxeDriverBindingStop (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id); Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
} else { } else {
Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile); Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
@ -715,7 +712,7 @@ HttpBootIp4DxeDriverBindingStop (
// Disable the HTTP boot function. // Disable the HTTP boot function.
// //
Status = HttpBootStop (Private); Status = HttpBootStop (Private);
if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) { if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
return Status; return Status;
} }
@ -724,7 +721,7 @@ HttpBootIp4DxeDriverBindingStop (
// //
HttpBootDestroyIp4Children (This, Private); HttpBootDestroyIp4Children (This, Private);
if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) { if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
// //
// Release the cached data. // Release the cached data.
// //
@ -741,7 +738,6 @@ HttpBootIp4DxeDriverBindingStop (
&Private->Id &Private->Id
); );
FreePool (Private); FreePool (Private);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -836,7 +832,6 @@ HttpBootIp6DxeDriverBindingSupported (
); );
return Status; return Status;
} }
/** /**
@ -895,14 +890,14 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id); Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
} else { } else {
FirstStart = TRUE; FirstStart = TRUE;
@ -913,6 +908,7 @@ HttpBootIp6DxeDriverBindingStart (
if (Private == NULL) { if (Private == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE; Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
Private->Controller = ControllerHandle; Private->Controller = ControllerHandle;
InitializeListHead (&Private->CacheList); InitializeListHead (&Private->CacheList);
@ -922,7 +918,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31, &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
(VOID **) &Private->Nii, (VOID **)&Private->Nii,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -937,7 +933,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
(VOID **) &Private->ParentDevicePath, (VOID **)&Private->ParentDevicePath,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -967,7 +963,6 @@ HttpBootIp6DxeDriverBindingStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
} }
// //
@ -999,6 +994,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR; goto ON_ERROR;
} }
Private->Ip6Nic->Private = Private; Private->Ip6Nic->Private = Private;
Private->Ip6Nic->ImageHandle = This->DriverBindingHandle; Private->Ip6Nic->ImageHandle = This->DriverBindingHandle;
Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE; Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
@ -1018,7 +1014,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Private->Dhcp6Child, Private->Dhcp6Child,
&gEfiDhcp6ProtocolGuid, &gEfiDhcp6ProtocolGuid,
(VOID **) &Private->Dhcp6, (VOID **)&Private->Dhcp6,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -1043,7 +1039,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Private->Ip6Child, Private->Ip6Child,
&gEfiIp6ProtocolGuid, &gEfiIp6ProtocolGuid,
(VOID **) &Private->Ip6, (VOID **)&Private->Ip6,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -1058,7 +1054,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiIp6ConfigProtocolGuid, &gEfiIp6ConfigProtocolGuid,
(VOID **) &Private->Ip6Config, (VOID **)&Private->Ip6Config,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -1075,12 +1071,13 @@ HttpBootIp6DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR; goto ON_ERROR;
} }
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH; Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.SubType = MSG_IPv6_DP; Node->Ipv6.Header.SubType = MSG_IPv6_DP;
Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH; Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH)); SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
DevicePath = AppendDevicePathNode(Private->ParentDevicePath, (EFI_DEVICE_PATH*) Node); DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH *)Node);
FreePool(Node); FreePool (Node);
if (DevicePath == NULL) { if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR; goto ON_ERROR;
@ -1094,10 +1091,11 @@ HttpBootIp6DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR; goto ON_ERROR;
} }
Node->DevPath.Type = MESSAGING_DEVICE_PATH; Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP; Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL)); SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
Private->Ip6Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); Private->Ip6Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node); FreePool (Node);
FreePool (DevicePath); FreePool (DevicePath);
if (Private->Ip6Nic->DevicePath == NULL) { if (Private->Ip6Nic->DevicePath == NULL) {
@ -1128,7 +1126,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
This->DriverBindingHandle, This->DriverBindingHandle,
Private->Ip6Nic->Controller, Private->Ip6Nic->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -1149,7 +1147,7 @@ ON_ERROR:
); );
} }
HttpBootDestroyIp6Children(This, Private); HttpBootDestroyIp6Children (This, Private);
HttpBootConfigFormUnload (Private); HttpBootConfigFormUnload (Private);
if (FirstStart) { if (FirstStart) {
@ -1207,7 +1205,7 @@ HttpBootIp6DxeDriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiLoadFileProtocolGuid, &gEfiLoadFileProtocolGuid,
(VOID **) &LoadFile, (VOID **)&LoadFile,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -1227,7 +1225,7 @@ HttpBootIp6DxeDriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -1235,6 +1233,7 @@ HttpBootIp6DxeDriverBindingStop (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id); Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
} else { } else {
Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile); Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
@ -1245,7 +1244,7 @@ HttpBootIp6DxeDriverBindingStop (
// Disable the HTTP boot function. // Disable the HTTP boot function.
// //
Status = HttpBootStop (Private); Status = HttpBootStop (Private);
if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) { if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
return Status; return Status;
} }
@ -1254,7 +1253,7 @@ HttpBootIp6DxeDriverBindingStop (
// //
HttpBootDestroyIp6Children (This, Private); HttpBootDestroyIp6Children (This, Private);
if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) { if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
// //
// Release the cached data. // Release the cached data.
// //
@ -1271,11 +1270,11 @@ HttpBootIp6DxeDriverBindingStop (
&Private->Id &Private->Id
); );
FreePool (Private); FreePool (Private);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This is the declaration of an EFI image entry point. This entry point is This is the declaration of an EFI image entry point. This entry point is
the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
@ -1321,12 +1320,12 @@ HttpBootDxeDriverEntryPoint (
&gHttpBootDxeComponentName2 &gHttpBootDxeComponentName2
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EfiLibUninstallDriverBindingComponentName2( EfiLibUninstallDriverBindingComponentName2 (
&gHttpBootIp4DxeDriverBinding, &gHttpBootIp4DxeDriverBinding,
&gHttpBootDxeComponentName, &gHttpBootDxeComponentName,
&gHttpBootDxeComponentName2 &gHttpBootDxeComponentName2
); );
} }
return Status; return Status;
} }

View File

@ -167,7 +167,6 @@ struct _HTTP_BOOT_PRIVATE_DATA {
EFI_DHCP6_PROTOCOL *Dhcp6; EFI_DHCP6_PROTOCOL *Dhcp6;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
// //
// Produced protocol // Produced protocol
// //
@ -522,4 +521,5 @@ HttpBootIp6DxeDriverBindingStop (
IN UINTN NumberOfChildren, IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
); );
#endif #endif

View File

@ -38,10 +38,9 @@ HttpBootInstallCallback (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
ControllerHandle, ControllerHandle,
&gEfiHttpBootCallbackProtocolGuid, &gEfiHttpBootCallbackProtocolGuid,
(VOID **) &Private->HttpBootCallback (VOID **)&Private->HttpBootCallback
); );
if (Status == EFI_UNSUPPORTED) { if (Status == EFI_UNSUPPORTED) {
CopyMem ( CopyMem (
&Private->LoadFileCallback, &Private->LoadFileCallback,
&gHttpBootDxeHttpBootCallback, &gHttpBootDxeHttpBootCallback,
@ -60,6 +59,7 @@ HttpBootInstallCallback (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Private->HttpBootCallback = &Private->LoadFileCallback; Private->HttpBootCallback = &Private->LoadFileCallback;
} }
@ -119,7 +119,7 @@ HttpBootStart (
Uri = NULL; Uri = NULL;
if (Private == NULL || FilePath == NULL) { if ((Private == NULL) || (FilePath == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -143,7 +143,8 @@ HttpBootStart (
// recorded before. // recorded before.
// //
if ((UsingIpv6 != Private->UsingIpv6) || if ((UsingIpv6 != Private->UsingIpv6) ||
((Uri != NULL) && (AsciiStrCmp (Private->BootFileUri, Uri) != 0))) { ((Uri != NULL) && (AsciiStrCmp (Private->BootFileUri, Uri) != 0)))
{
// //
// Restart is required, first stop then continue this start function. // Restart is required, first stop then continue this start function.
// //
@ -152,6 +153,7 @@ HttpBootStart (
if (Uri != NULL) { if (Uri != NULL) {
FreePool (Uri); FreePool (Uri);
} }
return Status; return Status;
} }
} else { } else {
@ -161,6 +163,7 @@ HttpBootStart (
if (Uri != NULL) { if (Uri != NULL) {
FreePool (Uri); FreePool (Uri);
} }
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
} }
@ -168,14 +171,15 @@ HttpBootStart (
// //
// Detect whether using ipv6 or not, and set it to the private data. // Detect whether using ipv6 or not, and set it to the private data.
// //
if (UsingIpv6 && Private->Ip6Nic != NULL) { if (UsingIpv6 && (Private->Ip6Nic != NULL)) {
Private->UsingIpv6 = TRUE; Private->UsingIpv6 = TRUE;
} else if (!UsingIpv6 && Private->Ip4Nic != NULL) { } else if (!UsingIpv6 && (Private->Ip4Nic != NULL)) {
Private->UsingIpv6 = FALSE; Private->UsingIpv6 = FALSE;
} else { } else {
if (Uri != NULL) { if (Uri != NULL) {
FreePool (Uri); FreePool (Uri);
} }
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -186,7 +190,7 @@ HttpBootStart (
if (Private->FilePathUri != NULL) { if (Private->FilePathUri != NULL) {
Status = HttpParseUrl ( Status = HttpParseUrl (
Private->FilePathUri, Private->FilePathUri,
(UINT32) AsciiStrLen (Private->FilePathUri), (UINT32)AsciiStrLen (Private->FilePathUri),
FALSE, FALSE,
&Private->FilePathUriParser &Private->FilePathUriParser
); );
@ -219,6 +223,7 @@ HttpBootStart (
return Status; return Status;
} }
} }
Private->Started = TRUE; Private->Started = TRUE;
Print (L"\n>>Start HTTP Boot over IPv%d", Private->UsingIpv6 ? 6 : 4); Print (L"\n>>Start HTTP Boot over IPv%d", Private->UsingIpv6 ? 6 : 4);
@ -302,11 +307,11 @@ HttpBootLoadFile (
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (Private == NULL || ImageType == NULL || BufferSize == NULL ) { if ((Private == NULL) || (ImageType == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (*BufferSize != 0 && Buffer == NULL) { if ((*BufferSize != 0) && (Buffer == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -315,7 +320,7 @@ HttpBootLoadFile (
} }
Status = HttpBootInstallCallback (Private); Status = HttpBootInstallCallback (Private);
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -355,7 +360,7 @@ HttpBootLoadFile (
NULL, NULL,
&Private->ImageType &Private->ImageType
); );
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
// //
// Failed to get file size by HEAD method, may be trunked encoding, try HTTP GET method. // Failed to get file size by HEAD method, may be trunked encoding, try HTTP GET method.
// //
@ -367,7 +372,7 @@ HttpBootLoadFile (
NULL, NULL,
&Private->ImageType &Private->ImageType
); );
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
AsciiPrint ("\n Error: Could not retrieve NBP file size from HTTP server.\n"); AsciiPrint ("\n Error: Could not retrieve NBP file size from HTTP server.\n");
goto ON_EXIT; goto ON_EXIT;
} }
@ -398,7 +403,7 @@ ON_EXIT:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_ACCESS_DENIED) { if (Status == EFI_ACCESS_DENIED) {
AsciiPrint ("\n Error: Could not establish connection with HTTP server.\n"); AsciiPrint ("\n Error: Could not establish connection with HTTP server.\n");
} else if (Status == EFI_BUFFER_TOO_SMALL && Buffer != NULL) { } else if ((Status == EFI_BUFFER_TOO_SMALL) && (Buffer != NULL)) {
AsciiPrint ("\n Error: Buffer size is smaller than the requested file.\n"); AsciiPrint ("\n Error: Buffer size is smaller than the requested file.\n");
} else if (Status == EFI_OUT_OF_RESOURCES) { } else if (Status == EFI_OUT_OF_RESOURCES) {
AsciiPrint ("\n Error: Could not allocate I/O buffers.\n"); AsciiPrint ("\n Error: Could not allocate I/O buffers.\n");
@ -489,7 +494,7 @@ HttpBootStop (
Private->DnsServerIp = NULL; Private->DnsServerIp = NULL;
} }
if (Private->FilePathUri!= NULL) { if (Private->FilePathUri != NULL) {
FreePool (Private->FilePathUri); FreePool (Private->FilePathUri);
HttpUrlFreeParser (Private->FilePathUriParser); HttpUrlFreeParser (Private->FilePathUriParser);
Private->FilePathUri = NULL; Private->FilePathUri = NULL;
@ -554,7 +559,7 @@ HttpBootDxeLoadFile (
EFI_STATUS Status; EFI_STATUS Status;
HTTP_BOOT_IMAGE_TYPE ImageType; HTTP_BOOT_IMAGE_TYPE ImageType;
if (This == NULL || BufferSize == NULL || FilePath == NULL) { if ((This == NULL) || (BufferSize == NULL) || (FilePath == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -590,7 +595,7 @@ HttpBootDxeLoadFile (
// Initialize HTTP boot. // Initialize HTTP boot.
// //
Status = HttpBootStart (Private, UsingIpv6, FilePath); Status = HttpBootStart (Private, UsingIpv6, FilePath);
if (Status != EFI_SUCCESS && Status != EFI_ALREADY_STARTED) { if ((Status != EFI_SUCCESS) && (Status != EFI_ALREADY_STARTED)) {
return Status; return Status;
} }
@ -600,18 +605,19 @@ HttpBootDxeLoadFile (
ImageType = ImageTypeMax; ImageType = ImageTypeMax;
Status = HttpBootLoadFile (Private, BufferSize, Buffer, &ImageType); Status = HttpBootLoadFile (Private, BufferSize, Buffer, &ImageType);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_BUFFER_TOO_SMALL && (ImageType == ImageTypeVirtualCd || ImageType == ImageTypeVirtualDisk)) { if ((Status == EFI_BUFFER_TOO_SMALL) && ((ImageType == ImageTypeVirtualCd) || (ImageType == ImageTypeVirtualDisk))) {
Status = EFI_WARN_FILE_SYSTEM; Status = EFI_WARN_FILE_SYSTEM;
} else if (Status != EFI_BUFFER_TOO_SMALL) { } else if (Status != EFI_BUFFER_TOO_SMALL) {
HttpBootStop (Private); HttpBootStop (Private);
} }
return Status; return Status;
} }
// //
// Register the RAM Disk to the system if needed. // Register the RAM Disk to the system if needed.
// //
if (ImageType == ImageTypeVirtualCd || ImageType == ImageTypeVirtualDisk) { if ((ImageType == ImageTypeVirtualCd) || (ImageType == ImageTypeVirtualDisk)) {
Status = HttpBootRegisterRamDisk (Private, *BufferSize, Buffer, ImageType); Status = HttpBootRegisterRamDisk (Private, *BufferSize, Buffer, ImageType);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = EFI_WARN_FILE_SYSTEM; Status = EFI_WARN_FILE_SYSTEM;
@ -671,7 +677,7 @@ HttpBootCallback (
HTTP_BOOT_PRIVATE_DATA *Private; HTTP_BOOT_PRIVATE_DATA *Private;
UINT32 Percentage; UINT32 Percentage;
Private = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_PROTOCOL(This); Private = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_PROTOCOL (This);
switch (DataType) { switch (DataType) {
case HttpBootDhcp4: case HttpBootDhcp4:
@ -681,17 +687,19 @@ HttpBootCallback (
case HttpBootHttpRequest: case HttpBootHttpRequest:
if (Data != NULL) { if (Data != NULL) {
HttpMessage = (EFI_HTTP_MESSAGE *) Data; HttpMessage = (EFI_HTTP_MESSAGE *)Data;
if (HttpMessage->Data.Request->Method == HttpMethodGet && if ((HttpMessage->Data.Request->Method == HttpMethodGet) &&
HttpMessage->Data.Request->Url != NULL) { (HttpMessage->Data.Request->Url != NULL))
{
Print (L"\n URI: %s\n", HttpMessage->Data.Request->Url); Print (L"\n URI: %s\n", HttpMessage->Data.Request->Url);
} }
} }
break; break;
case HttpBootHttpResponse: case HttpBootHttpResponse:
if (Data != NULL) { if (Data != NULL) {
HttpMessage = (EFI_HTTP_MESSAGE *) Data; HttpMessage = (EFI_HTTP_MESSAGE *)Data;
if (HttpMessage->Data.Response != NULL) { if (HttpMessage->Data.Response != NULL) {
if (HttpBootIsHttpRedirectStatusCode (HttpMessage->Data.Response->StatusCode)) { if (HttpBootIsHttpRedirectStatusCode (HttpMessage->Data.Response->StatusCode)) {
@ -708,6 +716,7 @@ HttpBootCallback (
if (HttpHeader != NULL) { if (HttpHeader != NULL) {
Print (L"\n HTTP ERROR: Resource Redirected.\n New Location: %a\n", HttpHeader->FieldValue); Print (L"\n HTTP ERROR: Resource Redirected.\n New Location: %a\n", HttpHeader->FieldValue);
} }
break; break;
} }
} }
@ -723,6 +732,7 @@ HttpBootCallback (
Private->Percentage = 0; Private->Percentage = 0;
} }
} }
break; break;
case HttpBootHttpEntityBody: case HttpBootHttpEntityBody:
@ -734,8 +744,9 @@ HttpBootCallback (
if (Private->ReceivedSize == 0) { if (Private->ReceivedSize == 0) {
Print (L" File Size: %lu Bytes\n", Private->FileSize); Print (L" File Size: %lu Bytes\n", Private->FileSize);
} }
Private->ReceivedSize += DataLength; Private->ReceivedSize += DataLength;
Percentage = (UINT32) DivU64x64Remainder (MultU64x32 (Private->ReceivedSize, 100), Private->FileSize, NULL); Percentage = (UINT32)DivU64x64Remainder (MultU64x32 (Private->ReceivedSize, 100), Private->FileSize, NULL);
if (Private->Percentage != Percentage) { if (Private->Percentage != Percentage) {
Private->Percentage = Percentage; Private->Percentage = Percentage;
Print (L"\r Downloading...%d%%", Percentage); Print (L"\r Downloading...%d%%", Percentage);
@ -749,11 +760,12 @@ HttpBootCallback (
Print (L"\r Downloading...%lu Bytes", Private->ReceivedSize); Print (L"\r Downloading...%lu Bytes", Private->ReceivedSize);
} }
} }
break; break;
default: default:
break; break;
}; }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -5,6 +5,7 @@ Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef __EFI_HTTP_BOOT_IMPL_H__ #ifndef __EFI_HTTP_BOOT_IMPL_H__
#define __EFI_HTTP_BOOT_IMPL_H__ #define __EFI_HTTP_BOOT_IMPL_H__

View File

@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "HttpBootDxe.h" #include "HttpBootDxe.h"
/** /**
Get the Nic handle using any child handle in the IPv4 stack. Get the Nic handle using any child handle in the IPv4 stack.
@ -52,6 +51,7 @@ HttpBootGetNicByIp6Children (
) )
{ {
EFI_HANDLE NicHandle; EFI_HANDLE NicHandle;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiHttpProtocolGuid); NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiHttpProtocolGuid);
if (NicHandle == NULL) { if (NicHandle == NULL) {
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid); NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid);
@ -80,10 +80,10 @@ HttpBootUintnToAscDecWithFormat (
{ {
UINTN Remainder; UINTN Remainder;
for (; Length > 0; Length--) { for ( ; Length > 0; Length--) {
Remainder = Number % 10; Remainder = Number % 10;
Number /= 10; Number /= 10;
Buffer[Length - 1] = (UINT8) ('0' + Remainder); Buffer[Length - 1] = (UINT8)('0' + Remainder);
} }
} }
@ -122,17 +122,19 @@ HttpBootShowIp6Addr (
UINTN Index; UINTN Index;
for (Index = 0; Index < 16; Index++) { for (Index = 0; Index < 16; Index++) {
if (Ip->Addr[Index] != 0) { if (Ip->Addr[Index] != 0) {
AsciiPrint ("%x", Ip->Addr[Index]); AsciiPrint ("%x", Ip->Addr[Index]);
} }
Index++; Index++;
if (Index > 15) { if (Index > 15) {
return; return;
} }
if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) { if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
AsciiPrint ("0"); AsciiPrint ("0");
} }
AsciiPrint ("%x", Ip->Addr[Index]); AsciiPrint ("%x", Ip->Addr[Index]);
if (Index < 15) { if (Index < 15) {
AsciiPrint (":"); AsciiPrint (":");
@ -282,8 +284,7 @@ HttpBootPrintErrorMessage (
AsciiPrint ("\n Server Error: 505 HTTP Version Not Supported"); AsciiPrint ("\n Server Error: 505 HTTP Version Not Supported");
break; break;
default: ; default:;
} }
} }
@ -301,7 +302,7 @@ HttpBootCommonNotify (
IN VOID *Context IN VOID *Context
) )
{ {
*((BOOLEAN *) Context) = TRUE; *((BOOLEAN *)Context) = TRUE;
} }
/** /**
@ -342,7 +343,7 @@ HttpBootDns (
// //
// Get DNS server list from EFI IPv6 Configuration protocol. // Get DNS server list from EFI IPv6 Configuration protocol.
// //
Status = gBS->HandleProtocol (Private->Controller, &gEfiIp6ConfigProtocolGuid, (VOID **) &Ip6Config); Status = gBS->HandleProtocol (Private->Controller, &gEfiIp6ConfigProtocolGuid, (VOID **)&Ip6Config);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Get the required size. // Get the required size.
@ -364,6 +365,7 @@ HttpBootDns (
} }
} }
} }
// //
// Create a DNSv6 child instance and get the protocol. // Create a DNSv6 child instance and get the protocol.
// //
@ -380,7 +382,7 @@ HttpBootDns (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dns6Handle, Dns6Handle,
&gEfiDns6ProtocolGuid, &gEfiDns6ProtocolGuid,
(VOID **) &Dns6, (VOID **)&Dns6,
Private->Ip6Nic->ImageHandle, Private->Ip6Nic->ImageHandle,
Private->Controller, Private->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -397,7 +399,7 @@ HttpBootDns (
Dns6ConfigData.DnsServerList = DnsServerList; Dns6ConfigData.DnsServerList = DnsServerList;
Dns6ConfigData.EnableDnsCache = TRUE; Dns6ConfigData.EnableDnsCache = TRUE;
Dns6ConfigData.Protocol = EFI_IP_PROTO_UDP; Dns6ConfigData.Protocol = EFI_IP_PROTO_UDP;
IP6_COPY_ADDRESS (&Dns6ConfigData.StationIp,&Private->StationIp.v6); IP6_COPY_ADDRESS (&Dns6ConfigData.StationIp, &Private->StationIp.v6);
Status = Dns6->Configure ( Status = Dns6->Configure (
Dns6, Dns6,
&Dns6ConfigData &Dns6ConfigData
@ -443,25 +445,30 @@ HttpBootDns (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Exit; 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; Status = EFI_DEVICE_ERROR;
goto Exit; goto Exit;
} }
// //
// We just return the first IPv6 address from DNS protocol. // We just return the first IPv6 address from DNS protocol.
// //
IP6_COPY_ADDRESS (IpAddress, Token.RspData.H2AData->IpList); IP6_COPY_ADDRESS (IpAddress, Token.RspData.H2AData->IpList);
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
Exit: Exit:
if (Token.Event != NULL) { if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event); gBS->CloseEvent (Token.Event);
} }
if (Token.RspData.H2AData != NULL) { if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) { if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList); FreePool (Token.RspData.H2AData->IpList);
} }
FreePool (Token.RspData.H2AData); FreePool (Token.RspData.H2AData);
} }
@ -519,7 +526,8 @@ HttpBootCheckUriScheme (
if (Uri[Index] == ':') { if (Uri[Index] == ':') {
break; break;
} }
if (Uri[Index] >= 'A' && Uri[Index] <= 'Z') {
if ((Uri[Index] >= 'A') && (Uri[Index] <= 'Z')) {
Uri[Index] -= (CHAR8)('A' - 'a'); Uri[Index] -= (CHAR8)('A' - 'a');
} }
} }
@ -578,28 +586,32 @@ HttpBootParseFilePath (
TempDevicePath = FilePath; TempDevicePath = FilePath;
while (!IsDevicePathEnd (TempDevicePath)) { while (!IsDevicePathEnd (TempDevicePath)) {
if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) && if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (TempDevicePath) == MSG_URI_DP)) { (DevicePathSubType (TempDevicePath) == MSG_URI_DP))
UriDevicePath = (URI_DEVICE_PATH*) TempDevicePath; {
UriDevicePath = (URI_DEVICE_PATH *)TempDevicePath;
// //
// UEFI Spec doesn't require the URI to be a NULL-terminated string // UEFI Spec doesn't require the URI to be a NULL-terminated string
// So we allocate a new buffer and always append a '\0' to it. // So we allocate a new buffer and always append a '\0' to it.
// //
UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL); UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);
if (UriStrLength == 0) { if (UriStrLength == 0) {
// //
// return a NULL UriAddress if it's a empty URI device path node. // return a NULL UriAddress if it's a empty URI device path node.
// //
break; break;
} }
Uri = AllocatePool (UriStrLength + 1); Uri = AllocatePool (UriStrLength + 1);
if (Uri == NULL) { if (Uri == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (Uri, UriDevicePath->Uri, DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL));
Uri[DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL)] = '\0'; CopyMem (Uri, UriDevicePath->Uri, DevicePathNodeLength (UriDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL));
Uri[DevicePathNodeLength (UriDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL)] = '\0';
*UriAddress = Uri; *UriAddress = Uri;
} }
TempDevicePath = NextDevicePathNode (TempDevicePath); TempDevicePath = NextDevicePathNode (TempDevicePath);
} }
@ -637,11 +649,11 @@ HttpBootCheckImageType (
CHAR8 *FilePath; CHAR8 *FilePath;
CHAR8 *FilePost; CHAR8 *FilePost;
if (Uri == NULL || UriParser == NULL || ImageType == NULL) { if ((Uri == NULL) || (UriParser == NULL) || (ImageType == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (HeaderCount != 0 && Headers == NULL) { if ((HeaderCount != 0) && (Headers == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -727,7 +739,7 @@ HttpBootRegisterRamDisk (
ASSERT (Buffer != NULL); ASSERT (Buffer != NULL);
ASSERT (BufferSize != 0); ASSERT (BufferSize != 0);
Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID**) &RamDisk); Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID **)&RamDisk);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "HTTP Boot: Couldn't find the RAM Disk protocol - %r\n", Status)); DEBUG ((DEBUG_ERROR, "HTTP Boot: Couldn't find the RAM Disk protocol - %r\n", Status));
return Status; return Status;
@ -768,10 +780,11 @@ HttpBootIsHttpRedirectStatusCode (
IN EFI_HTTP_STATUS_CODE StatusCode IN EFI_HTTP_STATUS_CODE StatusCode
) )
{ {
if (StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY || if ((StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY) ||
StatusCode == HTTP_STATUS_302_FOUND || (StatusCode == HTTP_STATUS_302_FOUND) ||
StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT || (StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT) ||
StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT) { (StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT))
{
return TRUE; return TRUE;
} }

View File

@ -53,7 +53,6 @@ HttpBootUintnToAscDecWithFormat (
IN INTN Length IN INTN Length
); );
/** /**
This function is to display the IPv4 address. This function is to display the IPv4 address.
@ -212,4 +211,5 @@ BOOLEAN
HttpBootIsHttpRedirectStatusCode ( HttpBootIsHttpRedirectStatusCode (
IN EFI_HTTP_STATUS_CODE StatusCode IN EFI_HTTP_STATUS_CODE StatusCode
); );
#endif #endif

View File

@ -15,8 +15,8 @@
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME_PROTOCOL gHttpDxeComponentName = { EFI_COMPONENT_NAME_PROTOCOL gHttpDxeComponentName = {
(EFI_COMPONENT_NAME_GET_DRIVER_NAME) HttpDxeComponentNameGetDriverName, (EFI_COMPONENT_NAME_GET_DRIVER_NAME)HttpDxeComponentNameGetDriverName,
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) HttpDxeComponentNameGetControllerName, (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)HttpDxeComponentNameGetControllerName,
"eng" "eng"
}; };
@ -35,7 +35,7 @@ EFI_COMPONENT_NAME2_PROTOCOL gHttpDxeComponentName2 = {
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_UNICODE_STRING_TABLE mHttpDxeDriverNameTable[] = { EFI_UNICODE_STRING_TABLE mHttpDxeDriverNameTable[] = {
{ "eng;en", (CHAR16 *) L"HttpDxe" }, { "eng;en", (CHAR16 *)L"HttpDxe" },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -40,7 +40,6 @@ HttpDns4 (
EFI_IPv4_ADDRESS *DnsServerList; EFI_IPv4_ADDRESS *DnsServerList;
UINTN DataSize; UINTN DataSize;
Service = HttpInstance->Service; Service = HttpInstance->Service;
ASSERT (Service != NULL); ASSERT (Service != NULL);
@ -51,7 +50,7 @@ HttpDns4 (
// //
// Get DNS server list from EFI IPv4 Configuration II protocol. // Get DNS server list from EFI IPv4 Configuration II protocol.
// //
Status = gBS->HandleProtocol (Service->ControllerHandle, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); Status = gBS->HandleProtocol (Service->ControllerHandle, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Get the required size. // Get the required size.
@ -93,7 +92,7 @@ HttpDns4 (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dns4Handle, Dns4Handle,
&gEfiDns4ProtocolGuid, &gEfiDns4ProtocolGuid,
(VOID **) &Dns4, (VOID **)&Dns4,
Service->Ip4DriverBindingHandle, Service->Ip4DriverBindingHandle,
Service->ControllerHandle, Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -113,6 +112,7 @@ HttpDns4 (
IP4_COPY_ADDRESS (&Dns4CfgData.StationIp, &HttpInstance->IPv4Node.LocalAddress); IP4_COPY_ADDRESS (&Dns4CfgData.StationIp, &HttpInstance->IPv4Node.LocalAddress);
IP4_COPY_ADDRESS (&Dns4CfgData.SubnetMask, &HttpInstance->IPv4Node.LocalSubnet); IP4_COPY_ADDRESS (&Dns4CfgData.SubnetMask, &HttpInstance->IPv4Node.LocalSubnet);
} }
Dns4CfgData.EnableDnsCache = TRUE; Dns4CfgData.EnableDnsCache = TRUE;
Dns4CfgData.Protocol = EFI_IP_PROTO_UDP; Dns4CfgData.Protocol = EFI_IP_PROTO_UDP;
Status = Dns4->Configure ( Status = Dns4->Configure (
@ -161,10 +161,12 @@ HttpDns4 (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Exit; 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; Status = EFI_DEVICE_ERROR;
goto Exit; goto Exit;
} }
// //
// We just return the first IP address from DNS protocol. // We just return the first IP address from DNS protocol.
// //
@ -177,10 +179,12 @@ Exit:
if (Token.Event != NULL) { if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event); gBS->CloseEvent (Token.Event);
} }
if (Token.RspData.H2AData != NULL) { if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) { if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList); FreePool (Token.RspData.H2AData->IpList);
} }
FreePool (Token.RspData.H2AData); FreePool (Token.RspData.H2AData);
} }
@ -243,7 +247,6 @@ HttpDns6 (
UINTN DataSize; UINTN DataSize;
BOOLEAN IsDone; BOOLEAN IsDone;
Service = HttpInstance->Service; Service = HttpInstance->Service;
ASSERT (Service != NULL); ASSERT (Service != NULL);
@ -256,7 +259,7 @@ HttpDns6 (
// //
// Get DNS server list from EFI IPv6 Configuration protocol. // Get DNS server list from EFI IPv6 Configuration protocol.
// //
Status = gBS->HandleProtocol (Service->ControllerHandle, &gEfiIp6ConfigProtocolGuid, (VOID **) &Ip6Config); Status = gBS->HandleProtocol (Service->ControllerHandle, &gEfiIp6ConfigProtocolGuid, (VOID **)&Ip6Config);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Get the required size. // Get the required size.
@ -295,7 +298,7 @@ HttpDns6 (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dns6Handle, Dns6Handle,
&gEfiDns6ProtocolGuid, &gEfiDns6ProtocolGuid,
(VOID **) &Dns6, (VOID **)&Dns6,
Service->Ip6DriverBindingHandle, Service->Ip6DriverBindingHandle,
Service->ControllerHandle, Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -358,10 +361,12 @@ HttpDns6 (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Exit; 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; Status = EFI_DEVICE_ERROR;
goto Exit; goto Exit;
} }
// //
// We just return the first IPv6 address from DNS protocol. // We just return the first IPv6 address from DNS protocol.
// //
@ -374,10 +379,12 @@ Exit:
if (Token.Event != NULL) { if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event); gBS->CloseEvent (Token.Event);
} }
if (Token.RspData.H2AData != NULL) { if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) { if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList); FreePool (Token.RspData.H2AData->IpList);
} }
FreePool (Token.RspData.H2AData); FreePool (Token.RspData.H2AData);
} }

View File

@ -33,7 +33,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {
NULL NULL
}; };
/** /**
Create a HTTP driver service binding private instance. Create a HTTP driver service binding private instance.
@ -86,10 +85,10 @@ HttpCleanService (
IN BOOLEAN UsingIpv6 IN BOOLEAN UsingIpv6
) )
{ {
if (HttpService == NULL) { if (HttpService == NULL) {
return ; return;
} }
if (!UsingIpv6) { if (!UsingIpv6) {
if (HttpService->Tcp4ChildHandle != NULL) { if (HttpService->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol ( gBS->CloseProtocol (
@ -127,7 +126,6 @@ HttpCleanService (
HttpService->Tcp6ChildHandle = NULL; HttpService->Tcp6ChildHandle = NULL;
} }
} }
} }
/** /**
@ -148,13 +146,13 @@ HttpUtilitiesInstalledCallback (
gBS->LocateProtocol ( gBS->LocateProtocol (
&gEfiHttpUtilitiesProtocolGuid, &gEfiHttpUtilitiesProtocolGuid,
NULL, NULL,
(VOID **) &mHttpUtilities (VOID **)&mHttpUtilities
); );
// //
// Close the event if Http utilities protocol is located. // Close the event if Http utilities protocol is located.
// //
if (mHttpUtilities != NULL && Event != NULL) { if ((mHttpUtilities != NULL) && (Event != NULL)) {
gBS->CloseEvent (Event); gBS->CloseEvent (Event);
} }
} }
@ -184,7 +182,7 @@ HttpDxeDriverEntryPoint (
gBS->LocateProtocol ( gBS->LocateProtocol (
&gEfiHttpUtilitiesProtocolGuid, &gEfiHttpUtilitiesProtocolGuid,
NULL, NULL,
(VOID **) &mHttpUtilities (VOID **)&mHttpUtilities
); );
if (mHttpUtilities == NULL) { if (mHttpUtilities == NULL) {
@ -230,6 +228,7 @@ HttpDxeDriverEntryPoint (
&gHttpDxeComponentName2 &gHttpDxeComponentName2
); );
} }
return Status; return Status;
} }
@ -256,14 +255,14 @@ HttpDestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren; UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer; EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) { if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
HttpInstance = NET_LIST_USER_STRUCT_S (Entry, HTTP_PROTOCOL, Link, HTTP_PROTOCOL_SIGNATURE); HttpInstance = NET_LIST_USER_STRUCT_S (Entry, HTTP_PROTOCOL, Link, HTTP_PROTOCOL_SIGNATURE);
ServiceBinding = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; ServiceBinding = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
NumberOfChildren = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; NumberOfChildren = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
ChildHandleBuffer = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; ChildHandleBuffer = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (HttpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) { if (!NetIsInHandleBuffer (HttpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -359,7 +358,7 @@ HttpDxeStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiHttpServiceBindingProtocolGuid, &gEfiHttpServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -420,11 +419,9 @@ HttpDxeStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
} else { } else {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
} else { } else {
UsingIpv6 = TRUE; UsingIpv6 = TRUE;
HttpService->Ip6DriverBindingHandle = This->DriverBindingHandle; HttpService->Ip6DriverBindingHandle = This->DriverBindingHandle;
@ -456,11 +453,9 @@ HttpDxeStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
} else { } else {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -469,14 +464,12 @@ ON_ERROR:
if (HttpService != NULL) { if (HttpService != NULL) {
HttpCleanService (HttpService, UsingIpv6); HttpCleanService (HttpService, UsingIpv6);
if (HttpService->Tcp4ChildHandle == NULL && HttpService->Tcp6ChildHandle == NULL) { if ((HttpService->Tcp4ChildHandle == NULL) && (HttpService->Tcp6ChildHandle == NULL)) {
FreePool (HttpService); FreePool (HttpService);
} }
} }
return Status; return Status;
} }
/** /**
@ -533,14 +526,13 @@ HttpDxeStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiHttpServiceBindingProtocolGuid, &gEfiHttpServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
NicHandle, NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding); HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);
if (NumberOfChildren != 0) { if (NumberOfChildren != 0) {
@ -558,10 +550,9 @@ HttpDxeStop (
NULL NULL
); );
} else { } else {
HttpCleanService (HttpService, UsingIpv6); HttpCleanService (HttpService, UsingIpv6);
if (HttpService->Tcp4ChildHandle == NULL && HttpService->Tcp6ChildHandle == NULL) { if ((HttpService->Tcp4ChildHandle == NULL) && (HttpService->Tcp6ChildHandle == NULL)) {
gBS->UninstallProtocolInterface ( gBS->UninstallProtocolInterface (
NicHandle, NicHandle,
&gEfiHttpServiceBindingProtocolGuid, &gEfiHttpServiceBindingProtocolGuid,
@ -569,12 +560,12 @@ HttpDxeStop (
); );
FreePool (HttpService); FreePool (HttpService);
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
} }
return Status; return Status;
} }
/** /**
@ -787,7 +778,6 @@ HttpDxeIp6DriverBindingSupported (
RemainingDevicePath, RemainingDevicePath,
IP_VERSION_6 IP_VERSION_6
); );
} }
/** /**
@ -885,6 +875,7 @@ HttpDxeIp6DriverBindingStop (
IP_VERSION_6 IP_VERSION_6
); );
} }
/** /**
Creates a child handle and installs a protocol. Creates a child handle and installs a protocol.
@ -1008,7 +999,7 @@ HttpServiceBindingDestroyChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiHttpProtocolGuid, &gEfiHttpProtocolGuid,
(VOID **) &Http, (VOID **)&Http,
NULL, NULL,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL

View File

@ -61,7 +61,8 @@ EfiHttpGetModeData (
HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This); HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
if ((HttpConfigData->AccessPoint.IPv6Node == NULL) || if ((HttpConfigData->AccessPoint.IPv6Node == NULL) ||
(HttpConfigData->AccessPoint.IPv4Node == NULL)) { (HttpConfigData->AccessPoint.IPv4Node == NULL))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -134,10 +135,11 @@ EfiHttpConfigure (
// //
// Check input parameters. // Check input parameters.
// //
if (This == NULL || if ((This == NULL) ||
(HttpConfigData != NULL && ((HttpConfigData != NULL) &&
((HttpConfigData->LocalAddressIsIPv6 && HttpConfigData->AccessPoint.IPv6Node == NULL) || ((HttpConfigData->LocalAddressIsIPv6 && (HttpConfigData->AccessPoint.IPv6Node == NULL)) ||
(!HttpConfigData->LocalAddressIsIPv6 && HttpConfigData->AccessPoint.IPv4Node == NULL)))) { (!HttpConfigData->LocalAddressIsIPv6 && (HttpConfigData->AccessPoint.IPv4Node == NULL)))))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -145,7 +147,6 @@ EfiHttpConfigure (
ASSERT (HttpInstance->Service != NULL); ASSERT (HttpInstance->Service != NULL);
if (HttpConfigData != NULL) { if (HttpConfigData != NULL) {
if (HttpConfigData->HttpVersion >= HttpVersionUnsupported) { if (HttpConfigData->HttpVersion >= HttpVersionUnsupported) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -185,7 +186,6 @@ EfiHttpConfigure (
HttpInstance->State = HTTP_STATE_HTTP_CONFIGED; HttpInstance->State = HTTP_STATE_HTTP_CONFIGED;
return EFI_SUCCESS; return EFI_SUCCESS;
} else { } else {
// //
// Reset all the resources related to HttpInstance. // Reset all the resources related to HttpInstance.
@ -196,7 +196,6 @@ EfiHttpConfigure (
} }
} }
/** /**
The Request() function queues an HTTP request to this HTTP instance. The Request() function queues an HTTP request to this HTTP instance.
@ -280,7 +279,8 @@ EfiHttpRequest (
if ((Request != NULL) && (Request->Method != HttpMethodGet) && if ((Request != NULL) && (Request->Method != HttpMethodGet) &&
(Request->Method != HttpMethodHead) && (Request->Method != HttpMethodDelete) && (Request->Method != HttpMethodHead) && (Request->Method != HttpMethodDelete) &&
(Request->Method != HttpMethodPut) && (Request->Method != HttpMethodPost) && (Request->Method != HttpMethodPut) && (Request->Method != HttpMethodPost) &&
(Request->Method != HttpMethodPatch)) { (Request->Method != HttpMethodPatch))
{
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -303,7 +303,8 @@ EfiHttpRequest (
// //
if ((HttpInstance->Method != HttpMethodPut) && if ((HttpInstance->Method != HttpMethodPut) &&
(HttpInstance->Method != HttpMethodPost) && (HttpInstance->Method != HttpMethodPost) &&
(HttpInstance->Method != HttpMethodPatch)) { (HttpInstance->Method != HttpMethodPatch))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -317,7 +318,7 @@ EfiHttpRequest (
// //
// We need to have the Message Body for sending the HTTP message across in these cases. // We need to have the Message Body for sending the HTTP message across in these cases.
// //
if (HttpMsg->Body == NULL || HttpMsg->BodyLength == 0) { if ((HttpMsg->Body == NULL) || (HttpMsg->BodyLength == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -344,11 +345,11 @@ EfiHttpRequest (
if (Url == NULL) { if (Url == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
FreePool (HttpInstance->Url); FreePool (HttpInstance->Url);
HttpInstance->Url = Url; HttpInstance->Url = Url;
} }
UnicodeStrToAsciiStrS (Request->Url, Url, UrlLen); UnicodeStrToAsciiStrS (Request->Url, Url, UrlLen);
// //
@ -361,7 +362,6 @@ EfiHttpRequest (
// HTTP is disabled, return directly if the URI is not HTTPS. // HTTP is disabled, return directly if the URI is not HTTPS.
// //
if (!PcdGetBool (PcdAllowHttpConnections) && !(HttpInstance->UseHttps)) { if (!PcdGetBool (PcdAllowHttpConnections) && !(HttpInstance->UseHttps)) {
DEBUG ((DEBUG_ERROR, "EfiHttpRequest: HTTP is disabled.\n")); DEBUG ((DEBUG_ERROR, "EfiHttpRequest: HTTP is disabled.\n"));
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
@ -370,7 +370,7 @@ EfiHttpRequest (
// //
// Check whether we need to create Tls child and open the TLS protocol. // Check whether we need to create Tls child and open the TLS protocol.
// //
if (HttpInstance->UseHttps && HttpInstance->TlsChildHandle == NULL) { if (HttpInstance->UseHttps && (HttpInstance->TlsChildHandle == NULL)) {
// //
// Use TlsSb to create Tls child and open the TLS protocol. // Use TlsSb to create Tls child and open the TLS protocol.
// //
@ -394,7 +394,7 @@ EfiHttpRequest (
} }
UrlParser = NULL; UrlParser = NULL;
Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, &UrlParser); Status = HttpParseUrl (Url, (UINT32)AsciiStrLen (Url), FALSE, &UrlParser);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Error1; goto Error1;
} }
@ -407,7 +407,7 @@ EfiHttpRequest (
if (HttpInstance->LocalAddressIsIPv6) { if (HttpInstance->LocalAddressIsIPv6) {
HostNameSize = AsciiStrSize (HostName); HostNameSize = AsciiStrSize (HostName);
if (HostNameSize > 2 && HostName[0] == '[' && HostName[HostNameSize - 2] == ']') { if ((HostNameSize > 2) && (HostName[0] == '[') && (HostName[HostNameSize - 2] == ']')) {
// //
// HostName format is expressed as IPv6, so, remove '[' and ']'. // HostName format is expressed as IPv6, so, remove '[' and ']'.
// //
@ -425,6 +425,7 @@ EfiHttpRequest (
RemotePort = HTTP_DEFAULT_PORT; RemotePort = HTTP_DEFAULT_PORT;
} }
} }
// //
// If Configure is TRUE, it indicates the first time to call Request(); // If Configure is TRUE, it indicates the first time to call Request();
// If ReConfigure is TRUE, it indicates the request URL is not same // If ReConfigure is TRUE, it indicates the request URL is not same
@ -443,7 +444,8 @@ EfiHttpRequest (
(AsciiStrCmp (HttpInstance->RemoteHost, HostName) == 0) && (AsciiStrCmp (HttpInstance->RemoteHost, HostName) == 0) &&
(!HttpInstance->UseHttps || (HttpInstance->UseHttps && (!HttpInstance->UseHttps || (HttpInstance->UseHttps &&
!TlsConfigure && !TlsConfigure &&
HttpInstance->TlsSessionState == EfiTlsSessionDataTransferring))) { (HttpInstance->TlsSessionState == EfiTlsSessionDataTransferring))))
{
// //
// Host Name and port number of the request URL are the same with previous call to Request(). // Host Name and port number of the request URL are the same with previous call to Request().
// If Https protocol used, the corresponding SessionState is EfiTlsSessionDataTransferring. // If Https protocol used, the corresponding SessionState is EfiTlsSessionDataTransferring.
@ -527,6 +529,7 @@ EfiHttpRequest (
} else { } else {
Status = HttpDns6 (HttpInstance, HostNameStr, &HttpInstance->RemoteIpv6Addr); Status = HttpDns6 (HttpInstance, HostNameStr, &HttpInstance->RemoteIpv6Addr);
} }
HttpNotify (HttpEventDns, Status); HttpNotify (HttpEventDns, Status);
FreePool (HostNameStr); FreePool (HostNameStr);
@ -608,13 +611,14 @@ EfiHttpRequest (
// Create request message. // Create request message.
// //
FileUrl = Url; FileUrl = Url;
if (Url != NULL && *FileUrl != '/') { if ((Url != NULL) && (*FileUrl != '/')) {
// //
// Convert the absolute-URI to the absolute-path // Convert the absolute-URI to the absolute-path
// //
while (*FileUrl != ':') { while (*FileUrl != ':') {
FileUrl++; FileUrl++;
} }
if ((*(FileUrl+1) == '/') && (*(FileUrl+2) == '/')) { if ((*(FileUrl+1) == '/') && (*(FileUrl+2) == '/')) {
FileUrl += 3; FileUrl += 3;
while (*FileUrl != '/') { while (*FileUrl != '/') {
@ -628,7 +632,7 @@ EfiHttpRequest (
Status = HttpGenRequestMessage (HttpMsg, FileUrl, &RequestMsg, &RequestMsgSize); Status = HttpGenRequestMessage (HttpMsg, FileUrl, &RequestMsg, &RequestMsgSize);
if (EFI_ERROR (Status) || NULL == RequestMsg) { if (EFI_ERROR (Status) || (NULL == RequestMsg)) {
goto Error3; goto Error3;
} }
@ -651,7 +655,7 @@ EfiHttpRequest (
Status = HttpTransmitTcp ( Status = HttpTransmitTcp (
HttpInstance, HttpInstance,
Wrap, Wrap,
(UINT8*) RequestMsg, (UINT8 *)RequestMsg,
RequestMsgSize RequestMsgSize
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -698,6 +702,7 @@ Error2:
gBS->CloseEvent (Wrap->TcpWrap.Tx4Token.CompletionToken.Event); gBS->CloseEvent (Wrap->TcpWrap.Tx4Token.CompletionToken.Event);
Wrap->TcpWrap.Tx4Token.CompletionToken.Event = NULL; Wrap->TcpWrap.Tx4Token.CompletionToken.Event = NULL;
} }
if (NULL != Wrap->TcpWrap.Tx6Token.CompletionToken.Event) { if (NULL != Wrap->TcpWrap.Tx6Token.CompletionToken.Event) {
gBS->CloseEvent (Wrap->TcpWrap.Tx6Token.CompletionToken.Event); gBS->CloseEvent (Wrap->TcpWrap.Tx6Token.CompletionToken.Event);
Wrap->TcpWrap.Tx6Token.CompletionToken.Event = NULL; Wrap->TcpWrap.Tx6Token.CompletionToken.Event = NULL;
@ -707,15 +712,16 @@ Error1:
if (HostName != NULL) { if (HostName != NULL) {
FreePool (HostName); FreePool (HostName);
} }
if (Wrap != NULL) { if (Wrap != NULL) {
FreePool (Wrap); FreePool (Wrap);
} }
if (UrlParser != NULL) { if (UrlParser != NULL) {
HttpUrlFreeParser (UrlParser); HttpUrlFreeParser (UrlParser);
} }
return Status; return Status;
} }
/** /**
@ -741,7 +747,7 @@ HttpCancelTokens (
HTTP_TOKEN_WRAP *Wrap; HTTP_TOKEN_WRAP *Wrap;
HTTP_PROTOCOL *HttpInstance; HTTP_PROTOCOL *HttpInstance;
Token = (EFI_HTTP_TOKEN *) Context; Token = (EFI_HTTP_TOKEN *)Context;
// //
// Return EFI_SUCCESS to check the next item in the map if // Return EFI_SUCCESS to check the next item in the map if
@ -751,7 +757,7 @@ HttpCancelTokens (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Wrap = (HTTP_TOKEN_WRAP *) Item->Value; Wrap = (HTTP_TOKEN_WRAP *)Item->Value;
ASSERT (Wrap != NULL); ASSERT (Wrap != NULL);
HttpInstance = Wrap->HttpInstance; HttpInstance = Wrap->HttpInstance;
@ -855,7 +861,6 @@ HttpCancel (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Abort an asynchronous HTTP request or response token. Abort an asynchronous HTTP request or response token.
@ -898,7 +903,6 @@ EfiHttpCancel (
} }
return HttpCancel (HttpInstance, Token); return HttpCancel (HttpInstance, Token);
} }
/** /**
@ -933,13 +937,13 @@ HttpBodyParserCallback (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
if (Data == NULL || Length != 0 || Context == NULL) { if ((Data == NULL) || (Length != 0) || (Context == NULL)) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
CallbackData = (HTTP_CALLBACK_DATA *) Context; CallbackData = (HTTP_CALLBACK_DATA *)Context;
Wrap = (HTTP_TOKEN_WRAP *) (CallbackData->Wrap); Wrap = (HTTP_TOKEN_WRAP *)(CallbackData->Wrap);
Body = CallbackData->ParseData; Body = CallbackData->ParseData;
BodyLength = CallbackData->ParseDataLength; BodyLength = CallbackData->ParseDataLength;
@ -987,7 +991,7 @@ HttpResponseWorker (
NET_FRAGMENT Fragment; NET_FRAGMENT Fragment;
UINT32 TimeoutValue; UINT32 TimeoutValue;
if (Wrap == NULL || Wrap->HttpInstance == NULL) { if ((Wrap == NULL) || (Wrap->HttpInstance == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1038,7 +1042,6 @@ HttpResponseWorker (
HttpInstance->EndofHeader = &EndofHeader; HttpInstance->EndofHeader = &EndofHeader;
HttpInstance->HttpHeaders = &HttpHeaders; HttpInstance->HttpHeaders = &HttpHeaders;
if (HttpInstance->TimeoutEvent == NULL) { if (HttpInstance->TimeoutEvent == NULL) {
// //
// Create TimeoutEvent for response // Create TimeoutEvent for response
@ -1144,7 +1147,7 @@ HttpResponseWorker (
// Hence, check that case before doing a NetMapRemoveHead. // Hence, check that case before doing a NetMapRemoveHead.
// //
if (!NetMapIsEmpty (&HttpInstance->TxTokens)) { if (!NetMapIsEmpty (&HttpInstance->TxTokens)) {
NetMapRemoveHead (&HttpInstance->TxTokens, (VOID**) &ValueInItem); NetMapRemoveHead (&HttpInstance->TxTokens, (VOID **)&ValueInItem);
if (ValueInItem == NULL) { if (ValueInItem == NULL) {
goto Error; goto Error;
} }
@ -1193,7 +1196,6 @@ HttpResponseWorker (
FreePool (HttpHeaders); FreePool (HttpHeaders);
HttpHeaders = NULL; HttpHeaders = NULL;
// //
// Init message-body parser by header information. // Init message-body parser by header information.
// //
@ -1203,7 +1205,7 @@ HttpResponseWorker (
HttpMsg->HeaderCount, HttpMsg->HeaderCount,
HttpMsg->Headers, HttpMsg->Headers,
HttpBodyParserCallback, HttpBodyParserCallback,
(VOID *) (&HttpInstance->CallbackData), (VOID *)(&HttpInstance->CallbackData),
&HttpInstance->MsgParser &HttpInstance->MsgParser
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -1217,8 +1219,8 @@ HttpResponseWorker (
// //
// Record the CallbackData data. // Record the CallbackData data.
// //
HttpInstance->CallbackData.Wrap = (VOID *) Wrap; HttpInstance->CallbackData.Wrap = (VOID *)Wrap;
HttpInstance->CallbackData.ParseData = (VOID *) HttpInstance->CacheBody; HttpInstance->CallbackData.ParseData = (VOID *)HttpInstance->CacheBody;
HttpInstance->CallbackData.ParseDataLength = HttpInstance->CacheLen; HttpInstance->CallbackData.ParseDataLength = HttpInstance->CacheLen;
// //
@ -1291,6 +1293,7 @@ HttpResponseWorker (
HttpInstance->CacheOffset = 0; HttpInstance->CacheOffset = 0;
} }
} }
// //
// Return since we already received required data. // Return since we already received required data.
// //
@ -1298,7 +1301,7 @@ HttpResponseWorker (
goto Exit; goto Exit;
} }
if (BodyLen == 0 && HttpInstance->MsgParser == NULL) { if ((BodyLen == 0) && (HttpInstance->MsgParser == NULL)) {
// //
// We received a complete HTTP message, and we don't have more data to return to caller. // We received a complete HTTP message, and we don't have more data to return to caller.
// //
@ -1319,7 +1322,6 @@ HttpResponseWorker (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Error2; goto Error2;
} }
} else { } else {
if (HttpInstance->TimeoutEvent == NULL) { if (HttpInstance->TimeoutEvent == NULL) {
// //
@ -1361,14 +1363,14 @@ HttpResponseWorker (
// //
// Process the received the body packet. // Process the received the body packet.
// //
HttpMsg->BodyLength = MIN ((UINTN) Fragment.Len, HttpMsg->BodyLength); HttpMsg->BodyLength = MIN ((UINTN)Fragment.Len, HttpMsg->BodyLength);
CopyMem (HttpMsg->Body, Fragment.Bulk, HttpMsg->BodyLength); CopyMem (HttpMsg->Body, Fragment.Bulk, HttpMsg->BodyLength);
// //
// Record the CallbackData data. // Record the CallbackData data.
// //
HttpInstance->CallbackData.Wrap = (VOID *) Wrap; HttpInstance->CallbackData.Wrap = (VOID *)Wrap;
HttpInstance->CallbackData.ParseData = HttpMsg->Body; HttpInstance->CallbackData.ParseData = HttpMsg->Body;
HttpInstance->CallbackData.ParseDataLength = HttpMsg->BodyLength; HttpInstance->CallbackData.ParseDataLength = HttpMsg->BodyLength;
@ -1396,7 +1398,7 @@ HttpResponseWorker (
// Check whether there is the next message header in the HttpMsg->Body. // Check whether there is the next message header in the HttpMsg->Body.
// //
if (HttpInstance->NextMsg != NULL) { if (HttpInstance->NextMsg != NULL) {
HttpMsg->BodyLength = HttpInstance->NextMsg - (CHAR8 *) HttpMsg->Body; HttpMsg->BodyLength = HttpInstance->NextMsg - (CHAR8 *)HttpMsg->Body;
} }
HttpInstance->CacheLen = Fragment.Len - HttpMsg->BodyLength; HttpInstance->CacheLen = Fragment.Len - HttpMsg->BodyLength;
@ -1491,10 +1493,8 @@ Error:
gBS->SignalEvent (Token->Event); gBS->SignalEvent (Token->Event);
return Status; return Status;
} }
/** /**
The Response() function queues an HTTP response to this HTTP instance, similar to The Response() function queues an HTTP response to this HTTP instance, similar to
Receive() function in the EFI TCP driver. When the HTTP response is received successfully, Receive() function in the EFI TCP driver. When the HTTP response is received successfully,
@ -1619,6 +1619,7 @@ Error:
if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event != NULL) { if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event != NULL) {
gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event); gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event);
} }
FreePool (Wrap); FreePool (Wrap);
} }
@ -1668,11 +1669,13 @@ EfiHttpPoll (
if (HttpInstance->Tcp6 == NULL) { if (HttpInstance->Tcp6 == NULL) {
return EFI_NOT_STARTED; return EFI_NOT_STARTED;
} }
Status = HttpInstance->Tcp6->Poll (HttpInstance->Tcp6); Status = HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
} else { } else {
if (HttpInstance->Tcp4 == NULL) { if (HttpInstance->Tcp4 == NULL) {
return EFI_NOT_STARTED; return EFI_NOT_STARTED;
} }
Status = HttpInstance->Tcp4->Poll (HttpInstance->Tcp4); Status = HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
} }

View File

@ -18,7 +18,6 @@
#define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n" #define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n"
#define HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE 300 #define HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE 300
/** /**
Returns the operational parameters for the current HTTP child instance. Returns the operational parameters for the current HTTP child instance.

View File

@ -24,10 +24,10 @@ HttpCommonNotify (
) )
{ {
if ((Event == NULL) || (Context == NULL)) { if ((Event == NULL) || (Context == NULL)) {
return ; return;
} }
*((BOOLEAN *) Context) = TRUE; *((BOOLEAN *)Context) = TRUE;
} }
/** /**
@ -46,10 +46,10 @@ HttpTcpTransmitNotifyDpc (
HTTP_PROTOCOL *HttpInstance; HTTP_PROTOCOL *HttpInstance;
if (Context == NULL) { if (Context == NULL) {
return ; return;
} }
Wrap = (HTTP_TOKEN_WRAP *) Context; Wrap = (HTTP_TOKEN_WRAP *)Context;
HttpInstance = Wrap->HttpInstance; HttpInstance = Wrap->HttpInstance;
if (!HttpInstance->LocalAddressIsIPv6) { if (!HttpInstance->LocalAddressIsIPv6) {
@ -66,7 +66,6 @@ HttpTcpTransmitNotifyDpc (
if (Wrap->TcpWrap.Tx4Token.CompletionToken.Event != NULL) { if (Wrap->TcpWrap.Tx4Token.CompletionToken.Event != NULL) {
gBS->CloseEvent (Wrap->TcpWrap.Tx4Token.CompletionToken.Event); gBS->CloseEvent (Wrap->TcpWrap.Tx4Token.CompletionToken.Event);
} }
} else { } else {
Wrap->HttpToken->Status = Wrap->TcpWrap.Tx6Token.CompletionToken.Status; Wrap->HttpToken->Status = Wrap->TcpWrap.Tx6Token.CompletionToken.Status;
gBS->SignalEvent (Wrap->HttpToken->Event); gBS->SignalEvent (Wrap->HttpToken->Event);
@ -83,14 +82,12 @@ HttpTcpTransmitNotifyDpc (
} }
} }
Wrap->TcpWrap.IsTxDone = TRUE; Wrap->TcpWrap.IsTxDone = TRUE;
// //
// Check pending TxTokens and sent out. // Check pending TxTokens and sent out.
// //
NetMapIterate (&Wrap->HttpInstance->TxTokens, HttpTcpTransmit, NULL); NetMapIterate (&Wrap->HttpInstance->TxTokens, HttpTcpTransmit, NULL);
} }
/** /**
@ -133,10 +130,10 @@ HttpTcpReceiveNotifyDpc (
BOOLEAN UsingIpv6; BOOLEAN UsingIpv6;
if (Context == NULL) { if (Context == NULL) {
return ; return;
} }
Wrap = (HTTP_TOKEN_WRAP *) Context; Wrap = (HTTP_TOKEN_WRAP *)Context;
HttpInstance = Wrap->HttpInstance; HttpInstance = Wrap->HttpInstance;
UsingIpv6 = HttpInstance->LocalAddressIsIPv6; UsingIpv6 = HttpInstance->LocalAddressIsIPv6;
@ -157,9 +154,8 @@ HttpTcpReceiveNotifyDpc (
FreePool (Wrap); FreePool (Wrap);
Wrap = NULL; Wrap = NULL;
return ; return;
} }
} else { } else {
gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event); gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);
Wrap->TcpWrap.Rx4Token.CompletionToken.Event = NULL; Wrap->TcpWrap.Rx4Token.CompletionToken.Event = NULL;
@ -177,7 +173,7 @@ HttpTcpReceiveNotifyDpc (
FreePool (Wrap); FreePool (Wrap);
Wrap = NULL; Wrap = NULL;
return ; return;
} }
} }
@ -186,15 +182,15 @@ HttpTcpReceiveNotifyDpc (
// //
ASSERT (HttpInstance->MsgParser != NULL); ASSERT (HttpInstance->MsgParser != NULL);
if (UsingIpv6) { if (UsingIpv6) {
Length = (UINTN) Wrap->TcpWrap.Rx6Data.FragmentTable[0].FragmentLength; Length = (UINTN)Wrap->TcpWrap.Rx6Data.FragmentTable[0].FragmentLength;
} else { } else {
Length = (UINTN) Wrap->TcpWrap.Rx4Data.FragmentTable[0].FragmentLength; Length = (UINTN)Wrap->TcpWrap.Rx4Data.FragmentTable[0].FragmentLength;
} }
// //
// Record the CallbackData data. // Record the CallbackData data.
// //
HttpInstance->CallbackData.Wrap = (VOID *) Wrap; HttpInstance->CallbackData.Wrap = (VOID *)Wrap;
HttpInstance->CallbackData.ParseData = Wrap->HttpToken->Message->Body; HttpInstance->CallbackData.ParseData = Wrap->HttpToken->Message->Body;
HttpInstance->CallbackData.ParseDataLength = Length; HttpInstance->CallbackData.ParseDataLength = Length;
@ -207,7 +203,7 @@ HttpTcpReceiveNotifyDpc (
Wrap->HttpToken->Message->Body Wrap->HttpToken->Message->Body
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return ; return;
} }
if (HttpIsMessageComplete (HttpInstance->MsgParser)) { if (HttpIsMessageComplete (HttpInstance->MsgParser)) {
@ -225,13 +221,14 @@ HttpTcpReceiveNotifyDpc (
// //
if (HttpInstance->NextMsg != NULL) { if (HttpInstance->NextMsg != NULL) {
Wrap->HttpToken->Message->BodyLength = HttpInstance->NextMsg - Wrap->HttpToken->Message->BodyLength = HttpInstance->NextMsg -
(CHAR8 *) Wrap->HttpToken->Message->Body; (CHAR8 *)Wrap->HttpToken->Message->Body;
HttpInstance->CacheLen = Length - Wrap->HttpToken->Message->BodyLength; HttpInstance->CacheLen = Length - Wrap->HttpToken->Message->BodyLength;
if (HttpInstance->CacheLen != 0) { if (HttpInstance->CacheLen != 0) {
HttpInstance->CacheBody = AllocateZeroPool (HttpInstance->CacheLen); HttpInstance->CacheBody = AllocateZeroPool (HttpInstance->CacheLen);
if (HttpInstance->CacheBody == NULL) { if (HttpInstance->CacheBody == NULL) {
return ; return;
} }
CopyMem (HttpInstance->CacheBody, HttpInstance->NextMsg, HttpInstance->CacheLen); CopyMem (HttpInstance->CacheBody, HttpInstance->NextMsg, HttpInstance->CacheLen);
HttpInstance->NextMsg = HttpInstance->CacheBody; HttpInstance->NextMsg = HttpInstance->CacheBody;
HttpInstance->CacheOffset = 0; HttpInstance->CacheOffset = 0;
@ -243,7 +240,6 @@ HttpTcpReceiveNotifyDpc (
NetMapRemoveItem (&Wrap->HttpInstance->RxTokens, Item, NULL); NetMapRemoveItem (&Wrap->HttpInstance->RxTokens, Item, NULL);
} }
Wrap->TcpWrap.IsRxDone = TRUE; Wrap->TcpWrap.IsRxDone = TRUE;
if (UsingIpv6) { if (UsingIpv6) {
Wrap->HttpToken->Status = Wrap->TcpWrap.Rx6Token.CompletionToken.Status; Wrap->HttpToken->Status = Wrap->TcpWrap.Rx6Token.CompletionToken.Status;
@ -251,7 +247,6 @@ HttpTcpReceiveNotifyDpc (
Wrap->HttpToken->Status = Wrap->TcpWrap.Rx4Token.CompletionToken.Status; Wrap->HttpToken->Status = Wrap->TcpWrap.Rx4Token.CompletionToken.Status;
} }
gBS->SignalEvent (Wrap->HttpToken->Event); gBS->SignalEvent (Wrap->HttpToken->Event);
// //
@ -327,7 +322,6 @@ HttpCreateTcpConnCloseEvent (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ERROR; goto ERROR;
} }
} else { } else {
// //
// Create events for various asynchronous operations. // Create events for various asynchronous operations.
@ -369,7 +363,6 @@ ERROR:
return Status; return Status;
} }
/** /**
Close events in the TCP connection token and TCP close token. Close events in the TCP connection token and TCP close token.
@ -390,10 +383,9 @@ HttpCloseTcpConnCloseEvent (
} }
if (NULL != HttpInstance->Tcp6CloseToken.CompletionToken.Event) { if (NULL != HttpInstance->Tcp6CloseToken.CompletionToken.Event) {
gBS->CloseEvent(HttpInstance->Tcp6CloseToken.CompletionToken.Event); gBS->CloseEvent (HttpInstance->Tcp6CloseToken.CompletionToken.Event);
HttpInstance->Tcp6CloseToken.CompletionToken.Event = NULL; HttpInstance->Tcp6CloseToken.CompletionToken.Event = NULL;
} }
} else { } else {
if (NULL != HttpInstance->Tcp4ConnToken.CompletionToken.Event) { if (NULL != HttpInstance->Tcp4ConnToken.CompletionToken.Event) {
gBS->CloseEvent (HttpInstance->Tcp4ConnToken.CompletionToken.Event); gBS->CloseEvent (HttpInstance->Tcp4ConnToken.CompletionToken.Event);
@ -401,11 +393,10 @@ HttpCloseTcpConnCloseEvent (
} }
if (NULL != HttpInstance->Tcp4CloseToken.CompletionToken.Event) { if (NULL != HttpInstance->Tcp4CloseToken.CompletionToken.Event) {
gBS->CloseEvent(HttpInstance->Tcp4CloseToken.CompletionToken.Event); gBS->CloseEvent (HttpInstance->Tcp4CloseToken.CompletionToken.Event);
HttpInstance->Tcp4CloseToken.CompletionToken.Event = NULL; HttpInstance->Tcp4CloseToken.CompletionToken.Event = NULL;
} }
} }
} }
/** /**
@ -446,7 +437,6 @@ HttpCreateTcpTxEvent (
TcpWrap->Tx4Data.FragmentCount = 1; TcpWrap->Tx4Data.FragmentCount = 1;
TcpWrap->Tx4Token.Packet.TxData = &Wrap->TcpWrap.Tx4Data; TcpWrap->Tx4Token.Packet.TxData = &Wrap->TcpWrap.Tx4Data;
TcpWrap->Tx4Token.CompletionToken.Status = EFI_NOT_READY; TcpWrap->Tx4Token.CompletionToken.Status = EFI_NOT_READY;
} else { } else {
Status = gBS->CreateEvent ( Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
@ -463,8 +453,7 @@ HttpCreateTcpTxEvent (
TcpWrap->Tx6Data.Urgent = FALSE; TcpWrap->Tx6Data.Urgent = FALSE;
TcpWrap->Tx6Data.FragmentCount = 1; TcpWrap->Tx6Data.FragmentCount = 1;
TcpWrap->Tx6Token.Packet.TxData = &Wrap->TcpWrap.Tx6Data; TcpWrap->Tx6Token.Packet.TxData = &Wrap->TcpWrap.Tx6Data;
TcpWrap->Tx6Token.CompletionToken.Status =EFI_NOT_READY; TcpWrap->Tx6Token.CompletionToken.Status = EFI_NOT_READY;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -501,7 +490,6 @@ HttpCreateTcpRxEventForHeader (
HttpInstance->Rx4Data.FragmentCount = 1; HttpInstance->Rx4Data.FragmentCount = 1;
HttpInstance->Rx4Token.Packet.RxData = &HttpInstance->Rx4Data; HttpInstance->Rx4Token.Packet.RxData = &HttpInstance->Rx4Data;
HttpInstance->Rx4Token.CompletionToken.Status = EFI_NOT_READY; HttpInstance->Rx4Token.CompletionToken.Status = EFI_NOT_READY;
} else { } else {
Status = gBS->CreateEvent ( Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
@ -514,13 +502,11 @@ HttpCreateTcpRxEventForHeader (
return Status; return Status;
} }
HttpInstance->Rx6Data.FragmentCount =1; HttpInstance->Rx6Data.FragmentCount = 1;
HttpInstance->Rx6Token.Packet.RxData = &HttpInstance->Rx6Data; HttpInstance->Rx6Token.Packet.RxData = &HttpInstance->Rx6Data;
HttpInstance->Rx6Token.CompletionToken.Status = EFI_NOT_READY; HttpInstance->Rx6Token.CompletionToken.Status = EFI_NOT_READY;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -559,7 +545,6 @@ HttpCreateTcpRxEvent (
TcpWrap->Rx4Data.FragmentCount = 1; TcpWrap->Rx4Data.FragmentCount = 1;
TcpWrap->Rx4Token.Packet.RxData = &Wrap->TcpWrap.Rx4Data; TcpWrap->Rx4Token.Packet.RxData = &Wrap->TcpWrap.Rx4Data;
TcpWrap->Rx4Token.CompletionToken.Status = EFI_NOT_READY; TcpWrap->Rx4Token.CompletionToken.Status = EFI_NOT_READY;
} else { } else {
Status = gBS->CreateEvent ( Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
@ -658,7 +643,7 @@ HttpInitProtocol (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
HttpInstance->Tcp4ChildHandle, HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid, &gEfiTcp4ProtocolGuid,
(VOID **) &Interface, (VOID **)&Interface,
HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Service->ControllerHandle, HttpInstance->Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -671,24 +656,24 @@ HttpInitProtocol (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
HttpInstance->Tcp4ChildHandle, HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid, &gEfiTcp4ProtocolGuid,
(VOID **) &HttpInstance->Tcp4, (VOID **)&HttpInstance->Tcp4,
HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle, HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
HttpInstance->Service->Tcp4ChildHandle, HttpInstance->Service->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid, &gEfiTcp4ProtocolGuid,
(VOID **) &Interface, (VOID **)&Interface,
HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Service->Ip4DriverBindingHandle,
HttpInstance->Handle, HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
} else { } else {
@ -709,7 +694,7 @@ HttpInitProtocol (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
HttpInstance->Tcp6ChildHandle, HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid, &gEfiTcp6ProtocolGuid,
(VOID **) &Interface, (VOID **)&Interface,
HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Service->ControllerHandle, HttpInstance->Service->ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -722,26 +707,26 @@ HttpInitProtocol (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
HttpInstance->Tcp6ChildHandle, HttpInstance->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid, &gEfiTcp6ProtocolGuid,
(VOID **) &HttpInstance->Tcp6, (VOID **)&HttpInstance->Tcp6,
HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle, HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
HttpInstance->Service->Tcp6ChildHandle, HttpInstance->Service->Tcp6ChildHandle,
&gEfiTcp6ProtocolGuid, &gEfiTcp6ProtocolGuid,
(VOID **) &Interface, (VOID **)&Interface,
HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Service->Ip6DriverBindingHandle,
HttpInstance->Handle, HttpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
} }
@ -821,7 +806,6 @@ ON_ERROR:
} }
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
/** /**
@ -868,7 +852,7 @@ HttpCleanProtocol (
NetMapClean (&HttpInstance->TxTokens); NetMapClean (&HttpInstance->TxTokens);
NetMapClean (&HttpInstance->RxTokens); NetMapClean (&HttpInstance->RxTokens);
if (HttpInstance->TlsSb != NULL && HttpInstance->TlsChildHandle != NULL) { if ((HttpInstance->TlsSb != NULL) && (HttpInstance->TlsChildHandle != NULL)) {
// //
// Destroy the TLS instance. // Destroy the TLS instance.
// //
@ -977,7 +961,6 @@ HttpCreateConnection (
} }
Status = HttpInstance->Tcp4ConnToken.CompletionToken.Status; Status = HttpInstance->Tcp4ConnToken.CompletionToken.Status;
} else { } else {
HttpInstance->IsTcp6ConnDone = FALSE; HttpInstance->IsTcp6ConnDone = FALSE;
HttpInstance->Tcp6ConnToken.CompletionToken.Status = EFI_NOT_READY; HttpInstance->Tcp6ConnToken.CompletionToken.Status = EFI_NOT_READY;
@ -988,7 +971,7 @@ HttpCreateConnection (
return Status; return Status;
} }
while(!HttpInstance->IsTcp6ConnDone) { while (!HttpInstance->IsTcp6ConnDone) {
HttpInstance->Tcp6->Poll (HttpInstance->Tcp6); HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
} }
@ -1019,7 +1002,6 @@ HttpCloseConnection (
EFI_STATUS Status; EFI_STATUS Status;
if (HttpInstance->State == HTTP_STATE_TCP_CONNECTED) { if (HttpInstance->State == HTTP_STATE_TCP_CONNECTED) {
if (HttpInstance->LocalAddressIsIPv6) { if (HttpInstance->LocalAddressIsIPv6) {
HttpInstance->Tcp6CloseToken.AbortOnClose = TRUE; HttpInstance->Tcp6CloseToken.AbortOnClose = TRUE;
HttpInstance->IsTcp6CloseDone = FALSE; HttpInstance->IsTcp6CloseDone = FALSE;
@ -1031,7 +1013,6 @@ HttpCloseConnection (
while (!HttpInstance->IsTcp6CloseDone) { while (!HttpInstance->IsTcp6CloseDone) {
HttpInstance->Tcp6->Poll (HttpInstance->Tcp6); HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
} }
} else { } else {
HttpInstance->Tcp4CloseToken.AbortOnClose = TRUE; HttpInstance->Tcp4CloseToken.AbortOnClose = TRUE;
HttpInstance->IsTcp4CloseDone = FALSE; HttpInstance->IsTcp4CloseDone = FALSE;
@ -1044,7 +1025,6 @@ HttpCloseConnection (
HttpInstance->Tcp4->Poll (HttpInstance->Tcp4); HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
} }
} }
} }
HttpInstance->State = HTTP_STATE_TCP_CLOSED; HttpInstance->State = HTTP_STATE_TCP_CLOSED;
@ -1074,7 +1054,6 @@ HttpConfigureTcp4 (
ASSERT (HttpInstance != NULL); ASSERT (HttpInstance != NULL);
Tcp4CfgData = &HttpInstance->Tcp4CfgData; Tcp4CfgData = &HttpInstance->Tcp4CfgData;
ZeroMem (Tcp4CfgData, sizeof (EFI_TCP4_CONFIG_DATA)); ZeroMem (Tcp4CfgData, sizeof (EFI_TCP4_CONFIG_DATA));
@ -1163,7 +1142,7 @@ HttpConfigureTcp6 (
Tcp6Ap->StationPort = HttpInstance->Ipv6Node.LocalPort; Tcp6Ap->StationPort = HttpInstance->Ipv6Node.LocalPort;
Tcp6Ap->RemotePort = HttpInstance->RemotePort; Tcp6Ap->RemotePort = HttpInstance->RemotePort;
IP6_COPY_ADDRESS (&Tcp6Ap->StationAddress, &HttpInstance->Ipv6Node.LocalAddress); IP6_COPY_ADDRESS (&Tcp6Ap->StationAddress, &HttpInstance->Ipv6Node.LocalAddress);
IP6_COPY_ADDRESS (&Tcp6Ap->RemoteAddress , &HttpInstance->RemoteIpv6Addr); IP6_COPY_ADDRESS (&Tcp6Ap->RemoteAddress, &HttpInstance->RemoteIpv6Addr);
Tcp6Option = Tcp6CfgData->ControlOption; Tcp6Option = Tcp6CfgData->ControlOption;
Tcp6Option->ReceiveBufferSize = HTTP_BUFFER_SIZE_DEAULT; Tcp6Option->ReceiveBufferSize = HTTP_BUFFER_SIZE_DEAULT;
@ -1196,7 +1175,6 @@ HttpConfigureTcp6 (
HttpInstance->State = HTTP_STATE_TCP_CONFIGED; HttpInstance->State = HTTP_STATE_TCP_CONFIGED;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
@ -1218,12 +1196,11 @@ HttpConnectTcp4 (
EFI_STATUS Status; EFI_STATUS Status;
EFI_TCP4_CONNECTION_STATE Tcp4State; EFI_TCP4_CONNECTION_STATE Tcp4State;
if ((HttpInstance->State < HTTP_STATE_TCP_CONFIGED) || (HttpInstance->Tcp4 == NULL)) {
if (HttpInstance->State < HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp4 == NULL) {
return EFI_NOT_READY; return EFI_NOT_READY;
} }
Status = HttpInstance->Tcp4->GetModeData( Status = HttpInstance->Tcp4->GetModeData (
HttpInstance->Tcp4, HttpInstance->Tcp4,
&Tcp4State, &Tcp4State,
NULL, NULL,
@ -1231,7 +1208,7 @@ HttpConnectTcp4 (
NULL, NULL,
NULL NULL
); );
if (EFI_ERROR(Status)){ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Tcp4 GetModeData fail - %x\n", Status)); DEBUG ((DEBUG_ERROR, "Tcp4 GetModeData fail - %x\n", Status));
return Status; return Status;
} }
@ -1239,11 +1216,11 @@ HttpConnectTcp4 (
if (Tcp4State == Tcp4StateEstablished) { if (Tcp4State == Tcp4StateEstablished) {
return EFI_SUCCESS; return EFI_SUCCESS;
} else if (Tcp4State > Tcp4StateEstablished ) { } else if (Tcp4State > Tcp4StateEstablished ) {
HttpCloseConnection(HttpInstance); HttpCloseConnection (HttpInstance);
} }
Status = HttpCreateConnection (HttpInstance); Status = HttpCreateConnection (HttpInstance);
if (EFI_ERROR(Status)){ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Tcp4 Connection fail - %x\n", Status)); DEBUG ((DEBUG_ERROR, "Tcp4 Connection fail - %x\n", Status));
return Status; return Status;
} }
@ -1311,7 +1288,7 @@ HttpConnectTcp6 (
EFI_STATUS Status; EFI_STATUS Status;
EFI_TCP6_CONNECTION_STATE Tcp6State; EFI_TCP6_CONNECTION_STATE Tcp6State;
if (HttpInstance->State < HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp6 == NULL) { if ((HttpInstance->State < HTTP_STATE_TCP_CONFIGED) || (HttpInstance->Tcp6 == NULL)) {
return EFI_NOT_READY; return EFI_NOT_READY;
} }
@ -1324,7 +1301,7 @@ HttpConnectTcp6 (
NULL NULL
); );
if (EFI_ERROR(Status)){ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Tcp6 GetModeData fail - %x\n", Status)); DEBUG ((DEBUG_ERROR, "Tcp6 GetModeData fail - %x\n", Status));
return Status; return Status;
} }
@ -1332,11 +1309,11 @@ HttpConnectTcp6 (
if (Tcp6State == Tcp6StateEstablished) { if (Tcp6State == Tcp6StateEstablished) {
return EFI_SUCCESS; return EFI_SUCCESS;
} else if (Tcp6State > Tcp6StateEstablished ) { } else if (Tcp6State > Tcp6StateEstablished ) {
HttpCloseConnection(HttpInstance); HttpCloseConnection (HttpInstance);
} }
Status = HttpCreateConnection (HttpInstance); Status = HttpCreateConnection (HttpInstance);
if (EFI_ERROR(Status)){ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Tcp6 Connection fail - %x\n", Status)); DEBUG ((DEBUG_ERROR, "Tcp6 Connection fail - %x\n", Status));
return Status; return Status;
} }
@ -1406,6 +1383,7 @@ HttpInitSession (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (HttpInstance != NULL); ASSERT (HttpInstance != NULL);
// //
@ -1457,7 +1435,6 @@ HttpInitSession (
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
@ -1530,12 +1507,12 @@ HttpTransmitTcp (
// //
RemainingLen = TxStringLen; RemainingLen = TxStringLen;
while (RemainingLen != 0) { while (RemainingLen != 0) {
PayloadSize = (UINT16) MIN (TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH, RemainingLen); PayloadSize = (UINT16)MIN (TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH, RemainingLen);
((TLS_RECORD_HEADER *) TlsRecord)->ContentType = TlsContentTypeApplicationData; ((TLS_RECORD_HEADER *)TlsRecord)->ContentType = TlsContentTypeApplicationData;
((TLS_RECORD_HEADER *) TlsRecord)->Version.Major = HttpInstance->TlsConfigData.Version.Major; ((TLS_RECORD_HEADER *)TlsRecord)->Version.Major = HttpInstance->TlsConfigData.Version.Major;
((TLS_RECORD_HEADER *) TlsRecord)->Version.Minor = HttpInstance->TlsConfigData.Version.Minor; ((TLS_RECORD_HEADER *)TlsRecord)->Version.Minor = HttpInstance->TlsConfigData.Version.Minor;
((TLS_RECORD_HEADER *) TlsRecord)->Length = PayloadSize; ((TLS_RECORD_HEADER *)TlsRecord)->Length = PayloadSize;
CopyMem (TlsRecord + TLS_RECORD_HEADER_LENGTH, TxString + (TxStringLen - RemainingLen), PayloadSize); CopyMem (TlsRecord + TLS_RECORD_HEADER_LENGTH, TxString + (TxStringLen - RemainingLen), PayloadSize);
@ -1560,7 +1537,7 @@ HttpTransmitTcp (
TempFragment.Len = 0; TempFragment.Len = 0;
TempFragment.Bulk = NULL; TempFragment.Bulk = NULL;
RemainingLen -= (UINTN) PayloadSize; RemainingLen -= (UINTN)PayloadSize;
ZeroMem (TlsRecord, TLS_RECORD_HEADER_LENGTH + TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH); ZeroMem (TlsRecord, TLS_RECORD_HEADER_LENGTH + TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH);
} }
@ -1575,11 +1552,11 @@ HttpTransmitTcp (
if (HttpInstance->UseHttps) { if (HttpInstance->UseHttps) {
Tx4Token->Packet.TxData->DataLength = Fragment.Len; Tx4Token->Packet.TxData->DataLength = Fragment.Len;
Tx4Token->Packet.TxData->FragmentTable[0].FragmentLength = Fragment.Len; Tx4Token->Packet.TxData->FragmentTable[0].FragmentLength = Fragment.Len;
Tx4Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *) Fragment.Bulk; Tx4Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *)Fragment.Bulk;
} else { } else {
Tx4Token->Packet.TxData->DataLength = (UINT32) TxStringLen; Tx4Token->Packet.TxData->DataLength = (UINT32)TxStringLen;
Tx4Token->Packet.TxData->FragmentTable[0].FragmentLength = (UINT32) TxStringLen; Tx4Token->Packet.TxData->FragmentTable[0].FragmentLength = (UINT32)TxStringLen;
Tx4Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *) TxString; Tx4Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *)TxString;
} }
Tx4Token->CompletionToken.Status = EFI_NOT_READY; Tx4Token->CompletionToken.Status = EFI_NOT_READY;
@ -1590,7 +1567,6 @@ HttpTransmitTcp (
DEBUG ((DEBUG_ERROR, "Transmit failed: %r\n", Status)); DEBUG ((DEBUG_ERROR, "Transmit failed: %r\n", Status));
goto ON_ERROR; goto ON_ERROR;
} }
} else { } else {
Tcp6 = HttpInstance->Tcp6; Tcp6 = HttpInstance->Tcp6;
Tx6Token = &Wrap->TcpWrap.Tx6Token; Tx6Token = &Wrap->TcpWrap.Tx6Token;
@ -1598,11 +1574,11 @@ HttpTransmitTcp (
if (HttpInstance->UseHttps) { if (HttpInstance->UseHttps) {
Tx6Token->Packet.TxData->DataLength = Fragment.Len; Tx6Token->Packet.TxData->DataLength = Fragment.Len;
Tx6Token->Packet.TxData->FragmentTable[0].FragmentLength = Fragment.Len; Tx6Token->Packet.TxData->FragmentTable[0].FragmentLength = Fragment.Len;
Tx6Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *) Fragment.Bulk; Tx6Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *)Fragment.Bulk;
} else { } else {
Tx6Token->Packet.TxData->DataLength = (UINT32) TxStringLen; Tx6Token->Packet.TxData->DataLength = (UINT32)TxStringLen;
Tx6Token->Packet.TxData->FragmentTable[0].FragmentLength = (UINT32) TxStringLen; Tx6Token->Packet.TxData->FragmentTable[0].FragmentLength = (UINT32)TxStringLen;
Tx6Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *) TxString; Tx6Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *)TxString;
} }
Tx6Token->CompletionToken.Status = EFI_NOT_READY; Tx6Token->CompletionToken.Status = EFI_NOT_READY;
@ -1659,10 +1635,10 @@ HttpTokenExist (
EFI_HTTP_TOKEN *Token; EFI_HTTP_TOKEN *Token;
EFI_HTTP_TOKEN *TokenInItem; EFI_HTTP_TOKEN *TokenInItem;
Token = (EFI_HTTP_TOKEN *) Context; Token = (EFI_HTTP_TOKEN *)Context;
TokenInItem = (EFI_HTTP_TOKEN *) Item->Key; TokenInItem = (EFI_HTTP_TOKEN *)Item->Key;
if (Token == TokenInItem || Token->Event == TokenInItem->Event) { if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
@ -1690,7 +1666,7 @@ HttpTcpNotReady (
{ {
HTTP_TOKEN_WRAP *ValueInItem; HTTP_TOKEN_WRAP *ValueInItem;
ValueInItem = (HTTP_TOKEN_WRAP *) Item->Value; ValueInItem = (HTTP_TOKEN_WRAP *)Item->Value;
if (!ValueInItem->TcpWrap.IsTxDone) { if (!ValueInItem->TcpWrap.IsTxDone) {
return EFI_NOT_READY; return EFI_NOT_READY;
@ -1728,7 +1704,7 @@ HttpTcpTransmit (
RequestMsg = NULL; RequestMsg = NULL;
ValueInItem = (HTTP_TOKEN_WRAP *) Item->Value; ValueInItem = (HTTP_TOKEN_WRAP *)Item->Value;
if (ValueInItem->TcpWrap.IsTxDone) { if (ValueInItem->TcpWrap.IsTxDone) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -1755,7 +1731,7 @@ HttpTcpTransmit (
); );
FreePool (Url); FreePool (Url);
if (EFI_ERROR (Status) || NULL == RequestMsg){ if (EFI_ERROR (Status) || (NULL == RequestMsg)) {
return Status; return Status;
} }
@ -1767,7 +1743,7 @@ HttpTcpTransmit (
Status = HttpTransmitTcp ( Status = HttpTransmitTcp (
ValueInItem->HttpInstance, ValueInItem->HttpInstance,
ValueInItem, ValueInItem,
(UINT8*) RequestMsg, (UINT8 *)RequestMsg,
RequestMsgSize RequestMsgSize
); );
FreePool (RequestMsg); FreePool (RequestMsg);
@ -1797,7 +1773,7 @@ HttpTcpReceive (
// //
// Process the queued HTTP response. // Process the queued HTTP response.
// //
return HttpResponseWorker ((HTTP_TOKEN_WRAP *) Item->Value); return HttpResponseWorker ((HTTP_TOKEN_WRAP *)Item->Value);
} }
/** /**
@ -1898,7 +1874,7 @@ HttpTcpReceiveHeader (
} }
Fragment.Len = Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength; Fragment.Len = Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength;
Fragment.Bulk = (UINT8 *) Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer; Fragment.Bulk = (UINT8 *)Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer;
} else { } else {
if (Fragment.Bulk != NULL) { if (Fragment.Bulk != NULL) {
FreePool (Fragment.Bulk); FreePool (Fragment.Bulk);
@ -1940,12 +1916,12 @@ HttpTcpReceiveHeader (
// Check whether we received end of HTTP headers. // Check whether we received end of HTTP headers.
// //
*EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR); *EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR);
}; }
// //
// Free the buffer. // Free the buffer.
// //
if (Rx4Token != NULL && Rx4Token->Packet.RxData != NULL && Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) { if ((Rx4Token != NULL) && (Rx4Token->Packet.RxData != NULL) && (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL)) {
FreePool (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer); FreePool (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL; Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
Fragment.Bulk = NULL; Fragment.Bulk = NULL;
@ -1998,7 +1974,7 @@ HttpTcpReceiveHeader (
} }
Fragment.Len = Rx6Token->Packet.RxData->FragmentTable[0].FragmentLength; Fragment.Len = Rx6Token->Packet.RxData->FragmentTable[0].FragmentLength;
Fragment.Bulk = (UINT8 *) Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer; Fragment.Bulk = (UINT8 *)Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer;
} else { } else {
if (Fragment.Bulk != NULL) { if (Fragment.Bulk != NULL) {
FreePool (Fragment.Bulk); FreePool (Fragment.Bulk);
@ -2040,12 +2016,12 @@ HttpTcpReceiveHeader (
// Check whether we received end of HTTP headers. // Check whether we received end of HTTP headers.
// //
*EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR); *EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR);
}; }
// //
// Free the buffer. // Free the buffer.
// //
if (Rx6Token != NULL && Rx6Token->Packet.RxData != NULL && Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) { if ((Rx6Token != NULL) && (Rx6Token->Packet.RxData != NULL) && (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL)) {
FreePool (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer); FreePool (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL; Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
Fragment.Bulk = NULL; Fragment.Bulk = NULL;
@ -2104,9 +2080,9 @@ HttpTcpReceiveBody (
if (HttpInstance->LocalAddressIsIPv6) { if (HttpInstance->LocalAddressIsIPv6) {
Rx6Token = &Wrap->TcpWrap.Rx6Token; Rx6Token = &Wrap->TcpWrap.Rx6Token;
Rx6Token ->Packet.RxData->DataLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength); Rx6Token->Packet.RxData->DataLength = (UINT32)MIN (MAX_UINT32, HttpMsg->BodyLength);
Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength); Rx6Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32)MIN (MAX_UINT32, HttpMsg->BodyLength);
Rx6Token ->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) HttpMsg->Body; Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *)HttpMsg->Body;
Rx6Token->CompletionToken.Status = EFI_NOT_READY; Rx6Token->CompletionToken.Status = EFI_NOT_READY;
Status = Tcp6->Receive (Tcp6, Rx6Token); Status = Tcp6->Receive (Tcp6, Rx6Token);
@ -2116,9 +2092,9 @@ HttpTcpReceiveBody (
} }
} else { } else {
Rx4Token = &Wrap->TcpWrap.Rx4Token; Rx4Token = &Wrap->TcpWrap.Rx4Token;
Rx4Token->Packet.RxData->DataLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength); Rx4Token->Packet.RxData->DataLength = (UINT32)MIN (MAX_UINT32, HttpMsg->BodyLength);
Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength); Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32)MIN (MAX_UINT32, HttpMsg->BodyLength);
Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) HttpMsg->Body; Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *)HttpMsg->Body;
Rx4Token->CompletionToken.Status = EFI_NOT_READY; Rx4Token->CompletionToken.Status = EFI_NOT_READY;
Status = Tcp4->Receive (Tcp4, Rx4Token); Status = Tcp4->Receive (Tcp4, Rx4Token);
@ -2129,7 +2105,6 @@ HttpTcpReceiveBody (
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
@ -2173,7 +2148,6 @@ HttpTcpTokenCleanup (
FreePool (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer); FreePool (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL; Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
} }
} else { } else {
Rx4Token = &Wrap->TcpWrap.Rx4Token; Rx4Token = &Wrap->TcpWrap.Rx4Token;
@ -2191,13 +2165,11 @@ HttpTcpTokenCleanup (
Rx4Token->CompletionToken.Event = NULL; Rx4Token->CompletionToken.Event = NULL;
} }
if (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) { if (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
FreePool (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer); FreePool (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL; Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
} }
} }
} }
/** /**
@ -2237,7 +2209,7 @@ HttpNotify (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
Handle, Handle,
&gEdkiiHttpCallbackProtocolGuid, &gEdkiiHttpCallbackProtocolGuid,
(VOID **) &HttpCallback (VOID **)&HttpCallback
); );
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
DEBUG ((DEBUG_INFO, "HttpNotify: Notifying %p\n", HttpCallback)); DEBUG ((DEBUG_INFO, "HttpNotify: Notifying %p\n", HttpCallback));
@ -2248,6 +2220,7 @@ HttpNotify (
); );
} }
} }
FreePool (Handles); FreePool (Handles);
} }
} }

View File

@ -22,7 +22,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
HTTP_SERVICE_SIGNATURE \ HTTP_SERVICE_SIGNATURE \
) )
// //
// The state of HTTP protocol. It starts from UNCONFIGED. // The state of HTTP protocol. It starts from UNCONFIGED.
// //
@ -203,7 +202,6 @@ typedef struct {
HTTP_TCP_TOKEN_WRAP TcpWrap; HTTP_TCP_TOKEN_WRAP TcpWrap;
} HTTP_TOKEN_WRAP; } HTTP_TOKEN_WRAP;
#define HTTP_PROTOCOL_SIGNATURE SIGNATURE_32('H', 't', 't', 'P') #define HTTP_PROTOCOL_SIGNATURE SIGNATURE_32('H', 't', 't', 'P')
#define HTTP_INSTANCE_FROM_PROTOCOL(a) \ #define HTTP_INSTANCE_FROM_PROTOCOL(a) \

View File

@ -48,15 +48,16 @@ AsciiStrCaseStr (
ASSERT (AsciiStrSize (SearchString) != 0); ASSERT (AsciiStrSize (SearchString) != 0);
if (*SearchString == '\0') { if (*SearchString == '\0') {
return (CHAR8 *) String; return (CHAR8 *)String;
} }
while (*String != '\0') { while (*String != '\0') {
SearchStringTmp = SearchString; SearchStringTmp = SearchString;
FirstMatch = String; FirstMatch = String;
while ((*SearchStringTmp != '\0') while ( (*SearchStringTmp != '\0')
&& (*String != '\0')) { && (*String != '\0'))
{
Src = *String; Src = *String;
Dst = *SearchStringTmp; Dst = *SearchStringTmp;
@ -77,7 +78,7 @@ AsciiStrCaseStr (
} }
if (*SearchStringTmp == '\0') { if (*SearchStringTmp == '\0') {
return (CHAR8 *) FirstMatch; return (CHAR8 *)FirstMatch;
} }
String = FirstMatch + 1; String = FirstMatch + 1;
@ -100,7 +101,7 @@ FreeNbufList (
{ {
ASSERT (Arg != NULL); ASSERT (Arg != NULL);
NetbufFreeList ((LIST_ENTRY *) Arg); NetbufFreeList ((LIST_ENTRY *)Arg);
FreePool (Arg); FreePool (Arg);
} }
@ -123,7 +124,7 @@ IsHttpsUrl (
Tmp = NULL; Tmp = NULL;
Tmp = AsciiStrCaseStr (Url, HTTPS_FLAG); Tmp = AsciiStrCaseStr (Url, HTTPS_FLAG);
if (Tmp != NULL && Tmp == Url) { if ((Tmp != NULL) && (Tmp == Url)) {
return TRUE; return TRUE;
} }
@ -161,7 +162,7 @@ TlsCreateChild (
gBS->LocateProtocol ( gBS->LocateProtocol (
&gEfiTlsServiceBindingProtocolGuid, &gEfiTlsServiceBindingProtocolGuid,
NULL, NULL,
(VOID **) TlsSb (VOID **)TlsSb
); );
if (*TlsSb == NULL) { if (*TlsSb == NULL) {
return NULL; return NULL;
@ -175,7 +176,7 @@ TlsCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
TlsChildHandle, TlsChildHandle,
&gEfiTlsProtocolGuid, &gEfiTlsProtocolGuid,
(VOID **) TlsProto, (VOID **)TlsProto,
ImageHandle, ImageHandle,
TlsChildHandle, TlsChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -188,7 +189,7 @@ TlsCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
TlsChildHandle, TlsChildHandle,
&gEfiTlsConfigurationProtocolGuid, &gEfiTlsConfigurationProtocolGuid,
(VOID **) TlsConfiguration, (VOID **)TlsConfiguration,
ImageHandle, ImageHandle,
TlsChildHandle, TlsChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -259,7 +260,7 @@ TlsCreateTxRxEvent (
HttpInstance->Tcp4TlsRxData.DataLength = 0; HttpInstance->Tcp4TlsRxData.DataLength = 0;
HttpInstance->Tcp4TlsRxData.FragmentCount = 1; HttpInstance->Tcp4TlsRxData.FragmentCount = 1;
HttpInstance->Tcp4TlsRxData.FragmentTable[0].FragmentLength = HttpInstance->Tcp4TlsRxData.DataLength ; HttpInstance->Tcp4TlsRxData.FragmentTable[0].FragmentLength = HttpInstance->Tcp4TlsRxData.DataLength;
HttpInstance->Tcp4TlsRxData.FragmentTable[0].FragmentBuffer = NULL; HttpInstance->Tcp4TlsRxData.FragmentTable[0].FragmentBuffer = NULL;
HttpInstance->Tcp4TlsRxToken.Packet.RxData = &HttpInstance->Tcp4TlsRxData; HttpInstance->Tcp4TlsRxToken.Packet.RxData = &HttpInstance->Tcp4TlsRxData;
HttpInstance->Tcp4TlsRxToken.CompletionToken.Status = EFI_NOT_READY; HttpInstance->Tcp4TlsRxToken.CompletionToken.Status = EFI_NOT_READY;
@ -303,7 +304,7 @@ TlsCreateTxRxEvent (
HttpInstance->Tcp6TlsRxData.DataLength = 0; HttpInstance->Tcp6TlsRxData.DataLength = 0;
HttpInstance->Tcp6TlsRxData.FragmentCount = 1; HttpInstance->Tcp6TlsRxData.FragmentCount = 1;
HttpInstance->Tcp6TlsRxData.FragmentTable[0].FragmentLength = HttpInstance->Tcp6TlsRxData.DataLength ; HttpInstance->Tcp6TlsRxData.FragmentTable[0].FragmentLength = HttpInstance->Tcp6TlsRxData.DataLength;
HttpInstance->Tcp6TlsRxData.FragmentTable[0].FragmentBuffer = NULL; HttpInstance->Tcp6TlsRxData.FragmentTable[0].FragmentBuffer = NULL;
HttpInstance->Tcp6TlsRxToken.Packet.RxData = &HttpInstance->Tcp6TlsRxData; HttpInstance->Tcp6TlsRxToken.Packet.RxData = &HttpInstance->Tcp6TlsRxData;
HttpInstance->Tcp6TlsRxToken.CompletionToken.Status = EFI_NOT_READY; HttpInstance->Tcp6TlsRxToken.CompletionToken.Status = EFI_NOT_READY;
@ -335,7 +336,7 @@ TlsCloseTxRxEvent (
ASSERT (HttpInstance != NULL); ASSERT (HttpInstance != NULL);
if (!HttpInstance->LocalAddressIsIPv6) { if (!HttpInstance->LocalAddressIsIPv6) {
if (NULL != HttpInstance->Tcp4TlsTxToken.CompletionToken.Event) { if (NULL != HttpInstance->Tcp4TlsTxToken.CompletionToken.Event) {
gBS->CloseEvent(HttpInstance->Tcp4TlsTxToken.CompletionToken.Event); gBS->CloseEvent (HttpInstance->Tcp4TlsTxToken.CompletionToken.Event);
HttpInstance->Tcp4TlsTxToken.CompletionToken.Event = NULL; HttpInstance->Tcp4TlsTxToken.CompletionToken.Event = NULL;
} }
@ -345,7 +346,7 @@ TlsCloseTxRxEvent (
} }
} else { } else {
if (NULL != HttpInstance->Tcp6TlsTxToken.CompletionToken.Event) { if (NULL != HttpInstance->Tcp6TlsTxToken.CompletionToken.Event) {
gBS->CloseEvent(HttpInstance->Tcp6TlsTxToken.CompletionToken.Event); gBS->CloseEvent (HttpInstance->Tcp6TlsTxToken.CompletionToken.Event);
HttpInstance->Tcp6TlsTxToken.CompletionToken.Event = NULL; HttpInstance->Tcp6TlsTxToken.CompletionToken.Event = NULL;
} }
@ -396,7 +397,7 @@ TlsConfigCertificate (
NULL NULL
); );
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
return Status; return Status;
} }
@ -429,60 +430,80 @@ TlsConfigCertificate (
// //
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
CertCount = 0; CertCount = 0;
ItemDataSize = (UINT32) CACertSize; ItemDataSize = (UINT32)CACertSize;
while (ItemDataSize > 0) { while (ItemDataSize > 0) {
if (ItemDataSize < sizeof (EFI_SIGNATURE_LIST)) { if (ItemDataSize < sizeof (EFI_SIGNATURE_LIST)) {
DEBUG ((DEBUG_ERROR, "%a: truncated EFI_SIGNATURE_LIST header\n", DEBUG ((
__FUNCTION__)); DEBUG_ERROR,
"%a: truncated EFI_SIGNATURE_LIST header\n",
__FUNCTION__
));
goto FreeCACert; goto FreeCACert;
} }
CertList = (EFI_SIGNATURE_LIST *) (CACert + (CACertSize - ItemDataSize)); CertList = (EFI_SIGNATURE_LIST *)(CACert + (CACertSize - ItemDataSize));
if (CertList->SignatureListSize < sizeof (EFI_SIGNATURE_LIST)) { if (CertList->SignatureListSize < sizeof (EFI_SIGNATURE_LIST)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"%a: SignatureListSize too small for EFI_SIGNATURE_LIST\n", "%a: SignatureListSize too small for EFI_SIGNATURE_LIST\n",
__FUNCTION__)); __FUNCTION__
));
goto FreeCACert; goto FreeCACert;
} }
if (CertList->SignatureListSize > ItemDataSize) { if (CertList->SignatureListSize > ItemDataSize) {
DEBUG ((DEBUG_ERROR, "%a: truncated EFI_SIGNATURE_LIST body\n", DEBUG ((
__FUNCTION__)); DEBUG_ERROR,
"%a: truncated EFI_SIGNATURE_LIST body\n",
__FUNCTION__
));
goto FreeCACert; goto FreeCACert;
} }
if (!CompareGuid (&CertList->SignatureType, &gEfiCertX509Guid)) { if (!CompareGuid (&CertList->SignatureType, &gEfiCertX509Guid)) {
DEBUG ((DEBUG_ERROR, "%a: only X509 certificates are supported\n", DEBUG ((
__FUNCTION__)); DEBUG_ERROR,
"%a: only X509 certificates are supported\n",
__FUNCTION__
));
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto FreeCACert; goto FreeCACert;
} }
if (CertList->SignatureHeaderSize != 0) { if (CertList->SignatureHeaderSize != 0) {
DEBUG ((DEBUG_ERROR, "%a: SignatureHeaderSize must be 0 for X509\n", DEBUG ((
__FUNCTION__)); DEBUG_ERROR,
"%a: SignatureHeaderSize must be 0 for X509\n",
__FUNCTION__
));
goto FreeCACert; goto FreeCACert;
} }
if (CertList->SignatureSize < sizeof (EFI_SIGNATURE_DATA)) { if (CertList->SignatureSize < sizeof (EFI_SIGNATURE_DATA)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
"%a: SignatureSize too small for EFI_SIGNATURE_DATA\n", __FUNCTION__)); DEBUG_ERROR,
"%a: SignatureSize too small for EFI_SIGNATURE_DATA\n",
__FUNCTION__
));
goto FreeCACert; goto FreeCACert;
} }
CertArraySizeInBytes = (CertList->SignatureListSize - CertArraySizeInBytes = (CertList->SignatureListSize -
sizeof (EFI_SIGNATURE_LIST)); sizeof (EFI_SIGNATURE_LIST));
if (CertArraySizeInBytes % CertList->SignatureSize != 0) { if (CertArraySizeInBytes % CertList->SignatureSize != 0) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"%a: EFI_SIGNATURE_DATA array not a multiple of SignatureSize\n", "%a: EFI_SIGNATURE_DATA array not a multiple of SignatureSize\n",
__FUNCTION__)); __FUNCTION__
));
goto FreeCACert; goto FreeCACert;
} }
CertCount += CertArraySizeInBytes / CertList->SignatureSize; CertCount += CertArraySizeInBytes / CertList->SignatureSize;
ItemDataSize -= CertList->SignatureListSize; ItemDataSize -= CertList->SignatureListSize;
} }
if (CertCount == 0) { if (CertCount == 0) {
DEBUG ((DEBUG_ERROR, "%a: no X509 certificates provided\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: no X509 certificates provided\n", __FUNCTION__));
goto FreeCACert; goto FreeCACert;
@ -491,10 +512,10 @@ TlsConfigCertificate (
// //
// Enumerate all data and erasing the target item. // Enumerate all data and erasing the target item.
// //
ItemDataSize = (UINT32) CACertSize; ItemDataSize = (UINT32)CACertSize;
CertList = (EFI_SIGNATURE_LIST *) CACert; CertList = (EFI_SIGNATURE_LIST *)CACert;
while ((ItemDataSize > 0) && (ItemDataSize >= CertList->SignatureListSize)) { while ((ItemDataSize > 0) && (ItemDataSize >= CertList->SignatureListSize)) {
Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) CertList + sizeof (EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize); Cert = (EFI_SIGNATURE_DATA *)((UINT8 *)CertList + sizeof (EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize);
CertCount = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize; CertCount = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;
for (Index = 0; Index < CertCount; Index++) { for (Index = 0; Index < CertCount; Index++) {
// //
@ -510,11 +531,11 @@ TlsConfigCertificate (
goto FreeCACert; goto FreeCACert;
} }
Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) Cert + CertList->SignatureSize); Cert = (EFI_SIGNATURE_DATA *)((UINT8 *)Cert + CertList->SignatureSize);
} }
ItemDataSize -= CertList->SignatureListSize; ItemDataSize -= CertList->SignatureListSize;
CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize); CertList = (EFI_SIGNATURE_LIST *)((UINT8 *)CertList + CertList->SignatureListSize);
} }
FreeCACert: FreeCACert:
@ -679,7 +700,7 @@ TlsConfigureSession (
// Tls Cipher List // Tls Cipher List
// //
Status = TlsConfigCipherList (HttpInstance); Status = TlsConfigCipherList (HttpInstance);
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
DEBUG ((DEBUG_ERROR, "TlsConfigCipherList: return %r error.\n", Status)); DEBUG ((DEBUG_ERROR, "TlsConfigCipherList: return %r error.\n", Status));
return Status; return Status;
} }
@ -751,22 +772,22 @@ TlsCommonTransmit (
} }
if (!HttpInstance->LocalAddressIsIPv6) { if (!HttpInstance->LocalAddressIsIPv6) {
((EFI_TCP4_TRANSMIT_DATA *) Data)->Push = TRUE; ((EFI_TCP4_TRANSMIT_DATA *)Data)->Push = TRUE;
((EFI_TCP4_TRANSMIT_DATA *) Data)->Urgent = FALSE; ((EFI_TCP4_TRANSMIT_DATA *)Data)->Urgent = FALSE;
((EFI_TCP4_TRANSMIT_DATA *) Data)->DataLength = Packet->TotalSize; ((EFI_TCP4_TRANSMIT_DATA *)Data)->DataLength = Packet->TotalSize;
// //
// Build the fragment table. // Build the fragment table.
// //
((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentCount = Packet->BlockOpNum; ((EFI_TCP4_TRANSMIT_DATA *)Data)->FragmentCount = Packet->BlockOpNum;
NetbufBuildExt ( NetbufBuildExt (
Packet, Packet,
(NET_FRAGMENT *) &((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentTable[0], (NET_FRAGMENT *)&((EFI_TCP4_TRANSMIT_DATA *)Data)->FragmentTable[0],
&((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentCount &((EFI_TCP4_TRANSMIT_DATA *)Data)->FragmentCount
); );
HttpInstance->Tcp4TlsTxToken.Packet.TxData = (EFI_TCP4_TRANSMIT_DATA *) Data; HttpInstance->Tcp4TlsTxToken.Packet.TxData = (EFI_TCP4_TRANSMIT_DATA *)Data;
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
@ -785,22 +806,22 @@ TlsCommonTransmit (
HttpInstance->TlsIsTxDone = FALSE; HttpInstance->TlsIsTxDone = FALSE;
Status = HttpInstance->Tcp4TlsTxToken.CompletionToken.Status; Status = HttpInstance->Tcp4TlsTxToken.CompletionToken.Status;
} else { } else {
((EFI_TCP6_TRANSMIT_DATA *) Data)->Push = TRUE; ((EFI_TCP6_TRANSMIT_DATA *)Data)->Push = TRUE;
((EFI_TCP6_TRANSMIT_DATA *) Data)->Urgent = FALSE; ((EFI_TCP6_TRANSMIT_DATA *)Data)->Urgent = FALSE;
((EFI_TCP6_TRANSMIT_DATA *) Data)->DataLength = Packet->TotalSize; ((EFI_TCP6_TRANSMIT_DATA *)Data)->DataLength = Packet->TotalSize;
// //
// Build the fragment table. // Build the fragment table.
// //
((EFI_TCP6_TRANSMIT_DATA *) Data)->FragmentCount = Packet->BlockOpNum; ((EFI_TCP6_TRANSMIT_DATA *)Data)->FragmentCount = Packet->BlockOpNum;
NetbufBuildExt ( NetbufBuildExt (
Packet, Packet,
(NET_FRAGMENT *) &((EFI_TCP6_TRANSMIT_DATA *) Data)->FragmentTable[0], (NET_FRAGMENT *)&((EFI_TCP6_TRANSMIT_DATA *)Data)->FragmentTable[0],
&((EFI_TCP6_TRANSMIT_DATA *) Data)->FragmentCount &((EFI_TCP6_TRANSMIT_DATA *)Data)->FragmentCount
); );
HttpInstance->Tcp6TlsTxToken.Packet.TxData = (EFI_TCP6_TRANSMIT_DATA *) Data; HttpInstance->Tcp6TlsTxToken.Packet.TxData = (EFI_TCP6_TRANSMIT_DATA *)Data;
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
@ -879,12 +900,14 @@ TlsCommonReceive (
if (Tcp4RxData == NULL) { if (Tcp4RxData == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Tcp4RxData->FragmentCount = 1; Tcp4RxData->FragmentCount = 1;
} else { } else {
Tcp6RxData = HttpInstance->Tcp6TlsRxToken.Packet.RxData; Tcp6RxData = HttpInstance->Tcp6TlsRxToken.Packet.RxData;
if (Tcp6RxData == NULL) { if (Tcp6RxData == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Tcp6RxData->FragmentCount = 1; Tcp6RxData->FragmentCount = 1;
} }
@ -903,6 +926,7 @@ TlsCommonReceive (
Tcp6RxData->FragmentTable[0].FragmentBuffer = Fragment[CurrentFragment].Bulk; Tcp6RxData->FragmentTable[0].FragmentBuffer = Fragment[CurrentFragment].Bulk;
Status = HttpInstance->Tcp6->Receive (HttpInstance->Tcp6, &HttpInstance->Tcp6TlsRxToken); Status = HttpInstance->Tcp6->Receive (HttpInstance->Tcp6, &HttpInstance->Tcp6TlsRxToken);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -1041,23 +1065,24 @@ TlsReceiveOnePdu (
goto ON_EXIT; goto ON_EXIT;
} }
RecordHeader = *(TLS_RECORD_HEADER *) Header; RecordHeader = *(TLS_RECORD_HEADER *)Header;
if ((RecordHeader.ContentType == TlsContentTypeHandshake || if (((RecordHeader.ContentType == TlsContentTypeHandshake) ||
RecordHeader.ContentType == TlsContentTypeAlert || (RecordHeader.ContentType == TlsContentTypeAlert) ||
RecordHeader.ContentType == TlsContentTypeChangeCipherSpec || (RecordHeader.ContentType == TlsContentTypeChangeCipherSpec) ||
RecordHeader.ContentType == TlsContentTypeApplicationData) && (RecordHeader.ContentType == TlsContentTypeApplicationData)) &&
(RecordHeader.Version.Major == 0x03) && /// Major versions are same. (RecordHeader.Version.Major == 0x03) && /// Major versions are same.
(RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR || ((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
RecordHeader.Version.Minor ==TLS11_PROTOCOL_VERSION_MINOR || (RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR) (RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
) { )
{
InsertTailList (NbufList, &PduHdr->List); InsertTailList (NbufList, &PduHdr->List);
} else { } else {
Status = EFI_PROTOCOL_ERROR; Status = EFI_PROTOCOL_ERROR;
goto ON_EXIT; goto ON_EXIT;
} }
Len = SwapBytes16(RecordHeader.Length); Len = SwapBytes16 (RecordHeader.Length);
if (Len == 0) { if (Len == 0) {
// //
// No TLS payload. // No TLS payload.
@ -1190,6 +1215,7 @@ TlsConnectSession (
&BufferOutSize &BufferOutSize
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (BufferOut); FreePool (BufferOut);
return Status; return Status;
@ -1198,8 +1224,8 @@ TlsConnectSession (
// //
// Transmit ClientHello // Transmit ClientHello
// //
PacketOut = NetbufAlloc ((UINT32) BufferOutSize); PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL); DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) { if (DataOut == NULL) {
FreePool (BufferOut); FreePool (BufferOut);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -1215,8 +1241,9 @@ TlsConnectSession (
return Status; return Status;
} }
while(HttpInstance->TlsSessionState != EfiTlsSessionDataTransferring && \ while (HttpInstance->TlsSessionState != EfiTlsSessionDataTransferring && \
((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout)))) { ((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout))))
{
// //
// Receive one TLS record. // Receive one TLS record.
// //
@ -1283,8 +1310,8 @@ TlsConnectSession (
// //
// Transmit the response packet. // Transmit the response packet.
// //
PacketOut = NetbufAlloc ((UINT32) BufferOutSize); PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL); DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) { if (DataOut == NULL) {
FreePool (BufferOut); FreePool (BufferOut);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -1335,17 +1362,18 @@ TlsConnectSession (
&GetSessionDataBufferSize &GetSessionDataBufferSize
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool(GetSessionDataBuffer); FreePool (GetSessionDataBuffer);
return Status; return Status;
} }
ASSERT(GetSessionDataBufferSize == sizeof (EFI_TLS_SESSION_STATE)); ASSERT (GetSessionDataBufferSize == sizeof (EFI_TLS_SESSION_STATE));
HttpInstance->TlsSessionState = *(EFI_TLS_SESSION_STATE *) GetSessionDataBuffer; HttpInstance->TlsSessionState = *(EFI_TLS_SESSION_STATE *)GetSessionDataBuffer;
FreePool (GetSessionDataBuffer); FreePool (GetSessionDataBuffer);
if(HttpInstance->TlsSessionState == EfiTlsSessionError) { if (HttpInstance->TlsSessionState == EfiTlsSessionError) {
return EFI_ABORTED; return EFI_ABORTED;
} }
} }
@ -1439,8 +1467,8 @@ TlsCloseSession (
return Status; return Status;
} }
PacketOut = NetbufAlloc ((UINT32) BufferOutSize); PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL); DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) { if (DataOut == NULL) {
FreePool (BufferOut); FreePool (BufferOut);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -1515,7 +1543,7 @@ TlsProcessMessage (
goto ON_EXIT; goto ON_EXIT;
} }
FragmentTable->FragmentLength = (UINT32) MessageSize; FragmentTable->FragmentLength = (UINT32)MessageSize;
FragmentTable->FragmentBuffer = Message; FragmentTable->FragmentBuffer = Message;
// //
@ -1575,9 +1603,10 @@ TlsProcessMessage (
ON_EXIT: ON_EXIT:
if (OriginalFragmentTable != NULL) { if (OriginalFragmentTable != NULL) {
if( FragmentTable == OriginalFragmentTable) { if ( FragmentTable == OriginalFragmentTable) {
FragmentTable = NULL; FragmentTable = NULL;
} }
FreePool (OriginalFragmentTable); FreePool (OriginalFragmentTable);
OriginalFragmentTable = NULL; OriginalFragmentTable = NULL;
} }
@ -1654,21 +1683,22 @@ HttpsReceive (
return Status; return Status;
} }
NetbufCopy (Pdu, 0, (UINT32) BufferInSize, BufferIn); NetbufCopy (Pdu, 0, (UINT32)BufferInSize, BufferIn);
NetbufFree (Pdu); NetbufFree (Pdu);
// //
// Handle Receive data. // Handle Receive data.
// //
RecordHeader = *(TLS_RECORD_HEADER *) BufferIn; RecordHeader = *(TLS_RECORD_HEADER *)BufferIn;
if ((RecordHeader.ContentType == TlsContentTypeApplicationData) && if ((RecordHeader.ContentType == TlsContentTypeApplicationData) &&
(RecordHeader.Version.Major == 0x03) && (RecordHeader.Version.Major == 0x03) &&
(RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR || ((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR || (RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR) (RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
) { )
{
// //
// Decrypt Packet. // Decrypt Packet.
// //
@ -1718,14 +1748,15 @@ HttpsReceive (
&BufferOutSize &BufferOutSize
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool(BufferOut); FreePool (BufferOut);
return Status; return Status;
} }
if (BufferOutSize != 0) { if (BufferOutSize != 0) {
PacketOut = NetbufAlloc ((UINT32)BufferOutSize); PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL); DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) { if (DataOut == NULL) {
FreePool (BufferOut); FreePool (BufferOut);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -1738,7 +1769,7 @@ HttpsReceive (
NetbufFree (PacketOut); NetbufFree (PacketOut);
} }
FreePool(BufferOut); FreePool (BufferOut);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -1753,9 +1784,9 @@ HttpsReceive (
// //
// Parsing buffer. // Parsing buffer.
// //
ASSERT (((TLS_RECORD_HEADER *) (TempFragment.Bulk))->ContentType == TlsContentTypeApplicationData); ASSERT (((TLS_RECORD_HEADER *)(TempFragment.Bulk))->ContentType == TlsContentTypeApplicationData);
BufferInSize = ((TLS_RECORD_HEADER *) (TempFragment.Bulk))->Length; BufferInSize = ((TLS_RECORD_HEADER *)(TempFragment.Bulk))->Length;
BufferIn = AllocateZeroPool (BufferInSize); BufferIn = AllocateZeroPool (BufferInSize);
if (BufferIn == NULL) { if (BufferIn == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -1768,13 +1799,13 @@ HttpsReceive (
// Free the buffer in TempFragment. // Free the buffer in TempFragment.
// //
FreePool (TempFragment.Bulk); FreePool (TempFragment.Bulk);
} else if ((RecordHeader.ContentType == TlsContentTypeAlert) && } else if ((RecordHeader.ContentType == TlsContentTypeAlert) &&
(RecordHeader.Version.Major == 0x03) && (RecordHeader.Version.Major == 0x03) &&
(RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR || ((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR || (RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR) (RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
) { )
{
BufferOutSize = DEF_BUF_LEN; BufferOutSize = DEF_BUF_LEN;
BufferOut = AllocateZeroPool (BufferOutSize); BufferOut = AllocateZeroPool (BufferOutSize);
if (BufferOut == NULL) { if (BufferOut == NULL) {
@ -1816,8 +1847,8 @@ HttpsReceive (
} }
if (BufferOutSize != 0) { if (BufferOutSize != 0) {
PacketOut = NetbufAlloc ((UINT32) BufferOutSize); PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL); DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
if (DataOut == NULL) { if (DataOut == NULL) {
FreePool (BufferOut); FreePool (BufferOut);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -1863,17 +1894,18 @@ HttpsReceive (
&GetSessionDataBufferSize &GetSessionDataBufferSize
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (GetSessionDataBuffer); FreePool (GetSessionDataBuffer);
return Status; return Status;
} }
ASSERT(GetSessionDataBufferSize == sizeof (EFI_TLS_SESSION_STATE)); ASSERT (GetSessionDataBufferSize == sizeof (EFI_TLS_SESSION_STATE));
HttpInstance->TlsSessionState = *(EFI_TLS_SESSION_STATE *) GetSessionDataBuffer; HttpInstance->TlsSessionState = *(EFI_TLS_SESSION_STATE *)GetSessionDataBuffer;
FreePool (GetSessionDataBuffer); FreePool (GetSessionDataBuffer);
if(HttpInstance->TlsSessionState == EfiTlsSessionError) { if (HttpInstance->TlsSessionState == EfiTlsSessionError) {
DEBUG ((DEBUG_ERROR, "TLS Session State Error!\n")); DEBUG ((DEBUG_ERROR, "TLS Session State Error!\n"));
return EFI_ABORTED; return EFI_ABORTED;
} }
@ -1883,7 +1915,7 @@ HttpsReceive (
} }
Fragment->Bulk = BufferIn; Fragment->Bulk = BufferIn;
Fragment->Len = (UINT32) BufferInSize; Fragment->Len = (UINT32)BufferInSize;
return Status; return Status;
} }

View File

@ -262,4 +262,3 @@ HttpsReceive (
); );
#endif #endif

View File

@ -9,7 +9,6 @@
#include "HttpUtilitiesDxe.h" #include "HttpUtilitiesDxe.h"
/** /**
Unloads an image. Unloads an image.
@ -31,7 +30,6 @@ HttpUtilitiesDxeUnload (
UINT32 Index; UINT32 Index;
EFI_HTTP_UTILITIES_PROTOCOL *HttpUtilitiesProtocol; EFI_HTTP_UTILITIES_PROTOCOL *HttpUtilitiesProtocol;
HandleBuffer = NULL; HandleBuffer = NULL;
// //
@ -55,7 +53,7 @@ HttpUtilitiesDxeUnload (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiHttpUtilitiesProtocolGuid, &gEfiHttpUtilitiesProtocolGuid,
(VOID **) &HttpUtilitiesProtocol, (VOID **)&HttpUtilitiesProtocol,
ImageHandle, ImageHandle,
NULL, NULL,
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
@ -69,7 +67,8 @@ HttpUtilitiesDxeUnload (
// //
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiHttpUtilitiesProtocolGuid, HttpUtilitiesProtocol, &gEfiHttpUtilitiesProtocolGuid,
HttpUtilitiesProtocol,
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -80,7 +79,6 @@ HttpUtilitiesDxeUnload (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This is the declaration of an EFI image entry point. This entry point is This is the declaration of an EFI image entry point. This entry point is
the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
@ -117,4 +115,3 @@ HttpUtilitiesDxeDriverEntryPoint (
return Status; return Status;
} }

View File

@ -81,7 +81,6 @@ HttpUtilitiesBuild (
OUT VOID **NewMessage OUT VOID **NewMessage
); );
/** /**
Parses HTTP header and produces an array of key/value pairs. Parses HTTP header and produces an array of key/value pairs.

View File

@ -14,7 +14,6 @@ EFI_HTTP_UTILITIES_PROTOCOL mHttpUtilitiesProtocol = {
HttpUtilitiesParse HttpUtilitiesParse
}; };
/** /**
Create HTTP header based on a combination of seed header, fields Create HTTP header based on a combination of seed header, fields
to delete, and fields to append. to delete, and fields to append.
@ -106,8 +105,8 @@ HttpUtilitiesBuild (
// //
// Handle DeleteList // Handle DeleteList
// //
if (SeedFieldCount != 0 && DeleteCount != 0) { if ((SeedFieldCount != 0) && (DeleteCount != 0)) {
TempHeaderFields = AllocateZeroPool (SeedFieldCount * sizeof(EFI_HTTP_HEADER)); TempHeaderFields = AllocateZeroPool (SeedFieldCount * sizeof (EFI_HTTP_HEADER));
if (TempHeaderFields == NULL) { if (TempHeaderFields == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -117,7 +116,7 @@ HttpUtilitiesBuild (
// //
// Check whether each SeedHeaderFields member is in DeleteList // Check whether each SeedHeaderFields member is in DeleteList
// //
if (HttpIsValidHttpHeader( DeleteList, DeleteCount, SeedHeaderFields[Index].FieldName)) { if (HttpIsValidHttpHeader (DeleteList, DeleteCount, SeedHeaderFields[Index].FieldName)) {
Status = HttpSetFieldNameAndValue ( Status = HttpSetFieldNameAndValue (
&TempHeaderFields[TempFieldCount], &TempHeaderFields[TempFieldCount],
SeedHeaderFields[Index].FieldName, SeedHeaderFields[Index].FieldName,
@ -126,6 +125,7 @@ HttpUtilitiesBuild (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
TempFieldCount++; TempFieldCount++;
} }
} }
@ -176,6 +176,7 @@ HttpUtilitiesBuild (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
NewFieldCount++; NewFieldCount++;
} }
} }
@ -189,16 +190,17 @@ HttpUtilitiesBuild (
StrLength = AsciiStrLen (HttpHeader->FieldName); StrLength = AsciiStrLen (HttpHeader->FieldName);
*NewMessageSize += StrLength; *NewMessageSize += StrLength;
StrLength = sizeof(": ") - 1; StrLength = sizeof (": ") - 1;
*NewMessageSize += StrLength; *NewMessageSize += StrLength;
StrLength = AsciiStrLen (HttpHeader->FieldValue); StrLength = AsciiStrLen (HttpHeader->FieldValue);
*NewMessageSize += StrLength; *NewMessageSize += StrLength;
StrLength = sizeof("\r\n") - 1; StrLength = sizeof ("\r\n") - 1;
*NewMessageSize += StrLength; *NewMessageSize += StrLength;
} }
StrLength = sizeof("\r\n") - 1;
StrLength = sizeof ("\r\n") - 1;
*NewMessageSize += StrLength; *NewMessageSize += StrLength;
*NewMessage = AllocateZeroPool (*NewMessageSize); *NewMessage = AllocateZeroPool (*NewMessageSize);
@ -216,7 +218,7 @@ HttpUtilitiesBuild (
CopyMem (NewMessagePtr, HttpHeader->FieldName, StrLength); CopyMem (NewMessagePtr, HttpHeader->FieldName, StrLength);
NewMessagePtr += StrLength; NewMessagePtr += StrLength;
StrLength = sizeof(": ") - 1; StrLength = sizeof (": ") - 1;
CopyMem (NewMessagePtr, ": ", StrLength); CopyMem (NewMessagePtr, ": ", StrLength);
NewMessagePtr += StrLength; NewMessagePtr += StrLength;
@ -224,11 +226,12 @@ HttpUtilitiesBuild (
CopyMem (NewMessagePtr, HttpHeader->FieldValue, StrLength); CopyMem (NewMessagePtr, HttpHeader->FieldValue, StrLength);
NewMessagePtr += StrLength; NewMessagePtr += StrLength;
StrLength = sizeof("\r\n") - 1; StrLength = sizeof ("\r\n") - 1;
CopyMem (NewMessagePtr, "\r\n", StrLength); CopyMem (NewMessagePtr, "\r\n", StrLength);
NewMessagePtr += StrLength; NewMessagePtr += StrLength;
} }
StrLength = sizeof("\r\n") - 1;
StrLength = sizeof ("\r\n") - 1;
CopyMem (NewMessagePtr, "\r\n", StrLength); CopyMem (NewMessagePtr, "\r\n", StrLength);
NewMessagePtr += StrLength; NewMessagePtr += StrLength;
@ -239,21 +242,20 @@ HttpUtilitiesBuild (
// //
ON_EXIT: ON_EXIT:
if (SeedHeaderFields != NULL) { if (SeedHeaderFields != NULL) {
HttpFreeHeaderFields(SeedHeaderFields, SeedFieldCount); HttpFreeHeaderFields (SeedHeaderFields, SeedFieldCount);
} }
if (TempHeaderFields != NULL) { if (TempHeaderFields != NULL) {
HttpFreeHeaderFields(TempHeaderFields, TempFieldCount); HttpFreeHeaderFields (TempHeaderFields, TempFieldCount);
} }
if (NewHeaderFields != NULL) { if (NewHeaderFields != NULL) {
HttpFreeHeaderFields(NewHeaderFields, NewFieldCount); HttpFreeHeaderFields (NewHeaderFields, NewFieldCount);
} }
return Status; return Status;
} }
/** /**
Parses HTTP header and produces an array of key/value pairs. Parses HTTP header and produces an array of key/value pairs.
@ -302,7 +304,7 @@ HttpUtilitiesParse (
FieldValue = NULL; FieldValue = NULL;
Index = 0; Index = 0;
if (This == NULL || HttpMessage == NULL || HeaderFields == NULL || FieldCount == NULL) { if ((This == NULL) || (HttpMessage == NULL) || (HeaderFields == NULL) || (FieldCount == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -328,7 +330,7 @@ HttpUtilitiesParse (
FieldValue = NULL; FieldValue = NULL;
NextToken = HttpGetFieldNameAndValue (Token, &FieldName, &FieldValue); NextToken = HttpGetFieldNameAndValue (Token, &FieldName, &FieldValue);
Token = NextToken; Token = NextToken;
if (FieldName == NULL || FieldValue == NULL) { if ((FieldName == NULL) || (FieldValue == NULL)) {
break; break;
} }
@ -343,7 +345,7 @@ HttpUtilitiesParse (
// //
// Allocate buffer for header // Allocate buffer for header
// //
*HeaderFields = AllocateZeroPool ((*FieldCount) * sizeof(EFI_HTTP_HEADER)); *HeaderFields = AllocateZeroPool ((*FieldCount) * sizeof (EFI_HTTP_HEADER));
if (*HeaderFields == NULL) { if (*HeaderFields == NULL) {
*FieldCount = 0; *FieldCount = 0;
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -361,7 +363,7 @@ HttpUtilitiesParse (
FieldValue = NULL; FieldValue = NULL;
NextToken = HttpGetFieldNameAndValue (Token, &FieldName, &FieldValue); NextToken = HttpGetFieldNameAndValue (Token, &FieldName, &FieldValue);
Token = NextToken; Token = NextToken;
if (FieldName == NULL || FieldValue == NULL) { if ((FieldName == NULL) || (FieldValue == NULL)) {
break; break;
} }

View File

@ -21,8 +21,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName =
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IScsiComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)IScsiComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IScsiComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)IScsiComponentNameGetControllerName,
"en" "en"
}; };
@ -91,7 +91,7 @@ IScsiComponentNameGetDriverName (
This->SupportedLanguages, This->SupportedLanguages,
mIScsiDriverNameTable, mIScsiDriverNameTable,
DriverName, DriverName,
(BOOLEAN) (This == &gIScsiComponentName) (BOOLEAN)(This == &gIScsiComponentName)
); );
} }
@ -268,7 +268,7 @@ IScsiComponentNameGetControllerName (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
IScsiController, IScsiController,
IScsiPrivateGuid, IScsiPrivateGuid,
(VOID **) &IScsiIdentifier, (VOID **)&IScsiIdentifier,
NULL, NULL,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -277,8 +277,8 @@ IScsiComponentNameGetControllerName (
return Status; return Status;
} }
if(ChildHandle != NULL) { if (ChildHandle != NULL) {
if(!Ipv6Flag) { if (!Ipv6Flag) {
// //
// Make sure this driver produced ChildHandle // Make sure this driver produced ChildHandle
// //

View File

@ -23,7 +23,7 @@ STATIC CONST CHAP_HASH mChapHash[] = {
Sha256Update, Sha256Update,
Sha256Final Sha256Final
}, },
#ifdef ENABLE_MD5_DEPRECATED_INTERFACES #ifdef ENABLE_MD5_DEPRECATED_INTERFACES
// //
// Keep the deprecated MD5 entry at the end of the array (making MD5 the // Keep the deprecated MD5 entry at the end of the array (making MD5 the
// least preferred choice of the initiator). // least preferred choice of the initiator).
@ -36,7 +36,7 @@ STATIC CONST CHAP_HASH mChapHash[] = {
Md5Update, Md5Update,
Md5Final Md5Final
}, },
#endif // ENABLE_MD5_DEPRECATED_INTERFACES #endif // ENABLE_MD5_DEPRECATED_INTERFACES
}; };
// //
@ -54,7 +54,7 @@ STATIC CHAR8 mChapHashListString[
// AsciiSPrint() // AsciiSPrint()
// truncation check // truncation check
1 // terminating NUL 1 // terminating NUL
]; ];
/** /**
Initiator calculates its own expected hash value. Initiator calculates its own expected hash value.
@ -117,7 +117,7 @@ IScsiCHAPCalculateResponse (
// //
// Hash Identifier - Only calculate 1 byte data (RFC1994) // Hash Identifier - Only calculate 1 byte data (RFC1994)
// //
IdByte[0] = (CHAR8) ChapIdentifier; IdByte[0] = (CHAR8)ChapIdentifier;
if (!Hash->Update (Ctx, IdByte, 1)) { if (!Hash->Update (Ctx, IdByte, 1)) {
goto Exit; goto Exit;
} }
@ -172,7 +172,7 @@ IScsiCHAPAuthTarget (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
SecretSize = (UINT32) AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret); SecretSize = (UINT32)AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
ASSERT (AuthData->Hash != NULL); ASSERT (AuthData->Hash != NULL);
@ -198,7 +198,6 @@ IScsiCHAPAuthTarget (
return Status; return Status;
} }
/** /**
This function checks the received iSCSI Login Response during the security This function checks the received iSCSI Login Response during the security
negotiation stage. negotiation stage.
@ -243,6 +242,7 @@ IScsiCHAPOnRspReceived (
if (Data == NULL) { if (Data == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Copy the data in case the data spans over multiple PDUs. // Copy the data in case the data spans over multiple PDUs.
// //
@ -251,7 +251,7 @@ IScsiCHAPOnRspReceived (
// //
// Build the key-value list from the data segment of the Login Response. // Build the key-value list from the data segment of the Login Response.
// //
KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len); KeyValueList = IScsiBuildKeyValueList ((CHAR8 *)Data, Len);
if (KeyValueList == NULL) { if (KeyValueList == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -277,7 +277,7 @@ IScsiCHAPOnRspReceived (
goto ON_EXIT; goto ON_EXIT;
} }
Session->TargetPortalGroupTag = (UINT16) Result; Session->TargetPortalGroupTag = (UINT16)Result;
Value = IScsiGetValueByKeyFromList ( Value = IScsiGetValueByKeyFromList (
KeyValueList, KeyValueList,
@ -286,6 +286,7 @@ IScsiCHAPOnRspReceived (
if (Value == NULL) { if (Value == NULL) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Initiator mandates CHAP authentication but target replies without // Initiator mandates CHAP authentication but target replies without
// "CHAP", or initiator suggets "None" but target replies with some kind of // "CHAP", or initiator suggets "None" but target replies with some kind of
@ -328,12 +329,14 @@ IScsiCHAPOnRspReceived (
break; break;
} }
} }
if (HashIndex == ARRAY_SIZE (mChapHash)) { if (HashIndex == ARRAY_SIZE (mChapHash)) {
// //
// Unsupported algorithm is chosen by target. // Unsupported algorithm is chosen by target.
// //
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Remember the target's chosen hash algorithm. // Remember the target's chosen hash algorithm.
// //
@ -355,6 +358,7 @@ IScsiCHAPOnRspReceived (
if (Challenge == NULL) { if (Challenge == NULL) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Process the CHAP identifier and CHAP Challenge from Target. // Process the CHAP identifier and CHAP Challenge from Target.
// Calculate Response value. // Calculate Response value.
@ -364,10 +368,10 @@ IScsiCHAPOnRspReceived (
goto ON_EXIT; goto ON_EXIT;
} }
AuthData->InIdentifier = (UINT32) Result; AuthData->InIdentifier = (UINT32)Result;
AuthData->InChallengeLength = (UINT32) sizeof (AuthData->InChallenge); AuthData->InChallengeLength = (UINT32)sizeof (AuthData->InChallenge);
Status = IScsiHexToBin ( Status = IScsiHexToBin (
(UINT8 *) AuthData->InChallenge, (UINT8 *)AuthData->InChallenge,
&AuthData->InChallengeLength, &AuthData->InChallengeLength,
Challenge Challenge
); );
@ -375,10 +379,11 @@ IScsiCHAPOnRspReceived (
Status = EFI_PROTOCOL_ERROR; Status = EFI_PROTOCOL_ERROR;
goto ON_EXIT; goto ON_EXIT;
} }
Status = IScsiCHAPCalculateResponse ( Status = IScsiCHAPCalculateResponse (
AuthData->InIdentifier, AuthData->InIdentifier,
AuthData->AuthConfig->CHAPSecret, AuthData->AuthConfig->CHAPSecret,
(UINT32) AsciiStrLen (AuthData->AuthConfig->CHAPSecret), (UINT32)AsciiStrLen (AuthData->AuthConfig->CHAPSecret),
AuthData->InChallenge, AuthData->InChallenge,
AuthData->InChallengeLength, AuthData->InChallengeLength,
AuthData->Hash, AuthData->Hash,
@ -420,7 +425,7 @@ IScsiCHAPOnRspReceived (
ASSERT (AuthData->Hash != NULL); ASSERT (AuthData->Hash != NULL);
RspLen = AuthData->Hash->DigestSize; RspLen = AuthData->Hash->DigestSize;
Status = IScsiHexToBin (TargetRsp, &RspLen, Response); Status = IScsiHexToBin (TargetRsp, &RspLen, Response);
if (EFI_ERROR (Status) || RspLen != AuthData->Hash->DigestSize) { if (EFI_ERROR (Status) || (RspLen != AuthData->Hash->DigestSize)) {
Status = EFI_PROTOCOL_ERROR; Status = EFI_PROTOCOL_ERROR;
goto ON_EXIT; goto ON_EXIT;
} }
@ -446,7 +451,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
This function fills the CHAP authentication information into the login PDU This function fills the CHAP authentication information into the login PDU
during the security negotiation stage in the iSCSI connection login. during the security negotiation stage in the iSCSI connection login.
@ -483,10 +487,11 @@ IScsiCHAPToSendReq (
Session = Conn->Session; Session = Conn->Session;
AuthData = &Session->AuthData.CHAP; AuthData = &Session->AuthData.CHAP;
LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0); LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufGetByte (Pdu, 0, 0);
if (LoginReq == NULL) { if (LoginReq == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3; RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
@ -552,14 +557,14 @@ IScsiCHAPToSendReq (
IScsiAddKeyValuePair ( IScsiAddKeyValuePair (
Pdu, Pdu,
ISCSI_KEY_CHAP_NAME, ISCSI_KEY_CHAP_NAME,
(CHAR8 *) &AuthData->AuthConfig->CHAPName (CHAR8 *)&AuthData->AuthConfig->CHAPName
); );
// //
// CHAP_R=<R> // CHAP_R=<R>
// //
ASSERT (AuthData->Hash != NULL); ASSERT (AuthData->Hash != NULL);
BinToHexStatus = IScsiBinToHex ( BinToHexStatus = IScsiBinToHex (
(UINT8 *) AuthData->CHAPResponse, (UINT8 *)AuthData->CHAPResponse,
AuthData->Hash->DigestSize, AuthData->Hash->DigestSize,
Response, Response,
&RspLen &RspLen
@ -571,18 +576,18 @@ IScsiCHAPToSendReq (
// //
// CHAP_I=<I> // CHAP_I=<I>
// //
IScsiGenRandom ((UINT8 *) &AuthData->OutIdentifier, 1); IScsiGenRandom ((UINT8 *)&AuthData->OutIdentifier, 1);
AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier); AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier);
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr); IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr);
// //
// CHAP_C=<C> // CHAP_C=<C>
// //
IScsiGenRandom ( IScsiGenRandom (
(UINT8 *) AuthData->OutChallenge, (UINT8 *)AuthData->OutChallenge,
AuthData->Hash->DigestSize AuthData->Hash->DigestSize
); );
BinToHexStatus = IScsiBinToHex ( BinToHexStatus = IScsiBinToHex (
(UINT8 *) AuthData->OutChallenge, (UINT8 *)AuthData->OutChallenge,
AuthData->Hash->DigestSize, AuthData->Hash->DigestSize,
Challenge, Challenge,
&ChallengeLen &ChallengeLen
@ -592,6 +597,7 @@ IScsiCHAPToSendReq (
Conn->AuthStep = ISCSI_CHAP_STEP_FOUR; Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
} }
// //
// Set the stage transition flag. // Set the stage transition flag.
// //

View File

@ -35,7 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define ISCSI_CHAP_STEP_THREE 3 #define ISCSI_CHAP_STEP_THREE 3
#define ISCSI_CHAP_STEP_FOUR 4 #define ISCSI_CHAP_STEP_FOUR 4
#pragma pack(1) #pragma pack(1)
typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA { typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
@ -53,19 +52,19 @@ typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
// //
typedef typedef
UINTN UINTN
(EFIAPI *CHAP_HASH_GET_CONTEXT_SIZE) ( (EFIAPI *CHAP_HASH_GET_CONTEXT_SIZE)(
VOID VOID
); );
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *CHAP_HASH_INIT) ( (EFIAPI *CHAP_HASH_INIT)(
OUT VOID *Context OUT VOID *Context
); );
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *CHAP_HASH_UPDATE) ( (EFIAPI *CHAP_HASH_UPDATE)(
IN OUT VOID *Context, IN OUT VOID *Context,
IN CONST VOID *Data, IN CONST VOID *Data,
IN UINTN DataSize IN UINTN DataSize
@ -73,7 +72,7 @@ BOOLEAN
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *CHAP_HASH_FINAL) ( (EFIAPI *CHAP_HASH_FINAL)(
IN OUT VOID *Context, IN OUT VOID *Context,
OUT UINT8 *HashValue OUT UINT8 *HashValue
); );
@ -133,6 +132,7 @@ EFI_STATUS
IScsiCHAPOnRspReceived ( IScsiCHAPOnRspReceived (
IN ISCSI_CONNECTION *Conn IN ISCSI_CONNECTION *Conn
); );
/** /**
This function fills the CHAP authentication information into the login PDU This function fills the CHAP authentication information into the login PDU
during the security negotiation stage in the iSCSI connection login. during the security negotiation stage in the iSCSI connection login.
@ -164,4 +164,5 @@ VOID
IScsiCHAPInitHashList ( IScsiCHAPInitHashList (
VOID VOID
); );
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,6 @@ extern UINT8 IScsiConfigVfrBin[];
extern UINT8 IScsiDxeStrings[]; extern UINT8 IScsiDxeStrings[];
extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo; extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo;
#define VAR_OFFSET(Field) \ #define VAR_OFFSET(Field) \
((UINT16) ((UINTN) &(((ISCSI_CONFIG_IFR_NVDATA *) 0)->Field))) ((UINT16) ((UINTN) &(((ISCSI_CONFIG_IFR_NVDATA *) 0)->Field)))
@ -80,7 +79,6 @@ extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo;
#define ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID QUESTION_ID (Keyword->ISCSIReverseChapSecret) #define ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID QUESTION_ID (Keyword->ISCSIReverseChapSecret)
#define ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIReverseChapSecret) #define ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIReverseChapSecret)
#define ISCSI_INITATOR_NAME_VAR_NAME L"I_NAME" #define ISCSI_INITATOR_NAME_VAR_NAME L"I_NAME"
#define ISCSI_CONFIG_VAR_ATTR (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE) #define ISCSI_CONFIG_VAR_ATTR (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE)

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "IScsiImpl.h" #include "IScsiImpl.h"
/** /**
Extract the Root Path option and get the required target information. Extract the Root Path option and get the required target information.
@ -46,18 +45,19 @@ IScsiDhcpExtractRootPath (
// //
// "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname> // "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>
// //
IScsiRootPathIdLen = (UINT8) AsciiStrLen (ISCSI_ROOT_PATH_ID); IScsiRootPathIdLen = (UINT8)AsciiStrLen (ISCSI_ROOT_PATH_ID);
if ((Length <= IScsiRootPathIdLen) || (CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) { if ((Length <= IScsiRootPathIdLen) || (CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// Skip the iSCSI RootPath ID "iscsi:". // Skip the iSCSI RootPath ID "iscsi:".
// //
RootPath += IScsiRootPathIdLen; RootPath += IScsiRootPathIdLen;
Length = (UINT8) (Length - IScsiRootPathIdLen); Length = (UINT8)(Length - IScsiRootPathIdLen);
TmpStr = (CHAR8 *) AllocatePool (Length + 1); TmpStr = (CHAR8 *)AllocatePool (Length + 1);
if (TmpStr == NULL) { if (TmpStr == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -88,7 +88,7 @@ IScsiDhcpExtractRootPath (
} }
if (Fields[FieldIndex].Str != NULL) { if (Fields[FieldIndex].Str != NULL) {
Fields[FieldIndex].Len = (UINT8) AsciiStrLen (Fields[FieldIndex].Str); Fields[FieldIndex].Len = (UINT8)AsciiStrLen (Fields[FieldIndex].Str);
} }
} }
} }
@ -101,11 +101,12 @@ IScsiDhcpExtractRootPath (
if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) || if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) ||
(Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) || (Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||
(Fields[RP_FIELD_IDX_PROTOCOL].Len > 1) (Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
) { )
{
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Get the IP address of the target. // Get the IP address of the target.
// //
@ -125,11 +126,12 @@ IScsiDhcpExtractRootPath (
if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) { if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len); CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
ConfigNvData->TargetUrl[Field->Len + 1] = '\0'; ConfigNvData->TargetUrl[Field->Len + 1] = '\0';
} else { } else {
ConfigNvData->DnsMode = FALSE; ConfigNvData->DnsMode = FALSE;
ZeroMem(ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl)); ZeroMem (ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);
CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));
@ -137,6 +139,7 @@ IScsiDhcpExtractRootPath (
goto ON_EXIT; goto ON_EXIT;
} }
} }
// //
// Check the protocol type. // Check the protocol type.
// //
@ -145,15 +148,17 @@ IScsiDhcpExtractRootPath (
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Get the port of the iSCSI target. // Get the port of the iSCSI target.
// //
Field = &Fields[RP_FIELD_IDX_PORT]; Field = &Fields[RP_FIELD_IDX_PORT];
if (Field->Str != NULL) { if (Field->Str != NULL) {
ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str); ConfigNvData->TargetPort = (UINT16)AsciiStrDecimalToUintn (Field->Str);
} else { } else {
ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT; ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
} }
// //
// Get the LUN. // Get the LUN.
// //
@ -166,6 +171,7 @@ IScsiDhcpExtractRootPath (
} else { } else {
ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun)); ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));
} }
// //
// Get the target iSCSI Name. // Get the target iSCSI Name.
// //
@ -175,6 +181,7 @@ IScsiDhcpExtractRootPath (
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Validate the iSCSI name. // Validate the iSCSI name.
// //
@ -253,9 +260,9 @@ IScsiDhcpSelectOffer (
} }
Status = IScsiDhcpExtractRootPath ( Status = IScsiDhcpExtractRootPath (
(CHAR8 *) &OptionList[Index]->Data[0], (CHAR8 *)&OptionList[Index]->Data[0],
OptionList[Index]->Length, OptionList[Index]->Length,
(ISCSI_ATTEMPT_CONFIG_NVDATA *) Context (ISCSI_ATTEMPT_CONFIG_NVDATA *)Context
); );
break; break;
@ -335,11 +342,11 @@ IScsiParseDhcpAck (
// Get DNS server addresses and DHCP server address from this offer. // Get DNS server addresses and DHCP server address from this offer.
// //
if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) { if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) {
if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) { if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
break; break;
} }
// //
// Primary DNS server address. // Primary DNS server address.
// //
@ -397,7 +404,7 @@ IScsiSetIp4Policy (
if (Policy != Ip4Config2PolicyStatic) { if (Policy != Ip4Config2PolicyStatic) {
Policy = Ip4Config2PolicyStatic; Policy = Ip4Config2PolicyStatic;
Status= Ip4Config2->SetData ( Status = Ip4Config2->SetData (
Ip4Config2, Ip4Config2,
Ip4Config2DataTypePolicy, Ip4Config2DataTypePolicy,
sizeof (EFI_IP4_CONFIG2_POLICY), sizeof (EFI_IP4_CONFIG2_POLICY),
@ -450,7 +457,7 @@ IScsiDoDhcp (
// //
MediaStatus = EFI_SUCCESS; MediaStatus = EFI_SUCCESS;
NetLibDetectMediaWaitTimeout (Controller, ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME, &MediaStatus); NetLibDetectMediaWaitTimeout (Controller, ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME, &MediaStatus);
if (MediaStatus!= EFI_SUCCESS) { if (MediaStatus != EFI_SUCCESS) {
AsciiPrint ("\n Error: Could not detect network connection.\n"); AsciiPrint ("\n Error: Could not detect network connection.\n");
return EFI_NO_MEDIA; return EFI_NO_MEDIA;
} }
@ -462,7 +469,7 @@ IScsiDoDhcp (
// will not be in the right state for the iSCSI to start a new round D.O.R.A. // will not be in the right state for the iSCSI to start a new round D.O.R.A.
// So, we need to switch its policy to static. // So, we need to switch its policy to static.
// //
Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = IScsiSetIp4Policy (Ip4Config2); Status = IScsiSetIp4Policy (Ip4Config2);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -486,7 +493,7 @@ IScsiDoDhcp (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dhcp4Handle, Dhcp4Handle,
&gEfiDhcp4ProtocolGuid, &gEfiDhcp4ProtocolGuid,
(VOID **) &Dhcp4, (VOID **)&Dhcp4,
Image, Image,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -507,7 +514,7 @@ IScsiDoDhcp (
// Ask the server to reply with Netmask, Router, DNS, and RootPath options. // Ask the server to reply with Netmask, Router, DNS, and RootPath options.
// //
ParaList->OpCode = DHCP4_TAG_PARA_LIST; ParaList->OpCode = DHCP4_TAG_PARA_LIST;
ParaList->Length = (UINT8) (NvData->TargetInfoFromDhcp ? 4 : 3); ParaList->Length = (UINT8)(NvData->TargetInfoFromDhcp ? 4 : 3);
ParaList->Data[0] = DHCP4_TAG_NETMASK; ParaList->Data[0] = DHCP4_TAG_NETMASK;
ParaList->Data[1] = DHCP4_TAG_ROUTER; ParaList->Data[1] = DHCP4_TAG_ROUTER;
ParaList->Data[2] = DHCP4_TAG_DNS_SERVER; ParaList->Data[2] = DHCP4_TAG_DNS_SERVER;
@ -534,6 +541,7 @@ IScsiDoDhcp (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Parse the ACK to get required information. // Parse the ACK to get required information.
// //

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "IScsiImpl.h" #include "IScsiImpl.h"
/** /**
Extract the Root Path option and get the required target information from Extract the Root Path option and get the required target information from
Boot File Uniform Resource Locator (URL) Option. Boot File Uniform Resource Locator (URL) Option.
@ -48,19 +47,21 @@ IScsiDhcp6ExtractRootPath (
// //
// "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname> // "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>
// //
IScsiRootPathIdLen = (UINT16) AsciiStrLen (ISCSI_ROOT_PATH_ID); IScsiRootPathIdLen = (UINT16)AsciiStrLen (ISCSI_ROOT_PATH_ID);
if ((Length <= IScsiRootPathIdLen) || if ((Length <= IScsiRootPathIdLen) ||
(CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) { (CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0))
{
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// Skip the iSCSI RootPath ID "iscsi:". // Skip the iSCSI RootPath ID "iscsi:".
// //
RootPath = RootPath + IScsiRootPathIdLen; RootPath = RootPath + IScsiRootPathIdLen;
Length = (UINT16) (Length - IScsiRootPathIdLen); Length = (UINT16)(Length - IScsiRootPathIdLen);
TmpStr = (CHAR8 *) AllocatePool (Length + 1); TmpStr = (CHAR8 *)AllocatePool (Length + 1);
if (TmpStr == NULL) { if (TmpStr == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -87,7 +88,7 @@ IScsiDhcp6ExtractRootPath (
Fields[RP_FIELD_IDX_SERVERNAME].Str = &TmpStr[Index]; Fields[RP_FIELD_IDX_SERVERNAME].Str = &TmpStr[Index];
if (!ConfigNvData->DnsMode) { if (!ConfigNvData->DnsMode) {
while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER)&& (Index < Length)) { while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER) && (Index < Length)) {
Index++; Index++;
} }
@ -100,6 +101,7 @@ IScsiDhcp6ExtractRootPath (
while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) { while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) {
Index++; Index++;
} }
// //
// Skip ':'. // Skip ':'.
// //
@ -107,13 +109,12 @@ IScsiDhcp6ExtractRootPath (
Index += 1; Index += 1;
} }
Fields[RP_FIELD_IDX_SERVERNAME].Len = (UINT8) AsciiStrLen (Fields[RP_FIELD_IDX_SERVERNAME].Str); Fields[RP_FIELD_IDX_SERVERNAME].Len = (UINT8)AsciiStrLen (Fields[RP_FIELD_IDX_SERVERNAME].Str);
// //
// Extract others fields in the Root Path option string. // Extract others fields in the Root Path option string.
// //
for (FieldIndex = 1; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) { for (FieldIndex = 1; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {
if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) { if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) {
Fields[FieldIndex].Str = &TmpStr[Index]; Fields[FieldIndex].Str = &TmpStr[Index];
} }
@ -129,7 +130,7 @@ IScsiDhcp6ExtractRootPath (
} }
if (Fields[FieldIndex].Str != NULL) { if (Fields[FieldIndex].Str != NULL) {
Fields[FieldIndex].Len = (UINT8) AsciiStrLen (Fields[FieldIndex].Str); Fields[FieldIndex].Len = (UINT8)AsciiStrLen (Fields[FieldIndex].Str);
} }
} }
} }
@ -142,11 +143,12 @@ IScsiDhcp6ExtractRootPath (
if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) || if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) ||
(Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) || (Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||
(Fields[RP_FIELD_IDX_PROTOCOL].Len > 1) (Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
) { )
{
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Get the IP address of the target. // Get the IP address of the target.
// //
@ -164,10 +166,11 @@ IScsiDhcp6ExtractRootPath (
if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) { if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len); CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
ConfigNvData->TargetUrl[Field->Len + 1] = '\0'; ConfigNvData->TargetUrl[Field->Len + 1] = '\0';
} else { } else {
ZeroMem(&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl)); ZeroMem (&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);
CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));
@ -184,15 +187,17 @@ IScsiDhcp6ExtractRootPath (
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Get the port of the iSCSI target. // Get the port of the iSCSI target.
// //
Field = &Fields[RP_FIELD_IDX_PORT]; Field = &Fields[RP_FIELD_IDX_PORT];
if (Field->Str != NULL) { if (Field->Str != NULL) {
ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str); ConfigNvData->TargetPort = (UINT16)AsciiStrDecimalToUintn (Field->Str);
} else { } else {
ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT; ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
} }
// //
// Get the LUN. // Get the LUN.
// //
@ -205,6 +210,7 @@ IScsiDhcp6ExtractRootPath (
} else { } else {
ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun)); ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));
} }
// //
// Get the target iSCSI Name. // Get the target iSCSI Name.
// //
@ -214,6 +220,7 @@ IScsiDhcp6ExtractRootPath (
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Validate the iSCSI name. // Validate the iSCSI name.
// //
@ -290,7 +297,7 @@ IScsiDhcp6ParseReply (
goto Exit; goto Exit;
} }
ConfigData = (ISCSI_ATTEMPT_CONFIG_NVDATA *) Context; ConfigData = (ISCSI_ATTEMPT_CONFIG_NVDATA *)Context;
for (Index = 0; Index < OptionCount; Index++) { for (Index = 0; Index < OptionCount; Index++) {
OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode); OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode);
@ -300,11 +307,11 @@ IScsiDhcp6ParseReply (
// Get DNS server addresses from this reply packet. // Get DNS server addresses from this reply packet.
// //
if (OptionList[Index]->OpCode == DHCP6_OPT_DNS_SERVERS) { if (OptionList[Index]->OpCode == DHCP6_OPT_DNS_SERVERS) {
if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) { if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto Exit; goto Exit;
} }
// //
// Primary DNS server address. // Primary DNS server address.
// //
@ -316,7 +323,6 @@ IScsiDhcp6ParseReply (
// //
CopyMem (&ConfigData->SecondaryDns, &OptionList[Index]->Data[16], sizeof (EFI_IPv6_ADDRESS)); CopyMem (&ConfigData->SecondaryDns, &OptionList[Index]->Data[16], sizeof (EFI_IPv6_ADDRESS));
} }
} else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_URL) { } else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_URL) {
// //
// The server sends this option to inform the client about an URL to a boot file. // The server sends this option to inform the client about an URL to a boot file.
@ -330,6 +336,7 @@ IScsiDhcp6ParseReply (
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto Exit; goto Exit;
} }
// //
// Check param-len 1, should be 16 bytes. // Check param-len 1, should be 16 bytes.
// //
@ -352,7 +359,7 @@ IScsiDhcp6ParseReply (
// Get iSCSI root path from Boot File Uniform Resource Locator (URL) Option // Get iSCSI root path from Boot File Uniform Resource Locator (URL) Option
// //
Status = IScsiDhcp6ExtractRootPath ( Status = IScsiDhcp6ExtractRootPath (
(CHAR8 *) BootFileOpt->Data, (CHAR8 *)BootFileOpt->Data,
BootFileOpt->OpLen, BootFileOpt->OpLen,
ConfigData ConfigData
); );
@ -363,7 +370,6 @@ Exit:
return Status; return Status;
} }
/** /**
Parse the DHCP ACK to get the address configuration and DNS information. Parse the DHCP ACK to get the address configuration and DNS information.
@ -435,7 +441,7 @@ IScsiDoDhcp6 (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dhcp6Handle, Dhcp6Handle,
&gEfiDhcp6ProtocolGuid, &gEfiDhcp6ProtocolGuid,
(VOID **) &Dhcp6, (VOID **)&Dhcp6,
Image, Image,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -493,7 +499,6 @@ IScsiDoDhcp6 (
} }
do { do {
TimerStatus = gBS->CheckEvent (Timer); TimerStatus = gBS->CheckEvent (Timer);
if (!EFI_ERROR (TimerStatus)) { if (!EFI_ERROR (TimerStatus)) {
@ -509,9 +514,7 @@ IScsiDoDhcp6 (
ConfigData ConfigData
); );
} }
} while (TimerStatus == EFI_NOT_READY); } while (TimerStatus == EFI_NOT_READY);
} }
ON_EXIT: ON_EXIT:
@ -542,4 +545,3 @@ ON_EXIT:
return Status; return Status;
} }

View File

@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define ISCSI_ROOT_PATH_ADDR_START_DELIMITER '[' #define ISCSI_ROOT_PATH_ADDR_START_DELIMITER '['
#define ISCSI_ROOT_PATH_ADDR_END_DELIMITER ']' #define ISCSI_ROOT_PATH_ADDR_END_DELIMITER ']'
/** /**
Extract the Root Path option and get the required target information from Extract the Root Path option and get the required target information from
Boot File Uniform Resource Locator (URL) Option. Boot File Uniform Resource Locator (URL) Option.

View File

@ -22,7 +22,7 @@ IScsiCommonNotify (
IN VOID *Context IN VOID *Context
) )
{ {
*((BOOLEAN *) Context) = TRUE; *((BOOLEAN *)Context) = TRUE;
} }
/** /**
@ -66,7 +66,7 @@ IScsiDns4 (
// //
// Get DNS server list from EFI IPv4 Configuration II protocol. // Get DNS server list from EFI IPv4 Configuration II protocol.
// //
Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Get the required size. // Get the required size.
@ -89,7 +89,6 @@ IScsiDns4 (
} }
} }
// //
// Create a DNS child instance and get the protocol. // Create a DNS child instance and get the protocol.
// //
@ -106,7 +105,7 @@ IScsiDns4 (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dns4Handle, Dns4Handle,
&gEfiDns4ProtocolGuid, &gEfiDns4ProtocolGuid,
(VOID **) &Dns4, (VOID **)&Dns4,
Image, Image,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -154,7 +153,7 @@ IScsiDns4 (
Token.Status = EFI_NOT_READY; Token.Status = EFI_NOT_READY;
IsDone = FALSE; IsDone = FALSE;
HostName = (CHAR16 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE); HostName = (CHAR16 *)AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
if (HostName == NULL) { if (HostName == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -183,10 +182,12 @@ IScsiDns4 (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Exit; 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; Status = EFI_DEVICE_ERROR;
goto Exit; goto Exit;
} }
// //
// We just return the first IP address from DNS protocol. // We just return the first IP address from DNS protocol.
// //
@ -199,10 +200,12 @@ Exit:
if (Token.Event != NULL) { if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event); gBS->CloseEvent (Token.Event);
} }
if (Token.RspData.H2AData != NULL) { if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) { if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList); FreePool (Token.RspData.H2AData->IpList);
} }
FreePool (Token.RspData.H2AData); FreePool (Token.RspData.H2AData);
} }
@ -270,7 +273,7 @@ IScsiDns6 (
// //
// Get DNS server list from EFI IPv6 Configuration protocol. // Get DNS server list from EFI IPv6 Configuration protocol.
// //
Status = gBS->HandleProtocol (Controller, &gEfiIp6ConfigProtocolGuid, (VOID **) &Ip6Config); Status = gBS->HandleProtocol (Controller, &gEfiIp6ConfigProtocolGuid, (VOID **)&Ip6Config);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Get the required size. // Get the required size.
@ -309,7 +312,7 @@ IScsiDns6 (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Dns6Handle, Dns6Handle,
&gEfiDns6ProtocolGuid, &gEfiDns6ProtocolGuid,
(VOID **) &Dns6, (VOID **)&Dns6,
Image, Image,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -353,7 +356,7 @@ IScsiDns6 (
// //
// Start asynchronous name resolution. // Start asynchronous name resolution.
// //
HostName = (CHAR16 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE); HostName = (CHAR16 *)AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
if (HostName == NULL) { if (HostName == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -381,10 +384,12 @@ IScsiDns6 (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Exit; 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; Status = EFI_DEVICE_ERROR;
goto Exit; goto Exit;
} }
// //
// We just return the first IPv6 address from DNS protocol. // We just return the first IPv6 address from DNS protocol.
// //
@ -397,10 +402,12 @@ Exit:
if (Token.Event != NULL) { if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event); gBS->CloseEvent (Token.Event);
} }
if (Token.RspData.H2AData != NULL) { if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) { if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList); FreePool (Token.RspData.H2AData->IpList);
} }
FreePool (Token.RspData.H2AData); FreePool (Token.RspData.H2AData);
} }
@ -426,4 +433,3 @@ Exit:
return Status; return Status;
} }

View File

@ -112,7 +112,7 @@ IScsiCheckAip (
&AipHandleCount, &AipHandleCount,
&AipHandleBuffer &AipHandleBuffer
); );
if (EFI_ERROR (Status) || AipHandleCount == 0) { if (EFI_ERROR (Status) || (AipHandleCount == 0)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -124,7 +124,7 @@ IScsiCheckAip (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
AipHandleBuffer[AipIndex], AipHandleBuffer[AipIndex],
&gEfiAdapterInformationProtocolGuid, &gEfiAdapterInformationProtocolGuid,
(VOID *) &Aip (VOID *)&Aip
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
ASSERT (Aip != NULL); ASSERT (Aip != NULL);
@ -132,18 +132,19 @@ IScsiCheckAip (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
AipHandleBuffer[AipIndex], AipHandleBuffer[AipIndex],
&gEfiExtScsiPassThruProtocolGuid, &gEfiExtScsiPassThruProtocolGuid,
(VOID *) &ExtScsiPassThru (VOID *)&ExtScsiPassThru
); );
if (EFI_ERROR (Status) || ExtScsiPassThru == NULL) { if (EFI_ERROR (Status) || (ExtScsiPassThru == NULL)) {
continue; continue;
} }
InfoTypesBuffer = NULL; InfoTypesBuffer = NULL;
InfoTypeBufferCount = 0; InfoTypeBufferCount = 0;
Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) { if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
continue; continue;
} }
// //
// Check whether the AIP instance has Network boot information block. // Check whether the AIP instance has Network boot information block.
// //
@ -166,32 +167,34 @@ IScsiCheckAip (
InfoBlock = NULL; InfoBlock = NULL;
InfoBlockSize = 0; InfoBlockSize = 0;
Status = Aip->GetInformation (Aip, &gEfiAdapterInfoNetworkBootGuid, &InfoBlock, &InfoBlockSize); Status = Aip->GetInformation (Aip, &gEfiAdapterInfoNetworkBootGuid, &InfoBlock, &InfoBlockSize);
if (EFI_ERROR (Status) || InfoBlock == NULL) { if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
continue; continue;
} }
// //
// Check whether the network boot policy matches. // Check whether the network boot policy matches.
// //
NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *) InfoBlock; NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *)InfoBlock;
NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy); NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy);
if (NetworkBootPolicy == STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP) { if (NetworkBootPolicy == STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
goto Exit; goto Exit;
} }
if (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0 &&
if ((((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0) &&
!NetworkBoot->iScsiIpv4BootCapablity) || !NetworkBoot->iScsiIpv4BootCapablity) ||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0 && (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0) &&
!NetworkBoot->iScsiIpv6BootCapablity) || !NetworkBoot->iScsiIpv6BootCapablity) ||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0 && (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0) &&
!NetworkBoot->OffloadCapability) || !NetworkBoot->OffloadCapability) ||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0 && (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0) &&
!NetworkBoot->iScsiMpioCapability) || !NetworkBoot->iScsiMpioCapability) ||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0 && (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0) &&
!NetworkBoot->iScsiIpv4Boot) || !NetworkBoot->iScsiIpv4Boot) ||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0 && (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0) &&
!NetworkBoot->iScsiIpv6Boot)) { !NetworkBoot->iScsiIpv6Boot))
{
FreePool (InfoBlock); FreePool (InfoBlock);
continue; continue;
} }
@ -206,9 +209,11 @@ Exit:
if (InfoBlock != NULL) { if (InfoBlock != NULL) {
FreePool (InfoBlock); FreePool (InfoBlock);
} }
if (AipHandleBuffer != NULL) { if (AipHandleBuffer != NULL) {
FreePool (AipHandleBuffer); FreePool (AipHandleBuffer);
} }
return Status; return Status;
} }
@ -257,7 +262,6 @@ IScsiSupported (
TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid; TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid; DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
DnsServiceBindingGuid = &gEfiDns4ServiceBindingProtocolGuid; DnsServiceBindingGuid = &gEfiDns4ServiceBindingProtocolGuid;
} else { } else {
IScsiServiceBindingGuid = &gIScsiV6PrivateGuid; IScsiServiceBindingGuid = &gIScsiV6PrivateGuid;
TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid; TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
@ -325,7 +329,6 @@ IScsiSupported (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Start to manage the controller. This is the worker function for Start to manage the controller. This is the worker function for
IScsiIp4(6)DriverBindingStart. IScsiIp4(6)DriverBindingStart.
@ -558,7 +561,7 @@ IScsiStart (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
(VOID **) &DevicePath (VOID **)&DevicePath
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
@ -572,7 +575,7 @@ IScsiStart (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiExtScsiPassThruProtocolGuid, &gEfiExtScsiPassThruProtocolGuid,
(VOID **) &ExistIScsiExtScsiPassThru (VOID **)&ExistIScsiExtScsiPassThru
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
break; break;
@ -622,9 +625,10 @@ IScsiStart (
// Don't process the attempt that does not associate with the current NIC or // Don't process the attempt that does not associate with the current NIC or
// this attempt is disabled or established. // this attempt is disabled or established.
// //
if (AttemptConfigData->NicIndex != mPrivate->CurrentNic || if ((AttemptConfigData->NicIndex != mPrivate->CurrentNic) ||
AttemptConfigData->SessionConfigData.Enabled == ISCSI_DISABLED || (AttemptConfigData->SessionConfigData.Enabled == ISCSI_DISABLED) ||
AttemptConfigData->ValidPath) { AttemptConfigData->ValidPath)
{
continue; continue;
} }
@ -633,9 +637,10 @@ IScsiStart (
// In default single path mode, don't process attempts configured for multipath. // In default single path mode, don't process attempts configured for multipath.
// //
if ((mPrivate->EnableMpio && if ((mPrivate->EnableMpio &&
AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO) || (AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO)) ||
(!mPrivate->EnableMpio && (!mPrivate->EnableMpio &&
AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED)) { (AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED)))
{
continue; continue;
} }
@ -643,18 +648,21 @@ IScsiStart (
// Don't process the attempt that fails to get the init/target information from DHCP. // Don't process the attempt that fails to get the init/target information from DHCP.
// //
if (AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp && if (AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp &&
!AttemptConfigData->DhcpSuccess) { !AttemptConfigData->DhcpSuccess)
if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) { {
if (!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount > 0)) {
mPrivate->ValidSinglePathCount--; mPrivate->ValidSinglePathCount--;
} }
continue; continue;
} }
// //
// Don't process the autoconfigure path if it is already established. // Don't process the autoconfigure path if it is already established.
// //
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG && if ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
AttemptConfigData->AutoConfigureSuccess) { AttemptConfigData->AutoConfigureSuccess)
{
continue; continue;
} }
@ -665,16 +673,20 @@ IScsiStart (
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) { if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) {
continue; continue;
} }
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6) { if ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
(AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6))
{
continue; continue;
} }
} else { } else {
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) { if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) {
continue; continue;
} }
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4) { if ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
(AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4))
{
continue; continue;
} }
} }
@ -682,7 +694,7 @@ IScsiStart (
// //
// Fill in the Session and init it. // Fill in the Session and init it.
// //
Session = (ISCSI_SESSION *) AllocateZeroPool (sizeof (ISCSI_SESSION)); Session = (ISCSI_SESSION *)AllocateZeroPool (sizeof (ISCSI_SESSION));
if (Session == NULL) { if (Session == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR; goto ON_ERROR;
@ -694,9 +706,9 @@ IScsiStart (
UnicodeSPrint ( UnicodeSPrint (
mPrivate->PortString, mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE, (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d", L"Attempt %d",
(UINTN) AttemptConfigData->AttemptConfigIndex (UINTN)AttemptConfigData->AttemptConfigIndex
); );
if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) { if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
@ -742,12 +754,11 @@ IScsiStart (
// In Single path mode, only the successful attempt will be recorded in iBFT; // In Single path mode, only the successful attempt will be recorded in iBFT;
// in multi-path mode, all the attempt entries in MPIO will be recorded in iBFT. // in multi-path mode, all the attempt entries in MPIO will be recorded in iBFT.
// //
if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) { if (!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount > 0)) {
mPrivate->ValidSinglePathCount--; mPrivate->ValidSinglePathCount--;
} }
FreePool (Session); FreePool (Session);
} else { } else {
AttemptConfigData->ValidPath = TRUE; AttemptConfigData->ValidPath = TRUE;
@ -756,7 +767,7 @@ IScsiStart (
// TODO: record KRB5 attempt information in the iSCSI device path. // TODO: record KRB5 attempt information in the iSCSI device path.
// //
if (Session->AuthType == ISCSI_AUTH_TYPE_KRB) { if (Session->AuthType == ISCSI_AUTH_TYPE_KRB) {
if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) { if (!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount > 0)) {
mPrivate->ValidSinglePathCount--; mPrivate->ValidSinglePathCount--;
} }
@ -814,7 +825,7 @@ IScsiStart (
// //
// Reinstall the original ExtScsiPassThru back. // Reinstall the original ExtScsiPassThru back.
// //
if (mPrivate->OneSessionEstablished && ExistPrivate != NULL) { if (mPrivate->OneSessionEstablished && (ExistPrivate != NULL)) {
Status = gBS->InstallProtocolInterface ( Status = gBS->InstallProtocolInterface (
&ExistPrivate->ExtScsiPassThruHandle, &ExistPrivate->ExtScsiPassThruHandle,
&gEfiExtScsiPassThruProtocolGuid, &gEfiExtScsiPassThruProtocolGuid,
@ -837,8 +848,7 @@ IScsiStart (
// //
// More than one attempt successes. // More than one attempt successes.
// //
if (Private->Session != NULL && mPrivate->OneSessionEstablished) { if ((Private->Session != NULL) && mPrivate->OneSessionEstablished) {
AttemptConfigOrder = IScsiGetVariableAndSize ( AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder", L"AttemptOrder",
&gIScsiConfigGuid, &gIScsiConfigGuid,
@ -847,9 +857,11 @@ IScsiStart (
if (AttemptConfigOrder == NULL) { if (AttemptConfigOrder == NULL) {
goto ON_ERROR; goto ON_ERROR;
} }
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex || if ((AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex) ||
AttemptConfigOrder[Index] == BootSelected) { (AttemptConfigOrder[Index] == BootSelected))
{
break; break;
} }
} }
@ -887,6 +899,7 @@ IScsiStart (
if (AttemptConfigOrder[Index] != BootSelected) { if (AttemptConfigOrder[Index] != BootSelected) {
goto ON_ERROR; goto ON_ERROR;
} }
mPrivate->BootSelectedIndex = BootSelected; mPrivate->BootSelectedIndex = BootSelected;
// //
// Clear the resource in ExistPrivate. // Clear the resource in ExistPrivate.
@ -917,7 +930,6 @@ IScsiStart (
gBS->CloseEvent (ExistPrivate->ExitBootServiceEvent); gBS->CloseEvent (ExistPrivate->ExitBootServiceEvent);
FreePool (ExistPrivate); FreePool (ExistPrivate);
} }
} else { } else {
// //
@ -927,7 +939,6 @@ IScsiStart (
NeedUpdate = FALSE; NeedUpdate = FALSE;
} }
} }
} }
if (NeedUpdate) { if (NeedUpdate) {
@ -945,6 +956,7 @@ IScsiStart (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto ON_ERROR; goto ON_ERROR;
} }
// //
// Install the updated device path onto the ExtScsiPassThruHandle. // Install the updated device path onto the ExtScsiPassThruHandle.
// //
@ -1042,7 +1054,6 @@ IScsiStop (
EFI_GUID *TcpServiceBindingGuid; EFI_GUID *TcpServiceBindingGuid;
EFI_GUID *TcpProtocolGuid; EFI_GUID *TcpProtocolGuid;
if (NumberOfChildren != 0) { if (NumberOfChildren != 0) {
// //
// We should have only one child. // We should have only one child.
@ -1050,7 +1061,7 @@ IScsiStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandleBuffer[0], ChildHandleBuffer[0],
&gEfiExtScsiPassThruProtocolGuid, &gEfiExtScsiPassThruProtocolGuid,
(VOID **) &PassThru, (VOID **)&PassThru,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -1102,6 +1113,7 @@ IScsiStop (
TcpProtocolGuid = &gEfiTcp6ProtocolGuid; TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid; TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
} }
IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid); IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid);
if (IScsiController == NULL) { if (IScsiController == NULL) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -1110,7 +1122,7 @@ IScsiStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
IScsiController, IScsiController,
ProtocolGuid, ProtocolGuid,
(VOID **) &IScsiIdentifier, (VOID **)&IScsiIdentifier,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -1524,11 +1536,13 @@ IScsiUnload (
Status = IScsiTestManagedDevice ( Status = IScsiTestManagedDevice (
DeviceHandleBuffer[Index], DeviceHandleBuffer[Index],
gIScsiIp4DriverBinding.DriverBindingHandle, gIScsiIp4DriverBinding.DriverBindingHandle,
&gEfiTcp4ProtocolGuid) &gEfiTcp4ProtocolGuid
)
; ;
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
Status = gBS->DisconnectController ( Status = gBS->DisconnectController (
DeviceHandleBuffer[Index], DeviceHandleBuffer[Index],
gIScsiIp4DriverBinding.DriverBindingHandle, gIScsiIp4DriverBinding.DriverBindingHandle,
@ -1551,6 +1565,7 @@ IScsiUnload (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
Status = gBS->DisconnectController ( Status = gBS->DisconnectController (
DeviceHandleBuffer[Index], DeviceHandleBuffer[Index],
gIScsiIp6DriverBinding.DriverBindingHandle, gIScsiIp6DriverBinding.DriverBindingHandle,
@ -1582,11 +1597,12 @@ IScsiUnload (
goto ON_EXIT; goto ON_EXIT;
} }
if (gIScsiControllerNameTable!= NULL) { if (gIScsiControllerNameTable != NULL) {
Status = FreeUnicodeStringTable (gIScsiControllerNameTable); Status = FreeUnicodeStringTable (gIScsiControllerNameTable);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
gIScsiControllerNameTable = NULL; gIScsiControllerNameTable = NULL;
} }
@ -1597,7 +1613,7 @@ IScsiUnload (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
gIScsiIp4DriverBinding.DriverBindingHandle, gIScsiIp4DriverBinding.DriverBindingHandle,
&gEfiComponentNameProtocolGuid, &gEfiComponentNameProtocolGuid,
(VOID **) &ComponentName (VOID **)&ComponentName
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
@ -1614,7 +1630,7 @@ IScsiUnload (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
gIScsiIp4DriverBinding.DriverBindingHandle, gIScsiIp4DriverBinding.DriverBindingHandle,
&gEfiComponentName2ProtocolGuid, &gEfiComponentName2ProtocolGuid,
(VOID **) &ComponentName2 (VOID **)&ComponentName2
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
@ -1635,7 +1651,7 @@ IScsiUnload (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
gIScsiIp6DriverBinding.DriverBindingHandle, gIScsiIp6DriverBinding.DriverBindingHandle,
&gEfiComponentNameProtocolGuid, &gEfiComponentNameProtocolGuid,
(VOID **) &ComponentName (VOID **)&ComponentName
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
@ -1652,7 +1668,7 @@ IScsiUnload (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
gIScsiIp6DriverBinding.DriverBindingHandle, gIScsiIp6DriverBinding.DriverBindingHandle,
&gEfiComponentName2ProtocolGuid, &gEfiComponentName2ProtocolGuid,
(VOID **) &ComponentName2 (VOID **)&ComponentName2
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
@ -1730,7 +1746,7 @@ IScsiDriverEntryPoint (
Status = gBS->LocateProtocol ( Status = gBS->LocateProtocol (
&gEfiIScsiInitiatorNameProtocolGuid, &gEfiIScsiInitiatorNameProtocolGuid,
NULL, NULL,
(VOID **) &IScsiInitiatorName (VOID **)&IScsiInitiatorName
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
@ -1821,7 +1837,7 @@ IScsiDriverEntryPoint (
Status = gBS->LocateProtocol ( Status = gBS->LocateProtocol (
&gEfiAuthenticationInfoProtocolGuid, &gEfiAuthenticationInfoProtocolGuid,
NULL, NULL,
(VOID **) &AuthenticationInfo (VOID **)&AuthenticationInfo
); );
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
Status = gBS->InstallProtocolInterface ( Status = gBS->InstallProtocolInterface (
@ -1873,4 +1889,3 @@ Error1:
return Status; return Status;
} }

View File

@ -19,7 +19,6 @@ EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {
IScsiExtScsiPassThruGetNextTarget IScsiExtScsiPassThruGetNextTarget
}; };
/** /**
Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel.
This function supports both blocking I/O and nonblocking I/O. The blocking I/O This function supports both blocking I/O and nonblocking I/O. The blocking I/O
@ -107,7 +106,6 @@ IScsiExtScsiPassThruFunction (
return Status; return Status;
} }
/** /**
Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on
a SCSI channel. These can either be the list SCSI devices that are actually a SCSI channel. These can either be the list SCSI devices that are actually
@ -152,7 +150,7 @@ IScsiExtScsiPassThruGetNextTargetLun (
Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This); Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
ConfigNvData = &Private->Session->ConfigData->SessionConfigData; ConfigNvData = &Private->Session->ConfigData->SessionConfigData;
if ((*Target)[0] == 0 && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) { if (((*Target)[0] == 0) && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) {
// //
// Only one <Target, Lun> pair per iSCSI Driver instance. // Only one <Target, Lun> pair per iSCSI Driver instance.
// //
@ -170,7 +168,6 @@ IScsiExtScsiPassThruGetNextTargetLun (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
/** /**
Allocate and build a device path node for a SCSI device on a SCSI channel. Allocate and build a device path node for a SCSI device on a SCSI channel.
@ -259,6 +256,7 @@ IScsiExtScsiPassThruBuildDevicePath (
if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) { if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {
Node->Iscsi.LoginOption |= 0x1000; Node->Iscsi.LoginOption |= 0x1000;
} }
break; break;
default: default:
@ -267,14 +265,13 @@ IScsiExtScsiPassThruBuildDevicePath (
CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64)); CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));
Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag; Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag;
AsciiStrCpyS ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName); AsciiStrCpyS ((CHAR8 *)Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName);
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node; *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Node;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Translate a device path node to a Target ID and LUN. Translate a device path node to a Target ID and LUN.
@ -315,7 +312,8 @@ IScsiExtScsiPassThruGetTargetLun (
if ((DevicePath->Type != MESSAGING_DEVICE_PATH) || if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
(DevicePath->SubType != MSG_ISCSI_DP) || (DevicePath->SubType != MSG_ISCSI_DP) ||
(DevicePathNodeLength (DevicePath) <= sizeof (ISCSI_DEVICE_PATH)) (DevicePathNodeLength (DevicePath) <= sizeof (ISCSI_DEVICE_PATH))
) { )
{
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -325,7 +323,7 @@ IScsiExtScsiPassThruGetTargetLun (
SetMem (*Target, TARGET_MAX_BYTES, 0xFF); SetMem (*Target, TARGET_MAX_BYTES, 0xFF);
(*Target)[0] = 0; (*Target)[0] = 0;
if (AsciiStrCmp (ConfigNvData->TargetName, (CHAR8 *) DevicePath + sizeof (ISCSI_DEVICE_PATH)) != 0) { if (AsciiStrCmp (ConfigNvData->TargetName, (CHAR8 *)DevicePath + sizeof (ISCSI_DEVICE_PATH)) != 0) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -334,7 +332,6 @@ IScsiExtScsiPassThruGetTargetLun (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Resets a SCSI channel. This operation resets all the SCSI devices connected to Resets a SCSI channel. This operation resets all the SCSI devices connected to
the SCSI channel. the SCSI channel.
@ -353,7 +350,6 @@ IScsiExtScsiPassThruResetChannel (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
/** /**
Resets a SCSI device that is connected to a SCSI channel. Resets a SCSI device that is connected to a SCSI channel.
@ -416,4 +412,3 @@ IScsiExtScsiPassThruGetNextTarget (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }

View File

@ -35,7 +35,6 @@ IScsiInitIbfTableHeader (
CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64)); CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64));
} }
/** /**
Initialize the control section of the iSCSI Boot Firmware Table. Initialize the control section of the iSCSI Boot Firmware Table.
@ -50,11 +49,11 @@ IScsiInitControlSection (
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control;
UINTN NumOffset; UINTN NumOffset;
Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *) (Table + 1); Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *)(Table + 1);
Control->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_ID; Control->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_ID;
Control->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_VERSION; Control->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_VERSION;
Control->Header.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE); Control->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE);
// //
// If in multipathing mode, enable the Boot Failover Flag. // If in multipathing mode, enable the Boot Failover Flag.
@ -79,11 +78,10 @@ IScsiInitControlSection (
// Need expand the control section if more than 2 NIC/Target attempts // Need expand the control section if more than 2 NIC/Target attempts
// exist. // exist.
// //
Control->Header.Length = (UINT16) (Control->Header.Length + (NumOffset - 4) * sizeof (UINT16)); Control->Header.Length = (UINT16)(Control->Header.Length + (NumOffset - 4) * sizeof (UINT16));
} }
} }
/** /**
Add one item into the heap. Add one item into the heap.
@ -109,7 +107,6 @@ IScsiAddHeapItem (
*(*Heap + Len) = 0; *(*Heap + Len) = 0;
} }
/** /**
Fill the Initiator section of the iSCSI Boot Firmware Table. Fill the Initiator section of the iSCSI Boot Firmware Table.
@ -126,19 +123,19 @@ IScsiFillInitiatorSection (
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control;
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE *Initiator; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE *Initiator;
Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *) (Table + 1); Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *)(Table + 1);
// //
// Initiator section immediately follows the control section. // Initiator section immediately follows the control section.
// //
Initiator = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE *) Initiator = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE *)
((UINT8 *) Control + IBFT_ROUNDUP (Control->Header.Length)); ((UINT8 *)Control + IBFT_ROUNDUP (Control->Header.Length));
Control->InitiatorOffset = (UINT16) ((UINTN) Initiator - (UINTN) Table); Control->InitiatorOffset = (UINT16)((UINTN)Initiator - (UINTN)Table);
Initiator->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_ID; Initiator->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_ID;
Initiator->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_VERSION; Initiator->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_VERSION;
Initiator->Header.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE); Initiator->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE);
Initiator->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BLOCK_VALID | Initiator->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BLOCK_VALID |
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BOOT_SELECTED; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BOOT_SELECTED;
@ -147,11 +144,10 @@ IScsiFillInitiatorSection (
// //
IScsiAddHeapItem (Heap, mPrivate->InitiatorName, mPrivate->InitiatorNameLength - 1); IScsiAddHeapItem (Heap, mPrivate->InitiatorName, mPrivate->InitiatorNameLength - 1);
Initiator->IScsiNameLength = (UINT16) (mPrivate->InitiatorNameLength - 1); Initiator->IScsiNameLength = (UINT16)(mPrivate->InitiatorNameLength - 1);
Initiator->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); Initiator->IScsiNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
} }
/** /**
Map the v4 IP address into v6 IP address. Map the v4 IP address into v6 IP address.
@ -177,7 +173,6 @@ IScsiMapV4ToV6Addr (
} }
} }
/** /**
Fill the NIC and target sections in iSCSI Boot Firmware Table. Fill the NIC and target sections in iSCSI Boot Firmware Table.
@ -208,10 +203,10 @@ IScsiFillNICAndTargetSections (
// //
// Get the offset of the first Nic and Target section. // Get the offset of the first Nic and Target section.
// //
Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *) (Table + 1); Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *)(Table + 1);
Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *) ((UINTN) Table + Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *)((UINTN)Table +
Control->InitiatorOffset + IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE))); Control->InitiatorOffset + IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE)));
Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *) ((UINTN) Nic + Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *)((UINTN)Nic +
IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE))); IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)));
SectionOffset = &Control->NIC0Offset; SectionOffset = &Control->NIC0Offset;
@ -233,9 +228,8 @@ IScsiFillNICAndTargetSections (
} }
ASSERT (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED); ASSERT (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED);
} else { } else {
if (Index == 1 && Flag) { if ((Index == 1) && Flag) {
Entry = mPrivate->AttemptConfigs.ForwardLink; Entry = mPrivate->AttemptConfigs.ForwardLink;
Flag = FALSE; Flag = FALSE;
} }
@ -260,7 +254,7 @@ IScsiFillNICAndTargetSections (
// //
// If multipath mode is enabled, only the attempts in MPIO will be recorded in iBFT. // If multipath mode is enabled, only the attempts in MPIO will be recorded in iBFT.
// //
if (mPrivate->EnableMpio && Attempt->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO) { if (mPrivate->EnableMpio && (Attempt->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO)) {
continue; continue;
} }
@ -280,8 +274,8 @@ IScsiFillNICAndTargetSections (
Nic->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_ID; Nic->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_ID;
Nic->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_VERSION; Nic->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_VERSION;
Nic->Header.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE); Nic->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE);
Nic->Header.Index = (UINT8) Index; Nic->Header.Index = (UINT8)Index;
Nic->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BLOCK_VALID | Nic->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BLOCK_VALID |
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_GLOBAL; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_GLOBAL;
@ -295,7 +289,7 @@ IScsiFillNICAndTargetSections (
Nic->Origin = IpPrefixOriginManual; Nic->Origin = IpPrefixOriginManual;
} }
if (NvData->IpMode == IP_MODE_IP4 || NvData->IpMode == IP_MODE_AUTOCONFIG) { if ((NvData->IpMode == IP_MODE_IP4) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
// //
// Get the subnet mask prefix length. // Get the subnet mask prefix length.
// //
@ -309,16 +303,13 @@ IScsiFillNICAndTargetSections (
IScsiMapV4ToV6Addr (&Attempt->PrimaryDns.v4, &Nic->PrimaryDns); IScsiMapV4ToV6Addr (&Attempt->PrimaryDns.v4, &Nic->PrimaryDns);
IScsiMapV4ToV6Addr (&Attempt->SecondaryDns.v4, &Nic->SecondaryDns); IScsiMapV4ToV6Addr (&Attempt->SecondaryDns.v4, &Nic->SecondaryDns);
IScsiMapV4ToV6Addr (&Attempt->DhcpServer.v4, &Nic->DhcpServer); IScsiMapV4ToV6Addr (&Attempt->DhcpServer.v4, &Nic->DhcpServer);
} else if ((NvData->IpMode == IP_MODE_IP6) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
} else if (NvData->IpMode == IP_MODE_IP6 || NvData->IpMode == IP_MODE_AUTOCONFIG) {
Nic->SubnetMaskPrefixLength = NvData->PrefixLength; Nic->SubnetMaskPrefixLength = NvData->PrefixLength;
CopyMem (&Nic->Ip, &NvData->LocalIp, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Nic->Ip, &NvData->LocalIp, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->Gateway, &NvData->Gateway, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Nic->Gateway, &NvData->Gateway, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->PrimaryDns, &Attempt->PrimaryDns, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Nic->PrimaryDns, &Attempt->PrimaryDns, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->SecondaryDns, &Attempt->SecondaryDns, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Nic->SecondaryDns, &Attempt->SecondaryDns, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->DhcpServer, &Attempt->DhcpServer, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Nic->DhcpServer, &Attempt->DhcpServer, sizeof (EFI_IPv6_ADDRESS));
} else { } else {
ASSERT (FALSE); ASSERT (FALSE);
} }
@ -331,9 +322,9 @@ IScsiFillNICAndTargetSections (
Nic->VLanTag = NicInfo->VlanId; Nic->VLanTag = NicInfo->VlanId;
CopyMem (Nic->Mac, &NicInfo->PermanentAddress, sizeof (Nic->Mac)); CopyMem (Nic->Mac, &NicInfo->PermanentAddress, sizeof (Nic->Mac));
Nic->PciLocation = (UINT16) ((NicInfo->BusNumber << 8) | Nic->PciLocation = (UINT16)((NicInfo->BusNumber << 8) |
(NicInfo->DeviceNumber << 3) | NicInfo->FunctionNumber); (NicInfo->DeviceNumber << 3) | NicInfo->FunctionNumber);
*SectionOffset = (UINT16) ((UINTN) Nic - (UINTN) Table); *SectionOffset = (UINT16)((UINTN)Nic - (UINTN)Table);
SectionOffset++; SectionOffset++;
// //
@ -342,8 +333,8 @@ IScsiFillNICAndTargetSections (
Target->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID; Target->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID;
Target->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION; Target->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION;
Target->Header.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE); Target->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE);
Target->Header.Index = (UINT8) Index; Target->Header.Index = (UINT8)Index;
Target->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID; Target->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID;
if (Index == 0) { if (Index == 0) {
@ -362,11 +353,11 @@ IScsiFillNICAndTargetSections (
Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP; Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP;
} }
Target->NicIndex = (UINT8) Index; Target->NicIndex = (UINT8)Index;
if (NvData->IpMode == IP_MODE_IP4 || NvData->IpMode == IP_MODE_AUTOCONFIG) { if ((NvData->IpMode == IP_MODE_IP4) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
IScsiMapV4ToV6Addr (&NvData->TargetIp.v4, &Target->Ip); IScsiMapV4ToV6Addr (&NvData->TargetIp.v4, &Target->Ip);
} else if (NvData->IpMode == IP_MODE_IP6 || NvData->IpMode == IP_MODE_AUTOCONFIG) { } else if ((NvData->IpMode == IP_MODE_IP6) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
CopyMem (&Target->Ip, &NvData->TargetIp, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Target->Ip, &NvData->TargetIp, sizeof (EFI_IPv6_ADDRESS));
} else { } else {
ASSERT (FALSE); ASSERT (FALSE);
@ -377,64 +368,63 @@ IScsiFillNICAndTargetSections (
// //
// Target iSCSI Name, CHAP name/secret, reverse CHAP name/secret. // Target iSCSI Name, CHAP name/secret, reverse CHAP name/secret.
// //
Length = (UINT16) AsciiStrLen (NvData->TargetName); Length = (UINT16)AsciiStrLen (NvData->TargetName);
IScsiAddHeapItem (Heap, NvData->TargetName, Length); IScsiAddHeapItem (Heap, NvData->TargetName, Length);
Target->IScsiNameLength = Length; Target->IScsiNameLength = Length;
Target->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); Target->IScsiNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) { if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
// //
// CHAP Name // CHAP Name
// //
Length = (UINT16) AsciiStrLen (AuthConfig->CHAPName); Length = (UINT16)AsciiStrLen (AuthConfig->CHAPName);
IScsiAddHeapItem (Heap, AuthConfig->CHAPName, Length); IScsiAddHeapItem (Heap, AuthConfig->CHAPName, Length);
Target->CHAPNameLength = Length; Target->CHAPNameLength = Length;
Target->CHAPNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); Target->CHAPNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
// //
// CHAP Secret // CHAP Secret
// //
Length = (UINT16) AsciiStrLen (AuthConfig->CHAPSecret); Length = (UINT16)AsciiStrLen (AuthConfig->CHAPSecret);
IScsiAddHeapItem (Heap, AuthConfig->CHAPSecret, Length); IScsiAddHeapItem (Heap, AuthConfig->CHAPSecret, Length);
Target->CHAPSecretLength = Length; Target->CHAPSecretLength = Length;
Target->CHAPSecretOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); Target->CHAPSecretOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
if (Target->CHAPType == EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP) { if (Target->CHAPType == EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP) {
// //
// Reverse CHAP Name. // Reverse CHAP Name.
// //
Length = (UINT16) AsciiStrLen (AuthConfig->ReverseCHAPName); Length = (UINT16)AsciiStrLen (AuthConfig->ReverseCHAPName);
IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPName, Length); IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPName, Length);
Target->ReverseCHAPNameLength = Length; Target->ReverseCHAPNameLength = Length;
Target->ReverseCHAPNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); Target->ReverseCHAPNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
// //
// Reverse CHAP Secret. // Reverse CHAP Secret.
// //
Length = (UINT16) AsciiStrLen (AuthConfig->ReverseCHAPSecret); Length = (UINT16)AsciiStrLen (AuthConfig->ReverseCHAPSecret);
IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPSecret, Length); IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPSecret, Length);
Target->ReverseCHAPSecretLength = Length; Target->ReverseCHAPSecretLength = Length;
Target->ReverseCHAPSecretOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); Target->ReverseCHAPSecretOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
} }
} }
*SectionOffset = (UINT16) ((UINTN) Target - (UINTN) Table); *SectionOffset = (UINT16)((UINTN)Target - (UINTN)Table);
SectionOffset++; SectionOffset++;
// //
// Advance to the next NIC/Target pair. // Advance to the next NIC/Target pair.
// //
Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *) ((UINTN) Target + Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *)((UINTN)Target +
IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE))); IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE)));
Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *) ((UINTN) Nic + Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *)((UINTN)Nic +
IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE))); IBFT_ROUNDUP (sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)));
Index++; Index++;
} }
} }
/** /**
Publish and remove the iSCSI Boot Firmware Table according to the iSCSI Publish and remove the iSCSI Boot Firmware Table according to the iSCSI
session status. session status.
@ -457,29 +447,29 @@ IScsiPublishIbft (
Rsdt = NULL; Rsdt = NULL;
Xsdt = NULL; Xsdt = NULL;
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return ; return;
} }
// //
// Find ACPI table RSD_PTR from the system table. // Find ACPI table RSD_PTR from the system table.
// //
Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp); Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **)&Rsdp);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &Rsdp); Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **)&Rsdp);
} }
if (EFI_ERROR (Status) || (Rsdp == NULL)) { if (EFI_ERROR (Status) || (Rsdp == NULL)) {
return ; return;
} else if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) { } else if ((Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) && (Rsdp->XsdtAddress != 0)) {
Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->XsdtAddress;
} else if (Rsdp->RsdtAddress != 0) { } else if (Rsdp->RsdtAddress != 0) {
Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress; Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->RsdtAddress;
} }
if ((Xsdt == NULL) && (Rsdt == NULL)) { if ((Xsdt == NULL) && (Rsdt == NULL)) {
return ; return;
} }
if (mIbftInstalled) { if (mIbftInstalled) {
@ -488,17 +478,19 @@ IScsiPublishIbft (
mTableKey mTableKey
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return ; return;
} }
mIbftInstalled = FALSE; mIbftInstalled = FALSE;
} }
// //
// If there is no valid attempt configuration, just return. // If there is no valid attempt configuration, just return.
// //
if ((!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount == 0) || if ((!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount == 0)) ||
(mPrivate->EnableMpio && mPrivate->MpioCount <= mPrivate->Krb5MpioCount)) { (mPrivate->EnableMpio && (mPrivate->MpioCount <= mPrivate->Krb5MpioCount)))
return ; {
return;
} }
// //
@ -506,10 +498,10 @@ IScsiPublishIbft (
// //
Table = AllocateZeroPool (IBFT_MAX_SIZE); Table = AllocateZeroPool (IBFT_MAX_SIZE);
if (Table == NULL) { if (Table == NULL) {
return ; return;
} }
Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET; Heap = (UINT8 *)Table + IBFT_HEAP_OFFSET;
// //
// Fill in the various section of the iSCSI Boot Firmware Table. // Fill in the various section of the iSCSI Boot Firmware Table.
@ -524,7 +516,7 @@ IScsiPublishIbft (
IScsiFillInitiatorSection (Table, &Heap); IScsiFillInitiatorSection (Table, &Heap);
IScsiFillNICAndTargetSections (Table, &Heap); IScsiFillNICAndTargetSections (Table, &Heap);
Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length); Checksum = CalculateCheckSum8 ((UINT8 *)Table, Table->Length);
Table->Checksum = Checksum; Table->Checksum = Checksum;
// //
@ -536,7 +528,7 @@ IScsiPublishIbft (
Table->Length, Table->Length,
&mTableKey &mTableKey
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return; return;
} }

View File

@ -13,7 +13,6 @@ EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName = {
IScsiSetInitiatorName IScsiSetInitiatorName
}; };
/** /**
Retrieves the current set value of iSCSI Initiator Name. Retrieves the current set value of iSCSI Initiator Name.
@ -64,7 +63,6 @@ IScsiGetInitiatorName (
return Status; return Status;
} }
/** /**
Sets the iSSI Initiator Name. Sets the iSSI Initiator Name.
@ -110,10 +108,11 @@ IScsiSetInitiatorName (
*BufferSize = ISCSI_NAME_MAX_SIZE; *BufferSize = ISCSI_NAME_MAX_SIZE;
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Only support iqn iSCSI names. // Only support iqn iSCSI names.
// //
Status = IScsiNormalizeName ((CHAR8 *) Buffer, *BufferSize - 1); Status = IScsiNormalizeName ((CHAR8 *)Buffer, *BufferSize - 1);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,6 @@ typedef struct _ISCSI_DRIVER_DATA ISCSI_DRIVER_DATA;
/// ///
#define IP6_OLD_IPADDRESS_OFFSET 42 #define IP6_OLD_IPADDRESS_OFFSET 42
#pragma pack(1) #pragma pack(1)
typedef struct _ISCSI_SESSION_CONFIG_NVDATA { typedef struct _ISCSI_SESSION_CONFIG_NVDATA {
UINT16 TargetPort; UINT16 TargetPort;
@ -56,7 +55,6 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA {
BOOLEAN DnsMode; // Flag indicate whether the Target address is expressed as URL format. BOOLEAN DnsMode; // Flag indicate whether the Target address is expressed as URL format.
CHAR8 TargetUrl[ISCSI_TARGET_URI_MAX_SIZE]; CHAR8 TargetUrl[ISCSI_TARGET_URI_MAX_SIZE];
} ISCSI_SESSION_CONFIG_NVDATA; } ISCSI_SESSION_CONFIG_NVDATA;
#pragma pack() #pragma pack()
@ -185,7 +183,6 @@ IScsiHexToBin (
IN CHAR8 *HexStr IN CHAR8 *HexStr
); );
/** /**
Convert the decimal-constant string or hex-constant string into a numerical value. Convert the decimal-constant string or hex-constant string into a numerical value.
@ -295,7 +292,6 @@ IScsiGetNicInfoByIndex (
IN UINT8 NicIndex IN UINT8 NicIndex
); );
/** /**
Get the NIC's PCI location and return it according to the composited Get the NIC's PCI location and return it according to the composited
format defined in iSCSI Boot Firmware Table. format defined in iSCSI Boot Firmware Table.
@ -469,4 +465,5 @@ IScsiTestManagedDevice (
IN EFI_HANDLE DriverBindingHandle, IN EFI_HANDLE DriverBindingHandle,
IN EFI_GUID *ProtocolGuid IN EFI_GUID *ProtocolGuid
); );
#endif #endif

View File

@ -44,7 +44,6 @@ IScsiDetatchConnection (
Conn->Session = NULL; Conn->Session = NULL;
} }
/** /**
Check the sequence number according to RFC3720. Check the sequence number according to RFC3720.
@ -80,7 +79,6 @@ IScsiCheckSN (
} }
} }
/** /**
Update the sequence numbers for the iSCSI command. Update the sequence numbers for the iSCSI command.
@ -97,7 +95,7 @@ IScsiUpdateCmdSN (
) )
{ {
if (ISCSI_SEQ_LT (MaxCmdSN, ExpCmdSN - 1)) { if (ISCSI_SEQ_LT (MaxCmdSN, ExpCmdSN - 1)) {
return ; return;
} }
if (ISCSI_SEQ_GT (MaxCmdSN, Session->MaxCmdSN)) { if (ISCSI_SEQ_GT (MaxCmdSN, Session->MaxCmdSN)) {
@ -109,7 +107,6 @@ IScsiUpdateCmdSN (
} }
} }
/** /**
This function does the iSCSI connection login. This function does the iSCSI connection login.
@ -171,7 +168,6 @@ IScsiConnLogin (
return Status; return Status;
} }
/** /**
Reset the iSCSI connection. Reset the iSCSI connection.
@ -186,7 +182,6 @@ IScsiConnReset (
TcpIoReset (&Conn->TcpIo); TcpIoReset (&Conn->TcpIo);
} }
/** /**
Create a TCP connection for the iSCSI session. Create a TCP connection for the iSCSI session.
@ -259,7 +254,7 @@ IScsiCreateConnection (
Status = IScsiDns6 (Private->Image, Private->Controller, NvData); Status = IScsiDns6 (Private->Image, Private->Controller, NvData);
} }
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "The configuration of Target address or DNS server address is invalid!\n")); DEBUG ((DEBUG_ERROR, "The configuration of Target address or DNS server address is invalid!\n"));
FreePool (Conn); FreePool (Conn);
return NULL; return NULL;
@ -292,7 +287,7 @@ IScsiCreateConnection (
Status = TcpIoCreateSocket ( Status = TcpIoCreateSocket (
Private->Image, Private->Image,
Private->Controller, Private->Controller,
(UINT8) (!Conn->Ipv6Flag ? TCP_VERSION_4: TCP_VERSION_6), (UINT8)(!Conn->Ipv6Flag ? TCP_VERSION_4 : TCP_VERSION_6),
&TcpIoConfig, &TcpIoConfig,
&Conn->TcpIo &Conn->TcpIo
); );
@ -305,7 +300,6 @@ IScsiCreateConnection (
return Conn; return Conn;
} }
/** /**
Destroy an iSCSI connection. Destroy an iSCSI connection.
@ -390,6 +384,7 @@ IScsiGetIp6NicInfo (
} }
} }
} }
if (RouteEntry != Ip6ModeData.RouteCount) { if (RouteEntry != Ip6ModeData.RouteCount) {
IP6_COPY_ADDRESS (&NvData->Gateway, &Ip6ModeData.RouteTable[RouteEntry].Gateway); IP6_COPY_ADDRESS (&NvData->Gateway, &Ip6ModeData.RouteTable[RouteEntry].Gateway);
} }
@ -398,19 +393,24 @@ ON_EXIT:
if (Ip6ModeData.AddressList != NULL) { if (Ip6ModeData.AddressList != NULL) {
FreePool (Ip6ModeData.AddressList); FreePool (Ip6ModeData.AddressList);
} }
if (Ip6ModeData.GroupTable!= NULL) {
if (Ip6ModeData.GroupTable != NULL) {
FreePool (Ip6ModeData.GroupTable); FreePool (Ip6ModeData.GroupTable);
} }
if (Ip6ModeData.RouteTable!= NULL) {
if (Ip6ModeData.RouteTable != NULL) {
FreePool (Ip6ModeData.RouteTable); FreePool (Ip6ModeData.RouteTable);
} }
if (Ip6ModeData.NeighborCache!= NULL) {
if (Ip6ModeData.NeighborCache != NULL) {
FreePool (Ip6ModeData.NeighborCache); FreePool (Ip6ModeData.NeighborCache);
} }
if (Ip6ModeData.PrefixTable!= NULL) {
if (Ip6ModeData.PrefixTable != NULL) {
FreePool (Ip6ModeData.PrefixTable); FreePool (Ip6ModeData.PrefixTable);
} }
if (Ip6ModeData.IcmpTypeList!= NULL) {
if (Ip6ModeData.IcmpTypeList != NULL) {
FreePool (Ip6ModeData.IcmpTypeList); FreePool (Ip6ModeData.IcmpTypeList);
} }
@ -517,7 +517,7 @@ IScsiSessionLogin (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Conn->TcpIo.Handle, Conn->TcpIo.Handle,
ProtocolGuid, ProtocolGuid,
(VOID **) &Tcp, (VOID **)&Tcp,
Session->Private->Image, Session->Private->Image,
Session->Private->ExtScsiPassThruHandle, Session->Private->ExtScsiPassThruHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -533,7 +533,6 @@ IScsiSessionLogin (
return Status; return Status;
} }
/** /**
Wait for IPsec negotiation, then try to login the iSCSI session again. Wait for IPsec negotiation, then try to login the iSCSI session again.
@ -549,7 +548,6 @@ IScsiSessionReLogin (
IN ISCSI_SESSION *Session IN ISCSI_SESSION *Session
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS TimerStatus; EFI_STATUS TimerStatus;
EFI_EVENT Timer; EFI_EVENT Timer;
@ -571,20 +569,17 @@ IScsiSessionReLogin (
} }
do { do {
TimerStatus = gBS->CheckEvent (Timer); TimerStatus = gBS->CheckEvent (Timer);
if (!EFI_ERROR (TimerStatus)) { if (!EFI_ERROR (TimerStatus)) {
Status = IScsiSessionLogin (Session); Status = IScsiSessionLogin (Session);
} }
} while (TimerStatus == EFI_NOT_READY); } while (TimerStatus == EFI_NOT_READY);
gBS->CloseEvent (Timer); gBS->CloseEvent (Timer);
return Status; return Status;
} }
/** /**
Build and send the iSCSI login request to the iSCSI target according to Build and send the iSCSI login request to the iSCSI target according to
the current login stage. the current login stage.
@ -612,6 +607,7 @@ IScsiSendLoginReq (
if (Pdu == NULL) { if (Pdu == NULL) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Send it to the iSCSI target. // Send it to the iSCSI target.
// //
@ -622,7 +618,6 @@ IScsiSendLoginReq (
return Status; return Status;
} }
/** /**
Receive and process the iSCSI login response. Receive and process the iSCSI login response.
@ -649,6 +644,7 @@ IScsiReceiveLoginRsp (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
ASSERT (Pdu != NULL); ASSERT (Pdu != NULL);
// //
@ -661,7 +657,6 @@ IScsiReceiveLoginRsp (
return Status; return Status;
} }
/** /**
Add an iSCSI key-value pair as a string into the data segment of the Login Request PDU. Add an iSCSI key-value pair as a string into the data segment of the Login Request PDU.
The DataSegmentLength and the actual size of the net buffer containing this PDU will be The DataSegmentLength and the actual size of the net buffer containing this PDU will be
@ -692,14 +687,15 @@ IScsiAddKeyValuePair (
ISCSI_LOGIN_REQUEST *LoginReq; ISCSI_LOGIN_REQUEST *LoginReq;
CHAR8 *Data; CHAR8 *Data;
LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, NULL); LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufGetByte (Pdu, 0, NULL);
if (LoginReq == NULL) { if (LoginReq == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
DataSegLen = NTOH24 (LoginReq->DataSegmentLength); DataSegLen = NTOH24 (LoginReq->DataSegmentLength);
KeyLen = (UINT32) AsciiStrLen (Key); KeyLen = (UINT32)AsciiStrLen (Key);
ValueLen = (UINT32) AsciiStrLen (Value); ValueLen = (UINT32)AsciiStrLen (Value);
// //
// 1 byte for the key value separator '=' and 1 byte for the null // 1 byte for the key value separator '=' and 1 byte for the null
@ -710,10 +706,11 @@ IScsiAddKeyValuePair (
// //
// Allocate the space for the key-value pair. // Allocate the space for the key-value pair.
// //
Data = (CHAR8 *) NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL); Data = (CHAR8 *)NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL);
if (Data == NULL) { if (Data == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Add the key. // Add the key.
// //
@ -739,7 +736,6 @@ IScsiAddKeyValuePair (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Prepare the iSCSI login request to be sent according to the current login status. Prepare the iSCSI login request to be sent according to the current login status.
@ -766,11 +762,12 @@ IScsiPrepareLoginReq (
return NULL; return NULL;
} }
LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufAllocSpace (Nbuf, sizeof (ISCSI_LOGIN_REQUEST), NET_BUF_TAIL); LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufAllocSpace (Nbuf, sizeof (ISCSI_LOGIN_REQUEST), NET_BUF_TAIL);
if (LoginReq == NULL) { if (LoginReq == NULL) {
NetbufFree (Nbuf); NetbufFree (Nbuf);
return NULL; return NULL;
} }
ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST)); ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST));
// //
@ -852,7 +849,6 @@ IScsiPrepareLoginReq (
return Nbuf; return Nbuf;
} }
/** /**
Process the iSCSI Login Response. Process the iSCSI Login Response.
@ -884,16 +880,18 @@ IScsiProcessLoginRsp (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
Session = Conn->Session; Session = Conn->Session;
LoginRsp = (ISCSI_LOGIN_RESPONSE *) NetbufGetByte (Pdu, 0, NULL); LoginRsp = (ISCSI_LOGIN_RESPONSE *)NetbufGetByte (Pdu, 0, NULL);
if (LoginRsp == NULL) { if (LoginRsp == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
if (!ISCSI_CHECK_OPCODE (LoginRsp, ISCSI_OPCODE_LOGIN_RSP)) { if (!ISCSI_CHECK_OPCODE (LoginRsp, ISCSI_OPCODE_LOGIN_RSP)) {
// //
// It is not a Login Response. // It is not a Login Response.
// //
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
// //
// Get the data segment, if any. // Get the data segment, if any.
// //
@ -903,6 +901,7 @@ IScsiProcessLoginRsp (
} else { } else {
DataSeg = NULL; DataSeg = NULL;
} }
// //
// Check the status class in the login response PDU. // Check the status class in the login response PDU.
// //
@ -920,14 +919,16 @@ IScsiProcessLoginRsp (
if (DataSeg == NULL) { if (DataSeg == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
// //
// Process the TargetAddress key-value strings in the data segment to update the // Process the TargetAddress key-value strings in the data segment to update the
// target address info. // target address info.
// //
Status = IScsiUpdateTargetAddress (Session, (CHAR8 *) DataSeg, DataSegLen); Status = IScsiUpdateTargetAddress (Session, (CHAR8 *)DataSeg, DataSegLen);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// Session will be restarted on this error status because the Target is // Session will be restarted on this error status because the Target is
// redirected by this Login Response. // redirected by this Login Response.
@ -940,6 +941,7 @@ IScsiProcessLoginRsp (
// //
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
// //
// The status is success; extract the wanted fields from the header segment. // The status is success; extract the wanted fields from the header segment.
// //
@ -957,7 +959,8 @@ IScsiProcessLoginRsp (
(Transit && (NextStage != Conn->NextStage)) || (Transit && (NextStage != Conn->NextStage)) ||
(CompareMem (Session->Isid, LoginRsp->Isid, sizeof (LoginRsp->Isid)) != 0) || (CompareMem (Session->Isid, LoginRsp->Isid, sizeof (LoginRsp->Isid)) != 0) ||
(LoginRsp->InitiatorTaskTag != Session->InitiatorTaskTag) (LoginRsp->InitiatorTaskTag != Session->InitiatorTaskTag)
) { )
{
// //
// A Login Response with the C bit set to 1 MUST have the T bit set to 0. // A Login Response with the C bit set to 1 MUST have the T bit set to 0.
// The CSG in the Login Response MUST be the same with the I-end of this connection. // The CSG in the Login Response MUST be the same with the I-end of this connection.
@ -1003,6 +1006,7 @@ IScsiProcessLoginRsp (
return Status; return Status;
} }
} }
// //
// Trim off the header segment. // Trim off the header segment.
// //
@ -1033,6 +1037,7 @@ IScsiProcessLoginRsp (
if (Session->AuthType != ISCSI_AUTH_TYPE_KRB) { if (Session->AuthType != ISCSI_AUTH_TYPE_KRB) {
Status = IScsiCHAPOnRspReceived (Conn); Status = IScsiCHAPOnRspReceived (Conn);
} }
break; break;
case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION: case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:
@ -1070,6 +1075,7 @@ IScsiProcessLoginRsp (
Session->Tsih = NTOHS (LoginRsp->Tsih); Session->Tsih = NTOHS (LoginRsp->Tsih);
} }
} }
// //
// Flush the response(s) received. // Flush the response(s) received.
// //
@ -1078,7 +1084,6 @@ IScsiProcessLoginRsp (
return Status; return Status;
} }
/** /**
Updated the target information according the data received in the iSCSI Updated the target information according the data received in the iSCSI
login response with an target redirection status. login response with an target redirection status.
@ -1140,11 +1145,11 @@ IScsiUpdateTargetAddress (
// //
TargetAddress++; TargetAddress++;
} }
} else if (*TargetAddress == ISCSI_REDIRECT_ADDR_START_DELIMITER){ } else if (*TargetAddress == ISCSI_REDIRECT_ADDR_START_DELIMITER) {
// //
// The domainname of the target is presented in a bracketed IPv6 address format. // The domainname of the target is presented in a bracketed IPv6 address format.
// //
TargetAddress ++; TargetAddress++;
IpStr = TargetAddress; IpStr = TargetAddress;
while ((*TargetAddress != '\0') && (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER)) { while ((*TargetAddress != '\0') && (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER)) {
// //
@ -1158,8 +1163,7 @@ IScsiUpdateTargetAddress (
} }
*TargetAddress = '\0'; *TargetAddress = '\0';
TargetAddress ++; TargetAddress++;
} else { } else {
// //
// The domainname of the target is presented in the format of a DNS host name. // The domainname of the target is presented in the format of a DNS host name.
@ -1169,6 +1173,7 @@ IScsiUpdateTargetAddress (
while ((*TargetAddress != '\0') && (*TargetAddress != ':') && (*TargetAddress != ',')) { while ((*TargetAddress != '\0') && (*TargetAddress != ':') && (*TargetAddress != ',')) {
TargetAddress++; TargetAddress++;
} }
NvData->DnsMode = TRUE; NvData->DnsMode = TRUE;
} }
@ -1192,7 +1197,7 @@ IScsiUpdateTargetAddress (
if (Number > 0xFFFF) { if (Number > 0xFFFF) {
continue; continue;
} else { } else {
NvData->TargetPort = (UINT16) Number; NvData->TargetPort = (UINT16)Number;
} }
} else { } else {
// //
@ -1220,9 +1225,10 @@ IScsiUpdateTargetAddress (
// Target address is expressed as URL format, just save it and // Target address is expressed as URL format, just save it and
// do DNS resolution when creating a TCP connection. // do DNS resolution when creating a TCP connection.
// //
if (AsciiStrSize (IpStr) > sizeof (Session->ConfigData->SessionConfigData.TargetUrl)){ if (AsciiStrSize (IpStr) > sizeof (Session->ConfigData->SessionConfigData.TargetUrl)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
CopyMem (&Session->ConfigData->SessionConfigData.TargetUrl, IpStr, AsciiStrSize (IpStr)); CopyMem (&Session->ConfigData->SessionConfigData.TargetUrl, IpStr, AsciiStrSize (IpStr));
} else { } else {
Status = IScsiAsciiStrToIp ( Status = IScsiAsciiStrToIp (
@ -1245,7 +1251,6 @@ IScsiUpdateTargetAddress (
return Status; return Status;
} }
/** /**
The callback function to free the net buffer list. The callback function to free the net buffer list.
@ -1260,11 +1265,10 @@ IScsiFreeNbufList (
{ {
ASSERT (Arg != NULL); ASSERT (Arg != NULL);
NetbufFreeList ((LIST_ENTRY *) Arg); NetbufFreeList ((LIST_ENTRY *)Arg);
FreePool (Arg); FreePool (Arg);
} }
/** /**
The callback function called in NetBufFree; it does nothing. The callback function called in NetBufFree; it does nothing.
@ -1279,7 +1283,6 @@ IScsiNbufExtFree (
{ {
} }
/** /**
Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU header and Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU header and
an optional data segment. The two parts will be put into two blocks of buffers in the an optional data segment. The two parts will be put into two blocks of buffers in the
@ -1344,6 +1347,7 @@ IScsiReceivePdu (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
InsertTailList (NbufList, &PduHdr->List); InsertTailList (NbufList, &PduHdr->List);
// //
@ -1372,6 +1376,7 @@ IScsiReceivePdu (
// //
goto FORM_PDU; goto FORM_PDU;
} }
// //
// Get the length of the padding bytes of the data segment. // Get the length of the padding bytes of the data segment.
// //
@ -1486,7 +1491,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Check and get the result of the parameter negotiation. Check and get the result of the parameter negotiation.
@ -1520,7 +1524,7 @@ IScsiCheckOpParams (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
NetbufQueCopy (&Conn->RspQue, 0, Len, (UINT8 *) Data); NetbufQueCopy (&Conn->RspQue, 0, Len, (UINT8 *)Data);
Status = EFI_PROTOCOL_ERROR; Status = EFI_PROTOCOL_ERROR;
@ -1532,6 +1536,7 @@ IScsiCheckOpParams (
FreePool (Data); FreePool (Data);
return Status; return Status;
} }
// //
// HeaderDigest // HeaderDigest
// //
@ -1549,6 +1554,7 @@ IScsiCheckOpParams (
} else { } else {
goto ON_ERROR; goto ON_ERROR;
} }
// //
// DataDigest // DataDigest
// //
@ -1566,6 +1572,7 @@ IScsiCheckOpParams (
} else { } else {
goto ON_ERROR; goto ON_ERROR;
} }
// //
// ErrorRecoveryLevel: result function is Minimum. // ErrorRecoveryLevel: result function is Minimum.
// //
@ -1579,7 +1586,7 @@ IScsiCheckOpParams (
goto ON_ERROR; goto ON_ERROR;
} }
Session->ErrorRecoveryLevel = (UINT8) MIN (Session->ErrorRecoveryLevel, NumericValue); Session->ErrorRecoveryLevel = (UINT8)MIN (Session->ErrorRecoveryLevel, NumericValue);
// //
// InitialR2T: result function is OR. // InitialR2T: result function is OR.
@ -1590,7 +1597,7 @@ IScsiCheckOpParams (
goto ON_ERROR; goto ON_ERROR;
} }
Session->InitialR2T = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0); Session->InitialR2T = (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0);
} }
// //
@ -1601,15 +1608,16 @@ IScsiCheckOpParams (
goto ON_ERROR; goto ON_ERROR;
} }
Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0)); Session->ImmediateData = (BOOLEAN)(Session->ImmediateData && (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0));
// //
// MaxRecvDataSegmentLength is declarative. // MaxRecvDataSegmentLength is declarative.
// //
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH); Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH);
if (Value != NULL) { if (Value != NULL) {
Conn->MaxRecvDataSegmentLength = (UINT32) IScsiNetNtoi (Value); Conn->MaxRecvDataSegmentLength = (UINT32)IScsiNetNtoi (Value);
} }
// //
// MaxBurstLength: result function is Minimum. // MaxBurstLength: result function is Minimum.
// //
@ -1619,7 +1627,7 @@ IScsiCheckOpParams (
} }
NumericValue = IScsiNetNtoi (Value); NumericValue = IScsiNetNtoi (Value);
Session->MaxBurstLength = (UINT32) MIN (Session->MaxBurstLength, NumericValue); Session->MaxBurstLength = (UINT32)MIN (Session->MaxBurstLength, NumericValue);
// //
// FirstBurstLength: result function is Minimum. Irrelevant when InitialR2T=Yes and // FirstBurstLength: result function is Minimum. Irrelevant when InitialR2T=Yes and
@ -1632,7 +1640,7 @@ IScsiCheckOpParams (
} }
NumericValue = IScsiNetNtoi (Value); NumericValue = IScsiNetNtoi (Value);
Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue); Session->FirstBurstLength = (UINT32)MIN (Session->FirstBurstLength, NumericValue);
} }
// //
@ -1648,7 +1656,7 @@ IScsiCheckOpParams (
goto ON_ERROR; goto ON_ERROR;
} }
Session->MaxConnections = (UINT32) MIN (Session->MaxConnections, NumericValue); Session->MaxConnections = (UINT32)MIN (Session->MaxConnections, NumericValue);
// //
// DataPDUInOrder: result function is OR. // DataPDUInOrder: result function is OR.
@ -1659,7 +1667,7 @@ IScsiCheckOpParams (
goto ON_ERROR; goto ON_ERROR;
} }
Session->DataPDUInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0); Session->DataPDUInOrder = (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0);
} }
// //
@ -1671,7 +1679,7 @@ IScsiCheckOpParams (
goto ON_ERROR; goto ON_ERROR;
} }
Session->DataSequenceInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0); Session->DataSequenceInOrder = (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0);
} }
// //
@ -1688,8 +1696,9 @@ IScsiCheckOpParams (
} else if (NumericValue > 3600) { } else if (NumericValue > 3600) {
goto ON_ERROR; goto ON_ERROR;
} else { } else {
Session->DefaultTime2Wait = (UINT32) MAX (Session->DefaultTime2Wait, NumericValue); Session->DefaultTime2Wait = (UINT32)MAX (Session->DefaultTime2Wait, NumericValue);
} }
// //
// DefaultTime2Retain: result function is Minimum. // DefaultTime2Retain: result function is Minimum.
// //
@ -1704,8 +1713,9 @@ IScsiCheckOpParams (
} else if (NumericValue > 3600) { } else if (NumericValue > 3600) {
goto ON_ERROR; goto ON_ERROR;
} else { } else {
Session->DefaultTime2Retain = (UINT32) MIN (Session->DefaultTime2Retain, NumericValue); Session->DefaultTime2Retain = (UINT32)MIN (Session->DefaultTime2Retain, NumericValue);
} }
// //
// MaxOutstandingR2T: result function is Minimum. // MaxOutstandingR2T: result function is Minimum.
// //
@ -1719,7 +1729,7 @@ IScsiCheckOpParams (
goto ON_ERROR; goto ON_ERROR;
} }
Session->MaxOutstandingR2T = (UINT16) MIN (Session->MaxOutstandingR2T, NumericValue); Session->MaxOutstandingR2T = (UINT16)MIN (Session->MaxOutstandingR2T, NumericValue);
// //
// Remove declarative key-value pairs, if any. // Remove declarative key-value pairs, if any.
@ -1728,7 +1738,6 @@ IScsiCheckOpParams (
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS); IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS);
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_PORTAL_GROUP_TAG); IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_PORTAL_GROUP_TAG);
// //
// Remove the key-value that may not needed for result function is OR. // Remove the key-value that may not needed for result function is OR.
// //
@ -1759,7 +1768,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Fill the operational parameters. Fill the operational parameters.
@ -1821,7 +1829,6 @@ IScsiFillOpParams (
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_MAX_OUTSTANDING_R2T, Value); IScsiAddKeyValuePair (Pdu, ISCSI_KEY_MAX_OUTSTANDING_R2T, Value);
} }
/** /**
Pad the iSCSI AHS or data segment to an integer number of 4 byte words. Pad the iSCSI AHS or data segment to an integer number of 4 byte words.
@ -1855,7 +1862,6 @@ IScsiPadSegment (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Build a key-value list from the data segment. Build a key-value list from the data segment.
@ -1909,10 +1915,10 @@ IScsiBuildKeyValueList (
KeyValuePair->Value = Data; KeyValuePair->Value = Data;
InsertTailList (ListHead, &KeyValuePair->List);; InsertTailList (ListHead, &KeyValuePair->List);
Data += AsciiStrLen (KeyValuePair->Value) + 1; Data += AsciiStrLen (KeyValuePair->Value) + 1;
Len -= (UINT32) AsciiStrLen (KeyValuePair->Value) + 1; Len -= (UINT32)AsciiStrLen (KeyValuePair->Value) + 1;
} }
return ListHead; return ListHead;
@ -1924,7 +1930,6 @@ ON_ERROR:
return NULL; return NULL;
} }
/** /**
Get the value string by the key name from the key-value list. If found, Get the value string by the key name from the key-value list. If found,
the key-value entry will be removed from the list. the key-value entry will be removed from the list.
@ -1963,7 +1968,6 @@ IScsiGetValueByKeyFromList (
return Value; return Value;
} }
/** /**
Free the key-value list. Free the key-value list.
@ -1988,7 +1992,6 @@ IScsiFreeKeyValueList (
FreePool (KeyValueList); FreePool (KeyValueList);
} }
/** /**
Normalize the iSCSI name according to RFC. Normalize the iSCSI name according to RFC.
@ -2012,7 +2015,7 @@ IScsiNormalizeName (
// //
// Convert the upper-case characters to lower-case ones. // Convert the upper-case characters to lower-case ones.
// //
Name[Index] = (CHAR8) (Name[Index] - 'A' + 'a'); Name[Index] = (CHAR8)(Name[Index] - 'A' + 'a');
} }
if (!NET_IS_LOWER_CASE_CHAR (Name[Index]) && if (!NET_IS_LOWER_CASE_CHAR (Name[Index]) &&
@ -2020,7 +2023,8 @@ IScsiNormalizeName (
(Name[Index] != '-') && (Name[Index] != '-') &&
(Name[Index] != '.') && (Name[Index] != '.') &&
(Name[Index] != ':') (Name[Index] != ':')
) { )
{
// //
// ASCII dash, dot, colon lower-case characters and digit characters // ASCII dash, dot, colon lower-case characters and digit characters
// are allowed. // are allowed.
@ -2039,7 +2043,6 @@ IScsiNormalizeName (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Create an iSCSI task control block. Create an iSCSI task control block.
@ -2093,7 +2096,6 @@ IScsiNewTcb (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Delete the tcb from the connection and destroy it. Delete the tcb from the connection and destroy it.
@ -2110,7 +2112,6 @@ IScsiDelTcb (
FreePool (Tcb); FreePool (Tcb);
} }
/** /**
Create a data segment, pad it, and calculate the CRC if needed. Create a data segment, pad it, and calculate the CRC if needed.
@ -2139,7 +2140,7 @@ IScsiNewDataSegment (
PadLen = ISCSI_GET_PAD_LEN (Len); PadLen = ISCSI_GET_PAD_LEN (Len);
if (PadLen != 0) { if (PadLen != 0) {
Fragment[1].Len = PadLen; Fragment[1].Len = PadLen;
Fragment[1].Bulk = (UINT8 *) &mDataSegPad; Fragment[1].Bulk = (UINT8 *)&mDataSegPad;
FragmentCount = 2; FragmentCount = 2;
} else { } else {
@ -2151,7 +2152,6 @@ IScsiNewDataSegment (
return DataSeg; return DataSeg;
} }
/** /**
Create a iSCSI SCSI command PDU to encapsulate the command issued Create a iSCSI SCSI command PDU to encapsulate the command issued
by SCSI through the EXT SCSI PASS THRU Protocol. by SCSI through the EXT SCSI PASS THRU Protocol.
@ -2197,7 +2197,7 @@ IScsiNewScsiCmdPdu (
// //
// The CDB exceeds 16 bytes. An extended CDB AHS is required. // The CDB exceeds 16 bytes. An extended CDB AHS is required.
// //
AHSLength = (UINT8) (AHSLength + ISCSI_ROUNDUP (Packet->CdbLength - 16) + sizeof (ISCSI_ADDITIONAL_HEADER)); AHSLength = (UINT8)(AHSLength + ISCSI_ROUNDUP (Packet->CdbLength - 16) + sizeof (ISCSI_ADDITIONAL_HEADER));
} }
Length = sizeof (SCSI_COMMAND) + AHSLength; Length = sizeof (SCSI_COMMAND) + AHSLength;
@ -2206,12 +2206,13 @@ IScsiNewScsiCmdPdu (
return NULL; return NULL;
} }
ScsiCmd = (SCSI_COMMAND *) NetbufAllocSpace (PduHeader, Length, NET_BUF_TAIL); ScsiCmd = (SCSI_COMMAND *)NetbufAllocSpace (PduHeader, Length, NET_BUF_TAIL);
if (ScsiCmd == NULL) { if (ScsiCmd == NULL) {
NetbufFree (PduHeader); NetbufFree (PduHeader);
return NULL; return NULL;
} }
Header = (ISCSI_ADDITIONAL_HEADER *) (ScsiCmd + 1);
Header = (ISCSI_ADDITIONAL_HEADER *)(ScsiCmd + 1);
ZeroMem (ScsiCmd, Length); ZeroMem (ScsiCmd, Length);
@ -2239,8 +2240,8 @@ IScsiNewScsiCmdPdu (
// //
// Fill the bidirectional expected read data length AHS. // Fill the bidirectional expected read data length AHS.
// //
BiExpReadDataLenAHS = (ISCSI_BI_EXP_READ_DATA_LEN_AHS *) Header; BiExpReadDataLenAHS = (ISCSI_BI_EXP_READ_DATA_LEN_AHS *)Header;
Header = (ISCSI_ADDITIONAL_HEADER *) (BiExpReadDataLenAHS + 1); Header = (ISCSI_ADDITIONAL_HEADER *)(BiExpReadDataLenAHS + 1);
BiExpReadDataLenAHS->Length = NTOHS (5); BiExpReadDataLenAHS->Length = NTOHS (5);
BiExpReadDataLenAHS->Type = ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN; BiExpReadDataLenAHS->Type = ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN;
@ -2258,10 +2259,10 @@ IScsiNewScsiCmdPdu (
CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb)); CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb));
if (Packet->CdbLength > 16) { if (Packet->CdbLength > 16) {
Header->Length = NTOHS ((UINT16) (Packet->CdbLength - 15)); Header->Length = NTOHS ((UINT16)(Packet->CdbLength - 15));
Header->Type = ISCSI_AHS_TYPE_EXT_CDB; Header->Type = ISCSI_AHS_TYPE_EXT_CDB;
CopyMem (Header + 1, (UINT8 *) Packet->Cdb + 16, Packet->CdbLength - 16); CopyMem (Header + 1, (UINT8 *)Packet->Cdb + 16, Packet->CdbLength - 16);
} }
Pdu = PduHeader; Pdu = PduHeader;
@ -2285,7 +2286,7 @@ IScsiNewScsiCmdPdu (
// //
// Create the data segment. // Create the data segment.
// //
DataSeg = IScsiNewDataSegment ((UINT8 *) Packet->OutDataBuffer, ImmediateDataLen, FALSE); DataSeg = IScsiNewDataSegment ((UINT8 *)Packet->OutDataBuffer, ImmediateDataLen, FALSE);
if (DataSeg == NULL) { if (DataSeg == NULL) {
NetbufFree (PduHeader); NetbufFree (PduHeader);
Pdu = NULL; Pdu = NULL;
@ -2314,7 +2315,8 @@ IScsiNewScsiCmdPdu (
if (Session->InitialR2T || if (Session->InitialR2T ||
(ImmediateDataLen == Session->FirstBurstLength) || (ImmediateDataLen == Session->FirstBurstLength) ||
(ImmediateDataLen == Packet->OutTransferLength) (ImmediateDataLen == Packet->OutTransferLength)
) { )
{
// //
// Unsolicited data out sequence is not allowed, // Unsolicited data out sequence is not allowed,
// or FirstBustLength data is already sent out by immediate data, // or FirstBustLength data is already sent out by immediate data,
@ -2330,7 +2332,6 @@ ON_EXIT:
return Pdu; return Pdu;
} }
/** /**
Create a new iSCSI SCSI Data Out PDU. Create a new iSCSI SCSI Data Out PDU.
@ -2375,16 +2376,18 @@ IScsiNewDataOutPdu (
FreePool (NbufList); FreePool (NbufList);
return NULL; return NULL;
} }
// //
// Insert the BHS into the buffer list. // Insert the BHS into the buffer list.
// //
InsertTailList (NbufList, &PduHdr->List); InsertTailList (NbufList, &PduHdr->List);
DataOutHdr = (ISCSI_SCSI_DATA_OUT *) NetbufAllocSpace (PduHdr, sizeof (ISCSI_SCSI_DATA_OUT), NET_BUF_TAIL); DataOutHdr = (ISCSI_SCSI_DATA_OUT *)NetbufAllocSpace (PduHdr, sizeof (ISCSI_SCSI_DATA_OUT), NET_BUF_TAIL);
if (DataOutHdr == NULL) { if (DataOutHdr == NULL) {
IScsiFreeNbufList (NbufList); IScsiFreeNbufList (NbufList);
return NULL; return NULL;
} }
XferContext = &Tcb->XferContext; XferContext = &Tcb->XferContext;
ZeroMem (DataOutHdr, sizeof (ISCSI_SCSI_DATA_OUT)); ZeroMem (DataOutHdr, sizeof (ISCSI_SCSI_DATA_OUT));
@ -2404,6 +2407,7 @@ IScsiNewDataOutPdu (
if (XferContext->TargetTransferTag != ISCSI_RESERVED_TAG) { if (XferContext->TargetTransferTag != ISCSI_RESERVED_TAG) {
CopyMem (&DataOutHdr->Lun, &Lun, sizeof (DataOutHdr->Lun)); CopyMem (&DataOutHdr->Lun, &Lun, sizeof (DataOutHdr->Lun));
} }
// //
// Build the data segment for this Data Out PDU. // Build the data segment for this Data Out PDU.
// //
@ -2412,6 +2416,7 @@ IScsiNewDataOutPdu (
IScsiFreeNbufList (NbufList); IScsiFreeNbufList (NbufList);
return NULL; return NULL;
} }
// //
// Put the data segment into the buffer list and combine it with the BHS // Put the data segment into the buffer list and combine it with the BHS
// into a full Data Out PDU. // into a full Data Out PDU.
@ -2425,7 +2430,6 @@ IScsiNewDataOutPdu (
return Pdu; return Pdu;
} }
/** /**
Generate a consecutive sequence of iSCSI SCSI Data Out PDUs. Generate a consecutive sequence of iSCSI SCSI Data Out PDUs.
@ -2491,6 +2495,7 @@ IScsiGenerateDataOutPduSequence (
XferContext->DesiredLength -= DataLen; XferContext->DesiredLength -= DataLen;
DataSN++; DataSN++;
} }
// //
// Set the F bit for the last data out PDU in this sequence. // Set the F bit for the last data out PDU in this sequence.
// //
@ -2560,7 +2565,6 @@ IScsiSendDataOutPduSequence (
return Status; return Status;
} }
/** /**
Process the received iSCSI SCSI Data In PDU. Process the received iSCSI SCSI Data In PDU.
@ -2585,7 +2589,7 @@ IScsiOnDataInRcvd (
ISCSI_SCSI_DATA_IN *DataInHdr; ISCSI_SCSI_DATA_IN *DataInHdr;
EFI_STATUS Status; EFI_STATUS Status;
DataInHdr = (ISCSI_SCSI_DATA_IN *) NetbufGetByte (Pdu, 0, NULL); DataInHdr = (ISCSI_SCSI_DATA_IN *)NetbufGetByte (Pdu, 0, NULL);
if (DataInHdr == NULL) { if (DataInHdr == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -2606,6 +2610,7 @@ IScsiOnDataInRcvd (
if (DataInHdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) { if (DataInHdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
// //
// Update the command related sequence numbers. // Update the command related sequence numbers.
// //
@ -2627,6 +2632,7 @@ IScsiOnDataInRcvd (
// //
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
// //
// S bit is on, the StatSN is valid. // S bit is on, the StatSN is valid.
// //
@ -2651,7 +2657,6 @@ IScsiOnDataInRcvd (
return Status; return Status;
} }
/** /**
Process the received iSCSI R2T PDU. Process the received iSCSI R2T PDU.
@ -2678,7 +2683,7 @@ IScsiOnR2TRcvd (
ISCSI_XFER_CONTEXT *XferContext; ISCSI_XFER_CONTEXT *XferContext;
UINT8 *Data; UINT8 *Data;
R2THdr = (ISCSI_READY_TO_TRANSFER *) NetbufGetByte (Pdu, 0, NULL); R2THdr = (ISCSI_READY_TO_TRANSFER *)NetbufGetByte (Pdu, 0, NULL);
if (R2THdr == NULL) { if (R2THdr == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -2691,8 +2696,9 @@ IScsiOnR2TRcvd (
R2THdr->DesiredDataTransferLength = NTOHL (R2THdr->DesiredDataTransferLength); R2THdr->DesiredDataTransferLength = NTOHL (R2THdr->DesiredDataTransferLength);
if ((R2THdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) || !ISCSI_SEQ_EQ (R2THdr->StatSN, Tcb->Conn->ExpStatSN)) { if ((R2THdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) || !ISCSI_SEQ_EQ (R2THdr->StatSN, Tcb->Conn->ExpStatSN)) {
return EFI_PROTOCOL_ERROR;; return EFI_PROTOCOL_ERROR;
} }
// //
// Check the sequence number. // Check the sequence number.
// //
@ -2708,19 +2714,20 @@ IScsiOnR2TRcvd (
if (((XferContext->Offset + XferContext->DesiredLength) > Packet->OutTransferLength) || if (((XferContext->Offset + XferContext->DesiredLength) > Packet->OutTransferLength) ||
(XferContext->DesiredLength > Tcb->Conn->Session->MaxBurstLength) (XferContext->DesiredLength > Tcb->Conn->Session->MaxBurstLength)
) { )
{
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
// //
// Send the data solicited by this R2T. // Send the data solicited by this R2T.
// //
Data = (UINT8 *) Packet->OutDataBuffer + XferContext->Offset; Data = (UINT8 *)Packet->OutDataBuffer + XferContext->Offset;
Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb); Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
return Status; return Status;
} }
/** /**
Process the received iSCSI SCSI Response PDU. Process the received iSCSI SCSI Response PDU.
@ -2746,7 +2753,7 @@ IScsiOnScsiRspRcvd (
EFI_STATUS Status; EFI_STATUS Status;
UINT32 DataSegLen; UINT32 DataSegLen;
ScsiRspHdr = (SCSI_RESPONSE *) NetbufGetByte (Pdu, 0, NULL); ScsiRspHdr = (SCSI_RESPONSE *)NetbufGetByte (Pdu, 0, NULL);
if (ScsiRspHdr == NULL) { if (ScsiRspHdr == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -2778,7 +2785,8 @@ IScsiOnScsiRspRcvd (
if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW | SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW) || if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW | SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW) ||
ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_OVERFLOW | SCSI_RSP_PDU_FLAG_UNDERFLOW) ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_OVERFLOW | SCSI_RSP_PDU_FLAG_UNDERFLOW)
) { )
{
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -2811,14 +2819,14 @@ IScsiOnScsiRspRcvd (
DataSegLen = ISCSI_GET_DATASEG_LEN (ScsiRspHdr); DataSegLen = ISCSI_GET_DATASEG_LEN (ScsiRspHdr);
if (DataSegLen != 0) { if (DataSegLen != 0) {
SenseData = (ISCSI_SENSE_DATA *) NetbufGetByte (Pdu, sizeof (SCSI_RESPONSE), NULL); SenseData = (ISCSI_SENSE_DATA *)NetbufGetByte (Pdu, sizeof (SCSI_RESPONSE), NULL);
if (SenseData == NULL) { if (SenseData == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
SenseData->Length = NTOHS (SenseData->Length); SenseData->Length = NTOHS (SenseData->Length);
Packet->SenseDataLength = (UINT8) MIN (SenseData->Length, Packet->SenseDataLength); Packet->SenseDataLength = (UINT8)MIN (SenseData->Length, Packet->SenseDataLength);
if (Packet->SenseDataLength != 0) { if (Packet->SenseDataLength != 0) {
CopyMem (Packet->SenseData, &SenseData->Data[0], Packet->SenseDataLength); CopyMem (Packet->SenseData, &SenseData->Data[0], Packet->SenseDataLength);
} }
@ -2829,7 +2837,6 @@ IScsiOnScsiRspRcvd (
return Status; return Status;
} }
/** /**
Process the received NOP In PDU. Process the received NOP In PDU.
@ -2850,7 +2857,7 @@ IScsiOnNopInRcvd (
ISCSI_NOP_IN *NopInHdr; ISCSI_NOP_IN *NopInHdr;
EFI_STATUS Status; EFI_STATUS Status;
NopInHdr = (ISCSI_NOP_IN *) NetbufGetByte (Pdu, 0, NULL); NopInHdr = (ISCSI_NOP_IN *)NetbufGetByte (Pdu, 0, NULL);
if (NopInHdr == NULL) { if (NopInHdr == NULL) {
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -2875,7 +2882,6 @@ IScsiOnNopInRcvd (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Execute the SCSI command issued through the EXT SCSI PASS THRU protocol. Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.
@ -2942,6 +2948,7 @@ IScsiExecuteScsiCommand (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Encapsulate the SCSI request packet into an iSCSI SCSI Command PDU. // Encapsulate the SCSI request packet into an iSCSI SCSI Command PDU.
// //
@ -2958,6 +2965,7 @@ IScsiExecuteScsiCommand (
NetbufFree (Pdu); NetbufFree (Pdu);
goto ON_EXIT; goto ON_EXIT;
} }
XferContext->Offset = ISCSI_GET_DATASEG_LEN (PduHdr); XferContext->Offset = ISCSI_GET_DATASEG_LEN (PduHdr);
// //
@ -2974,7 +2982,8 @@ IScsiExecuteScsiCommand (
if (!Session->InitialR2T && if (!Session->InitialR2T &&
(XferContext->Offset < Session->FirstBurstLength) && (XferContext->Offset < Session->FirstBurstLength) &&
(XferContext->Offset < Packet->OutTransferLength) (XferContext->Offset < Packet->OutTransferLength)
) { )
{
// //
// Unsolicited Data-Out sequence is allowed. There is remaining SCSI // Unsolicited Data-Out sequence is allowed. There is remaining SCSI
// OUT data, and the limit of FirstBurstLength is not reached. // OUT data, and the limit of FirstBurstLength is not reached.
@ -2985,14 +2994,14 @@ IScsiExecuteScsiCommand (
Packet->OutTransferLength - XferContext->Offset Packet->OutTransferLength - XferContext->Offset
); );
Data = (UINT8 *) Packet->OutDataBuffer + XferContext->Offset; Data = (UINT8 *)Packet->OutDataBuffer + XferContext->Offset;
Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb); Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
} }
InBufferContext.InData = (UINT8 *) Packet->InDataBuffer; InBufferContext.InData = (UINT8 *)Packet->InDataBuffer;
InBufferContext.InDataLen = Packet->InTransferLength; InBufferContext.InDataLen = Packet->InTransferLength;
while (!Tcb->StatusXferd) { while (!Tcb->StatusXferd) {
@ -3022,6 +3031,7 @@ IScsiExecuteScsiCommand (
NetbufFree (Pdu); NetbufFree (Pdu);
goto ON_EXIT; goto ON_EXIT;
} }
switch (ISCSI_GET_OPCODE (PduHdr)) { switch (ISCSI_GET_OPCODE (PduHdr)) {
case ISCSI_OPCODE_SCSI_DATA_IN: case ISCSI_OPCODE_SCSI_DATA_IN:
Status = IScsiOnDataInRcvd (Pdu, Tcb, Packet); Status = IScsiOnDataInRcvd (Pdu, Tcb, Packet);
@ -3072,7 +3082,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Reinstate the session on some error. Reinstate the session on some error.
@ -3105,7 +3114,6 @@ IScsiSessionReinstatement (
return Status; return Status;
} }
/** /**
Initialize some session parameters before login. Initialize some session parameters before login.
@ -3147,7 +3155,6 @@ IScsiSessionInit (
Session->ErrorRecoveryLevel = 0; Session->ErrorRecoveryLevel = 0;
} }
/** /**
Abort the iSCSI session. That is, reset all the connection(s), and free the Abort the iSCSI session. That is, reset all the connection(s), and free the
resources. resources.
@ -3164,7 +3171,7 @@ IScsiSessionAbort (
EFI_GUID *ProtocolGuid; EFI_GUID *ProtocolGuid;
if (Session->State != SESSION_STATE_LOGGED_IN) { if (Session->State != SESSION_STATE_LOGGED_IN) {
return ; return;
} }
ASSERT (!IsListEmpty (&Session->Conns)); ASSERT (!IsListEmpty (&Session->Conns));
@ -3197,5 +3204,5 @@ IScsiSessionAbort (
Session->State = SESSION_STATE_FAILED; Session->State = SESSION_STATE_FAILED;
return ; return;
} }

View File

@ -29,4 +29,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
extern EFI_GUID gEdkiiHttpTlsCipherListGuid; extern EFI_GUID gEdkiiHttpTlsCipherListGuid;
#endif #endif

View File

@ -17,4 +17,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
extern EFI_GUID gTlsAuthConfigGuid; extern EFI_GUID gTlsAuthConfigGuid;
#endif #endif

View File

@ -21,4 +21,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
extern EFI_GUID gEfiTlsCaCertificateGuid; extern EFI_GUID gEfiTlsCaCertificateGuid;
#endif #endif

View File

@ -39,7 +39,7 @@ typedef enum {
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI * HTTP_IO_CALLBACK) ( (EFIAPI *HTTP_IO_CALLBACK)(
IN HTTP_IO_CALLBACK_EVENT EventType, IN HTTP_IO_CALLBACK_EVENT EventType,
IN EFI_HTTP_MESSAGE *Message, IN EFI_HTTP_MESSAGE *Message,
IN VOID *Context IN VOID *Context
@ -324,5 +324,6 @@ HttpIoSendChunkedTransfer (
IN HTTP_IO *HttpIo, IN HTTP_IO *HttpIo,
IN HTTP_IO_SEND_CHUNK_PROCESS *SendChunkProcess, IN HTTP_IO_SEND_CHUNK_PROCESS *SendChunkProcess,
IN EFI_HTTP_MESSAGE *RequestMessage IN EFI_HTTP_MESSAGE *RequestMessage
); );
#endif #endif

View File

@ -13,7 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/Http.h> #include <Protocol/Http.h>
/** /**
Decode a percent-encoded URI component to the ASCII character. Decode a percent-encoded URI component to the ASCII character.
@ -229,12 +228,12 @@ typedef enum {
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *HTTP_BODY_PARSER_CALLBACK) ( (EFIAPI *HTTP_BODY_PARSER_CALLBACK)(
IN HTTP_BODY_PARSE_EVENT EventType, IN HTTP_BODY_PARSE_EVENT EventType,
IN CHAR8 *Data, IN CHAR8 *Data,
IN UINTN Length, IN UINTN Length,
IN VOID *Context IN VOID *Context
); );
/** /**
Initialize a HTTP message-body parser. Initialize a HTTP message-body parser.
@ -339,7 +338,6 @@ HttpFreeMsgParser (
IN VOID *MsgParser IN VOID *MsgParser
); );
/** /**
Find a specified header field according to the field name. Find a specified header field according to the field name.
@ -485,7 +483,6 @@ typedef struct {
EFI_HTTP_HEADER *Headers; EFI_HTTP_HEADER *Headers;
} HTTP_IO_HEADER; } HTTP_IO_HEADER;
/** /**
Create a HTTP_IO_HEADER to hold the HTTP header items. Create a HTTP_IO_HEADER to hold the HTTP header items.
@ -531,4 +528,3 @@ HttpIoSetHeader (
); );
#endif #endif

View File

@ -71,11 +71,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#define NET_PROTO_HDR(Buf, Type) ((Type *) ((Buf)->BlockOp[0].Head)) #define NET_PROTO_HDR(Buf, Type) ((Type *) ((Buf)->BlockOp[0].Head))
extern EFI_IP4_CONFIG_DATA mIp4IoDefaultIpConfigData; extern EFI_IP4_CONFIG_DATA mIp4IoDefaultIpConfigData;
extern EFI_IP6_CONFIG_DATA mIp6IoDefaultIpConfigData; extern EFI_IP6_CONFIG_DATA mIp6IoDefaultIpConfigData;
/// ///
/// This error will be delivered to the /// This error will be delivered to the
/// listening transportation layer protocol /// listening transportation layer protocol
@ -180,7 +178,7 @@ typedef struct _EFI_NET_SESSION_DATA {
**/ **/
typedef typedef
VOID VOID
(EFIAPI *PKT_RCVD_NOTIFY) ( (EFIAPI *PKT_RCVD_NOTIFY)(
IN EFI_STATUS Status, IN EFI_STATUS Status,
IN UINT8 IcmpErr, IN UINT8 IcmpErr,
IN EFI_NET_SESSION_DATA *NetSession, IN EFI_NET_SESSION_DATA *NetSession,
@ -201,7 +199,7 @@ VOID
**/ **/
typedef typedef
VOID VOID
(EFIAPI *PKT_SENT_NOTIFY) ( (EFIAPI *PKT_SENT_NOTIFY)(
IN EFI_STATUS Status, IN EFI_STATUS Status,
IN VOID *Context, IN VOID *Context,
IN IP_IO_IP_PROTOCOL Sender, IN IP_IO_IP_PROTOCOL Sender,
@ -604,4 +602,3 @@ IpIoRefreshNeighbor (
); );
#endif #endif

View File

@ -19,7 +19,6 @@ typedef UINT32 IP4_ADDR;
typedef UINT32 TCP_SEQNO; typedef UINT32 TCP_SEQNO;
typedef UINT16 TCP_PORTNO; typedef UINT16 TCP_PORTNO;
#define NET_ETHER_ADDR_LEN 6 #define NET_ETHER_ADDR_LEN 6
#define NET_IFTYPE_ETHERNET 0x01 #define NET_IFTYPE_ETHERNET 0x01
@ -94,15 +93,14 @@ typedef UINT16 TCP_PORTNO;
// //
#define MEDIA_STATE_DETECT_TIME_INTERVAL 1000000U #define MEDIA_STATE_DETECT_TIME_INTERVAL 1000000U
#pragma pack(1) #pragma pack(1)
// //
// Ethernet head definition // Ethernet head definition
// //
typedef struct { typedef struct {
UINT8 DstMac [NET_ETHER_ADDR_LEN]; UINT8 DstMac[NET_ETHER_ADDR_LEN];
UINT8 SrcMac [NET_ETHER_ADDR_LEN]; UINT8 SrcMac[NET_ETHER_ADDR_LEN];
UINT16 EtherType; UINT16 EtherType;
} ETHER_HEAD; } ETHER_HEAD;
@ -141,7 +139,6 @@ typedef struct {
IP4_ADDR Dst; IP4_ADDR Dst;
} IP4_HEAD; } IP4_HEAD;
// //
// ICMP head definition. Each ICMP message is categorized as either an error // ICMP head definition. Each ICMP message is categorized as either an error
// message or query message. Two message types have their own head format. // message or query message. Two message types have their own head format.
@ -357,7 +354,6 @@ NetDebugOutput (
IN UINT8 *Message IN UINT8 *Message
); );
/** /**
Return the length of the mask. Return the length of the mask.
@ -454,7 +450,6 @@ NetIp6IsValidUnicast (
IN EFI_IPv6_ADDRESS *Ip6 IN EFI_IPv6_ADDRESS *Ip6
); );
/** /**
Check whether the incoming Ipv6 address is the unspecified address or not. Check whether the incoming Ipv6 address is the unspecified address or not.
@ -533,7 +528,6 @@ Ip6Swap128 (
extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM]; extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM];
extern EFI_IPv4_ADDRESS mZeroIp4Addr; extern EFI_IPv4_ADDRESS mZeroIp4Addr;
#define NET_IS_DIGIT(Ch) (('0' <= (Ch)) && ((Ch) <= '9')) #define NET_IS_DIGIT(Ch) (('0' <= (Ch)) && ((Ch) <= '9'))
@ -601,7 +595,6 @@ NetRandomInitSeed (
VOID VOID
); );
#define NET_LIST_USER_STRUCT(Entry, Type, Field) \ #define NET_LIST_USER_STRUCT(Entry, Type, Field) \
BASE_CR(Entry, Type, Field) BASE_CR(Entry, Type, Field)
@ -635,7 +628,6 @@ NetRandomInitSeed (
#define NET_LIST_TAIL(ListHead, Type, Field) \ #define NET_LIST_TAIL(ListHead, Type, Field) \
NET_LIST_USER_STRUCT((ListHead)->BackLink, Type, Field) NET_LIST_USER_STRUCT((ListHead)->BackLink, Type, Field)
/** /**
Remove the first node entry on the list, and return the removed node entry. Remove the first node entry on the list, and return the removed node entry.
@ -734,7 +726,7 @@ NetListInsertBefore (
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK) ( (EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK)(
IN LIST_ENTRY *Entry, IN LIST_ENTRY *Entry,
IN VOID *Context OPTIONAL IN VOID *Context OPTIONAL
); );
@ -1031,7 +1023,7 @@ NetMapRemoveTail (
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *NET_MAP_CALLBACK) ( (EFIAPI *NET_MAP_CALLBACK)(
IN NET_MAP *Map, IN NET_MAP *Map,
IN NET_MAP_ITEM *Item, IN NET_MAP_ITEM *Item,
IN VOID *Arg IN VOID *Arg
@ -1064,10 +1056,10 @@ NetMapIterate (
IN VOID *Arg OPTIONAL IN VOID *Arg OPTIONAL
); );
// //
// Helper functions to implement driver binding and service binding protocols. // Helper functions to implement driver binding and service binding protocols.
// //
/** /**
Create a child of the service that is identified by ServiceBindingGuid. Create a child of the service that is identified by ServiceBindingGuid.
@ -1310,7 +1302,6 @@ NetLibDetectMediaWaitTimeout (
OUT EFI_STATUS *MediaState OUT EFI_STATUS *MediaState
); );
/** /**
Create an IPv4 device path node. Create an IPv4 device path node.
@ -1377,7 +1368,6 @@ NetLibCreateIPv6DPathNode (
IN UINT16 Protocol IN UINT16 Protocol
); );
/** /**
Find the UNDI/SNP handle from controller and protocol GUID. Find the UNDI/SNP handle from controller and protocol GUID.
@ -1542,7 +1532,6 @@ NetLibIp6ToStr (
#define NET_VECTOR_SIGNATURE SIGNATURE_32 ('n', 'v', 'e', 'c') #define NET_VECTOR_SIGNATURE SIGNATURE_32 ('n', 'v', 'e', 'c')
#define NET_QUE_SIGNATURE SIGNATURE_32 ('n', 'b', 'q', 'u') #define NET_QUE_SIGNATURE SIGNATURE_32 ('n', 'b', 'q', 'u')
#define NET_PROTO_DATA 64 // Opaque buffer for protocols #define NET_PROTO_DATA 64 // Opaque buffer for protocols
#define NET_BUF_HEAD 1 // Trim or allocate space from head #define NET_BUF_HEAD 1 // Trim or allocate space from head
#define NET_BUF_TAIL 0 // Trim or allocate space from tail #define NET_BUF_TAIL 0 // Trim or allocate space from tail
@ -1559,12 +1548,12 @@ typedef struct {
UINT8 *Bulk; // The block's Data UINT8 *Bulk; // The block's Data
} NET_BLOCK; } NET_BLOCK;
typedef VOID (EFIAPI *NET_VECTOR_EXT_FREE) (VOID *Arg); typedef VOID (EFIAPI *NET_VECTOR_EXT_FREE)(VOID *Arg);
// //
//NET_VECTOR contains several blocks to hold all packet's // NET_VECTOR contains several blocks to hold all packet's
//fragments and other house-keeping stuff for sharing. It // fragments and other house-keeping stuff for sharing. It
//doesn't specify the where actual packet fragment begins. // doesn't specify the where actual packet fragment begins.
// //
typedef struct { typedef struct {
UINT32 Signature; UINT32 Signature;
@ -1579,8 +1568,8 @@ typedef struct {
} NET_VECTOR; } NET_VECTOR;
// //
//NET_BLOCK_OP operates on the NET_BLOCK. It specifies // NET_BLOCK_OP operates on the NET_BLOCK. It specifies
//where the actual fragment begins and ends // where the actual fragment begins and ends
// //
typedef struct { typedef struct {
UINT8 *BlockHead; // Block's head, or the smallest valid Head UINT8 *BlockHead; // Block's head, or the smallest valid Head
@ -1596,14 +1585,14 @@ typedef union {
} NET_IP_HEAD; } NET_IP_HEAD;
// //
//NET_BUF is the buffer manage structure used by the // NET_BUF is the buffer manage structure used by the
//network stack. Every network packet may be fragmented. The Vector points to // network stack. Every network packet may be fragmented. The Vector points to
//memory blocks used by each fragment, and BlockOp // memory blocks used by each fragment, and BlockOp
//specifies where each fragment begins and ends. // specifies where each fragment begins and ends.
// //
//It also contains an opaque area for the protocol to store // It also contains an opaque area for the protocol to store
//per-packet information. Protocol must be careful not // per-packet information. Protocol must be careful not
//to overwrite the members after that. // to overwrite the members after that.
// //
typedef struct { typedef struct {
UINT32 Signature; UINT32 Signature;
@ -1613,7 +1602,7 @@ typedef struct {
NET_IP_HEAD Ip; // Network layer header, for fast access NET_IP_HEAD Ip; // Network layer header, for fast access
TCP_HEAD *Tcp; // Transport layer header, for fast access TCP_HEAD *Tcp; // Transport layer header, for fast access
EFI_UDP_HEADER *Udp; // User Datagram Protocol header EFI_UDP_HEADER *Udp; // User Datagram Protocol header
UINT8 ProtoData [NET_PROTO_DATA]; //Protocol specific data UINT8 ProtoData[NET_PROTO_DATA]; // Protocol specific data
NET_VECTOR *Vector; // The vector containing the packet NET_VECTOR *Vector; // The vector containing the packet
@ -1623,8 +1612,8 @@ typedef struct {
} NET_BUF; } NET_BUF;
// //
//A queue of NET_BUFs. It is a thin extension of // A queue of NET_BUFs. It is a thin extension of
//NET_BUF functions. // NET_BUF functions.
// //
typedef struct { typedef struct {
UINT32 Signature; UINT32 Signature;
@ -1652,8 +1641,8 @@ typedef struct {
EFI_IPv6_ADDRESS SrcIp; EFI_IPv6_ADDRESS SrcIp;
EFI_IPv6_ADDRESS DstIp; EFI_IPv6_ADDRESS DstIp;
UINT32 Len; UINT32 Len;
UINT32 Reserved:24; UINT32 Reserved : 24;
UINT32 NextHeader:8; UINT32 NextHeader : 8;
} NET_IP6_PSEUDO_HDR; } NET_IP6_PSEUDO_HDR;
#pragma pack() #pragma pack()
@ -1844,7 +1833,7 @@ NetbufReserve (
or NULL, if there is no sufficient space. or NULL, if there is no sufficient space.
**/ **/
UINT8* UINT8 *
EFIAPI EFIAPI
NetbufAllocSpace ( NetbufAllocSpace (
IN OUT NET_BUF *Nbuf, IN OUT NET_BUF *Nbuf,
@ -2104,7 +2093,6 @@ NetbufQueTrim (
IN UINT32 Len IN UINT32 Len
); );
/** /**
Flush the net buffer queue. Flush the net buffer queue.

View File

@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _TCP_IO_H_ #ifndef _TCP_IO_H_
#define _TCP_IO_H_ #define _TCP_IO_H_
#include <Protocol/Tcp4.h> #include <Protocol/Tcp4.h>
#include <Protocol/Tcp6.h> #include <Protocol/Tcp6.h>
@ -24,7 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// ///
#define TCP_GET_MAPPING_TIMEOUT 100000000U #define TCP_GET_MAPPING_TIMEOUT 100000000U
typedef struct { typedef struct {
EFI_IPv4_ADDRESS LocalIp; EFI_IPv4_ADDRESS LocalIp;
EFI_IPv4_ADDRESS SubnetMask; EFI_IPv4_ADDRESS SubnetMask;
@ -73,7 +71,6 @@ typedef union {
EFI_TCP6_LISTEN_TOKEN Tcp6Token; EFI_TCP6_LISTEN_TOKEN Tcp6Token;
} TCP_IO_LISTEN_TOKEN; } TCP_IO_LISTEN_TOKEN;
typedef struct { typedef struct {
UINT8 TcpVersion; UINT8 TcpVersion;
EFI_HANDLE Image; EFI_HANDLE Image;
@ -244,4 +241,3 @@ TcpIoReceive (
); );
#endif #endif

View File

@ -54,7 +54,7 @@ typedef struct {
**/ **/
typedef typedef
VOID VOID
(EFIAPI *UDP_IO_CALLBACK) ( (EFIAPI *UDP_IO_CALLBACK)(
IN NET_BUF *Packet, IN NET_BUF *Packet,
IN UDP_END_POINT *EndPoint, IN UDP_END_POINT *EndPoint,
IN EFI_STATUS IoStatus, IN EFI_STATUS IoStatus,
@ -85,8 +85,6 @@ typedef struct {
UDP_COMPLETION_TOKEN Token; UDP_COMPLETION_TOKEN Token;
} UDP_RX_TOKEN; } UDP_RX_TOKEN;
/// ///
/// This structure is used internally by UdpIo Library. /// This structure is used internally by UdpIo Library.
/// ///
@ -167,7 +165,7 @@ struct _UDP_IO {
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *UDP_IO_CONFIG) ( (EFIAPI *UDP_IO_CONFIG)(
IN UDP_IO *UdpIo, IN UDP_IO *UdpIo,
IN VOID *Context IN VOID *Context
); );
@ -184,7 +182,7 @@ EFI_STATUS
**/ **/
typedef typedef
BOOLEAN BOOLEAN
(EFIAPI *UDP_IO_TO_CANCEL) ( (EFIAPI *UDP_IO_TO_CANCEL)(
IN UDP_TX_TOKEN *Token, IN UDP_TX_TOKEN *Token,
IN VOID *Context IN VOID *Context
); );

View File

@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef __DPC_H__ #ifndef __DPC_H__
#define __DPC_H__ #define __DPC_H__
@ -24,7 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// //
typedef struct _EFI_DPC_PROTOCOL EFI_DPC_PROTOCOL; typedef struct _EFI_DPC_PROTOCOL EFI_DPC_PROTOCOL;
/** /**
Invoke a Deferred Procedure Call. Invoke a Deferred Procedure Call.

View File

@ -67,7 +67,7 @@ typedef enum {
**/ **/
typedef typedef
VOID VOID
(EFIAPI * EDKII_HTTP_CALLBACK) ( (EFIAPI *EDKII_HTTP_CALLBACK)(
IN EDKII_HTTP_CALLBACK_PROTOCOL *This, IN EDKII_HTTP_CALLBACK_PROTOCOL *This,
IN EDKII_HTTP_CALLBACK_EVENT Event, IN EDKII_HTTP_CALLBACK_EVENT Event,
IN EFI_STATUS EventStatus IN EFI_STATUS EventStatus

View File

@ -10,6 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user readable name of the driver. Retrieves a Unicode string that is the user readable name of the driver.
@ -57,7 +58,6 @@ Ip4ComponentNameGetDriverName (
OUT CHAR16 **DriverName OUT CHAR16 **DriverName
); );
/** /**
Retrieves a Unicode string that is the user readable name of the controller Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -136,7 +136,6 @@ Ip4ComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
// //
// EFI Component Name Protocol // EFI Component Name Protocol
// //
@ -150,12 +149,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName = {
// EFI Component Name 2 Protocol // EFI Component Name 2 Protocol
// //
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2 = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ip4ComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Ip4ComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ip4ComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Ip4ComponentNameGetControllerName,
"en" "en"
}; };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4DriverNameTable[] = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4DriverNameTable[] = {
{ {
"eng;en", "eng;en",
@ -223,7 +221,6 @@ Ip4ComponentNameGetDriverName (
DriverName, DriverName,
(BOOLEAN)(This == &gIp4ComponentName) (BOOLEAN)(This == &gIp4ComponentName)
); );
} }
/** /**
@ -261,7 +258,9 @@ UpdateName (
if (!Ip4ModeData.IsStarted || !Ip4ModeData.IsConfigured) { if (!Ip4ModeData.IsStarted || !Ip4ModeData.IsConfigured) {
UnicodeSPrint (HandleName, sizeof (HandleName), L"IPv4 (Not started)"); UnicodeSPrint (HandleName, sizeof (HandleName), L"IPv4 (Not started)");
} else { } else {
UnicodeSPrint (HandleName, sizeof (HandleName), UnicodeSPrint (
HandleName,
sizeof (HandleName),
L"IPv4 (SrcIP=%d.%d.%d.%d)", L"IPv4 (SrcIP=%d.%d.%d.%d)",
Ip4ModeData.ConfigData.StationAddress.Addr[0], Ip4ModeData.ConfigData.StationAddress.Addr[0],
Ip4ModeData.ConfigData.StationAddress.Addr[1], Ip4ModeData.ConfigData.StationAddress.Addr[1],
@ -274,6 +273,7 @@ UpdateName (
FreeUnicodeStringTable (gIp4ControllerNameTable); FreeUnicodeStringTable (gIp4ControllerNameTable);
gIp4ControllerNameTable = NULL; gIp4ControllerNameTable = NULL;
} }
Status = AddUnicodeString2 ( Status = AddUnicodeString2 (
"eng", "eng",
gIp4ComponentName.SupportedLanguages, gIp4ComponentName.SupportedLanguages,
@ -425,4 +425,3 @@ Ip4ComponentNameGetControllerName (
(BOOLEAN)(This == &gIp4ComponentName) (BOOLEAN)(This == &gIp4ComponentName)
); );
} }

View File

@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Ip4Impl.h" #include "Ip4Impl.h"
/** /**
Return the cast type (Unicast/Broadcast) specific to an Return the cast type (Unicast/Broadcast) specific to an
interface. All the addresses are host byte ordered. interface. All the addresses are host byte ordered.
@ -31,19 +30,15 @@ Ip4GetNetCast (
{ {
if (IpAddr == IpIf->Ip) { if (IpAddr == IpIf->Ip) {
return IP4_LOCAL_HOST; return IP4_LOCAL_HOST;
} else if (IpAddr == IpIf->SubnetBrdcast) { } else if (IpAddr == IpIf->SubnetBrdcast) {
return IP4_SUBNET_BROADCAST; return IP4_SUBNET_BROADCAST;
} else if (IpAddr == IpIf->NetBrdcast) { } else if (IpAddr == IpIf->NetBrdcast) {
return IP4_NET_BROADCAST; return IP4_NET_BROADCAST;
} }
return 0; return 0;
} }
/** /**
Find the cast type of the packet related to the local host. Find the cast type of the packet related to the local host.
This isn't the same as link layer cast type. For example, DHCP This isn't the same as link layer cast type. For example, DHCP
@ -106,18 +101,16 @@ Ip4GetHostCast (
if (Dst == IP4_ALLONE_ADDRESS) { if (Dst == IP4_ALLONE_ADDRESS) {
IpIf = Ip4FindNet (IpSb, Src); IpIf = Ip4FindNet (IpSb, Src);
if (IpIf != NULL && !IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf))) { if ((IpIf != NULL) && !IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf))) {
return IP4_LOCAL_BROADCAST; return IP4_LOCAL_BROADCAST;
} }
} else if (IP4_IS_MULTICAST (Dst) && (Ip4FindGroup (&IpSb->IgmpCtrl, Dst) != NULL)) {
} else if (IP4_IS_MULTICAST (Dst) && Ip4FindGroup (&IpSb->IgmpCtrl, Dst) != NULL) {
return IP4_MULTICAST; return IP4_MULTICAST;
} }
return Type; return Type;
} }
/** /**
Find an interface whose configured IP address is Ip. Find an interface whose configured IP address is Ip.
@ -147,7 +140,6 @@ Ip4FindInterface (
return NULL; return NULL;
} }
/** /**
Find an interface that Ip is on that connected network. Find an interface that Ip is on that connected network.
@ -177,7 +169,6 @@ Ip4FindNet (
return NULL; return NULL;
} }
/** /**
Find an interface of the service with the same Ip/Netmask pair. Find an interface of the service with the same Ip/Netmask pair.
@ -209,7 +200,6 @@ Ip4FindStationAddress (
return NULL; return NULL;
} }
/** /**
Get the MAC address for a multicast IP address. Call Get the MAC address for a multicast IP address. Call
Mnp's McastIpToMac to find the MAC address in stead of Mnp's McastIpToMac to find the MAC address in stead of
@ -237,7 +227,6 @@ Ip4GetMulticastMac (
return Mnp->McastIpToMac (Mnp, FALSE, &EfiIp, Mac); return Mnp->McastIpToMac (Mnp, FALSE, &EfiIp, Mac);
} }
/** /**
Convert the multibyte field in IP header's byter order. Convert the multibyte field in IP header's byter order.
In spite of its name, it can also be used to convert from In spite of its name, it can also be used to convert from
@ -262,7 +251,6 @@ Ip4NtohHead (
return Head; return Head;
} }
/** /**
Validate that Ip/Netmask pair is OK to be used as station Validate that Ip/Netmask pair is OK to be used as station
address. Only continuous netmasks are supported. and check address. Only continuous netmasks are supported. and check
@ -285,7 +273,7 @@ Ip4StationAddressValid (
// Only support the station address with 0.0.0.0/0 to enable DHCP client. // Only support the station address with 0.0.0.0/0 to enable DHCP client.
// //
if (Netmask == IP4_ALLZERO_ADDRESS) { if (Netmask == IP4_ALLZERO_ADDRESS) {
return (BOOLEAN) (Ip == IP4_ALLZERO_ADDRESS); return (BOOLEAN)(Ip == IP4_ALLZERO_ADDRESS);
} }
// //

View File

@ -195,7 +195,6 @@ Ip4NtohHead (
IN IP4_HEAD *Head IN IP4_HEAD *Head
); );
/** /**
Validate that Ip/Netmask pair is OK to be used as station Validate that Ip/Netmask pair is OK to be used as station
address. Only continuous netmasks are supported. and check address. Only continuous netmasks are supported. and check

View File

@ -10,7 +10,7 @@
#include "Ip4Impl.h" #include "Ip4Impl.h"
LIST_ENTRY mIp4Config2InstanceList = {&mIp4Config2InstanceList, &mIp4Config2InstanceList}; LIST_ENTRY mIp4Config2InstanceList = { &mIp4Config2InstanceList, &mIp4Config2InstanceList };
/** /**
The event process routine when the DHCPv4 service binding protocol is installed The event process routine when the DHCPv4 service binding protocol is installed
@ -122,13 +122,13 @@ Ip4Config2OnPolicyChanged (
// //
IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image); IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
if (IpIf == NULL) { if (IpIf == NULL) {
return ; return;
} }
RouteTable = Ip4CreateRouteTable (); RouteTable = Ip4CreateRouteTable ();
if (RouteTable == NULL) { if (RouteTable == NULL) {
Ip4FreeInterface (IpIf, NULL); Ip4FreeInterface (IpIf, NULL);
return ; return;
} }
IpSb->DefaultInterface = IpIf; IpSb->DefaultInterface = IpIf;
@ -136,7 +136,7 @@ Ip4Config2OnPolicyChanged (
IpSb->DefaultRouteTable = RouteTable; IpSb->DefaultRouteTable = RouteTable;
Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb); Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
if (IpSb->State == IP4_SERVICE_CONFIGED || IpSb->State == IP4_SERVICE_STARTED) { if ((IpSb->State == IP4_SERVICE_CONFIGED) || (IpSb->State == IP4_SERVICE_STARTED)) {
IpSb->State = IP4_SERVICE_UNSTARTED; IpSb->State = IP4_SERVICE_UNSTARTED;
} }
@ -146,7 +146,6 @@ Ip4Config2OnPolicyChanged (
if (NewPolicy == Ip4Config2PolicyDhcp) { if (NewPolicy == Ip4Config2PolicyDhcp) {
Ip4StartAutoConfig (&IpSb->Ip4Config2Instance); Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
} }
} }
/** /**
@ -166,7 +165,7 @@ Ip4Config2SignalEvent (
IN VOID *Arg IN VOID *Arg
) )
{ {
gBS->SignalEvent ((EFI_EVENT) Item->Key); gBS->SignalEvent ((EFI_EVENT)Item->Key);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -227,7 +226,7 @@ Ip4Config2ReadConfigData (
&VarSize, &VarSize,
Variable Variable
); );
if (EFI_ERROR (Status) || (UINT16) (~NetblockChecksum ((UINT8 *) Variable, (UINT32) VarSize)) != 0) { if (EFI_ERROR (Status) || ((UINT16)(~NetblockChecksum ((UINT8 *)Variable, (UINT32)VarSize)) != 0)) {
// //
// GetVariable still error or the variable is corrupted. // GetVariable still error or the variable is corrupted.
// Fall back to the default value. // Fall back to the default value.
@ -249,15 +248,14 @@ Ip4Config2ReadConfigData (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
for (Index = 0; Index < Variable->DataRecordCount; Index++) { for (Index = 0; Index < Variable->DataRecordCount; Index++) {
CopyMem (&DataRecord, &Variable->DataRecord[Index], sizeof (DataRecord)); CopyMem (&DataRecord, &Variable->DataRecord[Index], sizeof (DataRecord));
DataItem = &Instance->DataItem[DataRecord.DataType]; DataItem = &Instance->DataItem[DataRecord.DataType];
if (DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED) && if (DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED) &&
(DataItem->DataSize != DataRecord.DataSize) (DataItem->DataSize != DataRecord.DataSize)
) { )
{
// //
// Perhaps a corrupted data record... // Perhaps a corrupted data record...
// //
@ -277,7 +275,7 @@ Ip4Config2ReadConfigData (
} }
} }
Data = (CHAR8 *) Variable + DataRecord.Offset; Data = (CHAR8 *)Variable + DataRecord.Offset;
CopyMem (DataItem->Data.Ptr, Data, DataRecord.DataSize); CopyMem (DataItem->Data.Ptr, Data, DataRecord.DataSize);
DataItem->DataSize = DataRecord.DataSize; DataItem->DataSize = DataRecord.DataSize;
@ -318,10 +316,8 @@ Ip4Config2WriteConfigData (
VarSize = sizeof (IP4_CONFIG2_VARIABLE) - sizeof (IP4_CONFIG2_DATA_RECORD); VarSize = sizeof (IP4_CONFIG2_VARIABLE) - sizeof (IP4_CONFIG2_DATA_RECORD);
for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) { for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) {
DataItem = &Instance->DataItem[Index]; DataItem = &Instance->DataItem[Index];
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_VOLATILE) && !EFI_ERROR (DataItem->Status)) { if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_VOLATILE) && !EFI_ERROR (DataItem->Status)) {
VarSize += sizeof (IP4_CONFIG2_DATA_RECORD) + DataItem->DataSize; VarSize += sizeof (IP4_CONFIG2_DATA_RECORD) + DataItem->DataSize;
} }
} }
@ -331,28 +327,26 @@ Ip4Config2WriteConfigData (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Heap = (CHAR8 *) Variable + VarSize; Heap = (CHAR8 *)Variable + VarSize;
Variable->DataRecordCount = 0; Variable->DataRecordCount = 0;
for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) { for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) {
DataItem = &Instance->DataItem[Index]; DataItem = &Instance->DataItem[Index];
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_VOLATILE) && !EFI_ERROR (DataItem->Status)) { if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_VOLATILE) && !EFI_ERROR (DataItem->Status)) {
Heap -= DataItem->DataSize; Heap -= DataItem->DataSize;
CopyMem (Heap, DataItem->Data.Ptr, DataItem->DataSize); CopyMem (Heap, DataItem->Data.Ptr, DataItem->DataSize);
DataRecord = &Variable->DataRecord[Variable->DataRecordCount]; DataRecord = &Variable->DataRecord[Variable->DataRecordCount];
DataRecord->DataType = (EFI_IP4_CONFIG2_DATA_TYPE) Index; DataRecord->DataType = (EFI_IP4_CONFIG2_DATA_TYPE)Index;
DataRecord->DataSize = (UINT32) DataItem->DataSize; DataRecord->DataSize = (UINT32)DataItem->DataSize;
DataRecord->Offset = (UINT16) (Heap - (CHAR8 *) Variable); DataRecord->Offset = (UINT16)(Heap - (CHAR8 *)Variable);
Variable->DataRecordCount++; Variable->DataRecordCount++;
} }
} }
Variable->Checksum = 0; Variable->Checksum = 0;
Variable->Checksum = (UINT16) ~NetblockChecksum ((UINT8 *) Variable, (UINT32) VarSize); Variable->Checksum = (UINT16) ~NetblockChecksum ((UINT8 *)Variable, (UINT32)VarSize);
Status = gRT->SetVariable ( Status = gRT->SetVariable (
VarName, VarName,
@ -367,7 +361,6 @@ Ip4Config2WriteConfigData (
return Status; return Status;
} }
/** /**
Build a EFI_IP4_ROUTE_TABLE to be returned to the caller of GetModeData. Build a EFI_IP4_ROUTE_TABLE to be returned to the caller of GetModeData.
The EFI_IP4_ROUTE_TABLE is clumsy to use in the internal operation of the The EFI_IP4_ROUTE_TABLE is clumsy to use in the internal operation of the
@ -410,7 +403,6 @@ Ip4Config2BuildDefaultRouteTable (
Count = 0; Count = 0;
for (Index = IP4_MASK_MAX; Index >= 0; Index--) { for (Index = IP4_MASK_MAX; Index >= 0; Index--) {
NET_LIST_FOR_EACH (Entry, &(IpSb->DefaultRouteTable->RouteArea[Index])) { NET_LIST_FOR_EACH (Entry, &(IpSb->DefaultRouteTable->RouteArea[Index])) {
RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link); RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link);
@ -420,7 +412,6 @@ Ip4Config2BuildDefaultRouteTable (
Count++; Count++;
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -443,13 +434,13 @@ Ip4Config2OnDhcp4SbInstalled (
{ {
IP4_CONFIG2_INSTANCE *Instance; IP4_CONFIG2_INSTANCE *Instance;
Instance = (IP4_CONFIG2_INSTANCE *) Context; Instance = (IP4_CONFIG2_INSTANCE *)Context;
if ((Instance->Dhcp4Handle != NULL) || (Instance->Policy != Ip4Config2PolicyDhcp)) { if ((Instance->Dhcp4Handle != NULL) || (Instance->Policy != Ip4Config2PolicyDhcp)) {
// //
// The DHCP4 child is already created or the policy is no longer DHCP. // The DHCP4 child is already created or the policy is no longer DHCP.
// //
return ; return;
} }
Ip4StartAutoConfig (Instance); Ip4StartAutoConfig (Instance);
@ -542,7 +533,7 @@ Ip4Config2SetDefaultAddr (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
IpIf->ArpHandle, IpIf->ArpHandle,
&gEfiArpProtocolGuid, &gEfiArpProtocolGuid,
(VOID **) &Arp, (VOID **)&Arp,
gIp4DriverBinding.DriverBindingHandle, gIp4DriverBinding.DriverBindingHandle,
Ip4Instance->Handle, Ip4Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -623,7 +614,6 @@ Ip4Config2SetDefaultIf (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Release all the DHCP related resources. Release all the DHCP related resources.
@ -713,7 +703,7 @@ Ip4Config2SetDnsServerWorker (
} }
Item = &Instance->DataItem[Ip4Config2DataTypeDnsServer]; Item = &Instance->DataItem[Ip4Config2DataTypeDnsServer];
NewDns = (EFI_IPv4_ADDRESS *) Data; NewDns = (EFI_IPv4_ADDRESS *)Data;
OldDns = Item->Data.DnsServers; OldDns = Item->Data.DnsServers;
NewDnsCount = DataSize / sizeof (EFI_IPv4_ADDRESS); NewDnsCount = DataSize / sizeof (EFI_IPv4_ADDRESS);
OldDnsCount = Item->DataSize / sizeof (EFI_IPv4_ADDRESS); OldDnsCount = Item->DataSize / sizeof (EFI_IPv4_ADDRESS);
@ -737,6 +727,7 @@ Ip4Config2SetDnsServerWorker (
if (Tmp != NULL) { if (Tmp != NULL) {
FreePool (Tmp); FreePool (Tmp);
} }
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -773,6 +764,7 @@ Ip4Config2SetDnsServerWorker (
if (Item->Data.Ptr != NULL) { if (Item->Data.Ptr != NULL) {
FreePool (Item->Data.Ptr); FreePool (Item->Data.Ptr);
} }
Item->Data.Ptr = Tmp; Item->Data.Ptr = Tmp;
} }
@ -783,8 +775,6 @@ Ip4Config2SetDnsServerWorker (
} }
} }
/** /**
Callback function when DHCP process finished. It will save the Callback function when DHCP process finished. It will save the
retrieved IP configure parameter from DHCP to the NVRam. retrieved IP configure parameter from DHCP to the NVRam.
@ -812,7 +802,7 @@ Ip4Config2OnDhcp4Complete (
UINT32 OptionCount; UINT32 OptionCount;
EFI_DHCP4_PACKET_OPTION **OptionList; EFI_DHCP4_PACKET_OPTION **OptionList;
Instance = (IP4_CONFIG2_INSTANCE *) Context; Instance = (IP4_CONFIG2_INSTANCE *)Context;
ASSERT (Instance->Dhcp4 != NULL); ASSERT (Instance->Dhcp4 != NULL);
// //
@ -880,7 +870,6 @@ Exit:
DispatchDpc (); DispatchDpc ();
} }
/** /**
Start the DHCP configuration for this IP service instance. Start the DHCP configuration for this IP service instance.
It will locates the EFI_IP4_CONFIG2_PROTOCOL, then start the It will locates the EFI_IP4_CONFIG2_PROTOCOL, then start the
@ -934,7 +923,7 @@ Ip4StartAutoConfig (
&gEfiDhcp4ServiceBindingProtocolGuid, &gEfiDhcp4ServiceBindingProtocolGuid,
TPL_CALLBACK, TPL_CALLBACK,
Ip4Config2OnDhcp4SbInstalled, Ip4Config2OnDhcp4SbInstalled,
(VOID *) Instance, (VOID *)Instance,
&Instance->Registration &Instance->Registration
); );
} }
@ -951,7 +940,7 @@ Ip4StartAutoConfig (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Instance->Dhcp4Handle, Instance->Dhcp4Handle,
&gEfiDhcp4ProtocolGuid, &gEfiDhcp4ProtocolGuid,
(VOID **) &Instance->Dhcp4, (VOID **)&Instance->Dhcp4,
IpSb->Image, IpSb->Image,
IpSb->Controller, IpSb->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -1048,8 +1037,6 @@ Ip4StartAutoConfig (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The work function is to get the interface information of the communication The work function is to get the interface information of the communication
device this IP4_CONFIG2_INSTANCE manages. device this IP4_CONFIG2_INSTANCE manages.
@ -1096,7 +1083,7 @@ Ip4Config2GetIfInfo (
// Copy the fixed size part of the interface info. // Copy the fixed size part of the interface info.
// //
Item = &Instance->DataItem[Ip4Config2DataTypeInterfaceInfo]; Item = &Instance->DataItem[Ip4Config2DataTypeInterfaceInfo];
IfInfo = (EFI_IP4_CONFIG2_INTERFACE_INFO *) Data; IfInfo = (EFI_IP4_CONFIG2_INTERFACE_INFO *)Data;
CopyMem (IfInfo, Item->Data.Ptr, sizeof (EFI_IP4_CONFIG2_INTERFACE_INFO)); CopyMem (IfInfo, Item->Data.Ptr, sizeof (EFI_IP4_CONFIG2_INTERFACE_INFO));
// //
@ -1111,7 +1098,7 @@ Ip4Config2GetIfInfo (
if (IpSb->DefaultRouteTable != NULL) { if (IpSb->DefaultRouteTable != NULL) {
IfInfo->RouteTableSize = IpSb->DefaultRouteTable->TotalNum; IfInfo->RouteTableSize = IpSb->DefaultRouteTable->TotalNum;
IfInfo->RouteTable = (EFI_IP4_ROUTE_TABLE *) ((UINT8 *) Data + sizeof (EFI_IP4_CONFIG2_INTERFACE_INFO)); IfInfo->RouteTable = (EFI_IP4_ROUTE_TABLE *)((UINT8 *)Data + sizeof (EFI_IP4_CONFIG2_INTERFACE_INFO));
Ip4Config2BuildDefaultRouteTable (IpSb, IfInfo->RouteTable); Ip4Config2BuildDefaultRouteTable (IpSb, IfInfo->RouteTable);
} }
@ -1150,14 +1137,14 @@ Ip4Config2SetPolicy (
return EFI_BAD_BUFFER_SIZE; return EFI_BAD_BUFFER_SIZE;
} }
NewPolicy = *((EFI_IP4_CONFIG2_POLICY *) Data); NewPolicy = *((EFI_IP4_CONFIG2_POLICY *)Data);
if (NewPolicy >= Ip4Config2PolicyMax) { if (NewPolicy >= Ip4Config2PolicyMax) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (NewPolicy == Instance->Policy) { if (NewPolicy == Instance->Policy) {
if (NewPolicy != Ip4Config2PolicyDhcp || Instance->DhcpSuccess) { if ((NewPolicy != Ip4Config2PolicyDhcp) || Instance->DhcpSuccess) {
return EFI_ABORTED; return EFI_ABORTED;
} }
} else { } else {
@ -1169,6 +1156,7 @@ Ip4Config2SetPolicy (
if (DataItem->Data.Ptr != NULL) { if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr); FreePool (DataItem->Data.Ptr);
} }
DataItem->Data.Ptr = NULL; DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0; DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND; DataItem->Status = EFI_NOT_FOUND;
@ -1178,6 +1166,7 @@ Ip4Config2SetPolicy (
if (DataItem->Data.Ptr != NULL) { if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr); FreePool (DataItem->Data.Ptr);
} }
DataItem->Data.Ptr = NULL; DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0; DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND; DataItem->Status = EFI_NOT_FOUND;
@ -1187,6 +1176,7 @@ Ip4Config2SetPolicy (
if (DataItem->Data.Ptr != NULL) { if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr); FreePool (DataItem->Data.Ptr);
} }
DataItem->Data.Ptr = NULL; DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0; DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND; DataItem->Status = EFI_NOT_FOUND;
@ -1279,8 +1269,8 @@ Ip4Config2SetManualAddress (
DataItem = &Instance->DataItem[Ip4Config2DataTypeManualAddress]; DataItem = &Instance->DataItem[Ip4Config2DataTypeManualAddress];
if (Data != NULL && DataSize != 0) { if ((Data != NULL) && (DataSize != 0)) {
NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data); NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *)Data);
StationAddress = EFI_NTOHL (NewAddress.Address); StationAddress = EFI_NTOHL (NewAddress.Address);
SubnetMask = EFI_NTOHL (NewAddress.SubnetMask); SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
@ -1314,10 +1304,11 @@ Ip4Config2SetManualAddress (
DataItem->Status = Status; DataItem->Status = Status;
if (EFI_ERROR (DataItem->Status) && DataItem->Status != EFI_NOT_READY) { if (EFI_ERROR (DataItem->Status) && (DataItem->Status != EFI_NOT_READY)) {
if (Ptr != NULL) { if (Ptr != NULL) {
FreePool (Ptr); FreePool (Ptr);
} }
DataItem->Data.Ptr = NULL; DataItem->Data.Ptr = NULL;
} }
} else { } else {
@ -1327,6 +1318,7 @@ Ip4Config2SetManualAddress (
if (DataItem->Data.Ptr != NULL) { if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr); FreePool (DataItem->Data.Ptr);
} }
DataItem->Data.Ptr = NULL; DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0; DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND; DataItem->Status = EFI_NOT_FOUND;
@ -1370,7 +1362,7 @@ Ip4Config2SetManualAddress (
// //
// Reset the State to unstarted. // Reset the State to unstarted.
// //
if (IpSb->State == IP4_SERVICE_CONFIGED || IpSb->State == IP4_SERVICE_STARTED) { if ((IpSb->State == IP4_SERVICE_CONFIGED) || (IpSb->State == IP4_SERVICE_STARTED)) {
IpSb->State = IP4_SERVICE_UNSTARTED; IpSb->State = IP4_SERVICE_UNSTARTED;
} }
} }
@ -1455,14 +1447,15 @@ Ip4Config2SetGateway (
OneRemoved = TRUE; OneRemoved = TRUE;
} }
if (Data != NULL && DataSize != 0) { if ((Data != NULL) && (DataSize != 0)) {
NewGateway = (EFI_IPv4_ADDRESS *) Data; NewGateway = (EFI_IPv4_ADDRESS *)Data;
NewGatewayCount = DataSize / sizeof (EFI_IPv4_ADDRESS); NewGatewayCount = DataSize / sizeof (EFI_IPv4_ADDRESS);
for (Index1 = 0; Index1 < NewGatewayCount; Index1++) { for (Index1 = 0; Index1 < NewGatewayCount; Index1++) {
CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR)); CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR));
if ((IpSb->DefaultInterface->SubnetMask != 0) && if ((IpSb->DefaultInterface->SubnetMask != 0) &&
!NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->SubnetMask)) { !NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->SubnetMask))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1505,6 +1498,7 @@ Ip4Config2SetGateway (
if (DataItem->Data.Ptr != NULL) { if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr); FreePool (DataItem->Data.Ptr);
} }
DataItem->Data.Ptr = Tmp; DataItem->Data.Ptr = Tmp;
} }
@ -1519,6 +1513,7 @@ Ip4Config2SetGateway (
if (DataItem->Data.Ptr != NULL) { if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr); FreePool (DataItem->Data.Ptr);
} }
DataItem->Data.Ptr = NULL; DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0; DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND; DataItem->Status = EFI_NOT_FOUND;
@ -1572,7 +1567,7 @@ Ip4Config2SetDnsServer (
REMOVE_DATA_ATTRIB (Item->Attribute, DATA_ATTRIB_VOLATILE); REMOVE_DATA_ATTRIB (Item->Attribute, DATA_ATTRIB_VOLATILE);
} }
if (Data != NULL && DataSize != 0) { if ((Data != NULL) && (DataSize != 0)) {
Status = Ip4Config2SetDnsServerWorker (Instance, DataSize, Data); Status = Ip4Config2SetDnsServerWorker (Instance, DataSize, Data);
} else { } else {
// //
@ -1581,6 +1576,7 @@ Ip4Config2SetDnsServer (
if (Item->Data.Ptr != NULL) { if (Item->Data.Ptr != NULL) {
FreePool (Item->Data.Ptr); FreePool (Item->Data.Ptr);
} }
Item->Data.Ptr = NULL; Item->Data.Ptr = NULL;
Item->DataSize = 0; Item->DataSize = 0;
Item->Status = EFI_NOT_FOUND; Item->Status = EFI_NOT_FOUND;
@ -1615,8 +1611,6 @@ Ip4Config2InitIfInfo (
CopyMem (&IfInfo->HwAddress, &IpSb->SnpMode.CurrentAddress, IfInfo->HwAddressSize); CopyMem (&IfInfo->HwAddress, &IpSb->SnpMode.CurrentAddress, IfInfo->HwAddressSize);
} }
/** /**
Set the configuration for the EFI IPv4 network stack running on the communication Set the configuration for the EFI IPv4 network stack running on the communication
device this EFI_IP4_CONFIG2_PROTOCOL instance manages. device this EFI_IP4_CONFIG2_PROTOCOL instance manages.
@ -1678,7 +1672,7 @@ EfiIp4Config2SetData (
IP4_CONFIG2_INSTANCE *Instance; IP4_CONFIG2_INSTANCE *Instance;
IP4_SERVICE *IpSb; IP4_SERVICE *IpSb;
if ((This == NULL) || (Data == NULL && DataSize != 0) || (Data != NULL && DataSize == 0)) { if ((This == NULL) || ((Data == NULL) && (DataSize != 0)) || ((Data != NULL) && (DataSize == 0))) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1690,19 +1684,16 @@ EfiIp4Config2SetData (
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance); IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE); NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK); OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
Status = Instance->DataItem[DataType].Status; Status = Instance->DataItem[DataType].Status;
if (Status != EFI_NOT_READY) { if (Status != EFI_NOT_READY) {
if (Instance->DataItem[DataType].SetData == NULL) { if (Instance->DataItem[DataType].SetData == NULL) {
// //
// This type of data is readonly. // This type of data is readonly.
// //
Status = EFI_WRITE_PROTECTED; Status = EFI_WRITE_PROTECTED;
} else { } else {
Status = Instance->DataItem[DataType].SetData (Instance, DataSize, Data); Status = Instance->DataItem[DataType].SetData (Instance, DataSize, Data);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
@ -1798,9 +1789,7 @@ EfiIp4Config2GetData (
Status = Instance->DataItem[DataType].Status; Status = Instance->DataItem[DataType].Status;
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
if (DataItem->GetData != NULL) { if (DataItem->GetData != NULL) {
Status = DataItem->GetData (Instance, DataSize, Data); Status = DataItem->GetData (Instance, DataSize, Data);
} else if (*DataSize < Instance->DataItem[DataType].DataSize) { } else if (*DataSize < Instance->DataItem[DataType].DataSize) {
// //
@ -1809,7 +1798,6 @@ EfiIp4Config2GetData (
*DataSize = Instance->DataItem[DataType].DataSize; *DataSize = Instance->DataItem[DataType].DataSize;
Status = EFI_BUFFER_TOO_SMALL; Status = EFI_BUFFER_TOO_SMALL;
} else { } else {
*DataSize = Instance->DataItem[DataType].DataSize; *DataSize = Instance->DataItem[DataType].DataSize;
CopyMem (Data, Instance->DataItem[DataType].Data.Ptr, *DataSize); CopyMem (Data, Instance->DataItem[DataType].Data.Ptr, *DataSize);
} }
@ -1874,16 +1862,12 @@ EfiIp4Config2RegisterDataNotify (
// //
Item = NetMapFindKey (EventMap, Event); Item = NetMapFindKey (EventMap, Event);
if (Item == NULL) { if (Item == NULL) {
Status = NetMapInsertTail (EventMap, Event, NULL); Status = NetMapInsertTail (EventMap, Event, NULL);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
} }
} else { } else {
Status = EFI_ACCESS_DENIED; Status = EFI_ACCESS_DENIED;
} }
@ -1934,11 +1918,9 @@ EfiIp4Config2UnregisterDataNotify (
Item = NetMapFindKey (&Instance->DataItem[DataType].EventMap, Event); Item = NetMapFindKey (&Instance->DataItem[DataType].EventMap, Event);
if (Item != NULL) { if (Item != NULL) {
NetMapRemoveItem (&Instance->DataItem[DataType].EventMap, Item, NULL); NetMapRemoveItem (&Instance->DataItem[DataType].EventMap, Item, NULL);
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} else { } else {
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
} }
@ -1969,12 +1951,10 @@ Ip4Config2InitInstance (
UINT16 IfIndex; UINT16 IfIndex;
IP4_CONFIG2_DATA_ITEM *DataItem; IP4_CONFIG2_DATA_ITEM *DataItem;
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance); IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
Instance->Signature = IP4_CONFIG2_INSTANCE_SIGNATURE; Instance->Signature = IP4_CONFIG2_INSTANCE_SIGNATURE;
// //
// Determine the index of this interface. // Determine the index of this interface.
// //
@ -2002,7 +1982,6 @@ Ip4Config2InitInstance (
NetMapInit (&Instance->DataItem[Index].EventMap); NetMapInit (&Instance->DataItem[Index].EventMap);
} }
// //
// Initialize each data type: associate storage and set data size for the // Initialize each data type: associate storage and set data size for the
// fixed size data types, hook the SetData function, set the data attribute. // fixed size data types, hook the SetData function, set the data attribute.
@ -2060,7 +2039,6 @@ Ip4Config2InitInstance (
return Ip4Config2FormInit (Instance); return Ip4Config2FormInit (Instance);
} }
/** /**
Release an IP4_CONFIG2_INSTANCE. Release an IP4_CONFIG2_INSTANCE.
@ -2080,11 +2058,10 @@ Ip4Config2CleanInstance (
} }
if (!Instance->Configured) { if (!Instance->Configured) {
return ; return;
} }
if (Instance->Dhcp4Handle != NULL) { if (Instance->Dhcp4Handle != NULL) {
Ip4Config2DestroyDhcp4 (Instance); Ip4Config2DestroyDhcp4 (Instance);
} }
@ -2097,13 +2074,13 @@ Ip4Config2CleanInstance (
} }
for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) { for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) {
DataItem = &Instance->DataItem[Index]; DataItem = &Instance->DataItem[Index];
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED)) { if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED)) {
if (DataItem->Data.Ptr != NULL) { if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr); FreePool (DataItem->Data.Ptr);
} }
DataItem->Data.Ptr = NULL; DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0; DataItem->DataSize = 0;
} }
@ -2131,7 +2108,7 @@ Ip4AutoReconfigCallBackDpc (
{ {
IP4_SERVICE *IpSb; IP4_SERVICE *IpSb;
IpSb = (IP4_SERVICE *) Context; IpSb = (IP4_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE); NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
if (IpSb->State > IP4_SERVICE_UNSTARTED) { if (IpSb->State > IP4_SERVICE_UNSTARTED) {
@ -2142,10 +2119,9 @@ Ip4AutoReconfigCallBackDpc (
Ip4StartAutoConfig (&IpSb->Ip4Config2Instance); Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
return ; return;
} }
/** /**
Request Ip4AutoReconfigCallBackDpc as a DPC at TPL_CALLBACK. Request Ip4AutoReconfigCallBackDpc as a DPC at TPL_CALLBACK.
@ -2165,4 +2141,3 @@ Ip4AutoReconfigCallBack (
// //
QueueDpc (TPL_CALLBACK, Ip4AutoReconfigCallBackDpc, Context); QueueDpc (TPL_CALLBACK, Ip4AutoReconfigCallBackDpc, Context);
} }

View File

@ -48,7 +48,7 @@ GetSubnetMaskPrefixLength (
Len++; Len++;
} }
return (UINT8) (32 - Len); return (UINT8)(32 - Len);
} }
/** /**
@ -73,7 +73,6 @@ Ip4Config2StrToIp (
Index = 0; Index = 0;
while (*Str != L'\0') { while (*Str != L'\0') {
if (Index > 3) { if (Index > 3) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -88,7 +87,7 @@ Ip4Config2StrToIp (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Ip->Addr[Index] = (UINT8) Number; Ip->Addr[Index] = (UINT8)Number;
if ((*Str != L'\0') && (*Str != L'.')) { if ((*Str != L'\0') && (*Str != L'.')) {
// //
@ -178,7 +177,7 @@ Ip4Config2StrToIpList (
// //
// Allocate buffer for IpList. // Allocate buffer for IpList.
// //
*PtrIpList = AllocateZeroPool(*IpCount * sizeof(EFI_IPv4_ADDRESS)); *PtrIpList = AllocateZeroPool (*IpCount * sizeof (EFI_IPv4_ADDRESS));
if (*PtrIpList == NULL) { if (*PtrIpList == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -189,21 +188,21 @@ Ip4Config2StrToIpList (
Index = 0; Index = 0;
while (*(Str + Index) != L'\0') { while (*(Str + Index) != L'\0') {
if (*(Str + Index) == L' ') { if (*(Str + Index) == L' ') {
if(!SpaceTag) { if (!SpaceTag) {
StrTemp = AllocateZeroPool((EndIndex - BeginIndex + 1) * sizeof(CHAR16)); StrTemp = AllocateZeroPool ((EndIndex - BeginIndex + 1) * sizeof (CHAR16));
if (StrTemp == NULL) { if (StrTemp == NULL) {
FreePool(*PtrIpList); FreePool (*PtrIpList);
*PtrIpList = NULL; *PtrIpList = NULL;
*IpCount = 0; *IpCount = 0;
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) * sizeof(CHAR16)); CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) * sizeof (CHAR16));
*(StrTemp + (EndIndex - BeginIndex)) = L'\0'; *(StrTemp + (EndIndex - BeginIndex)) = L'\0';
if (Ip4Config2StrToIp (StrTemp, &((*PtrIpList)[IpIndex])) != EFI_SUCCESS) { if (Ip4Config2StrToIp (StrTemp, &((*PtrIpList)[IpIndex])) != EFI_SUCCESS) {
FreePool(StrTemp); FreePool (StrTemp);
FreePool(*PtrIpList); FreePool (*PtrIpList);
*PtrIpList = NULL; *PtrIpList = NULL;
*IpCount = 0; *IpCount = 0;
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -212,7 +211,7 @@ Ip4Config2StrToIpList (
BeginIndex = EndIndex; BeginIndex = EndIndex;
IpIndex++; IpIndex++;
FreePool(StrTemp); FreePool (StrTemp);
} }
BeginIndex++; BeginIndex++;
@ -227,26 +226,26 @@ Ip4Config2StrToIpList (
if (*(Str + Index) == L'\0') { if (*(Str + Index) == L'\0') {
if (!SpaceTag) { if (!SpaceTag) {
StrTemp = AllocateZeroPool((EndIndex - BeginIndex + 1) * sizeof(CHAR16)); StrTemp = AllocateZeroPool ((EndIndex - BeginIndex + 1) * sizeof (CHAR16));
if (StrTemp == NULL) { if (StrTemp == NULL) {
FreePool(*PtrIpList); FreePool (*PtrIpList);
*PtrIpList = NULL; *PtrIpList = NULL;
*IpCount = 0; *IpCount = 0;
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) * sizeof(CHAR16)); CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) * sizeof (CHAR16));
*(StrTemp + (EndIndex - BeginIndex)) = L'\0'; *(StrTemp + (EndIndex - BeginIndex)) = L'\0';
if (Ip4Config2StrToIp (StrTemp, &((*PtrIpList)[IpIndex])) != EFI_SUCCESS) { if (Ip4Config2StrToIp (StrTemp, &((*PtrIpList)[IpIndex])) != EFI_SUCCESS) {
FreePool(StrTemp); FreePool (StrTemp);
FreePool(*PtrIpList); FreePool (*PtrIpList);
*PtrIpList = NULL; *PtrIpList = NULL;
*IpCount = 0; *IpCount = 0;
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
FreePool(StrTemp); FreePool (StrTemp);
} }
} }
} }
@ -278,7 +277,6 @@ Ip4Config2IpToStr (
); );
} }
/** /**
Convert the IPv4 address list into string consists of several decimal Convert the IPv4 address list into string consists of several decimal
dotted IPv4 addresses separated by space. dotted IPv4 addresses separated by space.
@ -311,10 +309,10 @@ Ip4Config2IpListToStr (
TempStr = NULL; TempStr = NULL;
TempIp = NULL; TempIp = NULL;
for (Index = 0; Index < IpCount; Index ++) { for (Index = 0; Index < IpCount; Index++) {
TempIp = Ip + Index; TempIp = Ip + Index;
if (TempStr == NULL) { if (TempStr == NULL) {
TempStr = AllocateZeroPool(2 * IP4_STR_MAX_SIZE); TempStr = AllocateZeroPool (2 * IP4_STR_MAX_SIZE);
if (TempStr == NULL) { if (TempStr == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -330,13 +328,14 @@ Ip4Config2IpListToStr (
TempIp->Addr[3] TempIp->Addr[3]
); );
for (TemIndex = 0; TemIndex < IP4_STR_MAX_SIZE; TemIndex ++) { for (TemIndex = 0; TemIndex < IP4_STR_MAX_SIZE; TemIndex++) {
if (*(TempStr + TemIndex) == L'\0') { if (*(TempStr + TemIndex) == L'\0') {
if (Index == IpCount - 1) { if (Index == IpCount - 1) {
Str[StrIndex++] = L'\0'; Str[StrIndex++] = L'\0';
} else { } else {
Str[StrIndex++] = L' '; Str[StrIndex++] = L' ';
} }
break; break;
} else { } else {
Str[StrIndex++] = *(TempStr + TemIndex); Str[StrIndex++] = *(TempStr + TemIndex);
@ -345,7 +344,7 @@ Ip4Config2IpListToStr (
} }
if (TempStr != NULL) { if (TempStr != NULL) {
FreePool(TempStr); FreePool (TempStr);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -365,7 +364,7 @@ Ip4Config2ManualAddressNotify (
IN VOID *Context IN VOID *Context
) )
{ {
*((BOOLEAN *) Context) = TRUE; *((BOOLEAN *)Context) = TRUE;
} }
/** /**
@ -497,10 +496,10 @@ Ip4Config2ConvertConfigNvDataToIfrNvData (
goto Exit; goto Exit;
} }
DnsCount = (UINT32) (DnsSize / sizeof (EFI_IPv4_ADDRESS)); DnsCount = (UINT32)(DnsSize / sizeof (EFI_IPv4_ADDRESS));
if (DnsSize > 0) { if (DnsSize > 0) {
DnsAddress = AllocateZeroPool(DnsSize); DnsAddress = AllocateZeroPool (DnsSize);
if (DnsAddress == NULL) { if (DnsAddress == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto Exit; goto Exit;
@ -525,11 +524,11 @@ Ip4Config2ConvertConfigNvDataToIfrNvData (
Exit: Exit:
if (DnsAddress != NULL) { if (DnsAddress != NULL) {
FreePool(DnsAddress); FreePool (DnsAddress);
} }
if (Ip4Info != NULL) { if (Ip4Info != NULL) {
FreePool(Ip4Info); FreePool (Ip4Info);
} }
return Status; return Status;
@ -582,9 +581,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
TimeoutEvent = NULL; TimeoutEvent = NULL;
SetAddressEvent = NULL; SetAddressEvent = NULL;
if ((Instance == NULL) || (IfrFormNvData == NULL)) {
if (Instance == NULL || IfrFormNvData == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -601,7 +598,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
sizeof (EFI_IP4_CONFIG2_POLICY), sizeof (EFI_IP4_CONFIG2_POLICY),
&Ip4NvData->Policy &Ip4NvData->Policy
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
} else { } else {
@ -618,26 +615,28 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4); Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);
if (EFI_ERROR (Status) || if (EFI_ERROR (Status) ||
(SubnetMask.Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) || ((SubnetMask.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) ||
!Ip4StationAddressValid (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) { !Ip4StationAddressValid (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0])))
{
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL); CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4); Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);
if (EFI_ERROR (Status) || if (EFI_ERROR (Status) ||
(Gateway.Addr[0] != 0 && SubnetMask.Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0])))) { ((Gateway.Addr[0] != 0) && (SubnetMask.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0]))))
{
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL); CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount); Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount);
if (!EFI_ERROR (Status) && DnsCount > 0) { if (!EFI_ERROR (Status) && (DnsCount > 0)) {
for (Index = 0; Index < DnsCount; Index ++) { for (Index = 0; Index < DnsCount; Index++) {
CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR)); CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));
if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) { if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL); CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);
FreePool(DnsAddress); FreePool (DnsAddress);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
@ -648,37 +647,43 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
} }
if (Ip4NvData->ManualAddress != NULL) { if (Ip4NvData->ManualAddress != NULL) {
FreePool(Ip4NvData->ManualAddress); FreePool (Ip4NvData->ManualAddress);
} }
Ip4NvData->ManualAddressCount = 1; Ip4NvData->ManualAddressCount = 1;
Ip4NvData->ManualAddress = AllocateZeroPool(sizeof(EFI_IP4_CONFIG2_MANUAL_ADDRESS)); Ip4NvData->ManualAddress = AllocateZeroPool (sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS));
if (Ip4NvData->ManualAddress == NULL) { if (Ip4NvData->ManualAddress == NULL) {
if (DnsAddress != NULL) { if (DnsAddress != NULL) {
FreePool(DnsAddress); FreePool (DnsAddress);
} }
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem(&Ip4NvData->ManualAddress->Address, &StationAddress.v4, sizeof(EFI_IPv4_ADDRESS));
CopyMem(&Ip4NvData->ManualAddress->SubnetMask, &SubnetMask.v4, sizeof(EFI_IPv4_ADDRESS)); CopyMem (&Ip4NvData->ManualAddress->Address, &StationAddress.v4, sizeof (EFI_IPv4_ADDRESS));
CopyMem (&Ip4NvData->ManualAddress->SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));
if (Ip4NvData->GatewayAddress != NULL) { if (Ip4NvData->GatewayAddress != NULL) {
FreePool(Ip4NvData->GatewayAddress); FreePool (Ip4NvData->GatewayAddress);
} }
Ip4NvData->GatewayAddressCount = 1; Ip4NvData->GatewayAddressCount = 1;
Ip4NvData->GatewayAddress = AllocateZeroPool(sizeof(EFI_IPv4_ADDRESS)); Ip4NvData->GatewayAddress = AllocateZeroPool (sizeof (EFI_IPv4_ADDRESS));
if (Ip4NvData->GatewayAddress == NULL) { if (Ip4NvData->GatewayAddress == NULL) {
if (DnsAddress != NULL) { if (DnsAddress != NULL) {
FreePool(DnsAddress); FreePool (DnsAddress);
} }
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem(Ip4NvData->GatewayAddress, &Gateway.v4, sizeof(EFI_IPv4_ADDRESS));
CopyMem (Ip4NvData->GatewayAddress, &Gateway.v4, sizeof (EFI_IPv4_ADDRESS));
if (Ip4NvData->DnsAddress != NULL) { if (Ip4NvData->DnsAddress != NULL) {
FreePool(Ip4NvData->DnsAddress); FreePool (Ip4NvData->DnsAddress);
} }
Ip4NvData->DnsAddressCount = (UINT32) DnsCount;
Ip4NvData->DnsAddressCount = (UINT32)DnsCount;
Ip4NvData->DnsAddress = DnsAddress; Ip4NvData->DnsAddress = DnsAddress;
// //
@ -690,7 +695,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
sizeof (EFI_IP4_CONFIG2_POLICY), sizeof (EFI_IP4_CONFIG2_POLICY),
&Ip4NvData->Policy &Ip4NvData->Policy
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -738,7 +743,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
Ip4Cfg2, Ip4Cfg2,
Ip4Config2DataTypeManualAddress, Ip4Config2DataTypeManualAddress,
DataSize, DataSize,
(VOID *) Ip4NvData->ManualAddress (VOID *)Ip4NvData->ManualAddress
); );
if (Status == EFI_NOT_READY) { if (Status == EFI_NOT_READY) {
@ -777,7 +782,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
// //
// Set DNS addresses. // Set DNS addresses.
// //
if (Ip4NvData->DnsAddressCount > 0 && Ip4NvData->DnsAddress != NULL) { if ((Ip4NvData->DnsAddressCount > 0) && (Ip4NvData->DnsAddress != NULL)) {
DataSize = Ip4NvData->DnsAddressCount * sizeof (EFI_IPv4_ADDRESS); DataSize = Ip4NvData->DnsAddressCount * sizeof (EFI_IPv4_ADDRESS);
Status = Ip4Cfg2->SetData ( Status = Ip4Cfg2->SetData (
Ip4Cfg2, Ip4Cfg2,
@ -880,7 +885,7 @@ Ip4FormExtractConfig (
UINTN Size; UINTN Size;
UINTN BufferSize; UINTN BufferSize;
if (Progress == NULL || Results == NULL) { if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -891,8 +896,8 @@ Ip4FormExtractConfig (
Size = 0; Size = 0;
AllocatedRequest = FALSE; AllocatedRequest = FALSE;
ConfigRequest = Request; ConfigRequest = Request;
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This); Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private); Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
BufferSize = sizeof (IP4_CONFIG2_IFR_NVDATA); BufferSize = sizeof (IP4_CONFIG2_IFR_NVDATA);
*Progress = Request; *Progress = Request;
@ -920,6 +925,7 @@ Ip4FormExtractConfig (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto Failure; goto Failure;
} }
AllocatedRequest = TRUE; AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
@ -932,7 +938,7 @@ Ip4FormExtractConfig (
Status = gHiiConfigRouting->BlockToConfig ( Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting, gHiiConfigRouting,
ConfigRequest, ConfigRequest,
(UINT8 *) IfrFormNvData, (UINT8 *)IfrFormNvData,
BufferSize, BufferSize,
&FormResult, &FormResult,
Progress Progress
@ -953,7 +959,7 @@ Ip4FormExtractConfig (
} }
} }
if (Request == NULL || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) { if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
*Results = FormResult; *Results = FormResult;
} else { } else {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
@ -1022,14 +1028,14 @@ Ip4FormRouteConfig (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
IfrFormNvData = NULL; IfrFormNvData = NULL;
if (Configuration == NULL || Progress == NULL) { if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
*Progress = Configuration; *Progress = Configuration;
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This); Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private); Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
// //
// Check Routing data in <ConfigHdr>. // Check Routing data in <ConfigHdr>.
@ -1048,7 +1054,7 @@ Ip4FormRouteConfig (
Status = gHiiConfigRouting->ConfigToBlock ( Status = gHiiConfigRouting->ConfigToBlock (
gHiiConfigRouting, gHiiConfigRouting,
Configuration, Configuration,
(UINT8 *) IfrFormNvData, (UINT8 *)IfrFormNvData,
&BufferSize, &BufferSize,
Progress Progress
); );
@ -1059,7 +1065,7 @@ Ip4FormRouteConfig (
Status = gHiiConfigRouting->ConfigToBlock ( Status = gHiiConfigRouting->ConfigToBlock (
gHiiConfigRouting, gHiiConfigRouting,
Configuration, Configuration,
(UINT8 *) IfrFormNvData, (UINT8 *)IfrFormNvData,
&BufferSize, &BufferSize,
Progress Progress
); );
@ -1073,7 +1079,6 @@ Ip4FormRouteConfig (
} }
return Status; return Status;
} }
/** /**
@ -1133,8 +1138,8 @@ Ip4FormCallback (
DnsAddress = NULL; DnsAddress = NULL;
if (Action == EFI_BROWSER_ACTION_CHANGED) { if (Action == EFI_BROWSER_ACTION_CHANGED) {
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This); Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private); Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG2_IFR_NVDATA)); IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG2_IFR_NVDATA));
if (IfrFormNvData == NULL) { if (IfrFormNvData == NULL) {
@ -1144,7 +1149,7 @@ Ip4FormCallback (
// //
// Retrieve uncommitted data from Browser // Retrieve uncommitted data from Browser
// //
if (!HiiGetBrowserData (&gIp4Config2NvDataGuid, mIp4Config2StorageName, sizeof (IP4_CONFIG2_IFR_NVDATA), (UINT8 *) IfrFormNvData)) { if (!HiiGetBrowserData (&gIp4Config2NvDataGuid, mIp4Config2StorageName, sizeof (IP4_CONFIG2_IFR_NVDATA), (UINT8 *)IfrFormNvData)) {
FreePool (IfrFormNvData); FreePool (IfrFormNvData);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -1158,6 +1163,7 @@ Ip4FormCallback (
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL); CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
} }
break; break;
case KEY_SUBNET_MASK: case KEY_SUBNET_MASK:
@ -1166,20 +1172,22 @@ Ip4FormCallback (
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL); CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
} }
break; break;
case KEY_GATE_WAY: case KEY_GATE_WAY:
Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4); Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);
if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST(NTOHL(Gateway.Addr[0]))) { if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST (NTOHL (Gateway.Addr[0]))) {
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL); CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
} }
break; break;
case KEY_DNS: case KEY_DNS:
Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount); Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount);
if (!EFI_ERROR (Status) && DnsCount > 0) { if (!EFI_ERROR (Status) && (DnsCount > 0)) {
for (Index = 0; Index < DnsCount; Index ++) { for (Index = 0; Index < DnsCount; Index++) {
CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR)); CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));
if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) { if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL); CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);
@ -1193,9 +1201,10 @@ Ip4FormCallback (
} }
} }
if(DnsAddress != NULL) { if (DnsAddress != NULL) {
FreePool(DnsAddress); FreePool (DnsAddress);
} }
break; break;
case KEY_SAVE_CHANGES: case KEY_SAVE_CHANGES:
@ -1255,7 +1264,7 @@ Ip4Config2FormInit (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
IpSb->Controller, IpSb->Controller,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
(VOID **) &ParentDevicePath (VOID **)&ParentDevicePath
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -1275,7 +1284,7 @@ Ip4Config2FormInit (
SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH)); SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode ( CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
ParentDevicePath, ParentDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode (EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
); );
if (CallbackInfo->HiiVendorDevicePath == NULL) { if (CallbackInfo->HiiVendorDevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -1306,7 +1315,7 @@ Ip4Config2FormInit (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
IpSb->Controller, IpSb->Controller,
&gEfiManagedNetworkServiceBindingProtocolGuid, &gEfiManagedNetworkServiceBindingProtocolGuid,
(VOID **) &MnpSb, (VOID **)&MnpSb,
IpSb->Image, IpSb->Image,
CallbackInfo->ChildHandle, CallbackInfo->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -1426,16 +1435,16 @@ Ip4Config2FormUnload (
Ip4NvData = &Instance->Ip4NvData; Ip4NvData = &Instance->Ip4NvData;
if(Ip4NvData->ManualAddress != NULL) { if (Ip4NvData->ManualAddress != NULL) {
FreePool(Ip4NvData->ManualAddress); FreePool (Ip4NvData->ManualAddress);
} }
if(Ip4NvData->GatewayAddress != NULL) { if (Ip4NvData->GatewayAddress != NULL) {
FreePool(Ip4NvData->GatewayAddress); FreePool (Ip4NvData->GatewayAddress);
} }
if(Ip4NvData->DnsAddress != NULL) { if (Ip4NvData->DnsAddress != NULL) {
FreePool(Ip4NvData->DnsAddress); FreePool (Ip4NvData->DnsAddress);
} }
Ip4NvData->ManualAddressCount = 0; Ip4NvData->ManualAddressCount = 0;

View File

@ -36,12 +36,13 @@ IpSec2InstalledCallback (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
// //
// Test if protocol was even found. // Test if protocol was even found.
// Notification function will be called at least once. // Notification function will be called at least once.
// //
Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **)&mIpSec); Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **)&mIpSec);
if (Status == EFI_SUCCESS && mIpSec != NULL) { if ((Status == EFI_SUCCESS) && (mIpSec != NULL)) {
// //
// Close the event so it does not get called again. // Close the event so it does not get called again.
// //
@ -114,9 +115,9 @@ Ip4DriverEntryPoint (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
Ip4DriverBindingSupported ( Ip4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL * This, IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -170,7 +171,6 @@ Ip4CleanService (
IN IP4_SERVICE *IpSb IN IP4_SERVICE *IpSb
); );
/** /**
Create a new IP4 driver service binding private instance. Create a new IP4 driver service binding private instance.
@ -316,7 +316,7 @@ Ip4CreateService (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
IpSb->MnpChildHandle, IpSb->MnpChildHandle,
&gEfiManagedNetworkProtocolGuid, &gEfiManagedNetworkProtocolGuid,
(VOID **) &IpSb->Mnp, (VOID **)&IpSb->Mnp,
ImageHandle, ImageHandle,
Controller, Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -375,6 +375,7 @@ Ip4CreateService (
// //
IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN; IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN;
} }
IpSb->OldMaxPacketSize = IpSb->MaxPacketSize; IpSb->OldMaxPacketSize = IpSb->MaxPacketSize;
*Service = IpSb; *Service = IpSb;
@ -387,7 +388,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Clean up a IP4 service binding instance. It will release all Clean up a IP4 service binding instance. It will release all
the resource allocated by the instance. The instance may be the resource allocated by the instance. The instance may be
@ -502,14 +502,14 @@ Ip4DestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren; UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer; EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) { if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE); IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);
ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) { if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -617,11 +617,11 @@ Ip4DriverBindingStart (
DataItem->DataSize, DataItem->DataSize,
DataItem->Data.Ptr DataItem->Data.Ptr
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR (Status)) {
goto UNINSTALL_PROTOCOL; goto UNINSTALL_PROTOCOL;
} }
if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) { if ((Index == Ip4Config2DataTypePolicy) && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) {
break; break;
} }
} }
@ -634,7 +634,7 @@ Ip4DriverBindingStart (
// //
Status = Ip4ReceiveFrame (IpSb->DefaultInterface, NULL, Ip4AccpetFrame, IpSb); Status = Ip4ReceiveFrame (IpSb->DefaultInterface, NULL, Ip4AccpetFrame, IpSb);
if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
goto UNINSTALL_PROTOCOL; goto UNINSTALL_PROTOCOL;
} }
@ -673,7 +673,6 @@ FREE_SERVICE:
return Status; return Status;
} }
/** /**
Stop this driver on ControllerHandle. This service is called by the Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to EFI boot service DisconnectController(). In order to
@ -731,7 +730,7 @@ Ip4DriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiIp4ServiceBindingProtocolGuid, &gEfiIp4ServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
NicHandle, NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -758,7 +757,6 @@ Ip4DriverBindingStop (
NULL NULL
); );
} else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) { } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {
// //
// The ARP protocol for the default interface is being uninstalled and all // The ARP protocol for the default interface is being uninstalled and all
// its IP child handles should have been destroyed before. So, release the // its IP child handles should have been destroyed before. So, release the
@ -772,10 +770,11 @@ Ip4DriverBindingStop (
if (IpIf == NULL) { if (IpIf == NULL) {
goto ON_ERROR; goto ON_ERROR;
} }
RouteTable = Ip4CreateRouteTable (); RouteTable = Ip4CreateRouteTable ();
if (RouteTable == NULL) { if (RouteTable == NULL) {
Ip4FreeInterface (IpIf, NULL); Ip4FreeInterface (IpIf, NULL);
goto ON_ERROR;; goto ON_ERROR;
} }
IpSb->DefaultInterface = IpIf; IpSb->DefaultInterface = IpIf;
@ -784,7 +783,6 @@ Ip4DriverBindingStop (
Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb); Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
IpSb->State = IP4_SERVICE_UNSTARTED; IpSb->State = IP4_SERVICE_UNSTARTED;
} else if (IsListEmpty (&IpSb->Children)) { } else if (IsListEmpty (&IpSb->Children)) {
State = IpSb->State; State = IpSb->State;
// //
@ -809,6 +807,7 @@ Ip4DriverBindingStop (
FreeUnicodeStringTable (gIp4ControllerNameTable); FreeUnicodeStringTable (gIp4ControllerNameTable);
gIp4ControllerNameTable = NULL; gIp4ControllerNameTable = NULL;
} }
FreePool (IpSb); FreePool (IpSb);
} }
@ -816,7 +815,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Creates a child handle and installs a protocol. Creates a child handle and installs a protocol.
@ -884,7 +882,7 @@ Ip4ServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
IpSb->MnpChildHandle, IpSb->MnpChildHandle,
&gEfiManagedNetworkProtocolGuid, &gEfiManagedNetworkProtocolGuid,
(VOID **) &Mnp, (VOID **)&Mnp,
gIp4DriverBinding.DriverBindingHandle, gIp4DriverBinding.DriverBindingHandle,
IpInstance->Handle, IpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -913,7 +911,6 @@ Ip4ServiceBindingCreateChild (
ON_ERROR: ON_ERROR:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Ip4CleanProtocol (IpInstance); Ip4CleanProtocol (IpInstance);
FreePool (IpInstance); FreePool (IpInstance);
@ -922,7 +919,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Destroys a child handle with a protocol installed on it. Destroys a child handle with a protocol installed on it.
@ -966,7 +962,7 @@ Ip4ServiceBindingDestroyChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiIp4ProtocolGuid, &gEfiIp4ProtocolGuid,
(VOID **) &Ip4, (VOID **)&Ip4,
gIp4DriverBinding.DriverBindingHandle, gIp4DriverBinding.DriverBindingHandle,
ChildHandle, ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -1007,7 +1003,7 @@ Ip4ServiceBindingDestroyChild (
ChildHandle ChildHandle
); );
if (IpInstance->Interface != NULL && IpInstance->Interface->Arp != NULL) { if ((IpInstance->Interface != NULL) && (IpInstance->Interface->Arp != NULL)) {
gBS->CloseProtocol ( gBS->CloseProtocol (
IpInstance->Interface->ArpHandle, IpInstance->Interface->ArpHandle,
&gEfiArpProtocolGuid, &gEfiArpProtocolGuid,

View File

@ -24,6 +24,7 @@ typedef struct {
// //
// Function prototype for the driver's entry point // Function prototype for the driver's entry point
// //
/** /**
This is the declaration of an EFI image entry point. This entry point is This is the declaration of an EFI image entry point. This entry point is
the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
@ -49,6 +50,7 @@ Ip4DriverEntryPoint (
// //
// Function prototypes for the Driver Binding Protocol // Function prototypes for the Driver Binding Protocol
// //
/** /**
Test to see if this driver supports ControllerHandle. This service Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In is called by the EFI boot service ConnectController(). In
@ -70,9 +72,9 @@ Ip4DriverEntryPoint (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
Ip4DriverBindingSupported ( Ip4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL * This, IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
); );
/** /**
@ -96,9 +98,9 @@ Ip4DriverBindingSupported (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
Ip4DriverBindingStart ( Ip4DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL * This, IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
); );
/** /**
@ -131,6 +133,7 @@ Ip4DriverBindingStop (
// //
// Function prototypes for the ServiceBinding Protocol // Function prototypes for the ServiceBinding Protocol
// //
/** /**
Creates a child handle and installs a protocol. Creates a child handle and installs a protocol.
@ -181,4 +184,5 @@ Ip4ServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle IN EFI_HANDLE ChildHandle
); );
#endif #endif

View File

@ -8,61 +8,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Ip4Impl.h" #include "Ip4Impl.h"
IP4_ICMP_CLASS IP4_ICMP_CLASS
mIcmpClass[] = { mIcmpClass[] = {
{ICMP_ECHO_REPLY, ICMP_QUERY_MESSAGE }, { ICMP_ECHO_REPLY, ICMP_QUERY_MESSAGE },
{1, ICMP_INVALID_MESSAGE}, { 1, ICMP_INVALID_MESSAGE },
{2, ICMP_INVALID_MESSAGE}, { 2, ICMP_INVALID_MESSAGE },
{ICMP_DEST_UNREACHABLE, ICMP_ERROR_MESSAGE }, { ICMP_DEST_UNREACHABLE, ICMP_ERROR_MESSAGE },
{ICMP_SOURCE_QUENCH, ICMP_ERROR_MESSAGE }, { ICMP_SOURCE_QUENCH, ICMP_ERROR_MESSAGE },
{ICMP_REDIRECT, ICMP_ERROR_MESSAGE }, { ICMP_REDIRECT, ICMP_ERROR_MESSAGE },
{6, ICMP_INVALID_MESSAGE}, { 6, ICMP_INVALID_MESSAGE },
{7, ICMP_INVALID_MESSAGE}, { 7, ICMP_INVALID_MESSAGE },
{ICMP_ECHO_REQUEST, ICMP_QUERY_MESSAGE }, { ICMP_ECHO_REQUEST, ICMP_QUERY_MESSAGE },
{9, ICMP_INVALID_MESSAGE}, { 9, ICMP_INVALID_MESSAGE },
{10, ICMP_INVALID_MESSAGE}, { 10, ICMP_INVALID_MESSAGE },
{ICMP_TIME_EXCEEDED, ICMP_ERROR_MESSAGE }, { ICMP_TIME_EXCEEDED, ICMP_ERROR_MESSAGE },
{ICMP_PARAMETER_PROBLEM, ICMP_ERROR_MESSAGE }, { ICMP_PARAMETER_PROBLEM, ICMP_ERROR_MESSAGE },
{ICMP_TIMESTAMP , ICMP_QUERY_MESSAGE }, { ICMP_TIMESTAMP, ICMP_QUERY_MESSAGE },
{14, ICMP_INVALID_MESSAGE}, { 14, ICMP_INVALID_MESSAGE },
{ICMP_INFO_REQUEST , ICMP_QUERY_MESSAGE }, { ICMP_INFO_REQUEST, ICMP_QUERY_MESSAGE },
{ICMP_INFO_REPLY , ICMP_QUERY_MESSAGE }, { ICMP_INFO_REPLY, ICMP_QUERY_MESSAGE },
}; };
EFI_IP4_ICMP_TYPE EFI_IP4_ICMP_TYPE
mIp4SupportedIcmp[23] = { mIp4SupportedIcmp[23] = {
{ICMP_ECHO_REPLY, ICMP_DEFAULT_CODE }, { ICMP_ECHO_REPLY, ICMP_DEFAULT_CODE },
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE }, { ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE },
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE }, { ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE },
{ICMP_DEST_UNREACHABLE, ICMP_PROTO_UNREACHABLE }, { ICMP_DEST_UNREACHABLE, ICMP_PROTO_UNREACHABLE },
{ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACHABLE }, { ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACHABLE },
{ICMP_DEST_UNREACHABLE, ICMP_FRAGMENT_FAILED }, { ICMP_DEST_UNREACHABLE, ICMP_FRAGMENT_FAILED },
{ICMP_DEST_UNREACHABLE, ICMP_SOURCEROUTE_FAILED }, { ICMP_DEST_UNREACHABLE, ICMP_SOURCEROUTE_FAILED },
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNKNOWN }, { ICMP_DEST_UNREACHABLE, ICMP_NET_UNKNOWN },
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNKNOWN }, { ICMP_DEST_UNREACHABLE, ICMP_HOST_UNKNOWN },
{ICMP_DEST_UNREACHABLE, ICMP_SOURCE_ISOLATED }, { ICMP_DEST_UNREACHABLE, ICMP_SOURCE_ISOLATED },
{ICMP_DEST_UNREACHABLE, ICMP_NET_PROHIBITED }, { ICMP_DEST_UNREACHABLE, ICMP_NET_PROHIBITED },
{ICMP_DEST_UNREACHABLE, ICMP_HOST_PROHIBITED }, { ICMP_DEST_UNREACHABLE, ICMP_HOST_PROHIBITED },
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE_TOS }, { ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE_TOS },
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE_TOS}, { ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE_TOS },
{ICMP_SOURCE_QUENCH, ICMP_DEFAULT_CODE }, { ICMP_SOURCE_QUENCH, ICMP_DEFAULT_CODE },
{ICMP_REDIRECT, ICMP_NET_REDIRECT }, { ICMP_REDIRECT, ICMP_NET_REDIRECT },
{ICMP_REDIRECT, ICMP_HOST_REDIRECT }, { ICMP_REDIRECT, ICMP_HOST_REDIRECT },
{ICMP_REDIRECT, ICMP_NET_TOS_REDIRECT }, { ICMP_REDIRECT, ICMP_NET_TOS_REDIRECT },
{ICMP_REDIRECT, ICMP_HOST_TOS_REDIRECT }, { ICMP_REDIRECT, ICMP_HOST_TOS_REDIRECT },
{ICMP_ECHO_REQUEST, ICMP_DEFAULT_CODE }, { ICMP_ECHO_REQUEST, ICMP_DEFAULT_CODE },
{ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_IN_TRANSIT }, { ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_IN_TRANSIT },
{ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_REASSEMBLE }, { ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_REASSEMBLE },
{ICMP_PARAMETER_PROBLEM, ICMP_DEFAULT_CODE }, { ICMP_PARAMETER_PROBLEM, ICMP_DEFAULT_CODE },
}; };
/** /**
Process the ICMP redirect. Find the instance then update Process the ICMP redirect. Find the instance then update
its route cache. its route cache.
@ -146,7 +144,6 @@ Ip4ProcessIcmpRedirect (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Process the ICMP error packet. If it is an ICMP redirect packet, Process the ICMP error packet. If it is an ICMP redirect packet,
update call Ip4ProcessIcmpRedirect to update the IP instance's update call Ip4ProcessIcmpRedirect to update the IP instance's
@ -176,7 +173,7 @@ Ip4ProcessIcmpError (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp); NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
// //
// If it is an ICMP redirect error, update the route cache // If it is an ICMP redirect error, update the route cache
@ -190,7 +187,6 @@ Ip4ProcessIcmpError (
return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0); return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
} }
/** /**
Replay an ICMP echo request. Replay an ICMP echo request.
@ -233,11 +229,11 @@ Ip4IcmpReplyEcho (
// use specific destination. See RFC1122. SRR/RR option // use specific destination. See RFC1122. SRR/RR option
// update is omitted. // update is omitted.
// //
Icmp = (IP4_ICMP_QUERY_HEAD *) NetbufGetByte (Data, 0, NULL); Icmp = (IP4_ICMP_QUERY_HEAD *)NetbufGetByte (Data, 0, NULL);
ASSERT (Icmp != NULL); ASSERT (Icmp != NULL);
Icmp->Head.Type = ICMP_ECHO_REPLY; Icmp->Head.Type = ICMP_ECHO_REPLY;
Icmp->Head.Checksum = 0; Icmp->Head.Checksum = 0;
Icmp->Head.Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Icmp, Data->TotalSize)); Icmp->Head.Checksum = (UINT16)(~NetblockChecksum ((UINT8 *)Icmp, Data->TotalSize));
ReplyHead.Tos = 0; ReplyHead.Tos = 0;
ReplyHead.Fragment = 0; ReplyHead.Fragment = 0;
@ -270,7 +266,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Process the ICMP query message. If it is an ICMP echo Process the ICMP query message. If it is an ICMP echo
request, answer it. Otherwise deliver it to upper layer. request, answer it. Otherwise deliver it to upper layer.
@ -299,7 +294,7 @@ Ip4ProcessIcmpQuery (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp); NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
if (Icmp.Head.Type == ICMP_ECHO_REQUEST) { if (Icmp.Head.Type == ICMP_ECHO_REQUEST) {
return Ip4IcmpReplyEcho (IpSb, Head, Packet); return Ip4IcmpReplyEcho (IpSb, Head, Packet);
@ -308,7 +303,6 @@ Ip4ProcessIcmpQuery (
return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0); return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
} }
/** /**
Handle the ICMP packet. First validate the message format, Handle the ICMP packet. First validate the message format,
then according to the message types, process it as query or then according to the message types, process it as query or
@ -338,23 +332,21 @@ Ip4IcmpHandle (
goto DROP; goto DROP;
} }
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp); NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
if (Icmp.Type > ICMP_TYPE_MAX) { if (Icmp.Type > ICMP_TYPE_MAX) {
goto DROP; goto DROP;
} }
Checksum = (UINT16) (~NetbufChecksum (Packet)); Checksum = (UINT16)(~NetbufChecksum (Packet));
if ((Icmp.Checksum != 0) && (Checksum != 0)) { if ((Icmp.Checksum != 0) && (Checksum != 0)) {
goto DROP; goto DROP;
} }
if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_ERROR_MESSAGE) { if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_ERROR_MESSAGE) {
return Ip4ProcessIcmpError (IpSb, Head, Packet); return Ip4ProcessIcmpError (IpSb, Head, Packet);
} else if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_QUERY_MESSAGE) { } else if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_QUERY_MESSAGE) {
return Ip4ProcessIcmpQuery (IpSb, Head, Packet); return Ip4ProcessIcmpQuery (IpSb, Head, Packet);
} }
DROP: DROP:

View File

@ -9,9 +9,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __EFI_IP4_ICMP_H__ #ifndef __EFI_IP4_ICMP_H__
#define __EFI_IP4_ICMP_H__ #define __EFI_IP4_ICMP_H__
// //
// ICMP type definitions // ICMP type definitions
// //
#define ICMP_ECHO_REPLY 0 #define ICMP_ECHO_REPLY 0
#define ICMP_DEST_UNREACHABLE 3 #define ICMP_DEST_UNREACHABLE 3
#define ICMP_SOURCE_QUENCH 4 #define ICMP_SOURCE_QUENCH 4
@ -26,9 +26,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define ICMP_DEFAULT_CODE 0 #define ICMP_DEFAULT_CODE 0
// //
// ICMP code definitions for ICMP_DEST_UNREACHABLE // ICMP code definitions for ICMP_DEST_UNREACHABLE
// //
#define ICMP_NET_UNREACHABLE 0 #define ICMP_NET_UNREACHABLE 0
#define ICMP_HOST_UNREACHABLE 1 #define ICMP_HOST_UNREACHABLE 1
#define ICMP_PROTO_UNREACHABLE 2 // Host may generate #define ICMP_PROTO_UNREACHABLE 2 // Host may generate
@ -43,24 +43,24 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define ICMP_NET_UNREACHABLE_TOS 11 #define ICMP_NET_UNREACHABLE_TOS 11
#define ICMP_HOST_UNREACHABLE_TOS 12 #define ICMP_HOST_UNREACHABLE_TOS 12
// //
// ICMP code definitions for ICMP_TIME_EXCEEDED // ICMP code definitions for ICMP_TIME_EXCEEDED
// //
#define ICMP_TIMEOUT_IN_TRANSIT 0 #define ICMP_TIMEOUT_IN_TRANSIT 0
#define ICMP_TIMEOUT_REASSEMBLE 1 // Host may generate #define ICMP_TIMEOUT_REASSEMBLE 1 // Host may generate
// //
// ICMP code definitions for ICMP_TIME_EXCEEDED // ICMP code definitions for ICMP_TIME_EXCEEDED
// //
#define ICMP_NET_REDIRECT 0 #define ICMP_NET_REDIRECT 0
#define ICMP_HOST_REDIRECT 1 #define ICMP_HOST_REDIRECT 1
#define ICMP_NET_TOS_REDIRECT 2 #define ICMP_NET_TOS_REDIRECT 2
#define ICMP_HOST_TOS_REDIRECT 3 #define ICMP_HOST_TOS_REDIRECT 3
// //
// ICMP message classes, each class of ICMP message shares // ICMP message classes, each class of ICMP message shares
// a common message format. INVALID_MESSAGE is only a flag. // a common message format. INVALID_MESSAGE is only a flag.
// //
#define ICMP_INVALID_MESSAGE 0 #define ICMP_INVALID_MESSAGE 0
#define ICMP_ERROR_MESSAGE 1 #define ICMP_ERROR_MESSAGE 1
#define ICMP_QUERY_MESSAGE 2 #define ICMP_QUERY_MESSAGE 2
@ -94,4 +94,5 @@ Ip4IcmpHandle (
IN IP4_HEAD *Head, IN IP4_HEAD *Head,
IN NET_BUF *Packet IN NET_BUF *Packet
); );
#endif #endif

View File

@ -121,7 +121,6 @@ Ip4CancelFrameArp (
IN VOID *Context IN VOID *Context
); );
/** /**
Wrap a transmit request into a newly allocated IP4_LINK_TX_TOKEN. Wrap a transmit request into a newly allocated IP4_LINK_TX_TOKEN.
@ -154,8 +153,10 @@ Ip4WrapLinkTxToken (
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Count; UINT32 Count;
Token = AllocatePool (sizeof (IP4_LINK_TX_TOKEN) + \ Token = AllocatePool (
(Packet->BlockOpNum - 1) * sizeof (EFI_MANAGED_NETWORK_FRAGMENT_DATA)); sizeof (IP4_LINK_TX_TOKEN) + \
(Packet->BlockOpNum - 1) * sizeof (EFI_MANAGED_NETWORK_FRAGMENT_DATA)
);
if (Token == NULL) { if (Token == NULL) {
return NULL; return NULL;
@ -200,13 +201,12 @@ Ip4WrapLinkTxToken (
Count = Packet->BlockOpNum; Count = Packet->BlockOpNum;
NetbufBuildExt (Packet, (NET_FRAGMENT *) MnpTxData->FragmentTable, &Count); NetbufBuildExt (Packet, (NET_FRAGMENT *)MnpTxData->FragmentTable, &Count);
MnpTxData->FragmentCount = (UINT16)Count; MnpTxData->FragmentCount = (UINT16)Count;
return Token; return Token;
} }
/** /**
Free the link layer transmit token. It will close the event Free the link layer transmit token. It will close the event
then free the memory used. then free the memory used.
@ -225,7 +225,6 @@ Ip4FreeLinkTxToken (
FreePool (Token); FreePool (Token);
} }
/** /**
Create an IP_ARP_QUE structure to request ARP service. Create an IP_ARP_QUE structure to request ARP service.
@ -276,7 +275,6 @@ Ip4CreateArpQue (
return ArpQue; return ArpQue;
} }
/** /**
Remove all the transmit requests queued on the ARP queue, then free it. Remove all the transmit requests queued on the ARP queue, then free it.
@ -302,7 +300,6 @@ Ip4FreeArpQue (
FreePool (ArpQue); FreePool (ArpQue);
} }
/** /**
Create a link layer receive token to wrap the receive request Create a link layer receive token to wrap the receive request
@ -358,7 +355,6 @@ Ip4CreateLinkRxToken (
return Token; return Token;
} }
/** /**
Free the link layer request token. It will close the event Free the link layer request token. It will close the event
then free the memory used. then free the memory used.
@ -371,14 +367,12 @@ Ip4FreeFrameRxToken (
IN IP4_LINK_RX_TOKEN *Token IN IP4_LINK_RX_TOKEN *Token
) )
{ {
NET_CHECK_SIGNATURE (Token, IP4_FRAME_RX_SIGNATURE); NET_CHECK_SIGNATURE (Token, IP4_FRAME_RX_SIGNATURE);
gBS->CloseEvent (Token->MnpToken.Event); gBS->CloseEvent (Token->MnpToken.Event);
FreePool (Token); FreePool (Token);
} }
/** /**
Remove all the frames on the ARP queue that pass the FrameToCancel, Remove all the frames on the ARP queue that pass the FrameToCancel,
that is, either FrameToCancel is NULL or it returns true for the frame. that is, either FrameToCancel is NULL or it returns true for the frame.
@ -414,7 +408,6 @@ Ip4CancelFrameArp (
} }
} }
/** /**
Remove all the frames on the interface that pass the FrameToCancel, Remove all the frames on the interface that pass the FrameToCancel,
either queued on ARP queues or that have already been delivered to either queued on ARP queues or that have already been delivered to
@ -467,7 +460,6 @@ Ip4CancelFrames (
} }
} }
/** /**
Create an IP4_INTERFACE. Delay the creation of ARP instance until Create an IP4_INTERFACE. Delay the creation of ARP instance until
the interface is configured. the interface is configured.
@ -538,7 +530,6 @@ Ip4CreateInterface (
return Interface; return Interface;
} }
/** /**
Set the interface's address, create and configure Set the interface's address, create and configure
the ARP child if necessary. the ARP child if necessary.
@ -621,7 +612,7 @@ Ip4SetAddress (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Interface->ArpHandle, Interface->ArpHandle,
&gEfiArpProtocolGuid, &gEfiArpProtocolGuid,
(VOID **) &Interface->Arp, (VOID **)&Interface->Arp,
Interface->Image, Interface->Image,
Interface->Controller, Interface->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
@ -667,7 +658,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Filter function to cancel all the frame related to an IP instance. Filter function to cancel all the frame related to an IP instance.
@ -686,15 +676,13 @@ Ip4CancelInstanceFrame (
IN VOID *Context IN VOID *Context
) )
{ {
if (Frame->IpInstance == (IP4_PROTOCOL *) Context) { if (Frame->IpInstance == (IP4_PROTOCOL *)Context) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
/** /**
If there is a pending receive request, cancel it. Don't call If there is a pending receive request, cancel it. Don't call
the receive request's callback because this function can be only the receive request's callback because this function can be only
@ -725,7 +713,6 @@ Ip4CancelReceive (
} }
} }
/** /**
Free the interface used by IpInstance. All the IP instance with Free the interface used by IpInstance. All the IP instance with
the same Ip/Netmask pair share the same interface. It is reference the same Ip/Netmask pair share the same interface. It is reference
@ -830,18 +817,22 @@ Ip4SendFrameToDefaultRoute (
if (Token->IpInstance != NULL) { if (Token->IpInstance != NULL) {
RtCacheEntry = Ip4FindRouteCache (Token->IpInstance->RouteTable, NTOHL (ArpQue->Ip), Token->Interface->Ip); RtCacheEntry = Ip4FindRouteCache (Token->IpInstance->RouteTable, NTOHL (ArpQue->Ip), Token->Interface->Ip);
} }
if (RtCacheEntry == NULL) { if (RtCacheEntry == NULL) {
RtCacheEntry = Ip4FindRouteCache (Token->IpSb->DefaultRouteTable, NTOHL (ArpQue->Ip), Token->Interface->Ip); RtCacheEntry = Ip4FindRouteCache (Token->IpSb->DefaultRouteTable, NTOHL (ArpQue->Ip), Token->Interface->Ip);
} }
if (RtCacheEntry == NULL) { if (RtCacheEntry == NULL) {
Status= EFI_NO_MAPPING; Status = EFI_NO_MAPPING;
goto ON_ERROR; goto ON_ERROR;
} }
DefaultRoute = (IP4_ROUTE_ENTRY*)RtCacheEntry->Tag;
DefaultRoute = (IP4_ROUTE_ENTRY *)RtCacheEntry->Tag;
if (DefaultRoute == NULL) { if (DefaultRoute == NULL) {
Status= EFI_NO_MAPPING; Status = EFI_NO_MAPPING;
goto ON_ERROR; goto ON_ERROR;
} }
// //
// Try to send the frame to the default route. // Try to send the frame to the default route.
// //
@ -850,15 +841,17 @@ Ip4SendFrameToDefaultRoute (
// //
// ARP resolve for the default route is failed, return error to caller. // ARP resolve for the default route is failed, return error to caller.
// //
Status= EFI_NO_MAPPING; Status = EFI_NO_MAPPING;
goto ON_ERROR; goto ON_ERROR;
} }
RtCacheEntry->NextHop = Gateway; RtCacheEntry->NextHop = Gateway;
Status = Ip4SendFrame (Token->Interface,Token->IpInstance,Token->Packet,Gateway,Token->CallBack,Token->Context,Token->IpSb); Status = Ip4SendFrame (Token->Interface, Token->IpInstance, Token->Packet, Gateway, Token->CallBack, Token->Context, Token->IpSb);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Status= EFI_NO_MAPPING; Status = EFI_NO_MAPPING;
goto ON_ERROR; goto ON_ERROR;
} }
Ip4FreeRouteCacheEntry (RtCacheEntry); Ip4FreeRouteCacheEntry (RtCacheEntry);
} }
@ -868,12 +861,12 @@ ON_ERROR:
if (RtCacheEntry != NULL) { if (RtCacheEntry != NULL) {
Ip4FreeRouteCacheEntry (RtCacheEntry); Ip4FreeRouteCacheEntry (RtCacheEntry);
} }
Token->CallBack (Token->IpInstance, Token->Packet, Status, 0, Token->Context); Token->CallBack (Token->IpInstance, Token->Packet, Status, 0, Token->Context);
Ip4FreeLinkTxToken (Token); Ip4FreeLinkTxToken (Token);
return Status; return Status;
} }
/** /**
Callback function when ARP request are finished. It will cancel Callback function when ARP request are finished. It will cancel
all the queued frame if the ARP requests failed. Or transmit them all the queued frame if the ARP requests failed. Or transmit them
@ -897,7 +890,7 @@ Ip4OnArpResolvedDpc (
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS IoStatus; EFI_STATUS IoStatus;
ArpQue = (IP4_ARP_QUE *) Context; ArpQue = (IP4_ARP_QUE *)Context;
NET_CHECK_SIGNATURE (ArpQue, IP4_FRAME_ARP_SIGNATURE); NET_CHECK_SIGNATURE (ArpQue, IP4_FRAME_ARP_SIGNATURE);
RemoveEntryList (&ArpQue->Link); RemoveEntryList (&ArpQue->Link);
@ -919,6 +912,7 @@ Ip4OnArpResolvedDpc (
// //
IoStatus = Ip4SendFrameToDefaultRoute (ArpQue); IoStatus = Ip4SendFrameToDefaultRoute (ArpQue);
} }
goto ON_EXIT; goto ON_EXIT;
} }
@ -980,8 +974,6 @@ Ip4OnArpResolved (
QueueDpc (TPL_CALLBACK, Ip4OnArpResolvedDpc, Context); QueueDpc (TPL_CALLBACK, Ip4OnArpResolvedDpc, Context);
} }
/** /**
Callback function when frame transmission is finished. It will Callback function when frame transmission is finished. It will
call the frame owner's callback function to tell it the result. call the frame owner's callback function to tell it the result.
@ -997,7 +989,7 @@ Ip4OnFrameSentDpc (
{ {
IP4_LINK_TX_TOKEN *Token; IP4_LINK_TX_TOKEN *Token;
Token = (IP4_LINK_TX_TOKEN *) Context; Token = (IP4_LINK_TX_TOKEN *)Context;
NET_CHECK_SIGNATURE (Token, IP4_FRAME_TX_SIGNATURE); NET_CHECK_SIGNATURE (Token, IP4_FRAME_TX_SIGNATURE);
RemoveEntryList (&Token->Link); RemoveEntryList (&Token->Link);
@ -1033,8 +1025,6 @@ Ip4OnFrameSent (
QueueDpc (TPL_CALLBACK, Ip4OnFrameSentDpc, Context); QueueDpc (TPL_CALLBACK, Ip4OnFrameSentDpc, Context);
} }
/** /**
Send a frame from the interface. If the next hop is broadcast or Send a frame from the interface. If the next hop is broadcast or
multicast address, it is transmitted immediately. If the next hop multicast address, it is transmitted immediately. If the next hop
@ -1092,9 +1082,7 @@ Ip4SendFrame (
if (NextHop == IP4_ALLONE_ADDRESS) { if (NextHop == IP4_ALLONE_ADDRESS) {
CopyMem (&Token->DstMac, &Interface->BroadcastMac, sizeof (Token->DstMac)); CopyMem (&Token->DstMac, &Interface->BroadcastMac, sizeof (Token->DstMac));
goto SEND_NOW; goto SEND_NOW;
} else if (IP4_IS_MULTICAST (NextHop)) { } else if (IP4_IS_MULTICAST (NextHop)) {
Status = Ip4GetMulticastMac (Interface->Mnp, NextHop, &Token->DstMac); Status = Ip4GetMulticastMac (Interface->Mnp, NextHop, &Token->DstMac);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -1120,7 +1108,6 @@ Ip4SendFrame (
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
goto SEND_NOW; goto SEND_NOW;
} else if (Status != EFI_NOT_READY) { } else if (Status != EFI_NOT_READY) {
goto ON_ERROR; goto ON_ERROR;
} }
@ -1187,7 +1174,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Call back function when the received packet is freed. Call back function when the received packet is freed.
Check Ip4OnFrameReceived for information. Check Ip4OnFrameReceived for information.
@ -1203,14 +1189,13 @@ Ip4RecycleFrame (
{ {
IP4_LINK_RX_TOKEN *Frame; IP4_LINK_RX_TOKEN *Frame;
Frame = (IP4_LINK_RX_TOKEN *) Context; Frame = (IP4_LINK_RX_TOKEN *)Context;
NET_CHECK_SIGNATURE (Frame, IP4_FRAME_RX_SIGNATURE); NET_CHECK_SIGNATURE (Frame, IP4_FRAME_RX_SIGNATURE);
gBS->SignalEvent (Frame->MnpToken.Packet.RxData->RecycleEvent); gBS->SignalEvent (Frame->MnpToken.Packet.RxData->RecycleEvent);
Ip4FreeFrameRxToken (Frame); Ip4FreeFrameRxToken (Frame);
} }
/** /**
Received a frame from MNP, wrap it in net buffer then deliver Received a frame from MNP, wrap it in net buffer then deliver
it to IP's input function. The ownship of the packet also it to IP's input function. The ownship of the packet also
@ -1235,7 +1220,7 @@ Ip4OnFrameReceivedDpc (
NET_BUF *Packet; NET_BUF *Packet;
UINT32 Flag; UINT32 Flag;
Token = (IP4_LINK_RX_TOKEN *) Context; Token = (IP4_LINK_RX_TOKEN *)Context;
NET_CHECK_SIGNATURE (Token, IP4_FRAME_RX_SIGNATURE); NET_CHECK_SIGNATURE (Token, IP4_FRAME_RX_SIGNATURE);
// //
@ -1251,7 +1236,7 @@ Ip4OnFrameReceivedDpc (
Token->CallBack (Token->IpInstance, NULL, MnpToken->Status, 0, Token->Context); Token->CallBack (Token->IpInstance, NULL, MnpToken->Status, 0, Token->Context);
Ip4FreeFrameRxToken (Token); Ip4FreeFrameRxToken (Token);
return ; return;
} }
// //
@ -1269,7 +1254,7 @@ Ip4OnFrameReceivedDpc (
Token->CallBack (Token->IpInstance, NULL, EFI_OUT_OF_RESOURCES, 0, Token->Context); Token->CallBack (Token->IpInstance, NULL, EFI_OUT_OF_RESOURCES, 0, Token->Context);
Ip4FreeFrameRxToken (Token); Ip4FreeFrameRxToken (Token);
return ; return;
} }
Flag = (MnpRxData->BroadcastFlag ? IP4_LINK_BROADCAST : 0); Flag = (MnpRxData->BroadcastFlag ? IP4_LINK_BROADCAST : 0);
@ -1299,7 +1284,6 @@ Ip4OnFrameReceived (
QueueDpc (TPL_CALLBACK, Ip4OnFrameReceivedDpc, Context); QueueDpc (TPL_CALLBACK, Ip4OnFrameReceivedDpc, Context);
} }
/** /**
Request to receive the packet from the interface. Request to receive the packet from the interface.
@ -1345,5 +1329,6 @@ Ip4ReceiveFrame (
Ip4FreeFrameRxToken (Token); Ip4FreeFrameRxToken (Token);
return Status; return Status;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// //
UINT32 mRouteAlertOption = 0x00000494; UINT32 mRouteAlertOption = 0x00000494;
/** /**
Init the IGMP control data of the IP4 service instance, configure Init the IGMP control data of the IP4 service instance, configure
MNP to receive ALL SYSTEM multicast. MNP to receive ALL SYSTEM multicast.
@ -74,7 +73,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Find the IGMP_GROUP structure which contains the status of multicast Find the IGMP_GROUP structure which contains the status of multicast
group Address in this IGMP control block group Address in this IGMP control block
@ -107,7 +105,6 @@ Ip4FindGroup (
return NULL; return NULL;
} }
/** /**
Count the number of IP4 multicast groups that are mapped to the Count the number of IP4 multicast groups that are mapped to the
same MAC address. Several IP4 multicast address may be mapped to same MAC address. Several IP4 multicast address may be mapped to
@ -143,7 +140,6 @@ Ip4FindMac (
return Count; return Count;
} }
/** /**
Send an IGMP protocol message to the Dst, such as IGMP v1 membership report. Send an IGMP protocol message to the Dst, such as IGMP v1 membership report.
@ -185,7 +181,7 @@ Ip4SendIgmpMessage (
// //
NetbufReserve (Packet, IP4_MAX_HEADLEN); NetbufReserve (Packet, IP4_MAX_HEADLEN);
Igmp = (IGMP_HEAD *) NetbufAllocSpace (Packet, sizeof (IGMP_HEAD), FALSE); Igmp = (IGMP_HEAD *)NetbufAllocSpace (Packet, sizeof (IGMP_HEAD), FALSE);
if (Igmp == NULL) { if (Igmp == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -194,7 +190,7 @@ Ip4SendIgmpMessage (
Igmp->MaxRespTime = 0; Igmp->MaxRespTime = 0;
Igmp->Checksum = 0; Igmp->Checksum = 0;
Igmp->Group = HTONL (Group); Igmp->Group = HTONL (Group);
Igmp->Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Igmp, sizeof (IGMP_HEAD))); Igmp->Checksum = (UINT16)(~NetblockChecksum ((UINT8 *)Igmp, sizeof (IGMP_HEAD)));
Head.Tos = 0; Head.Tos = 0;
Head.Protocol = IP4_PROTO_IGMP; Head.Protocol = IP4_PROTO_IGMP;
@ -208,7 +204,7 @@ Ip4SendIgmpMessage (
NULL, NULL,
Packet, Packet,
&Head, &Head,
(UINT8 *) &mRouteAlertOption, (UINT8 *)&mRouteAlertOption,
sizeof (UINT32), sizeof (UINT32),
IP4_ALLZERO_ADDRESS, IP4_ALLZERO_ADDRESS,
Ip4SysPacketSent, Ip4SysPacketSent,
@ -216,7 +212,6 @@ Ip4SendIgmpMessage (
); );
} }
/** /**
Send an IGMP membership report. Depends on whether the server is Send an IGMP membership report. Depends on whether the server is
v1 or v2, it will send either a V1 or V2 membership report. v1 or v2, it will send either a V1 or V2 membership report.
@ -243,7 +238,6 @@ Ip4SendIgmpReport (
} }
} }
/** /**
Join the multicast group on behalf of this IP4 child Join the multicast group on behalf of this IP4 child
@ -323,7 +317,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Leave the IP4 multicast group on behalf of IpInstance. Leave the IP4 multicast group on behalf of IpInstance.
@ -383,7 +376,7 @@ Ip4LeaveGroup (
// Send a leave report if the membership is reported by us // Send a leave report if the membership is reported by us
// and we are talking IGMPv2. // and we are talking IGMPv2.
// //
if (Group->ReportByUs && IgmpCtrl->Igmpv1QuerySeen == 0) { if (Group->ReportByUs && (IgmpCtrl->Igmpv1QuerySeen == 0)) {
Ip4SendIgmpMessage (IpSb, IP4_ALLROUTER_ADDRESS, IGMP_LEAVE_GROUP, Group->Address); Ip4SendIgmpMessage (IpSb, IP4_ALLROUTER_ADDRESS, IGMP_LEAVE_GROUP, Group->Address);
} }
@ -393,7 +386,6 @@ Ip4LeaveGroup (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Handle the received IGMP message for the IP4 service instance. Handle the received IGMP message for the IP4 service instance.
@ -494,7 +486,6 @@ Ip4IgmpHandle (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The periodical timer function for IGMP. It does the following The periodical timer function for IGMP. It does the following
things: things:
@ -539,7 +530,6 @@ Ip4IgmpTicking (
} }
} }
/** /**
Add a group address to the array of group addresses. Add a group address to the array of group addresses.
The caller should make sure that no duplicated address The caller should make sure that no duplicated address
@ -576,7 +566,6 @@ Ip4CombineGroups (
return Groups; return Groups;
} }
/** /**
Remove a group address from the array of group addresses. Remove a group address from the array of group addresses.
Although the function doesn't assume the byte order of the Although the function doesn't assume the byte order of the

View File

@ -198,4 +198,5 @@ Ip4FindGroup (
IN IGMP_SERVICE_DATA *IgmpCtrl, IN IGMP_SERVICE_DATA *IgmpCtrl,
IN IP4_ADDR Address IN IP4_ADDR Address
); );
#endif #endif

View File

@ -329,7 +329,7 @@ EfiIp4Poll (
); );
EFI_IP4_PROTOCOL EFI_IP4_PROTOCOL
mEfiIp4ProtocolTemplete = { mEfiIp4ProtocolTemplete = {
EfiIp4GetModeData, EfiIp4GetModeData,
EfiIp4Configure, EfiIp4Configure,
EfiIp4Groups, EfiIp4Groups,
@ -392,7 +392,7 @@ EfiIp4GetModeData (
Ip4ModeData->IsConfigured = FALSE; Ip4ModeData->IsConfigured = FALSE;
Ip4ModeData->GroupCount = IpInstance->GroupCount; Ip4ModeData->GroupCount = IpInstance->GroupCount;
Ip4ModeData->GroupTable = (EFI_IPv4_ADDRESS *) IpInstance->Groups; Ip4ModeData->GroupTable = (EFI_IPv4_ADDRESS *)IpInstance->Groups;
Ip4ModeData->IcmpTypeCount = 23; Ip4ModeData->IcmpTypeCount = 23;
Ip4ModeData->IcmpTypeList = mIp4SupportedIcmp; Ip4ModeData->IcmpTypeList = mIp4SupportedIcmp;
@ -443,7 +443,6 @@ EfiIp4GetModeData (
return Status; return Status;
} }
/** /**
Config the MNP parameter used by IP. The IP driver use one MNP Config the MNP parameter used by IP. The IP driver use one MNP
child to transmit/receive frames. By default, it configures MNP child to transmit/receive frames. By default, it configures MNP
@ -486,7 +485,6 @@ Ip4ServiceConfigMnp (
// filter also. // filter also.
// //
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link); IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);
IpIf->PromiscRecv = FALSE; IpIf->PromiscRecv = FALSE;
@ -523,7 +521,6 @@ Ip4ServiceConfigMnp (
return Status; return Status;
} }
/** /**
Initialize the IP4_PROTOCOL structure to the unconfigured states. Initialize the IP4_PROTOCOL structure to the unconfigured states.
@ -557,7 +554,6 @@ Ip4InitProtocol (
EfiInitializeLock (&IpInstance->RecycleLock, TPL_NOTIFY); EfiInitializeLock (&IpInstance->RecycleLock, TPL_NOTIFY);
} }
/** /**
Configure the IP4 child. If the child is already configured, Configure the IP4 child. If the child is already configured,
change the configuration parameter. Otherwise configure it change the configuration parameter. Otherwise configure it
@ -646,7 +642,6 @@ Ip4ConfigProtocol (
if (IpIf != NULL) { if (IpIf != NULL) {
NET_GET_REF (IpIf); NET_GET_REF (IpIf);
} else { } else {
IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image); IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
@ -687,7 +682,7 @@ Ip4ConfigProtocol (
if (Policy != Ip4Config2PolicyDhcp) { if (Policy != Ip4Config2PolicyDhcp) {
Ip4Config2 = &IpSb->Ip4Config2Instance.Ip4Config2; Ip4Config2 = &IpSb->Ip4Config2Instance.Ip4Config2;
Policy = Ip4Config2PolicyDhcp; Policy = Ip4Config2PolicyDhcp;
Status= Ip4Config2->SetData ( Status = Ip4Config2->SetData (
Ip4Config2, Ip4Config2,
Ip4Config2DataTypePolicy, Ip4Config2DataTypePolicy,
sizeof (EFI_IP4_CONFIG2_POLICY), sizeof (EFI_IP4_CONFIG2_POLICY),
@ -719,7 +714,7 @@ Ip4ConfigProtocol (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
IpIf->ArpHandle, IpIf->ArpHandle,
&gEfiArpProtocolGuid, &gEfiArpProtocolGuid,
(VOID **) &Arp, (VOID **)&Arp,
gIp4DriverBinding.DriverBindingHandle, gIp4DriverBinding.DriverBindingHandle,
IpInstance->Handle, IpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -729,6 +724,7 @@ Ip4ConfigProtocol (
goto ON_ERROR; goto ON_ERROR;
} }
} }
InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink); InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink);
CopyMem (&IpInstance->ConfigData, Config, sizeof (IpInstance->ConfigData)); CopyMem (&IpInstance->ConfigData, Config, sizeof (IpInstance->ConfigData));
@ -751,7 +747,6 @@ ON_ERROR:
return Status; return Status;
} }
/** /**
Clean up the IP4 child, release all the resources used by it. Clean up the IP4 child, release all the resources used by it.
@ -780,7 +775,6 @@ Ip4CleanProtocol (
// hasn't been called. Just leave it alone. // hasn't been called. Just leave it alone.
// //
if (!IsListEmpty (&IpInstance->Delivered)) { if (!IsListEmpty (&IpInstance->Delivered)) {
;
} }
if (IpInstance->Interface != NULL) { if (IpInstance->Interface != NULL) {
@ -793,6 +787,7 @@ Ip4CleanProtocol (
IpInstance->Handle IpInstance->Handle
); );
} }
Ip4FreeInterface (IpInstance->Interface, IpInstance); Ip4FreeInterface (IpInstance->Interface, IpInstance);
IpInstance->Interface = NULL; IpInstance->Interface = NULL;
} }
@ -825,7 +820,6 @@ Ip4CleanProtocol (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance. Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
@ -898,7 +892,6 @@ EfiIp4Configure (
// Validate the configuration first. // Validate the configuration first.
// //
if (IpConfigData != NULL) { if (IpConfigData != NULL) {
CopyMem (&IpAddress, &IpConfigData->StationAddress, sizeof (IP4_ADDR)); CopyMem (&IpAddress, &IpConfigData->StationAddress, sizeof (IP4_ADDR));
CopyMem (&SubnetMask, &IpConfigData->SubnetMask, sizeof (IP4_ADDR)); CopyMem (&SubnetMask, &IpConfigData->SubnetMask, sizeof (IP4_ADDR));
@ -932,7 +925,8 @@ EfiIp4Configure (
if (!Current->UseDefaultAddress && if (!Current->UseDefaultAddress &&
(!EFI_IP4_EQUAL (&Current->StationAddress, &IpConfigData->StationAddress) || (!EFI_IP4_EQUAL (&Current->StationAddress, &IpConfigData->StationAddress) ||
!EFI_IP4_EQUAL (&Current->SubnetMask, &IpConfigData->SubnetMask))) { !EFI_IP4_EQUAL (&Current->SubnetMask, &IpConfigData->SubnetMask)))
{
Status = EFI_ALREADY_STARTED; Status = EFI_ALREADY_STARTED;
goto ON_EXIT; goto ON_EXIT;
} }
@ -971,10 +965,8 @@ EfiIp4Configure (
ON_EXIT: ON_EXIT:
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
/** /**
Change the IP4 child's multicast setting. The caller Change the IP4 child's multicast setting. The caller
should make sure that the parameters is valid. should make sure that the parameters is valid.
@ -1045,7 +1037,7 @@ Ip4Groups (
// Must iterate from the end to the beginning because the GroupCount // Must iterate from the end to the beginning because the GroupCount
// is decremented each time an address is removed.. // is decremented each time an address is removed..
// //
for (Index = IpInstance->GroupCount; Index > 0 ; Index--) { for (Index = IpInstance->GroupCount; Index > 0; Index--) {
ASSERT (IpInstance->Groups != NULL); ASSERT (IpInstance->Groups != NULL);
Group = IpInstance->Groups[Index - 1]; Group = IpInstance->Groups[Index - 1];
if ((GroupAddress == NULL) || EFI_IP4_EQUAL (&Group, GroupAddress)) { if ((GroupAddress == NULL) || EFI_IP4_EQUAL (&Group, GroupAddress)) {
@ -1072,7 +1064,6 @@ Ip4Groups (
return ((GroupAddress != NULL) ? EFI_NOT_FOUND : EFI_SUCCESS); return ((GroupAddress != NULL) ? EFI_NOT_FOUND : EFI_SUCCESS);
} }
/** /**
Joins and leaves multicast groups. Joins and leaves multicast groups.
@ -1148,7 +1139,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Adds and deletes routing table entries. Adds and deletes routing table entries.
@ -1221,7 +1211,8 @@ EfiIp4Routes (
// First, validate the parameters // First, validate the parameters
// //
if ((This == NULL) || (SubnetAddress == NULL) || if ((This == NULL) || (SubnetAddress == NULL) ||
(SubnetMask == NULL) || (GatewayAddress == NULL)) { (SubnetMask == NULL) || (GatewayAddress == NULL))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1257,9 +1248,9 @@ EfiIp4Routes (
// the gateway address must be a unicast on the connected network if not zero. // the gateway address must be a unicast on the connected network if not zero.
// //
if ((Nexthop != IP4_ALLZERO_ADDRESS) && if ((Nexthop != IP4_ALLZERO_ADDRESS) &&
((IpIf->SubnetMask != IP4_ALLONE_ADDRESS && !IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask)) || (((IpIf->SubnetMask != IP4_ALLONE_ADDRESS) && !IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask)) ||
IP4_IS_BROADCAST (Ip4GetNetCast (Nexthop, IpIf)))) { IP4_IS_BROADCAST (Ip4GetNetCast (Nexthop, IpIf))))
{
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
@ -1275,7 +1266,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Check whether the user's token or event has already Check whether the user's token or event has already
been enqueued on IP4's list. been enqueued on IP4's list.
@ -1301,8 +1291,8 @@ Ip4TokenExist (
EFI_IP4_COMPLETION_TOKEN *Token; EFI_IP4_COMPLETION_TOKEN *Token;
EFI_IP4_COMPLETION_TOKEN *TokenInItem; EFI_IP4_COMPLETION_TOKEN *TokenInItem;
Token = (EFI_IP4_COMPLETION_TOKEN *) Context; Token = (EFI_IP4_COMPLETION_TOKEN *)Context;
TokenInItem = (EFI_IP4_COMPLETION_TOKEN *) Item->Key; TokenInItem = (EFI_IP4_COMPLETION_TOKEN *)Item->Key;
if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) { if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
@ -1359,8 +1349,8 @@ Ip4TxTokenValid (
for (Index = 0; Index < TxData->FragmentCount; Index++) { for (Index = 0; Index < TxData->FragmentCount; Index++) {
if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) || if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) ||
(TxData->FragmentTable[Index].FragmentLength == 0)) { (TxData->FragmentTable[Index].FragmentLength == 0))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1407,8 +1397,8 @@ Ip4TxTokenValid (
if ((NetGetIpClass (Src) > IP4_ADDR_CLASSC) || if ((NetGetIpClass (Src) > IP4_ADDR_CLASSC) ||
(Src == IP4_ALLONE_ADDRESS) || (Src == IP4_ALLONE_ADDRESS) ||
IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf))) { IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf)))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1419,8 +1409,8 @@ Ip4TxTokenValid (
if ((Gateway != IP4_ALLZERO_ADDRESS) && if ((Gateway != IP4_ALLZERO_ADDRESS) &&
((NetGetIpClass (Gateway) > IP4_ADDR_CLASSC) || ((NetGetIpClass (Gateway) > IP4_ADDR_CLASSC) ||
!IP4_NET_EQUAL (Gateway, IpIf->Ip, IpIf->SubnetMask) || !IP4_NET_EQUAL (Gateway, IpIf->Ip, IpIf->SubnetMask) ||
IP4_IS_BROADCAST (Ip4GetNetCast (Gateway, IpIf)))) { IP4_IS_BROADCAST (Ip4GetNetCast (Gateway, IpIf))))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
@ -1431,15 +1421,14 @@ Ip4TxTokenValid (
HeadLen = sizeof (IP4_HEAD) + ((TxData->OptionsLength + 3) &~0x03); HeadLen = sizeof (IP4_HEAD) + ((TxData->OptionsLength + 3) &~0x03);
if ((HeadLen > IP4_MAX_HEADLEN) || if ((HeadLen > IP4_MAX_HEADLEN) ||
(TxData->TotalDataLength + HeadLen > IP4_MAX_PACKET_SIZE)) { (TxData->TotalDataLength + HeadLen > IP4_MAX_PACKET_SIZE))
{
return EFI_BAD_BUFFER_SIZE; return EFI_BAD_BUFFER_SIZE;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The callback function for the net buffer which wraps the user's The callback function for the net buffer which wraps the user's
transmit token. Although it seems this function is pretty simple, transmit token. Although it seems this function is pretty simple,
@ -1470,7 +1459,7 @@ Ip4FreeTxToken (
IP4_TXTOKEN_WRAP *Wrap; IP4_TXTOKEN_WRAP *Wrap;
NET_MAP_ITEM *Item; NET_MAP_ITEM *Item;
Wrap = (IP4_TXTOKEN_WRAP *) Context; Wrap = (IP4_TXTOKEN_WRAP *)Context;
// //
// Signal IpSecRecycleEvent to inform IPsec free the memory // Signal IpSecRecycleEvent to inform IPsec free the memory
@ -1501,7 +1490,6 @@ Ip4FreeTxToken (
FreePool (Wrap); FreePool (Wrap);
} }
/** /**
The callback function to Ip4Output to update the transmit status. The callback function to Ip4Output to update the transmit status.
@ -1536,13 +1524,12 @@ Ip4OnPacketSent (
// release when all the fragments are release. Check the comments // release when all the fragments are release. Check the comments
// in Ip4FreeTxToken and Ip4Output for information. // in Ip4FreeTxToken and Ip4Output for information.
// //
Wrap = (IP4_TXTOKEN_WRAP *) Context; Wrap = (IP4_TXTOKEN_WRAP *)Context;
Wrap->Token->Status = IoStatus; Wrap->Token->Status = IoStatus;
NetbufFree (Wrap->Packet); NetbufFree (Wrap->Packet);
} }
/** /**
Places outgoing data packets into the transmit queue. Places outgoing data packets into the transmit queue.
@ -1651,13 +1638,13 @@ EfiIp4Transmit (
FirstFragment = TxData->FragmentTable[0].FragmentBuffer; FirstFragment = TxData->FragmentTable[0].FragmentBuffer;
CopyMem (&RawHdrLen, FirstFragment, sizeof (UINT8)); CopyMem (&RawHdrLen, FirstFragment, sizeof (UINT8));
RawHdrLen = (UINT8) (RawHdrLen & 0x0f); RawHdrLen = (UINT8)(RawHdrLen & 0x0f);
if (RawHdrLen < 5) { if (RawHdrLen < 5) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT; goto ON_EXIT;
} }
RawHdrLen = (UINT8) (RawHdrLen << 2); RawHdrLen = (UINT8)(RawHdrLen << 2);
CopyMem (&Head, FirstFragment, IP4_MIN_HEADLEN); CopyMem (&Head, FirstFragment, IP4_MIN_HEADLEN);
@ -1680,13 +1667,13 @@ EfiIp4Transmit (
OptionsBuffer = NULL; OptionsBuffer = NULL;
} else { } else {
OptionsLength = RawHdrLen - IP4_MIN_HEADLEN; OptionsLength = RawHdrLen - IP4_MIN_HEADLEN;
OptionsBuffer = (UINT8 *) FirstFragment + IP4_MIN_HEADLEN; OptionsBuffer = (UINT8 *)FirstFragment + IP4_MIN_HEADLEN;
} }
// //
// Trim off IPv4 header and options from first fragment. // Trim off IPv4 header and options from first fragment.
// //
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment + RawHdrLen; TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment + RawHdrLen;
TxData->FragmentTable[0].FragmentLength = TxData->FragmentTable[0].FragmentLength - RawHdrLen; TxData->FragmentTable[0].FragmentLength = TxData->FragmentTable[0].FragmentLength - RawHdrLen;
} else { } else {
CopyMem (&Head.Dst, &TxData->DestinationAddress, sizeof (IP4_ADDR)); CopyMem (&Head.Dst, &TxData->DestinationAddress, sizeof (IP4_ADDR));
@ -1717,7 +1704,7 @@ EfiIp4Transmit (
HeadLen = (TxData->OptionsLength + 3) & (~0x03); HeadLen = (TxData->OptionsLength + 3) & (~0x03);
OptionsLength = TxData->OptionsLength; OptionsLength = TxData->OptionsLength;
OptionsBuffer = (UINT8 *) (TxData->OptionsBuffer); OptionsBuffer = (UINT8 *)(TxData->OptionsBuffer);
} }
// //
@ -1743,7 +1730,7 @@ EfiIp4Transmit (
Wrap->Sent = FALSE; Wrap->Sent = FALSE;
Wrap->Life = IP4_US_TO_SEC (Config->TransmitTimeout); Wrap->Life = IP4_US_TO_SEC (Config->TransmitTimeout);
Wrap->Packet = NetbufFromExt ( Wrap->Packet = NetbufFromExt (
(NET_FRAGMENT *) TxData->FragmentTable, (NET_FRAGMENT *)TxData->FragmentTable,
TxData->FragmentCount, TxData->FragmentCount,
IP4_MAX_HEADLEN, IP4_MAX_HEADLEN,
0, 0,
@ -1768,7 +1755,7 @@ EfiIp4Transmit (
// //
// Restore pointer of first fragment in RawData mode. // Restore pointer of first fragment in RawData mode.
// //
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment; TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
} }
NetbufFree (Wrap->Packet); NetbufFree (Wrap->Packet);
@ -1800,7 +1787,7 @@ EfiIp4Transmit (
// //
// Restore pointer of first fragment in RawData mode. // Restore pointer of first fragment in RawData mode.
// //
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment; TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
} }
NetbufFree (Wrap->Packet); NetbufFree (Wrap->Packet);
@ -1810,7 +1797,7 @@ EfiIp4Transmit (
// //
// Restore pointer of first fragment in RawData mode. // Restore pointer of first fragment in RawData mode.
// //
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment; TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
} }
ON_EXIT: ON_EXIT:
@ -1818,7 +1805,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Places a receiving request into the receiving queue. Places a receiving request into the receiving queue.
@ -1910,7 +1896,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Cancel the transmitted but not recycled packet. If a matching Cancel the transmitted but not recycled packet. If a matching
token is found, it will call Ip4CancelPacket to cancel the token is found, it will call Ip4CancelPacket to cancel the
@ -1939,7 +1924,7 @@ Ip4CancelTxTokens (
EFI_IP4_COMPLETION_TOKEN *Token; EFI_IP4_COMPLETION_TOKEN *Token;
IP4_TXTOKEN_WRAP *Wrap; IP4_TXTOKEN_WRAP *Wrap;
Token = (EFI_IP4_COMPLETION_TOKEN *) Context; Token = (EFI_IP4_COMPLETION_TOKEN *)Context;
// //
// Return EFI_SUCCESS to check the next item in the map if // Return EFI_SUCCESS to check the next item in the map if
@ -1949,7 +1934,7 @@ Ip4CancelTxTokens (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Wrap = (IP4_TXTOKEN_WRAP *) Item->Value; Wrap = (IP4_TXTOKEN_WRAP *)Item->Value;
ASSERT (Wrap != NULL); ASSERT (Wrap != NULL);
// //
@ -1969,7 +1954,6 @@ Ip4CancelTxTokens (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Cancel the receive request. This is quiet simple, because Cancel the receive request. This is quiet simple, because
it is only enqueued in our local receive map. it is only enqueued in our local receive map.
@ -1995,7 +1979,7 @@ Ip4CancelRxTokens (
EFI_IP4_COMPLETION_TOKEN *Token; EFI_IP4_COMPLETION_TOKEN *Token;
EFI_IP4_COMPLETION_TOKEN *This; EFI_IP4_COMPLETION_TOKEN *This;
Token = (EFI_IP4_COMPLETION_TOKEN *) Context; Token = (EFI_IP4_COMPLETION_TOKEN *)Context;
This = Item->Key; This = Item->Key;
if ((Token != NULL) && (Token != This)) { if ((Token != NULL) && (Token != This)) {
@ -2015,7 +1999,6 @@ Ip4CancelRxTokens (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Cancel the user's receive/transmit request. Cancel the user's receive/transmit request.
@ -2083,15 +2066,14 @@ Ip4Cancel (
// all of them are cancelled. // all of them are cancelled.
// //
if (!NetMapIsEmpty (&IpInstance->TxTokens) || if (!NetMapIsEmpty (&IpInstance->TxTokens) ||
!NetMapIsEmpty (&IpInstance->RxTokens)) { !NetMapIsEmpty (&IpInstance->RxTokens))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Abort an asynchronous transmit or receive request. Abort an asynchronous transmit or receive request.
@ -2157,7 +2139,6 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Polls for incoming data packets and processes outgoing data packets. Polls for incoming data packets and processes outgoing data packets.
@ -2237,7 +2218,7 @@ Ip4SentPacketTicking (
{ {
IP4_TXTOKEN_WRAP *Wrap; IP4_TXTOKEN_WRAP *Wrap;
Wrap = (IP4_TXTOKEN_WRAP *) Item->Value; Wrap = (IP4_TXTOKEN_WRAP *)Item->Value;
ASSERT (Wrap != NULL); ASSERT (Wrap != NULL);
if ((Wrap->Life > 0) && (--Wrap->Life == 0)) { if ((Wrap->Life > 0) && (--Wrap->Life == 0)) {
@ -2265,7 +2246,7 @@ Ip4TimerTicking (
{ {
IP4_SERVICE *IpSb; IP4_SERVICE *IpSb;
IpSb = (IP4_SERVICE *) Context; IpSb = (IP4_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE); NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
Ip4PacketTimerTicking (IpSb); Ip4PacketTimerTicking (IpSb);
@ -2296,7 +2277,7 @@ Ip4TimerReconfigChecking (
EFI_STATUS Status; EFI_STATUS Status;
EFI_SIMPLE_NETWORK_MODE SnpModeData; EFI_SIMPLE_NETWORK_MODE SnpModeData;
IpSb = (IP4_SERVICE *) Context; IpSb = (IP4_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE); NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
OldMediaPresent = IpSb->MediaPresent; OldMediaPresent = IpSb->MediaPresent;

View File

@ -74,7 +74,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define IP4_SERVICE_CONFIGED 2 #define IP4_SERVICE_CONFIGED 2
#define IP4_SERVICE_DESTROY 3 #define IP4_SERVICE_DESTROY 3
/// ///
/// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token. /// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.
/// The user's data is kept in the Packet. When fragment is /// The user's data is kept in the Packet. When fragment is
@ -120,7 +119,6 @@ typedef struct {
EFI_IP4_RECEIVE_DATA RxData; EFI_IP4_RECEIVE_DATA RxData;
} IP4_RXDATA_WRAP; } IP4_RXDATA_WRAP;
struct _IP4_PROTOCOL { struct _IP4_PROTOCOL {
UINT32 Signature; UINT32 Signature;
@ -161,7 +159,6 @@ struct _IP4_PROTOCOL {
UINT32 GroupCount; UINT32 GroupCount;
EFI_IP4_CONFIG_DATA ConfigData; EFI_IP4_CONFIG_DATA ConfigData;
}; };
struct _IP4_SERVICE { struct _IP4_SERVICE {
@ -230,7 +227,6 @@ struct _IP4_SERVICE {
#define IP4_SERVICE_FROM_CONFIG2_INSTANCE(This) \ #define IP4_SERVICE_FROM_CONFIG2_INSTANCE(This) \
CR (This, IP4_SERVICE, Ip4Config2Instance, IP4_SERVICE_SIGNATURE) CR (This, IP4_SERVICE, Ip4Config2Instance, IP4_SERVICE_SIGNATURE)
#define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured) #define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete; extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;

Some files were not shown because too many files have changed in this diff Show More