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:
committed by
mergify[bot]
parent
2f88bd3a12
commit
d1050b9dff
@ -116,7 +116,7 @@ NicNameToIndex (
|
||||
Str++;
|
||||
}
|
||||
|
||||
return (UINT16) StrDecimalToUintn (Name + 3);
|
||||
return (UINT16)StrDecimalToUintn (Name + 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,7 +177,7 @@ OpenVlanConfigProtocol (
|
||||
gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
(VOID **) &VlanConfig,
|
||||
(VOID **)&VlanConfig,
|
||||
mImageHandle,
|
||||
Handle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -227,7 +227,7 @@ ShowNicVlanInfo (
|
||||
|
||||
VlanConfig = OpenVlanConfigProtocol (Handle);
|
||||
if (VlanConfig == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
MacStr = NULL;
|
||||
@ -295,11 +295,11 @@ DisplayVlan (
|
||||
//
|
||||
NicHandle = NicNameToHandle (Name);
|
||||
if (NicHandle == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
ShowNicVlanInfo (NicHandle, 0);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -307,7 +307,7 @@ DisplayVlan (
|
||||
//
|
||||
LocateNicHandleBuffer (&NumberOfHandles, &HandleBuffer);
|
||||
if (NumberOfHandles == 0) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < NumberOfHandles; Index++) {
|
||||
@ -345,7 +345,7 @@ StrToVlanId (
|
||||
return INVALID_VLAN_ID;
|
||||
}
|
||||
|
||||
return (UINT16) StrDecimalToUintn (String);
|
||||
return (UINT16)StrDecimalToUintn (String);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -376,12 +376,12 @@ AddVlan (
|
||||
|
||||
if (ParamStr == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_IF), mHiiHandle);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
StrPtr = AllocateCopyPool (StrSize (ParamStr), ParamStr);
|
||||
if (StrPtr == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Name = StrPtr;
|
||||
@ -459,7 +459,7 @@ AddVlan (
|
||||
//
|
||||
// Set VLAN
|
||||
//
|
||||
Status = VlanConfig->Set (VlanConfig, (UINT16) VlanId, (UINT8) Priority);
|
||||
Status = VlanConfig->Set (VlanConfig, (UINT16)VlanId, (UINT8)Priority);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_SET_FAIL), mHiiHandle, Status);
|
||||
goto Exit;
|
||||
@ -468,7 +468,7 @@ AddVlan (
|
||||
//
|
||||
// Connect the VLAN device.
|
||||
//
|
||||
VlanHandle = NetLibGetVlanHandle (Handle, (UINT16) VlanId);
|
||||
VlanHandle = NetLibGetVlanHandle (Handle, (UINT16)VlanId);
|
||||
if (VlanHandle != NULL) {
|
||||
gBS->ConnectController (VlanHandle, NULL, NULL, TRUE);
|
||||
}
|
||||
@ -508,12 +508,12 @@ DeleteVlan (
|
||||
|
||||
if (ParamStr == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_IF), mHiiHandle);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
StrPtr = AllocateCopyPool (StrSize (ParamStr), ParamStr);
|
||||
if (StrPtr == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Name = StrPtr;
|
||||
@ -541,7 +541,7 @@ DeleteVlan (
|
||||
//
|
||||
// Check VLAN ID
|
||||
//
|
||||
if (VlanIdStr == NULL || *VlanIdStr == 0) {
|
||||
if ((VlanIdStr == NULL) || (*VlanIdStr == 0)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_VID), mHiiHandle);
|
||||
goto Exit;
|
||||
}
|
||||
@ -555,7 +555,7 @@ DeleteVlan (
|
||||
//
|
||||
// Delete VLAN.
|
||||
//
|
||||
Status = VlanConfig->Remove (VlanConfig, (UINT16) VlanId);
|
||||
Status = VlanConfig->Remove (VlanConfig, (UINT16)VlanId);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NOT_FOUND), mHiiHandle);
|
||||
@ -619,7 +619,7 @@ VlanConfigMain (
|
||||
Status = gBS->OpenProtocol (
|
||||
ImageHandle,
|
||||
&gEfiHiiPackageListProtocolGuid,
|
||||
(VOID **) &PackageList,
|
||||
(VOID **)&PackageList,
|
||||
ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -654,19 +654,19 @@ VlanConfigMain (
|
||||
|
||||
if (ShellCommandLineGetFlag (List, L"-l")) {
|
||||
Str = ShellCommandLineGetValue (List, L"-l");
|
||||
DisplayVlan ((CHAR16 *) Str);
|
||||
DisplayVlan ((CHAR16 *)Str);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if (ShellCommandLineGetFlag (List, L"-a")) {
|
||||
Str = ShellCommandLineGetValue (List, L"-a");
|
||||
AddVlan ((CHAR16 *) Str);
|
||||
AddVlan ((CHAR16 *)Str);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if (ShellCommandLineGetFlag (List, L"-d")) {
|
||||
Str = ShellCommandLineGetValue (List, L"-d");
|
||||
DeleteVlan ((CHAR16 *) Str);
|
||||
DeleteVlan ((CHAR16 *)Str);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = {
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Create and initialize the arp service context data.
|
||||
|
||||
@ -176,7 +175,6 @@ ERROR_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean the arp service context data.
|
||||
|
||||
@ -226,7 +224,7 @@ ArpCleanService (
|
||||
//
|
||||
// Destroy the mnp child.
|
||||
//
|
||||
NetLibDestroyServiceChild(
|
||||
NetLibDestroyServiceChild (
|
||||
ArpService->ControllerHandle,
|
||||
ArpService->ImageHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
@ -255,12 +253,12 @@ ArpDestroyChildEntryInHandleBuffer (
|
||||
ARP_INSTANCE_DATA *Instance;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
|
||||
if (Entry == NULL || Context == NULL) {
|
||||
if ((Entry == NULL) || (Context == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -334,7 +332,6 @@ ArpDriverBindingSupported (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle.
|
||||
|
||||
@ -380,7 +377,7 @@ ArpDriverBindingStart (
|
||||
//
|
||||
// Allocate a zero pool for ArpService.
|
||||
//
|
||||
ArpService = AllocateZeroPool (sizeof(ARP_SERVICE_DATA));
|
||||
ArpService = AllocateZeroPool (sizeof (ARP_SERVICE_DATA));
|
||||
if (ArpService == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -427,7 +424,6 @@ ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle.
|
||||
|
||||
@ -576,7 +572,7 @@ ArpServiceBindingCreateChild (
|
||||
//
|
||||
// Allocate memory for the instance context data.
|
||||
//
|
||||
Instance = AllocateZeroPool (sizeof(ARP_INSTANCE_DATA));
|
||||
Instance = AllocateZeroPool (sizeof (ARP_INSTANCE_DATA));
|
||||
if (Instance == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n"));
|
||||
|
||||
@ -615,7 +611,7 @@ ArpServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
ArpService->MnpChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
(VOID **) &Mnp,
|
||||
(VOID **)&Mnp,
|
||||
gArpDriverBinding.DriverBindingHandle,
|
||||
Instance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -637,7 +633,6 @@ ArpServiceBindingCreateChild (
|
||||
ERROR:
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
gBS->CloseProtocol (
|
||||
ArpService->MnpChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
@ -661,7 +656,6 @@ ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
@ -746,8 +740,11 @@ ArpServiceBindingDestroyChild (
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",
|
||||
Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",
|
||||
Status
|
||||
));
|
||||
|
||||
Instance->InDestroy = FALSE;
|
||||
return Status;
|
||||
|
@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _ARP_DRIVER_H_
|
||||
#define _ARP_DRIVER_H_
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/Arp.h>
|
||||
@ -21,7 +20,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
@ -32,6 +30,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2;
|
||||
//
|
||||
// Function prototypes for the Driver Binding Protocol
|
||||
//
|
||||
|
||||
/**
|
||||
Tests to see if this driver supports a given controller.
|
||||
|
||||
@ -199,10 +198,10 @@ ArpServiceBindingDestroyChild (
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -250,7 +249,6 @@ ArpComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -329,6 +327,4 @@ ArpComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -21,7 +21,6 @@ EFI_ARP_PROTOCOL mEfiArpProtocolTemplate = {
|
||||
ArpCancel
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Initialize the instance context data.
|
||||
|
||||
@ -51,7 +50,6 @@ ArpInitInstance (
|
||||
InitializeListHead (&Instance->List);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
//
|
||||
Head = (ARP_HEAD *) RxData->PacketData;
|
||||
Head = (ARP_HEAD *)RxData->PacketData;
|
||||
Head->HwType = NTOHS (Head->HwType);
|
||||
Head->ProtoType = NTOHS (Head->ProtoType);
|
||||
Head->OpCode = NTOHS (Head->OpCode);
|
||||
@ -130,7 +128,8 @@ ArpOnFrameRcvdDpc (
|
||||
|
||||
if ((Head->HwType != ArpService->SnpMode.IfType) ||
|
||||
(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.
|
||||
// There is a sanity check for the protocol type too.
|
||||
@ -183,7 +182,8 @@ ArpOnFrameRcvdDpc (
|
||||
|
||||
if ((Instance->Configured) &&
|
||||
(Head->ProtoType == ConfigData->SwAddressType) &&
|
||||
(Head->ProtoAddrLen == ConfigData->SwAddressLength)) {
|
||||
(Head->ProtoAddrLen == ConfigData->SwAddressLength))
|
||||
{
|
||||
//
|
||||
// The protocol type is matched for the received arp packet.
|
||||
//
|
||||
@ -192,7 +192,8 @@ ArpOnFrameRcvdDpc (
|
||||
(VOID *)ArpAddress.TargetProtoAddr,
|
||||
ConfigData->StationAddress,
|
||||
ConfigData->SwAddressLength
|
||||
)) {
|
||||
))
|
||||
{
|
||||
//
|
||||
// The arp driver has the target address required by the received arp packet.
|
||||
//
|
||||
@ -306,9 +307,14 @@ RESTART_RECEIVE:
|
||||
|
||||
DEBUG_CODE_BEGIN ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "ArpOnFrameRcvd: ArpService->Mnp->Receive "
|
||||
"failed, %r\n.", Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"ArpOnFrameRcvd: ArpService->Mnp->Receive "
|
||||
"failed, %r\n.",
|
||||
Status
|
||||
));
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
}
|
||||
|
||||
@ -362,6 +368,7 @@ ArpOnFrameSentDpc (
|
||||
if (EFI_ERROR (TxToken->Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status));
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
//
|
||||
@ -396,7 +403,6 @@ ArpOnFrameSent (
|
||||
QueueDpc (TPL_CALLBACK, ArpOnFrameSentDpc, Context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the arp cache olding and drive the retrying arp requests.
|
||||
|
||||
@ -449,7 +455,7 @@ ArpTimerHandler (
|
||||
//
|
||||
// resend the ARP request.
|
||||
//
|
||||
ASSERT (!IsListEmpty(&CacheEntry->UserRequestList));
|
||||
ASSERT (!IsListEmpty (&CacheEntry->UserRequestList));
|
||||
|
||||
ContextEntry = CacheEntry->UserRequestList.ForwardLink;
|
||||
RequestContext = NET_LIST_USER_STRUCT (ContextEntry, USER_REQUEST_CONTEXT, List);
|
||||
@ -524,7 +530,6 @@ ArpTimerHandler (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Match the two NET_ARP_ADDRESSes.
|
||||
|
||||
@ -543,7 +548,8 @@ ArpMatchAddress (
|
||||
ASSERT (AddressOne != NULL && AddressTwo != NULL);
|
||||
|
||||
if ((AddressOne->Type != AddressTwo->Type) ||
|
||||
(AddressOne->Length != AddressTwo->Length)) {
|
||||
(AddressOne->Length != AddressTwo->Length))
|
||||
{
|
||||
//
|
||||
// Either Type or Length doesn't match.
|
||||
//
|
||||
@ -555,7 +561,8 @@ ArpMatchAddress (
|
||||
AddressOne->AddressPtr,
|
||||
AddressTwo->AddressPtr,
|
||||
AddressOne->Length
|
||||
) != 0)) {
|
||||
) != 0))
|
||||
{
|
||||
//
|
||||
// The address is not the same.
|
||||
//
|
||||
@ -565,7 +572,6 @@ ArpMatchAddress (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the CacheEntry which matches the requirements in the specified CacheTable.
|
||||
|
||||
@ -637,7 +643,6 @@ ArpFindNextCacheEntryInTable (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the CacheEntry, using ProtocolAddress or HardwareAddress or both, as the keyword,
|
||||
in the DeniedCacheTable.
|
||||
@ -698,7 +703,6 @@ ArpFindDeniedCacheEntry (
|
||||
return CacheEntry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allocate a cache entry and initialize it.
|
||||
|
||||
@ -765,7 +769,6 @@ ArpAllocCacheEntry (
|
||||
return CacheEntry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Turn the CacheEntry into the resolved status.
|
||||
|
||||
@ -797,7 +800,8 @@ ArpAddressResolved (
|
||||
Context = NET_LIST_USER_STRUCT (Entry, USER_REQUEST_CONTEXT, List);
|
||||
|
||||
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.
|
||||
//
|
||||
@ -826,7 +830,6 @@ ArpAddressResolved (
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fill the addresses in the CacheEntry using the information passed in by
|
||||
HwAddr and SwAddr.
|
||||
@ -881,7 +884,6 @@ ArpFillAddressInCacheEntry (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Configure the instance using the ConfigData. ConfigData is already validated.
|
||||
|
||||
@ -912,7 +914,6 @@ ArpConfigureInstance (
|
||||
OldConfigData = &Instance->ConfigData;
|
||||
|
||||
if (ConfigData != NULL) {
|
||||
|
||||
if (Instance->Configured) {
|
||||
//
|
||||
// The instance is configured, check the unchangeable fields.
|
||||
@ -923,7 +924,8 @@ ArpConfigureInstance (
|
||||
OldConfigData->StationAddress,
|
||||
ConfigData->StationAddress,
|
||||
OldConfigData->SwAddressLength
|
||||
) != 0)) {
|
||||
) != 0))
|
||||
{
|
||||
//
|
||||
// Deny the unallowed changes.
|
||||
//
|
||||
@ -952,8 +954,11 @@ ArpConfigureInstance (
|
||||
|
||||
OldConfigData->StationAddress = AllocatePool (OldConfigData->SwAddressLength);
|
||||
if (OldConfigData->StationAddress == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "ArpConfigInstance: AllocatePool for the StationAddress "
|
||||
"failed.\n"));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"ArpConfigInstance: AllocatePool for the StationAddress "
|
||||
"failed.\n"
|
||||
));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@ -1006,7 +1011,6 @@ ArpConfigureInstance (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send out an arp frame using the CacheEntry and the ArpOpCode.
|
||||
|
||||
@ -1042,7 +1046,7 @@ ArpSendFrame (
|
||||
//
|
||||
// Allocate memory for the TxToken.
|
||||
//
|
||||
TxToken = AllocatePool (sizeof(EFI_MANAGED_NETWORK_COMPLETION_TOKEN));
|
||||
TxToken = AllocatePool (sizeof (EFI_MANAGED_NETWORK_COMPLETION_TOKEN));
|
||||
if (TxToken == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxToken failed.\n"));
|
||||
return;
|
||||
@ -1070,7 +1074,7 @@ ArpSendFrame (
|
||||
//
|
||||
// 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) {
|
||||
DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxData failed.\n"));
|
||||
goto CLEAN_EXIT;
|
||||
@ -1109,6 +1113,7 @@ ArpSendFrame (
|
||||
SnpMode->HwAddressSize
|
||||
);
|
||||
}
|
||||
|
||||
TmpPtr += SnpMode->HwAddressSize;
|
||||
|
||||
//
|
||||
@ -1126,7 +1131,7 @@ ArpSendFrame (
|
||||
//
|
||||
// The ARP Head.
|
||||
//
|
||||
ArpHead = (ARP_HEAD *) TmpPtr;
|
||||
ArpHead = (ARP_HEAD *)TmpPtr;
|
||||
ArpHead->HwType = HTONS ((UINT16)SnpMode->IfType);
|
||||
ArpHead->ProtoType = HTONS (ConfigData->SwAddressType);
|
||||
ArpHead->HwAddrLen = (UINT8)SnpMode->HwAddressSize;
|
||||
@ -1172,7 +1177,7 @@ ArpSendFrame (
|
||||
TxData->SourceAddress = NULL;
|
||||
TxData->ProtocolType = 0;
|
||||
TxData->DataLength = TotalLength - SnpMode->MediaHeaderSize;
|
||||
TxData->HeaderLength = (UINT16) SnpMode->MediaHeaderSize;
|
||||
TxData->HeaderLength = (UINT16)SnpMode->MediaHeaderSize;
|
||||
TxData->FragmentCount = 1;
|
||||
|
||||
TxData->FragmentTable[0].FragmentBuffer = Packet;
|
||||
@ -1212,7 +1217,6 @@ CLEAN_EXIT:
|
||||
FreePool (TxToken);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Delete the cache entries in the specified CacheTable, using the BySwAddress,
|
||||
SwAddressType, AddressBuffer combination as the matching key, if Force is TRUE,
|
||||
@ -1265,7 +1269,8 @@ ArpDeleteCacheEntryInTable (
|
||||
AddressBuffer,
|
||||
CacheEntry->Addresses[Protocol].AddressPtr,
|
||||
CacheEntry->Addresses[Protocol].Length
|
||||
) == 0)) {
|
||||
) == 0))
|
||||
{
|
||||
//
|
||||
// Address matched.
|
||||
//
|
||||
@ -1278,7 +1283,8 @@ ArpDeleteCacheEntryInTable (
|
||||
AddressBuffer,
|
||||
CacheEntry->Addresses[Hardware].AddressPtr,
|
||||
CacheEntry->Addresses[Hardware].Length
|
||||
) == 0)) {
|
||||
) == 0))
|
||||
{
|
||||
//
|
||||
// Address matched.
|
||||
//
|
||||
@ -1303,7 +1309,6 @@ MATCHED:
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Delete cache entries in all the cache tables.
|
||||
|
||||
@ -1357,7 +1362,6 @@ ArpDeleteCacheEntry (
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Cancel the arp request.
|
||||
|
||||
@ -1396,7 +1400,8 @@ ArpCancelRequest (
|
||||
TargetSwAddress,
|
||||
CacheEntry->Addresses[Protocol].AddressPtr,
|
||||
CacheEntry->Addresses[Protocol].Length
|
||||
) == 0)) {
|
||||
) == 0))
|
||||
{
|
||||
//
|
||||
// This request entry matches the TargetSwAddress or all requests are to be
|
||||
// cancelled as TargetSwAddress is NULL.
|
||||
@ -1416,7 +1421,6 @@ ArpCancelRequest (
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the cache entry in the cache table.
|
||||
|
||||
@ -1572,7 +1576,7 @@ ArpFindCacheEntry (
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
FoundCount = (UINT32) NetMapGetCount (&FoundEntries);
|
||||
FoundCount = (UINT32)NetMapGetCount (&FoundEntries);
|
||||
if (FoundCount == 0) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto CLEAN_EXIT;
|
||||
|
@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _ARP_IMPL_H_
|
||||
#define _ARP_IMPL_H_
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/Arp.h>
|
||||
|
@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "ArpImpl.h"
|
||||
|
||||
|
||||
/**
|
||||
This function is used to assign a station address to the ARP cache for this instance
|
||||
of the ARP driver.
|
||||
@ -55,7 +54,8 @@ ArpConfigure (
|
||||
if ((ConfigData != NULL) &&
|
||||
((ConfigData->SwAddressLength == 0) ||
|
||||
(ConfigData->StationAddress == NULL) ||
|
||||
(ConfigData->SwAddressType <= 1500))) {
|
||||
(ConfigData->SwAddressType <= 1500)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -73,7 +73,6 @@ ArpConfigure (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function is used to insert entries into the ARP cache.
|
||||
|
||||
@ -144,7 +143,8 @@ ArpAdd (
|
||||
|
||||
if (((!DenyFlag) && ((TargetHwAddress == NULL) || (TargetSwAddress == NULL))) ||
|
||||
(DenyFlag && (TargetHwAddress != NULL) && (TargetSwAddress != NULL)) ||
|
||||
((TargetHwAddress == NULL) && (TargetSwAddress == NULL))) {
|
||||
((TargetHwAddress == NULL) && (TargetSwAddress == NULL)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ ArpAdd (
|
||||
// Fill the hardware address part in the MatchAddress.
|
||||
//
|
||||
MatchAddress[Hardware].Type = SnpMode->IfType;
|
||||
MatchAddress[Hardware].Length = (UINT8) SnpMode->HwAddressSize;
|
||||
MatchAddress[Hardware].Length = (UINT8)SnpMode->HwAddressSize;
|
||||
MatchAddress[Hardware].AddressPtr = TargetHwAddress;
|
||||
|
||||
//
|
||||
@ -271,7 +271,6 @@ UNLOCK_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function searches the ARP cache for matching entries and allocates a buffer into
|
||||
which those entries are copied.
|
||||
@ -324,7 +323,8 @@ ArpFind (
|
||||
|
||||
if ((This == NULL) ||
|
||||
(!Refresh && (EntryCount == NULL) && (EntryLength == NULL)) ||
|
||||
((Entries != NULL) && ((EntryLength == NULL) || (EntryCount == NULL)))) {
|
||||
((Entries != NULL) && ((EntryLength == NULL) || (EntryCount == NULL))))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -354,7 +354,6 @@ ArpFind (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function removes specified ARP cache entries.
|
||||
|
||||
@ -406,7 +405,6 @@ ArpDelete (
|
||||
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function delete all dynamic entries from the ARP cache that match the specified
|
||||
software protocol type.
|
||||
@ -451,7 +449,6 @@ ArpFlush (
|
||||
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function tries to resolve the TargetSwAddress and optionally returns a
|
||||
TargetHwAddress if it already exists in the ARP cache.
|
||||
@ -509,7 +506,8 @@ ArpRequest (
|
||||
|
||||
if ((TargetSwAddress == NULL) ||
|
||||
((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) &&
|
||||
IP4_IS_LOCAL_BROADCAST (*((UINT32 *)TargetSwAddress)))) {
|
||||
IP4_IS_LOCAL_BROADCAST (*((UINT32 *)TargetSwAddress))))
|
||||
{
|
||||
//
|
||||
// Return the hardware broadcast address.
|
||||
//
|
||||
@ -519,7 +517,8 @@ ArpRequest (
|
||||
}
|
||||
|
||||
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
|
||||
// resolve the address.
|
||||
@ -588,7 +587,7 @@ ArpRequest (
|
||||
//
|
||||
// Create a request context for this arp request.
|
||||
//
|
||||
RequestContext = AllocatePool (sizeof(USER_REQUEST_CONTEXT));
|
||||
RequestContext = AllocatePool (sizeof (USER_REQUEST_CONTEXT));
|
||||
if (RequestContext == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "ArpRequest: Allocate memory for RequestContext failed.\n"));
|
||||
|
||||
@ -612,7 +611,6 @@ ArpRequest (
|
||||
NULL
|
||||
);
|
||||
if (CacheEntry != NULL) {
|
||||
|
||||
CacheEntry->NextRetryTime = Instance->ConfigData.RetryTimeOut;
|
||||
CacheEntry->RetryCount = Instance->ConfigData.RetryCount;
|
||||
} else {
|
||||
@ -668,7 +666,6 @@ SIGNAL_USER:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function aborts the previous ARP request (identified by This, TargetSwAddress
|
||||
and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().
|
||||
@ -710,7 +707,8 @@ ArpCancel (
|
||||
|
||||
if ((This == NULL) ||
|
||||
((TargetSwAddress != NULL) && (ResolvedEvent == NULL)) ||
|
||||
((TargetSwAddress == NULL) && (ResolvedEvent != NULL))) {
|
||||
((TargetSwAddress == NULL) && (ResolvedEvent != NULL)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "ArpDriver.h"
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -22,12 +21,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gArpComponentName = {
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ArpComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ArpComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)ArpComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)ArpComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = {
|
||||
{ "eng;en", L"ARP Network Service Driver" },
|
||||
{ NULL, NULL }
|
||||
|
@ -5,12 +5,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Dhcp4Impl.h"
|
||||
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -58,7 +58,6 @@ DhcpComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -137,7 +136,6 @@ DhcpComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -151,12 +149,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName =
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) DhcpComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) DhcpComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)DhcpComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)DhcpComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
|
@ -53,7 +53,6 @@ Dhcp4DriverEntryPoint (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. This service
|
||||
is called by the EFI boot service ConnectController(). In
|
||||
@ -94,8 +93,6 @@ Dhcp4DriverBindingSupported (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Configure the default UDP child to receive all the DHCP traffics
|
||||
on this network interface.
|
||||
@ -134,11 +131,9 @@ DhcpConfigUdpIo (
|
||||
ZeroMem (&UdpConfigData.SubnetMask, 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,
|
||||
or partly destroyed. If a resource is destroyed, it is marked as so in
|
||||
@ -171,8 +166,6 @@ Dhcp4CloseService (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Create a new DHCP service binding instance for the controller.
|
||||
|
||||
@ -244,7 +237,7 @@ Dhcp4CreateService (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
DhcpSb->HwLen = (UINT8) DhcpSb->UdpIo->SnpMode.HwAddressSize;
|
||||
DhcpSb->HwLen = (UINT8)DhcpSb->UdpIo->SnpMode.HwAddressSize;
|
||||
DhcpSb->HwType = DhcpSb->UdpIo->SnpMode.IfType;
|
||||
CopyMem (&DhcpSb->Mac, &DhcpSb->UdpIo->SnpMode.CurrentAddress, sizeof (DhcpSb->Mac));
|
||||
|
||||
@ -258,7 +251,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service ConnectController(). In order to make
|
||||
@ -309,6 +301,7 @@ Dhcp4DriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (DhcpSb != NULL);
|
||||
|
||||
//
|
||||
@ -319,6 +312,7 @@ Dhcp4DriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Status = gBS->SetTimer (DhcpSb->Timer, TimerPeriodic, TICKS_PER_SECOND);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -367,17 +361,16 @@ Dhcp4DestroyChildEntry (
|
||||
DHCP_PROTOCOL *Instance;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
|
||||
if (Entry == NULL || Context == NULL) {
|
||||
if ((Entry == NULL) || (Context == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service DisconnectController(). In order to
|
||||
@ -425,7 +418,7 @@ Dhcp4DriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiDhcp4ServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
NicHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -447,16 +440,16 @@ Dhcp4DriverBindingStop (
|
||||
ServiceBinding,
|
||||
&ListLength
|
||||
);
|
||||
if (EFI_ERROR (Status) || ListLength != 0) {
|
||||
if (EFI_ERROR (Status) || (ListLength != 0)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (NumberOfChildren == 0 && !IsListEmpty (&DhcpSb->Children)) {
|
||||
if ((NumberOfChildren == 0) && !IsListEmpty (&DhcpSb->Children)) {
|
||||
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.
|
||||
//
|
||||
@ -474,6 +467,7 @@ Dhcp4DriverBindingStop (
|
||||
FreeUnicodeStringTable (gDhcpControllerNameTable);
|
||||
gDhcpControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
FreePool (DhcpSb);
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
@ -482,7 +476,6 @@ Dhcp4DriverBindingStop (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize a new DHCP instance.
|
||||
|
||||
@ -510,7 +503,6 @@ DhcpInitProtocol (
|
||||
NetbufQueInit (&Instance->ResponseQueue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
@ -579,7 +571,7 @@ Dhcp4ServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
DhcpSb->UdpIo->UdpHandle,
|
||||
&gEfiUdp4ProtocolGuid,
|
||||
(VOID **) &Udp4,
|
||||
(VOID **)&Udp4,
|
||||
gDhcp4DriverBinding.DriverBindingHandle,
|
||||
Instance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -606,7 +598,6 @@ Dhcp4ServiceBindingCreateChild (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
@ -648,7 +639,7 @@ Dhcp4ServiceBindingDestroyChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiDhcp4ProtocolGuid,
|
||||
(VOID **) &Dhcp,
|
||||
(VOID **)&Dhcp,
|
||||
gDhcp4DriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
|
@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Dhcp4Impl.h"
|
||||
|
||||
/**
|
||||
@ -374,7 +373,7 @@ EfiDhcp4GetModeData (
|
||||
// Caller can use GetModeData to retrieve current DHCP states
|
||||
// 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->ClientMacAddress, &DhcpSb->Mac, sizeof (Dhcp4ModeData->ClientMacAddress));
|
||||
|
||||
@ -404,7 +403,6 @@ EfiDhcp4GetModeData (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the resource related to the configure parameters.
|
||||
DHCP driver will make a copy of the user's configure
|
||||
@ -441,7 +439,6 @@ DhcpCleanConfigure (
|
||||
ZeroMem (Config, sizeof (EFI_DHCP4_CONFIG_DATA));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allocate memory for configure parameter such as timeout value for Dst,
|
||||
then copy the configure parameter from Src to Dst.
|
||||
@ -536,7 +533,6 @@ ON_ERROR:
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Give up the control of the DHCP service to let other child
|
||||
resume. Don't change the service's DHCP state and the Client
|
||||
@ -575,7 +571,6 @@ DhcpYieldControl (
|
||||
Config->CallbackContext = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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));
|
||||
if (IP4_IS_LOCAL_BROADCAST(NTOHL (Ip))) {
|
||||
if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
@ -675,8 +670,8 @@ EfiDhcp4Configure (
|
||||
if ((DhcpSb->DhcpState != Dhcp4Stopped) &&
|
||||
(DhcpSb->DhcpState != Dhcp4Init) &&
|
||||
(DhcpSb->DhcpState != Dhcp4InitReboot) &&
|
||||
(DhcpSb->DhcpState != Dhcp4Bound)) {
|
||||
|
||||
(DhcpSb->DhcpState != Dhcp4Bound))
|
||||
{
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -712,7 +707,6 @@ EfiDhcp4Configure (
|
||||
|
||||
DhcpSb->ServiceState = DHCP_CONFIGED;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
} else if (DhcpSb->ActiveChild == Instance) {
|
||||
Status = EFI_SUCCESS;
|
||||
DhcpYieldControl (DhcpSb);
|
||||
@ -723,7 +717,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starts the DHCP configuration process.
|
||||
|
||||
@ -820,7 +813,6 @@ EfiDhcp4Start (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
|
||||
Instance->CompletionEvent = CompletionEvent;
|
||||
|
||||
//
|
||||
@ -843,7 +835,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extends the lease time by sending a request packet.
|
||||
|
||||
@ -946,7 +937,7 @@ EfiDhcp4RenewRebind (
|
||||
DhcpSb->Selected,
|
||||
DhcpSb->Para,
|
||||
DHCP_MSG_REQUEST,
|
||||
(UINT8 *) "Extra renew/rebind by the application"
|
||||
(UINT8 *)"Extra renew/rebind by the application"
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -963,7 +954,6 @@ EfiDhcp4RenewRebind (
|
||||
if (CompletionEvent == NULL) {
|
||||
while (DhcpSb->IoStatus == EFI_ALREADY_STARTED) {
|
||||
DhcpSb->UdpIo->Protocol.Udp4->Poll (DhcpSb->UdpIo->Protocol.Udp4);
|
||||
|
||||
}
|
||||
|
||||
return DhcpSb->IoStatus;
|
||||
@ -976,7 +966,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Releases the current address configuration.
|
||||
|
||||
@ -1053,7 +1042,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stops the current address configuration.
|
||||
|
||||
@ -1104,7 +1092,6 @@ EfiDhcp4Stop (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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) ||
|
||||
EFI_ERROR (DhcpValidateOptions (SeedPacket, NULL))) {
|
||||
|
||||
EFI_ERROR (DhcpValidateOptions (SeedPacket, NULL)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (((DeleteCount == 0) && (AppendCount == 0)) ||
|
||||
((DeleteCount != 0) && (DeleteList == NULL)) ||
|
||||
((AppendCount != 0) && (AppendList == NULL))) {
|
||||
|
||||
((AppendCount != 0) && (AppendList == NULL)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1201,7 +1188,7 @@ Dhcp4InstanceConfigUdpIo (
|
||||
INTN Class;
|
||||
IP4_ADDR SubnetMask;
|
||||
|
||||
Instance = (DHCP_PROTOCOL *) Context;
|
||||
Instance = (DHCP_PROTOCOL *)Context;
|
||||
DhcpSb = Instance->Service;
|
||||
Token = Instance->Token;
|
||||
|
||||
@ -1284,7 +1271,7 @@ Dhcp4InstanceCreateUdpIo (
|
||||
Status = gBS->OpenProtocol (
|
||||
Instance->UdpIo->UdpHandle,
|
||||
&gEfiUdp4ProtocolGuid,
|
||||
(VOID **) &Udp4,
|
||||
(VOID **)&Udp4,
|
||||
Instance->Service->Image,
|
||||
Instance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1293,6 +1280,7 @@ Dhcp4InstanceCreateUdpIo (
|
||||
UdpIoFreeIo (Instance->UdpIo);
|
||||
Instance->UdpIo = NULL;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
@ -1341,14 +1329,14 @@ PxeDhcpInput (
|
||||
EFI_STATUS Status;
|
||||
|
||||
Wrap = NULL;
|
||||
Instance = (DHCP_PROTOCOL *) Context;
|
||||
Instance = (DHCP_PROTOCOL *)Context;
|
||||
Token = Instance->Token;
|
||||
|
||||
//
|
||||
// Don't restart receive if error occurs or DHCP is destroyed.
|
||||
//
|
||||
if (EFI_ERROR (IoStatus)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (UdpPacket != NULL);
|
||||
@ -1370,12 +1358,12 @@ PxeDhcpInput (
|
||||
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);
|
||||
|
||||
Packet->Size = Len;
|
||||
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) {
|
||||
goto RESTART;
|
||||
@ -1386,7 +1374,8 @@ PxeDhcpInput (
|
||||
//
|
||||
if ((Head->OpCode != BOOTP_REPLY) ||
|
||||
(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;
|
||||
}
|
||||
|
||||
@ -1395,8 +1384,8 @@ PxeDhcpInput (
|
||||
//
|
||||
if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) &&
|
||||
(Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) &&
|
||||
EFI_ERROR (DhcpValidateOptions (Packet, NULL))) {
|
||||
|
||||
EFI_ERROR (DhcpValidateOptions (Packet, NULL)))
|
||||
{
|
||||
goto RESTART;
|
||||
}
|
||||
|
||||
@ -1437,7 +1426,7 @@ PxeDhcpDone (
|
||||
|
||||
Token->ResponseCount = Instance->ResponseQueue.BufNum;
|
||||
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) {
|
||||
Token->Status = EFI_OUT_OF_RESOURCES;
|
||||
goto SIGNAL_USER;
|
||||
@ -1446,7 +1435,7 @@ PxeDhcpDone (
|
||||
//
|
||||
// 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;
|
||||
} else {
|
||||
Token->ResponseList = NULL;
|
||||
@ -1474,7 +1463,6 @@ SIGNAL_USER:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Transmits a DHCP formatted packet and optionally waits for responses.
|
||||
|
||||
@ -1532,7 +1520,8 @@ EfiDhcp4TransmitReceive (
|
||||
((Token->ListenPointCount != 0) && (Token->ListenPoints == NULL)) ||
|
||||
EFI_ERROR (DhcpValidateOptions (Token->Packet, NULL)) ||
|
||||
EFI_IP4_EQUAL (&Token->RemoteAddress, &mZeroIp4Addr)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// The DHCP packet isn't well-formed, the Transaction ID is already used,
|
||||
// the timeout value is zero, the ListenPoint is invalid, or the
|
||||
@ -1575,7 +1564,7 @@ EfiDhcp4TransmitReceive (
|
||||
//
|
||||
// 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;
|
||||
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
|
||||
if (Wrap == NULL) {
|
||||
@ -1667,7 +1656,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Callback function for DhcpIterateOptions. This callback sets the
|
||||
EFI_DHCP4_PACKET_OPTION array in the DHCP_PARSE_CONTEXT to point
|
||||
@ -1691,7 +1679,7 @@ Dhcp4ParseCheckOption (
|
||||
{
|
||||
DHCP_PARSE_CONTEXT *Parse;
|
||||
|
||||
Parse = (DHCP_PARSE_CONTEXT *) Context;
|
||||
Parse = (DHCP_PARSE_CONTEXT *)Context;
|
||||
Parse->Index++;
|
||||
|
||||
if (Parse->Index <= Parse->OptionCount) {
|
||||
@ -1706,7 +1694,6 @@ Dhcp4ParseCheckOption (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parses the packed DHCP option data.
|
||||
|
||||
@ -1755,8 +1742,8 @@ EfiDhcp4Parse (
|
||||
|
||||
if ((Packet->Size < Packet->Length + 2 * sizeof (UINT32)) ||
|
||||
(Packet->Dhcp4.Magik != DHCP_OPTION_MAGIC) ||
|
||||
EFI_ERROR (DhcpValidateOptions (Packet, NULL))) {
|
||||
|
||||
EFI_ERROR (DhcpValidateOptions (Packet, NULL)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1798,5 +1785,5 @@ SetElapsedTime (
|
||||
IN DHCP_PROTOCOL *Instance
|
||||
)
|
||||
{
|
||||
WriteUnaligned16 (Elapsed, HTONS(Instance->ElaspedTime));
|
||||
WriteUnaligned16 (Elapsed, HTONS (Instance->ElaspedTime));
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef __EFI_DHCP4_IMPL_H__
|
||||
#define __EFI_DHCP4_IMPL_H__
|
||||
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/Dhcp4.h>
|
||||
@ -50,7 +48,6 @@ typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
|
||||
#define DHCP_CONFIGED 1
|
||||
#define DHCP_DESTROY 2
|
||||
|
||||
|
||||
struct _DHCP_PROTOCOL {
|
||||
UINT32 Signature;
|
||||
EFI_DHCP4_PROTOCOL Dhcp4Protocol;
|
||||
|
@ -6,12 +6,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Dhcp4Impl.h"
|
||||
|
||||
UINT32 mDhcp4DefaultTimeout[4] = { 4, 8, 16, 32 };
|
||||
|
||||
|
||||
/**
|
||||
Send an initial DISCOVER or REQUEST message according to the
|
||||
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.
|
||||
//
|
||||
DhcpSb->ActiveChild->ElaspedTime= 0;
|
||||
DhcpSb->ActiveChild->ElaspedTime = 0;
|
||||
|
||||
if (DhcpSb->DhcpState == Dhcp4Init) {
|
||||
DhcpSetState (DhcpSb, Dhcp4Selecting, FALSE);
|
||||
@ -57,7 +55,6 @@ DhcpInitRequest (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Call user provided callback function, and return the value the
|
||||
function returns. If the user doesn't provide a callback, a
|
||||
@ -109,7 +106,7 @@ DhcpCallUser (
|
||||
Status = Config->Dhcp4Callback (
|
||||
&DhcpSb->ActiveChild->Dhcp4Protocol,
|
||||
Config->CallbackContext,
|
||||
(EFI_DHCP4_STATE) DhcpSb->DhcpState,
|
||||
(EFI_DHCP4_STATE)DhcpSb->DhcpState,
|
||||
Event,
|
||||
Packet,
|
||||
NewPacket
|
||||
@ -127,7 +124,6 @@ DhcpCallUser (
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Notify the user about the operation result.
|
||||
|
||||
@ -144,28 +140,26 @@ DhcpNotifyUser (
|
||||
DHCP_PROTOCOL *Child;
|
||||
|
||||
if ((Child = DhcpSb->ActiveChild) == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Child->CompletionEvent != NULL) &&
|
||||
((Which == DHCP_NOTIFY_COMPLETION) || (Which == DHCP_NOTIFY_ALL))
|
||||
) {
|
||||
|
||||
)
|
||||
{
|
||||
gBS->SignalEvent (Child->CompletionEvent);
|
||||
Child->CompletionEvent = NULL;
|
||||
}
|
||||
|
||||
if ((Child->RenewRebindEvent != NULL) &&
|
||||
((Which == DHCP_NOTIFY_RENEWREBIND) || (Which == DHCP_NOTIFY_ALL))
|
||||
) {
|
||||
|
||||
)
|
||||
{
|
||||
gBS->SignalEvent (Child->RenewRebindEvent);
|
||||
Child->RenewRebindEvent = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Set the DHCP state. If CallUser is true, it will try to notify
|
||||
the user before change the state by DhcpNotifyUser. It returns
|
||||
@ -195,13 +189,10 @@ DhcpSetState (
|
||||
|
||||
if (State == Dhcp4Renewing) {
|
||||
Status = DhcpCallUser (DhcpSb, Dhcp4EnterRenewing, NULL, NULL);
|
||||
|
||||
} else if (State == Dhcp4Rebinding) {
|
||||
Status = DhcpCallUser (DhcpSb, Dhcp4EnterRebinding, NULL, NULL);
|
||||
|
||||
} else if (State == Dhcp4Bound) {
|
||||
Status = DhcpCallUser (DhcpSb, Dhcp4BoundCompleted, NULL, NULL);
|
||||
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -231,7 +222,6 @@ DhcpSetState (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the retransmit timer for the packet. It will select from either
|
||||
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.
|
||||
DHCP driver needs this port to unicast packet to the server
|
||||
@ -325,7 +314,7 @@ DhcpConfigLeaseIoPort (
|
||||
EFI_STATUS Status;
|
||||
IP4_ADDR Ip;
|
||||
|
||||
DhcpSb = (DHCP_SERVICE *) Context;
|
||||
DhcpSb = (DHCP_SERVICE *)Context;
|
||||
|
||||
UdpConfigData.AcceptBroadcast = FALSE;
|
||||
UdpConfigData.AcceptPromiscuous = FALSE;
|
||||
@ -370,7 +359,6 @@ DhcpConfigLeaseIoPort (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -426,7 +414,6 @@ DhcpLeaseAcquired (
|
||||
return DhcpSetState (DhcpSb, Dhcp4Bound, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up the DHCP related states, IoStatus isn't reset.
|
||||
|
||||
@ -486,7 +473,6 @@ DhcpCleanLease (
|
||||
DhcpCleanConfigure (&DhcpSb->ActiveConfig);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -524,7 +510,7 @@ DhcpChooseOffer (
|
||||
Selected = DhcpSb->LastOffer;
|
||||
|
||||
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) {
|
||||
CopyMem (TempPacket, NewPacket, NewPacket->Size);
|
||||
FreePool (Selected);
|
||||
@ -565,7 +551,6 @@ DhcpChooseOffer (
|
||||
return DhcpSendMessage (DhcpSb, Selected, DhcpSb->Para, DHCP_MSG_REQUEST, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Terminate the current address acquire. All the allocated resources
|
||||
are released. Be careful when calling this function. A rule related
|
||||
@ -594,7 +579,6 @@ DhcpEndSession (
|
||||
DhcpNotifyUser (DhcpSb, DHCP_NOTIFY_ALL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle packets in DHCP select state.
|
||||
|
||||
@ -626,7 +610,8 @@ DhcpHandleSelect (
|
||||
//
|
||||
if (!DHCP_IS_BOOTP (Para) &&
|
||||
((Para->DhcpType != DHCP_MSG_OFFER) || (Para->ServerId == 0))
|
||||
) {
|
||||
)
|
||||
{
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -646,14 +631,12 @@ DhcpHandleSelect (
|
||||
DhcpSb->LastOffer = Packet;
|
||||
|
||||
return DhcpChooseOffer (DhcpSb);
|
||||
|
||||
} else if (Status == EFI_NOT_READY) {
|
||||
if (DhcpSb->LastOffer != NULL) {
|
||||
FreePool (DhcpSb->LastOffer);
|
||||
}
|
||||
|
||||
DhcpSb->LastOffer = Packet;
|
||||
|
||||
} else if (Status == EFI_ABORTED) {
|
||||
//
|
||||
// DhcpInput will end the session upon error return. Remember
|
||||
@ -669,7 +652,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle packets in DHCP request state.
|
||||
|
||||
@ -705,8 +687,8 @@ DhcpHandleRequest (
|
||||
if (DHCP_IS_BOOTP (Para) ||
|
||||
(Para->ServerId != DhcpSb->Para->ServerId) ||
|
||||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
|
||||
) {
|
||||
|
||||
)
|
||||
{
|
||||
Status = EFI_SUCCESS;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -727,14 +709,14 @@ DhcpHandleRequest (
|
||||
Message = NULL;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Status = DhcpCallUser (DhcpSb, Dhcp4RcvdAck, Packet, NULL);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
Message = (UINT8 *) "Lease is denied upon received ACK";
|
||||
Message = (UINT8 *)"Lease is denied upon received ACK";
|
||||
goto REJECT;
|
||||
}
|
||||
|
||||
@ -744,7 +726,7 @@ DhcpHandleRequest (
|
||||
Status = DhcpLeaseAcquired (DhcpSb);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
Message = (UINT8 *) "Lease is denied upon entering bound";
|
||||
Message = (UINT8 *)"Lease is denied upon entering bound";
|
||||
goto REJECT;
|
||||
}
|
||||
|
||||
@ -762,7 +744,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle packets in DHCP renew/rebound state.
|
||||
|
||||
@ -797,8 +778,8 @@ DhcpHandleRenewRebind (
|
||||
if (DHCP_IS_BOOTP (Para) ||
|
||||
(Para->ServerId != DhcpSb->Para->ServerId) ||
|
||||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
|
||||
) {
|
||||
|
||||
)
|
||||
{
|
||||
Status = EFI_SUCCESS;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -846,7 +827,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle packets in DHCP reboot state.
|
||||
|
||||
@ -876,8 +856,8 @@ DhcpHandleReboot (
|
||||
//
|
||||
if (DHCP_IS_BOOTP (Para) ||
|
||||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
|
||||
) {
|
||||
|
||||
)
|
||||
{
|
||||
Status = EFI_SUCCESS;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -932,7 +912,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle the received DHCP packets. This function drives the DHCP
|
||||
state machine.
|
||||
@ -960,16 +939,16 @@ DhcpInput (
|
||||
UINT32 Len;
|
||||
|
||||
Packet = NULL;
|
||||
DhcpSb = (DHCP_SERVICE *) Context;
|
||||
DhcpSb = (DHCP_SERVICE *)Context;
|
||||
|
||||
//
|
||||
// Don't restart receive if error occurs or DHCP is destroyed.
|
||||
//
|
||||
if (EFI_ERROR (IoStatus)) {
|
||||
return ;
|
||||
return;
|
||||
} else if (DhcpSb->ServiceState == DHCP_DESTROY) {
|
||||
NetbufFree (UdpPacket);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (UdpPacket != NULL);
|
||||
@ -989,7 +968,7 @@ DhcpInput (
|
||||
// Copy the DHCP message to a continuous memory block
|
||||
//
|
||||
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) {
|
||||
goto RESTART;
|
||||
@ -997,7 +976,7 @@ DhcpInput (
|
||||
|
||||
Packet->Size = Len;
|
||||
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) {
|
||||
goto RESTART;
|
||||
@ -1008,7 +987,8 @@ DhcpInput (
|
||||
//
|
||||
if ((Head->OpCode != BOOTP_REPLY) ||
|
||||
(NTOHL (Head->Xid) != DhcpSb->Xid) ||
|
||||
(CompareMem (DhcpSb->ClientAddressSendOut, Head->ClientHwAddr, Head->HwAddrLen) != 0)) {
|
||||
(CompareMem (DhcpSb->ClientAddressSendOut, Head->ClientHwAddr, Head->HwAddrLen) != 0))
|
||||
{
|
||||
goto RESTART;
|
||||
}
|
||||
|
||||
@ -1018,8 +998,8 @@ DhcpInput (
|
||||
Para = NULL;
|
||||
if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) &&
|
||||
(Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) &&
|
||||
EFI_ERROR (DhcpValidateOptions (Packet, &Para))) {
|
||||
|
||||
EFI_ERROR (DhcpValidateOptions (Packet, &Para)))
|
||||
{
|
||||
goto RESTART;
|
||||
}
|
||||
|
||||
@ -1073,7 +1053,7 @@ DhcpInput (
|
||||
NetbufFree (UdpPacket);
|
||||
UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0);
|
||||
DhcpEndSession (DhcpSb, Status);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
RESTART:
|
||||
@ -1111,8 +1091,6 @@ DhcpOnPacketSent (
|
||||
NetbufFree (Packet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Build and transmit a DHCP message according to the current states.
|
||||
This function implement the Table 5. of RFC 2131. Always transits
|
||||
@ -1163,7 +1141,7 @@ DhcpSendMessage (
|
||||
Len = sizeof (EFI_DHCP4_PACKET) + 128 + DhcpSb->UserOptionLen;
|
||||
|
||||
if (Msg != NULL) {
|
||||
Len += (UINT32)AsciiStrLen ((CHAR8 *) Msg);
|
||||
Len += (UINT32)AsciiStrLen ((CHAR8 *)Msg);
|
||||
}
|
||||
|
||||
Packet = AllocatePool (Len);
|
||||
@ -1192,7 +1170,7 @@ DhcpSendMessage (
|
||||
Head->HwType = DhcpSb->HwType;
|
||||
Head->HwAddrLen = DhcpSb->HwLen;
|
||||
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);
|
||||
CopyMem (Head->ClientHwAddr, DhcpSb->Mac.Addr, DhcpSb->HwLen);
|
||||
@ -1205,7 +1183,7 @@ DhcpSendMessage (
|
||||
//
|
||||
Head->Seconds = DhcpSb->LastPacket->Dhcp4.Header.Seconds;
|
||||
} 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) ||
|
||||
((Type == DHCP_MSG_REQUEST) && (DhcpSb->DhcpState == Dhcp4Requesting))
|
||||
) {
|
||||
|
||||
)
|
||||
{
|
||||
ASSERT ((Para != NULL) && (Para->ServerId != 0));
|
||||
|
||||
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 (DhcpSb->DhcpState == Dhcp4Rebooting) {
|
||||
IpAddr = EFI_IP4 (Config->ClientAddress);
|
||||
|
||||
} else if (DhcpSb->DhcpState == Dhcp4Requesting) {
|
||||
ASSERT (SeedHead != NULL);
|
||||
IpAddr = EFI_IP4 (SeedHead->YourAddr);
|
||||
}
|
||||
|
||||
} else if (Type == DHCP_MSG_DECLINE) {
|
||||
ASSERT (SeedHead != NULL);
|
||||
IpAddr = EFI_IP4 (SeedHead->YourAddr);
|
||||
}
|
||||
|
||||
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)) {
|
||||
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
|
||||
//
|
||||
if (Msg != NULL) {
|
||||
Len = MIN ((UINT32) AsciiStrLen ((CHAR8 *) Msg), 255);
|
||||
Buf = DhcpAppendOption (Buf, DHCP4_TAG_MESSAGE, (UINT16) Len, Msg);
|
||||
Len = MIN ((UINT32)AsciiStrLen ((CHAR8 *)Msg), 255);
|
||||
Buf = DhcpAppendOption (Buf, DHCP4_TAG_MESSAGE, (UINT16)Len, Msg);
|
||||
}
|
||||
|
||||
//
|
||||
@ -1285,7 +1261,8 @@ DhcpSendMessage (
|
||||
// if it is a DHCP decline or DHCP 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;
|
||||
}
|
||||
|
||||
@ -1299,7 +1276,7 @@ DhcpSendMessage (
|
||||
}
|
||||
|
||||
*(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.
|
||||
@ -1309,10 +1286,8 @@ DhcpSendMessage (
|
||||
|
||||
if (Type == DHCP_MSG_DISCOVER) {
|
||||
Status = DhcpCallUser (DhcpSb, Dhcp4SendDiscover, Packet, &NewPacket);
|
||||
|
||||
} else if (Type == DHCP_MSG_REQUEST) {
|
||||
Status = DhcpCallUser (DhcpSb, Dhcp4SendRequest, Packet, &NewPacket);
|
||||
|
||||
} else if (Type == DHCP_MSG_DECLINE) {
|
||||
Status = DhcpCallUser (DhcpSb, Dhcp4SendDecline, Packet, &NewPacket);
|
||||
}
|
||||
@ -1339,7 +1314,7 @@ DhcpSendMessage (
|
||||
//
|
||||
// Wrap it into a netbuf then send it.
|
||||
//
|
||||
Frag.Bulk = (UINT8 *) &Packet->Dhcp4.Header;
|
||||
Frag.Bulk = (UINT8 *)&Packet->Dhcp4.Header;
|
||||
Frag.Len = Packet->Length;
|
||||
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
|
||||
|
||||
@ -1393,7 +1368,6 @@ DhcpSendMessage (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retransmit a saved packet. Only DISCOVER and REQUEST messages
|
||||
will be retransmitted.
|
||||
@ -1421,13 +1395,13 @@ DhcpRetransmit (
|
||||
// For REQUEST message in Dhcp4Requesting state, do not change the secs fields.
|
||||
//
|
||||
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.
|
||||
//
|
||||
Frag.Bulk = (UINT8 *) &DhcpSb->LastPacket->Dhcp4.Header;
|
||||
Frag.Bulk = (UINT8 *)&DhcpSb->LastPacket->Dhcp4.Header;
|
||||
Frag.Len = DhcpSb->LastPacket->Length;
|
||||
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
|
||||
|
||||
@ -1469,7 +1443,6 @@ DhcpRetransmit (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -1494,13 +1467,13 @@ DhcpOnTimerTick (
|
||||
DHCP_PROTOCOL *Instance;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DhcpSb = (DHCP_SERVICE *) Context;
|
||||
DhcpSb = (DHCP_SERVICE *)Context;
|
||||
Instance = DhcpSb->ActiveChild;
|
||||
|
||||
//
|
||||
// 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++;
|
||||
}
|
||||
|
||||
@ -1508,15 +1481,13 @@ DhcpOnTimerTick (
|
||||
// Check the retransmit timer
|
||||
//
|
||||
if ((DhcpSb->PacketToLive > 0) && (--DhcpSb->PacketToLive == 0)) {
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (DhcpSb->LastOffer != NULL) {
|
||||
FreePool (DhcpSb->LastOffer);
|
||||
DhcpSb->LastOffer = NULL;
|
||||
@ -1532,9 +1503,7 @@ DhcpOnTimerTick (
|
||||
//
|
||||
DhcpRetransmit (DhcpSb);
|
||||
DhcpSetTransmitTimer (DhcpSb);
|
||||
|
||||
} else if (DHCP_CONNECTED (DhcpSb->DhcpState)) {
|
||||
|
||||
//
|
||||
// Retransmission failed, if the DHCP request is initiated by
|
||||
// user, adjust the current state according to the lease life.
|
||||
@ -1545,16 +1514,12 @@ DhcpOnTimerTick (
|
||||
|
||||
if (DhcpSb->LeaseLife < DhcpSb->T1) {
|
||||
Status = DhcpSetState (DhcpSb, Dhcp4Bound, FALSE);
|
||||
|
||||
} else if (DhcpSb->LeaseLife < DhcpSb->T2) {
|
||||
Status = DhcpSetState (DhcpSb, Dhcp4Renewing, FALSE);
|
||||
|
||||
} else if (DhcpSb->LeaseLife < DhcpSb->Lease) {
|
||||
Status = DhcpSetState (DhcpSb, Dhcp4Rebinding, FALSE);
|
||||
|
||||
} else {
|
||||
goto END_SESSION;
|
||||
|
||||
}
|
||||
|
||||
DhcpSb->IoStatus = EFI_TIMEOUT;
|
||||
@ -1577,7 +1542,7 @@ DhcpOnTimerTick (
|
||||
// requesting extra renew/rebind. Adjust the state after that.
|
||||
//
|
||||
if (DhcpSb->ExtraRefresh != 0) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (DhcpSb->LeaseLife == DhcpSb->Lease) {
|
||||
@ -1585,7 +1550,6 @@ DhcpOnTimerTick (
|
||||
// Lease expires, end the session
|
||||
//
|
||||
goto END_SESSION;
|
||||
|
||||
} else if (DhcpSb->LeaseLife == DhcpSb->T2) {
|
||||
//
|
||||
// T2 expires, transit to rebinding then send a REQUEST to any server
|
||||
@ -1595,7 +1559,7 @@ DhcpOnTimerTick (
|
||||
}
|
||||
|
||||
if (Instance != NULL) {
|
||||
Instance->ElaspedTime= 0;
|
||||
Instance->ElaspedTime = 0;
|
||||
}
|
||||
|
||||
Status = DhcpSendMessage (
|
||||
@ -1609,7 +1573,6 @@ DhcpOnTimerTick (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto END_SESSION;
|
||||
}
|
||||
|
||||
} else if (DhcpSb->LeaseLife == DhcpSb->T1) {
|
||||
//
|
||||
// T1 expires, transit to renewing, then send a REQUEST to the server
|
||||
@ -1619,7 +1582,7 @@ DhcpOnTimerTick (
|
||||
}
|
||||
|
||||
if (Instance != NULL) {
|
||||
Instance->ElaspedTime= 0;
|
||||
Instance->ElaspedTime = 0;
|
||||
}
|
||||
|
||||
Status = DhcpSendMessage (
|
||||
@ -1643,15 +1606,15 @@ ON_EXIT:
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &DhcpSb->Children) {
|
||||
Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link);
|
||||
Instance->Timeout--;
|
||||
if (Instance->Timeout == 0 && Instance->Token != NULL) {
|
||||
if ((Instance->Timeout == 0) && (Instance->Token != NULL)) {
|
||||
PxeDhcpDone (Instance);
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
|
||||
END_SESSION:
|
||||
DhcpEndSession (DhcpSb, EFI_TIMEOUT);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
|
||||
|
||||
#define DHCP_WAIT_OFFER 3 // Time to wait the offers
|
||||
#define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default.
|
||||
#define DHCP_SERVER_PORT 67
|
||||
|
@ -14,94 +14,93 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
/// DHCP_OPTION_FORMAT structure.
|
||||
///
|
||||
DHCP_OPTION_FORMAT DhcpOptionFormats[] = {
|
||||
{DHCP4_TAG_NETMASK, DHCP_OPTION_IP, 1, 1 , TRUE},
|
||||
{DHCP4_TAG_TIME_OFFSET, DHCP_OPTION_INT32, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_ROUTER, DHCP_OPTION_IP, 1, -1 , TRUE},
|
||||
{DHCP4_TAG_TIME_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_LOG_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_IMPRESS_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_BOOTFILE_LEN, DHCP_OPTION_INT16, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_DUMP, 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_ROOTPATH, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_EXTEND_PATH, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_NETMASK, DHCP_OPTION_IP, 1, 1, TRUE },
|
||||
{ DHCP4_TAG_TIME_OFFSET, DHCP_OPTION_INT32, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_ROUTER, DHCP_OPTION_IP, 1, -1, TRUE },
|
||||
{ DHCP4_TAG_TIME_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_LOG_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_IMPRESS_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_BOOTFILE_LEN, DHCP_OPTION_INT16, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_DUMP, 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_ROOTPATH, 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_NONLOCAL_SRR, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_POLICY_SRR, DHCP_OPTION_IPPAIR, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_EMTU, DHCP_OPTION_INT16, 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_PLATEAU,DHCP_OPTION_INT16, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_IPFORWARD, 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_EMTU, DHCP_OPTION_INT16, 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_PLATEAU, 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_BROADCAST, DHCP_OPTION_IP, 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_DISCOVER_ROUTE, DHCP_OPTION_SWITCH, 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_IFMTU, DHCP_OPTION_INT16, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_SUBNET_LOCAL, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_BROADCAST, DHCP_OPTION_IP, 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_DISCOVER_ROUTE, DHCP_OPTION_SWITCH, 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_TRAILER, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_ARPAGE, DHCP_OPTION_INT32, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_ETHER_ENCAP, 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_ETHER_ENCAP, DHCP_OPTION_SWITCH, 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_GARBAGE, DHCP_OPTION_SWITCH, 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_GARBAGE, DHCP_OPTION_SWITCH, 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_NTP_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_VENDOR, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NBNS, 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_NBSCOPE, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_XFONT, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_XDM, DHCP_OPTION_IP, 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_NTP_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_VENDOR, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NBNS, 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_NBSCOPE, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_XFONT, 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_LEASE, DHCP_OPTION_INT32, 1, 1 , TRUE},
|
||||
{DHCP4_TAG_OVERLOAD, 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_PARA_LIST, 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_T1, 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_CLIENT_ID, DHCP_OPTION_INT8, 2, -1 , FALSE},
|
||||
{ DHCP4_TAG_REQUEST_IP, DHCP_OPTION_IP, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_LEASE, DHCP_OPTION_INT32, 1, 1, TRUE },
|
||||
{ DHCP4_TAG_OVERLOAD, 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_PARA_LIST, 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_T1, 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_CLIENT_ID, DHCP_OPTION_INT8, 2, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_NISPLUS, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NISPLUS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_NISPLUS, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NISPLUS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_TFTP, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_BOOTFILE, 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_MOBILEIP, DHCP_OPTION_IP, 0, -1 , FALSE},
|
||||
{DHCP4_TAG_SMTP, 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_WWW, 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_STTALK, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_STDA, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_MOBILEIP, DHCP_OPTION_IP, 0, -1, FALSE },
|
||||
{ DHCP4_TAG_SMTP, 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_WWW, 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_STTALK, 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
|
||||
information about a specific option.
|
||||
@ -140,7 +139,6 @@ DhcpFindOptionFormat (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Validate whether a single DHCP option is valid according to its format.
|
||||
|
||||
@ -201,7 +199,8 @@ DhcpOptionIsValid (
|
||||
|
||||
if (((Format->MinOccur != -1) && (Occur < Format->MinOccur)) ||
|
||||
((Format->MaxOccur != -1) && (Occur > Format->MaxOccur))
|
||||
) {
|
||||
)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -219,7 +218,6 @@ DhcpOptionIsValid (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extract the client interested options, all the parameters are
|
||||
converted to host byte order.
|
||||
@ -263,6 +261,7 @@ DhcpGetParameter (
|
||||
if ((Para->Overload < 1) || (Para->Overload > 3)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DHCP4_TAG_MSG_TYPE:
|
||||
@ -271,6 +270,7 @@ DhcpGetParameter (
|
||||
if ((Para->DhcpType < 1) || (Para->DhcpType > 9)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DHCP4_TAG_SERVER_ID:
|
||||
@ -289,7 +289,6 @@ DhcpGetParameter (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -364,7 +363,6 @@ DhcpIterateBufferOptions (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Iterate through a DHCP message to visit each option. First 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)) {
|
||||
Status = DhcpIterateBufferOptions (
|
||||
(UINT8 *) Packet->Dhcp4.Header.BootFileName,
|
||||
(UINT8 *)Packet->Dhcp4.Header.BootFileName,
|
||||
128,
|
||||
Check,
|
||||
Context,
|
||||
@ -420,7 +418,7 @@ DhcpIterateOptions (
|
||||
|
||||
if ((Overload == DHCP_OVERLOAD_SVRNAME) || (Overload == DHCP_OVERLOAD_BOTH)) {
|
||||
Status = DhcpIterateBufferOptions (
|
||||
(UINT8 *) Packet->Dhcp4.Header.ServerName,
|
||||
(UINT8 *)Packet->Dhcp4.Header.ServerName,
|
||||
64,
|
||||
Check,
|
||||
Context,
|
||||
@ -435,7 +433,6 @@ DhcpIterateOptions (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Call back function to DhcpIterateOptions to compute each option's
|
||||
length. It just adds the data length of all the occurrences of this
|
||||
@ -460,13 +457,12 @@ DhcpGetOptionLen (
|
||||
{
|
||||
DHCP_OPTION_COUNT *OpCount;
|
||||
|
||||
OpCount = (DHCP_OPTION_COUNT *) Context;
|
||||
OpCount[Tag].Offset = (UINT16) (OpCount[Tag].Offset + Len);
|
||||
OpCount = (DHCP_OPTION_COUNT *)Context;
|
||||
OpCount[Tag].Offset = (UINT16)(OpCount[Tag].Offset + Len);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Call back function to DhcpIterateOptions to consolidate each option's
|
||||
data. There are maybe several occurrence of the same option.
|
||||
@ -494,7 +490,7 @@ DhcpFillOption (
|
||||
UINT8 *Buf;
|
||||
UINT8 Index;
|
||||
|
||||
OptContext = (DHCP_OPTION_CONTEXT *) Context;
|
||||
OptContext = (DHCP_OPTION_CONTEXT *)Context;
|
||||
|
||||
OptCount = OptContext->OpCount;
|
||||
Index = OptCount[Tag].Index;
|
||||
@ -508,12 +504,11 @@ DhcpFillOption (
|
||||
|
||||
CopyMem (Buf + OptCount[Tag].Offset, Data, Len);
|
||||
|
||||
OptCount[Tag].Offset = (UINT16) (OptCount[Tag].Offset + Len);
|
||||
Options[Index].Len = (UINT16) (Options[Index].Len + Len);
|
||||
OptCount[Tag].Offset = (UINT16)(OptCount[Tag].Offset + Len);
|
||||
Options[Index].Len = (UINT16)(Options[Index].Len + Len);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -585,10 +580,10 @@ DhcpParseOption (
|
||||
|
||||
for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) {
|
||||
if (OptCount[Index].Offset != 0) {
|
||||
OptCount[Index].Index = (UINT8) OptNum;
|
||||
OptCount[Index].Index = (UINT8)OptNum;
|
||||
|
||||
TotalLen = (UINT16) (TotalLen + OptCount[Index].Offset);
|
||||
OptCount[Index].Offset = (UINT16) (TotalLen - OptCount[Index].Offset);
|
||||
TotalLen = (UINT16)(TotalLen + OptCount[Index].Offset);
|
||||
OptCount[Index].Offset = (UINT16)(TotalLen - OptCount[Index].Offset);
|
||||
|
||||
OptNum++;
|
||||
}
|
||||
@ -605,7 +600,7 @@ DhcpParseOption (
|
||||
// Allocate a buffer to hold the DHCP options, and after that, a
|
||||
// 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) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -614,7 +609,7 @@ DhcpParseOption (
|
||||
|
||||
Context.OpCount = OptCount;
|
||||
Context.Options = Options;
|
||||
Context.Buf = (UINT8 *) (Options + OptNum);
|
||||
Context.Buf = (UINT8 *)(Options + OptNum);
|
||||
|
||||
Status = DhcpIterateOptions (Packet, DhcpFillOption, &Context);
|
||||
|
||||
@ -630,7 +625,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Validate the packet's options. If necessary, allocate
|
||||
and fill in the interested parameters.
|
||||
@ -668,6 +662,7 @@ DhcpValidateOptions (
|
||||
if (EFI_ERROR (Status) || (Count == 0)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (AllOption != NULL);
|
||||
|
||||
Updated = FALSE;
|
||||
@ -716,8 +711,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Append an option to the memory, if the option is longer than
|
||||
255 bytes, splits it into several options.
|
||||
@ -747,8 +740,8 @@ DhcpAppendOption (
|
||||
Len = MIN (255, DataLen - Index * 255);
|
||||
|
||||
*(Buf++) = Tag;
|
||||
*(Buf++) = (UINT8) Len;
|
||||
CopyMem (Buf, Data + Index * 255, (UINTN) Len);
|
||||
*(Buf++) = (UINT8)Len;
|
||||
CopyMem (Buf, Data + Index * 255, (UINTN)Len);
|
||||
|
||||
Buf += Len;
|
||||
}
|
||||
@ -756,7 +749,6 @@ DhcpAppendOption (
|
||||
return Buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -804,7 +796,7 @@ DhcpBuild (
|
||||
}
|
||||
|
||||
for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) {
|
||||
Mark[Index].Tag = (UINT8) Index;
|
||||
Mark[Index].Tag = (UINT8)Index;
|
||||
Mark[Index].Len = 0;
|
||||
}
|
||||
|
||||
@ -820,7 +812,7 @@ DhcpBuild (
|
||||
}
|
||||
|
||||
if (SeedOptions != NULL) {
|
||||
for (Index = 0; Index < (UINT32) Count; Index++) {
|
||||
for (Index = 0; Index < (UINT32)Count; Index++) {
|
||||
Mark[SeedOptions[Index].Tag] = SeedOptions[Index];
|
||||
}
|
||||
}
|
||||
@ -855,7 +847,7 @@ DhcpBuild (
|
||||
}
|
||||
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
Packet = (EFI_DHCP4_PACKET *) AllocatePool (Len);
|
||||
Packet = (EFI_DHCP4_PACKET *)AllocatePool (Len);
|
||||
|
||||
if (Packet == NULL) {
|
||||
goto ON_ERROR;
|
||||
@ -875,7 +867,7 @@ DhcpBuild (
|
||||
|
||||
*(Buf++) = DHCP4_TAG_EOP;
|
||||
Packet->Length = sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)
|
||||
+ (UINT32) (Buf - Packet->Dhcp4.Option);
|
||||
+ (UINT32)(Buf - Packet->Dhcp4.Option);
|
||||
|
||||
*NewPacket = Packet;
|
||||
Status = EFI_SUCCESS;
|
||||
|
@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define DHCP_OPTION_MAGIC 0x63538263 // Network byte order
|
||||
#define DHCP_MAX_OPTIONS 256
|
||||
|
||||
|
||||
//
|
||||
// DHCP option types, this is used to validate the DHCP options.
|
||||
//
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "Dhcp6Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the driver.
|
||||
|
||||
@ -57,7 +56,6 @@ Dhcp6ComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -136,7 +134,6 @@ Dhcp6ComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -150,8 +147,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp6ComponentName
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Dhcp6ComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Dhcp6ComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Dhcp6ComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Dhcp6ComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
@ -278,12 +275,14 @@ UpdateName (
|
||||
if (Dhcp6ModeData.Ia->State > Dhcp6Rebinding) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
HandleName = mDhcp6ControllerName[Dhcp6ModeData.Ia->State];
|
||||
}
|
||||
|
||||
if (Dhcp6ModeData.Ia != NULL) {
|
||||
FreePool (Dhcp6ModeData.Ia);
|
||||
}
|
||||
|
||||
if (Dhcp6ModeData.ClientId != NULL) {
|
||||
FreePool (Dhcp6ModeData.ClientId);
|
||||
}
|
||||
@ -439,4 +438,3 @@ Dhcp6ComponentNameGetControllerName (
|
||||
(BOOLEAN)(This == &gDhcp6ComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "Dhcp6Impl.h"
|
||||
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = {
|
||||
Dhcp6DriverBindingSupported,
|
||||
Dhcp6DriverBindingStart,
|
||||
@ -70,10 +69,9 @@ Dhcp6ConfigureUdpIo (
|
||||
Config->StationPort = DHCP6_PORT_CLIENT;
|
||||
Config->RemotePort = 0;
|
||||
|
||||
return Udp6->Configure (Udp6, Config);;
|
||||
return Udp6->Configure (Udp6, Config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -103,7 +101,6 @@ Dhcp6DestroyService (
|
||||
FreePool (Service);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a new Dhcp6 service for the Nic controller.
|
||||
|
||||
@ -164,7 +161,7 @@ Dhcp6CreateService (
|
||||
Status = gBS->HandleProtocol (
|
||||
Controller,
|
||||
&gEfiIp6ConfigProtocolGuid,
|
||||
(VOID **) &Dhcp6Srv->Ip6Cfg
|
||||
(VOID **)&Dhcp6Srv->Ip6Cfg
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Dhcp6Srv);
|
||||
@ -206,7 +203,6 @@ Dhcp6CreateService (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroy the Dhcp6 instance and recycle the resources.
|
||||
|
||||
@ -239,6 +235,7 @@ Dhcp6DestroyInstance (
|
||||
if (Instance->IaCb.Ia->ReplyPacket != NULL) {
|
||||
FreePool (Instance->IaCb.Ia->ReplyPacket);
|
||||
}
|
||||
|
||||
FreePool (Instance->IaCb.Ia);
|
||||
}
|
||||
|
||||
@ -253,7 +250,6 @@ Dhcp6DestroyInstance (
|
||||
FreePool (Instance);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create the Dhcp6 instance and initialize it.
|
||||
|
||||
@ -340,17 +336,16 @@ Dhcp6DestroyChildEntry (
|
||||
DHCP6_INSTANCE *Instance;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
|
||||
if (Entry == NULL || Context == NULL) {
|
||||
if ((Entry == NULL) || (Context == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
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
|
||||
EFI boot service ConnectController(). In order to make
|
||||
@ -490,7 +483,6 @@ Dhcp6DriverBindingStart (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service DisconnectController(). In order to
|
||||
@ -538,7 +530,7 @@ Dhcp6DriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiDhcp6ServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
NicHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -560,16 +552,16 @@ Dhcp6DriverBindingStop (
|
||||
ServiceBinding,
|
||||
&ListLength
|
||||
);
|
||||
if (EFI_ERROR (Status) || ListLength != 0) {
|
||||
if (EFI_ERROR (Status) || (ListLength != 0)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (NumberOfChildren == 0 && !IsListEmpty (&Service->Child)) {
|
||||
if ((NumberOfChildren == 0) && !IsListEmpty (&Service->Child)) {
|
||||
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.
|
||||
//
|
||||
@ -590,7 +582,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
@ -621,7 +612,7 @@ Dhcp6ServiceBindingCreateChild (
|
||||
DHCP6_INSTANCE *Instance;
|
||||
VOID *Udp6;
|
||||
|
||||
if (This == NULL || ChildHandle == NULL) {
|
||||
if ((This == NULL) || (ChildHandle == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -670,14 +661,13 @@ Dhcp6ServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
Service->UdpIo->UdpHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
(VOID **) &Udp6,
|
||||
(VOID **)&Udp6,
|
||||
gDhcp6DriverBinding.DriverBindingHandle,
|
||||
Instance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
Instance->Handle,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
@ -704,7 +694,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
@ -736,7 +725,7 @@ Dhcp6ServiceBindingDestroyChild (
|
||||
DHCP6_SERVICE *Service;
|
||||
DHCP6_INSTANCE *Instance;
|
||||
|
||||
if (This == NULL || ChildHandle == NULL) {
|
||||
if ((This == NULL) || (ChildHandle == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -746,7 +735,7 @@ Dhcp6ServiceBindingDestroyChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
(VOID **) &Dhcp6,
|
||||
(VOID **)&Dhcp6,
|
||||
gDhcp6DriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
|
@ -14,7 +14,9 @@
|
||||
//
|
||||
// ALL_DHCP_Relay_Agents_and_Servers address: FF02::1:2
|
||||
//
|
||||
EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress = {{0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2}};
|
||||
EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress = {
|
||||
{ 0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2 }
|
||||
};
|
||||
|
||||
EFI_DHCP6_PROTOCOL gDhcp6ProtocolTemplate = {
|
||||
EfiDhcp6GetModeData,
|
||||
@ -119,7 +121,7 @@ EfiDhcp6Start (
|
||||
//
|
||||
// Register receive callback for the stateful exchange process.
|
||||
//
|
||||
Status = UdpIoRecvDatagram(
|
||||
Status = UdpIoRecvDatagram (
|
||||
Service->UdpIo,
|
||||
Dhcp6ReceivePacket,
|
||||
Service,
|
||||
@ -136,10 +138,10 @@ EfiDhcp6Start (
|
||||
// Poll udp out of the net tpl if synchronous call.
|
||||
//
|
||||
if (Instance->Config->IaInfoEvent == NULL) {
|
||||
|
||||
while (Instance->UdpSts == EFI_ALREADY_STARTED) {
|
||||
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
|
||||
}
|
||||
|
||||
return Instance->UdpSts;
|
||||
}
|
||||
|
||||
@ -151,7 +153,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stops the DHCPv6 standard S.A.R.R. process.
|
||||
|
||||
@ -200,10 +201,11 @@ EfiDhcp6Stop (
|
||||
//
|
||||
// No valid REPLY message received yet, cleanup this instance directly.
|
||||
//
|
||||
if (Instance->IaCb.Ia->State == Dhcp6Init ||
|
||||
Instance->IaCb.Ia->State == Dhcp6Selecting ||
|
||||
Instance->IaCb.Ia->State == Dhcp6Requesting
|
||||
) {
|
||||
if ((Instance->IaCb.Ia->State == Dhcp6Init) ||
|
||||
(Instance->IaCb.Ia->State == Dhcp6Selecting) ||
|
||||
(Instance->IaCb.Ia->State == Dhcp6Requesting)
|
||||
)
|
||||
{
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -227,6 +229,7 @@ EfiDhcp6Stop (
|
||||
while (Instance->UdpSts == EFI_ALREADY_STARTED) {
|
||||
Udp6->Poll (Udp6);
|
||||
}
|
||||
|
||||
Status = Instance->UdpSts;
|
||||
}
|
||||
|
||||
@ -241,7 +244,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the current operating mode data for the Dhcp6 instance.
|
||||
|
||||
@ -272,14 +274,14 @@ EfiDhcp6GetModeData (
|
||||
UINT32 IaSize;
|
||||
UINT32 IdSize;
|
||||
|
||||
if (This == NULL || (Dhcp6ModeData == NULL && Dhcp6ConfigData == NULL)) {
|
||||
if ((This == NULL) || ((Dhcp6ModeData == NULL) && (Dhcp6ConfigData == NULL))) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = DHCP6_INSTANCE_FROM_THIS (This);
|
||||
Service = Instance->Service;
|
||||
|
||||
if (Instance->Config == NULL && Dhcp6ConfigData != NULL) {
|
||||
if ((Instance->Config == NULL) && (Dhcp6ConfigData != NULL)) {
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
@ -291,7 +293,7 @@ EfiDhcp6GetModeData (
|
||||
// User needs a copy of instance config data.
|
||||
//
|
||||
if (Dhcp6ConfigData != NULL) {
|
||||
ZeroMem (Dhcp6ConfigData, sizeof(EFI_DHCP6_CONFIG_DATA));
|
||||
ZeroMem (Dhcp6ConfigData, sizeof (EFI_DHCP6_CONFIG_DATA));
|
||||
//
|
||||
// Duplicate config data, including all reference buffers.
|
||||
//
|
||||
@ -347,6 +349,7 @@ EfiDhcp6GetModeData (
|
||||
if (Dhcp6ModeData->Ia->ReplyPacket == NULL) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
Dhcp6ModeData->Ia->ReplyPacket,
|
||||
Ia->ReplyPacket,
|
||||
@ -365,15 +368,16 @@ ON_ERROR:
|
||||
if (Dhcp6ConfigData != NULL) {
|
||||
Dhcp6CleanupConfigData (Dhcp6ConfigData);
|
||||
}
|
||||
|
||||
if (Dhcp6ModeData != NULL) {
|
||||
Dhcp6CleanupModeData (Dhcp6ModeData);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initializes, changes, or resets the operational settings for the Dhcp6 instance.
|
||||
|
||||
@ -428,36 +432,40 @@ EfiDhcp6Configure (
|
||||
// Check the parameter of configure data.
|
||||
//
|
||||
if (Dhcp6CfgData != NULL) {
|
||||
if (Dhcp6CfgData->OptionCount > 0 && Dhcp6CfgData->OptionList == NULL) {
|
||||
if ((Dhcp6CfgData->OptionCount > 0) && (Dhcp6CfgData->OptionList == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Dhcp6CfgData->OptionList != NULL) {
|
||||
for (Index = 0; Index < Dhcp6CfgData->OptionCount; Index++) {
|
||||
if (Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptClientId ||
|
||||
Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptRapidCommit ||
|
||||
Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptReconfigureAccept ||
|
||||
Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptIana ||
|
||||
Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptIata
|
||||
) {
|
||||
if ((Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptClientId) ||
|
||||
(Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptRapidCommit) ||
|
||||
(Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptReconfigureAccept) ||
|
||||
(Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptIana) ||
|
||||
(Dhcp6CfgData->OptionList[Index]->OpCode == Dhcp6OptIata)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Dhcp6CfgData->IaDescriptor.Type != EFI_DHCP6_IA_TYPE_NA &&
|
||||
Dhcp6CfgData->IaDescriptor.Type != EFI_DHCP6_IA_TYPE_TA
|
||||
) {
|
||||
if ((Dhcp6CfgData->IaDescriptor.Type != EFI_DHCP6_IA_TYPE_NA) &&
|
||||
(Dhcp6CfgData->IaDescriptor.Type != EFI_DHCP6_IA_TYPE_TA)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Dhcp6CfgData->IaInfoEvent == NULL && Dhcp6CfgData->SolicitRetransmission == NULL) {
|
||||
if ((Dhcp6CfgData->IaInfoEvent == NULL) && (Dhcp6CfgData->SolicitRetransmission == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Dhcp6CfgData->SolicitRetransmission != NULL &&
|
||||
Dhcp6CfgData->SolicitRetransmission->Mrc == 0 &&
|
||||
Dhcp6CfgData->SolicitRetransmission->Mrd == 0
|
||||
) {
|
||||
if ((Dhcp6CfgData->SolicitRetransmission != NULL) &&
|
||||
(Dhcp6CfgData->SolicitRetransmission->Mrc == 0) &&
|
||||
(Dhcp6CfgData->SolicitRetransmission->Mrd == 0)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -466,10 +474,11 @@ EfiDhcp6Configure (
|
||||
//
|
||||
NET_LIST_FOR_EACH (Entry, &Service->Child) {
|
||||
Other = NET_LIST_USER_STRUCT (Entry, DHCP6_INSTANCE, Link);
|
||||
if (Other->IaCb.Ia != NULL &&
|
||||
Other->IaCb.Ia->Descriptor.Type == Dhcp6CfgData->IaDescriptor.Type &&
|
||||
Other->IaCb.Ia->Descriptor.IaId == Dhcp6CfgData->IaDescriptor.IaId
|
||||
) {
|
||||
if ((Other->IaCb.Ia != NULL) &&
|
||||
(Other->IaCb.Ia->Descriptor.Type == Dhcp6CfgData->IaDescriptor.Type) &&
|
||||
(Other->IaCb.Ia->Descriptor.IaId == Dhcp6CfgData->IaDescriptor.IaId)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
@ -496,7 +505,7 @@ EfiDhcp6Configure (
|
||||
}
|
||||
|
||||
Status = Dhcp6CopyConfigData (Instance->Config, Dhcp6CfgData);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Instance->Config);
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -506,21 +515,20 @@ EfiDhcp6Configure (
|
||||
// Initialize the Ia descriptor from the config data, and leave the other
|
||||
// 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) {
|
||||
Dhcp6CleanupConfigData (Instance->Config);
|
||||
FreePool (Instance->Config);
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
&Instance->IaCb.Ia->Descriptor,
|
||||
&Dhcp6CfgData->IaDescriptor,
|
||||
sizeof(EFI_DHCP6_IA_DESCRIPTOR)
|
||||
sizeof (EFI_DHCP6_IA_DESCRIPTOR)
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
if (Instance->Config == NULL) {
|
||||
ASSERT (Instance->IaCb.Ia == NULL);
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
@ -548,7 +556,6 @@ EfiDhcp6Configure (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Request configuration information without the assignment of any
|
||||
Ia addresses of the client.
|
||||
@ -612,21 +619,21 @@ EfiDhcp6InfoRequest (
|
||||
EFI_STATUS TimerStatus;
|
||||
UINTN GetMappingTimeOut;
|
||||
|
||||
if (This == NULL || OptionRequest == NULL || Retransmission == NULL || ReplyCallback == NULL) {
|
||||
if ((This == NULL) || (OptionRequest == NULL) || (Retransmission == NULL) || (ReplyCallback == NULL)) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (OptionCount > 0 && OptionList == NULL) {
|
||||
if ((OptionCount > 0) && (OptionList == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (OptionList != NULL) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -651,8 +658,8 @@ EfiDhcp6InfoRequest (
|
||||
// The link local address is not ready, wait for some time and restart
|
||||
// the DHCP6 information request process.
|
||||
//
|
||||
Status = Dhcp6GetMappingTimeOut(Service->Ip6Cfg, &GetMappingTimeOut);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = Dhcp6GetMappingTimeOut (Service->Ip6Cfg, &GetMappingTimeOut);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -689,6 +696,7 @@ EfiDhcp6InfoRequest (
|
||||
|
||||
gBS->CloseEvent (Timer);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -697,17 +705,16 @@ EfiDhcp6InfoRequest (
|
||||
// Poll udp out of the net tpl if synchronous call.
|
||||
//
|
||||
if (TimeoutEvent == NULL) {
|
||||
|
||||
while (Instance->UdpSts == EFI_ALREADY_STARTED) {
|
||||
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
|
||||
}
|
||||
|
||||
return Instance->UdpSts;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Manually extend the valid and preferred lifetimes for the IPv6 addresses
|
||||
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.
|
||||
//
|
||||
if ((Instance->IaCb.Ia->State == Dhcp6Rebinding && RebindRequest) ||
|
||||
(Instance->IaCb.Ia->State == Dhcp6Renewing && !RebindRequest)
|
||||
) {
|
||||
if (((Instance->IaCb.Ia->State == Dhcp6Rebinding) && RebindRequest) ||
|
||||
((Instance->IaCb.Ia->State == Dhcp6Renewing) && !RebindRequest)
|
||||
)
|
||||
{
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
@ -809,7 +817,7 @@ EfiDhcp6RenewRebind (
|
||||
//
|
||||
// Register receive callback for the stateful exchange process.
|
||||
//
|
||||
Status = UdpIoRecvDatagram(
|
||||
Status = UdpIoRecvDatagram (
|
||||
Service->UdpIo,
|
||||
Dhcp6ReceivePacket,
|
||||
Service,
|
||||
@ -826,10 +834,10 @@ EfiDhcp6RenewRebind (
|
||||
// Poll udp out of the net tpl if synchronous call.
|
||||
//
|
||||
if (Instance->Config->IaInfoEvent == NULL) {
|
||||
|
||||
while (Instance->UdpSts == EFI_ALREADY_STARTED) {
|
||||
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
|
||||
}
|
||||
|
||||
return Instance->UdpSts;
|
||||
}
|
||||
|
||||
@ -841,7 +849,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Inform that one or more addresses assigned by a server are already
|
||||
in use by another node.
|
||||
@ -888,7 +895,7 @@ EfiDhcp6Decline (
|
||||
DHCP6_INSTANCE *Instance;
|
||||
DHCP6_SERVICE *Service;
|
||||
|
||||
if (This == NULL || AddressCount == 0 || Addresses == NULL) {
|
||||
if ((This == NULL) || (AddressCount == 0) || (Addresses == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -913,7 +920,7 @@ EfiDhcp6Decline (
|
||||
//
|
||||
Status = Dhcp6CheckAddress (Instance->IaCb.Ia, AddressCount, Addresses);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -943,7 +950,7 @@ EfiDhcp6Decline (
|
||||
//
|
||||
// Register receive callback for the stateful exchange process.
|
||||
//
|
||||
Status = UdpIoRecvDatagram(
|
||||
Status = UdpIoRecvDatagram (
|
||||
Service->UdpIo,
|
||||
Dhcp6ReceivePacket,
|
||||
Service,
|
||||
@ -961,10 +968,10 @@ EfiDhcp6Decline (
|
||||
// Poll udp out of the net tpl if synchronous call.
|
||||
//
|
||||
if (Instance->Config->IaInfoEvent == NULL) {
|
||||
|
||||
while (Instance->UdpSts == EFI_ALREADY_STARTED) {
|
||||
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
|
||||
}
|
||||
|
||||
return Instance->UdpSts;
|
||||
}
|
||||
|
||||
@ -975,12 +982,12 @@ ON_ERROR:
|
||||
if (DecIa != NULL) {
|
||||
FreePool (DecIa);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release one or more addresses associated with the configured Ia
|
||||
for current instance.
|
||||
@ -1029,7 +1036,7 @@ EfiDhcp6Release (
|
||||
DHCP6_INSTANCE *Instance;
|
||||
DHCP6_SERVICE *Service;
|
||||
|
||||
if (This == NULL || (AddressCount != 0 && Addresses == NULL)) {
|
||||
if ((This == NULL) || ((AddressCount != 0) && (Addresses == NULL))) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1054,7 +1061,7 @@ EfiDhcp6Release (
|
||||
//
|
||||
Status = Dhcp6CheckAddress (Instance->IaCb.Ia, AddressCount, Addresses);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1084,7 +1091,7 @@ EfiDhcp6Release (
|
||||
//
|
||||
// Register receive callback for the stateful exchange process.
|
||||
//
|
||||
Status = UdpIoRecvDatagram(
|
||||
Status = UdpIoRecvDatagram (
|
||||
Service->UdpIo,
|
||||
Dhcp6ReceivePacket,
|
||||
Service,
|
||||
@ -1105,6 +1112,7 @@ EfiDhcp6Release (
|
||||
while (Instance->UdpSts == EFI_ALREADY_STARTED) {
|
||||
Service->UdpIo->Protocol.Udp6->Poll (Service->UdpIo->Protocol.Udp6);
|
||||
}
|
||||
|
||||
return Instance->UdpSts;
|
||||
}
|
||||
|
||||
@ -1115,12 +1123,12 @@ ON_ERROR:
|
||||
if (RelIa != NULL) {
|
||||
FreePool (RelIa);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse the option data in the Dhcp6 packet.
|
||||
|
||||
@ -1152,15 +1160,15 @@ EfiDhcp6Parse (
|
||||
UINT8 *Start;
|
||||
UINT8 *End;
|
||||
|
||||
if (This == NULL || Packet == NULL || OptionCount == NULL) {
|
||||
if ((This == NULL) || (Packet == NULL) || (OptionCount == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (*OptionCount != 0 && PacketOptionList == NULL) {
|
||||
if ((*OptionCount != 0) && (PacketOptionList == NULL)) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1185,7 +1193,7 @@ EfiDhcp6Parse (
|
||||
// Calculate the number of option in the packet.
|
||||
//
|
||||
while (Start < End) {
|
||||
DataLen = ((EFI_DHCP6_PACKET_OPTION *) Start)->OpLen;
|
||||
DataLen = ((EFI_DHCP6_PACKET_OPTION *)Start)->OpLen;
|
||||
Start += (NTOHS (DataLen) + 4);
|
||||
OptCnt++;
|
||||
}
|
||||
@ -1208,13 +1216,11 @@ EfiDhcp6Parse (
|
||||
Start = Packet->Dhcp6.Option;
|
||||
|
||||
while (Start < End) {
|
||||
|
||||
PacketOptionList[OptCnt] = (EFI_DHCP6_PACKET_OPTION *) Start;
|
||||
DataLen = ((EFI_DHCP6_PACKET_OPTION *) Start)->OpLen;
|
||||
PacketOptionList[OptCnt] = (EFI_DHCP6_PACKET_OPTION *)Start;
|
||||
DataLen = ((EFI_DHCP6_PACKET_OPTION *)Start)->OpLen;
|
||||
Start += (NTOHS (DataLen) + 4);
|
||||
OptCnt++;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#ifndef __EFI_DHCP6_IMPL_H__
|
||||
#define __EFI_DHCP6_IMPL_H__
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <IndustryStandard/Dhcp.h>
|
||||
@ -33,7 +32,6 @@
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Guid/ZeroGuid.h>
|
||||
|
||||
|
||||
typedef struct _DHCP6_IA_CB DHCP6_IA_CB;
|
||||
typedef struct _DHCP6_INF_CB DHCP6_INF_CB;
|
||||
typedef struct _DHCP6_TX_CB DHCP6_TX_CB;
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "Dhcp6Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Enqueue the packet into the retry list in case of timeout.
|
||||
|
||||
@ -203,7 +202,7 @@ Dhcp6EnqueueRetry (
|
||||
//
|
||||
// Unexpected message type.
|
||||
//
|
||||
FreePool(TxCb);
|
||||
FreePool (TxCb);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@ -215,7 +214,6 @@ Dhcp6EnqueueRetry (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
//
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
|
||||
|
||||
TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link);
|
||||
ASSERT(TxCb->TxPacket);
|
||||
ASSERT (TxCb->TxPacket);
|
||||
|
||||
if (TxCb->Xid == PacketXid) {
|
||||
|
||||
if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) {
|
||||
|
||||
//
|
||||
// Seek the info-request node in the info-request list by packet xid.
|
||||
//
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) {
|
||||
|
||||
InfCb = NET_LIST_USER_STRUCT (Entry, DHCP6_INF_CB, Link);
|
||||
|
||||
if (InfCb->Xid == PacketXid) {
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -272,11 +266,12 @@ Dhcp6DequeueRetry (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Remove the retransmit node.
|
||||
//
|
||||
RemoveEntryList (&TxCb->Link);
|
||||
ASSERT(TxCb->TxPacket);
|
||||
ASSERT (TxCb->TxPacket);
|
||||
FreePool (TxCb->TxPacket);
|
||||
FreePool (TxCb);
|
||||
return EFI_SUCCESS;
|
||||
@ -286,7 +281,6 @@ Dhcp6DequeueRetry (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up the specific nodes in the retry list.
|
||||
|
||||
@ -308,12 +302,10 @@ Dhcp6CleanupRetry (
|
||||
//
|
||||
// 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) {
|
||||
|
||||
TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link);
|
||||
ASSERT(TxCb->TxPacket);
|
||||
ASSERT (TxCb->TxPacket);
|
||||
|
||||
if (TxCb->TxPacket->Dhcp6.Header.MessageType != Dhcp6MsgInfoRequest) {
|
||||
RemoveEntryList (&TxCb->Link);
|
||||
@ -326,15 +318,13 @@ Dhcp6CleanupRetry (
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
|
||||
|
||||
TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link);
|
||||
ASSERT(TxCb->TxPacket);
|
||||
ASSERT (TxCb->TxPacket);
|
||||
|
||||
if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) {
|
||||
RemoveEntryList (&TxCb->Link);
|
||||
@ -347,12 +337,12 @@ Dhcp6CleanupRetry (
|
||||
// Clean up all the info-request messages list.
|
||||
//
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) {
|
||||
|
||||
InfCb = NET_LIST_USER_STRUCT (Entry, DHCP6_INF_CB, Link);
|
||||
|
||||
if (InfCb->TimeoutEvent != NULL) {
|
||||
gBS->SignalEvent (InfCb->TimeoutEvent);
|
||||
}
|
||||
|
||||
RemoveEntryList (&InfCb->Link);
|
||||
FreePool (InfCb);
|
||||
}
|
||||
@ -402,8 +392,8 @@ Dhcp6CleanupSession (
|
||||
UINTN Index;
|
||||
EFI_DHCP6_IA *Ia;
|
||||
|
||||
ASSERT(Instance->Config);
|
||||
ASSERT(Instance->IaCb.Ia);
|
||||
ASSERT (Instance->Config);
|
||||
ASSERT (Instance->IaCb.Ia);
|
||||
|
||||
//
|
||||
// Clean up the retransmit list for stateful messages.
|
||||
@ -461,7 +451,6 @@ Dhcp6CleanupSession (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Callback to user when Dhcp6 transmit/receive occurs.
|
||||
|
||||
@ -500,7 +489,6 @@ Dhcp6CallbackUser (
|
||||
// Callback to user with the new message if has.
|
||||
//
|
||||
if (Callback != NULL) {
|
||||
|
||||
Status = Callback (
|
||||
&Instance->Dhcp6,
|
||||
Context,
|
||||
@ -522,7 +510,6 @@ Dhcp6CallbackUser (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
//
|
||||
if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) {
|
||||
T1 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 8)));
|
||||
T2 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 12)));
|
||||
T1 = NTOHL (ReadUnaligned32 ((UINT32 *)(Option + 8)));
|
||||
T2 = NTOHL (ReadUnaligned32 ((UINT32 *)(Option + 12)));
|
||||
//
|
||||
// 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
|
||||
// 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;
|
||||
}
|
||||
|
||||
IaInnerOpt = Option + 16;
|
||||
IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 2))) - 12);
|
||||
IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(Option + 2))) - 12);
|
||||
} else {
|
||||
T1 = 0;
|
||||
T2 = 0;
|
||||
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);
|
||||
|
||||
if (Option != NULL) {
|
||||
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 4)));
|
||||
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(Option + 4)));
|
||||
if (StsCode != Dhcp6StsSuccess) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -673,8 +661,6 @@ Dhcp6UpdateIaInfo (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -710,7 +696,7 @@ Dhcp6SeekStsOption (
|
||||
);
|
||||
|
||||
if (*Option != NULL) {
|
||||
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 4)));
|
||||
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(*Option + 4)));
|
||||
if (StsCode != Dhcp6StsSuccess) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -771,10 +757,10 @@ Dhcp6SeekStsOption (
|
||||
//
|
||||
if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) {
|
||||
IaInnerOpt = *Option + 16;
|
||||
IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 2))) - 12);
|
||||
IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(*Option + 2))) - 12);
|
||||
} else {
|
||||
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);
|
||||
if (*Option != NULL) {
|
||||
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 4)));
|
||||
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(*Option + 4)));
|
||||
if (StsCode != Dhcp6StsSuccess) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -807,7 +793,6 @@ Dhcp6SeekStsOption (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Transmit Dhcp6 message by udpio.
|
||||
|
||||
@ -838,7 +823,7 @@ Dhcp6TransmitPacket (
|
||||
//
|
||||
// Wrap it into a netbuf then send it.
|
||||
//
|
||||
Frag.Bulk = (UINT8 *) &Packet->Dhcp6.Header;
|
||||
Frag.Bulk = (UINT8 *)&Packet->Dhcp6.Header;
|
||||
Frag.Len = Packet->Length;
|
||||
|
||||
//
|
||||
@ -899,7 +884,6 @@ Dhcp6TransmitPacket (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create the solicit message and send it.
|
||||
|
||||
@ -985,9 +969,8 @@ Dhcp6SendSolicitMsg (
|
||||
// Append user-defined when configurate Dhcp6 service.
|
||||
//
|
||||
for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
|
||||
|
||||
UserOpt = Instance->Config->OptionList[Index];
|
||||
Cursor = Dhcp6AppendOption(
|
||||
Cursor = Dhcp6AppendOption (
|
||||
Cursor,
|
||||
UserOpt->OpCode,
|
||||
UserOpt->OpLen,
|
||||
@ -998,7 +981,7 @@ Dhcp6SendSolicitMsg (
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
@ -1061,7 +1044,6 @@ Dhcp6InitSolicitMsg (
|
||||
return Dhcp6SendSolicitMsg (Instance);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create the request message and send it.
|
||||
|
||||
@ -1091,15 +1073,15 @@ Dhcp6SendRequestMsg (
|
||||
UINTN Index;
|
||||
UINT16 Length;
|
||||
|
||||
ASSERT(Instance->AdSelect != NULL);
|
||||
ASSERT(Instance->Config != NULL);
|
||||
ASSERT(Instance->IaCb.Ia != NULL);
|
||||
ASSERT(Instance->Service != NULL);
|
||||
ASSERT (Instance->AdSelect != NULL);
|
||||
ASSERT (Instance->Config != NULL);
|
||||
ASSERT (Instance->IaCb.Ia != NULL);
|
||||
ASSERT (Instance->Service != NULL);
|
||||
|
||||
Service = Instance->Service;
|
||||
ClientId = Service->ClientId;
|
||||
|
||||
ASSERT(ClientId != NULL);
|
||||
ASSERT (ClientId != NULL);
|
||||
|
||||
//
|
||||
// Get the server Id from the selected advertisement message.
|
||||
@ -1113,7 +1095,7 @@ Dhcp6SendRequestMsg (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
ServerId = (EFI_DHCP6_DUID *) (Option + 2);
|
||||
ServerId = (EFI_DHCP6_DUID *)(Option + 2);
|
||||
|
||||
//
|
||||
// Calculate the added length of customized option list.
|
||||
@ -1174,9 +1156,8 @@ Dhcp6SendRequestMsg (
|
||||
// Append user-defined when configurate Dhcp6 service.
|
||||
//
|
||||
for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
|
||||
|
||||
UserOpt = Instance->Config->OptionList[Index];
|
||||
Cursor = Dhcp6AppendOption(
|
||||
Cursor = Dhcp6AppendOption (
|
||||
Cursor,
|
||||
UserOpt->OpCode,
|
||||
UserOpt->OpLen,
|
||||
@ -1187,7 +1168,7 @@ Dhcp6SendRequestMsg (
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
@ -1223,7 +1204,6 @@ Dhcp6SendRequestMsg (
|
||||
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create the decline message and send it.
|
||||
|
||||
@ -1279,7 +1259,7 @@ Dhcp6SendDeclineMsg (
|
||||
//
|
||||
// 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.
|
||||
@ -1325,7 +1305,7 @@ Dhcp6SendDeclineMsg (
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
@ -1361,7 +1341,6 @@ Dhcp6SendDeclineMsg (
|
||||
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create the release message and send it.
|
||||
|
||||
@ -1391,15 +1370,15 @@ Dhcp6SendReleaseMsg (
|
||||
UINT16 *Elapsed;
|
||||
UINT16 Length;
|
||||
|
||||
ASSERT(Instance->Config);
|
||||
ASSERT(Instance->IaCb.Ia);
|
||||
ASSERT (Instance->Config);
|
||||
ASSERT (Instance->IaCb.Ia);
|
||||
|
||||
Service = Instance->Service;
|
||||
ClientId = Service->ClientId;
|
||||
LastReply = Instance->IaCb.Ia->ReplyPacket;
|
||||
|
||||
ASSERT(ClientId);
|
||||
ASSERT(LastReply);
|
||||
ASSERT (ClientId);
|
||||
ASSERT (LastReply);
|
||||
|
||||
//
|
||||
// Get the server Id from the last reply message.
|
||||
@ -1413,7 +1392,7 @@ Dhcp6SendReleaseMsg (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
ServerId = (EFI_DHCP6_DUID *) (Option + 2);
|
||||
ServerId = (EFI_DHCP6_DUID *)(Option + 2);
|
||||
|
||||
//
|
||||
// Create the Dhcp6 packet and initialize common fields.
|
||||
@ -1462,7 +1441,7 @@ Dhcp6SendReleaseMsg (
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
@ -1494,7 +1473,6 @@ Dhcp6SendReleaseMsg (
|
||||
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create the renew/rebind message and send it.
|
||||
|
||||
@ -1530,13 +1508,13 @@ Dhcp6SendRenewRebindMsg (
|
||||
UINTN Index;
|
||||
UINT16 Length;
|
||||
|
||||
ASSERT(Instance->Config);
|
||||
ASSERT(Instance->IaCb.Ia);
|
||||
ASSERT (Instance->Config);
|
||||
ASSERT (Instance->IaCb.Ia);
|
||||
|
||||
Service = Instance->Service;
|
||||
ClientId = Service->ClientId;
|
||||
|
||||
ASSERT(ClientId);
|
||||
ASSERT (ClientId);
|
||||
|
||||
//
|
||||
// Calculate the added length of customized option list.
|
||||
@ -1604,7 +1582,7 @@ Dhcp6SendRenewRebindMsg (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
ServerId = (EFI_DHCP6_DUID *) (Option + 2);
|
||||
ServerId = (EFI_DHCP6_DUID *)(Option + 2);
|
||||
|
||||
Cursor = Dhcp6AppendOption (
|
||||
Cursor,
|
||||
@ -1618,9 +1596,8 @@ Dhcp6SendRenewRebindMsg (
|
||||
// Append user-defined when configurate Dhcp6 service.
|
||||
//
|
||||
for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
|
||||
|
||||
UserOpt = Instance->Config->OptionList[Index];
|
||||
Cursor = Dhcp6AppendOption(
|
||||
Cursor = Dhcp6AppendOption (
|
||||
Cursor,
|
||||
UserOpt->OpCode,
|
||||
UserOpt->OpLen,
|
||||
@ -1631,7 +1608,7 @@ Dhcp6SendRenewRebindMsg (
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
@ -1719,7 +1696,7 @@ Dhcp6StartInfoRequest (
|
||||
//
|
||||
// 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) {
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
@ -1752,7 +1729,7 @@ Dhcp6StartInfoRequest (
|
||||
//
|
||||
// Register receive callback for the stateless exchange process.
|
||||
//
|
||||
Status = UdpIoRecvDatagram(
|
||||
Status = UdpIoRecvDatagram (
|
||||
Service->UdpIo,
|
||||
Dhcp6ReceivePacket,
|
||||
Service,
|
||||
@ -1814,13 +1791,13 @@ Dhcp6SendInfoRequestMsg (
|
||||
UINTN Index;
|
||||
UINT16 Length;
|
||||
|
||||
ASSERT(OptionRequest);
|
||||
ASSERT (OptionRequest);
|
||||
|
||||
Service = Instance->Service;
|
||||
ClientId = Service->ClientId;
|
||||
UserLen = NTOHS (OptionRequest->OpLen) + 4;
|
||||
|
||||
ASSERT(ClientId);
|
||||
ASSERT (ClientId);
|
||||
|
||||
//
|
||||
// Calculate the added length of customized option list.
|
||||
@ -1876,9 +1853,8 @@ Dhcp6SendInfoRequestMsg (
|
||||
// Append user-defined when configurate Dhcp6 service.
|
||||
//
|
||||
for (Index = 0; Index < OptionCount; Index++) {
|
||||
|
||||
UserOpt = OptionList[Index];
|
||||
Cursor = Dhcp6AppendOption(
|
||||
Cursor = Dhcp6AppendOption (
|
||||
Cursor,
|
||||
UserOpt->OpCode,
|
||||
UserOpt->OpLen,
|
||||
@ -1889,7 +1865,7 @@ Dhcp6SendInfoRequestMsg (
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
@ -1913,7 +1889,6 @@ Dhcp6SendInfoRequestMsg (
|
||||
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, Retransmission);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create the Confirm message and send it.
|
||||
|
||||
@ -2013,7 +1988,7 @@ Dhcp6SendConfirmMsg (
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
@ -2049,8 +2024,6 @@ Dhcp6SendConfirmMsg (
|
||||
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Handle with the Dhcp6 reply message.
|
||||
|
||||
@ -2096,7 +2069,7 @@ Dhcp6HandleReplyMsg (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -2104,11 +2077,11 @@ Dhcp6HandleReplyMsg (
|
||||
// As to a valid reply packet in response to a request/renew/rebind packet,
|
||||
// ignore the packet if not contains the Ia option
|
||||
//
|
||||
if (Instance->IaCb.Ia->State == Dhcp6Requesting ||
|
||||
Instance->IaCb.Ia->State == Dhcp6Renewing ||
|
||||
Instance->IaCb.Ia->State == Dhcp6Rebinding
|
||||
) {
|
||||
|
||||
if ((Instance->IaCb.Ia->State == Dhcp6Requesting) ||
|
||||
(Instance->IaCb.Ia->State == Dhcp6Renewing) ||
|
||||
(Instance->IaCb.Ia->State == Dhcp6Rebinding)
|
||||
)
|
||||
{
|
||||
Option = Dhcp6SeekIaOption (
|
||||
Packet->Dhcp6.Option,
|
||||
Packet->Length,
|
||||
@ -2133,8 +2106,7 @@ Dhcp6HandleReplyMsg (
|
||||
// the client considers the decline/release event completed regardless of the
|
||||
// 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) {
|
||||
Instance->IaCb.Ia->State = Dhcp6Bound;
|
||||
} else {
|
||||
@ -2235,12 +2207,11 @@ Dhcp6HandleReplyMsg (
|
||||
}
|
||||
|
||||
goto ON_EXIT;
|
||||
|
||||
} else if (Option != NULL) {
|
||||
//
|
||||
// Any error status code option is found.
|
||||
//
|
||||
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 4)));
|
||||
StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(Option + 4)));
|
||||
switch (StsCode) {
|
||||
case Dhcp6StsUnspecFail:
|
||||
//
|
||||
@ -2259,6 +2230,7 @@ Dhcp6HandleReplyMsg (
|
||||
FreePool (Instance->Unicast);
|
||||
Instance->Unicast = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Dhcp6StsNotOnLink:
|
||||
@ -2279,19 +2251,21 @@ Dhcp6HandleReplyMsg (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
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
|
||||
// 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)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2306,7 +2280,7 @@ Dhcp6HandleReplyMsg (
|
||||
|
||||
ON_EXIT:
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = Dhcp6DequeueRetry (
|
||||
Instance,
|
||||
Packet->Dhcp6.Header.TransactionId,
|
||||
@ -2317,7 +2291,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Select the appointed Dhcp6 advertisement message.
|
||||
|
||||
@ -2361,7 +2334,7 @@ Dhcp6SelectAdvertiseMsg (
|
||||
FALSE
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -2369,21 +2342,20 @@ Dhcp6SelectAdvertiseMsg (
|
||||
// Check whether there is server unicast option in the selected advertise
|
||||
// packet, and update it.
|
||||
//
|
||||
Option = Dhcp6SeekOption(
|
||||
Option = Dhcp6SeekOption (
|
||||
AdSelect->Dhcp6.Option,
|
||||
AdSelect->Length - 4,
|
||||
Dhcp6OptServerUnicast
|
||||
);
|
||||
|
||||
if (Option != NULL) {
|
||||
|
||||
Instance->Unicast = AllocateZeroPool (sizeof(EFI_IPv6_ADDRESS));
|
||||
Instance->Unicast = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS));
|
||||
|
||||
if (Instance->Unicast == NULL) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle with the Dhcp6 advertisement message.
|
||||
|
||||
@ -2424,8 +2395,8 @@ Dhcp6HandleAdvertiseMsg (
|
||||
UINT8 *Option;
|
||||
BOOLEAN Timeout;
|
||||
|
||||
ASSERT(Instance->Config);
|
||||
ASSERT(Instance->IaCb.Ia);
|
||||
ASSERT (Instance->Config);
|
||||
ASSERT (Instance->IaCb.Ia);
|
||||
|
||||
Timeout = FALSE;
|
||||
|
||||
@ -2435,14 +2406,13 @@ Dhcp6HandleAdvertiseMsg (
|
||||
// this reply message. Or else, process the advertise messages as normal.
|
||||
// See details in the section-17.1.4 of rfc-3315.
|
||||
//
|
||||
Option = Dhcp6SeekOption(
|
||||
Option = Dhcp6SeekOption (
|
||||
Packet->Dhcp6.Option,
|
||||
Packet->Length - 4,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -2490,12 +2460,11 @@ Dhcp6HandleAdvertiseMsg (
|
||||
CopyMem (Instance->AdSelect, Packet, Packet->Size);
|
||||
|
||||
Instance->AdPref = 0xff;
|
||||
|
||||
} else if (Status == EFI_NOT_READY) {
|
||||
//
|
||||
// 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
|
||||
// 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.
|
||||
// Take non-preference option as 0 value.
|
||||
//
|
||||
Option = Dhcp6SeekOption(
|
||||
Option = Dhcp6SeekOption (
|
||||
Packet->Dhcp6.Option,
|
||||
Packet->Length - 4,
|
||||
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
|
||||
// advertisements received before. Then store the new packet and the
|
||||
@ -2541,7 +2510,6 @@ Dhcp6HandleAdvertiseMsg (
|
||||
// preference is less than other advertisements received before.
|
||||
// Leave the packet alone.
|
||||
}
|
||||
|
||||
} else {
|
||||
//
|
||||
// Other error status means termination.
|
||||
@ -2554,14 +2522,13 @@ Dhcp6HandleAdvertiseMsg (
|
||||
// RT has elapsed, or get a highest preference 255 advertise.
|
||||
// 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);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The Dhcp6 stateful exchange process routine.
|
||||
|
||||
@ -2595,27 +2562,27 @@ Dhcp6HandleStateful (
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether include client Id or not.
|
||||
//
|
||||
Option = Dhcp6SeekOption(
|
||||
Option = Dhcp6SeekOption (
|
||||
Packet->Dhcp6.Option,
|
||||
Packet->Length - 4,
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether include server Id or not.
|
||||
//
|
||||
Option = Dhcp6SeekOption(
|
||||
Option = Dhcp6SeekOption (
|
||||
Packet->Dhcp6.Option,
|
||||
Packet->Length - 4,
|
||||
Dhcp6OptServerId
|
||||
@ -2649,6 +2616,7 @@ Dhcp6HandleStateful (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
//
|
||||
@ -2673,7 +2641,6 @@ ON_EXIT:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The Dhcp6 stateless exchange process routine.
|
||||
|
||||
@ -2776,7 +2743,6 @@ ON_EXIT:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The receive callback function for Dhcp6 exchange process.
|
||||
|
||||
@ -2812,14 +2778,14 @@ Dhcp6ReceivePacket (
|
||||
ASSERT (Udp6Wrap != NULL);
|
||||
ASSERT (Context != NULL);
|
||||
|
||||
Service = (DHCP6_SERVICE *) Context;
|
||||
Service = (DHCP6_SERVICE *)Context;
|
||||
Instance = NULL;
|
||||
Packet = NULL;
|
||||
IsDispatched = FALSE;
|
||||
IsStateless = FALSE;
|
||||
|
||||
if (EFI_ERROR (IoStatus)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Udp6Wrap->TotalSize < sizeof (EFI_DHCP6_HEADER)) {
|
||||
@ -2830,7 +2796,7 @@ Dhcp6ReceivePacket (
|
||||
// Copy the net buffer received from upd6 to a Dhcp6 packet.
|
||||
//
|
||||
Size = sizeof (EFI_DHCP6_PACKET) + Udp6Wrap->TotalSize;
|
||||
Packet = (EFI_DHCP6_PACKET *) AllocateZeroPool (Size);
|
||||
Packet = (EFI_DHCP6_PACKET *)AllocateZeroPool (Size);
|
||||
|
||||
if (Packet == NULL) {
|
||||
goto ON_CONTINUE;
|
||||
@ -2838,7 +2804,7 @@ Dhcp6ReceivePacket (
|
||||
|
||||
Packet->Size = Size;
|
||||
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) {
|
||||
goto ON_CONTINUE;
|
||||
@ -2848,11 +2814,9 @@ Dhcp6ReceivePacket (
|
||||
// Dispatch packet to right instance by transaction id.
|
||||
//
|
||||
NET_LIST_FOR_EACH_SAFE (Entry1, Next1, &Service->Child) {
|
||||
|
||||
Instance = NET_LIST_USER_STRUCT (Entry1, DHCP6_INSTANCE, Link);
|
||||
|
||||
NET_LIST_FOR_EACH_SAFE (Entry2, Next2, &Instance->TxList) {
|
||||
|
||||
TxCb = NET_LIST_USER_STRUCT (Entry2, DHCP6_TX_CB, Link);
|
||||
|
||||
if (Packet->Dhcp6.Header.TransactionId == TxCb->Xid) {
|
||||
@ -2863,6 +2827,7 @@ Dhcp6ReceivePacket (
|
||||
if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) {
|
||||
IsStateless = TRUE;
|
||||
}
|
||||
|
||||
IsDispatched = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -2963,10 +2928,10 @@ Dhcp6LinkMovDetect (
|
||||
if (!MediaPresent && Instance->MediaPresent) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The timer routine of the Dhcp6 instance for each second.
|
||||
|
||||
@ -2991,14 +2956,13 @@ Dhcp6OnTimerTick (
|
||||
|
||||
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
|
||||
// need re-transmit or not.
|
||||
//
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
|
||||
|
||||
TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link);
|
||||
|
||||
TxCb->TickTime++;
|
||||
@ -3007,7 +2971,7 @@ Dhcp6OnTimerTick (
|
||||
//
|
||||
// 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) {
|
||||
//
|
||||
// Set adpref as 0xff here to indicate select any advertisement
|
||||
@ -3024,9 +2988,11 @@ Dhcp6OnTimerTick (
|
||||
} else if (EFI_ERROR (Status)) {
|
||||
TxCb->RetryCnt++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
//
|
||||
if (TxCb->RetryCtl.Mrc != 0 && TxCb->RetryCtl.Mrc < TxCb->RetryCnt) {
|
||||
if ((TxCb->RetryCtl.Mrc != 0) && (TxCb->RetryCtl.Mrc < TxCb->RetryCnt)) {
|
||||
Status = EFI_NO_RESPONSE;
|
||||
goto ON_CLOSE;
|
||||
}
|
||||
@ -3044,7 +3010,7 @@ Dhcp6OnTimerTick (
|
||||
//
|
||||
// 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;
|
||||
goto ON_CLOSE;
|
||||
}
|
||||
@ -3061,7 +3027,7 @@ Dhcp6OnTimerTick (
|
||||
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->RetryCtl.Mrt,
|
||||
TRUE,
|
||||
@ -3074,7 +3040,7 @@ Dhcp6OnTimerTick (
|
||||
// duration time.
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
@ -3100,22 +3066,19 @@ Dhcp6OnTimerTick (
|
||||
//
|
||||
IaCb = &Instance->IaCb;
|
||||
|
||||
if (Instance->Config == NULL || IaCb->Ia == NULL) {
|
||||
if ((Instance->Config == NULL) || (IaCb->Ia == NULL)) {
|
||||
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++;
|
||||
|
||||
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.
|
||||
//
|
||||
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.
|
||||
//
|
||||
@ -3133,28 +3096,32 @@ Dhcp6OnTimerTick (
|
||||
|
||||
return;
|
||||
|
||||
ON_CLOSE:
|
||||
ON_CLOSE:
|
||||
|
||||
if (Dhcp6IsValidTxCb (Instance, TxCb) &&
|
||||
TxCb->TxPacket != NULL &&
|
||||
(TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest ||
|
||||
TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew ||
|
||||
TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm)
|
||||
) {
|
||||
(TxCb->TxPacket != NULL) &&
|
||||
((TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) ||
|
||||
(TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew) ||
|
||||
(TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm))
|
||||
)
|
||||
{
|
||||
//
|
||||
// The failure of renew/Confirm will still switch to the bound state.
|
||||
//
|
||||
if ((TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew) ||
|
||||
(TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm)) {
|
||||
(TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm))
|
||||
{
|
||||
ASSERT (Instance->IaCb.Ia);
|
||||
Instance->IaCb.Ia->State = Dhcp6Bound;
|
||||
}
|
||||
|
||||
//
|
||||
// The failure of info-request will return no response.
|
||||
//
|
||||
if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) {
|
||||
Instance->UdpSts = EFI_NO_RESPONSE;
|
||||
}
|
||||
|
||||
Dhcp6DequeueRetry (
|
||||
Instance,
|
||||
TxCb->Xid,
|
||||
|
@ -10,7 +10,6 @@
|
||||
#ifndef __EFI_DHCP6_IO_H__
|
||||
#define __EFI_DHCP6_IO_H__
|
||||
|
||||
|
||||
/**
|
||||
Clean up the specific nodes in the retry list.
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "Dhcp6Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Generate client Duid in the format of Duid-llt.
|
||||
|
||||
@ -31,12 +30,11 @@ Dhcp6GenerateClientId (
|
||||
UINT32 Stamp;
|
||||
EFI_GUID Uuid;
|
||||
|
||||
|
||||
//
|
||||
// Attempt to get client Id from variable to keep it constant.
|
||||
// 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) {
|
||||
return Duid;
|
||||
}
|
||||
@ -84,17 +82,15 @@ Dhcp6GenerateClientId (
|
||||
//
|
||||
// sizeof (Duid-type + UUID-size) = 18 bytes
|
||||
//
|
||||
Duid->Length = (UINT16) (18);
|
||||
Duid->Length = (UINT16)(18);
|
||||
|
||||
//
|
||||
// Set the Duid-type and copy UUID.
|
||||
//
|
||||
WriteUnaligned16 ((UINT16 *) (Duid->Duid), HTONS (Dhcp6DuidTypeUuid));
|
||||
|
||||
CopyMem (Duid->Duid + 2, &Uuid, sizeof(EFI_GUID));
|
||||
WriteUnaligned16 ((UINT16 *)(Duid->Duid), HTONS (Dhcp6DuidTypeUuid));
|
||||
|
||||
CopyMem (Duid->Duid + 2, &Uuid, sizeof (EFI_GUID));
|
||||
} else {
|
||||
|
||||
//
|
||||
//
|
||||
// The format of DUID-LLT:
|
||||
@ -133,14 +129,14 @@ Dhcp6GenerateClientId (
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
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));
|
||||
WriteUnaligned32 ((UINT32 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 4), HTONL (Stamp));
|
||||
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));
|
||||
WriteUnaligned32 ((UINT32 *)((UINT8 *)Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 4), HTONL (Stamp));
|
||||
|
||||
CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);
|
||||
}
|
||||
@ -150,7 +146,7 @@ Dhcp6GenerateClientId (
|
||||
&gEfiDhcp6ServiceBindingProtocolGuid,
|
||||
(EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS),
|
||||
Duid->Length + 2,
|
||||
(VOID *) Duid
|
||||
(VOID *)Duid
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Duid);
|
||||
@ -160,7 +156,6 @@ Dhcp6GenerateClientId (
|
||||
return Duid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Copy the Dhcp6 configure data.
|
||||
|
||||
@ -187,7 +182,6 @@ Dhcp6CopyConfigData (
|
||||
// Allocate another buffer for solicitretransmission, and copy it.
|
||||
//
|
||||
if (SorCfg->SolicitRetransmission != NULL) {
|
||||
|
||||
DstCfg->SolicitRetransmission = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
|
||||
|
||||
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 *);
|
||||
DstCfg->OptionList = AllocateZeroPool (OptionListSize);
|
||||
|
||||
@ -217,7 +210,6 @@ Dhcp6CopyConfigData (
|
||||
}
|
||||
|
||||
for (Index = 0; Index < SorCfg->OptionCount; Index++) {
|
||||
|
||||
OptionSize = NTOHS (SorCfg->OptionList[Index]->OpLen) + 4;
|
||||
DstCfg->OptionList[Index] = AllocateZeroPool (OptionSize);
|
||||
|
||||
@ -239,7 +231,6 @@ Dhcp6CopyConfigData (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up the configure data.
|
||||
|
||||
@ -264,6 +255,7 @@ Dhcp6CleanupConfigData (
|
||||
FreePool (CfgData->OptionList[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (CfgData->OptionList);
|
||||
}
|
||||
|
||||
@ -274,7 +266,6 @@ Dhcp6CleanupConfigData (
|
||||
ZeroMem (CfgData, sizeof (EFI_DHCP6_CONFIG_DATA));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up the mode data.
|
||||
|
||||
@ -296,17 +287,16 @@ Dhcp6CleanupModeData (
|
||||
}
|
||||
|
||||
if (ModeData->Ia != NULL) {
|
||||
|
||||
if (ModeData->Ia->ReplyPacket != NULL) {
|
||||
FreePool (ModeData->Ia->ReplyPacket);
|
||||
}
|
||||
|
||||
FreePool (ModeData->Ia);
|
||||
}
|
||||
|
||||
ZeroMem (ModeData, sizeof (EFI_DHCP6_MODE_DATA));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Calculate the expire time by the algorithm defined in rfc.
|
||||
|
||||
@ -335,8 +325,8 @@ Dhcp6CalculateExpireTime (
|
||||
//
|
||||
gRT->GetTime (&Time, NULL);
|
||||
Seed = ((Time.Nanosecond >> 10) & DHCP6_10_BIT_MASK);
|
||||
Signed = (BOOLEAN) ((((Time.Nanosecond >> 9) & 0x01) != 0) ? TRUE : FALSE);
|
||||
Signed = (BOOLEAN) (NeedSigned ? Signed : FALSE);
|
||||
Signed = (BOOLEAN)((((Time.Nanosecond >> 9) & 0x01) != 0) ? TRUE : FALSE);
|
||||
Signed = (BOOLEAN)(NeedSigned ? Signed : FALSE);
|
||||
|
||||
//
|
||||
// Calculate expire by the following algo:
|
||||
@ -348,20 +338,13 @@ Dhcp6CalculateExpireTime (
|
||||
// The (Seed / 0x3ff / 10) is used to a random range (0, 0.1).
|
||||
//
|
||||
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) {
|
||||
|
||||
Expire = Base + (UINT32) (Base * Seed / DHCP6_10_BIT_MASK / 10);
|
||||
|
||||
Expire = Base + (UINT32)(Base * Seed / DHCP6_10_BIT_MASK / 10);
|
||||
} 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 {
|
||||
|
||||
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;
|
||||
@ -369,7 +352,6 @@ Dhcp6CalculateExpireTime (
|
||||
return Expire;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Calculate the lease time by the algorithm defined in rfc.
|
||||
|
||||
@ -387,7 +369,7 @@ Dhcp6CalculateLeaseTime (
|
||||
|
||||
ASSERT (IaCb->Ia->IaAddressCount > 0);
|
||||
|
||||
MinLt = (UINT32) (-1);
|
||||
MinLt = (UINT32)(-1);
|
||||
MaxLt = 0;
|
||||
|
||||
//
|
||||
@ -409,7 +391,6 @@ Dhcp6CalculateLeaseTime (
|
||||
IaCb->LeaseTime = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
//
|
||||
for (Index1 = 0; Index1 < AddressCount; Index1++) {
|
||||
|
||||
Found = FALSE;
|
||||
|
||||
for (Index2 = 0; Index2 < Ia->IaAddressCount; Index2++) {
|
||||
|
||||
if (CompareMem (
|
||||
&Addresses[Index1],
|
||||
&Ia->IaAddress[Index2],
|
||||
sizeof (EFI_IPv6_ADDRESS)
|
||||
) == 0) {
|
||||
|
||||
) == 0)
|
||||
{
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -461,7 +440,6 @@ Dhcp6CheckAddress (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
//
|
||||
for (Index1 = 0; Index1 < AddressCount; Index1++) {
|
||||
|
||||
Found = FALSE;
|
||||
|
||||
for (Index2 = 0; Index2 < Ia->IaAddressCount; Index2++) {
|
||||
|
||||
if (CompareMem (
|
||||
&Addresses[Index1],
|
||||
&Ia->IaAddress[Index2],
|
||||
sizeof (EFI_IPv6_ADDRESS)
|
||||
) == 0) {
|
||||
) == 0)
|
||||
{
|
||||
//
|
||||
// Copy the deprived address to the copy of Ia
|
||||
//
|
||||
@ -549,10 +526,12 @@ Dhcp6DepriveAddress (
|
||||
(Ia->IaAddressCount - Index2 - 1) * sizeof (EFI_DHCP6_IA_ADDRESS)
|
||||
);
|
||||
}
|
||||
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT (Found == TRUE);
|
||||
}
|
||||
|
||||
@ -562,7 +541,6 @@ Dhcp6DepriveAddress (
|
||||
return IaCopy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The dummy ext buffer free callback routine.
|
||||
|
||||
@ -577,7 +555,6 @@ Dhcp6DummyExtFree (
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The callback routine once message transmitted.
|
||||
|
||||
@ -599,7 +576,6 @@ Dhcp6OnTransmitted (
|
||||
NetbufFree (Wrap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Append the option to Buf, and move Buf to the end.
|
||||
|
||||
@ -633,9 +609,9 @@ Dhcp6AppendOption (
|
||||
|
||||
ASSERT (OptLen != 0);
|
||||
|
||||
WriteUnaligned16 ((UINT16 *) Buf, OptType);
|
||||
WriteUnaligned16 ((UINT16 *)Buf, OptType);
|
||||
Buf += 2;
|
||||
WriteUnaligned16 ((UINT16 *) Buf, OptLen);
|
||||
WriteUnaligned16 ((UINT16 *)Buf, OptLen);
|
||||
Buf += 2;
|
||||
CopyMem (Buf, Data, NTOHS (OptLen));
|
||||
Buf += NTOHS (OptLen);
|
||||
@ -658,9 +634,8 @@ Dhcp6AppendIaAddrOption (
|
||||
IN OUT UINT8 *Buf,
|
||||
IN EFI_DHCP6_IA_ADDRESS *IaAddr,
|
||||
IN UINT32 MessageType
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
// The format of the IA Address option is:
|
||||
//
|
||||
// 0 1 2 3
|
||||
@ -685,14 +660,14 @@ Dhcp6AppendIaAddrOption (
|
||||
//
|
||||
// Fill the value of Ia Address option type
|
||||
//
|
||||
WriteUnaligned16 ((UINT16 *) Buf, HTONS (Dhcp6OptIaAddr));
|
||||
WriteUnaligned16 ((UINT16 *)Buf, HTONS (Dhcp6OptIaAddr));
|
||||
Buf += 2;
|
||||
|
||||
WriteUnaligned16 ((UINT16 *) Buf, HTONS (sizeof (EFI_DHCP6_IA_ADDRESS)));
|
||||
WriteUnaligned16 ((UINT16 *)Buf, HTONS (sizeof (EFI_DHCP6_IA_ADDRESS)));
|
||||
Buf += 2;
|
||||
|
||||
CopyMem (Buf, &IaAddr->IpAddress, sizeof(EFI_IPv6_ADDRESS));
|
||||
Buf += sizeof(EFI_IPv6_ADDRESS);
|
||||
CopyMem (Buf, &IaAddr->IpAddress, sizeof (EFI_IPv6_ADDRESS));
|
||||
Buf += sizeof (EFI_IPv6_ADDRESS);
|
||||
|
||||
//
|
||||
// Fill the value of preferred-lifetime and valid-lifetime.
|
||||
@ -700,19 +675,20 @@ Dhcp6AppendIaAddrOption (
|
||||
// should set to 0 when initiate a Confirm message.
|
||||
//
|
||||
if (MessageType != Dhcp6MsgConfirm) {
|
||||
WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->PreferredLifetime));
|
||||
WriteUnaligned32 ((UINT32 *)Buf, HTONL (IaAddr->PreferredLifetime));
|
||||
}
|
||||
|
||||
Buf += 4;
|
||||
|
||||
if (MessageType != Dhcp6MsgConfirm) {
|
||||
WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->ValidLifetime));
|
||||
WriteUnaligned32 ((UINT32 *)Buf, HTONL (IaAddr->ValidLifetime));
|
||||
}
|
||||
|
||||
Buf += 4;
|
||||
|
||||
return Buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
//
|
||||
WriteUnaligned16 ((UINT16 *) Buf, HTONS (Ia->Descriptor.Type));
|
||||
WriteUnaligned16 ((UINT16 *)Buf, HTONS (Ia->Descriptor.Type));
|
||||
Buf += 2;
|
||||
|
||||
//
|
||||
// Fill the len of Ia option later, keep the pointer first
|
||||
//
|
||||
Len = (UINT16 *) Buf;
|
||||
Len = (UINT16 *)Buf;
|
||||
Buf += 2;
|
||||
|
||||
//
|
||||
// Fill the value of iaid
|
||||
//
|
||||
WriteUnaligned32 ((UINT32 *) Buf, HTONL (Ia->Descriptor.IaId));
|
||||
WriteUnaligned32 ((UINT32 *)Buf, HTONL (Ia->Descriptor.IaId));
|
||||
Buf += 4;
|
||||
|
||||
//
|
||||
// Fill the value of t1 and t2 if iana, keep it 0xffffffff if no specified.
|
||||
//
|
||||
if (Ia->Descriptor.Type == Dhcp6OptIana) {
|
||||
WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T1 != 0) ? T1 : 0xffffffff));
|
||||
WriteUnaligned32 ((UINT32 *)Buf, HTONL ((T1 != 0) ? T1 : 0xffffffff));
|
||||
Buf += 4;
|
||||
WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T2 != 0) ? T2 : 0xffffffff));
|
||||
WriteUnaligned32 ((UINT32 *)Buf, HTONL ((T2 != 0) ? T2 : 0xffffffff));
|
||||
Buf += 4;
|
||||
}
|
||||
|
||||
@ -789,14 +765,14 @@ Dhcp6AppendIaOption (
|
||||
// Fill all the addresses belong to the Ia
|
||||
//
|
||||
for (Index = 0; Index < Ia->IaAddressCount; Index++) {
|
||||
AddrOpt = (UINT8 *) Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS);
|
||||
Buf = Dhcp6AppendIaAddrOption (Buf, (EFI_DHCP6_IA_ADDRESS *) AddrOpt, MessageType);
|
||||
AddrOpt = (UINT8 *)Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS);
|
||||
Buf = Dhcp6AppendIaAddrOption (Buf, (EFI_DHCP6_IA_ADDRESS *)AddrOpt, MessageType);
|
||||
}
|
||||
|
||||
//
|
||||
// Fill the value of Ia option length
|
||||
//
|
||||
*Len = HTONS ((UINT16) (Buf - (UINT8 *) Len - 2));
|
||||
*Len = HTONS ((UINT16)(Buf - (UINT8 *)Len - 2));
|
||||
|
||||
return Buf;
|
||||
}
|
||||
@ -833,21 +809,21 @@ Dhcp6AppendETOption (
|
||||
//
|
||||
// Fill the value of elapsed-time option type.
|
||||
//
|
||||
WriteUnaligned16 ((UINT16 *) Buf, HTONS (Dhcp6OptElapsedTime));
|
||||
WriteUnaligned16 ((UINT16 *)Buf, HTONS (Dhcp6OptElapsedTime));
|
||||
Buf += 2;
|
||||
|
||||
//
|
||||
// Fill the len of elapsed-time option, which is fixed.
|
||||
//
|
||||
WriteUnaligned16 ((UINT16 *) Buf, HTONS(2));
|
||||
WriteUnaligned16 ((UINT16 *)Buf, HTONS (2));
|
||||
Buf += 2;
|
||||
|
||||
//
|
||||
// Fill in elapsed time value with 0 value for now. The actual value is
|
||||
// filled in later just before the packet is transmitted.
|
||||
//
|
||||
WriteUnaligned16 ((UINT16 *) Buf, HTONS(0));
|
||||
*Elapsed = (UINT16 *) Buf;
|
||||
WriteUnaligned16 ((UINT16 *)Buf, HTONS (0));
|
||||
*Elapsed = (UINT16 *)Buf;
|
||||
Buf += 2;
|
||||
|
||||
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,
|
||||
100
|
||||
) +
|
||||
DivU64x32(
|
||||
DivU64x32 (
|
||||
Time.Nanosecond,
|
||||
10000000
|
||||
);
|
||||
@ -902,9 +878,9 @@ SetElapsedTime (
|
||||
ElapsedTimeValue = 0xffff;
|
||||
}
|
||||
}
|
||||
WriteUnaligned16 (Elapsed, HTONS((UINT16) ElapsedTimeValue));
|
||||
}
|
||||
|
||||
WriteUnaligned16 (Elapsed, HTONS ((UINT16)ElapsedTimeValue));
|
||||
}
|
||||
|
||||
/**
|
||||
Seek the address of the first byte of the option header.
|
||||
@ -936,19 +912,19 @@ Dhcp6SeekOption (
|
||||
// The format of Dhcp6 option refers to Dhcp6AppendOption().
|
||||
//
|
||||
while (Cursor < Buf + SeekLen) {
|
||||
OpCode = ReadUnaligned16 ((UINT16 *) Cursor);
|
||||
OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
|
||||
if (OpCode == HTONS (OptType)) {
|
||||
Option = Cursor;
|
||||
break;
|
||||
}
|
||||
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2)));
|
||||
|
||||
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
|
||||
Cursor += (DataLen + 4);
|
||||
}
|
||||
|
||||
return Option;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Seek the address of the first byte of the Ia option header.
|
||||
|
||||
@ -980,13 +956,14 @@ Dhcp6SeekIaOption (
|
||||
Cursor = Buf;
|
||||
|
||||
while (Cursor < Buf + SeekLen) {
|
||||
OpCode = ReadUnaligned16 ((UINT16 *) Cursor);
|
||||
IaId = ReadUnaligned32 ((UINT32 *) (Cursor + 4));
|
||||
if (OpCode == HTONS (IaDesc->Type) && IaId == HTONL (IaDesc->IaId)) {
|
||||
OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
|
||||
IaId = ReadUnaligned32 ((UINT32 *)(Cursor + 4));
|
||||
if ((OpCode == HTONS (IaDesc->Type)) && (IaId == HTONL (IaDesc->IaId))) {
|
||||
Option = Cursor;
|
||||
break;
|
||||
}
|
||||
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2)));
|
||||
|
||||
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
|
||||
Cursor += (DataLen + 4);
|
||||
}
|
||||
|
||||
@ -1015,10 +992,11 @@ Dhcp6AddrIsInCurrentIa (
|
||||
ASSERT (IaAddr != NULL && CurrentIa != NULL);
|
||||
|
||||
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 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
|
||||
// that the client already has recorded in the IA, and discard the Ia address option with 0 valid time.
|
||||
//
|
||||
OpCode = ReadUnaligned16 ((UINT16 *) Cursor);
|
||||
PreferredLt = NTOHL (ReadUnaligned32 ((UINT32 *) (Cursor + 20)));
|
||||
ValidLt = NTOHL (ReadUnaligned32 ((UINT32 *) (Cursor + 24)));
|
||||
IaAddr = (EFI_DHCP6_IA_ADDRESS *) (Cursor + 4);
|
||||
if (OpCode == HTONS (Dhcp6OptIaAddr) && ValidLt >= PreferredLt &&
|
||||
(Dhcp6AddrIsInCurrentIa(IaAddr, CurrentIa) || ValidLt !=0)) {
|
||||
OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
|
||||
PreferredLt = NTOHL (ReadUnaligned32 ((UINT32 *)(Cursor + 20)));
|
||||
ValidLt = NTOHL (ReadUnaligned32 ((UINT32 *)(Cursor + 24)));
|
||||
IaAddr = (EFI_DHCP6_IA_ADDRESS *)(Cursor + 4);
|
||||
if ((OpCode == HTONS (Dhcp6OptIaAddr)) && (ValidLt >= PreferredLt) &&
|
||||
(Dhcp6AddrIsInCurrentIa (IaAddr, CurrentIa) || (ValidLt != 0)))
|
||||
{
|
||||
if (AddrBuf != NULL) {
|
||||
CopyMem (AddrBuf, IaAddr, sizeof (EFI_DHCP6_IA_ADDRESS));
|
||||
AddrBuf->PreferredLifetime = PreferredLt;
|
||||
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)++;
|
||||
}
|
||||
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2)));
|
||||
|
||||
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
|
||||
Cursor += (DataLen + 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a control block for the Ia according to the corresponding options.
|
||||
|
||||
@ -1172,8 +1152,8 @@ Dhcp6GenerateIaCb (
|
||||
if (Instance->IaCb.Ia->ReplyPacket != NULL) {
|
||||
FreePool (Instance->IaCb.Ia->ReplyPacket);
|
||||
}
|
||||
FreePool (Instance->IaCb.Ia);
|
||||
|
||||
FreePool (Instance->IaCb.Ia);
|
||||
|
||||
ZeroMem (&Instance->IaCb, sizeof (DHCP6_IA_CB));
|
||||
|
||||
@ -1193,7 +1173,6 @@ Dhcp6GenerateIaCb (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Cache the current IA configuration information.
|
||||
|
||||
@ -1223,8 +1202,10 @@ Dhcp6CacheIa (
|
||||
if (Instance->CacheIa == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (Instance->CacheIa, Ia, IaSize);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1271,7 +1252,7 @@ Dhcp6AppendCacheIa (
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
//
|
||||
@ -1303,7 +1284,7 @@ Dhcp6GetMappingTimeOut (
|
||||
UINTN DataSize;
|
||||
EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
|
||||
|
||||
if (Ip6Cfg == NULL || TimeOut == NULL) {
|
||||
if ((Ip6Cfg == NULL) || (TimeOut == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#ifndef __EFI_DHCP6_UTILITY_H__
|
||||
#define __EFI_DHCP6_UTILITY_H__
|
||||
|
||||
|
||||
#define DHCP6_10_BIT_MASK 0x3ff
|
||||
#define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
|
||||
|
||||
@ -310,7 +309,6 @@ Dhcp6GenerateIaCb (
|
||||
IN UINT32 T2
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Cache the current IA configuration information.
|
||||
|
||||
@ -325,7 +323,6 @@ Dhcp6CacheIa (
|
||||
IN DHCP6_INSTANCE *Instance
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Append CacheIa to the current IA. Meanwhile, clear CacheIa.ValidLifetime to 0.
|
||||
|
||||
@ -351,4 +348,5 @@ Dhcp6GetMappingTimeOut (
|
||||
IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg,
|
||||
OUT UINTN *TimeOut
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the EFI Driver.
|
||||
|
||||
@ -91,7 +92,6 @@ DnsComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
///
|
||||
/// Component Name Protocol instance
|
||||
///
|
||||
@ -107,8 +107,8 @@ EFI_COMPONENT_NAME_PROTOCOL gDnsComponentName = {
|
||||
///
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED
|
||||
EFI_COMPONENT_NAME2_PROTOCOL gDnsComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) DnsComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) DnsComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)DnsComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)DnsComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
@ -208,6 +208,7 @@ UpdateDns4Name (
|
||||
if (ModeData.DnsCacheList != NULL) {
|
||||
FreePool (ModeData.DnsCacheList);
|
||||
}
|
||||
|
||||
if (ModeData.DnsServerList != NULL) {
|
||||
FreePool (ModeData.DnsServerList);
|
||||
}
|
||||
@ -255,7 +256,7 @@ UpdateDns6Name (
|
||||
EFI_STATUS Status;
|
||||
CHAR16 HandleName[128];
|
||||
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) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -274,6 +275,7 @@ UpdateDns6Name (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
UnicodeSPrint (
|
||||
HandleName,
|
||||
sizeof (HandleName),
|
||||
@ -285,6 +287,7 @@ UpdateDns6Name (
|
||||
if (ModeData.DnsCacheList != NULL) {
|
||||
FreePool (ModeData.DnsCacheList);
|
||||
}
|
||||
|
||||
if (ModeData.DnsServerList != NULL) {
|
||||
FreePool (ModeData.DnsServerList);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ DnsInitSeedPacket (
|
||||
ZeroMem (Header, sizeof (EFI_DHCP4_HEADER));
|
||||
Header->OpCode = DHCP4_OPCODE_REQUEST;
|
||||
Header->HwType = InterfaceInfo->IfType;
|
||||
Header->HwAddrLen = (UINT8) InterfaceInfo->HwAddressSize;
|
||||
Header->HwAddrLen = (UINT8)InterfaceInfo->HwAddressSize;
|
||||
CopyMem (Header->ClientHwAddr, &(InterfaceInfo->HwAddress), Header->HwAddrLen);
|
||||
|
||||
Seed->Dhcp4.Magik = DHCP4_MAGIC;
|
||||
@ -56,10 +56,10 @@ DhcpCommonNotify (
|
||||
)
|
||||
{
|
||||
if ((Event == NULL) || (Context == NULL)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
*((BOOLEAN *) Context) = TRUE;
|
||||
*((BOOLEAN *)Context) = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +119,6 @@ ParseDhcp4Ack (
|
||||
// Get DNS server addresses
|
||||
//
|
||||
if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) {
|
||||
|
||||
if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
break;
|
||||
@ -131,7 +130,7 @@ ParseDhcp4Ack (
|
||||
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));
|
||||
}
|
||||
|
||||
@ -201,7 +200,7 @@ ParseDhcp6Ack (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
DnsServerInfor = (DNS6_SERVER_INFOR *) Context;
|
||||
DnsServerInfor = (DNS6_SERVER_INFOR *)Context;
|
||||
|
||||
for (Index = 0; Index < OptionCount; Index++) {
|
||||
OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode);
|
||||
@ -211,7 +210,6 @@ ParseDhcp6Ack (
|
||||
// Get DNS server addresses from this reply packet.
|
||||
//
|
||||
if (OptionList[Index]->OpCode == DHCP6_TAG_DNS_SERVER) {
|
||||
|
||||
if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
gBS->FreePool (OptionList);
|
||||
@ -225,7 +223,7 @@ ParseDhcp6Ack (
|
||||
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));
|
||||
}
|
||||
|
||||
@ -237,7 +235,6 @@ ParseDhcp6Ack (
|
||||
gBS->FreePool (OptionList);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -295,7 +292,7 @@ GetDns4ServerFromDhcp4 (
|
||||
Data = NULL;
|
||||
InterfaceInfo = NULL;
|
||||
|
||||
ZeroMem ((UINT8 *) ParaList, sizeof (ParaList));
|
||||
ZeroMem ((UINT8 *)ParaList, sizeof (ParaList));
|
||||
|
||||
ZeroMem (&MnpConfigData, sizeof (EFI_MANAGED_NETWORK_CONFIG_DATA));
|
||||
|
||||
@ -332,7 +329,7 @@ GetDns4ServerFromDhcp4 (
|
||||
Status = gBS->OpenProtocol (
|
||||
MnpChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
(VOID **) &Mnp,
|
||||
(VOID **)&Mnp,
|
||||
Image,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -352,7 +349,7 @@ GetDns4ServerFromDhcp4 (
|
||||
MnpConfigData.EnableReceiveTimestamps = FALSE;
|
||||
MnpConfigData.DisableBackgroundPolling = FALSE;
|
||||
|
||||
Status = Mnp->Configure(Mnp, &MnpConfigData);
|
||||
Status = Mnp->Configure (Mnp, &MnpConfigData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -373,7 +370,7 @@ GetDns4ServerFromDhcp4 (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dhcp4Handle,
|
||||
&gEfiDhcp4ProtocolGuid,
|
||||
(VOID **) &Dhcp4,
|
||||
(VOID **)&Dhcp4,
|
||||
Image,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -385,13 +382,13 @@ GetDns4ServerFromDhcp4 (
|
||||
//
|
||||
// Get Ip4Config2 instance info.
|
||||
//
|
||||
Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);
|
||||
Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -470,7 +467,7 @@ GetDns4ServerFromDhcp4 (
|
||||
|
||||
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);
|
||||
|
||||
@ -651,7 +648,7 @@ GetDns6ServerFromDhcp6 (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dhcp6Handle,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
(VOID **) &Dhcp6,
|
||||
(VOID **)&Dhcp6,
|
||||
Image,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -753,6 +750,4 @@ ON_EXIT:
|
||||
);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define DHCP4_TAG_PARA_LIST 55
|
||||
#define DHCP4_TAG_DNS_SERVER 6
|
||||
|
||||
|
||||
#define DHCP6_TAG_DNS_REQUEST 6
|
||||
#define DHCP6_TAG_DNS_SERVER 23
|
||||
|
||||
|
@ -61,7 +61,7 @@ DnsDestroyInstance (
|
||||
Dns6InstanceCancelToken (Instance, NULL);
|
||||
}
|
||||
|
||||
if (Instance->UdpIo!= NULL) {
|
||||
if (Instance->UdpIo != NULL) {
|
||||
UdpIoFreeIo (Instance->UdpIo);
|
||||
}
|
||||
|
||||
@ -146,14 +146,14 @@ DnsDestroyChildEntryInHandleBuffer (
|
||||
UINTN NumberOfChildren;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
|
||||
if (Entry == NULL || Context == NULL) {
|
||||
if ((Entry == NULL) || (Context == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = NET_LIST_USER_STRUCT_S (Entry, DNS_INSTANCE, Link, DNS_INSTANCE_SIGNATURE);
|
||||
ServiceBinding = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
|
||||
NumberOfChildren = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
|
||||
ServiceBinding = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
|
||||
NumberOfChildren = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((DNS_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
|
||||
|
||||
if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
|
||||
return EFI_SUCCESS;
|
||||
@ -299,6 +299,7 @@ DnsCreateService (
|
||||
if (DnsSb->TimerToGetMap != NULL) {
|
||||
gBS->CloseEvent (DnsSb->TimerToGetMap);
|
||||
}
|
||||
|
||||
FreePool (DnsSb);
|
||||
return Status;
|
||||
}
|
||||
@ -315,6 +316,7 @@ DnsCreateService (
|
||||
if (DnsSb->TimerToGetMap != NULL) {
|
||||
gBS->CloseEvent (DnsSb->TimerToGetMap);
|
||||
}
|
||||
|
||||
gBS->CloseEvent (DnsSb->Timer);
|
||||
FreePool (DnsSb);
|
||||
return EFI_DEVICE_ERROR;
|
||||
@ -355,7 +357,7 @@ DnsUnload (
|
||||
//
|
||||
// Disconnect the driver specified by ImageHandle
|
||||
//
|
||||
Status = NetLibDefaultUnload(ImageHandle);
|
||||
Status = NetLibDefaultUnload (ImageHandle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -493,20 +495,20 @@ DnsDriverEntryPoint (
|
||||
|
||||
return Status;
|
||||
|
||||
Error4:
|
||||
Error4:
|
||||
gBS->CloseEvent (mDriverData->Timer);
|
||||
|
||||
Error3:
|
||||
Error3:
|
||||
FreePool (mDriverData);
|
||||
|
||||
Error2:
|
||||
Error2:
|
||||
EfiLibUninstallDriverBindingComponentName2 (
|
||||
&gDns6DriverBinding,
|
||||
&gDnsComponentName,
|
||||
&gDnsComponentName2
|
||||
);
|
||||
|
||||
Error1:
|
||||
Error1:
|
||||
EfiLibUninstallDriverBindingComponentName2 (
|
||||
&gDns4DriverBinding,
|
||||
&gDnsComponentName,
|
||||
@ -733,7 +735,7 @@ Dns4DriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiDns4ServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
NicHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -760,7 +762,7 @@ Dns4DriverBindingStop (
|
||||
);
|
||||
}
|
||||
|
||||
if (NumberOfChildren == 0 && IsListEmpty (&DnsSb->Dns4ChildrenList)) {
|
||||
if ((NumberOfChildren == 0) && IsListEmpty (&DnsSb->Dns4ChildrenList)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
NicHandle,
|
||||
&gEfiDns4ServiceBindingProtocolGuid,
|
||||
@ -998,7 +1000,7 @@ Dns6DriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiDns6ServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
NicHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1025,7 +1027,7 @@ Dns6DriverBindingStop (
|
||||
);
|
||||
}
|
||||
|
||||
if (NumberOfChildren == 0 && IsListEmpty (&DnsSb->Dns6ChildrenList)) {
|
||||
if ((NumberOfChildren == 0) && IsListEmpty (&DnsSb->Dns6ChildrenList)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
NicHandle,
|
||||
&gEfiDns6ServiceBindingProtocolGuid,
|
||||
@ -1087,6 +1089,7 @@ Dns4ServiceBindingCreateChild (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (Instance != NULL);
|
||||
|
||||
//
|
||||
@ -1110,7 +1113,7 @@ Dns4ServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
DnsSb->ConnectUdp->UdpHandle,
|
||||
&gEfiUdp4ProtocolGuid,
|
||||
(VOID **) &Udp4,
|
||||
(VOID **)&Udp4,
|
||||
gDns4DriverBinding.DriverBindingHandle,
|
||||
Instance->ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1132,7 +1135,7 @@ Dns4ServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
Instance->UdpIo->UdpHandle,
|
||||
&gEfiUdp4ProtocolGuid,
|
||||
(VOID **) &Udp4,
|
||||
(VOID **)&Udp4,
|
||||
gDns4DriverBinding.DriverBindingHandle,
|
||||
Instance->ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1218,7 +1221,7 @@ Dns4ServiceBindingDestroyChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiDns4ProtocolGuid,
|
||||
(VOID **) &Dns4,
|
||||
(VOID **)&Dns4,
|
||||
gDns4DriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1330,6 +1333,7 @@ Dns6ServiceBindingCreateChild (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (Instance != NULL);
|
||||
|
||||
//
|
||||
@ -1353,7 +1357,7 @@ Dns6ServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
DnsSb->ConnectUdp->UdpHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
(VOID **) &Udp6,
|
||||
(VOID **)&Udp6,
|
||||
gDns6DriverBinding.DriverBindingHandle,
|
||||
Instance->ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1375,7 +1379,7 @@ Dns6ServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
Instance->UdpIo->UdpHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
(VOID **) &Udp6,
|
||||
(VOID **)&Udp6,
|
||||
gDns6DriverBinding.DriverBindingHandle,
|
||||
Instance->ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1461,7 +1465,7 @@ Dns6ServiceBindingDestroyChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiDns6ProtocolGuid,
|
||||
(VOID **) &Dns6,
|
||||
(VOID **)&Dns6,
|
||||
gDns6DriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
|
@ -103,7 +103,6 @@ extern DNS_DRIVER_DATA *mDriverData;
|
||||
#define DNS_INSTANCE_FROM_THIS_PROTOCOL6(a) \
|
||||
CR (a, DNS_INSTANCE, Dns6, DNS_INSTANCE_SIGNATURE)
|
||||
|
||||
|
||||
/**
|
||||
Destroy the DNS instance and recycle the resources.
|
||||
|
||||
@ -594,5 +593,4 @@ Dns6ServiceBindingDestroyChild (
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -29,7 +29,7 @@ Dns4RemoveTokenEntry (
|
||||
//
|
||||
// Find the TokenEntry first.
|
||||
//
|
||||
Item = NetMapFindKey (TokenMap, (VOID *) TokenEntry);
|
||||
Item = NetMapFindKey (TokenMap, (VOID *)TokenEntry);
|
||||
|
||||
if (Item != NULL) {
|
||||
//
|
||||
@ -64,7 +64,7 @@ Dns6RemoveTokenEntry (
|
||||
//
|
||||
// Find the TokenEntry first.
|
||||
//
|
||||
Item = NetMapFindKey (TokenMap, (VOID *) TokenEntry);
|
||||
Item = NetMapFindKey (TokenMap, (VOID *)TokenEntry);
|
||||
|
||||
if (Item != NULL) {
|
||||
//
|
||||
@ -115,8 +115,8 @@ Dns4CancelTokens (
|
||||
// If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in
|
||||
// Item->Value.
|
||||
//
|
||||
Packet = (NET_BUF *) (Item->Value);
|
||||
UdpIo = (UDP_IO *) (*((UINTN *) &Packet->ProtoData[0]));
|
||||
Packet = (NET_BUF *)(Item->Value);
|
||||
UdpIo = (UDP_IO *)(*((UINTN *)&Packet->ProtoData[0]));
|
||||
|
||||
UdpIoCancelSentDatagram (UdpIo, Packet);
|
||||
}
|
||||
@ -124,7 +124,7 @@ Dns4CancelTokens (
|
||||
//
|
||||
// Remove TokenEntry from Dns4TxTokens.
|
||||
//
|
||||
TokenEntry = (DNS4_TOKEN_ENTRY *) Item->Key;
|
||||
TokenEntry = (DNS4_TOKEN_ENTRY *)Item->Key;
|
||||
if (Dns4RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) {
|
||||
TokenEntry->Token->Status = EFI_ABORTED;
|
||||
gBS->SignalEvent (TokenEntry->Token->Event);
|
||||
@ -175,8 +175,8 @@ Dns6CancelTokens (
|
||||
// If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in
|
||||
// Item->Value.
|
||||
//
|
||||
Packet = (NET_BUF *) (Item->Value);
|
||||
UdpIo = (UDP_IO *) (*((UINTN *) &Packet->ProtoData[0]));
|
||||
Packet = (NET_BUF *)(Item->Value);
|
||||
UdpIo = (UDP_IO *)(*((UINTN *)&Packet->ProtoData[0]));
|
||||
|
||||
UdpIoCancelSentDatagram (UdpIo, Packet);
|
||||
}
|
||||
@ -184,7 +184,7 @@ Dns6CancelTokens (
|
||||
//
|
||||
// Remove TokenEntry from Dns6TxTokens.
|
||||
//
|
||||
TokenEntry = (DNS6_TOKEN_ENTRY *) Item->Key;
|
||||
TokenEntry = (DNS6_TOKEN_ENTRY *)Item->Key;
|
||||
if (Dns6RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) {
|
||||
TokenEntry->Token->Status = EFI_ABORTED;
|
||||
gBS->SignalEvent (TokenEntry->Token->Event);
|
||||
@ -223,7 +223,7 @@ GetDns4TokenEntry (
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
|
||||
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) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -259,13 +259,13 @@ GetDns6TokenEntry (
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
|
||||
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) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
*TokenEntry =NULL;
|
||||
*TokenEntry = NULL;
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -293,7 +293,7 @@ Dns4InstanceCancelToken (
|
||||
|
||||
TokenEntry = NULL;
|
||||
|
||||
if(Token != NULL ) {
|
||||
if (Token != NULL ) {
|
||||
Status = GetDns4TokenEntry (&Instance->Dns4TxTokens, Token, &TokenEntry);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -315,6 +315,7 @@ Dns4InstanceCancelToken (
|
||||
if (NetMapIsEmpty (&Instance->Dns4TxTokens)) {
|
||||
Instance->UdpIo->Protocol.Udp4->Cancel (Instance->UdpIo->Protocol.Udp4, &Instance->UdpIo->RecvRequest->Token.Udp4);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -350,7 +351,7 @@ Dns6InstanceCancelToken (
|
||||
|
||||
TokenEntry = NULL;
|
||||
|
||||
if(Token != NULL ) {
|
||||
if (Token != NULL ) {
|
||||
Status = GetDns6TokenEntry (&Instance->Dns6TxTokens, Token, &TokenEntry);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -372,6 +373,7 @@ Dns6InstanceCancelToken (
|
||||
if (NetMapIsEmpty (&Instance->Dns6TxTokens)) {
|
||||
Instance->UdpIo->Protocol.Udp6->Cancel (Instance->UdpIo->Protocol.Udp6, &Instance->UdpIo->RecvRequest->Token.Udp6);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -563,10 +565,10 @@ Dns4GetMapping (
|
||||
Udp->Poll (Udp);
|
||||
|
||||
if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) &&
|
||||
Ip4Mode.IsConfigured) {
|
||||
|
||||
Ip4Mode.IsConfigured)
|
||||
{
|
||||
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) {
|
||||
Item = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);
|
||||
if (StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0 && \
|
||||
CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS)) == 0) {
|
||||
if ((StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0) && \
|
||||
(CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS)) == 0))
|
||||
{
|
||||
//
|
||||
// This is the Dns cache entry
|
||||
//
|
||||
@ -874,8 +877,9 @@ UpdateDns6Cache (
|
||||
//
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, Dns6CacheList) {
|
||||
Item = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);
|
||||
if (StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0 && \
|
||||
CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS)) == 0) {
|
||||
if ((StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0) && \
|
||||
(CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS)) == 0))
|
||||
{
|
||||
//
|
||||
// This is the Dns cache entry
|
||||
//
|
||||
@ -1079,20 +1083,20 @@ IsValidDnsResponse (
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
|
||||
*Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
|
||||
Packet = (NET_BUF *) ((*Item)->Value);
|
||||
Packet = (NET_BUF *)((*Item)->Value);
|
||||
if (Packet == NULL) {
|
||||
|
||||
continue;
|
||||
} else {
|
||||
TxString = NetbufGetByte (Packet, 0, NULL);
|
||||
ASSERT (TxString != NULL);
|
||||
DnsHeader = (DNS_HEADER *) TxString;
|
||||
QueryName = (CHAR8 *) (TxString + sizeof (*DnsHeader));
|
||||
QuerySection = (DNS_QUERY_SECTION *) (QueryName + AsciiStrLen (QueryName) + 1);
|
||||
DnsHeader = (DNS_HEADER *)TxString;
|
||||
QueryName = (CHAR8 *)(TxString + sizeof (*DnsHeader));
|
||||
QuerySection = (DNS_QUERY_SECTION *)(QueryName + AsciiStrLen (QueryName) + 1);
|
||||
|
||||
if (NTOHS (DnsHeader->Identification) == Identification &&
|
||||
NTOHS (QuerySection->Type) == Type &&
|
||||
NTOHS (QuerySection->Class) == Class) {
|
||||
if ((NTOHS (DnsHeader->Identification) == Identification) &&
|
||||
(NTOHS (QuerySection->Type) == Type) &&
|
||||
(NTOHS (QuerySection->Class) == Class))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -1191,7 +1195,7 @@ ParseDnsResponse (
|
||||
//
|
||||
// Get header
|
||||
//
|
||||
DnsHeader = (DNS_HEADER *) RxString;
|
||||
DnsHeader = (DNS_HEADER *)RxString;
|
||||
|
||||
DnsHeader->Identification = NTOHS (DnsHeader->Identification);
|
||||
DnsHeader->Flags.Uint16 = NTOHS (DnsHeader->Flags.Uint16);
|
||||
@ -1212,9 +1216,9 @@ ParseDnsResponse (
|
||||
//
|
||||
// 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.
|
||||
@ -1229,7 +1233,7 @@ ParseDnsResponse (
|
||||
//
|
||||
// Get query section
|
||||
//
|
||||
QuerySection = (DNS_QUERY_SECTION *) (QueryName + QueryNameLen);
|
||||
QuerySection = (DNS_QUERY_SECTION *)(QueryName + QueryNameLen);
|
||||
QuerySection->Type = NTOHS (QuerySection->Type);
|
||||
QuerySection->Class = NTOHS (QuerySection->Class);
|
||||
|
||||
@ -1245,13 +1249,15 @@ ParseDnsResponse (
|
||||
QuerySection->Type,
|
||||
QuerySection->Class,
|
||||
&Item
|
||||
)) {
|
||||
))
|
||||
{
|
||||
*Completed = FALSE;
|
||||
Status = EFI_ABORTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
ASSERT (Item != NULL);
|
||||
Dns4TokenEntry = (DNS4_TOKEN_ENTRY *) (Item->Key);
|
||||
Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(Item->Key);
|
||||
} else {
|
||||
if (!IsValidDnsResponse (
|
||||
&Instance->Dns6TxTokens,
|
||||
@ -1259,20 +1265,23 @@ ParseDnsResponse (
|
||||
QuerySection->Type,
|
||||
QuerySection->Class,
|
||||
&Item
|
||||
)) {
|
||||
))
|
||||
{
|
||||
*Completed = FALSE;
|
||||
Status = EFI_ABORTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
ASSERT (Item != NULL);
|
||||
Dns6TokenEntry = (DNS6_TOKEN_ENTRY *) (Item->Key);
|
||||
Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(Item->Key);
|
||||
}
|
||||
|
||||
//
|
||||
// Continue Check Some Errors.
|
||||
//
|
||||
if (DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR || DnsHeader->AnswersNum < 1 || \
|
||||
DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE) {
|
||||
if ((DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR) || (DnsHeader->AnswersNum < 1) || \
|
||||
(DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE))
|
||||
{
|
||||
//
|
||||
// The domain name referenced in the query does not exist.
|
||||
//
|
||||
@ -1300,6 +1309,7 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Dns4TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD));
|
||||
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -1315,6 +1325,7 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Dns4TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv4_ADDRESS));
|
||||
if (Dns4TokenEntry->Token->RspData.H2AData->IpList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -1337,6 +1348,7 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Dns6TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD));
|
||||
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -1352,6 +1364,7 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Dns6TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv6_ADDRESS));
|
||||
if (Dns6TokenEntry->Token->RspData.H2AData->IpList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -1369,7 +1382,7 @@ ParseDnsResponse (
|
||||
//
|
||||
// Get Answer name
|
||||
//
|
||||
AnswerName = (CHAR8 *) QuerySection + sizeof (*QuerySection);
|
||||
AnswerName = (CHAR8 *)QuerySection + sizeof (*QuerySection);
|
||||
|
||||
//
|
||||
// Processing AnswerSection.
|
||||
@ -1389,7 +1402,7 @@ ParseDnsResponse (
|
||||
//
|
||||
// Answer name should be PTR, else EFI_UNSUPPORTED returned.
|
||||
//
|
||||
if ((*(UINT8 *) AnswerName & 0xC0) != 0xC0) {
|
||||
if ((*(UINT8 *)AnswerName & 0xC0) != 0xC0) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -1397,7 +1410,7 @@ ParseDnsResponse (
|
||||
//
|
||||
// Get Answer section.
|
||||
//
|
||||
AnswerSection = (DNS_ANSWER_SECTION *) (AnswerName + sizeof (UINT16));
|
||||
AnswerSection = (DNS_ANSWER_SECTION *)(AnswerName + sizeof (UINT16));
|
||||
AnswerSection->Type = NTOHS (AnswerSection->Type);
|
||||
AnswerSection->Class = NTOHS (AnswerSection->Class);
|
||||
AnswerSection->Ttl = NTOHL (AnswerSection->Ttl);
|
||||
@ -1417,9 +1430,9 @@ ParseDnsResponse (
|
||||
//
|
||||
// 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;
|
||||
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
|
||||
AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
|
||||
|
||||
//
|
||||
// Fill the ResourceRecord.
|
||||
@ -1429,6 +1442,7 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
CopyMem (Dns4RR[RRCount].QName, QueryName, AsciiStrLen (QueryName));
|
||||
Dns4RR[RRCount].QType = AnswerSection->Type;
|
||||
Dns4RR[RRCount].QClass = AnswerSection->Class;
|
||||
@ -1439,13 +1453,14 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
CopyMem (Dns4RR[RRCount].RData, AnswerData, Dns4RR[RRCount].DataLength);
|
||||
|
||||
RRCount ++;
|
||||
RRCount++;
|
||||
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;
|
||||
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
|
||||
AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
|
||||
|
||||
//
|
||||
// Fill the ResourceRecord.
|
||||
@ -1455,6 +1470,7 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
CopyMem (Dns6RR[RRCount].QName, QueryName, AsciiStrLen (QueryName));
|
||||
Dns6RR[RRCount].QType = AnswerSection->Type;
|
||||
Dns6RR[RRCount].QClass = AnswerSection->Class;
|
||||
@ -1465,9 +1481,10 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
CopyMem (Dns6RR[RRCount].RData, AnswerData, Dns6RR[RRCount].DataLength);
|
||||
|
||||
RRCount ++;
|
||||
RRCount++;
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
//
|
||||
@ -1487,7 +1504,7 @@ ParseDnsResponse (
|
||||
}
|
||||
|
||||
HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList;
|
||||
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
|
||||
AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
|
||||
CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS));
|
||||
|
||||
//
|
||||
@ -1498,20 +1515,23 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
Dns4CacheEntry->HostName = AllocateZeroPool (2 * (StrLen(Dns4TokenEntry->QueryHostName) + 1));
|
||||
|
||||
Dns4CacheEntry->HostName = AllocateZeroPool (2 * (StrLen (Dns4TokenEntry->QueryHostName) + 1));
|
||||
if (Dns4CacheEntry->HostName == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
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));
|
||||
if (Dns4CacheEntry->IpAddress == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
Dns4CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);
|
||||
@ -1531,7 +1551,7 @@ ParseDnsResponse (
|
||||
FreePool (Dns4CacheEntry);
|
||||
Dns4CacheEntry = NULL;
|
||||
|
||||
IpCount ++;
|
||||
IpCount++;
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
case DNS_TYPE_AAAA:
|
||||
@ -1546,7 +1566,7 @@ ParseDnsResponse (
|
||||
}
|
||||
|
||||
HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList;
|
||||
AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
|
||||
AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
|
||||
CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS));
|
||||
|
||||
//
|
||||
@ -1557,20 +1577,23 @@ ParseDnsResponse (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
Dns6CacheEntry->HostName = AllocateZeroPool (2 * (StrLen(Dns6TokenEntry->QueryHostName) + 1));
|
||||
|
||||
Dns6CacheEntry->HostName = AllocateZeroPool (2 * (StrLen (Dns6TokenEntry->QueryHostName) + 1));
|
||||
if (Dns6CacheEntry->HostName == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
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));
|
||||
if (Dns6CacheEntry->IpAddress == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
Dns6CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);
|
||||
@ -1590,7 +1613,7 @@ ParseDnsResponse (
|
||||
FreePool (Dns6CacheEntry);
|
||||
Dns6CacheEntry = NULL;
|
||||
|
||||
IpCount ++;
|
||||
IpCount++;
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
case DNS_TYPE_CNAME:
|
||||
@ -1610,8 +1633,8 @@ ParseDnsResponse (
|
||||
//
|
||||
// Find next one
|
||||
//
|
||||
AnswerName = (CHAR8 *) AnswerSection + sizeof (*AnswerSection) + AnswerSection->DataLength;
|
||||
AnswerSectionNum ++;
|
||||
AnswerName = (CHAR8 *)AnswerSection + sizeof (*AnswerSection) + AnswerSection->DataLength;
|
||||
AnswerSectionNum++;
|
||||
}
|
||||
|
||||
if (Instance->Service->IpVersion == IP_VERSION_4) {
|
||||
@ -1646,8 +1669,8 @@ ON_COMPLETE:
|
||||
//
|
||||
// Parsing is complete, free the sending packet and signal Event here.
|
||||
//
|
||||
if (Item != NULL && Item->Value != NULL) {
|
||||
NetbufFree ((NET_BUF *) (Item->Value));
|
||||
if ((Item != NULL) && (Item->Value != NULL)) {
|
||||
NetbufFree ((NET_BUF *)(Item->Value));
|
||||
}
|
||||
|
||||
if (Instance->Service->IpVersion == IP_VERSION_4) {
|
||||
@ -1678,7 +1701,7 @@ ON_EXIT:
|
||||
if (Dns4TokenEntry->Token->RspData.GLookupData != NULL) {
|
||||
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList != NULL) {
|
||||
while (RRCount != 0) {
|
||||
RRCount --;
|
||||
RRCount--;
|
||||
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) {
|
||||
FreePool (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName);
|
||||
}
|
||||
@ -1694,7 +1717,7 @@ ON_EXIT:
|
||||
FreePool (Dns4TokenEntry->Token->RspData.GLookupData);
|
||||
}
|
||||
} 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) {
|
||||
FreePool (Dns4TokenEntry->Token->RspData.H2AData->IpList);
|
||||
}
|
||||
@ -1710,7 +1733,7 @@ ON_EXIT:
|
||||
if (Dns6TokenEntry->Token->RspData.GLookupData != NULL) {
|
||||
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList != NULL) {
|
||||
while (RRCount != 0) {
|
||||
RRCount --;
|
||||
RRCount--;
|
||||
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) {
|
||||
FreePool (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName);
|
||||
}
|
||||
@ -1726,7 +1749,7 @@ ON_EXIT:
|
||||
FreePool (Dns6TokenEntry->Token->RspData.GLookupData);
|
||||
}
|
||||
} 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) {
|
||||
FreePool (Dns6TokenEntry->Token->RspData.H2AData->IpList);
|
||||
}
|
||||
@ -1791,7 +1814,7 @@ DnsOnPacketReceived (
|
||||
|
||||
BOOLEAN Completed;
|
||||
|
||||
Instance = (DNS_INSTANCE *) Context;
|
||||
Instance = (DNS_INSTANCE *)Context;
|
||||
NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE);
|
||||
|
||||
RcvString = NULL;
|
||||
@ -1851,7 +1874,7 @@ DnsOnPacketSent (
|
||||
Dns4TokenEntry = NULL;
|
||||
Dns6TokenEntry = NULL;
|
||||
|
||||
Instance = (DNS_INSTANCE *) Context;
|
||||
Instance = (DNS_INSTANCE *)Context;
|
||||
NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE);
|
||||
|
||||
if (Instance->Service->IpVersion == IP_VERSION_4) {
|
||||
@ -1953,8 +1976,8 @@ ConstructDNSQuery (
|
||||
//
|
||||
// Fill header
|
||||
//
|
||||
DnsHeader = (DNS_HEADER *) Frag.Bulk;
|
||||
DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed());
|
||||
DnsHeader = (DNS_HEADER *)Frag.Bulk;
|
||||
DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed ());
|
||||
DnsHeader->Flags.Uint16 = 0x0000;
|
||||
DnsHeader->Flags.Bits.RD = 1;
|
||||
DnsHeader->Flags.Bits.OpCode = DNS_FLAGS_OPCODE_STANDARD;
|
||||
@ -1977,14 +2000,14 @@ ConstructDNSQuery (
|
||||
// Fill Query name
|
||||
//
|
||||
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.Len ++;
|
||||
Frag.Len++;
|
||||
|
||||
//
|
||||
// Rest query section
|
||||
//
|
||||
DnsQuery = (DNS_QUERY_SECTION *) (Frag.Bulk + Frag.Len);
|
||||
DnsQuery = (DNS_QUERY_SECTION *)(Frag.Bulk + Frag.Len);
|
||||
|
||||
DnsQuery->Type = HTONS (Type);
|
||||
DnsQuery->Class = HTONS (Class);
|
||||
@ -2003,7 +2026,7 @@ ConstructDNSQuery (
|
||||
//
|
||||
// Store the UdpIo in ProtoData.
|
||||
//
|
||||
*((UINTN *) &((*Packet)->ProtoData[0])) = (UINTN) (Instance->UdpIo);
|
||||
*((UINTN *)&((*Packet)->ProtoData[0])) = (UINTN)(Instance->UdpIo);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -2082,8 +2105,7 @@ DnsOnTimerRetransmit (
|
||||
Dns4TokenEntry = NULL;
|
||||
Dns6TokenEntry = NULL;
|
||||
|
||||
Service = (DNS_SERVICE *) Context;
|
||||
|
||||
Service = (DNS_SERVICE *)Context;
|
||||
|
||||
if (Service->IpVersion == IP_VERSION_4) {
|
||||
//
|
||||
@ -2097,7 +2119,7 @@ DnsOnTimerRetransmit (
|
||||
while (EntryNetMap != &Instance->Dns4TxTokens.Used) {
|
||||
ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link);
|
||||
Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(ItemNetMap->Key);
|
||||
if (Dns4TokenEntry->PacketToLive == 0 || (--Dns4TokenEntry->PacketToLive > 0)) {
|
||||
if ((Dns4TokenEntry->PacketToLive == 0) || (--Dns4TokenEntry->PacketToLive > 0)) {
|
||||
EntryNetMap = EntryNetMap->ForwardLink;
|
||||
continue;
|
||||
}
|
||||
@ -2140,8 +2162,8 @@ DnsOnTimerRetransmit (
|
||||
EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink;
|
||||
while (EntryNetMap != &Instance->Dns6TxTokens.Used) {
|
||||
ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link);
|
||||
Dns6TokenEntry = (DNS6_TOKEN_ENTRY *) (ItemNetMap->Key);
|
||||
if (Dns6TokenEntry->PacketToLive == 0 || (--Dns6TokenEntry->PacketToLive > 0)) {
|
||||
Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(ItemNetMap->Key);
|
||||
if ((Dns6TokenEntry->PacketToLive == 0) || (--Dns6TokenEntry->PacketToLive > 0)) {
|
||||
EntryNetMap = EntryNetMap->ForwardLink;
|
||||
continue;
|
||||
}
|
||||
@ -2151,7 +2173,7 @@ DnsOnTimerRetransmit (
|
||||
// otherwise exit the transfer.
|
||||
//
|
||||
if (++Dns6TokenEntry->RetryCounting <= Dns6TokenEntry->Token->RetryCount) {
|
||||
DnsRetransmit (Instance, (NET_BUF *) ItemNetMap->Value);
|
||||
DnsRetransmit (Instance, (NET_BUF *)ItemNetMap->Value);
|
||||
EntryNetMap = EntryNetMap->ForwardLink;
|
||||
} else {
|
||||
//
|
||||
@ -2166,7 +2188,7 @@ DnsOnTimerRetransmit (
|
||||
// Free the sending packet.
|
||||
//
|
||||
if (ItemNetMap->Value != NULL) {
|
||||
NetbufFree ((NET_BUF *) (ItemNetMap->Value));
|
||||
NetbufFree ((NET_BUF *)(ItemNetMap->Value));
|
||||
}
|
||||
|
||||
EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink;
|
||||
@ -2242,4 +2264,3 @@ DnsOnTimerUpdate (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,14 +127,14 @@ typedef struct {
|
||||
|
||||
union _DNS_FLAGS {
|
||||
struct {
|
||||
UINT16 RCode:4;
|
||||
UINT16 Zero:3;
|
||||
UINT16 RA:1;
|
||||
UINT16 RD:1;
|
||||
UINT16 TC:1;
|
||||
UINT16 AA:1;
|
||||
UINT16 OpCode:4;
|
||||
UINT16 QR:1;
|
||||
UINT16 RCode : 4;
|
||||
UINT16 Zero : 3;
|
||||
UINT16 RA : 1;
|
||||
UINT16 RD : 1;
|
||||
UINT16 TC : 1;
|
||||
UINT16 AA : 1;
|
||||
UINT16 OpCode : 4;
|
||||
UINT16 QR : 1;
|
||||
} Bits;
|
||||
UINT16 Uint16;
|
||||
};
|
||||
@ -173,7 +173,6 @@ typedef struct {
|
||||
#define DNS4_DOMAIN L"in-addr.arpa"
|
||||
#define DNS6_DOMAIN L"IP6.ARPA"
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/**
|
||||
@ -710,7 +709,6 @@ DnsOnTimerUpdate (
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieve mode data of this DNS instance.
|
||||
|
||||
@ -954,7 +952,6 @@ Dns4Cancel (
|
||||
IN EFI_DNS4_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieve mode data of this DNS instance.
|
||||
|
||||
|
@ -73,7 +73,6 @@ Dns4GetModeData (
|
||||
CacheList = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
|
||||
if ((This == NULL) || (DnsModeData == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -103,7 +102,7 @@ Dns4GetModeData (
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4ServerList) {
|
||||
Index++;
|
||||
}
|
||||
DnsModeData->DnsServerCount = (UINT32) Index;
|
||||
DnsModeData->DnsServerCount = (UINT32)Index;
|
||||
ServerList = AllocatePool (sizeof (EFI_IPv4_ADDRESS) * DnsModeData->DnsServerCount);
|
||||
if (ServerList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -122,11 +121,11 @@ Dns4GetModeData (
|
||||
//
|
||||
// Get the DnsCacheCount and DnsCacheList
|
||||
//
|
||||
Index =0;
|
||||
Index = 0;
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {
|
||||
Index++;
|
||||
}
|
||||
DnsModeData->DnsCacheCount = (UINT32) Index;
|
||||
DnsModeData->DnsCacheCount = (UINT32)Index;
|
||||
CacheList = AllocatePool (sizeof (EFI_DNS4_CACHE_ENTRY) * DnsModeData->DnsCacheCount);
|
||||
if (CacheList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -135,7 +134,7 @@ Dns4GetModeData (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Index =0;
|
||||
Index = 0;
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {
|
||||
CacheItem = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);
|
||||
CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof (EFI_DNS4_CACHE_ENTRY));
|
||||
@ -193,13 +192,14 @@ Dns4Configure (
|
||||
Status = EFI_SUCCESS;
|
||||
ServerList = NULL;
|
||||
|
||||
if (This == NULL ||
|
||||
(DnsConfigData != NULL && ((DnsConfigData->DnsServerListCount != 0 && DnsConfigData->DnsServerList == NULL) ||
|
||||
(DnsConfigData->DnsServerListCount == 0 && DnsConfigData->DnsServerList != NULL)))) {
|
||||
if ((This == NULL) ||
|
||||
((DnsConfigData != NULL) && (((DnsConfigData->DnsServerListCount != 0) && (DnsConfigData->DnsServerList == NULL)) ||
|
||||
((DnsConfigData->DnsServerListCount == 0) && (DnsConfigData->DnsServerList != NULL)))))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (DnsConfigData != NULL && DnsConfigData->Protocol != DNS_PROTOCOL_UDP) {
|
||||
if ((DnsConfigData != NULL) && (DnsConfigData->Protocol != DNS_PROTOCOL_UDP)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -213,8 +213,8 @@ Dns4Configure (
|
||||
//
|
||||
// Reset the Instance if ConfigData is NULL
|
||||
//
|
||||
if (!NetMapIsEmpty(&Instance->Dns4TxTokens)) {
|
||||
Dns4InstanceCancelToken(Instance, NULL);
|
||||
if (!NetMapIsEmpty (&Instance->Dns4TxTokens)) {
|
||||
Dns4InstanceCancelToken (Instance, NULL);
|
||||
}
|
||||
|
||||
if (Instance->UdpIo != NULL) {
|
||||
@ -224,6 +224,7 @@ Dns4Configure (
|
||||
if (Instance->Dns4CfgData.DnsServerList != NULL) {
|
||||
FreePool (Instance->Dns4CfgData.DnsServerList);
|
||||
}
|
||||
|
||||
ZeroMem (&Instance->Dns4CfgData, sizeof (EFI_DNS4_CONFIG_DATA));
|
||||
|
||||
Instance->State = DNS_STATE_UNCONFIGED;
|
||||
@ -238,7 +239,8 @@ Dns4Configure (
|
||||
Netmask = NTOHL (Netmask);
|
||||
|
||||
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;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -263,7 +265,7 @@ Dns4Configure (
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT(ServerList != NULL);
|
||||
ASSERT (ServerList != NULL);
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
@ -281,6 +283,7 @@ Dns4Configure (
|
||||
FreePool (Instance->Dns4CfgData.DnsServerList);
|
||||
Instance->Dns4CfgData.DnsServerList = NULL;
|
||||
}
|
||||
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -293,6 +296,7 @@ Dns4Configure (
|
||||
FreePool (Instance->Dns4CfgData.DnsServerList);
|
||||
Instance->Dns4CfgData.DnsServerList = NULL;
|
||||
}
|
||||
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -359,7 +363,7 @@ Dns4HostNameToIp (
|
||||
//
|
||||
// Validate the parameters
|
||||
//
|
||||
if ((This == NULL) || (HostName == NULL) || Token == NULL) {
|
||||
if ((This == NULL) || (HostName == NULL) || (Token == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -430,7 +434,7 @@ Dns4HostNameToIp (
|
||||
Index = 0;
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {
|
||||
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));
|
||||
Index++;
|
||||
}
|
||||
@ -451,7 +455,7 @@ Dns4HostNameToIp (
|
||||
//
|
||||
// Construct DNS TokenEntry.
|
||||
//
|
||||
TokenEntry = AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY));
|
||||
TokenEntry = AllocateZeroPool (sizeof (DNS4_TOKEN_ENTRY));
|
||||
if (TokenEntry == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
@ -614,7 +618,7 @@ Dns4GeneralLookUp (
|
||||
//
|
||||
// Validate the parameters
|
||||
//
|
||||
if ((This == NULL) || (QName == NULL) || Token == NULL) {
|
||||
if ((This == NULL) || (QName == NULL) || (Token == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -655,7 +659,7 @@ Dns4GeneralLookUp (
|
||||
//
|
||||
// Construct DNS TokenEntry.
|
||||
//
|
||||
TokenEntry = AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY));
|
||||
TokenEntry = AllocateZeroPool (sizeof (DNS4_TOKEN_ENTRY));
|
||||
if (TokenEntry == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
@ -752,7 +756,7 @@ Dns4UpdateDnsCache (
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -951,8 +955,8 @@ Dns6GetModeData (
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6ServerList) {
|
||||
Index++;
|
||||
}
|
||||
DnsModeData->DnsServerCount = (UINT32) Index;
|
||||
ServerList = AllocatePool (sizeof(EFI_IPv6_ADDRESS) * DnsModeData->DnsServerCount);
|
||||
DnsModeData->DnsServerCount = (UINT32)Index;
|
||||
ServerList = AllocatePool (sizeof (EFI_IPv6_ADDRESS) * DnsModeData->DnsServerCount);
|
||||
if (ServerList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
Dns6CleanConfigure (&DnsModeData->DnsConfigData);
|
||||
@ -970,12 +974,12 @@ Dns6GetModeData (
|
||||
//
|
||||
// Get the DnsCacheCount and DnsCacheList
|
||||
//
|
||||
Index =0;
|
||||
Index = 0;
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {
|
||||
Index++;
|
||||
}
|
||||
DnsModeData->DnsCacheCount = (UINT32) Index;
|
||||
CacheList = AllocatePool (sizeof(EFI_DNS6_CACHE_ENTRY) * DnsModeData->DnsCacheCount);
|
||||
DnsModeData->DnsCacheCount = (UINT32)Index;
|
||||
CacheList = AllocatePool (sizeof (EFI_DNS6_CACHE_ENTRY) * DnsModeData->DnsCacheCount);
|
||||
if (CacheList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
Dns6CleanConfigure (&DnsModeData->DnsConfigData);
|
||||
@ -983,7 +987,7 @@ Dns6GetModeData (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Index =0;
|
||||
Index = 0;
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {
|
||||
CacheItem = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);
|
||||
CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof (EFI_DNS6_CACHE_ENTRY));
|
||||
@ -1037,13 +1041,14 @@ Dns6Configure (
|
||||
Status = EFI_SUCCESS;
|
||||
ServerList = NULL;
|
||||
|
||||
if (This == NULL ||
|
||||
(DnsConfigData != NULL && ((DnsConfigData->DnsServerCount != 0 && DnsConfigData->DnsServerList == NULL) ||
|
||||
(DnsConfigData->DnsServerCount == 0 && DnsConfigData->DnsServerList != NULL)))) {
|
||||
if ((This == NULL) ||
|
||||
((DnsConfigData != NULL) && (((DnsConfigData->DnsServerCount != 0) && (DnsConfigData->DnsServerList == NULL)) ||
|
||||
((DnsConfigData->DnsServerCount == 0) && (DnsConfigData->DnsServerList != NULL)))))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (DnsConfigData != NULL && DnsConfigData->Protocol != DNS_PROTOCOL_UDP) {
|
||||
if ((DnsConfigData != NULL) && (DnsConfigData->Protocol != DNS_PROTOCOL_UDP)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -1057,8 +1062,8 @@ Dns6Configure (
|
||||
//
|
||||
// Reset the Instance if ConfigData is NULL
|
||||
//
|
||||
if (!NetMapIsEmpty(&Instance->Dns6TxTokens)) {
|
||||
Dns6InstanceCancelToken(Instance, NULL);
|
||||
if (!NetMapIsEmpty (&Instance->Dns6TxTokens)) {
|
||||
Dns6InstanceCancelToken (Instance, NULL);
|
||||
}
|
||||
|
||||
if (Instance->UdpIo != NULL) {
|
||||
@ -1068,6 +1073,7 @@ Dns6Configure (
|
||||
if (Instance->Dns6CfgData.DnsServerList != NULL) {
|
||||
FreePool (Instance->Dns6CfgData.DnsServerList);
|
||||
}
|
||||
|
||||
ZeroMem (&Instance->Dns6CfgData, sizeof (EFI_DNS6_CONFIG_DATA));
|
||||
|
||||
Instance->State = DNS_STATE_UNCONFIGED;
|
||||
@ -1089,7 +1095,7 @@ Dns6Configure (
|
||||
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 (
|
||||
Instance->Service->ImageHandle,
|
||||
@ -1101,7 +1107,7 @@ Dns6Configure (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
ASSERT(ServerList != NULL);
|
||||
ASSERT (ServerList != NULL);
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
@ -1121,6 +1127,7 @@ Dns6Configure (
|
||||
FreePool (Instance->Dns6CfgData.DnsServerList);
|
||||
Instance->Dns6CfgData.DnsServerList = NULL;
|
||||
}
|
||||
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -1133,6 +1140,7 @@ Dns6Configure (
|
||||
FreePool (Instance->Dns6CfgData.DnsServerList);
|
||||
Instance->Dns6CfgData.DnsServerList = NULL;
|
||||
}
|
||||
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -1201,7 +1209,7 @@ Dns6HostNameToIp (
|
||||
//
|
||||
// Validate the parameters
|
||||
//
|
||||
if ((This == NULL) || (HostName == NULL) || Token == NULL) {
|
||||
if ((This == NULL) || (HostName == NULL) || (Token == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1272,7 +1280,7 @@ Dns6HostNameToIp (
|
||||
Index = 0;
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {
|
||||
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));
|
||||
Index++;
|
||||
}
|
||||
@ -1459,7 +1467,7 @@ Dns6GeneralLookUp (
|
||||
//
|
||||
// Validate the parameters
|
||||
//
|
||||
if ((This == NULL) || (QName == NULL) || Token == NULL) {
|
||||
if ((This == NULL) || (QName == NULL) || (Token == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1500,7 +1508,7 @@ Dns6GeneralLookUp (
|
||||
//
|
||||
// Construct DNS TokenEntry.
|
||||
//
|
||||
TokenEntry = AllocateZeroPool (sizeof(DNS6_TOKEN_ENTRY));
|
||||
TokenEntry = AllocateZeroPool (sizeof (DNS6_TOKEN_ENTRY));
|
||||
if (TokenEntry == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
@ -1598,7 +1606,7 @@ Dns6UpdateDnsCache (
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1726,4 +1734,3 @@ Dns6Cancel (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
// 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.
|
||||
@ -81,7 +81,7 @@ DpcQueueDpc (
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ DpcDispatchDpc (
|
||||
//
|
||||
// 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
|
||||
|
@ -77,4 +77,3 @@ DpcDispatchDpc (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -42,6 +42,7 @@ HttpBootUpdateDevicePath (
|
||||
if (Node == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->Ipv4.Header.SubType = MSG_IPv4_DP;
|
||||
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
|
||||
@ -56,6 +57,7 @@ HttpBootUpdateDevicePath (
|
||||
if (Node == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->Ipv6.Header.SubType = MSG_IPv6_DP;
|
||||
SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
|
||||
@ -68,7 +70,7 @@ HttpBootUpdateDevicePath (
|
||||
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);
|
||||
if (TmpIpDevicePath == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -84,13 +86,14 @@ HttpBootUpdateDevicePath (
|
||||
FreePool (TmpIpDevicePath);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->DevPath.SubType = MSG_DNS_DP;
|
||||
SetDevicePathNodeLength (Node, Length);
|
||||
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 (TmpIpDevicePath);
|
||||
TmpIpDevicePath = NULL;
|
||||
@ -108,24 +111,28 @@ HttpBootUpdateDevicePath (
|
||||
if (TmpIpDevicePath != NULL) {
|
||||
FreePool (TmpIpDevicePath);
|
||||
}
|
||||
|
||||
if (TmpDnsDevicePath != NULL) {
|
||||
FreePool (TmpDnsDevicePath);
|
||||
}
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->DevPath.SubType = MSG_URI_DP;
|
||||
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) {
|
||||
NewDevicePath = AppendDevicePathNode (TmpDnsDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
|
||||
NewDevicePath = AppendDevicePathNode (TmpDnsDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
|
||||
FreePool (TmpDnsDevicePath);
|
||||
} else {
|
||||
ASSERT (TmpIpDevicePath != NULL);
|
||||
NewDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
|
||||
NewDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
|
||||
FreePool (TmpIpDevicePath);
|
||||
}
|
||||
|
||||
FreePool (Node);
|
||||
if (NewDevicePath == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -160,6 +167,7 @@ HttpBootUpdateDevicePath (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
FreePool (Private->Ip6Nic->DevicePath);
|
||||
Private->Ip6Nic->DevicePath = NewDevicePath;
|
||||
}
|
||||
@ -209,15 +217,17 @@ HttpBootDhcp4ExtractUriInfo (
|
||||
//
|
||||
if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns))
|
||||
{
|
||||
HttpOffer = SelectOffer;
|
||||
} else {
|
||||
ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
|
||||
ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
|
||||
HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;
|
||||
}
|
||||
|
||||
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 {
|
||||
//
|
||||
// In Home environment the BootFileUri comes from the FilePath.
|
||||
@ -237,12 +247,14 @@ HttpBootDhcp4ExtractUriInfo (
|
||||
} else if (Status == EFI_ACCESS_DENIED) {
|
||||
AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n");
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) ||
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns))
|
||||
{
|
||||
Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER];
|
||||
ASSERT (Option != NULL);
|
||||
|
||||
@ -257,7 +269,7 @@ HttpBootDhcp4ExtractUriInfo (
|
||||
}
|
||||
|
||||
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->Port
|
||||
);
|
||||
if (EFI_ERROR (Status) || Private->Port == 0) {
|
||||
if (EFI_ERROR (Status) || (Private->Port == 0)) {
|
||||
Private->Port = 80;
|
||||
}
|
||||
|
||||
@ -295,7 +307,7 @@ HttpBootDhcp4ExtractUriInfo (
|
||||
// Update the device path to include the boot resource information.
|
||||
//
|
||||
Status = HttpBootUpdateDevicePath (Private);
|
||||
if (EFI_ERROR (Status) && Private->DnsServerIp != NULL) {
|
||||
if (EFI_ERROR (Status) && (Private->DnsServerIp != NULL)) {
|
||||
FreePool (Private->DnsServerIp);
|
||||
Private->DnsServerIp = NULL;
|
||||
}
|
||||
@ -349,15 +361,17 @@ HttpBootDhcp6ExtractUriInfo (
|
||||
//
|
||||
if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns))
|
||||
{
|
||||
HttpOffer = SelectOffer;
|
||||
} else {
|
||||
ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
|
||||
ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
|
||||
HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;
|
||||
}
|
||||
|
||||
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 {
|
||||
//
|
||||
// In Home environment the BootFileUri comes from the FilePath.
|
||||
@ -377,6 +391,7 @@ HttpBootDhcp6ExtractUriInfo (
|
||||
} else if (Status == EFI_ACCESS_DENIED) {
|
||||
AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n");
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -398,7 +413,8 @@ HttpBootDhcp6ExtractUriInfo (
|
||||
|
||||
if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) ||
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {
|
||||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns))
|
||||
{
|
||||
Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];
|
||||
ASSERT (Option != NULL);
|
||||
|
||||
@ -413,7 +429,7 @@ HttpBootDhcp6ExtractUriInfo (
|
||||
}
|
||||
|
||||
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->Port
|
||||
);
|
||||
if (EFI_ERROR (Status) || Private->Port == 0) {
|
||||
if (EFI_ERROR (Status) || (Private->Port == 0)) {
|
||||
Private->Port = 80;
|
||||
}
|
||||
|
||||
@ -510,7 +526,6 @@ Error:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Discover all the boot information for boot file.
|
||||
|
||||
@ -565,17 +580,19 @@ HttpBootHttpIoCallback (
|
||||
{
|
||||
HTTP_BOOT_PRIVATE_DATA *Private;
|
||||
EFI_STATUS Status;
|
||||
Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
|
||||
|
||||
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
|
||||
if (Private->HttpBootCallback != NULL) {
|
||||
Status = Private->HttpBootCallback->Callback (
|
||||
Private->HttpBootCallback,
|
||||
EventType == HttpIoRequest ? HttpBootHttpRequest : HttpBootHttpResponse,
|
||||
EventType == HttpIoRequest ? FALSE : TRUE,
|
||||
sizeof (EFI_HTTP_MESSAGE),
|
||||
(VOID *) Message
|
||||
(VOID *)Message
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -625,7 +642,7 @@ HttpBootCreateHttpIo (
|
||||
Private->UsingIpv6 ? IP_VERSION_6 : IP_VERSION_4,
|
||||
&ConfigData,
|
||||
HttpBootHttpIoCallback,
|
||||
(VOID *) Private,
|
||||
(VOID *)Private,
|
||||
&Private->HttpIo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -660,6 +677,7 @@ HttpBootFreeCache (
|
||||
if (Cache->RequestData->Url != NULL) {
|
||||
FreePool (Cache->RequestData->Url);
|
||||
}
|
||||
|
||||
FreePool (Cache->RequestData);
|
||||
}
|
||||
|
||||
@ -672,6 +690,7 @@ HttpBootFreeCache (
|
||||
FreePool (Cache->ResponseData->Headers[Index].FieldName);
|
||||
FreePool (Cache->ResponseData->Headers[Index].FieldValue);
|
||||
}
|
||||
|
||||
FreePool (Cache->ResponseData->Headers);
|
||||
}
|
||||
}
|
||||
@ -684,6 +703,7 @@ HttpBootFreeCache (
|
||||
if (EntityData->Block != NULL) {
|
||||
FreePool (EntityData->Block);
|
||||
}
|
||||
|
||||
RemoveEntryList (&EntityData->Link);
|
||||
FreePool (EntityData);
|
||||
}
|
||||
@ -747,7 +767,7 @@ HttpBootGetFileFromCache (
|
||||
HTTP_BOOT_ENTITY_DATA *EntityData;
|
||||
UINTN CopyedSize;
|
||||
|
||||
if (Uri == NULL || BufferSize == NULL || Buffer == NULL || ImageType == NULL) {
|
||||
if ((Uri == NULL) || (BufferSize == NULL) || (Buffer == NULL) || (ImageType == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -758,7 +778,8 @@ HttpBootGetFileFromCache (
|
||||
//
|
||||
if ((Cache->RequestData != NULL) &&
|
||||
(Cache->RequestData->Url != NULL) &&
|
||||
(StrCmp (Uri, Cache->RequestData->Url) == 0)) {
|
||||
(StrCmp (Uri, Cache->RequestData->Url) == 0))
|
||||
{
|
||||
//
|
||||
// Hit in cache, record image type.
|
||||
//
|
||||
@ -831,7 +852,7 @@ HttpBootGetBootFileCallback (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
CallbackData = (HTTP_BOOT_CALLBACK_DATA *) Context;
|
||||
CallbackData = (HTTP_BOOT_CALLBACK_DATA *)Context;
|
||||
HttpBootCallback = CallbackData->Private->HttpBootCallback;
|
||||
if (HttpBootCallback != NULL) {
|
||||
Status = HttpBootCallback->Callback (
|
||||
@ -845,6 +866,7 @@ HttpBootGetBootFileCallback (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Copy data if caller has provided a buffer.
|
||||
//
|
||||
@ -865,14 +887,17 @@ HttpBootGetBootFileCallback (
|
||||
if (NewEntityData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
if (CallbackData->NewBlock) {
|
||||
NewEntityData->Block = CallbackData->Block;
|
||||
CallbackData->Block = NULL;
|
||||
}
|
||||
|
||||
NewEntityData->DataLength = Length;
|
||||
NewEntityData->DataStart = (UINT8*) Data;
|
||||
NewEntityData->DataStart = (UINT8 *)Data;
|
||||
InsertTailList (&CallbackData->Cache->EntityDataList, &NewEntityData->Link);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -930,11 +955,11 @@ HttpBootGetBootFile (
|
||||
ASSERT (Private != NULL);
|
||||
ASSERT (Private->HttpCreated);
|
||||
|
||||
if (BufferSize == NULL || ImageType == NULL) {
|
||||
if ((BufferSize == NULL) || (ImageType == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (*BufferSize != 0 && Buffer == NULL) {
|
||||
if ((*BufferSize != 0) && (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -946,8 +971,9 @@ HttpBootGetBootFile (
|
||||
if (Url == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);
|
||||
if (!HeaderOnly && Buffer != NULL) {
|
||||
if (!HeaderOnly && (Buffer != NULL)) {
|
||||
Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType);
|
||||
if (Status != EFI_NOT_FOUND) {
|
||||
FreePool (Url);
|
||||
@ -969,6 +995,7 @@ HttpBootGetBootFile (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ERROR_1;
|
||||
}
|
||||
|
||||
Cache->ImageType = ImageTypeMax;
|
||||
InitializeListHead (&Cache->EntityDataList);
|
||||
}
|
||||
@ -1001,6 +1028,7 @@ HttpBootGetBootFile (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ERROR_3;
|
||||
}
|
||||
|
||||
Status = HttpIoSetHeader (
|
||||
HttpIoHeader,
|
||||
HTTP_HEADER_HOST,
|
||||
@ -1043,6 +1071,7 @@ HttpBootGetBootFile (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ERROR_3;
|
||||
}
|
||||
|
||||
RequestData->Method = HeaderOnly ? HttpMethodHead : HttpMethodGet;
|
||||
RequestData->Url = Url;
|
||||
|
||||
@ -1076,11 +1105,12 @@ HttpBootGetBootFile (
|
||||
//
|
||||
// 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) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ERROR_4;
|
||||
}
|
||||
|
||||
Status = HttpIoRecvResponse (
|
||||
&Private->HttpIo,
|
||||
TRUE,
|
||||
@ -1092,6 +1122,7 @@ HttpBootGetBootFile (
|
||||
HttpBootPrintErrorMessage (StatusCode);
|
||||
Status = ResponseData->Status;
|
||||
}
|
||||
|
||||
goto ERROR_5;
|
||||
}
|
||||
|
||||
@ -1134,7 +1165,7 @@ HttpBootGetBootFile (
|
||||
ResponseData->HeaderCount,
|
||||
ResponseData->Headers,
|
||||
HttpBootGetBootFileCallback,
|
||||
(VOID*) &Context,
|
||||
(VOID *)&Context,
|
||||
&Parser
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -1169,7 +1200,7 @@ HttpBootGetBootFile (
|
||||
//
|
||||
ReceivedSize = 0;
|
||||
while (ReceivedSize < ContentLength) {
|
||||
ResponseBody.Body = (CHAR8*) Buffer + ReceivedSize;
|
||||
ResponseBody.Body = (CHAR8 *)Buffer + ReceivedSize;
|
||||
ResponseBody.BodyLength = *BufferSize - ReceivedSize;
|
||||
Status = HttpIoRecvResponse (
|
||||
&Private->HttpIo,
|
||||
@ -1180,8 +1211,10 @@ HttpBootGetBootFile (
|
||||
if (EFI_ERROR (ResponseBody.Status)) {
|
||||
Status = ResponseBody.Status;
|
||||
}
|
||||
|
||||
goto ERROR_6;
|
||||
}
|
||||
|
||||
ReceivedSize += ResponseBody.BodyLength;
|
||||
if (Private->HttpBootCallback != NULL) {
|
||||
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
|
||||
// every HttpIoRecvResponse().
|
||||
//
|
||||
if (Block == NULL || Context.BufferSize == 0) {
|
||||
if ((Block == NULL) || (Context.BufferSize == 0)) {
|
||||
Block = AllocatePool (HTTP_BOOT_BLOCK_SIZE);
|
||||
if (Block == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ERROR_6;
|
||||
}
|
||||
|
||||
Context.NewBlock = TRUE;
|
||||
Context.Block = Block;
|
||||
} else {
|
||||
Context.NewBlock = FALSE;
|
||||
}
|
||||
|
||||
ResponseBody.Body = (CHAR8*) Block;
|
||||
ResponseBody.Body = (CHAR8 *)Block;
|
||||
ResponseBody.BodyLength = HTTP_BOOT_BLOCK_SIZE;
|
||||
Status = HttpIoRecvResponse (
|
||||
&Private->HttpIo,
|
||||
@ -1232,6 +1266,7 @@ HttpBootGetBootFile (
|
||||
if (EFI_ERROR (ResponseBody.Status)) {
|
||||
Status = ResponseBody.Status;
|
||||
}
|
||||
|
||||
goto ERROR_6;
|
||||
}
|
||||
|
||||
@ -1263,6 +1298,7 @@ HttpBootGetBootFile (
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
*BufferSize = ContentLength;
|
||||
|
||||
//
|
||||
@ -1283,25 +1319,30 @@ ERROR_6:
|
||||
if (Parser != NULL) {
|
||||
HttpFreeMsgParser (Parser);
|
||||
}
|
||||
|
||||
if (Context.Block != NULL) {
|
||||
FreePool (Context.Block);
|
||||
}
|
||||
|
||||
HttpBootFreeCache (Cache);
|
||||
|
||||
ERROR_5:
|
||||
if (ResponseData != NULL) {
|
||||
FreePool (ResponseData);
|
||||
}
|
||||
|
||||
ERROR_4:
|
||||
if (RequestData != NULL) {
|
||||
FreePool (RequestData);
|
||||
}
|
||||
|
||||
ERROR_3:
|
||||
HttpIoFreeHeader (HttpIoHeader);
|
||||
ERROR_2:
|
||||
if (Cache != NULL) {
|
||||
FreePool (Cache);
|
||||
}
|
||||
|
||||
ERROR_1:
|
||||
if (Url != NULL) {
|
||||
FreePool (Url);
|
||||
|
@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
///
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED
|
||||
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,
|
||||
"eng"
|
||||
};
|
||||
@ -81,7 +81,7 @@ HttpBootDxeComponentNameGetDriverName (
|
||||
This->SupportedLanguages,
|
||||
mHttpBootDxeDriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN) (This != &gHttpBootDxeComponentName2)
|
||||
(BOOLEAN)(This != &gHttpBootDxeComponentName2)
|
||||
);
|
||||
}
|
||||
|
||||
@ -139,13 +139,13 @@ HttpBootDxeComponentNameGetControllerName (
|
||||
EFI_HANDLE NicHandle;
|
||||
UINT32 *Id;
|
||||
|
||||
if (ControllerHandle == NULL || ChildHandle != NULL) {
|
||||
if ((ControllerHandle == NULL) || (ChildHandle != NULL)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);
|
||||
if (NicHandle == NULL) {
|
||||
NicHandle = HttpBootGetNicByIp6Children(ControllerHandle);
|
||||
NicHandle = HttpBootGetNicByIp6Children (ControllerHandle);
|
||||
if (NicHandle == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@ -157,7 +157,7 @@ HttpBootDxeComponentNameGetControllerName (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &Id,
|
||||
(VOID **)&Id,
|
||||
NULL,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -173,5 +173,4 @@ HttpBootDxeComponentNameGetControllerName (
|
||||
ControllerName,
|
||||
(BOOLEAN)(This != &gHttpBootDxeComponentName2)
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ HttpBootAddBootOption (
|
||||
if (Uri[Index] == L':') {
|
||||
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');
|
||||
}
|
||||
}
|
||||
@ -77,6 +78,7 @@ HttpBootAddBootOption (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->Ipv4.Header.SubType = MSG_IPv4_DP;
|
||||
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
|
||||
@ -86,15 +88,18 @@ HttpBootAddBootOption (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->Ipv6.Header.SubType = MSG_IPv6_DP;
|
||||
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);
|
||||
if (TmpDevicePath == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Update the URI node with the input boot file URI.
|
||||
//
|
||||
@ -106,11 +111,12 @@ HttpBootAddBootOption (
|
||||
FreePool (TmpDevicePath);
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->DevPath.SubType = MSG_URI_DP;
|
||||
SetDevicePathNodeLength (Node, Length);
|
||||
CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, AsciiStrSize (AsciiUri));
|
||||
NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
|
||||
CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, AsciiStrSize (AsciiUri));
|
||||
NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
|
||||
FreePool (Node);
|
||||
FreePool (TmpDevicePath);
|
||||
if (NewDevicePath == NULL) {
|
||||
@ -135,7 +141,7 @@ HttpBootAddBootOption (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1);
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
|
||||
EfiBootManagerFreeLoadOption (&NewOption);
|
||||
|
||||
ON_EXIT:
|
||||
@ -235,7 +241,7 @@ HttpBootFormExtractConfig (
|
||||
BOOLEAN AllocatedRequest;
|
||||
UINTN Size;
|
||||
|
||||
if (Progress == NULL || Results == NULL) {
|
||||
if ((Progress == NULL) || (Results == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -270,6 +276,7 @@ HttpBootFormExtractConfig (
|
||||
if (ConfigRequest == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
AllocatedRequest = TRUE;
|
||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||
FreePool (ConfigRequestHdr);
|
||||
@ -278,7 +285,7 @@ HttpBootFormExtractConfig (
|
||||
Status = gHiiConfigRouting->BlockToConfig (
|
||||
gHiiConfigRouting,
|
||||
ConfigRequest,
|
||||
(UINT8 *) &CallbackInfo->HttpBootNvData,
|
||||
(UINT8 *)&CallbackInfo->HttpBootNvData,
|
||||
BufferSize,
|
||||
Results,
|
||||
Progress
|
||||
@ -291,6 +298,7 @@ HttpBootFormExtractConfig (
|
||||
FreePool (ConfigRequest);
|
||||
ConfigRequest = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Progress string to the original request string.
|
||||
//
|
||||
@ -359,6 +367,7 @@ HttpBootFormRouteConfig (
|
||||
if (Progress == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Progress = Configuration;
|
||||
|
||||
if (Configuration == NULL) {
|
||||
@ -382,7 +391,7 @@ HttpBootFormRouteConfig (
|
||||
Status = gHiiConfigRouting->ConfigToBlock (
|
||||
gHiiConfigRouting,
|
||||
Configuration,
|
||||
(UINT8 *) &CallbackInfo->HttpBootNvData,
|
||||
(UINT8 *)&CallbackInfo->HttpBootNvData,
|
||||
&BufferSize,
|
||||
Progress
|
||||
);
|
||||
@ -451,7 +460,7 @@ HttpBootFormCallback (
|
||||
AsciiUri = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
if (This == NULL || Value == NULL) {
|
||||
if ((This == NULL) || (Value == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -467,7 +476,7 @@ HttpBootFormCallback (
|
||||
// Get user input URI string
|
||||
//
|
||||
Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
|
||||
if(Uri == NULL) {
|
||||
if (Uri == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -488,7 +497,6 @@ HttpBootFormCallback (
|
||||
Status = HttpBootCheckUriScheme (AsciiUri);
|
||||
|
||||
if (Status == EFI_INVALID_PARAMETER) {
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
|
||||
|
||||
CreatePopUp (
|
||||
@ -499,7 +507,6 @@ HttpBootFormCallback (
|
||||
NULL
|
||||
);
|
||||
} else if (Status == EFI_ACCESS_DENIED) {
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
|
||||
|
||||
CreatePopUp (
|
||||
@ -570,7 +577,7 @@ HttpBootConfigFormInit (
|
||||
SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
|
||||
CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
|
||||
Private->ParentDevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
|
||||
);
|
||||
if (CallbackInfo->HiiVendorDevicePath == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -660,7 +667,7 @@ HttpBootConfigFormUnload (
|
||||
{
|
||||
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.
|
||||
//
|
||||
|
@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _HTTP_BOOT_CONFIG_H_
|
||||
#define _HTTP_BOOT_CONFIG_H_
|
||||
|
||||
|
||||
#include "HttpBootConfigNVDataStruc.h"
|
||||
|
||||
typedef struct _HTTP_BOOT_FORM_CALLBACK_INFO HTTP_BOOT_FORM_CALLBACK_INFO;
|
||||
|
@ -40,5 +40,4 @@ typedef struct _HTTP_BOOT_CONFIG_IFR_NVDATA {
|
||||
} HTTP_BOOT_CONFIG_IFR_NVDATA;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -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.
|
||||
//
|
||||
UINT32 mHttpDhcpTimeout[4] = {4, 8, 16, 32};
|
||||
UINT32 mHttpDhcpTimeout[4] = { 4, 8, 16, 32 };
|
||||
|
||||
/**
|
||||
Build the options buffer for the DHCPv4 request packet.
|
||||
@ -48,14 +48,14 @@ HttpBootBuildDhcp4Options (
|
||||
UINT32 Index;
|
||||
|
||||
Index = 0;
|
||||
OptList[0] = (EFI_DHCP4_PACKET_OPTION *) Buffer;
|
||||
OptList[0] = (EFI_DHCP4_PACKET_OPTION *)Buffer;
|
||||
|
||||
//
|
||||
// Append parameter request list option.
|
||||
//
|
||||
OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST;
|
||||
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[1] = DHCP4_TAG_TIME_OFFSET;
|
||||
OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER;
|
||||
@ -89,15 +89,16 @@ HttpBootBuildDhcp4Options (
|
||||
// Append UUID/Guid-based client identifier option
|
||||
//
|
||||
OptList[Index]->OpCode = DHCP4_TAG_UUID;
|
||||
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_UUID);
|
||||
OptEnt.Uuid = (HTTP_BOOT_DHCP4_OPTION_UUID *) OptList[Index]->Data;
|
||||
OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_UUID);
|
||||
OptEnt.Uuid = (HTTP_BOOT_DHCP4_OPTION_UUID *)OptList[Index]->Data;
|
||||
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.
|
||||
//
|
||||
ZeroMem (OptEnt.Uuid->Guid, sizeof (EFI_GUID));
|
||||
}
|
||||
|
||||
Index++;
|
||||
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
|
||||
|
||||
@ -105,8 +106,8 @@ HttpBootBuildDhcp4Options (
|
||||
// Append client network device interface option
|
||||
//
|
||||
OptList[Index]->OpCode = DHCP4_TAG_UNDI;
|
||||
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_UNDI);
|
||||
OptEnt.Undi = (HTTP_BOOT_DHCP4_OPTION_UNDI *) OptList[Index]->Data;
|
||||
OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_UNDI);
|
||||
OptEnt.Undi = (HTTP_BOOT_DHCP4_OPTION_UNDI *)OptList[Index]->Data;
|
||||
|
||||
if (Private->Nii != NULL) {
|
||||
OptEnt.Undi->Type = Private->Nii->Type;
|
||||
@ -125,8 +126,8 @@ HttpBootBuildDhcp4Options (
|
||||
// Append client system architecture option
|
||||
//
|
||||
OptList[Index]->OpCode = DHCP4_TAG_ARCH;
|
||||
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_ARCH);
|
||||
OptEnt.Arch = (HTTP_BOOT_DHCP4_OPTION_ARCH *) OptList[Index]->Data;
|
||||
OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_ARCH);
|
||||
OptEnt.Arch = (HTTP_BOOT_DHCP4_OPTION_ARCH *)OptList[Index]->Data;
|
||||
Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
|
||||
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
|
||||
Index++;
|
||||
@ -136,8 +137,8 @@ HttpBootBuildDhcp4Options (
|
||||
// Append vendor class identify option
|
||||
//
|
||||
OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
|
||||
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_CLID);
|
||||
OptEnt.Clid = (HTTP_BOOT_DHCP4_OPTION_CLID *) OptList[Index]->Data;
|
||||
OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_CLID);
|
||||
OptEnt.Clid = (HTTP_BOOT_DHCP4_OPTION_CLID *)OptList[Index]->Data;
|
||||
CopyMem (
|
||||
OptEnt.Clid,
|
||||
DEFAULT_CLASS_ID_DATA,
|
||||
@ -181,11 +182,10 @@ HttpBootParseDhcp4Options (
|
||||
EFI_DHCP4_PACKET_OPTION *Option;
|
||||
UINT32 Offset;
|
||||
|
||||
Option = (EFI_DHCP4_PACKET_OPTION *) Buffer;
|
||||
Option = (EFI_DHCP4_PACKET_OPTION *)Buffer;
|
||||
Offset = 0;
|
||||
|
||||
while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
|
||||
|
||||
if (Option->OpCode == OptTag) {
|
||||
//
|
||||
// Found the required option.
|
||||
@ -202,7 +202,7 @@ HttpBootParseDhcp4Options (
|
||||
Offset += Option->Length + 2;
|
||||
}
|
||||
|
||||
Option = (EFI_DHCP4_PACKET_OPTION *) (Buffer + Offset);
|
||||
Option = (EFI_DHCP4_PACKET_OPTION *)(Buffer + Offset);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -284,6 +284,7 @@ HttpBootParseDhcp4Packet (
|
||||
mInterestedDhcp4Tags[Index]
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132.
|
||||
// If yes, try to parse options from the BootFileName field, then ServerName field.
|
||||
@ -295,18 +296,19 @@ HttpBootParseDhcp4Packet (
|
||||
for (Index = 0; Index < HTTP_BOOT_DHCP4_TAG_INDEX_MAX; Index++) {
|
||||
if (Options[Index] == NULL) {
|
||||
Options[Index] = HttpBootParseDhcp4Options (
|
||||
(UINT8 *) Offer->Dhcp4.Header.BootFileName,
|
||||
(UINT8 *)Offer->Dhcp4.Header.BootFileName,
|
||||
sizeof (Offer->Dhcp4.Header.BootFileName),
|
||||
mInterestedDhcp4Tags[Index]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((Option->Data[0] & HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME) != 0) {
|
||||
for (Index = 0; Index < HTTP_BOOT_DHCP4_TAG_INDEX_MAX; Index++) {
|
||||
if (Options[Index] == NULL) {
|
||||
Options[Index] = HttpBootParseDhcp4Options (
|
||||
(UINT8 *) Offer->Dhcp4.Header.ServerName,
|
||||
(UINT8 *)Offer->Dhcp4.Header.ServerName,
|
||||
sizeof (Offer->Dhcp4.Header.ServerName),
|
||||
mInterestedDhcp4Tags[Index]
|
||||
);
|
||||
@ -327,7 +329,8 @@ HttpBootParseDhcp4Packet (
|
||||
//
|
||||
Option = Options[HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID];
|
||||
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;
|
||||
}
|
||||
|
||||
@ -350,12 +353,12 @@ HttpBootParseDhcp4Packet (
|
||||
// RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is null
|
||||
// terminated string. So force to append null terminated character at the end of string.
|
||||
//
|
||||
Ptr8 = (UINT8*)&Options[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;
|
||||
if (*(Ptr8 - 1) != '\0') {
|
||||
*Ptr8 = '\0';
|
||||
}
|
||||
} else if (!FileFieldOverloaded && Offer->Dhcp4.Header.BootFileName[0] != 0) {
|
||||
} else if (!FileFieldOverloaded && (Offer->Dhcp4.Header.BootFileName[0] != 0)) {
|
||||
//
|
||||
// If the bootfile is not present and bootfilename is present in DHCPv4 packet, just parse it.
|
||||
// Do not count dhcp option header here, or else will destroy the serverhostname.
|
||||
@ -368,7 +371,7 @@ HttpBootParseDhcp4Packet (
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -377,8 +380,8 @@ HttpBootParseDhcp4Packet (
|
||||
//
|
||||
if (IsHttpOffer) {
|
||||
Status = HttpParseUrl (
|
||||
(CHAR8*) Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
|
||||
(UINT32) AsciiStrLen ((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),
|
||||
FALSE,
|
||||
&Cache4->UriParser
|
||||
);
|
||||
@ -387,7 +390,7 @@ HttpBootParseDhcp4Packet (
|
||||
}
|
||||
|
||||
Status = HttpUrlGetIp4 (
|
||||
(CHAR8*) Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
|
||||
(CHAR8 *)Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
|
||||
Cache4->UriParser,
|
||||
&IpAddr
|
||||
);
|
||||
@ -411,7 +414,6 @@ HttpBootParseDhcp4Packet (
|
||||
OfferType = HttpOfferTypeProxyNameUri;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!IsProxyOffer) {
|
||||
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
|
||||
@ -419,6 +421,7 @@ HttpBootParseDhcp4Packet (
|
||||
if (Cache4->UriParser != NULL) {
|
||||
FreePool (Cache4->UriParser);
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
@ -500,26 +503,16 @@ HttpBootSelectDhcpOffer (
|
||||
// The offer with DNS server address takes priority here.
|
||||
//
|
||||
if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0) {
|
||||
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {
|
||||
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {
|
||||
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) {
|
||||
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {
|
||||
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
//
|
||||
// We are in corporate environment.
|
||||
@ -532,45 +525,35 @@ HttpBootSelectDhcpOffer (
|
||||
// Priority6: HttpOfferTypeDhcpDns + HttpOfferTypeDhcpNameUri
|
||||
//
|
||||
if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {
|
||||
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {
|
||||
|
||||
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;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0 &&
|
||||
Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {
|
||||
|
||||
} else if ((Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) &&
|
||||
(Private->OfferCount[HttpOfferTypeProxyIpUri] > 0))
|
||||
{
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;
|
||||
Private->SelectProxyType = HttpOfferTypeProxyIpUri;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&
|
||||
Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {
|
||||
|
||||
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
|
||||
(Private->OfferCount[HttpOfferTypeProxyIpUri] > 0))
|
||||
{
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
|
||||
Private->SelectProxyType = HttpOfferTypeProxyIpUri;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&
|
||||
Private->OfferCount[HttpOfferTypeProxyNameUri] > 0) {
|
||||
|
||||
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
|
||||
(Private->OfferCount[HttpOfferTypeProxyNameUri] > 0))
|
||||
{
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
|
||||
Private->SelectProxyType = HttpOfferTypeProxyNameUri;
|
||||
|
||||
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&
|
||||
Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0) {
|
||||
|
||||
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
|
||||
(Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0))
|
||||
{
|
||||
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
|
||||
Private->SelectProxyType = HttpOfferTypeDhcpNameUri;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver
|
||||
to intercept events that occurred in the configuration process.
|
||||
@ -612,11 +595,12 @@ HttpBootDhcp4CallBack (
|
||||
(Dhcp4Event != Dhcp4RcvdOffer) &&
|
||||
(Dhcp4Event != Dhcp4SendRequest) &&
|
||||
(Dhcp4Event != Dhcp4RcvdAck) &&
|
||||
(Dhcp4Event != Dhcp4SelectOffer)) {
|
||||
(Dhcp4Event != Dhcp4SelectOffer))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
|
||||
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
|
||||
|
||||
//
|
||||
// Override the Maximum DHCP Message Size.
|
||||
@ -634,8 +618,8 @@ HttpBootDhcp4CallBack (
|
||||
//
|
||||
// Callback to user if any packets sent or received.
|
||||
//
|
||||
if (Private->HttpBootCallback != NULL && Dhcp4Event != Dhcp4SelectOffer) {
|
||||
Received = (BOOLEAN) (Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
|
||||
if ((Private->HttpBootCallback != NULL) && (Dhcp4Event != Dhcp4SelectOffer)) {
|
||||
Received = (BOOLEAN)(Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
|
||||
Status = Private->HttpBootCallback->Callback (
|
||||
Private->HttpBootCallback,
|
||||
HttpBootDhcp4,
|
||||
@ -658,6 +642,7 @@ HttpBootDhcp4CallBack (
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
|
||||
//
|
||||
// Cache the DHCPv4 offers to OfferBuffer[] for select later, and record
|
||||
@ -666,6 +651,7 @@ HttpBootDhcp4CallBack (
|
||||
//
|
||||
HttpBootCacheDhcp4Offer (Private, Packet);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Dhcp4SelectOffer:
|
||||
@ -680,6 +666,7 @@ HttpBootDhcp4CallBack (
|
||||
} else {
|
||||
*NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -761,7 +748,6 @@ HttpBootRegisterIp4Dns (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will switch the IP4 configuration policy to Static.
|
||||
|
||||
@ -796,7 +782,7 @@ HttpBootSetIp4Policy (
|
||||
|
||||
if (Policy != Ip4Config2PolicyStatic) {
|
||||
Policy = Ip4Config2PolicyStatic;
|
||||
Status= Ip4Config2->SetData (
|
||||
Status = Ip4Config2->SetData (
|
||||
Ip4Config2,
|
||||
Ip4Config2DataTypePolicy,
|
||||
sizeof (EFI_IP4_CONFIG2_POLICY),
|
||||
@ -846,7 +832,7 @@ HttpBootDhcp4Dora (
|
||||
OptCount = HttpBootBuildDhcp4Options (Private, OptList, Buffer);
|
||||
ASSERT (OptCount > 0);
|
||||
|
||||
ZeroMem (&Config, sizeof(Config));
|
||||
ZeroMem (&Config, sizeof (Config));
|
||||
Config.OptionCount = OptCount;
|
||||
Config.OptionList = OptList;
|
||||
Config.Dhcp4Callback = HttpBootDhcp4CallBack;
|
||||
|
@ -30,18 +30,18 @@ HttpBootBuildDhcp6Options (
|
||||
UINT32 Index;
|
||||
|
||||
Index = 0;
|
||||
OptList[0] = (EFI_DHCP6_PACKET_OPTION *) Buffer;
|
||||
OptList[0] = (EFI_DHCP6_PACKET_OPTION *)Buffer;
|
||||
|
||||
//
|
||||
// Append client option request option
|
||||
//
|
||||
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
|
||||
OptList[Index]->OpLen = HTONS (8);
|
||||
OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *) OptList[Index]->Data;
|
||||
OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL);
|
||||
OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);
|
||||
OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS);
|
||||
OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS);
|
||||
OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *)OptList[Index]->Data;
|
||||
OptEnt.Oro->OpCode[0] = HTONS (DHCP6_OPT_BOOT_FILE_URL);
|
||||
OptEnt.Oro->OpCode[1] = HTONS (DHCP6_OPT_BOOT_FILE_PARAM);
|
||||
OptEnt.Oro->OpCode[2] = HTONS (DHCP6_OPT_DNS_SERVERS);
|
||||
OptEnt.Oro->OpCode[3] = HTONS (DHCP6_OPT_VENDOR_CLASS);
|
||||
Index++;
|
||||
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
|
||||
|
||||
@ -50,7 +50,7 @@ HttpBootBuildDhcp6Options (
|
||||
//
|
||||
OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
|
||||
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) {
|
||||
OptEnt.Undi->Type = Private->Nii->Type;
|
||||
@ -69,8 +69,8 @@ HttpBootBuildDhcp6Options (
|
||||
// Append client system architecture option
|
||||
//
|
||||
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
|
||||
OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH));
|
||||
OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *) OptList[Index]->Data;
|
||||
OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH));
|
||||
OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *)OptList[Index]->Data;
|
||||
Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
|
||||
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
|
||||
Index++;
|
||||
@ -80,10 +80,10 @@ HttpBootBuildDhcp6Options (
|
||||
// Append vendor class identify option.
|
||||
//
|
||||
OptList[Index]->OpCode = HTONS (DHCP6_OPT_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;
|
||||
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->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 (
|
||||
&OptEnt.VendorClass->ClassId,
|
||||
DEFAULT_CLASS_ID_DATA,
|
||||
@ -139,25 +139,22 @@ HttpBootParseDhcp6Options (
|
||||
EFI_DHCP6_PACKET_OPTION *Option;
|
||||
UINT32 Offset;
|
||||
|
||||
Option = (EFI_DHCP6_PACKET_OPTION *) Buffer;
|
||||
Option = (EFI_DHCP6_PACKET_OPTION *)Buffer;
|
||||
Offset = 0;
|
||||
|
||||
//
|
||||
// OpLen and OpCode here are both stored in network order.
|
||||
//
|
||||
while (Offset < Length) {
|
||||
|
||||
if (NTOHS (Option->OpCode) == OptTag) {
|
||||
|
||||
return Option;
|
||||
}
|
||||
|
||||
Offset += (NTOHS(Option->OpLen) + 4);
|
||||
Option = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset);
|
||||
Offset += (NTOHS (Option->OpLen) + 4);
|
||||
Option = (EFI_DHCP6_PACKET_OPTION *)(Buffer + Offset);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,7 +193,7 @@ HttpBootParseDhcp6Packet (
|
||||
|
||||
ZeroMem (Cache6->OptList, sizeof (Cache6->OptList));
|
||||
|
||||
Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option);
|
||||
Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option);
|
||||
Offset = 0;
|
||||
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.
|
||||
//
|
||||
while (Offset < Length) {
|
||||
|
||||
if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) {
|
||||
Options[HTTP_BOOT_DHCP6_IDX_IA_NA] = Option;
|
||||
} else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) {
|
||||
@ -221,8 +217,9 @@ HttpBootParseDhcp6Packet (
|
||||
}
|
||||
|
||||
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.
|
||||
// An ia_na option, embedded with valid ia_addr option and a status_code of success.
|
||||
@ -234,7 +231,7 @@ HttpBootParseDhcp6Packet (
|
||||
NTOHS (Option->OpLen),
|
||||
DHCP6_OPT_STATUS_CODE
|
||||
);
|
||||
if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) {
|
||||
if (((Option != NULL) && (Option->Data[0] == 0)) || (Option == NULL)) {
|
||||
IsProxyOffer = FALSE;
|
||||
}
|
||||
}
|
||||
@ -244,9 +241,10 @@ HttpBootParseDhcp6Packet (
|
||||
//
|
||||
Option = Options[HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS];
|
||||
|
||||
if (Option != NULL &&
|
||||
NTOHS(Option->OpLen) >= 16 &&
|
||||
CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0) {
|
||||
if ((Option != NULL) &&
|
||||
(NTOHS (Option->OpLen) >= 16) &&
|
||||
(CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0))
|
||||
{
|
||||
IsHttpOffer = TRUE;
|
||||
}
|
||||
|
||||
@ -261,7 +259,7 @@ HttpBootParseDhcp6Packet (
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -270,8 +268,8 @@ HttpBootParseDhcp6Packet (
|
||||
//
|
||||
if (IsHttpOffer) {
|
||||
Status = HttpParseUrl (
|
||||
(CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
|
||||
(UINT32) AsciiStrLen ((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),
|
||||
FALSE,
|
||||
&Cache6->UriParser
|
||||
);
|
||||
@ -280,7 +278,7 @@ HttpBootParseDhcp6Packet (
|
||||
}
|
||||
|
||||
Status = HttpUrlGetIp6 (
|
||||
(CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
|
||||
(CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
|
||||
Cache6->UriParser,
|
||||
&IpAddr
|
||||
);
|
||||
@ -304,7 +302,6 @@ HttpBootParseDhcp6Packet (
|
||||
OfferType = HttpOfferTypeProxyNameUri;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!IsProxyOffer) {
|
||||
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
|
||||
@ -370,7 +367,7 @@ HttpBootCacheDhcp6Offer (
|
||||
//
|
||||
// Cache the content of DHCPv6 packet firstly.
|
||||
//
|
||||
Status = HttpBootCacheDhcp6Packet(Offer, RcvdOffer);
|
||||
Status = HttpBootCacheDhcp6Packet (Offer, RcvdOffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -434,16 +431,17 @@ HttpBootDhcp6CallBack (
|
||||
(Dhcp6Event != Dhcp6RcvdAdvertise) &&
|
||||
(Dhcp6Event != Dhcp6SendRequest) &&
|
||||
(Dhcp6Event != Dhcp6RcvdReply) &&
|
||||
(Dhcp6Event != Dhcp6SelectAdvertise)) {
|
||||
(Dhcp6Event != Dhcp6SelectAdvertise))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
ASSERT (Packet != NULL);
|
||||
|
||||
Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
|
||||
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
|
||||
Status = EFI_SUCCESS;
|
||||
if (Private->HttpBootCallback != NULL && Dhcp6Event != Dhcp6SelectAdvertise) {
|
||||
Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
|
||||
if ((Private->HttpBootCallback != NULL) && (Dhcp6Event != Dhcp6SelectAdvertise)) {
|
||||
Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
|
||||
Status = Private->HttpBootCallback->Callback (
|
||||
Private->HttpBootCallback,
|
||||
HttpBootDhcp6,
|
||||
@ -455,8 +453,8 @@ HttpBootDhcp6CallBack (
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
}
|
||||
switch (Dhcp6Event) {
|
||||
|
||||
switch (Dhcp6Event) {
|
||||
case Dhcp6RcvdAdvertise:
|
||||
Status = EFI_NOT_READY;
|
||||
if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) {
|
||||
@ -465,6 +463,7 @@ HttpBootDhcp6CallBack (
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
|
||||
//
|
||||
// Cache the dhcp offers to OfferBuffer[] for select later, and record
|
||||
@ -473,6 +472,7 @@ HttpBootDhcp6CallBack (
|
||||
//
|
||||
HttpBootCacheDhcp6Offer (Private, Packet);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Dhcp6SelectAdvertise:
|
||||
@ -491,8 +491,10 @@ HttpBootDhcp6CallBack (
|
||||
if (*NewPacket == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (*NewPacket, SelectAd, SelectAd->Size);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -562,23 +564,28 @@ HttpBootCheckRouteTable (
|
||||
if (Ip6ModeData.AddressList != NULL) {
|
||||
FreePool (Ip6ModeData.AddressList);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.GroupTable != NULL) {
|
||||
FreePool (Ip6ModeData.GroupTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.RouteTable != NULL) {
|
||||
FreePool (Ip6ModeData.RouteTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.NeighborCache != NULL) {
|
||||
FreePool (Ip6ModeData.NeighborCache);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.PrefixTable != NULL) {
|
||||
FreePool (Ip6ModeData.PrefixTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.IcmpTypeList != NULL) {
|
||||
FreePool (Ip6ModeData.IcmpTypeList);
|
||||
}
|
||||
|
||||
if (GatewayIsFound || RetryCount == TimeOutInSecond) {
|
||||
if (GatewayIsFound || (RetryCount == TimeOutInSecond)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -604,6 +611,7 @@ HttpBootCheckRouteTable (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
|
||||
Ip6->Poll (Ip6);
|
||||
}
|
||||
@ -663,13 +671,14 @@ HttpBootSetIp6Policy (
|
||||
Status = Ip6Config->SetData (
|
||||
Ip6Config,
|
||||
Ip6ConfigDataTypePolicy,
|
||||
sizeof(EFI_IP6_CONFIG_POLICY),
|
||||
sizeof (EFI_IP6_CONFIG_POLICY),
|
||||
&Policy
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -736,7 +745,7 @@ HttpBootSetIp6Gateway (
|
||||
sizeof (EFI_IPv6_ADDRESS),
|
||||
&Private->GatewayIp.v6
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
@ -756,7 +765,7 @@ HttpBootSetIp6Gateway (
|
||||
EFI_STATUS
|
||||
HttpBootSetIp6Address (
|
||||
IN HTTP_BOOT_PRIVATE_DATA *Private
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_IP6_PROTOCOL *Ip6;
|
||||
@ -811,7 +820,7 @@ HttpBootSetIp6Address (
|
||||
Status = Ip6Cfg->SetData (
|
||||
Ip6Cfg,
|
||||
Ip6ConfigDataTypePolicy,
|
||||
sizeof(EFI_IP6_CONFIG_POLICY),
|
||||
sizeof (EFI_IP6_CONFIG_POLICY),
|
||||
&Policy
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -840,7 +849,7 @@ HttpBootSetIp6Address (
|
||||
Ip6ConfigDataTypeManualAddress,
|
||||
MappedEvt
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -850,7 +859,7 @@ HttpBootSetIp6Address (
|
||||
sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS),
|
||||
&CfgAddr
|
||||
);
|
||||
if (EFI_ERROR (Status) && Status != EFI_NOT_READY) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
|
||||
goto ON_EXIT;
|
||||
} else if (Status == EFI_NOT_READY) {
|
||||
//
|
||||
@ -859,6 +868,7 @@ HttpBootSetIp6Address (
|
||||
while (!IsAddressOk) {
|
||||
Ip6->Poll (Ip6);
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether the Ip6 Address setting is successed.
|
||||
//
|
||||
@ -869,7 +879,7 @@ HttpBootSetIp6Address (
|
||||
&DataSize,
|
||||
NULL
|
||||
);
|
||||
if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) {
|
||||
if ((Status != EFI_BUFFER_TOO_SMALL) || (DataSize == 0)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -878,22 +888,24 @@ HttpBootSetIp6Address (
|
||||
if (Ip6Addr == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = Ip6Cfg->GetData (
|
||||
Ip6Cfg,
|
||||
Ip6ConfigDataTypeManualAddress,
|
||||
&DataSize,
|
||||
(VOID *) Ip6Addr
|
||||
(VOID *)Ip6Addr
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) {
|
||||
Status = EFI_ABORTED;
|
||||
goto ON_EXIT;
|
||||
@ -947,7 +959,7 @@ HttpBootDhcp6Sarr (
|
||||
// Build options list for the request packet.
|
||||
//
|
||||
OptCount = HttpBootBuildDhcp6Options (Private, OptList, Buffer);
|
||||
ASSERT (OptCount >0);
|
||||
ASSERT (OptCount > 0);
|
||||
|
||||
Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
|
||||
if (Retransmit == NULL) {
|
||||
@ -980,6 +992,7 @@ HttpBootDhcp6Sarr (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the record fields for DHCPv6 offer in private data.
|
||||
//
|
||||
@ -1021,12 +1034,11 @@ ON_EXIT:
|
||||
if (Mode.ClientId != NULL) {
|
||||
FreePool (Mode.ClientId);
|
||||
}
|
||||
|
||||
if (Mode.Ia != NULL) {
|
||||
FreePool (Mode.Ia);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef __EFI_HTTP_BOOT_DHCP6_H__
|
||||
#define __EFI_HTTP_BOOT_DHCP6_H__
|
||||
|
||||
|
@ -29,8 +29,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Check whether UNDI protocol supports IPv6.
|
||||
|
||||
@ -79,16 +77,16 @@ HttpBootCheckIpv6Support (
|
||||
Status = gBS->HandleProtocol (
|
||||
Handle,
|
||||
&gEfiAdapterInformationProtocolGuid,
|
||||
(VOID *) &Aip
|
||||
(VOID *)&Aip
|
||||
);
|
||||
if (EFI_ERROR (Status) || Aip == NULL) {
|
||||
if (EFI_ERROR (Status) || (Aip == NULL)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
InfoTypesBuffer = NULL;
|
||||
InfoTypeBufferCount = 0;
|
||||
Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
|
||||
if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
|
||||
if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
|
||||
FreePool (InfoTypesBuffer);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -112,12 +110,12 @@ HttpBootCheckIpv6Support (
|
||||
InfoBlock = NULL;
|
||||
InfoBlockSize = 0;
|
||||
Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
|
||||
if (EFI_ERROR (Status) || InfoBlock == NULL) {
|
||||
if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
|
||||
FreePool (InfoBlock);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
*Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support;
|
||||
*Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support;
|
||||
FreePool (InfoBlock);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -155,13 +153,12 @@ HttpBootDestroyIp4Children (
|
||||
);
|
||||
}
|
||||
|
||||
if (Private->Ip6Nic == NULL && Private->HttpCreated) {
|
||||
if ((Private->Ip6Nic == NULL) && Private->HttpCreated) {
|
||||
HttpIoDestroyIo (&Private->HttpIo);
|
||||
Private->HttpCreated = FALSE;
|
||||
}
|
||||
|
||||
if (Private->Ip4Nic != NULL) {
|
||||
|
||||
gBS->CloseProtocol (
|
||||
Private->Controller,
|
||||
&gEfiCallerIdGuid,
|
||||
@ -180,7 +177,6 @@ HttpBootDestroyIp4Children (
|
||||
FreePool (Private->Ip4Nic);
|
||||
Private->Ip4Nic = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,13 +227,12 @@ HttpBootDestroyIp6Children (
|
||||
);
|
||||
}
|
||||
|
||||
if (Private->Ip4Nic == NULL && Private->HttpCreated) {
|
||||
HttpIoDestroyIo(&Private->HttpIo);
|
||||
if ((Private->Ip4Nic == NULL) && Private->HttpCreated) {
|
||||
HttpIoDestroyIo (&Private->HttpIo);
|
||||
Private->HttpCreated = FALSE;
|
||||
}
|
||||
|
||||
if (Private->Ip6Nic != NULL) {
|
||||
|
||||
gBS->CloseProtocol (
|
||||
Private->Controller,
|
||||
&gEfiCallerIdGuid,
|
||||
@ -349,7 +344,6 @@ HttpBootIp4DxeDriverBindingSupported (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starts a device controller or a bus controller.
|
||||
|
||||
@ -405,14 +399,14 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &Id,
|
||||
(VOID **)&Id,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
|
||||
} else {
|
||||
FirstStart = TRUE;
|
||||
|
||||
@ -423,6 +417,7 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
if (Private == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
|
||||
Private->Controller = ControllerHandle;
|
||||
InitializeListHead (&Private->CacheList);
|
||||
@ -432,7 +427,7 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
|
||||
(VOID **) &Private->Nii,
|
||||
(VOID **)&Private->Nii,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -447,7 +442,7 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &Private->ParentDevicePath,
|
||||
(VOID **)&Private->ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -477,7 +472,6 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Private->Ip4Nic != NULL) {
|
||||
@ -492,6 +486,7 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Private->Ip4Nic->Private = Private;
|
||||
Private->Ip4Nic->ImageHandle = This->DriverBindingHandle;
|
||||
Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
|
||||
@ -512,7 +507,7 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Private->Dhcp4Child,
|
||||
&gEfiDhcp4ProtocolGuid,
|
||||
(VOID **) &Private->Dhcp4,
|
||||
(VOID **)&Private->Dhcp4,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -527,7 +522,7 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiIp4Config2ProtocolGuid,
|
||||
(VOID **) &Private->Ip4Config2,
|
||||
(VOID **)&Private->Ip4Config2,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -544,11 +539,12 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->Ipv4.Header.SubType = MSG_IPv4_DP;
|
||||
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
|
||||
Node->Ipv4.StaticIpAddress = FALSE;
|
||||
DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
|
||||
DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
|
||||
FreePool (Node);
|
||||
if (DevicePath == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -563,10 +559,11 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->DevPath.SubType = MSG_URI_DP;
|
||||
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 (DevicePath);
|
||||
if (Private->Ip4Nic->DevicePath == NULL) {
|
||||
@ -597,7 +594,7 @@ HttpBootIp4DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &Id,
|
||||
(VOID **)&Id,
|
||||
This->DriverBindingHandle,
|
||||
Private->Ip4Nic->Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -629,7 +626,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stops a device controller or a bus controller.
|
||||
|
||||
@ -677,7 +673,7 @@ HttpBootIp4DxeDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiLoadFileProtocolGuid,
|
||||
(VOID **) &LoadFile,
|
||||
(VOID **)&LoadFile,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -697,7 +693,7 @@ HttpBootIp4DxeDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &Id,
|
||||
(VOID **)&Id,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -705,6 +701,7 @@ HttpBootIp4DxeDriverBindingStop (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
|
||||
} else {
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
|
||||
@ -715,7 +712,7 @@ HttpBootIp4DxeDriverBindingStop (
|
||||
// Disable the HTTP boot function.
|
||||
//
|
||||
Status = HttpBootStop (Private);
|
||||
if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
|
||||
if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -724,7 +721,7 @@ HttpBootIp4DxeDriverBindingStop (
|
||||
//
|
||||
HttpBootDestroyIp4Children (This, Private);
|
||||
|
||||
if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
|
||||
if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
|
||||
//
|
||||
// Release the cached data.
|
||||
//
|
||||
@ -741,7 +738,6 @@ HttpBootIp4DxeDriverBindingStop (
|
||||
&Private->Id
|
||||
);
|
||||
FreePool (Private);
|
||||
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -836,7 +832,6 @@ HttpBootIp6DxeDriverBindingSupported (
|
||||
);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -895,14 +890,14 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &Id,
|
||||
(VOID **)&Id,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
|
||||
} else {
|
||||
FirstStart = TRUE;
|
||||
|
||||
@ -913,6 +908,7 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
if (Private == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
|
||||
Private->Controller = ControllerHandle;
|
||||
InitializeListHead (&Private->CacheList);
|
||||
@ -922,7 +918,7 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
|
||||
(VOID **) &Private->Nii,
|
||||
(VOID **)&Private->Nii,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -937,7 +933,7 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &Private->ParentDevicePath,
|
||||
(VOID **)&Private->ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -967,7 +963,6 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@ -999,6 +994,7 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Private->Ip6Nic->Private = Private;
|
||||
Private->Ip6Nic->ImageHandle = This->DriverBindingHandle;
|
||||
Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
|
||||
@ -1018,7 +1014,7 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Private->Dhcp6Child,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
(VOID **) &Private->Dhcp6,
|
||||
(VOID **)&Private->Dhcp6,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -1043,7 +1039,7 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Private->Ip6Child,
|
||||
&gEfiIp6ProtocolGuid,
|
||||
(VOID **) &Private->Ip6,
|
||||
(VOID **)&Private->Ip6,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -1058,7 +1054,7 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiIp6ConfigProtocolGuid,
|
||||
(VOID **) &Private->Ip6Config,
|
||||
(VOID **)&Private->Ip6Config,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1075,12 +1071,13 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->Ipv6.Header.SubType = MSG_IPv6_DP;
|
||||
Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
|
||||
SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
|
||||
DevicePath = AppendDevicePathNode(Private->ParentDevicePath, (EFI_DEVICE_PATH*) Node);
|
||||
FreePool(Node);
|
||||
DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH *)Node);
|
||||
FreePool (Node);
|
||||
if (DevicePath == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
@ -1094,10 +1091,11 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
|
||||
Node->DevPath.SubType = MSG_URI_DP;
|
||||
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 (DevicePath);
|
||||
if (Private->Ip6Nic->DevicePath == NULL) {
|
||||
@ -1128,7 +1126,7 @@ HttpBootIp6DxeDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &Id,
|
||||
(VOID **)&Id,
|
||||
This->DriverBindingHandle,
|
||||
Private->Ip6Nic->Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1149,7 +1147,7 @@ ON_ERROR:
|
||||
);
|
||||
}
|
||||
|
||||
HttpBootDestroyIp6Children(This, Private);
|
||||
HttpBootDestroyIp6Children (This, Private);
|
||||
HttpBootConfigFormUnload (Private);
|
||||
|
||||
if (FirstStart) {
|
||||
@ -1207,7 +1205,7 @@ HttpBootIp6DxeDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiLoadFileProtocolGuid,
|
||||
(VOID **) &LoadFile,
|
||||
(VOID **)&LoadFile,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1227,7 +1225,7 @@ HttpBootIp6DxeDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &Id,
|
||||
(VOID **)&Id,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1235,6 +1233,7 @@ HttpBootIp6DxeDriverBindingStop (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
|
||||
} else {
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
|
||||
@ -1245,7 +1244,7 @@ HttpBootIp6DxeDriverBindingStop (
|
||||
// Disable the HTTP boot function.
|
||||
//
|
||||
Status = HttpBootStop (Private);
|
||||
if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
|
||||
if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1254,7 +1253,7 @@ HttpBootIp6DxeDriverBindingStop (
|
||||
//
|
||||
HttpBootDestroyIp6Children (This, Private);
|
||||
|
||||
if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
|
||||
if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
|
||||
//
|
||||
// Release the cached data.
|
||||
//
|
||||
@ -1271,11 +1270,11 @@ HttpBootIp6DxeDriverBindingStop (
|
||||
&Private->Id
|
||||
);
|
||||
FreePool (Private);
|
||||
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
@ -1321,12 +1320,12 @@ HttpBootDxeDriverEntryPoint (
|
||||
&gHttpBootDxeComponentName2
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
EfiLibUninstallDriverBindingComponentName2(
|
||||
EfiLibUninstallDriverBindingComponentName2 (
|
||||
&gHttpBootIp4DxeDriverBinding,
|
||||
&gHttpBootDxeComponentName,
|
||||
&gHttpBootDxeComponentName2
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,6 @@ struct _HTTP_BOOT_PRIVATE_DATA {
|
||||
EFI_DHCP6_PROTOCOL *Dhcp6;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
|
||||
|
||||
//
|
||||
// Produced protocol
|
||||
//
|
||||
@ -522,4 +521,5 @@ HttpBootIp6DxeDriverBindingStop (
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -38,10 +38,9 @@ HttpBootInstallCallback (
|
||||
Status = gBS->HandleProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiHttpBootCallbackProtocolGuid,
|
||||
(VOID **) &Private->HttpBootCallback
|
||||
(VOID **)&Private->HttpBootCallback
|
||||
);
|
||||
if (Status == EFI_UNSUPPORTED) {
|
||||
|
||||
CopyMem (
|
||||
&Private->LoadFileCallback,
|
||||
&gHttpBootDxeHttpBootCallback,
|
||||
@ -60,6 +59,7 @@ HttpBootInstallCallback (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Private->HttpBootCallback = &Private->LoadFileCallback;
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ HttpBootStart (
|
||||
|
||||
Uri = NULL;
|
||||
|
||||
if (Private == NULL || FilePath == NULL) {
|
||||
if ((Private == NULL) || (FilePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -143,7 +143,8 @@ HttpBootStart (
|
||||
// recorded before.
|
||||
//
|
||||
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.
|
||||
//
|
||||
@ -152,6 +153,7 @@ HttpBootStart (
|
||||
if (Uri != NULL) {
|
||||
FreePool (Uri);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
@ -161,6 +163,7 @@ HttpBootStart (
|
||||
if (Uri != NULL) {
|
||||
FreePool (Uri);
|
||||
}
|
||||
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
}
|
||||
@ -168,14 +171,15 @@ HttpBootStart (
|
||||
//
|
||||
// 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;
|
||||
} else if (!UsingIpv6 && Private->Ip4Nic != NULL) {
|
||||
} else if (!UsingIpv6 && (Private->Ip4Nic != NULL)) {
|
||||
Private->UsingIpv6 = FALSE;
|
||||
} else {
|
||||
if (Uri != NULL) {
|
||||
FreePool (Uri);
|
||||
}
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -186,7 +190,7 @@ HttpBootStart (
|
||||
if (Private->FilePathUri != NULL) {
|
||||
Status = HttpParseUrl (
|
||||
Private->FilePathUri,
|
||||
(UINT32) AsciiStrLen (Private->FilePathUri),
|
||||
(UINT32)AsciiStrLen (Private->FilePathUri),
|
||||
FALSE,
|
||||
&Private->FilePathUriParser
|
||||
);
|
||||
@ -219,6 +223,7 @@ HttpBootStart (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
Private->Started = TRUE;
|
||||
Print (L"\n>>Start HTTP Boot over IPv%d", Private->UsingIpv6 ? 6 : 4);
|
||||
|
||||
@ -302,11 +307,11 @@ HttpBootLoadFile (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (Private == NULL || ImageType == NULL || BufferSize == NULL ) {
|
||||
if ((Private == NULL) || (ImageType == NULL) || (BufferSize == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (*BufferSize != 0 && Buffer == NULL) {
|
||||
if ((*BufferSize != 0) && (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -315,7 +320,7 @@ HttpBootLoadFile (
|
||||
}
|
||||
|
||||
Status = HttpBootInstallCallback (Private);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -355,7 +360,7 @@ HttpBootLoadFile (
|
||||
NULL,
|
||||
&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.
|
||||
//
|
||||
@ -367,7 +372,7 @@ HttpBootLoadFile (
|
||||
NULL,
|
||||
&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");
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -398,7 +403,7 @@ ON_EXIT:
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_ACCESS_DENIED) {
|
||||
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");
|
||||
} else if (Status == EFI_OUT_OF_RESOURCES) {
|
||||
AsciiPrint ("\n Error: Could not allocate I/O buffers.\n");
|
||||
@ -489,7 +494,7 @@ HttpBootStop (
|
||||
Private->DnsServerIp = NULL;
|
||||
}
|
||||
|
||||
if (Private->FilePathUri!= NULL) {
|
||||
if (Private->FilePathUri != NULL) {
|
||||
FreePool (Private->FilePathUri);
|
||||
HttpUrlFreeParser (Private->FilePathUriParser);
|
||||
Private->FilePathUri = NULL;
|
||||
@ -554,7 +559,7 @@ HttpBootDxeLoadFile (
|
||||
EFI_STATUS Status;
|
||||
HTTP_BOOT_IMAGE_TYPE ImageType;
|
||||
|
||||
if (This == NULL || BufferSize == NULL || FilePath == NULL) {
|
||||
if ((This == NULL) || (BufferSize == NULL) || (FilePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -590,7 +595,7 @@ HttpBootDxeLoadFile (
|
||||
// Initialize HTTP boot.
|
||||
//
|
||||
Status = HttpBootStart (Private, UsingIpv6, FilePath);
|
||||
if (Status != EFI_SUCCESS && Status != EFI_ALREADY_STARTED) {
|
||||
if ((Status != EFI_SUCCESS) && (Status != EFI_ALREADY_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -600,18 +605,19 @@ HttpBootDxeLoadFile (
|
||||
ImageType = ImageTypeMax;
|
||||
Status = HttpBootLoadFile (Private, BufferSize, Buffer, &ImageType);
|
||||
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;
|
||||
} else if (Status != EFI_BUFFER_TOO_SMALL) {
|
||||
HttpBootStop (Private);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = EFI_WARN_FILE_SYSTEM;
|
||||
@ -671,7 +677,7 @@ HttpBootCallback (
|
||||
HTTP_BOOT_PRIVATE_DATA *Private;
|
||||
UINT32 Percentage;
|
||||
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_PROTOCOL(This);
|
||||
Private = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_PROTOCOL (This);
|
||||
|
||||
switch (DataType) {
|
||||
case HttpBootDhcp4:
|
||||
@ -681,17 +687,19 @@ HttpBootCallback (
|
||||
|
||||
case HttpBootHttpRequest:
|
||||
if (Data != NULL) {
|
||||
HttpMessage = (EFI_HTTP_MESSAGE *) Data;
|
||||
if (HttpMessage->Data.Request->Method == HttpMethodGet &&
|
||||
HttpMessage->Data.Request->Url != NULL) {
|
||||
HttpMessage = (EFI_HTTP_MESSAGE *)Data;
|
||||
if ((HttpMessage->Data.Request->Method == HttpMethodGet) &&
|
||||
(HttpMessage->Data.Request->Url != NULL))
|
||||
{
|
||||
Print (L"\n URI: %s\n", HttpMessage->Data.Request->Url);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case HttpBootHttpResponse:
|
||||
if (Data != NULL) {
|
||||
HttpMessage = (EFI_HTTP_MESSAGE *) Data;
|
||||
HttpMessage = (EFI_HTTP_MESSAGE *)Data;
|
||||
|
||||
if (HttpMessage->Data.Response != NULL) {
|
||||
if (HttpBootIsHttpRedirectStatusCode (HttpMessage->Data.Response->StatusCode)) {
|
||||
@ -708,6 +716,7 @@ HttpBootCallback (
|
||||
if (HttpHeader != NULL) {
|
||||
Print (L"\n HTTP ERROR: Resource Redirected.\n New Location: %a\n", HttpHeader->FieldValue);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -723,6 +732,7 @@ HttpBootCallback (
|
||||
Private->Percentage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case HttpBootHttpEntityBody:
|
||||
@ -734,8 +744,9 @@ HttpBootCallback (
|
||||
if (Private->ReceivedSize == 0) {
|
||||
Print (L" File Size: %lu Bytes\n", Private->FileSize);
|
||||
}
|
||||
|
||||
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) {
|
||||
Private->Percentage = Percentage;
|
||||
Print (L"\r Downloading...%d%%", Percentage);
|
||||
@ -749,11 +760,12 @@ HttpBootCallback (
|
||||
Print (L"\r Downloading...%lu Bytes", Private->ReceivedSize);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_HTTP_BOOT_IMPL_H__
|
||||
#define __EFI_HTTP_BOOT_IMPL_H__
|
||||
|
||||
|
@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "HttpBootDxe.h"
|
||||
|
||||
|
||||
/**
|
||||
Get the Nic handle using any child handle in the IPv4 stack.
|
||||
|
||||
@ -52,6 +51,7 @@ HttpBootGetNicByIp6Children (
|
||||
)
|
||||
{
|
||||
EFI_HANDLE NicHandle;
|
||||
|
||||
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiHttpProtocolGuid);
|
||||
if (NicHandle == NULL) {
|
||||
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid);
|
||||
@ -80,10 +80,10 @@ HttpBootUintnToAscDecWithFormat (
|
||||
{
|
||||
UINTN Remainder;
|
||||
|
||||
for (; Length > 0; Length--) {
|
||||
for ( ; Length > 0; Length--) {
|
||||
Remainder = Number % 10;
|
||||
Number /= 10;
|
||||
Buffer[Length - 1] = (UINT8) ('0' + Remainder);
|
||||
Buffer[Length - 1] = (UINT8)('0' + Remainder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,17 +122,19 @@ HttpBootShowIp6Addr (
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < 16; Index++) {
|
||||
|
||||
if (Ip->Addr[Index] != 0) {
|
||||
AsciiPrint ("%x", Ip->Addr[Index]);
|
||||
}
|
||||
|
||||
Index++;
|
||||
if (Index > 15) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
|
||||
AsciiPrint ("0");
|
||||
}
|
||||
|
||||
AsciiPrint ("%x", Ip->Addr[Index]);
|
||||
if (Index < 15) {
|
||||
AsciiPrint (":");
|
||||
@ -282,8 +284,7 @@ HttpBootPrintErrorMessage (
|
||||
AsciiPrint ("\n Server Error: 505 HTTP Version Not Supported");
|
||||
break;
|
||||
|
||||
default: ;
|
||||
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +302,7 @@ HttpBootCommonNotify (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
*((BOOLEAN *) Context) = TRUE;
|
||||
*((BOOLEAN *)Context) = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -342,7 +343,7 @@ HttpBootDns (
|
||||
//
|
||||
// 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)) {
|
||||
//
|
||||
// Get the required size.
|
||||
@ -364,6 +365,7 @@ HttpBootDns (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Create a DNSv6 child instance and get the protocol.
|
||||
//
|
||||
@ -380,7 +382,7 @@ HttpBootDns (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dns6Handle,
|
||||
&gEfiDns6ProtocolGuid,
|
||||
(VOID **) &Dns6,
|
||||
(VOID **)&Dns6,
|
||||
Private->Ip6Nic->ImageHandle,
|
||||
Private->Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -397,7 +399,7 @@ HttpBootDns (
|
||||
Dns6ConfigData.DnsServerList = DnsServerList;
|
||||
Dns6ConfigData.EnableDnsCache = TRUE;
|
||||
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 (
|
||||
Dns6,
|
||||
&Dns6ConfigData
|
||||
@ -443,25 +445,30 @@ HttpBootDns (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
|
||||
|
||||
if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// We just return the first IPv6 address from DNS protocol.
|
||||
//
|
||||
IP6_COPY_ADDRESS (IpAddress, Token.RspData.H2AData->IpList);
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
if (Token.Event != NULL) {
|
||||
gBS->CloseEvent (Token.Event);
|
||||
}
|
||||
|
||||
if (Token.RspData.H2AData != NULL) {
|
||||
if (Token.RspData.H2AData->IpList != NULL) {
|
||||
FreePool (Token.RspData.H2AData->IpList);
|
||||
}
|
||||
|
||||
FreePool (Token.RspData.H2AData);
|
||||
}
|
||||
|
||||
@ -519,7 +526,8 @@ HttpBootCheckUriScheme (
|
||||
if (Uri[Index] == ':') {
|
||||
break;
|
||||
}
|
||||
if (Uri[Index] >= 'A' && Uri[Index] <= 'Z') {
|
||||
|
||||
if ((Uri[Index] >= 'A') && (Uri[Index] <= 'Z')) {
|
||||
Uri[Index] -= (CHAR8)('A' - 'a');
|
||||
}
|
||||
}
|
||||
@ -578,28 +586,32 @@ HttpBootParseFilePath (
|
||||
TempDevicePath = FilePath;
|
||||
while (!IsDevicePathEnd (TempDevicePath)) {
|
||||
if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&
|
||||
(DevicePathSubType (TempDevicePath) == MSG_URI_DP)) {
|
||||
UriDevicePath = (URI_DEVICE_PATH*) TempDevicePath;
|
||||
(DevicePathSubType (TempDevicePath) == MSG_URI_DP))
|
||||
{
|
||||
UriDevicePath = (URI_DEVICE_PATH *)TempDevicePath;
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
|
||||
UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
if (UriStrLength == 0) {
|
||||
//
|
||||
// return a NULL UriAddress if it's a empty URI device path node.
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
Uri = AllocatePool (UriStrLength + 1);
|
||||
if (Uri == NULL) {
|
||||
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;
|
||||
}
|
||||
|
||||
TempDevicePath = NextDevicePathNode (TempDevicePath);
|
||||
}
|
||||
|
||||
@ -637,11 +649,11 @@ HttpBootCheckImageType (
|
||||
CHAR8 *FilePath;
|
||||
CHAR8 *FilePost;
|
||||
|
||||
if (Uri == NULL || UriParser == NULL || ImageType == NULL) {
|
||||
if ((Uri == NULL) || (UriParser == NULL) || (ImageType == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (HeaderCount != 0 && Headers == NULL) {
|
||||
if ((HeaderCount != 0) && (Headers == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -727,7 +739,7 @@ HttpBootRegisterRamDisk (
|
||||
ASSERT (Buffer != NULL);
|
||||
ASSERT (BufferSize != 0);
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID**) &RamDisk);
|
||||
Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID **)&RamDisk);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "HTTP Boot: Couldn't find the RAM Disk protocol - %r\n", Status));
|
||||
return Status;
|
||||
@ -768,10 +780,11 @@ HttpBootIsHttpRedirectStatusCode (
|
||||
IN EFI_HTTP_STATUS_CODE StatusCode
|
||||
)
|
||||
{
|
||||
if (StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY ||
|
||||
StatusCode == HTTP_STATUS_302_FOUND ||
|
||||
StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT ||
|
||||
StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT) {
|
||||
if ((StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY) ||
|
||||
(StatusCode == HTTP_STATUS_302_FOUND) ||
|
||||
(StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT) ||
|
||||
(StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,6 @@ HttpBootUintnToAscDecWithFormat (
|
||||
IN INTN Length
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This function is to display the IPv4 address.
|
||||
|
||||
@ -212,4 +211,5 @@ BOOLEAN
|
||||
HttpBootIsHttpRedirectStatusCode (
|
||||
IN EFI_HTTP_STATUS_CODE StatusCode
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -15,8 +15,8 @@
|
||||
///
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED
|
||||
EFI_COMPONENT_NAME_PROTOCOL gHttpDxeComponentName = {
|
||||
(EFI_COMPONENT_NAME_GET_DRIVER_NAME) HttpDxeComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) HttpDxeComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME_GET_DRIVER_NAME)HttpDxeComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)HttpDxeComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
@ -35,7 +35,7 @@ EFI_COMPONENT_NAME2_PROTOCOL gHttpDxeComponentName2 = {
|
||||
///
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED
|
||||
EFI_UNICODE_STRING_TABLE mHttpDxeDriverNameTable[] = {
|
||||
{ "eng;en", (CHAR16 *) L"HttpDxe" },
|
||||
{ "eng;en", (CHAR16 *)L"HttpDxe" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,6 @@ HttpDns4 (
|
||||
EFI_IPv4_ADDRESS *DnsServerList;
|
||||
UINTN DataSize;
|
||||
|
||||
|
||||
Service = HttpInstance->Service;
|
||||
ASSERT (Service != NULL);
|
||||
|
||||
@ -51,7 +50,7 @@ HttpDns4 (
|
||||
//
|
||||
// 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)) {
|
||||
//
|
||||
// Get the required size.
|
||||
@ -93,7 +92,7 @@ HttpDns4 (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dns4Handle,
|
||||
&gEfiDns4ProtocolGuid,
|
||||
(VOID **) &Dns4,
|
||||
(VOID **)&Dns4,
|
||||
Service->Ip4DriverBindingHandle,
|
||||
Service->ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -113,6 +112,7 @@ HttpDns4 (
|
||||
IP4_COPY_ADDRESS (&Dns4CfgData.StationIp, &HttpInstance->IPv4Node.LocalAddress);
|
||||
IP4_COPY_ADDRESS (&Dns4CfgData.SubnetMask, &HttpInstance->IPv4Node.LocalSubnet);
|
||||
}
|
||||
|
||||
Dns4CfgData.EnableDnsCache = TRUE;
|
||||
Dns4CfgData.Protocol = EFI_IP_PROTO_UDP;
|
||||
Status = Dns4->Configure (
|
||||
@ -161,10 +161,12 @@ HttpDns4 (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
|
||||
|
||||
if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// We just return the first IP address from DNS protocol.
|
||||
//
|
||||
@ -177,10 +179,12 @@ Exit:
|
||||
if (Token.Event != NULL) {
|
||||
gBS->CloseEvent (Token.Event);
|
||||
}
|
||||
|
||||
if (Token.RspData.H2AData != NULL) {
|
||||
if (Token.RspData.H2AData->IpList != NULL) {
|
||||
FreePool (Token.RspData.H2AData->IpList);
|
||||
}
|
||||
|
||||
FreePool (Token.RspData.H2AData);
|
||||
}
|
||||
|
||||
@ -243,7 +247,6 @@ HttpDns6 (
|
||||
UINTN DataSize;
|
||||
BOOLEAN IsDone;
|
||||
|
||||
|
||||
Service = HttpInstance->Service;
|
||||
ASSERT (Service != NULL);
|
||||
|
||||
@ -256,7 +259,7 @@ HttpDns6 (
|
||||
//
|
||||
// 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)) {
|
||||
//
|
||||
// Get the required size.
|
||||
@ -295,7 +298,7 @@ HttpDns6 (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dns6Handle,
|
||||
&gEfiDns6ProtocolGuid,
|
||||
(VOID **) &Dns6,
|
||||
(VOID **)&Dns6,
|
||||
Service->Ip6DriverBindingHandle,
|
||||
Service->ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -358,10 +361,12 @@ HttpDns6 (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
|
||||
|
||||
if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// We just return the first IPv6 address from DNS protocol.
|
||||
//
|
||||
@ -374,10 +379,12 @@ Exit:
|
||||
if (Token.Event != NULL) {
|
||||
gBS->CloseEvent (Token.Event);
|
||||
}
|
||||
|
||||
if (Token.RspData.H2AData != NULL) {
|
||||
if (Token.RspData.H2AData->IpList != NULL) {
|
||||
FreePool (Token.RspData.H2AData->IpList);
|
||||
}
|
||||
|
||||
FreePool (Token.RspData.H2AData);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Create a HTTP driver service binding private instance.
|
||||
|
||||
@ -86,10 +85,10 @@ HttpCleanService (
|
||||
IN BOOLEAN UsingIpv6
|
||||
)
|
||||
{
|
||||
|
||||
if (HttpService == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UsingIpv6) {
|
||||
if (HttpService->Tcp4ChildHandle != NULL) {
|
||||
gBS->CloseProtocol (
|
||||
@ -127,7 +126,6 @@ HttpCleanService (
|
||||
HttpService->Tcp6ChildHandle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,13 +146,13 @@ HttpUtilitiesInstalledCallback (
|
||||
gBS->LocateProtocol (
|
||||
&gEfiHttpUtilitiesProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &mHttpUtilities
|
||||
(VOID **)&mHttpUtilities
|
||||
);
|
||||
|
||||
//
|
||||
// Close the event if Http utilities protocol is located.
|
||||
//
|
||||
if (mHttpUtilities != NULL && Event != NULL) {
|
||||
if ((mHttpUtilities != NULL) && (Event != NULL)) {
|
||||
gBS->CloseEvent (Event);
|
||||
}
|
||||
}
|
||||
@ -184,7 +182,7 @@ HttpDxeDriverEntryPoint (
|
||||
gBS->LocateProtocol (
|
||||
&gEfiHttpUtilitiesProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &mHttpUtilities
|
||||
(VOID **)&mHttpUtilities
|
||||
);
|
||||
|
||||
if (mHttpUtilities == NULL) {
|
||||
@ -230,6 +228,7 @@ HttpDxeDriverEntryPoint (
|
||||
&gHttpDxeComponentName2
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -256,14 +255,14 @@ HttpDestroyChildEntryInHandleBuffer (
|
||||
UINTN NumberOfChildren;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
|
||||
if (Entry == NULL || Context == NULL) {
|
||||
if ((Entry == NULL) || (Context == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
HttpInstance = NET_LIST_USER_STRUCT_S (Entry, HTTP_PROTOCOL, Link, HTTP_PROTOCOL_SIGNATURE);
|
||||
ServiceBinding = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
|
||||
NumberOfChildren = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
|
||||
ServiceBinding = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
|
||||
NumberOfChildren = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
|
||||
|
||||
if (!NetIsInHandleBuffer (HttpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
|
||||
return EFI_SUCCESS;
|
||||
@ -359,7 +358,7 @@ HttpDxeStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiHttpServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -420,11 +419,9 @@ HttpDxeStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
} else {
|
||||
UsingIpv6 = TRUE;
|
||||
HttpService->Ip6DriverBindingHandle = This->DriverBindingHandle;
|
||||
@ -456,11 +453,9 @@ HttpDxeStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -469,14 +464,12 @@ ON_ERROR:
|
||||
|
||||
if (HttpService != NULL) {
|
||||
HttpCleanService (HttpService, UsingIpv6);
|
||||
if (HttpService->Tcp4ChildHandle == NULL && HttpService->Tcp6ChildHandle == NULL) {
|
||||
if ((HttpService->Tcp4ChildHandle == NULL) && (HttpService->Tcp6ChildHandle == NULL)) {
|
||||
FreePool (HttpService);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -533,14 +526,13 @@ HttpDxeStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiHttpServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
NicHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);
|
||||
|
||||
if (NumberOfChildren != 0) {
|
||||
@ -558,10 +550,9 @@ HttpDxeStop (
|
||||
NULL
|
||||
);
|
||||
} else {
|
||||
|
||||
HttpCleanService (HttpService, UsingIpv6);
|
||||
|
||||
if (HttpService->Tcp4ChildHandle == NULL && HttpService->Tcp6ChildHandle == NULL) {
|
||||
if ((HttpService->Tcp4ChildHandle == NULL) && (HttpService->Tcp6ChildHandle == NULL)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
NicHandle,
|
||||
&gEfiHttpServiceBindingProtocolGuid,
|
||||
@ -569,12 +560,12 @@ HttpDxeStop (
|
||||
);
|
||||
FreePool (HttpService);
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -787,7 +778,6 @@ HttpDxeIp6DriverBindingSupported (
|
||||
RemainingDevicePath,
|
||||
IP_VERSION_6
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -885,6 +875,7 @@ HttpDxeIp6DriverBindingStop (
|
||||
IP_VERSION_6
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
@ -1008,7 +999,7 @@ HttpServiceBindingDestroyChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiHttpProtocolGuid,
|
||||
(VOID **) &Http,
|
||||
(VOID **)&Http,
|
||||
NULL,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
|
@ -61,7 +61,8 @@ EfiHttpGetModeData (
|
||||
HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
|
||||
|
||||
if ((HttpConfigData->AccessPoint.IPv6Node == NULL) ||
|
||||
(HttpConfigData->AccessPoint.IPv4Node == NULL)) {
|
||||
(HttpConfigData->AccessPoint.IPv4Node == NULL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -134,10 +135,11 @@ EfiHttpConfigure (
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (This == NULL ||
|
||||
(HttpConfigData != NULL &&
|
||||
((HttpConfigData->LocalAddressIsIPv6 && HttpConfigData->AccessPoint.IPv6Node == NULL) ||
|
||||
(!HttpConfigData->LocalAddressIsIPv6 && HttpConfigData->AccessPoint.IPv4Node == NULL)))) {
|
||||
if ((This == NULL) ||
|
||||
((HttpConfigData != NULL) &&
|
||||
((HttpConfigData->LocalAddressIsIPv6 && (HttpConfigData->AccessPoint.IPv6Node == NULL)) ||
|
||||
(!HttpConfigData->LocalAddressIsIPv6 && (HttpConfigData->AccessPoint.IPv4Node == NULL)))))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -145,7 +147,6 @@ EfiHttpConfigure (
|
||||
ASSERT (HttpInstance->Service != NULL);
|
||||
|
||||
if (HttpConfigData != NULL) {
|
||||
|
||||
if (HttpConfigData->HttpVersion >= HttpVersionUnsupported) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@ -185,7 +186,6 @@ EfiHttpConfigure (
|
||||
|
||||
HttpInstance->State = HTTP_STATE_HTTP_CONFIGED;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
} else {
|
||||
//
|
||||
// Reset all the resources related to HttpInstance.
|
||||
@ -196,7 +196,6 @@ EfiHttpConfigure (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The Request() function queues an HTTP request to this HTTP instance.
|
||||
|
||||
@ -280,7 +279,8 @@ EfiHttpRequest (
|
||||
if ((Request != NULL) && (Request->Method != HttpMethodGet) &&
|
||||
(Request->Method != HttpMethodHead) && (Request->Method != HttpMethodDelete) &&
|
||||
(Request->Method != HttpMethodPut) && (Request->Method != HttpMethodPost) &&
|
||||
(Request->Method != HttpMethodPatch)) {
|
||||
(Request->Method != HttpMethodPatch))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -303,7 +303,8 @@ EfiHttpRequest (
|
||||
//
|
||||
if ((HttpInstance->Method != HttpMethodPut) &&
|
||||
(HttpInstance->Method != HttpMethodPost) &&
|
||||
(HttpInstance->Method != HttpMethodPatch)) {
|
||||
(HttpInstance->Method != HttpMethodPatch))
|
||||
{
|
||||
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.
|
||||
//
|
||||
if (HttpMsg->Body == NULL || HttpMsg->BodyLength == 0) {
|
||||
if ((HttpMsg->Body == NULL) || (HttpMsg->BodyLength == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -344,11 +345,11 @@ EfiHttpRequest (
|
||||
if (Url == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
FreePool (HttpInstance->Url);
|
||||
HttpInstance->Url = Url;
|
||||
}
|
||||
|
||||
|
||||
UnicodeStrToAsciiStrS (Request->Url, Url, UrlLen);
|
||||
|
||||
//
|
||||
@ -361,7 +362,6 @@ EfiHttpRequest (
|
||||
// HTTP is disabled, return directly if the URI is not HTTPS.
|
||||
//
|
||||
if (!PcdGetBool (PcdAllowHttpConnections) && !(HttpInstance->UseHttps)) {
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "EfiHttpRequest: HTTP is disabled.\n"));
|
||||
|
||||
return EFI_ACCESS_DENIED;
|
||||
@ -370,7 +370,7 @@ EfiHttpRequest (
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
@ -394,7 +394,7 @@ EfiHttpRequest (
|
||||
}
|
||||
|
||||
UrlParser = NULL;
|
||||
Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, &UrlParser);
|
||||
Status = HttpParseUrl (Url, (UINT32)AsciiStrLen (Url), FALSE, &UrlParser);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Error1;
|
||||
}
|
||||
@ -407,7 +407,7 @@ EfiHttpRequest (
|
||||
if (HttpInstance->LocalAddressIsIPv6) {
|
||||
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 ']'.
|
||||
//
|
||||
@ -425,6 +425,7 @@ EfiHttpRequest (
|
||||
RemotePort = HTTP_DEFAULT_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If Configure is TRUE, it indicates the first time to call Request();
|
||||
// If ReConfigure is TRUE, it indicates the request URL is not same
|
||||
@ -443,7 +444,8 @@ EfiHttpRequest (
|
||||
(AsciiStrCmp (HttpInstance->RemoteHost, HostName) == 0) &&
|
||||
(!HttpInstance->UseHttps || (HttpInstance->UseHttps &&
|
||||
!TlsConfigure &&
|
||||
HttpInstance->TlsSessionState == EfiTlsSessionDataTransferring))) {
|
||||
(HttpInstance->TlsSessionState == EfiTlsSessionDataTransferring))))
|
||||
{
|
||||
//
|
||||
// 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.
|
||||
@ -527,6 +529,7 @@ EfiHttpRequest (
|
||||
} else {
|
||||
Status = HttpDns6 (HttpInstance, HostNameStr, &HttpInstance->RemoteIpv6Addr);
|
||||
}
|
||||
|
||||
HttpNotify (HttpEventDns, Status);
|
||||
|
||||
FreePool (HostNameStr);
|
||||
@ -608,13 +611,14 @@ EfiHttpRequest (
|
||||
// Create request message.
|
||||
//
|
||||
FileUrl = Url;
|
||||
if (Url != NULL && *FileUrl != '/') {
|
||||
if ((Url != NULL) && (*FileUrl != '/')) {
|
||||
//
|
||||
// Convert the absolute-URI to the absolute-path
|
||||
//
|
||||
while (*FileUrl != ':') {
|
||||
FileUrl++;
|
||||
}
|
||||
|
||||
if ((*(FileUrl+1) == '/') && (*(FileUrl+2) == '/')) {
|
||||
FileUrl += 3;
|
||||
while (*FileUrl != '/') {
|
||||
@ -628,7 +632,7 @@ EfiHttpRequest (
|
||||
|
||||
Status = HttpGenRequestMessage (HttpMsg, FileUrl, &RequestMsg, &RequestMsgSize);
|
||||
|
||||
if (EFI_ERROR (Status) || NULL == RequestMsg) {
|
||||
if (EFI_ERROR (Status) || (NULL == RequestMsg)) {
|
||||
goto Error3;
|
||||
}
|
||||
|
||||
@ -651,7 +655,7 @@ EfiHttpRequest (
|
||||
Status = HttpTransmitTcp (
|
||||
HttpInstance,
|
||||
Wrap,
|
||||
(UINT8*) RequestMsg,
|
||||
(UINT8 *)RequestMsg,
|
||||
RequestMsgSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -698,6 +702,7 @@ Error2:
|
||||
gBS->CloseEvent (Wrap->TcpWrap.Tx4Token.CompletionToken.Event);
|
||||
Wrap->TcpWrap.Tx4Token.CompletionToken.Event = NULL;
|
||||
}
|
||||
|
||||
if (NULL != Wrap->TcpWrap.Tx6Token.CompletionToken.Event) {
|
||||
gBS->CloseEvent (Wrap->TcpWrap.Tx6Token.CompletionToken.Event);
|
||||
Wrap->TcpWrap.Tx6Token.CompletionToken.Event = NULL;
|
||||
@ -707,15 +712,16 @@ Error1:
|
||||
if (HostName != NULL) {
|
||||
FreePool (HostName);
|
||||
}
|
||||
|
||||
if (Wrap != NULL) {
|
||||
FreePool (Wrap);
|
||||
}
|
||||
|
||||
if (UrlParser != NULL) {
|
||||
HttpUrlFreeParser (UrlParser);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -741,7 +747,7 @@ HttpCancelTokens (
|
||||
HTTP_TOKEN_WRAP *Wrap;
|
||||
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
|
||||
@ -751,7 +757,7 @@ HttpCancelTokens (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Wrap = (HTTP_TOKEN_WRAP *) Item->Value;
|
||||
Wrap = (HTTP_TOKEN_WRAP *)Item->Value;
|
||||
ASSERT (Wrap != NULL);
|
||||
HttpInstance = Wrap->HttpInstance;
|
||||
|
||||
@ -855,7 +861,6 @@ HttpCancel (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Abort an asynchronous HTTP request or response token.
|
||||
|
||||
@ -898,7 +903,6 @@ EfiHttpCancel (
|
||||
}
|
||||
|
||||
return HttpCancel (HttpInstance, Token);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -933,13 +937,13 @@ HttpBodyParserCallback (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (Data == NULL || Length != 0 || Context == NULL) {
|
||||
if ((Data == NULL) || (Length != 0) || (Context == NULL)) {
|
||||
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;
|
||||
BodyLength = CallbackData->ParseDataLength;
|
||||
|
||||
@ -987,7 +991,7 @@ HttpResponseWorker (
|
||||
NET_FRAGMENT Fragment;
|
||||
UINT32 TimeoutValue;
|
||||
|
||||
if (Wrap == NULL || Wrap->HttpInstance == NULL) {
|
||||
if ((Wrap == NULL) || (Wrap->HttpInstance == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1038,7 +1042,6 @@ HttpResponseWorker (
|
||||
HttpInstance->EndofHeader = &EndofHeader;
|
||||
HttpInstance->HttpHeaders = &HttpHeaders;
|
||||
|
||||
|
||||
if (HttpInstance->TimeoutEvent == NULL) {
|
||||
//
|
||||
// Create TimeoutEvent for response
|
||||
@ -1144,7 +1147,7 @@ HttpResponseWorker (
|
||||
// Hence, check that case before doing a NetMapRemoveHead.
|
||||
//
|
||||
if (!NetMapIsEmpty (&HttpInstance->TxTokens)) {
|
||||
NetMapRemoveHead (&HttpInstance->TxTokens, (VOID**) &ValueInItem);
|
||||
NetMapRemoveHead (&HttpInstance->TxTokens, (VOID **)&ValueInItem);
|
||||
if (ValueInItem == NULL) {
|
||||
goto Error;
|
||||
}
|
||||
@ -1193,7 +1196,6 @@ HttpResponseWorker (
|
||||
FreePool (HttpHeaders);
|
||||
HttpHeaders = NULL;
|
||||
|
||||
|
||||
//
|
||||
// Init message-body parser by header information.
|
||||
//
|
||||
@ -1203,7 +1205,7 @@ HttpResponseWorker (
|
||||
HttpMsg->HeaderCount,
|
||||
HttpMsg->Headers,
|
||||
HttpBodyParserCallback,
|
||||
(VOID *) (&HttpInstance->CallbackData),
|
||||
(VOID *)(&HttpInstance->CallbackData),
|
||||
&HttpInstance->MsgParser
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -1217,8 +1219,8 @@ HttpResponseWorker (
|
||||
//
|
||||
// Record the CallbackData data.
|
||||
//
|
||||
HttpInstance->CallbackData.Wrap = (VOID *) Wrap;
|
||||
HttpInstance->CallbackData.ParseData = (VOID *) HttpInstance->CacheBody;
|
||||
HttpInstance->CallbackData.Wrap = (VOID *)Wrap;
|
||||
HttpInstance->CallbackData.ParseData = (VOID *)HttpInstance->CacheBody;
|
||||
HttpInstance->CallbackData.ParseDataLength = HttpInstance->CacheLen;
|
||||
|
||||
//
|
||||
@ -1291,6 +1293,7 @@ HttpResponseWorker (
|
||||
HttpInstance->CacheOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Return since we already received required data.
|
||||
//
|
||||
@ -1298,7 +1301,7 @@ HttpResponseWorker (
|
||||
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.
|
||||
//
|
||||
@ -1319,7 +1322,6 @@ HttpResponseWorker (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Error2;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (HttpInstance->TimeoutEvent == NULL) {
|
||||
//
|
||||
@ -1361,14 +1363,14 @@ HttpResponseWorker (
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Record the CallbackData data.
|
||||
//
|
||||
HttpInstance->CallbackData.Wrap = (VOID *) Wrap;
|
||||
HttpInstance->CallbackData.Wrap = (VOID *)Wrap;
|
||||
HttpInstance->CallbackData.ParseData = HttpMsg->Body;
|
||||
HttpInstance->CallbackData.ParseDataLength = HttpMsg->BodyLength;
|
||||
|
||||
@ -1396,7 +1398,7 @@ HttpResponseWorker (
|
||||
// Check whether there is the next message header in the HttpMsg->Body.
|
||||
//
|
||||
if (HttpInstance->NextMsg != NULL) {
|
||||
HttpMsg->BodyLength = HttpInstance->NextMsg - (CHAR8 *) HttpMsg->Body;
|
||||
HttpMsg->BodyLength = HttpInstance->NextMsg - (CHAR8 *)HttpMsg->Body;
|
||||
}
|
||||
|
||||
HttpInstance->CacheLen = Fragment.Len - HttpMsg->BodyLength;
|
||||
@ -1491,10 +1493,8 @@ Error:
|
||||
gBS->SignalEvent (Token->Event);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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,
|
||||
@ -1619,6 +1619,7 @@ Error:
|
||||
if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event != NULL) {
|
||||
gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event);
|
||||
}
|
||||
|
||||
FreePool (Wrap);
|
||||
}
|
||||
|
||||
@ -1668,11 +1669,13 @@ EfiHttpPoll (
|
||||
if (HttpInstance->Tcp6 == NULL) {
|
||||
return EFI_NOT_STARTED;
|
||||
}
|
||||
|
||||
Status = HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
|
||||
} else {
|
||||
if (HttpInstance->Tcp4 == NULL) {
|
||||
return EFI_NOT_STARTED;
|
||||
}
|
||||
|
||||
Status = HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n"
|
||||
#define HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE 300
|
||||
|
||||
|
||||
/**
|
||||
Returns the operational parameters for the current HTTP child instance.
|
||||
|
||||
|
@ -24,10 +24,10 @@ HttpCommonNotify (
|
||||
)
|
||||
{
|
||||
if ((Event == NULL) || (Context == NULL)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
*((BOOLEAN *) Context) = TRUE;
|
||||
*((BOOLEAN *)Context) = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,10 +46,10 @@ HttpTcpTransmitNotifyDpc (
|
||||
HTTP_PROTOCOL *HttpInstance;
|
||||
|
||||
if (Context == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Wrap = (HTTP_TOKEN_WRAP *) Context;
|
||||
Wrap = (HTTP_TOKEN_WRAP *)Context;
|
||||
HttpInstance = Wrap->HttpInstance;
|
||||
|
||||
if (!HttpInstance->LocalAddressIsIPv6) {
|
||||
@ -66,7 +66,6 @@ HttpTcpTransmitNotifyDpc (
|
||||
if (Wrap->TcpWrap.Tx4Token.CompletionToken.Event != NULL) {
|
||||
gBS->CloseEvent (Wrap->TcpWrap.Tx4Token.CompletionToken.Event);
|
||||
}
|
||||
|
||||
} else {
|
||||
Wrap->HttpToken->Status = Wrap->TcpWrap.Tx6Token.CompletionToken.Status;
|
||||
gBS->SignalEvent (Wrap->HttpToken->Event);
|
||||
@ -83,14 +82,12 @@ HttpTcpTransmitNotifyDpc (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Wrap->TcpWrap.IsTxDone = TRUE;
|
||||
|
||||
//
|
||||
// Check pending TxTokens and sent out.
|
||||
//
|
||||
NetMapIterate (&Wrap->HttpInstance->TxTokens, HttpTcpTransmit, NULL);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,10 +130,10 @@ HttpTcpReceiveNotifyDpc (
|
||||
BOOLEAN UsingIpv6;
|
||||
|
||||
if (Context == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Wrap = (HTTP_TOKEN_WRAP *) Context;
|
||||
Wrap = (HTTP_TOKEN_WRAP *)Context;
|
||||
HttpInstance = Wrap->HttpInstance;
|
||||
UsingIpv6 = HttpInstance->LocalAddressIsIPv6;
|
||||
|
||||
@ -157,9 +154,8 @@ HttpTcpReceiveNotifyDpc (
|
||||
FreePool (Wrap);
|
||||
Wrap = NULL;
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);
|
||||
Wrap->TcpWrap.Rx4Token.CompletionToken.Event = NULL;
|
||||
@ -177,7 +173,7 @@ HttpTcpReceiveNotifyDpc (
|
||||
FreePool (Wrap);
|
||||
Wrap = NULL;
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,15 +182,15 @@ HttpTcpReceiveNotifyDpc (
|
||||
//
|
||||
ASSERT (HttpInstance->MsgParser != NULL);
|
||||
if (UsingIpv6) {
|
||||
Length = (UINTN) Wrap->TcpWrap.Rx6Data.FragmentTable[0].FragmentLength;
|
||||
Length = (UINTN)Wrap->TcpWrap.Rx6Data.FragmentTable[0].FragmentLength;
|
||||
} else {
|
||||
Length = (UINTN) Wrap->TcpWrap.Rx4Data.FragmentTable[0].FragmentLength;
|
||||
Length = (UINTN)Wrap->TcpWrap.Rx4Data.FragmentTable[0].FragmentLength;
|
||||
}
|
||||
|
||||
//
|
||||
// Record the CallbackData data.
|
||||
//
|
||||
HttpInstance->CallbackData.Wrap = (VOID *) Wrap;
|
||||
HttpInstance->CallbackData.Wrap = (VOID *)Wrap;
|
||||
HttpInstance->CallbackData.ParseData = Wrap->HttpToken->Message->Body;
|
||||
HttpInstance->CallbackData.ParseDataLength = Length;
|
||||
|
||||
@ -207,7 +203,7 @@ HttpTcpReceiveNotifyDpc (
|
||||
Wrap->HttpToken->Message->Body
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (HttpIsMessageComplete (HttpInstance->MsgParser)) {
|
||||
@ -225,13 +221,14 @@ HttpTcpReceiveNotifyDpc (
|
||||
//
|
||||
if (HttpInstance->NextMsg != NULL) {
|
||||
Wrap->HttpToken->Message->BodyLength = HttpInstance->NextMsg -
|
||||
(CHAR8 *) Wrap->HttpToken->Message->Body;
|
||||
(CHAR8 *)Wrap->HttpToken->Message->Body;
|
||||
HttpInstance->CacheLen = Length - Wrap->HttpToken->Message->BodyLength;
|
||||
if (HttpInstance->CacheLen != 0) {
|
||||
HttpInstance->CacheBody = AllocateZeroPool (HttpInstance->CacheLen);
|
||||
if (HttpInstance->CacheBody == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
CopyMem (HttpInstance->CacheBody, HttpInstance->NextMsg, HttpInstance->CacheLen);
|
||||
HttpInstance->NextMsg = HttpInstance->CacheBody;
|
||||
HttpInstance->CacheOffset = 0;
|
||||
@ -243,7 +240,6 @@ HttpTcpReceiveNotifyDpc (
|
||||
NetMapRemoveItem (&Wrap->HttpInstance->RxTokens, Item, NULL);
|
||||
}
|
||||
|
||||
|
||||
Wrap->TcpWrap.IsRxDone = TRUE;
|
||||
if (UsingIpv6) {
|
||||
Wrap->HttpToken->Status = Wrap->TcpWrap.Rx6Token.CompletionToken.Status;
|
||||
@ -251,7 +247,6 @@ HttpTcpReceiveNotifyDpc (
|
||||
Wrap->HttpToken->Status = Wrap->TcpWrap.Rx4Token.CompletionToken.Status;
|
||||
}
|
||||
|
||||
|
||||
gBS->SignalEvent (Wrap->HttpToken->Event);
|
||||
|
||||
//
|
||||
@ -327,7 +322,6 @@ HttpCreateTcpConnCloseEvent (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
//
|
||||
// Create events for various asynchronous operations.
|
||||
@ -369,7 +363,6 @@ ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Close events in the TCP connection token and TCP close token.
|
||||
|
||||
@ -390,10 +383,9 @@ HttpCloseTcpConnCloseEvent (
|
||||
}
|
||||
|
||||
if (NULL != HttpInstance->Tcp6CloseToken.CompletionToken.Event) {
|
||||
gBS->CloseEvent(HttpInstance->Tcp6CloseToken.CompletionToken.Event);
|
||||
gBS->CloseEvent (HttpInstance->Tcp6CloseToken.CompletionToken.Event);
|
||||
HttpInstance->Tcp6CloseToken.CompletionToken.Event = NULL;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (NULL != HttpInstance->Tcp4ConnToken.CompletionToken.Event) {
|
||||
gBS->CloseEvent (HttpInstance->Tcp4ConnToken.CompletionToken.Event);
|
||||
@ -401,11 +393,10 @@ HttpCloseTcpConnCloseEvent (
|
||||
}
|
||||
|
||||
if (NULL != HttpInstance->Tcp4CloseToken.CompletionToken.Event) {
|
||||
gBS->CloseEvent(HttpInstance->Tcp4CloseToken.CompletionToken.Event);
|
||||
gBS->CloseEvent (HttpInstance->Tcp4CloseToken.CompletionToken.Event);
|
||||
HttpInstance->Tcp4CloseToken.CompletionToken.Event = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -446,7 +437,6 @@ HttpCreateTcpTxEvent (
|
||||
TcpWrap->Tx4Data.FragmentCount = 1;
|
||||
TcpWrap->Tx4Token.Packet.TxData = &Wrap->TcpWrap.Tx4Data;
|
||||
TcpWrap->Tx4Token.CompletionToken.Status = EFI_NOT_READY;
|
||||
|
||||
} else {
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
@ -463,8 +453,7 @@ HttpCreateTcpTxEvent (
|
||||
TcpWrap->Tx6Data.Urgent = FALSE;
|
||||
TcpWrap->Tx6Data.FragmentCount = 1;
|
||||
TcpWrap->Tx6Token.Packet.TxData = &Wrap->TcpWrap.Tx6Data;
|
||||
TcpWrap->Tx6Token.CompletionToken.Status =EFI_NOT_READY;
|
||||
|
||||
TcpWrap->Tx6Token.CompletionToken.Status = EFI_NOT_READY;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -501,7 +490,6 @@ HttpCreateTcpRxEventForHeader (
|
||||
HttpInstance->Rx4Data.FragmentCount = 1;
|
||||
HttpInstance->Rx4Token.Packet.RxData = &HttpInstance->Rx4Data;
|
||||
HttpInstance->Rx4Token.CompletionToken.Status = EFI_NOT_READY;
|
||||
|
||||
} else {
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
@ -514,13 +502,11 @@ HttpCreateTcpRxEventForHeader (
|
||||
return Status;
|
||||
}
|
||||
|
||||
HttpInstance->Rx6Data.FragmentCount =1;
|
||||
HttpInstance->Rx6Data.FragmentCount = 1;
|
||||
HttpInstance->Rx6Token.Packet.RxData = &HttpInstance->Rx6Data;
|
||||
HttpInstance->Rx6Token.CompletionToken.Status = EFI_NOT_READY;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -559,7 +545,6 @@ HttpCreateTcpRxEvent (
|
||||
TcpWrap->Rx4Data.FragmentCount = 1;
|
||||
TcpWrap->Rx4Token.Packet.RxData = &Wrap->TcpWrap.Rx4Data;
|
||||
TcpWrap->Rx4Token.CompletionToken.Status = EFI_NOT_READY;
|
||||
|
||||
} else {
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
@ -658,7 +643,7 @@ HttpInitProtocol (
|
||||
Status = gBS->OpenProtocol (
|
||||
HttpInstance->Tcp4ChildHandle,
|
||||
&gEfiTcp4ProtocolGuid,
|
||||
(VOID **) &Interface,
|
||||
(VOID **)&Interface,
|
||||
HttpInstance->Service->Ip4DriverBindingHandle,
|
||||
HttpInstance->Service->ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -671,24 +656,24 @@ HttpInitProtocol (
|
||||
Status = gBS->OpenProtocol (
|
||||
HttpInstance->Tcp4ChildHandle,
|
||||
&gEfiTcp4ProtocolGuid,
|
||||
(VOID **) &HttpInstance->Tcp4,
|
||||
(VOID **)&HttpInstance->Tcp4,
|
||||
HttpInstance->Service->Ip4DriverBindingHandle,
|
||||
HttpInstance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
HttpInstance->Service->Tcp4ChildHandle,
|
||||
&gEfiTcp4ProtocolGuid,
|
||||
(VOID **) &Interface,
|
||||
(VOID **)&Interface,
|
||||
HttpInstance->Service->Ip4DriverBindingHandle,
|
||||
HttpInstance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
} else {
|
||||
@ -709,7 +694,7 @@ HttpInitProtocol (
|
||||
Status = gBS->OpenProtocol (
|
||||
HttpInstance->Tcp6ChildHandle,
|
||||
&gEfiTcp6ProtocolGuid,
|
||||
(VOID **) &Interface,
|
||||
(VOID **)&Interface,
|
||||
HttpInstance->Service->Ip6DriverBindingHandle,
|
||||
HttpInstance->Service->ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -722,26 +707,26 @@ HttpInitProtocol (
|
||||
Status = gBS->OpenProtocol (
|
||||
HttpInstance->Tcp6ChildHandle,
|
||||
&gEfiTcp6ProtocolGuid,
|
||||
(VOID **) &HttpInstance->Tcp6,
|
||||
(VOID **)&HttpInstance->Tcp6,
|
||||
HttpInstance->Service->Ip6DriverBindingHandle,
|
||||
HttpInstance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
HttpInstance->Service->Tcp6ChildHandle,
|
||||
&gEfiTcp6ProtocolGuid,
|
||||
(VOID **) &Interface,
|
||||
(VOID **)&Interface,
|
||||
HttpInstance->Service->Ip6DriverBindingHandle,
|
||||
HttpInstance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
}
|
||||
@ -821,7 +806,6 @@ ON_ERROR:
|
||||
}
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -868,7 +852,7 @@ HttpCleanProtocol (
|
||||
NetMapClean (&HttpInstance->TxTokens);
|
||||
NetMapClean (&HttpInstance->RxTokens);
|
||||
|
||||
if (HttpInstance->TlsSb != NULL && HttpInstance->TlsChildHandle != NULL) {
|
||||
if ((HttpInstance->TlsSb != NULL) && (HttpInstance->TlsChildHandle != NULL)) {
|
||||
//
|
||||
// Destroy the TLS instance.
|
||||
//
|
||||
@ -977,7 +961,6 @@ HttpCreateConnection (
|
||||
}
|
||||
|
||||
Status = HttpInstance->Tcp4ConnToken.CompletionToken.Status;
|
||||
|
||||
} else {
|
||||
HttpInstance->IsTcp6ConnDone = FALSE;
|
||||
HttpInstance->Tcp6ConnToken.CompletionToken.Status = EFI_NOT_READY;
|
||||
@ -988,7 +971,7 @@ HttpCreateConnection (
|
||||
return Status;
|
||||
}
|
||||
|
||||
while(!HttpInstance->IsTcp6ConnDone) {
|
||||
while (!HttpInstance->IsTcp6ConnDone) {
|
||||
HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
|
||||
}
|
||||
|
||||
@ -1019,7 +1002,6 @@ HttpCloseConnection (
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (HttpInstance->State == HTTP_STATE_TCP_CONNECTED) {
|
||||
|
||||
if (HttpInstance->LocalAddressIsIPv6) {
|
||||
HttpInstance->Tcp6CloseToken.AbortOnClose = TRUE;
|
||||
HttpInstance->IsTcp6CloseDone = FALSE;
|
||||
@ -1031,7 +1013,6 @@ HttpCloseConnection (
|
||||
while (!HttpInstance->IsTcp6CloseDone) {
|
||||
HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
|
||||
}
|
||||
|
||||
} else {
|
||||
HttpInstance->Tcp4CloseToken.AbortOnClose = TRUE;
|
||||
HttpInstance->IsTcp4CloseDone = FALSE;
|
||||
@ -1044,7 +1025,6 @@ HttpCloseConnection (
|
||||
HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HttpInstance->State = HTTP_STATE_TCP_CLOSED;
|
||||
@ -1074,7 +1054,6 @@ HttpConfigureTcp4 (
|
||||
|
||||
ASSERT (HttpInstance != NULL);
|
||||
|
||||
|
||||
Tcp4CfgData = &HttpInstance->Tcp4CfgData;
|
||||
ZeroMem (Tcp4CfgData, sizeof (EFI_TCP4_CONFIG_DATA));
|
||||
|
||||
@ -1163,7 +1142,7 @@ HttpConfigureTcp6 (
|
||||
Tcp6Ap->StationPort = HttpInstance->Ipv6Node.LocalPort;
|
||||
Tcp6Ap->RemotePort = HttpInstance->RemotePort;
|
||||
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->ReceiveBufferSize = HTTP_BUFFER_SIZE_DEAULT;
|
||||
@ -1196,7 +1175,6 @@ HttpConfigureTcp6 (
|
||||
HttpInstance->State = HTTP_STATE_TCP_CONFIGED;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1218,12 +1196,11 @@ HttpConnectTcp4 (
|
||||
EFI_STATUS Status;
|
||||
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;
|
||||
}
|
||||
|
||||
Status = HttpInstance->Tcp4->GetModeData(
|
||||
Status = HttpInstance->Tcp4->GetModeData (
|
||||
HttpInstance->Tcp4,
|
||||
&Tcp4State,
|
||||
NULL,
|
||||
@ -1231,7 +1208,7 @@ HttpConnectTcp4 (
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR(Status)){
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Tcp4 GetModeData fail - %x\n", Status));
|
||||
return Status;
|
||||
}
|
||||
@ -1239,11 +1216,11 @@ HttpConnectTcp4 (
|
||||
if (Tcp4State == Tcp4StateEstablished) {
|
||||
return EFI_SUCCESS;
|
||||
} else if (Tcp4State > Tcp4StateEstablished ) {
|
||||
HttpCloseConnection(HttpInstance);
|
||||
HttpCloseConnection (HttpInstance);
|
||||
}
|
||||
|
||||
Status = HttpCreateConnection (HttpInstance);
|
||||
if (EFI_ERROR(Status)){
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Tcp4 Connection fail - %x\n", Status));
|
||||
return Status;
|
||||
}
|
||||
@ -1311,7 +1288,7 @@ HttpConnectTcp6 (
|
||||
EFI_STATUS Status;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1324,7 +1301,7 @@ HttpConnectTcp6 (
|
||||
NULL
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)){
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Tcp6 GetModeData fail - %x\n", Status));
|
||||
return Status;
|
||||
}
|
||||
@ -1332,11 +1309,11 @@ HttpConnectTcp6 (
|
||||
if (Tcp6State == Tcp6StateEstablished) {
|
||||
return EFI_SUCCESS;
|
||||
} else if (Tcp6State > Tcp6StateEstablished ) {
|
||||
HttpCloseConnection(HttpInstance);
|
||||
HttpCloseConnection (HttpInstance);
|
||||
}
|
||||
|
||||
Status = HttpCreateConnection (HttpInstance);
|
||||
if (EFI_ERROR(Status)){
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Tcp6 Connection fail - %x\n", Status));
|
||||
return Status;
|
||||
}
|
||||
@ -1406,6 +1383,7 @@ HttpInitSession (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (HttpInstance != NULL);
|
||||
|
||||
//
|
||||
@ -1457,7 +1435,6 @@ HttpInitSession (
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1530,12 +1507,12 @@ HttpTransmitTcp (
|
||||
//
|
||||
RemainingLen = TxStringLen;
|
||||
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)->Version.Major = HttpInstance->TlsConfigData.Version.Major;
|
||||
((TLS_RECORD_HEADER *) TlsRecord)->Version.Minor = HttpInstance->TlsConfigData.Version.Minor;
|
||||
((TLS_RECORD_HEADER *) TlsRecord)->Length = PayloadSize;
|
||||
((TLS_RECORD_HEADER *)TlsRecord)->ContentType = TlsContentTypeApplicationData;
|
||||
((TLS_RECORD_HEADER *)TlsRecord)->Version.Major = HttpInstance->TlsConfigData.Version.Major;
|
||||
((TLS_RECORD_HEADER *)TlsRecord)->Version.Minor = HttpInstance->TlsConfigData.Version.Minor;
|
||||
((TLS_RECORD_HEADER *)TlsRecord)->Length = PayloadSize;
|
||||
|
||||
CopyMem (TlsRecord + TLS_RECORD_HEADER_LENGTH, TxString + (TxStringLen - RemainingLen), PayloadSize);
|
||||
|
||||
@ -1560,7 +1537,7 @@ HttpTransmitTcp (
|
||||
TempFragment.Len = 0;
|
||||
TempFragment.Bulk = NULL;
|
||||
|
||||
RemainingLen -= (UINTN) PayloadSize;
|
||||
RemainingLen -= (UINTN)PayloadSize;
|
||||
ZeroMem (TlsRecord, TLS_RECORD_HEADER_LENGTH + TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH);
|
||||
}
|
||||
|
||||
@ -1575,11 +1552,11 @@ HttpTransmitTcp (
|
||||
if (HttpInstance->UseHttps) {
|
||||
Tx4Token->Packet.TxData->DataLength = 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 {
|
||||
Tx4Token->Packet.TxData->DataLength = (UINT32) TxStringLen;
|
||||
Tx4Token->Packet.TxData->FragmentTable[0].FragmentLength = (UINT32) TxStringLen;
|
||||
Tx4Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *) TxString;
|
||||
Tx4Token->Packet.TxData->DataLength = (UINT32)TxStringLen;
|
||||
Tx4Token->Packet.TxData->FragmentTable[0].FragmentLength = (UINT32)TxStringLen;
|
||||
Tx4Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *)TxString;
|
||||
}
|
||||
|
||||
Tx4Token->CompletionToken.Status = EFI_NOT_READY;
|
||||
@ -1590,7 +1567,6 @@ HttpTransmitTcp (
|
||||
DEBUG ((DEBUG_ERROR, "Transmit failed: %r\n", Status));
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
Tcp6 = HttpInstance->Tcp6;
|
||||
Tx6Token = &Wrap->TcpWrap.Tx6Token;
|
||||
@ -1598,11 +1574,11 @@ HttpTransmitTcp (
|
||||
if (HttpInstance->UseHttps) {
|
||||
Tx6Token->Packet.TxData->DataLength = 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 {
|
||||
Tx6Token->Packet.TxData->DataLength = (UINT32) TxStringLen;
|
||||
Tx6Token->Packet.TxData->FragmentTable[0].FragmentLength = (UINT32) TxStringLen;
|
||||
Tx6Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *) TxString;
|
||||
Tx6Token->Packet.TxData->DataLength = (UINT32)TxStringLen;
|
||||
Tx6Token->Packet.TxData->FragmentTable[0].FragmentLength = (UINT32)TxStringLen;
|
||||
Tx6Token->Packet.TxData->FragmentTable[0].FragmentBuffer = (VOID *)TxString;
|
||||
}
|
||||
|
||||
Tx6Token->CompletionToken.Status = EFI_NOT_READY;
|
||||
@ -1659,10 +1635,10 @@ HttpTokenExist (
|
||||
EFI_HTTP_TOKEN *Token;
|
||||
EFI_HTTP_TOKEN *TokenInItem;
|
||||
|
||||
Token = (EFI_HTTP_TOKEN *) Context;
|
||||
TokenInItem = (EFI_HTTP_TOKEN *) Item->Key;
|
||||
Token = (EFI_HTTP_TOKEN *)Context;
|
||||
TokenInItem = (EFI_HTTP_TOKEN *)Item->Key;
|
||||
|
||||
if (Token == TokenInItem || Token->Event == TokenInItem->Event) {
|
||||
if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
@ -1690,7 +1666,7 @@ HttpTcpNotReady (
|
||||
{
|
||||
HTTP_TOKEN_WRAP *ValueInItem;
|
||||
|
||||
ValueInItem = (HTTP_TOKEN_WRAP *) Item->Value;
|
||||
ValueInItem = (HTTP_TOKEN_WRAP *)Item->Value;
|
||||
|
||||
if (!ValueInItem->TcpWrap.IsTxDone) {
|
||||
return EFI_NOT_READY;
|
||||
@ -1728,7 +1704,7 @@ HttpTcpTransmit (
|
||||
|
||||
RequestMsg = NULL;
|
||||
|
||||
ValueInItem = (HTTP_TOKEN_WRAP *) Item->Value;
|
||||
ValueInItem = (HTTP_TOKEN_WRAP *)Item->Value;
|
||||
if (ValueInItem->TcpWrap.IsTxDone) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1755,7 +1731,7 @@ HttpTcpTransmit (
|
||||
);
|
||||
FreePool (Url);
|
||||
|
||||
if (EFI_ERROR (Status) || NULL == RequestMsg){
|
||||
if (EFI_ERROR (Status) || (NULL == RequestMsg)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1767,7 +1743,7 @@ HttpTcpTransmit (
|
||||
Status = HttpTransmitTcp (
|
||||
ValueInItem->HttpInstance,
|
||||
ValueInItem,
|
||||
(UINT8*) RequestMsg,
|
||||
(UINT8 *)RequestMsg,
|
||||
RequestMsgSize
|
||||
);
|
||||
FreePool (RequestMsg);
|
||||
@ -1797,7 +1773,7 @@ HttpTcpReceive (
|
||||
//
|
||||
// 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.Bulk = (UINT8 *) Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer;
|
||||
Fragment.Bulk = (UINT8 *)Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer;
|
||||
} else {
|
||||
if (Fragment.Bulk != NULL) {
|
||||
FreePool (Fragment.Bulk);
|
||||
@ -1940,12 +1916,12 @@ HttpTcpReceiveHeader (
|
||||
// Check whether we received end of HTTP headers.
|
||||
//
|
||||
*EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR);
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
|
||||
Fragment.Bulk = NULL;
|
||||
@ -1998,7 +1974,7 @@ HttpTcpReceiveHeader (
|
||||
}
|
||||
|
||||
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 {
|
||||
if (Fragment.Bulk != NULL) {
|
||||
FreePool (Fragment.Bulk);
|
||||
@ -2040,12 +2016,12 @@ HttpTcpReceiveHeader (
|
||||
// Check whether we received end of HTTP headers.
|
||||
//
|
||||
*EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR);
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
|
||||
Fragment.Bulk = NULL;
|
||||
@ -2104,9 +2080,9 @@ HttpTcpReceiveBody (
|
||||
|
||||
if (HttpInstance->LocalAddressIsIPv6) {
|
||||
Rx6Token = &Wrap->TcpWrap.Rx6Token;
|
||||
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].FragmentBuffer = (VOID *) HttpMsg->Body;
|
||||
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].FragmentBuffer = (VOID *)HttpMsg->Body;
|
||||
Rx6Token->CompletionToken.Status = EFI_NOT_READY;
|
||||
|
||||
Status = Tcp6->Receive (Tcp6, Rx6Token);
|
||||
@ -2116,9 +2092,9 @@ HttpTcpReceiveBody (
|
||||
}
|
||||
} else {
|
||||
Rx4Token = &Wrap->TcpWrap.Rx4Token;
|
||||
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].FragmentBuffer = (VOID *) HttpMsg->Body;
|
||||
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].FragmentBuffer = (VOID *)HttpMsg->Body;
|
||||
|
||||
Rx4Token->CompletionToken.Status = EFI_NOT_READY;
|
||||
Status = Tcp4->Receive (Tcp4, Rx4Token);
|
||||
@ -2129,7 +2105,6 @@ HttpTcpReceiveBody (
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2173,7 +2148,6 @@ HttpTcpTokenCleanup (
|
||||
FreePool (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
|
||||
Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
|
||||
}
|
||||
|
||||
} else {
|
||||
Rx4Token = &Wrap->TcpWrap.Rx4Token;
|
||||
|
||||
@ -2191,13 +2165,11 @@ HttpTcpTokenCleanup (
|
||||
Rx4Token->CompletionToken.Event = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
|
||||
FreePool (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
|
||||
Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2237,7 +2209,7 @@ HttpNotify (
|
||||
Status = gBS->HandleProtocol (
|
||||
Handle,
|
||||
&gEdkiiHttpCallbackProtocolGuid,
|
||||
(VOID **) &HttpCallback
|
||||
(VOID **)&HttpCallback
|
||||
);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
DEBUG ((DEBUG_INFO, "HttpNotify: Notifying %p\n", HttpCallback));
|
||||
@ -2248,6 +2220,7 @@ HttpNotify (
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (Handles);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
HTTP_SERVICE_SIGNATURE \
|
||||
)
|
||||
|
||||
|
||||
//
|
||||
// The state of HTTP protocol. It starts from UNCONFIGED.
|
||||
//
|
||||
@ -203,7 +202,6 @@ typedef struct {
|
||||
HTTP_TCP_TOKEN_WRAP TcpWrap;
|
||||
} HTTP_TOKEN_WRAP;
|
||||
|
||||
|
||||
#define HTTP_PROTOCOL_SIGNATURE SIGNATURE_32('H', 't', 't', 'P')
|
||||
|
||||
#define HTTP_INSTANCE_FROM_PROTOCOL(a) \
|
||||
|
@ -48,15 +48,16 @@ AsciiStrCaseStr (
|
||||
ASSERT (AsciiStrSize (SearchString) != 0);
|
||||
|
||||
if (*SearchString == '\0') {
|
||||
return (CHAR8 *) String;
|
||||
return (CHAR8 *)String;
|
||||
}
|
||||
|
||||
while (*String != '\0') {
|
||||
SearchStringTmp = SearchString;
|
||||
FirstMatch = String;
|
||||
|
||||
while ((*SearchStringTmp != '\0')
|
||||
&& (*String != '\0')) {
|
||||
while ( (*SearchStringTmp != '\0')
|
||||
&& (*String != '\0'))
|
||||
{
|
||||
Src = *String;
|
||||
Dst = *SearchStringTmp;
|
||||
|
||||
@ -77,7 +78,7 @@ AsciiStrCaseStr (
|
||||
}
|
||||
|
||||
if (*SearchStringTmp == '\0') {
|
||||
return (CHAR8 *) FirstMatch;
|
||||
return (CHAR8 *)FirstMatch;
|
||||
}
|
||||
|
||||
String = FirstMatch + 1;
|
||||
@ -100,7 +101,7 @@ FreeNbufList (
|
||||
{
|
||||
ASSERT (Arg != NULL);
|
||||
|
||||
NetbufFreeList ((LIST_ENTRY *) Arg);
|
||||
NetbufFreeList ((LIST_ENTRY *)Arg);
|
||||
FreePool (Arg);
|
||||
}
|
||||
|
||||
@ -123,7 +124,7 @@ IsHttpsUrl (
|
||||
Tmp = NULL;
|
||||
|
||||
Tmp = AsciiStrCaseStr (Url, HTTPS_FLAG);
|
||||
if (Tmp != NULL && Tmp == Url) {
|
||||
if ((Tmp != NULL) && (Tmp == Url)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -161,7 +162,7 @@ TlsCreateChild (
|
||||
gBS->LocateProtocol (
|
||||
&gEfiTlsServiceBindingProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) TlsSb
|
||||
(VOID **)TlsSb
|
||||
);
|
||||
if (*TlsSb == NULL) {
|
||||
return NULL;
|
||||
@ -175,7 +176,7 @@ TlsCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
TlsChildHandle,
|
||||
&gEfiTlsProtocolGuid,
|
||||
(VOID **) TlsProto,
|
||||
(VOID **)TlsProto,
|
||||
ImageHandle,
|
||||
TlsChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -188,7 +189,7 @@ TlsCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
TlsChildHandle,
|
||||
&gEfiTlsConfigurationProtocolGuid,
|
||||
(VOID **) TlsConfiguration,
|
||||
(VOID **)TlsConfiguration,
|
||||
ImageHandle,
|
||||
TlsChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -259,7 +260,7 @@ TlsCreateTxRxEvent (
|
||||
|
||||
HttpInstance->Tcp4TlsRxData.DataLength = 0;
|
||||
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->Tcp4TlsRxToken.Packet.RxData = &HttpInstance->Tcp4TlsRxData;
|
||||
HttpInstance->Tcp4TlsRxToken.CompletionToken.Status = EFI_NOT_READY;
|
||||
@ -303,7 +304,7 @@ TlsCreateTxRxEvent (
|
||||
|
||||
HttpInstance->Tcp6TlsRxData.DataLength = 0;
|
||||
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->Tcp6TlsRxToken.Packet.RxData = &HttpInstance->Tcp6TlsRxData;
|
||||
HttpInstance->Tcp6TlsRxToken.CompletionToken.Status = EFI_NOT_READY;
|
||||
@ -335,7 +336,7 @@ TlsCloseTxRxEvent (
|
||||
ASSERT (HttpInstance != NULL);
|
||||
if (!HttpInstance->LocalAddressIsIPv6) {
|
||||
if (NULL != HttpInstance->Tcp4TlsTxToken.CompletionToken.Event) {
|
||||
gBS->CloseEvent(HttpInstance->Tcp4TlsTxToken.CompletionToken.Event);
|
||||
gBS->CloseEvent (HttpInstance->Tcp4TlsTxToken.CompletionToken.Event);
|
||||
HttpInstance->Tcp4TlsTxToken.CompletionToken.Event = NULL;
|
||||
}
|
||||
|
||||
@ -345,7 +346,7 @@ TlsCloseTxRxEvent (
|
||||
}
|
||||
} else {
|
||||
if (NULL != HttpInstance->Tcp6TlsTxToken.CompletionToken.Event) {
|
||||
gBS->CloseEvent(HttpInstance->Tcp6TlsTxToken.CompletionToken.Event);
|
||||
gBS->CloseEvent (HttpInstance->Tcp6TlsTxToken.CompletionToken.Event);
|
||||
HttpInstance->Tcp6TlsTxToken.CompletionToken.Event = NULL;
|
||||
}
|
||||
|
||||
@ -396,7 +397,7 @@ TlsConfigCertificate (
|
||||
NULL
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -429,60 +430,80 @@ TlsConfigCertificate (
|
||||
//
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
CertCount = 0;
|
||||
ItemDataSize = (UINT32) CACertSize;
|
||||
ItemDataSize = (UINT32)CACertSize;
|
||||
while (ItemDataSize > 0) {
|
||||
if (ItemDataSize < sizeof (EFI_SIGNATURE_LIST)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: truncated EFI_SIGNATURE_LIST header\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: truncated EFI_SIGNATURE_LIST header\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
goto FreeCACert;
|
||||
}
|
||||
|
||||
CertList = (EFI_SIGNATURE_LIST *) (CACert + (CACertSize - ItemDataSize));
|
||||
CertList = (EFI_SIGNATURE_LIST *)(CACert + (CACertSize - ItemDataSize));
|
||||
|
||||
if (CertList->SignatureListSize < sizeof (EFI_SIGNATURE_LIST)) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: SignatureListSize too small for EFI_SIGNATURE_LIST\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
goto FreeCACert;
|
||||
}
|
||||
|
||||
if (CertList->SignatureListSize > ItemDataSize) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: truncated EFI_SIGNATURE_LIST body\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: truncated EFI_SIGNATURE_LIST body\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
goto FreeCACert;
|
||||
}
|
||||
|
||||
if (!CompareGuid (&CertList->SignatureType, &gEfiCertX509Guid)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: only X509 certificates are supported\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: only X509 certificates are supported\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
Status = EFI_UNSUPPORTED;
|
||||
goto FreeCACert;
|
||||
}
|
||||
|
||||
if (CertList->SignatureHeaderSize != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: SignatureHeaderSize must be 0 for X509\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: SignatureHeaderSize must be 0 for X509\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
goto FreeCACert;
|
||||
}
|
||||
|
||||
if (CertList->SignatureSize < sizeof (EFI_SIGNATURE_DATA)) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
"%a: SignatureSize too small for EFI_SIGNATURE_DATA\n", __FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: SignatureSize too small for EFI_SIGNATURE_DATA\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
goto FreeCACert;
|
||||
}
|
||||
|
||||
CertArraySizeInBytes = (CertList->SignatureListSize -
|
||||
sizeof (EFI_SIGNATURE_LIST));
|
||||
if (CertArraySizeInBytes % CertList->SignatureSize != 0) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: EFI_SIGNATURE_DATA array not a multiple of SignatureSize\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
goto FreeCACert;
|
||||
}
|
||||
|
||||
CertCount += CertArraySizeInBytes / CertList->SignatureSize;
|
||||
ItemDataSize -= CertList->SignatureListSize;
|
||||
}
|
||||
|
||||
if (CertCount == 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: no X509 certificates provided\n", __FUNCTION__));
|
||||
goto FreeCACert;
|
||||
@ -491,10 +512,10 @@ TlsConfigCertificate (
|
||||
//
|
||||
// Enumerate all data and erasing the target item.
|
||||
//
|
||||
ItemDataSize = (UINT32) CACertSize;
|
||||
CertList = (EFI_SIGNATURE_LIST *) CACert;
|
||||
ItemDataSize = (UINT32)CACertSize;
|
||||
CertList = (EFI_SIGNATURE_LIST *)CACert;
|
||||
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;
|
||||
for (Index = 0; Index < CertCount; Index++) {
|
||||
//
|
||||
@ -510,11 +531,11 @@ TlsConfigCertificate (
|
||||
goto FreeCACert;
|
||||
}
|
||||
|
||||
Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) Cert + CertList->SignatureSize);
|
||||
Cert = (EFI_SIGNATURE_DATA *)((UINT8 *)Cert + CertList->SignatureSize);
|
||||
}
|
||||
|
||||
ItemDataSize -= CertList->SignatureListSize;
|
||||
CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);
|
||||
CertList = (EFI_SIGNATURE_LIST *)((UINT8 *)CertList + CertList->SignatureListSize);
|
||||
}
|
||||
|
||||
FreeCACert:
|
||||
@ -679,7 +700,7 @@ TlsConfigureSession (
|
||||
// Tls Cipher List
|
||||
//
|
||||
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));
|
||||
return Status;
|
||||
}
|
||||
@ -751,22 +772,22 @@ TlsCommonTransmit (
|
||||
}
|
||||
|
||||
if (!HttpInstance->LocalAddressIsIPv6) {
|
||||
((EFI_TCP4_TRANSMIT_DATA *) Data)->Push = TRUE;
|
||||
((EFI_TCP4_TRANSMIT_DATA *) Data)->Urgent = FALSE;
|
||||
((EFI_TCP4_TRANSMIT_DATA *) Data)->DataLength = Packet->TotalSize;
|
||||
((EFI_TCP4_TRANSMIT_DATA *)Data)->Push = TRUE;
|
||||
((EFI_TCP4_TRANSMIT_DATA *)Data)->Urgent = FALSE;
|
||||
((EFI_TCP4_TRANSMIT_DATA *)Data)->DataLength = Packet->TotalSize;
|
||||
|
||||
//
|
||||
// Build the fragment table.
|
||||
//
|
||||
((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentCount = Packet->BlockOpNum;
|
||||
((EFI_TCP4_TRANSMIT_DATA *)Data)->FragmentCount = Packet->BlockOpNum;
|
||||
|
||||
NetbufBuildExt (
|
||||
Packet,
|
||||
(NET_FRAGMENT *) &((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentTable[0],
|
||||
&((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentCount
|
||||
(NET_FRAGMENT *)&((EFI_TCP4_TRANSMIT_DATA *)Data)->FragmentTable[0],
|
||||
&((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;
|
||||
|
||||
@ -785,22 +806,22 @@ TlsCommonTransmit (
|
||||
HttpInstance->TlsIsTxDone = FALSE;
|
||||
Status = HttpInstance->Tcp4TlsTxToken.CompletionToken.Status;
|
||||
} else {
|
||||
((EFI_TCP6_TRANSMIT_DATA *) Data)->Push = TRUE;
|
||||
((EFI_TCP6_TRANSMIT_DATA *) Data)->Urgent = FALSE;
|
||||
((EFI_TCP6_TRANSMIT_DATA *) Data)->DataLength = Packet->TotalSize;
|
||||
((EFI_TCP6_TRANSMIT_DATA *)Data)->Push = TRUE;
|
||||
((EFI_TCP6_TRANSMIT_DATA *)Data)->Urgent = FALSE;
|
||||
((EFI_TCP6_TRANSMIT_DATA *)Data)->DataLength = Packet->TotalSize;
|
||||
|
||||
//
|
||||
// Build the fragment table.
|
||||
//
|
||||
((EFI_TCP6_TRANSMIT_DATA *) Data)->FragmentCount = Packet->BlockOpNum;
|
||||
((EFI_TCP6_TRANSMIT_DATA *)Data)->FragmentCount = Packet->BlockOpNum;
|
||||
|
||||
NetbufBuildExt (
|
||||
Packet,
|
||||
(NET_FRAGMENT *) &((EFI_TCP6_TRANSMIT_DATA *) Data)->FragmentTable[0],
|
||||
&((EFI_TCP6_TRANSMIT_DATA *) Data)->FragmentCount
|
||||
(NET_FRAGMENT *)&((EFI_TCP6_TRANSMIT_DATA *)Data)->FragmentTable[0],
|
||||
&((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;
|
||||
|
||||
@ -879,12 +900,14 @@ TlsCommonReceive (
|
||||
if (Tcp4RxData == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Tcp4RxData->FragmentCount = 1;
|
||||
} else {
|
||||
Tcp6RxData = HttpInstance->Tcp6TlsRxToken.Packet.RxData;
|
||||
if (Tcp6RxData == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Tcp6RxData->FragmentCount = 1;
|
||||
}
|
||||
|
||||
@ -903,6 +926,7 @@ TlsCommonReceive (
|
||||
Tcp6RxData->FragmentTable[0].FragmentBuffer = Fragment[CurrentFragment].Bulk;
|
||||
Status = HttpInstance->Tcp6->Receive (HttpInstance->Tcp6, &HttpInstance->Tcp6TlsRxToken);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -1041,23 +1065,24 @@ TlsReceiveOnePdu (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
RecordHeader = *(TLS_RECORD_HEADER *) Header;
|
||||
if ((RecordHeader.ContentType == TlsContentTypeHandshake ||
|
||||
RecordHeader.ContentType == TlsContentTypeAlert ||
|
||||
RecordHeader.ContentType == TlsContentTypeChangeCipherSpec ||
|
||||
RecordHeader.ContentType == TlsContentTypeApplicationData) &&
|
||||
RecordHeader = *(TLS_RECORD_HEADER *)Header;
|
||||
if (((RecordHeader.ContentType == TlsContentTypeHandshake) ||
|
||||
(RecordHeader.ContentType == TlsContentTypeAlert) ||
|
||||
(RecordHeader.ContentType == TlsContentTypeChangeCipherSpec) ||
|
||||
(RecordHeader.ContentType == TlsContentTypeApplicationData)) &&
|
||||
(RecordHeader.Version.Major == 0x03) && /// Major versions are same.
|
||||
(RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR ||
|
||||
RecordHeader.Version.Minor ==TLS11_PROTOCOL_VERSION_MINOR ||
|
||||
RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR)
|
||||
) {
|
||||
((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
|
||||
(RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
|
||||
(RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
|
||||
)
|
||||
{
|
||||
InsertTailList (NbufList, &PduHdr->List);
|
||||
} else {
|
||||
Status = EFI_PROTOCOL_ERROR;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Len = SwapBytes16(RecordHeader.Length);
|
||||
Len = SwapBytes16 (RecordHeader.Length);
|
||||
if (Len == 0) {
|
||||
//
|
||||
// No TLS payload.
|
||||
@ -1190,6 +1215,7 @@ TlsConnectSession (
|
||||
&BufferOutSize
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (BufferOut);
|
||||
return Status;
|
||||
@ -1198,8 +1224,8 @@ TlsConnectSession (
|
||||
//
|
||||
// Transmit ClientHello
|
||||
//
|
||||
PacketOut = NetbufAlloc ((UINT32) BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL);
|
||||
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
|
||||
if (DataOut == NULL) {
|
||||
FreePool (BufferOut);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -1215,8 +1241,9 @@ TlsConnectSession (
|
||||
return Status;
|
||||
}
|
||||
|
||||
while(HttpInstance->TlsSessionState != EfiTlsSessionDataTransferring && \
|
||||
((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout)))) {
|
||||
while (HttpInstance->TlsSessionState != EfiTlsSessionDataTransferring && \
|
||||
((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout))))
|
||||
{
|
||||
//
|
||||
// Receive one TLS record.
|
||||
//
|
||||
@ -1283,8 +1310,8 @@ TlsConnectSession (
|
||||
//
|
||||
// Transmit the response packet.
|
||||
//
|
||||
PacketOut = NetbufAlloc ((UINT32) BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL);
|
||||
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
|
||||
if (DataOut == NULL) {
|
||||
FreePool (BufferOut);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -1335,17 +1362,18 @@ TlsConnectSession (
|
||||
&GetSessionDataBufferSize
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool(GetSessionDataBuffer);
|
||||
FreePool (GetSessionDataBuffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT(GetSessionDataBufferSize == sizeof (EFI_TLS_SESSION_STATE));
|
||||
HttpInstance->TlsSessionState = *(EFI_TLS_SESSION_STATE *) GetSessionDataBuffer;
|
||||
ASSERT (GetSessionDataBufferSize == sizeof (EFI_TLS_SESSION_STATE));
|
||||
HttpInstance->TlsSessionState = *(EFI_TLS_SESSION_STATE *)GetSessionDataBuffer;
|
||||
|
||||
FreePool (GetSessionDataBuffer);
|
||||
|
||||
if(HttpInstance->TlsSessionState == EfiTlsSessionError) {
|
||||
if (HttpInstance->TlsSessionState == EfiTlsSessionError) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
}
|
||||
@ -1439,8 +1467,8 @@ TlsCloseSession (
|
||||
return Status;
|
||||
}
|
||||
|
||||
PacketOut = NetbufAlloc ((UINT32) BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL);
|
||||
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
|
||||
if (DataOut == NULL) {
|
||||
FreePool (BufferOut);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -1515,7 +1543,7 @@ TlsProcessMessage (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
FragmentTable->FragmentLength = (UINT32) MessageSize;
|
||||
FragmentTable->FragmentLength = (UINT32)MessageSize;
|
||||
FragmentTable->FragmentBuffer = Message;
|
||||
|
||||
//
|
||||
@ -1575,9 +1603,10 @@ TlsProcessMessage (
|
||||
ON_EXIT:
|
||||
|
||||
if (OriginalFragmentTable != NULL) {
|
||||
if( FragmentTable == OriginalFragmentTable) {
|
||||
if ( FragmentTable == OriginalFragmentTable) {
|
||||
FragmentTable = NULL;
|
||||
}
|
||||
|
||||
FreePool (OriginalFragmentTable);
|
||||
OriginalFragmentTable = NULL;
|
||||
}
|
||||
@ -1654,21 +1683,22 @@ HttpsReceive (
|
||||
return Status;
|
||||
}
|
||||
|
||||
NetbufCopy (Pdu, 0, (UINT32) BufferInSize, BufferIn);
|
||||
NetbufCopy (Pdu, 0, (UINT32)BufferInSize, BufferIn);
|
||||
|
||||
NetbufFree (Pdu);
|
||||
|
||||
//
|
||||
// Handle Receive data.
|
||||
//
|
||||
RecordHeader = *(TLS_RECORD_HEADER *) BufferIn;
|
||||
RecordHeader = *(TLS_RECORD_HEADER *)BufferIn;
|
||||
|
||||
if ((RecordHeader.ContentType == TlsContentTypeApplicationData) &&
|
||||
(RecordHeader.Version.Major == 0x03) &&
|
||||
(RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR ||
|
||||
RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR ||
|
||||
RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR)
|
||||
) {
|
||||
((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
|
||||
(RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
|
||||
(RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
|
||||
)
|
||||
{
|
||||
//
|
||||
// Decrypt Packet.
|
||||
//
|
||||
@ -1718,14 +1748,15 @@ HttpsReceive (
|
||||
&BufferOutSize
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool(BufferOut);
|
||||
FreePool (BufferOut);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (BufferOutSize != 0) {
|
||||
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
|
||||
if (DataOut == NULL) {
|
||||
FreePool (BufferOut);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -1738,7 +1769,7 @@ HttpsReceive (
|
||||
NetbufFree (PacketOut);
|
||||
}
|
||||
|
||||
FreePool(BufferOut);
|
||||
FreePool (BufferOut);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -1753,9 +1784,9 @@ HttpsReceive (
|
||||
//
|
||||
// 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);
|
||||
if (BufferIn == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -1768,13 +1799,13 @@ HttpsReceive (
|
||||
// Free the buffer in TempFragment.
|
||||
//
|
||||
FreePool (TempFragment.Bulk);
|
||||
|
||||
} else if ((RecordHeader.ContentType == TlsContentTypeAlert) &&
|
||||
(RecordHeader.Version.Major == 0x03) &&
|
||||
(RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR ||
|
||||
RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR ||
|
||||
RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR)
|
||||
) {
|
||||
((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
|
||||
(RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
|
||||
(RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
|
||||
)
|
||||
{
|
||||
BufferOutSize = DEF_BUF_LEN;
|
||||
BufferOut = AllocateZeroPool (BufferOutSize);
|
||||
if (BufferOut == NULL) {
|
||||
@ -1816,8 +1847,8 @@ HttpsReceive (
|
||||
}
|
||||
|
||||
if (BufferOutSize != 0) {
|
||||
PacketOut = NetbufAlloc ((UINT32) BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32) BufferOutSize, NET_BUF_TAIL);
|
||||
PacketOut = NetbufAlloc ((UINT32)BufferOutSize);
|
||||
DataOut = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
|
||||
if (DataOut == NULL) {
|
||||
FreePool (BufferOut);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -1863,17 +1894,18 @@ HttpsReceive (
|
||||
&GetSessionDataBufferSize
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (GetSessionDataBuffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT(GetSessionDataBufferSize == sizeof (EFI_TLS_SESSION_STATE));
|
||||
HttpInstance->TlsSessionState = *(EFI_TLS_SESSION_STATE *) GetSessionDataBuffer;
|
||||
ASSERT (GetSessionDataBufferSize == sizeof (EFI_TLS_SESSION_STATE));
|
||||
HttpInstance->TlsSessionState = *(EFI_TLS_SESSION_STATE *)GetSessionDataBuffer;
|
||||
|
||||
FreePool (GetSessionDataBuffer);
|
||||
|
||||
if(HttpInstance->TlsSessionState == EfiTlsSessionError) {
|
||||
if (HttpInstance->TlsSessionState == EfiTlsSessionError) {
|
||||
DEBUG ((DEBUG_ERROR, "TLS Session State Error!\n"));
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
@ -1883,7 +1915,7 @@ HttpsReceive (
|
||||
}
|
||||
|
||||
Fragment->Bulk = BufferIn;
|
||||
Fragment->Len = (UINT32) BufferInSize;
|
||||
Fragment->Len = (UINT32)BufferInSize;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -262,4 +262,3 @@ HttpsReceive (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "HttpUtilitiesDxe.h"
|
||||
|
||||
|
||||
/**
|
||||
Unloads an image.
|
||||
|
||||
@ -31,7 +30,6 @@ HttpUtilitiesDxeUnload (
|
||||
UINT32 Index;
|
||||
EFI_HTTP_UTILITIES_PROTOCOL *HttpUtilitiesProtocol;
|
||||
|
||||
|
||||
HandleBuffer = NULL;
|
||||
|
||||
//
|
||||
@ -55,7 +53,7 @@ HttpUtilitiesDxeUnload (
|
||||
Status = gBS->OpenProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiHttpUtilitiesProtocolGuid,
|
||||
(VOID **) &HttpUtilitiesProtocol,
|
||||
(VOID **)&HttpUtilitiesProtocol,
|
||||
ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
|
||||
@ -69,7 +67,8 @@ HttpUtilitiesDxeUnload (
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
HandleBuffer[Index],
|
||||
&gEfiHttpUtilitiesProtocolGuid, HttpUtilitiesProtocol,
|
||||
&gEfiHttpUtilitiesProtocolGuid,
|
||||
HttpUtilitiesProtocol,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -80,7 +79,6 @@ HttpUtilitiesDxeUnload (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -117,4 +115,3 @@ HttpUtilitiesDxeDriverEntryPoint (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@ HttpUtilitiesBuild (
|
||||
OUT VOID **NewMessage
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Parses HTTP header and produces an array of key/value pairs.
|
||||
|
||||
|
@ -14,7 +14,6 @@ EFI_HTTP_UTILITIES_PROTOCOL mHttpUtilitiesProtocol = {
|
||||
HttpUtilitiesParse
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Create HTTP header based on a combination of seed header, fields
|
||||
to delete, and fields to append.
|
||||
@ -106,8 +105,8 @@ HttpUtilitiesBuild (
|
||||
//
|
||||
// Handle DeleteList
|
||||
//
|
||||
if (SeedFieldCount != 0 && DeleteCount != 0) {
|
||||
TempHeaderFields = AllocateZeroPool (SeedFieldCount * sizeof(EFI_HTTP_HEADER));
|
||||
if ((SeedFieldCount != 0) && (DeleteCount != 0)) {
|
||||
TempHeaderFields = AllocateZeroPool (SeedFieldCount * sizeof (EFI_HTTP_HEADER));
|
||||
if (TempHeaderFields == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
@ -117,7 +116,7 @@ HttpUtilitiesBuild (
|
||||
//
|
||||
// Check whether each SeedHeaderFields member is in DeleteList
|
||||
//
|
||||
if (HttpIsValidHttpHeader( DeleteList, DeleteCount, SeedHeaderFields[Index].FieldName)) {
|
||||
if (HttpIsValidHttpHeader (DeleteList, DeleteCount, SeedHeaderFields[Index].FieldName)) {
|
||||
Status = HttpSetFieldNameAndValue (
|
||||
&TempHeaderFields[TempFieldCount],
|
||||
SeedHeaderFields[Index].FieldName,
|
||||
@ -126,6 +125,7 @@ HttpUtilitiesBuild (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
TempFieldCount++;
|
||||
}
|
||||
}
|
||||
@ -176,6 +176,7 @@ HttpUtilitiesBuild (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
NewFieldCount++;
|
||||
}
|
||||
}
|
||||
@ -189,16 +190,17 @@ HttpUtilitiesBuild (
|
||||
StrLength = AsciiStrLen (HttpHeader->FieldName);
|
||||
*NewMessageSize += StrLength;
|
||||
|
||||
StrLength = sizeof(": ") - 1;
|
||||
StrLength = sizeof (": ") - 1;
|
||||
*NewMessageSize += StrLength;
|
||||
|
||||
StrLength = AsciiStrLen (HttpHeader->FieldValue);
|
||||
*NewMessageSize += StrLength;
|
||||
|
||||
StrLength = sizeof("\r\n") - 1;
|
||||
StrLength = sizeof ("\r\n") - 1;
|
||||
*NewMessageSize += StrLength;
|
||||
}
|
||||
StrLength = sizeof("\r\n") - 1;
|
||||
|
||||
StrLength = sizeof ("\r\n") - 1;
|
||||
*NewMessageSize += StrLength;
|
||||
|
||||
*NewMessage = AllocateZeroPool (*NewMessageSize);
|
||||
@ -216,7 +218,7 @@ HttpUtilitiesBuild (
|
||||
CopyMem (NewMessagePtr, HttpHeader->FieldName, StrLength);
|
||||
NewMessagePtr += StrLength;
|
||||
|
||||
StrLength = sizeof(": ") - 1;
|
||||
StrLength = sizeof (": ") - 1;
|
||||
CopyMem (NewMessagePtr, ": ", StrLength);
|
||||
NewMessagePtr += StrLength;
|
||||
|
||||
@ -224,11 +226,12 @@ HttpUtilitiesBuild (
|
||||
CopyMem (NewMessagePtr, HttpHeader->FieldValue, StrLength);
|
||||
NewMessagePtr += StrLength;
|
||||
|
||||
StrLength = sizeof("\r\n") - 1;
|
||||
StrLength = sizeof ("\r\n") - 1;
|
||||
CopyMem (NewMessagePtr, "\r\n", StrLength);
|
||||
NewMessagePtr += StrLength;
|
||||
}
|
||||
StrLength = sizeof("\r\n") - 1;
|
||||
|
||||
StrLength = sizeof ("\r\n") - 1;
|
||||
CopyMem (NewMessagePtr, "\r\n", StrLength);
|
||||
NewMessagePtr += StrLength;
|
||||
|
||||
@ -239,21 +242,20 @@ HttpUtilitiesBuild (
|
||||
//
|
||||
ON_EXIT:
|
||||
if (SeedHeaderFields != NULL) {
|
||||
HttpFreeHeaderFields(SeedHeaderFields, SeedFieldCount);
|
||||
HttpFreeHeaderFields (SeedHeaderFields, SeedFieldCount);
|
||||
}
|
||||
|
||||
if (TempHeaderFields != NULL) {
|
||||
HttpFreeHeaderFields(TempHeaderFields, TempFieldCount);
|
||||
HttpFreeHeaderFields (TempHeaderFields, TempFieldCount);
|
||||
}
|
||||
|
||||
if (NewHeaderFields != NULL) {
|
||||
HttpFreeHeaderFields(NewHeaderFields, NewFieldCount);
|
||||
HttpFreeHeaderFields (NewHeaderFields, NewFieldCount);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parses HTTP header and produces an array of key/value pairs.
|
||||
|
||||
@ -302,7 +304,7 @@ HttpUtilitiesParse (
|
||||
FieldValue = NULL;
|
||||
Index = 0;
|
||||
|
||||
if (This == NULL || HttpMessage == NULL || HeaderFields == NULL || FieldCount == NULL) {
|
||||
if ((This == NULL) || (HttpMessage == NULL) || (HeaderFields == NULL) || (FieldCount == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -328,7 +330,7 @@ HttpUtilitiesParse (
|
||||
FieldValue = NULL;
|
||||
NextToken = HttpGetFieldNameAndValue (Token, &FieldName, &FieldValue);
|
||||
Token = NextToken;
|
||||
if (FieldName == NULL || FieldValue == NULL) {
|
||||
if ((FieldName == NULL) || (FieldValue == NULL)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -343,7 +345,7 @@ HttpUtilitiesParse (
|
||||
//
|
||||
// Allocate buffer for header
|
||||
//
|
||||
*HeaderFields = AllocateZeroPool ((*FieldCount) * sizeof(EFI_HTTP_HEADER));
|
||||
*HeaderFields = AllocateZeroPool ((*FieldCount) * sizeof (EFI_HTTP_HEADER));
|
||||
if (*HeaderFields == NULL) {
|
||||
*FieldCount = 0;
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -361,7 +363,7 @@ HttpUtilitiesParse (
|
||||
FieldValue = NULL;
|
||||
NextToken = HttpGetFieldNameAndValue (Token, &FieldName, &FieldValue);
|
||||
Token = NextToken;
|
||||
if (FieldName == NULL || FieldValue == NULL) {
|
||||
if ((FieldName == NULL) || (FieldValue == NULL)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName =
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IScsiComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IScsiComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)IScsiComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)IScsiComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
@ -91,7 +91,7 @@ IScsiComponentNameGetDriverName (
|
||||
This->SupportedLanguages,
|
||||
mIScsiDriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN) (This == &gIScsiComponentName)
|
||||
(BOOLEAN)(This == &gIScsiComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ IScsiComponentNameGetControllerName (
|
||||
Status = gBS->OpenProtocol (
|
||||
IScsiController,
|
||||
IScsiPrivateGuid,
|
||||
(VOID **) &IScsiIdentifier,
|
||||
(VOID **)&IScsiIdentifier,
|
||||
NULL,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -277,8 +277,8 @@ IScsiComponentNameGetControllerName (
|
||||
return Status;
|
||||
}
|
||||
|
||||
if(ChildHandle != NULL) {
|
||||
if(!Ipv6Flag) {
|
||||
if (ChildHandle != NULL) {
|
||||
if (!Ipv6Flag) {
|
||||
//
|
||||
// Make sure this driver produced ChildHandle
|
||||
//
|
||||
|
@ -23,7 +23,7 @@ STATIC CONST CHAP_HASH mChapHash[] = {
|
||||
Sha256Update,
|
||||
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
|
||||
// least preferred choice of the initiator).
|
||||
@ -36,7 +36,7 @@ STATIC CONST CHAP_HASH mChapHash[] = {
|
||||
Md5Update,
|
||||
Md5Final
|
||||
},
|
||||
#endif // ENABLE_MD5_DEPRECATED_INTERFACES
|
||||
#endif // ENABLE_MD5_DEPRECATED_INTERFACES
|
||||
};
|
||||
|
||||
//
|
||||
@ -54,7 +54,7 @@ STATIC CHAR8 mChapHashListString[
|
||||
// AsciiSPrint()
|
||||
// truncation check
|
||||
1 // terminating NUL
|
||||
];
|
||||
];
|
||||
|
||||
/**
|
||||
Initiator calculates its own expected hash value.
|
||||
@ -117,7 +117,7 @@ IScsiCHAPCalculateResponse (
|
||||
//
|
||||
// Hash Identifier - Only calculate 1 byte data (RFC1994)
|
||||
//
|
||||
IdByte[0] = (CHAR8) ChapIdentifier;
|
||||
IdByte[0] = (CHAR8)ChapIdentifier;
|
||||
if (!Hash->Update (Ctx, IdByte, 1)) {
|
||||
goto Exit;
|
||||
}
|
||||
@ -172,7 +172,7 @@ IScsiCHAPAuthTarget (
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
SecretSize = (UINT32) AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
|
||||
SecretSize = (UINT32)AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
|
||||
|
||||
ASSERT (AuthData->Hash != NULL);
|
||||
|
||||
@ -198,7 +198,6 @@ IScsiCHAPAuthTarget (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function checks the received iSCSI Login Response during the security
|
||||
negotiation stage.
|
||||
@ -243,6 +242,7 @@ IScsiCHAPOnRspReceived (
|
||||
if (Data == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len);
|
||||
KeyValueList = IScsiBuildKeyValueList ((CHAR8 *)Data, Len);
|
||||
if (KeyValueList == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
@ -277,7 +277,7 @@ IScsiCHAPOnRspReceived (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Session->TargetPortalGroupTag = (UINT16) Result;
|
||||
Session->TargetPortalGroupTag = (UINT16)Result;
|
||||
|
||||
Value = IScsiGetValueByKeyFromList (
|
||||
KeyValueList,
|
||||
@ -286,6 +286,7 @@ IScsiCHAPOnRspReceived (
|
||||
if (Value == NULL) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Initiator mandates CHAP authentication but target replies without
|
||||
// "CHAP", or initiator suggets "None" but target replies with some kind of
|
||||
@ -328,12 +329,14 @@ IScsiCHAPOnRspReceived (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (HashIndex == ARRAY_SIZE (mChapHash)) {
|
||||
//
|
||||
// Unsupported algorithm is chosen by target.
|
||||
//
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Remember the target's chosen hash algorithm.
|
||||
//
|
||||
@ -355,6 +358,7 @@ IScsiCHAPOnRspReceived (
|
||||
if (Challenge == NULL) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Process the CHAP identifier and CHAP Challenge from Target.
|
||||
// Calculate Response value.
|
||||
@ -364,10 +368,10 @@ IScsiCHAPOnRspReceived (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
AuthData->InIdentifier = (UINT32) Result;
|
||||
AuthData->InChallengeLength = (UINT32) sizeof (AuthData->InChallenge);
|
||||
AuthData->InIdentifier = (UINT32)Result;
|
||||
AuthData->InChallengeLength = (UINT32)sizeof (AuthData->InChallenge);
|
||||
Status = IScsiHexToBin (
|
||||
(UINT8 *) AuthData->InChallenge,
|
||||
(UINT8 *)AuthData->InChallenge,
|
||||
&AuthData->InChallengeLength,
|
||||
Challenge
|
||||
);
|
||||
@ -375,10 +379,11 @@ IScsiCHAPOnRspReceived (
|
||||
Status = EFI_PROTOCOL_ERROR;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Status = IScsiCHAPCalculateResponse (
|
||||
AuthData->InIdentifier,
|
||||
AuthData->AuthConfig->CHAPSecret,
|
||||
(UINT32) AsciiStrLen (AuthData->AuthConfig->CHAPSecret),
|
||||
(UINT32)AsciiStrLen (AuthData->AuthConfig->CHAPSecret),
|
||||
AuthData->InChallenge,
|
||||
AuthData->InChallengeLength,
|
||||
AuthData->Hash,
|
||||
@ -420,7 +425,7 @@ IScsiCHAPOnRspReceived (
|
||||
ASSERT (AuthData->Hash != NULL);
|
||||
RspLen = AuthData->Hash->DigestSize;
|
||||
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;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -446,7 +451,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function fills the CHAP authentication information into the login PDU
|
||||
during the security negotiation stage in the iSCSI connection login.
|
||||
@ -483,10 +487,11 @@ IScsiCHAPToSendReq (
|
||||
|
||||
Session = Conn->Session;
|
||||
AuthData = &Session->AuthData.CHAP;
|
||||
LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0);
|
||||
LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufGetByte (Pdu, 0, 0);
|
||||
if (LoginReq == NULL) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
|
||||
@ -552,14 +557,14 @@ IScsiCHAPToSendReq (
|
||||
IScsiAddKeyValuePair (
|
||||
Pdu,
|
||||
ISCSI_KEY_CHAP_NAME,
|
||||
(CHAR8 *) &AuthData->AuthConfig->CHAPName
|
||||
(CHAR8 *)&AuthData->AuthConfig->CHAPName
|
||||
);
|
||||
//
|
||||
// CHAP_R=<R>
|
||||
//
|
||||
ASSERT (AuthData->Hash != NULL);
|
||||
BinToHexStatus = IScsiBinToHex (
|
||||
(UINT8 *) AuthData->CHAPResponse,
|
||||
(UINT8 *)AuthData->CHAPResponse,
|
||||
AuthData->Hash->DigestSize,
|
||||
Response,
|
||||
&RspLen
|
||||
@ -571,18 +576,18 @@ IScsiCHAPToSendReq (
|
||||
//
|
||||
// CHAP_I=<I>
|
||||
//
|
||||
IScsiGenRandom ((UINT8 *) &AuthData->OutIdentifier, 1);
|
||||
IScsiGenRandom ((UINT8 *)&AuthData->OutIdentifier, 1);
|
||||
AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier);
|
||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr);
|
||||
//
|
||||
// CHAP_C=<C>
|
||||
//
|
||||
IScsiGenRandom (
|
||||
(UINT8 *) AuthData->OutChallenge,
|
||||
(UINT8 *)AuthData->OutChallenge,
|
||||
AuthData->Hash->DigestSize
|
||||
);
|
||||
BinToHexStatus = IScsiBinToHex (
|
||||
(UINT8 *) AuthData->OutChallenge,
|
||||
(UINT8 *)AuthData->OutChallenge,
|
||||
AuthData->Hash->DigestSize,
|
||||
Challenge,
|
||||
&ChallengeLen
|
||||
@ -592,6 +597,7 @@ IScsiCHAPToSendReq (
|
||||
|
||||
Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the stage transition flag.
|
||||
//
|
||||
|
@ -35,7 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define ISCSI_CHAP_STEP_THREE 3
|
||||
#define ISCSI_CHAP_STEP_FOUR 4
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
|
||||
@ -53,19 +52,19 @@ typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
|
||||
//
|
||||
typedef
|
||||
UINTN
|
||||
(EFIAPI *CHAP_HASH_GET_CONTEXT_SIZE) (
|
||||
(EFIAPI *CHAP_HASH_GET_CONTEXT_SIZE)(
|
||||
VOID
|
||||
);
|
||||
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *CHAP_HASH_INIT) (
|
||||
(EFIAPI *CHAP_HASH_INIT)(
|
||||
OUT VOID *Context
|
||||
);
|
||||
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *CHAP_HASH_UPDATE) (
|
||||
(EFIAPI *CHAP_HASH_UPDATE)(
|
||||
IN OUT VOID *Context,
|
||||
IN CONST VOID *Data,
|
||||
IN UINTN DataSize
|
||||
@ -73,7 +72,7 @@ BOOLEAN
|
||||
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *CHAP_HASH_FINAL) (
|
||||
(EFIAPI *CHAP_HASH_FINAL)(
|
||||
IN OUT VOID *Context,
|
||||
OUT UINT8 *HashValue
|
||||
);
|
||||
@ -133,6 +132,7 @@ EFI_STATUS
|
||||
IScsiCHAPOnRspReceived (
|
||||
IN ISCSI_CONNECTION *Conn
|
||||
);
|
||||
|
||||
/**
|
||||
This function fills the CHAP authentication information into the login PDU
|
||||
during the security negotiation stage in the iSCSI connection login.
|
||||
@ -164,4 +164,5 @@ VOID
|
||||
IScsiCHAPInitHashList (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,6 @@ extern UINT8 IScsiConfigVfrBin[];
|
||||
extern UINT8 IScsiDxeStrings[];
|
||||
extern ISCSI_FORM_CALLBACK_INFO *mCallbackInfo;
|
||||
|
||||
|
||||
#define VAR_OFFSET(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_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIReverseChapSecret)
|
||||
|
||||
|
||||
#define ISCSI_INITATOR_NAME_VAR_NAME L"I_NAME"
|
||||
|
||||
#define ISCSI_CONFIG_VAR_ATTR (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE)
|
||||
|
@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "IScsiImpl.h"
|
||||
|
||||
|
||||
/**
|
||||
Extract the Root Path option and get the required target information.
|
||||
|
||||
@ -46,18 +45,19 @@ IScsiDhcpExtractRootPath (
|
||||
//
|
||||
// "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)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip the iSCSI RootPath ID "iscsi:".
|
||||
//
|
||||
RootPath += IScsiRootPathIdLen;
|
||||
Length = (UINT8) (Length - IScsiRootPathIdLen);
|
||||
Length = (UINT8)(Length - IScsiRootPathIdLen);
|
||||
|
||||
TmpStr = (CHAR8 *) AllocatePool (Length + 1);
|
||||
TmpStr = (CHAR8 *)AllocatePool (Length + 1);
|
||||
if (TmpStr == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -88,7 +88,7 @@ IScsiDhcpExtractRootPath (
|
||||
}
|
||||
|
||||
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) ||
|
||||
(Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||
|
||||
(Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
|
||||
) {
|
||||
|
||||
)
|
||||
{
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the IP address of the target.
|
||||
//
|
||||
@ -125,11 +126,12 @@ IScsiDhcpExtractRootPath (
|
||||
if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
|
||||
ConfigNvData->TargetUrl[Field->Len + 1] = '\0';
|
||||
} else {
|
||||
ConfigNvData->DnsMode = FALSE;
|
||||
ZeroMem(ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
|
||||
ZeroMem (ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
|
||||
Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);
|
||||
CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));
|
||||
|
||||
@ -137,6 +139,7 @@ IScsiDhcpExtractRootPath (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check the protocol type.
|
||||
//
|
||||
@ -145,15 +148,17 @@ IScsiDhcpExtractRootPath (
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the port of the iSCSI target.
|
||||
//
|
||||
Field = &Fields[RP_FIELD_IDX_PORT];
|
||||
if (Field->Str != NULL) {
|
||||
ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str);
|
||||
ConfigNvData->TargetPort = (UINT16)AsciiStrDecimalToUintn (Field->Str);
|
||||
} else {
|
||||
ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the LUN.
|
||||
//
|
||||
@ -166,6 +171,7 @@ IScsiDhcpExtractRootPath (
|
||||
} else {
|
||||
ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));
|
||||
}
|
||||
|
||||
//
|
||||
// Get the target iSCSI Name.
|
||||
//
|
||||
@ -175,6 +181,7 @@ IScsiDhcpExtractRootPath (
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate the iSCSI name.
|
||||
//
|
||||
@ -253,9 +260,9 @@ IScsiDhcpSelectOffer (
|
||||
}
|
||||
|
||||
Status = IScsiDhcpExtractRootPath (
|
||||
(CHAR8 *) &OptionList[Index]->Data[0],
|
||||
(CHAR8 *)&OptionList[Index]->Data[0],
|
||||
OptionList[Index]->Length,
|
||||
(ISCSI_ATTEMPT_CONFIG_NVDATA *) Context
|
||||
(ISCSI_ATTEMPT_CONFIG_NVDATA *)Context
|
||||
);
|
||||
|
||||
break;
|
||||
@ -335,11 +342,11 @@ IScsiParseDhcpAck (
|
||||
// Get DNS server addresses and DHCP server address from this offer.
|
||||
//
|
||||
if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) {
|
||||
|
||||
if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Primary DNS server address.
|
||||
//
|
||||
@ -397,7 +404,7 @@ IScsiSetIp4Policy (
|
||||
|
||||
if (Policy != Ip4Config2PolicyStatic) {
|
||||
Policy = Ip4Config2PolicyStatic;
|
||||
Status= Ip4Config2->SetData (
|
||||
Status = Ip4Config2->SetData (
|
||||
Ip4Config2,
|
||||
Ip4Config2DataTypePolicy,
|
||||
sizeof (EFI_IP4_CONFIG2_POLICY),
|
||||
@ -450,7 +457,7 @@ IScsiDoDhcp (
|
||||
//
|
||||
MediaStatus = EFI_SUCCESS;
|
||||
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");
|
||||
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.
|
||||
// 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)) {
|
||||
Status = IScsiSetIp4Policy (Ip4Config2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -486,7 +493,7 @@ IScsiDoDhcp (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dhcp4Handle,
|
||||
&gEfiDhcp4ProtocolGuid,
|
||||
(VOID **) &Dhcp4,
|
||||
(VOID **)&Dhcp4,
|
||||
Image,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -507,7 +514,7 @@ IScsiDoDhcp (
|
||||
// Ask the server to reply with Netmask, Router, DNS, and RootPath options.
|
||||
//
|
||||
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[1] = DHCP4_TAG_ROUTER;
|
||||
ParaList->Data[2] = DHCP4_TAG_DNS_SERVER;
|
||||
@ -534,6 +541,7 @@ IScsiDoDhcp (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Parse the ACK to get required information.
|
||||
//
|
||||
|
@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "IScsiImpl.h"
|
||||
|
||||
|
||||
/**
|
||||
Extract the Root Path option and get the required target information from
|
||||
Boot File Uniform Resource Locator (URL) Option.
|
||||
@ -48,19 +47,21 @@ IScsiDhcp6ExtractRootPath (
|
||||
//
|
||||
// "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>
|
||||
//
|
||||
IScsiRootPathIdLen = (UINT16) AsciiStrLen (ISCSI_ROOT_PATH_ID);
|
||||
IScsiRootPathIdLen = (UINT16)AsciiStrLen (ISCSI_ROOT_PATH_ID);
|
||||
|
||||
if ((Length <= IScsiRootPathIdLen) ||
|
||||
(CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) {
|
||||
(CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0))
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip the iSCSI RootPath ID "iscsi:".
|
||||
//
|
||||
RootPath = RootPath + IScsiRootPathIdLen;
|
||||
Length = (UINT16) (Length - IScsiRootPathIdLen);
|
||||
Length = (UINT16)(Length - IScsiRootPathIdLen);
|
||||
|
||||
TmpStr = (CHAR8 *) AllocatePool (Length + 1);
|
||||
TmpStr = (CHAR8 *)AllocatePool (Length + 1);
|
||||
if (TmpStr == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -87,7 +88,7 @@ IScsiDhcp6ExtractRootPath (
|
||||
Fields[RP_FIELD_IDX_SERVERNAME].Str = &TmpStr[Index];
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
@ -100,6 +101,7 @@ IScsiDhcp6ExtractRootPath (
|
||||
while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) {
|
||||
Index++;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip ':'.
|
||||
//
|
||||
@ -107,13 +109,12 @@ IScsiDhcp6ExtractRootPath (
|
||||
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.
|
||||
//
|
||||
for (FieldIndex = 1; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {
|
||||
|
||||
if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) {
|
||||
Fields[FieldIndex].Str = &TmpStr[Index];
|
||||
}
|
||||
@ -129,7 +130,7 @@ IScsiDhcp6ExtractRootPath (
|
||||
}
|
||||
|
||||
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) ||
|
||||
(Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||
|
||||
(Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
|
||||
) {
|
||||
|
||||
)
|
||||
{
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the IP address of the target.
|
||||
//
|
||||
@ -164,10 +166,11 @@ IScsiDhcp6ExtractRootPath (
|
||||
if ((Field->Len + 2) > sizeof (ConfigNvData->TargetUrl)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
|
||||
ConfigNvData->TargetUrl[Field->Len + 1] = '\0';
|
||||
} else {
|
||||
ZeroMem(&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
|
||||
ZeroMem (&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
|
||||
Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);
|
||||
CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));
|
||||
|
||||
@ -184,15 +187,17 @@ IScsiDhcp6ExtractRootPath (
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the port of the iSCSI target.
|
||||
//
|
||||
Field = &Fields[RP_FIELD_IDX_PORT];
|
||||
if (Field->Str != NULL) {
|
||||
ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str);
|
||||
ConfigNvData->TargetPort = (UINT16)AsciiStrDecimalToUintn (Field->Str);
|
||||
} else {
|
||||
ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the LUN.
|
||||
//
|
||||
@ -205,6 +210,7 @@ IScsiDhcp6ExtractRootPath (
|
||||
} else {
|
||||
ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));
|
||||
}
|
||||
|
||||
//
|
||||
// Get the target iSCSI Name.
|
||||
//
|
||||
@ -214,6 +220,7 @@ IScsiDhcp6ExtractRootPath (
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate the iSCSI name.
|
||||
//
|
||||
@ -290,7 +297,7 @@ IScsiDhcp6ParseReply (
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
ConfigData = (ISCSI_ATTEMPT_CONFIG_NVDATA *) Context;
|
||||
ConfigData = (ISCSI_ATTEMPT_CONFIG_NVDATA *)Context;
|
||||
|
||||
for (Index = 0; Index < OptionCount; Index++) {
|
||||
OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode);
|
||||
@ -300,11 +307,11 @@ IScsiDhcp6ParseReply (
|
||||
// Get DNS server addresses from this reply packet.
|
||||
//
|
||||
if (OptionList[Index]->OpCode == DHCP6_OPT_DNS_SERVERS) {
|
||||
|
||||
if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Primary DNS server address.
|
||||
//
|
||||
@ -316,7 +323,6 @@ IScsiDhcp6ParseReply (
|
||||
//
|
||||
CopyMem (&ConfigData->SecondaryDns, &OptionList[Index]->Data[16], sizeof (EFI_IPv6_ADDRESS));
|
||||
}
|
||||
|
||||
} 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.
|
||||
@ -330,6 +336,7 @@ IScsiDhcp6ParseReply (
|
||||
Status = EFI_UNSUPPORTED;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
//
|
||||
Status = IScsiDhcp6ExtractRootPath (
|
||||
(CHAR8 *) BootFileOpt->Data,
|
||||
(CHAR8 *)BootFileOpt->Data,
|
||||
BootFileOpt->OpLen,
|
||||
ConfigData
|
||||
);
|
||||
@ -363,7 +370,6 @@ Exit:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse the DHCP ACK to get the address configuration and DNS information.
|
||||
|
||||
@ -435,7 +441,7 @@ IScsiDoDhcp6 (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dhcp6Handle,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
(VOID **) &Dhcp6,
|
||||
(VOID **)&Dhcp6,
|
||||
Image,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -493,7 +499,6 @@ IScsiDoDhcp6 (
|
||||
}
|
||||
|
||||
do {
|
||||
|
||||
TimerStatus = gBS->CheckEvent (Timer);
|
||||
|
||||
if (!EFI_ERROR (TimerStatus)) {
|
||||
@ -509,9 +514,7 @@ IScsiDoDhcp6 (
|
||||
ConfigData
|
||||
);
|
||||
}
|
||||
|
||||
} while (TimerStatus == EFI_NOT_READY);
|
||||
|
||||
}
|
||||
|
||||
ON_EXIT:
|
||||
@ -542,4 +545,3 @@ ON_EXIT:
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define ISCSI_ROOT_PATH_ADDR_START_DELIMITER '['
|
||||
#define ISCSI_ROOT_PATH_ADDR_END_DELIMITER ']'
|
||||
|
||||
|
||||
/**
|
||||
Extract the Root Path option and get the required target information from
|
||||
Boot File Uniform Resource Locator (URL) Option.
|
||||
|
@ -22,7 +22,7 @@ IScsiCommonNotify (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
*((BOOLEAN *) Context) = TRUE;
|
||||
*((BOOLEAN *)Context) = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ IScsiDns4 (
|
||||
//
|
||||
// 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)) {
|
||||
//
|
||||
// Get the required size.
|
||||
@ -89,7 +89,6 @@ IScsiDns4 (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Create a DNS child instance and get the protocol.
|
||||
//
|
||||
@ -106,7 +105,7 @@ IScsiDns4 (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dns4Handle,
|
||||
&gEfiDns4ProtocolGuid,
|
||||
(VOID **) &Dns4,
|
||||
(VOID **)&Dns4,
|
||||
Image,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -154,7 +153,7 @@ IScsiDns4 (
|
||||
Token.Status = EFI_NOT_READY;
|
||||
IsDone = FALSE;
|
||||
|
||||
HostName = (CHAR16 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
|
||||
HostName = (CHAR16 *)AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
|
||||
if (HostName == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -183,10 +182,12 @@ IScsiDns4 (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
|
||||
|
||||
if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// We just return the first IP address from DNS protocol.
|
||||
//
|
||||
@ -199,10 +200,12 @@ Exit:
|
||||
if (Token.Event != NULL) {
|
||||
gBS->CloseEvent (Token.Event);
|
||||
}
|
||||
|
||||
if (Token.RspData.H2AData != NULL) {
|
||||
if (Token.RspData.H2AData->IpList != NULL) {
|
||||
FreePool (Token.RspData.H2AData->IpList);
|
||||
}
|
||||
|
||||
FreePool (Token.RspData.H2AData);
|
||||
}
|
||||
|
||||
@ -270,7 +273,7 @@ IScsiDns6 (
|
||||
//
|
||||
// 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)) {
|
||||
//
|
||||
// Get the required size.
|
||||
@ -309,7 +312,7 @@ IScsiDns6 (
|
||||
Status = gBS->OpenProtocol (
|
||||
Dns6Handle,
|
||||
&gEfiDns6ProtocolGuid,
|
||||
(VOID **) &Dns6,
|
||||
(VOID **)&Dns6,
|
||||
Image,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -353,7 +356,7 @@ IScsiDns6 (
|
||||
//
|
||||
// Start asynchronous name resolution.
|
||||
//
|
||||
HostName = (CHAR16 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
|
||||
HostName = (CHAR16 *)AllocateZeroPool (ISCSI_NAME_MAX_SIZE);
|
||||
if (HostName == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -381,10 +384,12 @@ IScsiDns6 (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
|
||||
|
||||
if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// We just return the first IPv6 address from DNS protocol.
|
||||
//
|
||||
@ -397,10 +402,12 @@ Exit:
|
||||
if (Token.Event != NULL) {
|
||||
gBS->CloseEvent (Token.Event);
|
||||
}
|
||||
|
||||
if (Token.RspData.H2AData != NULL) {
|
||||
if (Token.RspData.H2AData->IpList != NULL) {
|
||||
FreePool (Token.RspData.H2AData->IpList);
|
||||
}
|
||||
|
||||
FreePool (Token.RspData.H2AData);
|
||||
}
|
||||
|
||||
@ -426,4 +433,3 @@ Exit:
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ IScsiCheckAip (
|
||||
&AipHandleCount,
|
||||
&AipHandleBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status) || AipHandleCount == 0) {
|
||||
if (EFI_ERROR (Status) || (AipHandleCount == 0)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ IScsiCheckAip (
|
||||
Status = gBS->HandleProtocol (
|
||||
AipHandleBuffer[AipIndex],
|
||||
&gEfiAdapterInformationProtocolGuid,
|
||||
(VOID *) &Aip
|
||||
(VOID *)&Aip
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
ASSERT (Aip != NULL);
|
||||
@ -132,18 +132,19 @@ IScsiCheckAip (
|
||||
Status = gBS->HandleProtocol (
|
||||
AipHandleBuffer[AipIndex],
|
||||
&gEfiExtScsiPassThruProtocolGuid,
|
||||
(VOID *) &ExtScsiPassThru
|
||||
(VOID *)&ExtScsiPassThru
|
||||
);
|
||||
if (EFI_ERROR (Status) || ExtScsiPassThru == NULL) {
|
||||
if (EFI_ERROR (Status) || (ExtScsiPassThru == NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InfoTypesBuffer = NULL;
|
||||
InfoTypeBufferCount = 0;
|
||||
Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
|
||||
if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
|
||||
if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether the AIP instance has Network boot information block.
|
||||
//
|
||||
@ -166,32 +167,34 @@ IScsiCheckAip (
|
||||
InfoBlock = NULL;
|
||||
InfoBlockSize = 0;
|
||||
Status = Aip->GetInformation (Aip, &gEfiAdapterInfoNetworkBootGuid, &InfoBlock, &InfoBlockSize);
|
||||
if (EFI_ERROR (Status) || InfoBlock == NULL) {
|
||||
if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether the network boot policy matches.
|
||||
//
|
||||
NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *) InfoBlock;
|
||||
NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *)InfoBlock;
|
||||
NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy);
|
||||
|
||||
if (NetworkBootPolicy == STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP) {
|
||||
Status = EFI_SUCCESS;
|
||||
goto Exit;
|
||||
}
|
||||
if (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0 &&
|
||||
|
||||
if ((((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0) &&
|
||||
!NetworkBoot->iScsiIpv4BootCapablity) ||
|
||||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0 &&
|
||||
(((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0) &&
|
||||
!NetworkBoot->iScsiIpv6BootCapablity) ||
|
||||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0 &&
|
||||
(((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0) &&
|
||||
!NetworkBoot->OffloadCapability) ||
|
||||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0 &&
|
||||
(((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0) &&
|
||||
!NetworkBoot->iScsiMpioCapability) ||
|
||||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0 &&
|
||||
(((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0) &&
|
||||
!NetworkBoot->iScsiIpv4Boot) ||
|
||||
((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0 &&
|
||||
!NetworkBoot->iScsiIpv6Boot)) {
|
||||
(((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0) &&
|
||||
!NetworkBoot->iScsiIpv6Boot))
|
||||
{
|
||||
FreePool (InfoBlock);
|
||||
continue;
|
||||
}
|
||||
@ -206,9 +209,11 @@ Exit:
|
||||
if (InfoBlock != NULL) {
|
||||
FreePool (InfoBlock);
|
||||
}
|
||||
|
||||
if (AipHandleBuffer != NULL) {
|
||||
FreePool (AipHandleBuffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -257,7 +262,6 @@ IScsiSupported (
|
||||
TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
|
||||
DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
|
||||
DnsServiceBindingGuid = &gEfiDns4ServiceBindingProtocolGuid;
|
||||
|
||||
} else {
|
||||
IScsiServiceBindingGuid = &gIScsiV6PrivateGuid;
|
||||
TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
||||
@ -325,7 +329,6 @@ IScsiSupported (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Start to manage the controller. This is the worker function for
|
||||
IScsiIp4(6)DriverBindingStart.
|
||||
@ -558,7 +561,7 @@ IScsiStart (
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath
|
||||
(VOID **)&DevicePath
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
@ -572,7 +575,7 @@ IScsiStart (
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiExtScsiPassThruProtocolGuid,
|
||||
(VOID **) &ExistIScsiExtScsiPassThru
|
||||
(VOID **)&ExistIScsiExtScsiPassThru
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
break;
|
||||
@ -622,9 +625,10 @@ IScsiStart (
|
||||
// Don't process the attempt that does not associate with the current NIC or
|
||||
// this attempt is disabled or established.
|
||||
//
|
||||
if (AttemptConfigData->NicIndex != mPrivate->CurrentNic ||
|
||||
AttemptConfigData->SessionConfigData.Enabled == ISCSI_DISABLED ||
|
||||
AttemptConfigData->ValidPath) {
|
||||
if ((AttemptConfigData->NicIndex != mPrivate->CurrentNic) ||
|
||||
(AttemptConfigData->SessionConfigData.Enabled == ISCSI_DISABLED) ||
|
||||
AttemptConfigData->ValidPath)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -633,9 +637,10 @@ IScsiStart (
|
||||
// In default single path mode, don't process attempts configured for multipath.
|
||||
//
|
||||
if ((mPrivate->EnableMpio &&
|
||||
AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO) ||
|
||||
(AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO)) ||
|
||||
(!mPrivate->EnableMpio &&
|
||||
AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED)) {
|
||||
(AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -643,18 +648,21 @@ IScsiStart (
|
||||
// Don't process the attempt that fails to get the init/target information from DHCP.
|
||||
//
|
||||
if (AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp &&
|
||||
!AttemptConfigData->DhcpSuccess) {
|
||||
if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
|
||||
!AttemptConfigData->DhcpSuccess)
|
||||
{
|
||||
if (!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount > 0)) {
|
||||
mPrivate->ValidSinglePathCount--;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Don't process the autoconfigure path if it is already established.
|
||||
//
|
||||
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
|
||||
AttemptConfigData->AutoConfigureSuccess) {
|
||||
if ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
|
||||
AttemptConfigData->AutoConfigureSuccess)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -665,16 +673,20 @@ IScsiStart (
|
||||
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) {
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -682,7 +694,7 @@ IScsiStart (
|
||||
//
|
||||
// Fill in the Session and init it.
|
||||
//
|
||||
Session = (ISCSI_SESSION *) AllocateZeroPool (sizeof (ISCSI_SESSION));
|
||||
Session = (ISCSI_SESSION *)AllocateZeroPool (sizeof (ISCSI_SESSION));
|
||||
if (Session == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
@ -694,9 +706,9 @@ IScsiStart (
|
||||
|
||||
UnicodeSPrint (
|
||||
mPrivate->PortString,
|
||||
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
|
||||
(UINTN)ISCSI_NAME_IFR_MAX_SIZE,
|
||||
L"Attempt %d",
|
||||
(UINTN) AttemptConfigData->AttemptConfigIndex
|
||||
(UINTN)AttemptConfigData->AttemptConfigIndex
|
||||
);
|
||||
|
||||
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 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--;
|
||||
}
|
||||
|
||||
FreePool (Session);
|
||||
|
||||
} else {
|
||||
AttemptConfigData->ValidPath = TRUE;
|
||||
|
||||
@ -756,7 +767,7 @@ IScsiStart (
|
||||
// TODO: record KRB5 attempt information in the iSCSI device path.
|
||||
//
|
||||
if (Session->AuthType == ISCSI_AUTH_TYPE_KRB) {
|
||||
if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
|
||||
if (!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount > 0)) {
|
||||
mPrivate->ValidSinglePathCount--;
|
||||
}
|
||||
|
||||
@ -814,7 +825,7 @@ IScsiStart (
|
||||
//
|
||||
// Reinstall the original ExtScsiPassThru back.
|
||||
//
|
||||
if (mPrivate->OneSessionEstablished && ExistPrivate != NULL) {
|
||||
if (mPrivate->OneSessionEstablished && (ExistPrivate != NULL)) {
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&ExistPrivate->ExtScsiPassThruHandle,
|
||||
&gEfiExtScsiPassThruProtocolGuid,
|
||||
@ -837,8 +848,7 @@ IScsiStart (
|
||||
//
|
||||
// More than one attempt successes.
|
||||
//
|
||||
if (Private->Session != NULL && mPrivate->OneSessionEstablished) {
|
||||
|
||||
if ((Private->Session != NULL) && mPrivate->OneSessionEstablished) {
|
||||
AttemptConfigOrder = IScsiGetVariableAndSize (
|
||||
L"AttemptOrder",
|
||||
&gIScsiConfigGuid,
|
||||
@ -847,9 +857,11 @@ IScsiStart (
|
||||
if (AttemptConfigOrder == NULL) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
|
||||
if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex ||
|
||||
AttemptConfigOrder[Index] == BootSelected) {
|
||||
if ((AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex) ||
|
||||
(AttemptConfigOrder[Index] == BootSelected))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -887,6 +899,7 @@ IScsiStart (
|
||||
if (AttemptConfigOrder[Index] != BootSelected) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
mPrivate->BootSelectedIndex = BootSelected;
|
||||
//
|
||||
// Clear the resource in ExistPrivate.
|
||||
@ -917,7 +930,6 @@ IScsiStart (
|
||||
|
||||
gBS->CloseEvent (ExistPrivate->ExitBootServiceEvent);
|
||||
FreePool (ExistPrivate);
|
||||
|
||||
}
|
||||
} else {
|
||||
//
|
||||
@ -927,7 +939,6 @@ IScsiStart (
|
||||
NeedUpdate = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (NeedUpdate) {
|
||||
@ -945,6 +956,7 @@ IScsiStart (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Install the updated device path onto the ExtScsiPassThruHandle.
|
||||
//
|
||||
@ -1042,7 +1054,6 @@ IScsiStop (
|
||||
EFI_GUID *TcpServiceBindingGuid;
|
||||
EFI_GUID *TcpProtocolGuid;
|
||||
|
||||
|
||||
if (NumberOfChildren != 0) {
|
||||
//
|
||||
// We should have only one child.
|
||||
@ -1050,7 +1061,7 @@ IScsiStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandleBuffer[0],
|
||||
&gEfiExtScsiPassThruProtocolGuid,
|
||||
(VOID **) &PassThru,
|
||||
(VOID **)&PassThru,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1102,6 +1113,7 @@ IScsiStop (
|
||||
TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
|
||||
TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
||||
}
|
||||
|
||||
IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid);
|
||||
if (IScsiController == NULL) {
|
||||
return EFI_SUCCESS;
|
||||
@ -1110,7 +1122,7 @@ IScsiStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
IScsiController,
|
||||
ProtocolGuid,
|
||||
(VOID **) &IScsiIdentifier,
|
||||
(VOID **)&IScsiIdentifier,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1524,11 +1536,13 @@ IScsiUnload (
|
||||
Status = IScsiTestManagedDevice (
|
||||
DeviceHandleBuffer[Index],
|
||||
gIScsiIp4DriverBinding.DriverBindingHandle,
|
||||
&gEfiTcp4ProtocolGuid)
|
||||
&gEfiTcp4ProtocolGuid
|
||||
)
|
||||
;
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = gBS->DisconnectController (
|
||||
DeviceHandleBuffer[Index],
|
||||
gIScsiIp4DriverBinding.DriverBindingHandle,
|
||||
@ -1551,6 +1565,7 @@ IScsiUnload (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = gBS->DisconnectController (
|
||||
DeviceHandleBuffer[Index],
|
||||
gIScsiIp6DriverBinding.DriverBindingHandle,
|
||||
@ -1582,11 +1597,12 @@ IScsiUnload (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if (gIScsiControllerNameTable!= NULL) {
|
||||
if (gIScsiControllerNameTable != NULL) {
|
||||
Status = FreeUnicodeStringTable (gIScsiControllerNameTable);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
gIScsiControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
@ -1597,7 +1613,7 @@ IScsiUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
gIScsiIp4DriverBinding.DriverBindingHandle,
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
(VOID **) &ComponentName
|
||||
(VOID **)&ComponentName
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
@ -1614,7 +1630,7 @@ IScsiUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
gIScsiIp4DriverBinding.DriverBindingHandle,
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
(VOID **) &ComponentName2
|
||||
(VOID **)&ComponentName2
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
@ -1635,7 +1651,7 @@ IScsiUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
gIScsiIp6DriverBinding.DriverBindingHandle,
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
(VOID **) &ComponentName
|
||||
(VOID **)&ComponentName
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
@ -1652,7 +1668,7 @@ IScsiUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
gIScsiIp6DriverBinding.DriverBindingHandle,
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
(VOID **) &ComponentName2
|
||||
(VOID **)&ComponentName2
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
@ -1730,7 +1746,7 @@ IScsiDriverEntryPoint (
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiIScsiInitiatorNameProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &IScsiInitiatorName
|
||||
(VOID **)&IScsiInitiatorName
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return EFI_ACCESS_DENIED;
|
||||
@ -1821,7 +1837,7 @@ IScsiDriverEntryPoint (
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiAuthenticationInfoProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &AuthenticationInfo
|
||||
(VOID **)&AuthenticationInfo
|
||||
);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
@ -1873,4 +1889,3 @@ Error1:
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {
|
||||
IScsiExtScsiPassThruGetNextTarget
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -107,7 +106,6 @@ IScsiExtScsiPassThruFunction (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -152,7 +150,7 @@ IScsiExtScsiPassThruGetNextTargetLun (
|
||||
Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
|
||||
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.
|
||||
//
|
||||
@ -170,7 +168,6 @@ IScsiExtScsiPassThruGetNextTargetLun (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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) {
|
||||
Node->Iscsi.LoginOption |= 0x1000;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -267,14 +265,13 @@ IScsiExtScsiPassThruBuildDevicePath (
|
||||
|
||||
CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Translate a device path node to a Target ID and LUN.
|
||||
|
||||
@ -315,7 +312,8 @@ IScsiExtScsiPassThruGetTargetLun (
|
||||
if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
|
||||
(DevicePath->SubType != MSG_ISCSI_DP) ||
|
||||
(DevicePathNodeLength (DevicePath) <= sizeof (ISCSI_DEVICE_PATH))
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -325,7 +323,7 @@ IScsiExtScsiPassThruGetTargetLun (
|
||||
SetMem (*Target, TARGET_MAX_BYTES, 0xFF);
|
||||
(*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;
|
||||
}
|
||||
|
||||
@ -334,7 +332,6 @@ IScsiExtScsiPassThruGetTargetLun (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Resets a SCSI channel. This operation resets all the SCSI devices connected to
|
||||
the SCSI channel.
|
||||
@ -353,7 +350,6 @@ IScsiExtScsiPassThruResetChannel (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Resets a SCSI device that is connected to a SCSI channel.
|
||||
|
||||
@ -416,4 +412,3 @@ IScsiExtScsiPassThruGetNextTarget (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ IScsiInitIbfTableHeader (
|
||||
CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize the control section of the iSCSI Boot Firmware Table.
|
||||
|
||||
@ -50,11 +49,11 @@ IScsiInitControlSection (
|
||||
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control;
|
||||
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.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.
|
||||
@ -79,11 +78,10 @@ IScsiInitControlSection (
|
||||
// Need expand the control section if more than 2 NIC/Target attempts
|
||||
// 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.
|
||||
|
||||
@ -109,7 +107,6 @@ IScsiAddHeapItem (
|
||||
*(*Heap + Len) = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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_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 = (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.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 |
|
||||
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BOOT_SELECTED;
|
||||
|
||||
@ -147,11 +144,10 @@ IScsiFillInitiatorSection (
|
||||
//
|
||||
IScsiAddHeapItem (Heap, mPrivate->InitiatorName, mPrivate->InitiatorNameLength - 1);
|
||||
|
||||
Initiator->IScsiNameLength = (UINT16) (mPrivate->InitiatorNameLength - 1);
|
||||
Initiator->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
|
||||
Initiator->IScsiNameLength = (UINT16)(mPrivate->InitiatorNameLength - 1);
|
||||
Initiator->IScsiNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
|
||||
@ -208,10 +203,10 @@ IScsiFillNICAndTargetSections (
|
||||
//
|
||||
// Get the offset of the first Nic and Target section.
|
||||
//
|
||||
Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *) (Table + 1);
|
||||
Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *) ((UINTN) Table +
|
||||
Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *)(Table + 1);
|
||||
Nic = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *)((UINTN)Table +
|
||||
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)));
|
||||
|
||||
SectionOffset = &Control->NIC0Offset;
|
||||
@ -233,9 +228,8 @@ IScsiFillNICAndTargetSections (
|
||||
}
|
||||
|
||||
ASSERT (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED);
|
||||
|
||||
} else {
|
||||
if (Index == 1 && Flag) {
|
||||
if ((Index == 1) && Flag) {
|
||||
Entry = mPrivate->AttemptConfigs.ForwardLink;
|
||||
Flag = FALSE;
|
||||
}
|
||||
@ -260,7 +254,7 @@ IScsiFillNICAndTargetSections (
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -280,8 +274,8 @@ IScsiFillNICAndTargetSections (
|
||||
|
||||
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.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE);
|
||||
Nic->Header.Index = (UINT8) Index;
|
||||
Nic->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE);
|
||||
Nic->Header.Index = (UINT8)Index;
|
||||
Nic->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BLOCK_VALID |
|
||||
EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_GLOBAL;
|
||||
|
||||
@ -295,7 +289,7 @@ IScsiFillNICAndTargetSections (
|
||||
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.
|
||||
//
|
||||
@ -309,16 +303,13 @@ IScsiFillNICAndTargetSections (
|
||||
IScsiMapV4ToV6Addr (&Attempt->PrimaryDns.v4, &Nic->PrimaryDns);
|
||||
IScsiMapV4ToV6Addr (&Attempt->SecondaryDns.v4, &Nic->SecondaryDns);
|
||||
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;
|
||||
CopyMem (&Nic->Ip, &NvData->LocalIp, sizeof (EFI_IPv6_ADDRESS));
|
||||
CopyMem (&Nic->Gateway, &NvData->Gateway, sizeof (EFI_IPv6_ADDRESS));
|
||||
CopyMem (&Nic->PrimaryDns, &Attempt->PrimaryDns, sizeof (EFI_IPv6_ADDRESS));
|
||||
CopyMem (&Nic->SecondaryDns, &Attempt->SecondaryDns, sizeof (EFI_IPv6_ADDRESS));
|
||||
CopyMem (&Nic->DhcpServer, &Attempt->DhcpServer, sizeof (EFI_IPv6_ADDRESS));
|
||||
|
||||
} else {
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
@ -331,9 +322,9 @@ IScsiFillNICAndTargetSections (
|
||||
|
||||
Nic->VLanTag = NicInfo->VlanId;
|
||||
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);
|
||||
*SectionOffset = (UINT16) ((UINTN) Nic - (UINTN) Table);
|
||||
*SectionOffset = (UINT16)((UINTN)Nic - (UINTN)Table);
|
||||
SectionOffset++;
|
||||
|
||||
//
|
||||
@ -342,8 +333,8 @@ IScsiFillNICAndTargetSections (
|
||||
|
||||
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.Length = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE);
|
||||
Target->Header.Index = (UINT8) Index;
|
||||
Target->Header.Length = (UINT16)sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE);
|
||||
Target->Header.Index = (UINT8)Index;
|
||||
Target->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID;
|
||||
|
||||
if (Index == 0) {
|
||||
@ -362,11 +353,11 @@ IScsiFillNICAndTargetSections (
|
||||
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);
|
||||
} 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));
|
||||
} else {
|
||||
ASSERT (FALSE);
|
||||
@ -377,64 +368,63 @@ IScsiFillNICAndTargetSections (
|
||||
//
|
||||
// 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);
|
||||
|
||||
Target->IScsiNameLength = Length;
|
||||
Target->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
|
||||
Target->IScsiNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
|
||||
|
||||
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
|
||||
//
|
||||
// CHAP Name
|
||||
//
|
||||
Length = (UINT16) AsciiStrLen (AuthConfig->CHAPName);
|
||||
Length = (UINT16)AsciiStrLen (AuthConfig->CHAPName);
|
||||
IScsiAddHeapItem (Heap, AuthConfig->CHAPName, Length);
|
||||
Target->CHAPNameLength = Length;
|
||||
Target->CHAPNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
|
||||
Target->CHAPNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
|
||||
|
||||
//
|
||||
// CHAP Secret
|
||||
//
|
||||
Length = (UINT16) AsciiStrLen (AuthConfig->CHAPSecret);
|
||||
Length = (UINT16)AsciiStrLen (AuthConfig->CHAPSecret);
|
||||
IScsiAddHeapItem (Heap, AuthConfig->CHAPSecret, 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) {
|
||||
//
|
||||
// Reverse CHAP Name.
|
||||
//
|
||||
Length = (UINT16) AsciiStrLen (AuthConfig->ReverseCHAPName);
|
||||
Length = (UINT16)AsciiStrLen (AuthConfig->ReverseCHAPName);
|
||||
IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPName, Length);
|
||||
Target->ReverseCHAPNameLength = Length;
|
||||
Target->ReverseCHAPNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
|
||||
Target->ReverseCHAPNameOffset = (UINT16)((UINTN)*Heap - (UINTN)Table);
|
||||
|
||||
//
|
||||
// Reverse CHAP Secret.
|
||||
//
|
||||
Length = (UINT16) AsciiStrLen (AuthConfig->ReverseCHAPSecret);
|
||||
Length = (UINT16)AsciiStrLen (AuthConfig->ReverseCHAPSecret);
|
||||
IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPSecret, 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++;
|
||||
|
||||
//
|
||||
// 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)));
|
||||
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)));
|
||||
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Publish and remove the iSCSI Boot Firmware Table according to the iSCSI
|
||||
session status.
|
||||
@ -457,29 +447,29 @@ IScsiPublishIbft (
|
||||
Rsdt = NULL;
|
||||
Xsdt = NULL;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
|
||||
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Find ACPI table RSD_PTR from the system table.
|
||||
//
|
||||
Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp);
|
||||
Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **)&Rsdp);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &Rsdp);
|
||||
Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **)&Rsdp);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status) || (Rsdp == NULL)) {
|
||||
return ;
|
||||
} else if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) {
|
||||
Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
|
||||
return;
|
||||
} else if ((Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) && (Rsdp->XsdtAddress != 0)) {
|
||||
Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->XsdtAddress;
|
||||
} 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)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIbftInstalled) {
|
||||
@ -488,17 +478,19 @@ IScsiPublishIbft (
|
||||
mTableKey
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
mIbftInstalled = FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// If there is no valid attempt configuration, just return.
|
||||
//
|
||||
if ((!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount == 0) ||
|
||||
(mPrivate->EnableMpio && mPrivate->MpioCount <= mPrivate->Krb5MpioCount)) {
|
||||
return ;
|
||||
if ((!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount == 0)) ||
|
||||
(mPrivate->EnableMpio && (mPrivate->MpioCount <= mPrivate->Krb5MpioCount)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -506,10 +498,10 @@ IScsiPublishIbft (
|
||||
//
|
||||
Table = AllocateZeroPool (IBFT_MAX_SIZE);
|
||||
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.
|
||||
@ -524,7 +516,7 @@ IScsiPublishIbft (
|
||||
IScsiFillInitiatorSection (Table, &Heap);
|
||||
IScsiFillNICAndTargetSections (Table, &Heap);
|
||||
|
||||
Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
|
||||
Checksum = CalculateCheckSum8 ((UINT8 *)Table, Table->Length);
|
||||
Table->Checksum = Checksum;
|
||||
|
||||
//
|
||||
@ -536,7 +528,7 @@ IScsiPublishIbft (
|
||||
Table->Length,
|
||||
&mTableKey
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName = {
|
||||
IScsiSetInitiatorName
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Retrieves the current set value of iSCSI Initiator Name.
|
||||
|
||||
@ -64,7 +63,6 @@ IScsiGetInitiatorName (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets the iSSI Initiator Name.
|
||||
|
||||
@ -110,10 +108,11 @@ IScsiSetInitiatorName (
|
||||
*BufferSize = ISCSI_NAME_MAX_SIZE;
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Only support iqn iSCSI names.
|
||||
//
|
||||
Status = IScsiNormalizeName ((CHAR8 *) Buffer, *BufferSize - 1);
|
||||
Status = IScsiNormalizeName ((CHAR8 *)Buffer, *BufferSize - 1);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,6 @@ typedef struct _ISCSI_DRIVER_DATA ISCSI_DRIVER_DATA;
|
||||
///
|
||||
#define IP6_OLD_IPADDRESS_OFFSET 42
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct _ISCSI_SESSION_CONFIG_NVDATA {
|
||||
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.
|
||||
CHAR8 TargetUrl[ISCSI_TARGET_URI_MAX_SIZE];
|
||||
|
||||
} ISCSI_SESSION_CONFIG_NVDATA;
|
||||
#pragma pack()
|
||||
|
||||
@ -185,7 +183,6 @@ IScsiHexToBin (
|
||||
IN CHAR8 *HexStr
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Convert the decimal-constant string or hex-constant string into a numerical value.
|
||||
|
||||
@ -295,7 +292,6 @@ IScsiGetNicInfoByIndex (
|
||||
IN UINT8 NicIndex
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Get the NIC's PCI location and return it according to the composited
|
||||
format defined in iSCSI Boot Firmware Table.
|
||||
@ -469,4 +465,5 @@ IScsiTestManagedDevice (
|
||||
IN EFI_HANDLE DriverBindingHandle,
|
||||
IN EFI_GUID *ProtocolGuid
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -44,7 +44,6 @@ IScsiDetatchConnection (
|
||||
Conn->Session = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check the sequence number according to RFC3720.
|
||||
|
||||
@ -80,7 +79,6 @@ IScsiCheckSN (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Update the sequence numbers for the iSCSI command.
|
||||
|
||||
@ -97,7 +95,7 @@ IScsiUpdateCmdSN (
|
||||
)
|
||||
{
|
||||
if (ISCSI_SEQ_LT (MaxCmdSN, ExpCmdSN - 1)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ISCSI_SEQ_GT (MaxCmdSN, Session->MaxCmdSN)) {
|
||||
@ -109,7 +107,6 @@ IScsiUpdateCmdSN (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function does the iSCSI connection login.
|
||||
|
||||
@ -171,7 +168,6 @@ IScsiConnLogin (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset the iSCSI connection.
|
||||
|
||||
@ -186,7 +182,6 @@ IScsiConnReset (
|
||||
TcpIoReset (&Conn->TcpIo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a TCP connection for the iSCSI session.
|
||||
|
||||
@ -259,7 +254,7 @@ IScsiCreateConnection (
|
||||
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"));
|
||||
FreePool (Conn);
|
||||
return NULL;
|
||||
@ -292,7 +287,7 @@ IScsiCreateConnection (
|
||||
Status = TcpIoCreateSocket (
|
||||
Private->Image,
|
||||
Private->Controller,
|
||||
(UINT8) (!Conn->Ipv6Flag ? TCP_VERSION_4: TCP_VERSION_6),
|
||||
(UINT8)(!Conn->Ipv6Flag ? TCP_VERSION_4 : TCP_VERSION_6),
|
||||
&TcpIoConfig,
|
||||
&Conn->TcpIo
|
||||
);
|
||||
@ -305,7 +300,6 @@ IScsiCreateConnection (
|
||||
return Conn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroy an iSCSI connection.
|
||||
|
||||
@ -390,6 +384,7 @@ IScsiGetIp6NicInfo (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (RouteEntry != Ip6ModeData.RouteCount) {
|
||||
IP6_COPY_ADDRESS (&NvData->Gateway, &Ip6ModeData.RouteTable[RouteEntry].Gateway);
|
||||
}
|
||||
@ -398,19 +393,24 @@ ON_EXIT:
|
||||
if (Ip6ModeData.AddressList != NULL) {
|
||||
FreePool (Ip6ModeData.AddressList);
|
||||
}
|
||||
if (Ip6ModeData.GroupTable!= NULL) {
|
||||
|
||||
if (Ip6ModeData.GroupTable != NULL) {
|
||||
FreePool (Ip6ModeData.GroupTable);
|
||||
}
|
||||
if (Ip6ModeData.RouteTable!= NULL) {
|
||||
|
||||
if (Ip6ModeData.RouteTable != NULL) {
|
||||
FreePool (Ip6ModeData.RouteTable);
|
||||
}
|
||||
if (Ip6ModeData.NeighborCache!= NULL) {
|
||||
|
||||
if (Ip6ModeData.NeighborCache != NULL) {
|
||||
FreePool (Ip6ModeData.NeighborCache);
|
||||
}
|
||||
if (Ip6ModeData.PrefixTable!= NULL) {
|
||||
|
||||
if (Ip6ModeData.PrefixTable != NULL) {
|
||||
FreePool (Ip6ModeData.PrefixTable);
|
||||
}
|
||||
if (Ip6ModeData.IcmpTypeList!= NULL) {
|
||||
|
||||
if (Ip6ModeData.IcmpTypeList != NULL) {
|
||||
FreePool (Ip6ModeData.IcmpTypeList);
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ IScsiSessionLogin (
|
||||
Status = gBS->OpenProtocol (
|
||||
Conn->TcpIo.Handle,
|
||||
ProtocolGuid,
|
||||
(VOID **) &Tcp,
|
||||
(VOID **)&Tcp,
|
||||
Session->Private->Image,
|
||||
Session->Private->ExtScsiPassThruHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -533,7 +533,6 @@ IScsiSessionLogin (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Wait for IPsec negotiation, then try to login the iSCSI session again.
|
||||
|
||||
@ -549,7 +548,6 @@ IScsiSessionReLogin (
|
||||
IN ISCSI_SESSION *Session
|
||||
)
|
||||
{
|
||||
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS TimerStatus;
|
||||
EFI_EVENT Timer;
|
||||
@ -571,20 +569,17 @@ IScsiSessionReLogin (
|
||||
}
|
||||
|
||||
do {
|
||||
|
||||
TimerStatus = gBS->CheckEvent (Timer);
|
||||
|
||||
if (!EFI_ERROR (TimerStatus)) {
|
||||
Status = IScsiSessionLogin (Session);
|
||||
}
|
||||
|
||||
} while (TimerStatus == EFI_NOT_READY);
|
||||
|
||||
gBS->CloseEvent (Timer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build and send the iSCSI login request to the iSCSI target according to
|
||||
the current login stage.
|
||||
@ -612,6 +607,7 @@ IScsiSendLoginReq (
|
||||
if (Pdu == NULL) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Send it to the iSCSI target.
|
||||
//
|
||||
@ -622,7 +618,6 @@ IScsiSendLoginReq (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Receive and process the iSCSI login response.
|
||||
|
||||
@ -649,6 +644,7 @@ IScsiReceiveLoginRsp (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (Pdu != NULL);
|
||||
|
||||
//
|
||||
@ -661,7 +657,6 @@ IScsiReceiveLoginRsp (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -692,14 +687,15 @@ IScsiAddKeyValuePair (
|
||||
ISCSI_LOGIN_REQUEST *LoginReq;
|
||||
CHAR8 *Data;
|
||||
|
||||
LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, NULL);
|
||||
LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufGetByte (Pdu, 0, NULL);
|
||||
if (LoginReq == NULL) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
DataSegLen = NTOH24 (LoginReq->DataSegmentLength);
|
||||
|
||||
KeyLen = (UINT32) AsciiStrLen (Key);
|
||||
ValueLen = (UINT32) AsciiStrLen (Value);
|
||||
KeyLen = (UINT32)AsciiStrLen (Key);
|
||||
ValueLen = (UINT32)AsciiStrLen (Value);
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
Data = (CHAR8 *) NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL);
|
||||
Data = (CHAR8 *)NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL);
|
||||
if (Data == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Add the key.
|
||||
//
|
||||
@ -739,7 +736,6 @@ IScsiAddKeyValuePair (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Prepare the iSCSI login request to be sent according to the current login status.
|
||||
|
||||
@ -766,11 +762,12 @@ IScsiPrepareLoginReq (
|
||||
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) {
|
||||
NetbufFree (Nbuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST));
|
||||
|
||||
//
|
||||
@ -852,7 +849,6 @@ IScsiPrepareLoginReq (
|
||||
return Nbuf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the iSCSI Login Response.
|
||||
|
||||
@ -884,16 +880,18 @@ IScsiProcessLoginRsp (
|
||||
Status = EFI_SUCCESS;
|
||||
Session = Conn->Session;
|
||||
|
||||
LoginRsp = (ISCSI_LOGIN_RESPONSE *) NetbufGetByte (Pdu, 0, NULL);
|
||||
LoginRsp = (ISCSI_LOGIN_RESPONSE *)NetbufGetByte (Pdu, 0, NULL);
|
||||
if (LoginRsp == NULL) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
if (!ISCSI_CHECK_OPCODE (LoginRsp, ISCSI_OPCODE_LOGIN_RSP)) {
|
||||
//
|
||||
// It is not a Login Response.
|
||||
//
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the data segment, if any.
|
||||
//
|
||||
@ -903,6 +901,7 @@ IScsiProcessLoginRsp (
|
||||
} else {
|
||||
DataSeg = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Check the status class in the login response PDU.
|
||||
//
|
||||
@ -920,14 +919,16 @@ IScsiProcessLoginRsp (
|
||||
if (DataSeg == NULL) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Process the TargetAddress key-value strings in the data segment to update the
|
||||
// target address info.
|
||||
//
|
||||
Status = IScsiUpdateTargetAddress (Session, (CHAR8 *) DataSeg, DataSegLen);
|
||||
Status = IScsiUpdateTargetAddress (Session, (CHAR8 *)DataSeg, DataSegLen);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Session will be restarted on this error status because the Target is
|
||||
// redirected by this Login Response.
|
||||
@ -940,6 +941,7 @@ IScsiProcessLoginRsp (
|
||||
//
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// The status is success; extract the wanted fields from the header segment.
|
||||
//
|
||||
@ -957,7 +959,8 @@ IScsiProcessLoginRsp (
|
||||
(Transit && (NextStage != Conn->NextStage)) ||
|
||||
(CompareMem (Session->Isid, LoginRsp->Isid, sizeof (LoginRsp->Isid)) != 0) ||
|
||||
(LoginRsp->InitiatorTaskTag != Session->InitiatorTaskTag)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// 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.
|
||||
@ -1003,6 +1006,7 @@ IScsiProcessLoginRsp (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Trim off the header segment.
|
||||
//
|
||||
@ -1033,6 +1037,7 @@ IScsiProcessLoginRsp (
|
||||
if (Session->AuthType != ISCSI_AUTH_TYPE_KRB) {
|
||||
Status = IScsiCHAPOnRspReceived (Conn);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:
|
||||
@ -1070,6 +1075,7 @@ IScsiProcessLoginRsp (
|
||||
Session->Tsih = NTOHS (LoginRsp->Tsih);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Flush the response(s) received.
|
||||
//
|
||||
@ -1078,7 +1084,6 @@ IScsiProcessLoginRsp (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Updated the target information according the data received in the iSCSI
|
||||
login response with an target redirection status.
|
||||
@ -1140,11 +1145,11 @@ IScsiUpdateTargetAddress (
|
||||
//
|
||||
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.
|
||||
//
|
||||
TargetAddress ++;
|
||||
TargetAddress++;
|
||||
IpStr = TargetAddress;
|
||||
while ((*TargetAddress != '\0') && (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER)) {
|
||||
//
|
||||
@ -1158,8 +1163,7 @@ IScsiUpdateTargetAddress (
|
||||
}
|
||||
|
||||
*TargetAddress = '\0';
|
||||
TargetAddress ++;
|
||||
|
||||
TargetAddress++;
|
||||
} else {
|
||||
//
|
||||
// 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 != ',')) {
|
||||
TargetAddress++;
|
||||
}
|
||||
|
||||
NvData->DnsMode = TRUE;
|
||||
}
|
||||
|
||||
@ -1192,7 +1197,7 @@ IScsiUpdateTargetAddress (
|
||||
if (Number > 0xFFFF) {
|
||||
continue;
|
||||
} else {
|
||||
NvData->TargetPort = (UINT16) Number;
|
||||
NvData->TargetPort = (UINT16)Number;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
@ -1220,9 +1225,10 @@ IScsiUpdateTargetAddress (
|
||||
// Target address is expressed as URL format, just save it and
|
||||
// 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;
|
||||
}
|
||||
|
||||
CopyMem (&Session->ConfigData->SessionConfigData.TargetUrl, IpStr, AsciiStrSize (IpStr));
|
||||
} else {
|
||||
Status = IScsiAsciiStrToIp (
|
||||
@ -1245,7 +1251,6 @@ IScsiUpdateTargetAddress (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The callback function to free the net buffer list.
|
||||
|
||||
@ -1260,11 +1265,10 @@ IScsiFreeNbufList (
|
||||
{
|
||||
ASSERT (Arg != NULL);
|
||||
|
||||
NetbufFreeList ((LIST_ENTRY *) Arg);
|
||||
NetbufFreeList ((LIST_ENTRY *)Arg);
|
||||
FreePool (Arg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
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;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
InsertTailList (NbufList, &PduHdr->List);
|
||||
|
||||
//
|
||||
@ -1372,6 +1376,7 @@ IScsiReceivePdu (
|
||||
//
|
||||
goto FORM_PDU;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the length of the padding bytes of the data segment.
|
||||
//
|
||||
@ -1486,7 +1491,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check and get the result of the parameter negotiation.
|
||||
|
||||
@ -1520,7 +1524,7 @@ IScsiCheckOpParams (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
NetbufQueCopy (&Conn->RspQue, 0, Len, (UINT8 *) Data);
|
||||
NetbufQueCopy (&Conn->RspQue, 0, Len, (UINT8 *)Data);
|
||||
|
||||
Status = EFI_PROTOCOL_ERROR;
|
||||
|
||||
@ -1532,6 +1536,7 @@ IScsiCheckOpParams (
|
||||
FreePool (Data);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// HeaderDigest
|
||||
//
|
||||
@ -1549,6 +1554,7 @@ IScsiCheckOpParams (
|
||||
} else {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// DataDigest
|
||||
//
|
||||
@ -1566,6 +1572,7 @@ IScsiCheckOpParams (
|
||||
} else {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// ErrorRecoveryLevel: result function is Minimum.
|
||||
//
|
||||
@ -1579,7 +1586,7 @@ IScsiCheckOpParams (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Session->ErrorRecoveryLevel = (UINT8) MIN (Session->ErrorRecoveryLevel, NumericValue);
|
||||
Session->ErrorRecoveryLevel = (UINT8)MIN (Session->ErrorRecoveryLevel, NumericValue);
|
||||
|
||||
//
|
||||
// InitialR2T: result function is OR.
|
||||
@ -1590,7 +1597,7 @@ IScsiCheckOpParams (
|
||||
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;
|
||||
}
|
||||
|
||||
Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0));
|
||||
Session->ImmediateData = (BOOLEAN)(Session->ImmediateData && (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0));
|
||||
|
||||
//
|
||||
// MaxRecvDataSegmentLength is declarative.
|
||||
//
|
||||
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH);
|
||||
if (Value != NULL) {
|
||||
Conn->MaxRecvDataSegmentLength = (UINT32) IScsiNetNtoi (Value);
|
||||
Conn->MaxRecvDataSegmentLength = (UINT32)IScsiNetNtoi (Value);
|
||||
}
|
||||
|
||||
//
|
||||
// MaxBurstLength: result function is Minimum.
|
||||
//
|
||||
@ -1619,7 +1627,7 @@ IScsiCheckOpParams (
|
||||
}
|
||||
|
||||
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
|
||||
@ -1632,7 +1640,7 @@ IScsiCheckOpParams (
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Session->MaxConnections = (UINT32) MIN (Session->MaxConnections, NumericValue);
|
||||
Session->MaxConnections = (UINT32)MIN (Session->MaxConnections, NumericValue);
|
||||
|
||||
//
|
||||
// DataPDUInOrder: result function is OR.
|
||||
@ -1659,7 +1667,7 @@ IScsiCheckOpParams (
|
||||
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;
|
||||
}
|
||||
|
||||
Session->DataSequenceInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
|
||||
Session->DataSequenceInOrder = (BOOLEAN)(AsciiStrCmp (Value, "Yes") == 0);
|
||||
}
|
||||
|
||||
//
|
||||
@ -1688,8 +1696,9 @@ IScsiCheckOpParams (
|
||||
} else if (NumericValue > 3600) {
|
||||
goto ON_ERROR;
|
||||
} else {
|
||||
Session->DefaultTime2Wait = (UINT32) MAX (Session->DefaultTime2Wait, NumericValue);
|
||||
Session->DefaultTime2Wait = (UINT32)MAX (Session->DefaultTime2Wait, NumericValue);
|
||||
}
|
||||
|
||||
//
|
||||
// DefaultTime2Retain: result function is Minimum.
|
||||
//
|
||||
@ -1704,8 +1713,9 @@ IScsiCheckOpParams (
|
||||
} else if (NumericValue > 3600) {
|
||||
goto ON_ERROR;
|
||||
} else {
|
||||
Session->DefaultTime2Retain = (UINT32) MIN (Session->DefaultTime2Retain, NumericValue);
|
||||
Session->DefaultTime2Retain = (UINT32)MIN (Session->DefaultTime2Retain, NumericValue);
|
||||
}
|
||||
|
||||
//
|
||||
// MaxOutstandingR2T: result function is Minimum.
|
||||
//
|
||||
@ -1719,7 +1729,7 @@ IScsiCheckOpParams (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Session->MaxOutstandingR2T = (UINT16) MIN (Session->MaxOutstandingR2T, NumericValue);
|
||||
Session->MaxOutstandingR2T = (UINT16)MIN (Session->MaxOutstandingR2T, NumericValue);
|
||||
|
||||
//
|
||||
// Remove declarative key-value pairs, if any.
|
||||
@ -1728,7 +1738,6 @@ IScsiCheckOpParams (
|
||||
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS);
|
||||
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_PORTAL_GROUP_TAG);
|
||||
|
||||
|
||||
//
|
||||
// Remove the key-value that may not needed for result function is OR.
|
||||
//
|
||||
@ -1759,7 +1768,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fill the operational parameters.
|
||||
|
||||
@ -1821,7 +1829,6 @@ IScsiFillOpParams (
|
||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_MAX_OUTSTANDING_R2T, Value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Pad the iSCSI AHS or data segment to an integer number of 4 byte words.
|
||||
|
||||
@ -1855,7 +1862,6 @@ IScsiPadSegment (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build a key-value list from the data segment.
|
||||
|
||||
@ -1909,10 +1915,10 @@ IScsiBuildKeyValueList (
|
||||
|
||||
KeyValuePair->Value = Data;
|
||||
|
||||
InsertTailList (ListHead, &KeyValuePair->List);;
|
||||
InsertTailList (ListHead, &KeyValuePair->List);
|
||||
|
||||
Data += AsciiStrLen (KeyValuePair->Value) + 1;
|
||||
Len -= (UINT32) AsciiStrLen (KeyValuePair->Value) + 1;
|
||||
Len -= (UINT32)AsciiStrLen (KeyValuePair->Value) + 1;
|
||||
}
|
||||
|
||||
return ListHead;
|
||||
@ -1924,7 +1930,6 @@ ON_ERROR:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -1963,7 +1968,6 @@ IScsiGetValueByKeyFromList (
|
||||
return Value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the key-value list.
|
||||
|
||||
@ -1988,7 +1992,6 @@ IScsiFreeKeyValueList (
|
||||
FreePool (KeyValueList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Normalize the iSCSI name according to RFC.
|
||||
|
||||
@ -2012,7 +2015,7 @@ IScsiNormalizeName (
|
||||
//
|
||||
// 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]) &&
|
||||
@ -2020,7 +2023,8 @@ IScsiNormalizeName (
|
||||
(Name[Index] != '-') &&
|
||||
(Name[Index] != '.') &&
|
||||
(Name[Index] != ':')
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASCII dash, dot, colon lower-case characters and digit characters
|
||||
// are allowed.
|
||||
@ -2039,7 +2043,6 @@ IScsiNormalizeName (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create an iSCSI task control block.
|
||||
|
||||
@ -2093,7 +2096,6 @@ IScsiNewTcb (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Delete the tcb from the connection and destroy it.
|
||||
|
||||
@ -2110,7 +2112,6 @@ IScsiDelTcb (
|
||||
FreePool (Tcb);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a data segment, pad it, and calculate the CRC if needed.
|
||||
|
||||
@ -2139,7 +2140,7 @@ IScsiNewDataSegment (
|
||||
PadLen = ISCSI_GET_PAD_LEN (Len);
|
||||
if (PadLen != 0) {
|
||||
Fragment[1].Len = PadLen;
|
||||
Fragment[1].Bulk = (UINT8 *) &mDataSegPad;
|
||||
Fragment[1].Bulk = (UINT8 *)&mDataSegPad;
|
||||
|
||||
FragmentCount = 2;
|
||||
} else {
|
||||
@ -2151,7 +2152,6 @@ IScsiNewDataSegment (
|
||||
return DataSeg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a iSCSI SCSI command PDU to encapsulate the command issued
|
||||
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.
|
||||
//
|
||||
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;
|
||||
@ -2206,12 +2206,13 @@ IScsiNewScsiCmdPdu (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ScsiCmd = (SCSI_COMMAND *) NetbufAllocSpace (PduHeader, Length, NET_BUF_TAIL);
|
||||
ScsiCmd = (SCSI_COMMAND *)NetbufAllocSpace (PduHeader, Length, NET_BUF_TAIL);
|
||||
if (ScsiCmd == NULL) {
|
||||
NetbufFree (PduHeader);
|
||||
return NULL;
|
||||
}
|
||||
Header = (ISCSI_ADDITIONAL_HEADER *) (ScsiCmd + 1);
|
||||
|
||||
Header = (ISCSI_ADDITIONAL_HEADER *)(ScsiCmd + 1);
|
||||
|
||||
ZeroMem (ScsiCmd, Length);
|
||||
|
||||
@ -2239,8 +2240,8 @@ IScsiNewScsiCmdPdu (
|
||||
//
|
||||
// Fill the bidirectional expected read data length AHS.
|
||||
//
|
||||
BiExpReadDataLenAHS = (ISCSI_BI_EXP_READ_DATA_LEN_AHS *) Header;
|
||||
Header = (ISCSI_ADDITIONAL_HEADER *) (BiExpReadDataLenAHS + 1);
|
||||
BiExpReadDataLenAHS = (ISCSI_BI_EXP_READ_DATA_LEN_AHS *)Header;
|
||||
Header = (ISCSI_ADDITIONAL_HEADER *)(BiExpReadDataLenAHS + 1);
|
||||
|
||||
BiExpReadDataLenAHS->Length = NTOHS (5);
|
||||
BiExpReadDataLenAHS->Type = ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN;
|
||||
@ -2258,10 +2259,10 @@ IScsiNewScsiCmdPdu (
|
||||
CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb));
|
||||
|
||||
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;
|
||||
|
||||
CopyMem (Header + 1, (UINT8 *) Packet->Cdb + 16, Packet->CdbLength - 16);
|
||||
CopyMem (Header + 1, (UINT8 *)Packet->Cdb + 16, Packet->CdbLength - 16);
|
||||
}
|
||||
|
||||
Pdu = PduHeader;
|
||||
@ -2285,7 +2286,7 @@ IScsiNewScsiCmdPdu (
|
||||
//
|
||||
// Create the data segment.
|
||||
//
|
||||
DataSeg = IScsiNewDataSegment ((UINT8 *) Packet->OutDataBuffer, ImmediateDataLen, FALSE);
|
||||
DataSeg = IScsiNewDataSegment ((UINT8 *)Packet->OutDataBuffer, ImmediateDataLen, FALSE);
|
||||
if (DataSeg == NULL) {
|
||||
NetbufFree (PduHeader);
|
||||
Pdu = NULL;
|
||||
@ -2314,7 +2315,8 @@ IScsiNewScsiCmdPdu (
|
||||
if (Session->InitialR2T ||
|
||||
(ImmediateDataLen == Session->FirstBurstLength) ||
|
||||
(ImmediateDataLen == Packet->OutTransferLength)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Unsolicited data out sequence is not allowed,
|
||||
// or FirstBustLength data is already sent out by immediate data,
|
||||
@ -2330,7 +2332,6 @@ ON_EXIT:
|
||||
return Pdu;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a new iSCSI SCSI Data Out PDU.
|
||||
|
||||
@ -2375,16 +2376,18 @@ IScsiNewDataOutPdu (
|
||||
FreePool (NbufList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Insert the BHS into the buffer 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) {
|
||||
IScsiFreeNbufList (NbufList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XferContext = &Tcb->XferContext;
|
||||
|
||||
ZeroMem (DataOutHdr, sizeof (ISCSI_SCSI_DATA_OUT));
|
||||
@ -2404,6 +2407,7 @@ IScsiNewDataOutPdu (
|
||||
if (XferContext->TargetTransferTag != ISCSI_RESERVED_TAG) {
|
||||
CopyMem (&DataOutHdr->Lun, &Lun, sizeof (DataOutHdr->Lun));
|
||||
}
|
||||
|
||||
//
|
||||
// Build the data segment for this Data Out PDU.
|
||||
//
|
||||
@ -2412,6 +2416,7 @@ IScsiNewDataOutPdu (
|
||||
IScsiFreeNbufList (NbufList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Put the data segment into the buffer list and combine it with the BHS
|
||||
// into a full Data Out PDU.
|
||||
@ -2425,7 +2430,6 @@ IScsiNewDataOutPdu (
|
||||
return Pdu;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Generate a consecutive sequence of iSCSI SCSI Data Out PDUs.
|
||||
|
||||
@ -2491,6 +2495,7 @@ IScsiGenerateDataOutPduSequence (
|
||||
XferContext->DesiredLength -= DataLen;
|
||||
DataSN++;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the F bit for the last data out PDU in this sequence.
|
||||
//
|
||||
@ -2560,7 +2565,6 @@ IScsiSendDataOutPduSequence (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the received iSCSI SCSI Data In PDU.
|
||||
|
||||
@ -2585,7 +2589,7 @@ IScsiOnDataInRcvd (
|
||||
ISCSI_SCSI_DATA_IN *DataInHdr;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DataInHdr = (ISCSI_SCSI_DATA_IN *) NetbufGetByte (Pdu, 0, NULL);
|
||||
DataInHdr = (ISCSI_SCSI_DATA_IN *)NetbufGetByte (Pdu, 0, NULL);
|
||||
if (DataInHdr == NULL) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
@ -2606,6 +2610,7 @@ IScsiOnDataInRcvd (
|
||||
if (DataInHdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Update the command related sequence numbers.
|
||||
//
|
||||
@ -2627,6 +2632,7 @@ IScsiOnDataInRcvd (
|
||||
//
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// S bit is on, the StatSN is valid.
|
||||
//
|
||||
@ -2651,7 +2657,6 @@ IScsiOnDataInRcvd (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the received iSCSI R2T PDU.
|
||||
|
||||
@ -2678,7 +2683,7 @@ IScsiOnR2TRcvd (
|
||||
ISCSI_XFER_CONTEXT *XferContext;
|
||||
UINT8 *Data;
|
||||
|
||||
R2THdr = (ISCSI_READY_TO_TRANSFER *) NetbufGetByte (Pdu, 0, NULL);
|
||||
R2THdr = (ISCSI_READY_TO_TRANSFER *)NetbufGetByte (Pdu, 0, NULL);
|
||||
if (R2THdr == NULL) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
@ -2691,8 +2696,9 @@ IScsiOnR2TRcvd (
|
||||
R2THdr->DesiredDataTransferLength = NTOHL (R2THdr->DesiredDataTransferLength);
|
||||
|
||||
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.
|
||||
//
|
||||
@ -2708,19 +2714,20 @@ IScsiOnR2TRcvd (
|
||||
|
||||
if (((XferContext->Offset + XferContext->DesiredLength) > Packet->OutTransferLength) ||
|
||||
(XferContext->DesiredLength > Tcb->Conn->Session->MaxBurstLength)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Send the data solicited by this R2T.
|
||||
//
|
||||
Data = (UINT8 *) Packet->OutDataBuffer + XferContext->Offset;
|
||||
Data = (UINT8 *)Packet->OutDataBuffer + XferContext->Offset;
|
||||
Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the received iSCSI SCSI Response PDU.
|
||||
|
||||
@ -2746,7 +2753,7 @@ IScsiOnScsiRspRcvd (
|
||||
EFI_STATUS Status;
|
||||
UINT32 DataSegLen;
|
||||
|
||||
ScsiRspHdr = (SCSI_RESPONSE *) NetbufGetByte (Pdu, 0, NULL);
|
||||
ScsiRspHdr = (SCSI_RESPONSE *)NetbufGetByte (Pdu, 0, NULL);
|
||||
if (ScsiRspHdr == NULL) {
|
||||
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) ||
|
||||
ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_OVERFLOW | SCSI_RSP_PDU_FLAG_UNDERFLOW)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -2811,14 +2819,14 @@ IScsiOnScsiRspRcvd (
|
||||
|
||||
DataSegLen = ISCSI_GET_DATASEG_LEN (ScsiRspHdr);
|
||||
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) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
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) {
|
||||
CopyMem (Packet->SenseData, &SenseData->Data[0], Packet->SenseDataLength);
|
||||
}
|
||||
@ -2829,7 +2837,6 @@ IScsiOnScsiRspRcvd (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the received NOP In PDU.
|
||||
|
||||
@ -2850,7 +2857,7 @@ IScsiOnNopInRcvd (
|
||||
ISCSI_NOP_IN *NopInHdr;
|
||||
EFI_STATUS Status;
|
||||
|
||||
NopInHdr = (ISCSI_NOP_IN *) NetbufGetByte (Pdu, 0, NULL);
|
||||
NopInHdr = (ISCSI_NOP_IN *)NetbufGetByte (Pdu, 0, NULL);
|
||||
if (NopInHdr == NULL) {
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
@ -2875,7 +2882,6 @@ IScsiOnNopInRcvd (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.
|
||||
|
||||
@ -2942,6 +2948,7 @@ IScsiExecuteScsiCommand (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Encapsulate the SCSI request packet into an iSCSI SCSI Command PDU.
|
||||
//
|
||||
@ -2958,6 +2965,7 @@ IScsiExecuteScsiCommand (
|
||||
NetbufFree (Pdu);
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
XferContext->Offset = ISCSI_GET_DATASEG_LEN (PduHdr);
|
||||
|
||||
//
|
||||
@ -2974,7 +2982,8 @@ IScsiExecuteScsiCommand (
|
||||
if (!Session->InitialR2T &&
|
||||
(XferContext->Offset < Session->FirstBurstLength) &&
|
||||
(XferContext->Offset < Packet->OutTransferLength)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Unsolicited Data-Out sequence is allowed. There is remaining SCSI
|
||||
// OUT data, and the limit of FirstBurstLength is not reached.
|
||||
@ -2985,14 +2994,14 @@ IScsiExecuteScsiCommand (
|
||||
Packet->OutTransferLength - XferContext->Offset
|
||||
);
|
||||
|
||||
Data = (UINT8 *) Packet->OutDataBuffer + XferContext->Offset;
|
||||
Data = (UINT8 *)Packet->OutDataBuffer + XferContext->Offset;
|
||||
Status = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
InBufferContext.InData = (UINT8 *) Packet->InDataBuffer;
|
||||
InBufferContext.InData = (UINT8 *)Packet->InDataBuffer;
|
||||
InBufferContext.InDataLen = Packet->InTransferLength;
|
||||
|
||||
while (!Tcb->StatusXferd) {
|
||||
@ -3022,6 +3031,7 @@ IScsiExecuteScsiCommand (
|
||||
NetbufFree (Pdu);
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
switch (ISCSI_GET_OPCODE (PduHdr)) {
|
||||
case ISCSI_OPCODE_SCSI_DATA_IN:
|
||||
Status = IScsiOnDataInRcvd (Pdu, Tcb, Packet);
|
||||
@ -3072,7 +3082,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reinstate the session on some error.
|
||||
|
||||
@ -3105,7 +3114,6 @@ IScsiSessionReinstatement (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize some session parameters before login.
|
||||
|
||||
@ -3147,7 +3155,6 @@ IScsiSessionInit (
|
||||
Session->ErrorRecoveryLevel = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Abort the iSCSI session. That is, reset all the connection(s), and free the
|
||||
resources.
|
||||
@ -3164,7 +3171,7 @@ IScsiSessionAbort (
|
||||
EFI_GUID *ProtocolGuid;
|
||||
|
||||
if (Session->State != SESSION_STATE_LOGGED_IN) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (!IsListEmpty (&Session->Conns));
|
||||
@ -3197,5 +3204,5 @@ IScsiSessionAbort (
|
||||
|
||||
Session->State = SESSION_STATE_FAILED;
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
@ -29,4 +29,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
extern EFI_GUID gEdkiiHttpTlsCipherListGuid;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -17,4 +17,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
extern EFI_GUID gTlsAuthConfigGuid;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -21,4 +21,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
extern EFI_GUID gEfiTlsCaCertificateGuid;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -39,7 +39,7 @@ typedef enum {
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI * HTTP_IO_CALLBACK) (
|
||||
(EFIAPI *HTTP_IO_CALLBACK)(
|
||||
IN HTTP_IO_CALLBACK_EVENT EventType,
|
||||
IN EFI_HTTP_MESSAGE *Message,
|
||||
IN VOID *Context
|
||||
@ -324,5 +324,6 @@ HttpIoSendChunkedTransfer (
|
||||
IN HTTP_IO *HttpIo,
|
||||
IN HTTP_IO_SEND_CHUNK_PROCESS *SendChunkProcess,
|
||||
IN EFI_HTTP_MESSAGE *RequestMessage
|
||||
);
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -13,7 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include <Protocol/Http.h>
|
||||
|
||||
|
||||
/**
|
||||
Decode a percent-encoded URI component to the ASCII character.
|
||||
|
||||
@ -229,12 +228,12 @@ typedef enum {
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *HTTP_BODY_PARSER_CALLBACK) (
|
||||
(EFIAPI *HTTP_BODY_PARSER_CALLBACK)(
|
||||
IN HTTP_BODY_PARSE_EVENT EventType,
|
||||
IN CHAR8 *Data,
|
||||
IN UINTN Length,
|
||||
IN VOID *Context
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize a HTTP message-body parser.
|
||||
@ -339,7 +338,6 @@ HttpFreeMsgParser (
|
||||
IN VOID *MsgParser
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Find a specified header field according to the field name.
|
||||
|
||||
@ -485,7 +483,6 @@ typedef struct {
|
||||
EFI_HTTP_HEADER *Headers;
|
||||
} HTTP_IO_HEADER;
|
||||
|
||||
|
||||
/**
|
||||
Create a HTTP_IO_HEADER to hold the HTTP header items.
|
||||
|
||||
@ -531,4 +528,3 @@ HttpIoSetHeader (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -71,11 +71,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
#define NET_PROTO_HDR(Buf, Type) ((Type *) ((Buf)->BlockOp[0].Head))
|
||||
|
||||
|
||||
extern EFI_IP4_CONFIG_DATA mIp4IoDefaultIpConfigData;
|
||||
extern EFI_IP6_CONFIG_DATA mIp6IoDefaultIpConfigData;
|
||||
|
||||
|
||||
///
|
||||
/// This error will be delivered to the
|
||||
/// listening transportation layer protocol
|
||||
@ -180,7 +178,7 @@ typedef struct _EFI_NET_SESSION_DATA {
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *PKT_RCVD_NOTIFY) (
|
||||
(EFIAPI *PKT_RCVD_NOTIFY)(
|
||||
IN EFI_STATUS Status,
|
||||
IN UINT8 IcmpErr,
|
||||
IN EFI_NET_SESSION_DATA *NetSession,
|
||||
@ -201,7 +199,7 @@ VOID
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *PKT_SENT_NOTIFY) (
|
||||
(EFIAPI *PKT_SENT_NOTIFY)(
|
||||
IN EFI_STATUS Status,
|
||||
IN VOID *Context,
|
||||
IN IP_IO_IP_PROTOCOL Sender,
|
||||
@ -604,4 +602,3 @@ IpIoRefreshNeighbor (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -19,7 +19,6 @@ typedef UINT32 IP4_ADDR;
|
||||
typedef UINT32 TCP_SEQNO;
|
||||
typedef UINT16 TCP_PORTNO;
|
||||
|
||||
|
||||
#define NET_ETHER_ADDR_LEN 6
|
||||
#define NET_IFTYPE_ETHERNET 0x01
|
||||
|
||||
@ -94,15 +93,14 @@ typedef UINT16 TCP_PORTNO;
|
||||
//
|
||||
#define MEDIA_STATE_DETECT_TIME_INTERVAL 1000000U
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
//
|
||||
// Ethernet head definition
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 DstMac [NET_ETHER_ADDR_LEN];
|
||||
UINT8 SrcMac [NET_ETHER_ADDR_LEN];
|
||||
UINT8 DstMac[NET_ETHER_ADDR_LEN];
|
||||
UINT8 SrcMac[NET_ETHER_ADDR_LEN];
|
||||
UINT16 EtherType;
|
||||
} ETHER_HEAD;
|
||||
|
||||
@ -141,7 +139,6 @@ typedef struct {
|
||||
IP4_ADDR Dst;
|
||||
} IP4_HEAD;
|
||||
|
||||
|
||||
//
|
||||
// ICMP head definition. Each ICMP message is categorized as either an error
|
||||
// message or query message. Two message types have their own head format.
|
||||
@ -357,7 +354,6 @@ NetDebugOutput (
|
||||
IN UINT8 *Message
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Return the length of the mask.
|
||||
|
||||
@ -454,7 +450,6 @@ NetIp6IsValidUnicast (
|
||||
IN EFI_IPv6_ADDRESS *Ip6
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
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 EFI_IPv4_ADDRESS mZeroIp4Addr;
|
||||
|
||||
#define NET_IS_DIGIT(Ch) (('0' <= (Ch)) && ((Ch) <= '9'))
|
||||
@ -601,7 +595,6 @@ NetRandomInitSeed (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
#define NET_LIST_USER_STRUCT(Entry, Type, Field) \
|
||||
BASE_CR(Entry, Type, Field)
|
||||
|
||||
@ -635,7 +628,6 @@ NetRandomInitSeed (
|
||||
#define NET_LIST_TAIL(ListHead, Type, Field) \
|
||||
NET_LIST_USER_STRUCT((ListHead)->BackLink, Type, Field)
|
||||
|
||||
|
||||
/**
|
||||
Remove the first node entry on the list, and return the removed node entry.
|
||||
|
||||
@ -734,7 +726,7 @@ NetListInsertBefore (
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK) (
|
||||
(EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK)(
|
||||
IN LIST_ENTRY *Entry,
|
||||
IN VOID *Context OPTIONAL
|
||||
);
|
||||
@ -1031,7 +1023,7 @@ NetMapRemoveTail (
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *NET_MAP_CALLBACK) (
|
||||
(EFIAPI *NET_MAP_CALLBACK)(
|
||||
IN NET_MAP *Map,
|
||||
IN NET_MAP_ITEM *Item,
|
||||
IN VOID *Arg
|
||||
@ -1064,10 +1056,10 @@ NetMapIterate (
|
||||
IN VOID *Arg OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Helper functions to implement driver binding and service binding protocols.
|
||||
//
|
||||
|
||||
/**
|
||||
Create a child of the service that is identified by ServiceBindingGuid.
|
||||
|
||||
@ -1310,7 +1302,6 @@ NetLibDetectMediaWaitTimeout (
|
||||
OUT EFI_STATUS *MediaState
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Create an IPv4 device path node.
|
||||
|
||||
@ -1377,7 +1368,6 @@ NetLibCreateIPv6DPathNode (
|
||||
IN UINT16 Protocol
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
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_QUE_SIGNATURE SIGNATURE_32 ('n', 'b', 'q', 'u')
|
||||
|
||||
|
||||
#define NET_PROTO_DATA 64 // Opaque buffer for protocols
|
||||
#define NET_BUF_HEAD 1 // Trim or allocate space from head
|
||||
#define NET_BUF_TAIL 0 // Trim or allocate space from tail
|
||||
@ -1559,12 +1548,12 @@ typedef struct {
|
||||
UINT8 *Bulk; // The block's Data
|
||||
} 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
|
||||
//fragments and other house-keeping stuff for sharing. It
|
||||
//doesn't specify the where actual packet fragment begins.
|
||||
// NET_VECTOR contains several blocks to hold all packet's
|
||||
// fragments and other house-keeping stuff for sharing. It
|
||||
// doesn't specify the where actual packet fragment begins.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
@ -1579,8 +1568,8 @@ typedef struct {
|
||||
} NET_VECTOR;
|
||||
|
||||
//
|
||||
//NET_BLOCK_OP operates on the NET_BLOCK. It specifies
|
||||
//where the actual fragment begins and ends
|
||||
// NET_BLOCK_OP operates on the NET_BLOCK. It specifies
|
||||
// where the actual fragment begins and ends
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 *BlockHead; // Block's head, or the smallest valid Head
|
||||
@ -1596,14 +1585,14 @@ typedef union {
|
||||
} NET_IP_HEAD;
|
||||
|
||||
//
|
||||
//NET_BUF is the buffer manage structure used by the
|
||||
//network stack. Every network packet may be fragmented. The Vector points to
|
||||
//memory blocks used by each fragment, and BlockOp
|
||||
//specifies where each fragment begins and ends.
|
||||
// NET_BUF is the buffer manage structure used by the
|
||||
// network stack. Every network packet may be fragmented. The Vector points to
|
||||
// memory blocks used by each fragment, and BlockOp
|
||||
// specifies where each fragment begins and ends.
|
||||
//
|
||||
//It also contains an opaque area for the protocol to store
|
||||
//per-packet information. Protocol must be careful not
|
||||
//to overwrite the members after that.
|
||||
// It also contains an opaque area for the protocol to store
|
||||
// per-packet information. Protocol must be careful not
|
||||
// to overwrite the members after that.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
@ -1613,7 +1602,7 @@ typedef struct {
|
||||
NET_IP_HEAD Ip; // Network layer header, for fast access
|
||||
TCP_HEAD *Tcp; // Transport layer header, for fast access
|
||||
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
|
||||
|
||||
@ -1623,8 +1612,8 @@ typedef struct {
|
||||
} NET_BUF;
|
||||
|
||||
//
|
||||
//A queue of NET_BUFs. It is a thin extension of
|
||||
//NET_BUF functions.
|
||||
// A queue of NET_BUFs. It is a thin extension of
|
||||
// NET_BUF functions.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
@ -1652,8 +1641,8 @@ typedef struct {
|
||||
EFI_IPv6_ADDRESS SrcIp;
|
||||
EFI_IPv6_ADDRESS DstIp;
|
||||
UINT32 Len;
|
||||
UINT32 Reserved:24;
|
||||
UINT32 NextHeader:8;
|
||||
UINT32 Reserved : 24;
|
||||
UINT32 NextHeader : 8;
|
||||
} NET_IP6_PSEUDO_HDR;
|
||||
#pragma pack()
|
||||
|
||||
@ -1844,7 +1833,7 @@ NetbufReserve (
|
||||
or NULL, if there is no sufficient space.
|
||||
|
||||
**/
|
||||
UINT8*
|
||||
UINT8 *
|
||||
EFIAPI
|
||||
NetbufAllocSpace (
|
||||
IN OUT NET_BUF *Nbuf,
|
||||
@ -2104,7 +2093,6 @@ NetbufQueTrim (
|
||||
IN UINT32 Len
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Flush the net buffer queue.
|
||||
|
||||
|
@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _TCP_IO_H_
|
||||
#define _TCP_IO_H_
|
||||
|
||||
|
||||
#include <Protocol/Tcp4.h>
|
||||
#include <Protocol/Tcp6.h>
|
||||
|
||||
@ -24,7 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
///
|
||||
#define TCP_GET_MAPPING_TIMEOUT 100000000U
|
||||
|
||||
|
||||
typedef struct {
|
||||
EFI_IPv4_ADDRESS LocalIp;
|
||||
EFI_IPv4_ADDRESS SubnetMask;
|
||||
@ -73,7 +71,6 @@ typedef union {
|
||||
EFI_TCP6_LISTEN_TOKEN Tcp6Token;
|
||||
} TCP_IO_LISTEN_TOKEN;
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINT8 TcpVersion;
|
||||
EFI_HANDLE Image;
|
||||
@ -244,4 +241,3 @@ TcpIoReceive (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef struct {
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *UDP_IO_CALLBACK) (
|
||||
(EFIAPI *UDP_IO_CALLBACK)(
|
||||
IN NET_BUF *Packet,
|
||||
IN UDP_END_POINT *EndPoint,
|
||||
IN EFI_STATUS IoStatus,
|
||||
@ -85,8 +85,6 @@ typedef struct {
|
||||
UDP_COMPLETION_TOKEN Token;
|
||||
} UDP_RX_TOKEN;
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// This structure is used internally by UdpIo Library.
|
||||
///
|
||||
@ -167,7 +165,7 @@ struct _UDP_IO {
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *UDP_IO_CONFIG) (
|
||||
(EFIAPI *UDP_IO_CONFIG)(
|
||||
IN UDP_IO *UdpIo,
|
||||
IN VOID *Context
|
||||
);
|
||||
@ -184,7 +182,7 @@ EFI_STATUS
|
||||
**/
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *UDP_IO_TO_CANCEL) (
|
||||
(EFIAPI *UDP_IO_TO_CANCEL)(
|
||||
IN UDP_TX_TOKEN *Token,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef __DPC_H__
|
||||
#define __DPC_H__
|
||||
|
||||
@ -24,7 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
typedef struct _EFI_DPC_PROTOCOL EFI_DPC_PROTOCOL;
|
||||
|
||||
|
||||
/**
|
||||
Invoke a Deferred Procedure Call.
|
||||
|
||||
|
@ -67,7 +67,7 @@ typedef enum {
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI * EDKII_HTTP_CALLBACK) (
|
||||
(EFIAPI *EDKII_HTTP_CALLBACK)(
|
||||
IN EDKII_HTTP_CALLBACK_PROTOCOL *This,
|
||||
IN EDKII_HTTP_CALLBACK_EVENT Event,
|
||||
IN EFI_STATUS EventStatus
|
||||
|
@ -10,6 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -57,7 +58,6 @@ Ip4ComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -136,7 +136,6 @@ Ip4ComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -150,12 +149,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName = {
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ip4ComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ip4ComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Ip4ComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Ip4ComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4DriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
@ -223,7 +221,6 @@ Ip4ComponentNameGetDriverName (
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gIp4ComponentName)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,7 +258,9 @@ UpdateName (
|
||||
if (!Ip4ModeData.IsStarted || !Ip4ModeData.IsConfigured) {
|
||||
UnicodeSPrint (HandleName, sizeof (HandleName), L"IPv4 (Not started)");
|
||||
} else {
|
||||
UnicodeSPrint (HandleName, sizeof (HandleName),
|
||||
UnicodeSPrint (
|
||||
HandleName,
|
||||
sizeof (HandleName),
|
||||
L"IPv4 (SrcIP=%d.%d.%d.%d)",
|
||||
Ip4ModeData.ConfigData.StationAddress.Addr[0],
|
||||
Ip4ModeData.ConfigData.StationAddress.Addr[1],
|
||||
@ -274,6 +273,7 @@ UpdateName (
|
||||
FreeUnicodeStringTable (gIp4ControllerNameTable);
|
||||
gIp4ControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
Status = AddUnicodeString2 (
|
||||
"eng",
|
||||
gIp4ComponentName.SupportedLanguages,
|
||||
@ -425,4 +425,3 @@ Ip4ComponentNameGetControllerName (
|
||||
(BOOLEAN)(This == &gIp4ComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Return the cast type (Unicast/Broadcast) specific to an
|
||||
interface. All the addresses are host byte ordered.
|
||||
@ -31,19 +30,15 @@ Ip4GetNetCast (
|
||||
{
|
||||
if (IpAddr == IpIf->Ip) {
|
||||
return IP4_LOCAL_HOST;
|
||||
|
||||
} else if (IpAddr == IpIf->SubnetBrdcast) {
|
||||
return IP4_SUBNET_BROADCAST;
|
||||
|
||||
} else if (IpAddr == IpIf->NetBrdcast) {
|
||||
return IP4_NET_BROADCAST;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -106,18 +101,16 @@ Ip4GetHostCast (
|
||||
if (Dst == IP4_ALLONE_ADDRESS) {
|
||||
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;
|
||||
}
|
||||
|
||||
} 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 Type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find an interface whose configured IP address is Ip.
|
||||
|
||||
@ -147,7 +140,6 @@ Ip4FindInterface (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find an interface that Ip is on that connected network.
|
||||
|
||||
@ -177,7 +169,6 @@ Ip4FindNet (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find an interface of the service with the same Ip/Netmask pair.
|
||||
|
||||
@ -209,7 +200,6 @@ Ip4FindStationAddress (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the MAC address for a multicast IP address. Call
|
||||
Mnp's McastIpToMac to find the MAC address in stead of
|
||||
@ -237,7 +227,6 @@ Ip4GetMulticastMac (
|
||||
return Mnp->McastIpToMac (Mnp, FALSE, &EfiIp, Mac);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert the multibyte field in IP header's byter order.
|
||||
In spite of its name, it can also be used to convert from
|
||||
@ -262,7 +251,6 @@ Ip4NtohHead (
|
||||
return Head;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Validate that Ip/Netmask pair is OK to be used as station
|
||||
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.
|
||||
//
|
||||
if (Netmask == IP4_ALLZERO_ADDRESS) {
|
||||
return (BOOLEAN) (Ip == IP4_ALLZERO_ADDRESS);
|
||||
return (BOOLEAN)(Ip == IP4_ALLZERO_ADDRESS);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -195,7 +195,6 @@ Ip4NtohHead (
|
||||
IN IP4_HEAD *Head
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Validate that Ip/Netmask pair is OK to be used as station
|
||||
address. Only continuous netmasks are supported. and check
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#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
|
||||
@ -122,13 +122,13 @@ Ip4Config2OnPolicyChanged (
|
||||
//
|
||||
IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
|
||||
if (IpIf == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
RouteTable = Ip4CreateRouteTable ();
|
||||
if (RouteTable == NULL) {
|
||||
Ip4FreeInterface (IpIf, NULL);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
IpSb->DefaultInterface = IpIf;
|
||||
@ -136,7 +136,7 @@ Ip4Config2OnPolicyChanged (
|
||||
IpSb->DefaultRouteTable = RouteTable;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -146,7 +146,6 @@ Ip4Config2OnPolicyChanged (
|
||||
if (NewPolicy == Ip4Config2PolicyDhcp) {
|
||||
Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,7 +165,7 @@ Ip4Config2SignalEvent (
|
||||
IN VOID *Arg
|
||||
)
|
||||
{
|
||||
gBS->SignalEvent ((EFI_EVENT) Item->Key);
|
||||
gBS->SignalEvent ((EFI_EVENT)Item->Key);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -227,7 +226,7 @@ Ip4Config2ReadConfigData (
|
||||
&VarSize,
|
||||
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.
|
||||
// Fall back to the default value.
|
||||
@ -249,15 +248,14 @@ Ip4Config2ReadConfigData (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
for (Index = 0; Index < Variable->DataRecordCount; Index++) {
|
||||
|
||||
CopyMem (&DataRecord, &Variable->DataRecord[Index], sizeof (DataRecord));
|
||||
|
||||
DataItem = &Instance->DataItem[DataRecord.DataType];
|
||||
if (DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED) &&
|
||||
(DataItem->DataSize != DataRecord.DataSize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// 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);
|
||||
|
||||
DataItem->DataSize = DataRecord.DataSize;
|
||||
@ -318,10 +316,8 @@ Ip4Config2WriteConfigData (
|
||||
VarSize = sizeof (IP4_CONFIG2_VARIABLE) - sizeof (IP4_CONFIG2_DATA_RECORD);
|
||||
|
||||
for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) {
|
||||
|
||||
DataItem = &Instance->DataItem[Index];
|
||||
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_VOLATILE) && !EFI_ERROR (DataItem->Status)) {
|
||||
|
||||
VarSize += sizeof (IP4_CONFIG2_DATA_RECORD) + DataItem->DataSize;
|
||||
}
|
||||
}
|
||||
@ -331,28 +327,26 @@ Ip4Config2WriteConfigData (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Heap = (CHAR8 *) Variable + VarSize;
|
||||
Heap = (CHAR8 *)Variable + VarSize;
|
||||
Variable->DataRecordCount = 0;
|
||||
|
||||
for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) {
|
||||
|
||||
DataItem = &Instance->DataItem[Index];
|
||||
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_VOLATILE) && !EFI_ERROR (DataItem->Status)) {
|
||||
|
||||
Heap -= DataItem->DataSize;
|
||||
CopyMem (Heap, DataItem->Data.Ptr, DataItem->DataSize);
|
||||
|
||||
DataRecord = &Variable->DataRecord[Variable->DataRecordCount];
|
||||
DataRecord->DataType = (EFI_IP4_CONFIG2_DATA_TYPE) Index;
|
||||
DataRecord->DataSize = (UINT32) DataItem->DataSize;
|
||||
DataRecord->Offset = (UINT16) (Heap - (CHAR8 *) Variable);
|
||||
DataRecord->DataType = (EFI_IP4_CONFIG2_DATA_TYPE)Index;
|
||||
DataRecord->DataSize = (UINT32)DataItem->DataSize;
|
||||
DataRecord->Offset = (UINT16)(Heap - (CHAR8 *)Variable);
|
||||
|
||||
Variable->DataRecordCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Variable->Checksum = 0;
|
||||
Variable->Checksum = (UINT16) ~NetblockChecksum ((UINT8 *) Variable, (UINT32) VarSize);
|
||||
Variable->Checksum = (UINT16) ~NetblockChecksum ((UINT8 *)Variable, (UINT32)VarSize);
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
VarName,
|
||||
@ -367,7 +361,6 @@ Ip4Config2WriteConfigData (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -410,7 +403,6 @@ Ip4Config2BuildDefaultRouteTable (
|
||||
Count = 0;
|
||||
|
||||
for (Index = IP4_MASK_MAX; Index >= 0; Index--) {
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &(IpSb->DefaultRouteTable->RouteArea[Index])) {
|
||||
RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link);
|
||||
|
||||
@ -420,7 +412,6 @@ Ip4Config2BuildDefaultRouteTable (
|
||||
|
||||
Count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -443,13 +434,13 @@ Ip4Config2OnDhcp4SbInstalled (
|
||||
{
|
||||
IP4_CONFIG2_INSTANCE *Instance;
|
||||
|
||||
Instance = (IP4_CONFIG2_INSTANCE *) Context;
|
||||
Instance = (IP4_CONFIG2_INSTANCE *)Context;
|
||||
|
||||
if ((Instance->Dhcp4Handle != NULL) || (Instance->Policy != Ip4Config2PolicyDhcp)) {
|
||||
//
|
||||
// The DHCP4 child is already created or the policy is no longer DHCP.
|
||||
//
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Ip4StartAutoConfig (Instance);
|
||||
@ -542,7 +533,7 @@ Ip4Config2SetDefaultAddr (
|
||||
Status = gBS->OpenProtocol (
|
||||
IpIf->ArpHandle,
|
||||
&gEfiArpProtocolGuid,
|
||||
(VOID **) &Arp,
|
||||
(VOID **)&Arp,
|
||||
gIp4DriverBinding.DriverBindingHandle,
|
||||
Ip4Instance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -623,7 +614,6 @@ Ip4Config2SetDefaultIf (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release all the DHCP related resources.
|
||||
|
||||
@ -713,7 +703,7 @@ Ip4Config2SetDnsServerWorker (
|
||||
}
|
||||
|
||||
Item = &Instance->DataItem[Ip4Config2DataTypeDnsServer];
|
||||
NewDns = (EFI_IPv4_ADDRESS *) Data;
|
||||
NewDns = (EFI_IPv4_ADDRESS *)Data;
|
||||
OldDns = Item->Data.DnsServers;
|
||||
NewDnsCount = DataSize / sizeof (EFI_IPv4_ADDRESS);
|
||||
OldDnsCount = Item->DataSize / sizeof (EFI_IPv4_ADDRESS);
|
||||
@ -737,6 +727,7 @@ Ip4Config2SetDnsServerWorker (
|
||||
if (Tmp != NULL) {
|
||||
FreePool (Tmp);
|
||||
}
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -773,6 +764,7 @@ Ip4Config2SetDnsServerWorker (
|
||||
if (Item->Data.Ptr != NULL) {
|
||||
FreePool (Item->Data.Ptr);
|
||||
}
|
||||
|
||||
Item->Data.Ptr = Tmp;
|
||||
}
|
||||
|
||||
@ -783,8 +775,6 @@ Ip4Config2SetDnsServerWorker (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Callback function when DHCP process finished. It will save the
|
||||
retrieved IP configure parameter from DHCP to the NVRam.
|
||||
@ -812,7 +802,7 @@ Ip4Config2OnDhcp4Complete (
|
||||
UINT32 OptionCount;
|
||||
EFI_DHCP4_PACKET_OPTION **OptionList;
|
||||
|
||||
Instance = (IP4_CONFIG2_INSTANCE *) Context;
|
||||
Instance = (IP4_CONFIG2_INSTANCE *)Context;
|
||||
ASSERT (Instance->Dhcp4 != NULL);
|
||||
|
||||
//
|
||||
@ -880,7 +870,6 @@ Exit:
|
||||
DispatchDpc ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Start the DHCP configuration for this IP service instance.
|
||||
It will locates the EFI_IP4_CONFIG2_PROTOCOL, then start the
|
||||
@ -934,7 +923,7 @@ Ip4StartAutoConfig (
|
||||
&gEfiDhcp4ServiceBindingProtocolGuid,
|
||||
TPL_CALLBACK,
|
||||
Ip4Config2OnDhcp4SbInstalled,
|
||||
(VOID *) Instance,
|
||||
(VOID *)Instance,
|
||||
&Instance->Registration
|
||||
);
|
||||
}
|
||||
@ -951,7 +940,7 @@ Ip4StartAutoConfig (
|
||||
Status = gBS->OpenProtocol (
|
||||
Instance->Dhcp4Handle,
|
||||
&gEfiDhcp4ProtocolGuid,
|
||||
(VOID **) &Instance->Dhcp4,
|
||||
(VOID **)&Instance->Dhcp4,
|
||||
IpSb->Image,
|
||||
IpSb->Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -1048,8 +1037,6 @@ Ip4StartAutoConfig (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The work function is to get the interface information of the communication
|
||||
device this IP4_CONFIG2_INSTANCE manages.
|
||||
@ -1096,7 +1083,7 @@ Ip4Config2GetIfInfo (
|
||||
// Copy the fixed size part of the interface info.
|
||||
//
|
||||
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));
|
||||
|
||||
//
|
||||
@ -1111,7 +1098,7 @@ Ip4Config2GetIfInfo (
|
||||
|
||||
if (IpSb->DefaultRouteTable != NULL) {
|
||||
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);
|
||||
}
|
||||
@ -1150,14 +1137,14 @@ Ip4Config2SetPolicy (
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
NewPolicy = *((EFI_IP4_CONFIG2_POLICY *) Data);
|
||||
NewPolicy = *((EFI_IP4_CONFIG2_POLICY *)Data);
|
||||
|
||||
if (NewPolicy >= Ip4Config2PolicyMax) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (NewPolicy == Instance->Policy) {
|
||||
if (NewPolicy != Ip4Config2PolicyDhcp || Instance->DhcpSuccess) {
|
||||
if ((NewPolicy != Ip4Config2PolicyDhcp) || Instance->DhcpSuccess) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
} else {
|
||||
@ -1169,6 +1156,7 @@ Ip4Config2SetPolicy (
|
||||
if (DataItem->Data.Ptr != NULL) {
|
||||
FreePool (DataItem->Data.Ptr);
|
||||
}
|
||||
|
||||
DataItem->Data.Ptr = NULL;
|
||||
DataItem->DataSize = 0;
|
||||
DataItem->Status = EFI_NOT_FOUND;
|
||||
@ -1178,6 +1166,7 @@ Ip4Config2SetPolicy (
|
||||
if (DataItem->Data.Ptr != NULL) {
|
||||
FreePool (DataItem->Data.Ptr);
|
||||
}
|
||||
|
||||
DataItem->Data.Ptr = NULL;
|
||||
DataItem->DataSize = 0;
|
||||
DataItem->Status = EFI_NOT_FOUND;
|
||||
@ -1187,6 +1176,7 @@ Ip4Config2SetPolicy (
|
||||
if (DataItem->Data.Ptr != NULL) {
|
||||
FreePool (DataItem->Data.Ptr);
|
||||
}
|
||||
|
||||
DataItem->Data.Ptr = NULL;
|
||||
DataItem->DataSize = 0;
|
||||
DataItem->Status = EFI_NOT_FOUND;
|
||||
@ -1279,8 +1269,8 @@ Ip4Config2SetManualAddress (
|
||||
|
||||
DataItem = &Instance->DataItem[Ip4Config2DataTypeManualAddress];
|
||||
|
||||
if (Data != NULL && DataSize != 0) {
|
||||
NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data);
|
||||
if ((Data != NULL) && (DataSize != 0)) {
|
||||
NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *)Data);
|
||||
|
||||
StationAddress = EFI_NTOHL (NewAddress.Address);
|
||||
SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
|
||||
@ -1314,10 +1304,11 @@ Ip4Config2SetManualAddress (
|
||||
|
||||
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) {
|
||||
FreePool (Ptr);
|
||||
}
|
||||
|
||||
DataItem->Data.Ptr = NULL;
|
||||
}
|
||||
} else {
|
||||
@ -1327,6 +1318,7 @@ Ip4Config2SetManualAddress (
|
||||
if (DataItem->Data.Ptr != NULL) {
|
||||
FreePool (DataItem->Data.Ptr);
|
||||
}
|
||||
|
||||
DataItem->Data.Ptr = NULL;
|
||||
DataItem->DataSize = 0;
|
||||
DataItem->Status = EFI_NOT_FOUND;
|
||||
@ -1370,7 +1362,7 @@ Ip4Config2SetManualAddress (
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@ -1455,14 +1447,15 @@ Ip4Config2SetGateway (
|
||||
OneRemoved = TRUE;
|
||||
}
|
||||
|
||||
if (Data != NULL && DataSize != 0) {
|
||||
NewGateway = (EFI_IPv4_ADDRESS *) Data;
|
||||
if ((Data != NULL) && (DataSize != 0)) {
|
||||
NewGateway = (EFI_IPv4_ADDRESS *)Data;
|
||||
NewGatewayCount = DataSize / sizeof (EFI_IPv4_ADDRESS);
|
||||
for (Index1 = 0; Index1 < NewGatewayCount; Index1++) {
|
||||
CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR));
|
||||
|
||||
if ((IpSb->DefaultInterface->SubnetMask != 0) &&
|
||||
!NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->SubnetMask)) {
|
||||
!NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->SubnetMask))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1505,6 +1498,7 @@ Ip4Config2SetGateway (
|
||||
if (DataItem->Data.Ptr != NULL) {
|
||||
FreePool (DataItem->Data.Ptr);
|
||||
}
|
||||
|
||||
DataItem->Data.Ptr = Tmp;
|
||||
}
|
||||
|
||||
@ -1519,6 +1513,7 @@ Ip4Config2SetGateway (
|
||||
if (DataItem->Data.Ptr != NULL) {
|
||||
FreePool (DataItem->Data.Ptr);
|
||||
}
|
||||
|
||||
DataItem->Data.Ptr = NULL;
|
||||
DataItem->DataSize = 0;
|
||||
DataItem->Status = EFI_NOT_FOUND;
|
||||
@ -1572,7 +1567,7 @@ Ip4Config2SetDnsServer (
|
||||
REMOVE_DATA_ATTRIB (Item->Attribute, DATA_ATTRIB_VOLATILE);
|
||||
}
|
||||
|
||||
if (Data != NULL && DataSize != 0) {
|
||||
if ((Data != NULL) && (DataSize != 0)) {
|
||||
Status = Ip4Config2SetDnsServerWorker (Instance, DataSize, Data);
|
||||
} else {
|
||||
//
|
||||
@ -1581,6 +1576,7 @@ Ip4Config2SetDnsServer (
|
||||
if (Item->Data.Ptr != NULL) {
|
||||
FreePool (Item->Data.Ptr);
|
||||
}
|
||||
|
||||
Item->Data.Ptr = NULL;
|
||||
Item->DataSize = 0;
|
||||
Item->Status = EFI_NOT_FOUND;
|
||||
@ -1615,8 +1611,6 @@ Ip4Config2InitIfInfo (
|
||||
CopyMem (&IfInfo->HwAddress, &IpSb->SnpMode.CurrentAddress, IfInfo->HwAddressSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Set the configuration for the EFI IPv4 network stack running on the communication
|
||||
device this EFI_IP4_CONFIG2_PROTOCOL instance manages.
|
||||
@ -1678,7 +1672,7 @@ EfiIp4Config2SetData (
|
||||
IP4_CONFIG2_INSTANCE *Instance;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1690,19 +1684,16 @@ EfiIp4Config2SetData (
|
||||
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
|
||||
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
|
||||
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
Status = Instance->DataItem[DataType].Status;
|
||||
if (Status != EFI_NOT_READY) {
|
||||
|
||||
if (Instance->DataItem[DataType].SetData == NULL) {
|
||||
//
|
||||
// This type of data is readonly.
|
||||
//
|
||||
Status = EFI_WRITE_PROTECTED;
|
||||
} else {
|
||||
|
||||
Status = Instance->DataItem[DataType].SetData (Instance, DataSize, Data);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
@ -1798,9 +1789,7 @@ EfiIp4Config2GetData (
|
||||
|
||||
Status = Instance->DataItem[DataType].Status;
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
if (DataItem->GetData != NULL) {
|
||||
|
||||
Status = DataItem->GetData (Instance, DataSize, Data);
|
||||
} else if (*DataSize < Instance->DataItem[DataType].DataSize) {
|
||||
//
|
||||
@ -1809,7 +1798,6 @@ EfiIp4Config2GetData (
|
||||
*DataSize = Instance->DataItem[DataType].DataSize;
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
} else {
|
||||
|
||||
*DataSize = Instance->DataItem[DataType].DataSize;
|
||||
CopyMem (Data, Instance->DataItem[DataType].Data.Ptr, *DataSize);
|
||||
}
|
||||
@ -1874,16 +1862,12 @@ EfiIp4Config2RegisterDataNotify (
|
||||
//
|
||||
Item = NetMapFindKey (EventMap, Event);
|
||||
if (Item == NULL) {
|
||||
|
||||
Status = NetMapInsertTail (EventMap, Event, NULL);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Status = EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
@ -1934,11 +1918,9 @@ EfiIp4Config2UnregisterDataNotify (
|
||||
|
||||
Item = NetMapFindKey (&Instance->DataItem[DataType].EventMap, Event);
|
||||
if (Item != NULL) {
|
||||
|
||||
NetMapRemoveItem (&Instance->DataItem[DataType].EventMap, Item, NULL);
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -1969,12 +1951,10 @@ Ip4Config2InitInstance (
|
||||
UINT16 IfIndex;
|
||||
IP4_CONFIG2_DATA_ITEM *DataItem;
|
||||
|
||||
|
||||
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
|
||||
|
||||
Instance->Signature = IP4_CONFIG2_INSTANCE_SIGNATURE;
|
||||
|
||||
|
||||
//
|
||||
// Determine the index of this interface.
|
||||
//
|
||||
@ -2002,7 +1982,6 @@ Ip4Config2InitInstance (
|
||||
NetMapInit (&Instance->DataItem[Index].EventMap);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Initialize each data type: associate storage and set data size for the
|
||||
// fixed size data types, hook the SetData function, set the data attribute.
|
||||
@ -2060,7 +2039,6 @@ Ip4Config2InitInstance (
|
||||
return Ip4Config2FormInit (Instance);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release an IP4_CONFIG2_INSTANCE.
|
||||
|
||||
@ -2080,11 +2058,10 @@ Ip4Config2CleanInstance (
|
||||
}
|
||||
|
||||
if (!Instance->Configured) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Instance->Dhcp4Handle != NULL) {
|
||||
|
||||
Ip4Config2DestroyDhcp4 (Instance);
|
||||
}
|
||||
|
||||
@ -2097,13 +2074,13 @@ Ip4Config2CleanInstance (
|
||||
}
|
||||
|
||||
for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) {
|
||||
|
||||
DataItem = &Instance->DataItem[Index];
|
||||
|
||||
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED)) {
|
||||
if (DataItem->Data.Ptr != NULL) {
|
||||
FreePool (DataItem->Data.Ptr);
|
||||
}
|
||||
|
||||
DataItem->Data.Ptr = NULL;
|
||||
DataItem->DataSize = 0;
|
||||
}
|
||||
@ -2131,7 +2108,7 @@ Ip4AutoReconfigCallBackDpc (
|
||||
{
|
||||
IP4_SERVICE *IpSb;
|
||||
|
||||
IpSb = (IP4_SERVICE *) Context;
|
||||
IpSb = (IP4_SERVICE *)Context;
|
||||
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
|
||||
|
||||
if (IpSb->State > IP4_SERVICE_UNSTARTED) {
|
||||
@ -2142,10 +2119,9 @@ Ip4AutoReconfigCallBackDpc (
|
||||
|
||||
Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Request Ip4AutoReconfigCallBackDpc as a DPC at TPL_CALLBACK.
|
||||
|
||||
@ -2165,4 +2141,3 @@ Ip4AutoReconfigCallBack (
|
||||
//
|
||||
QueueDpc (TPL_CALLBACK, Ip4AutoReconfigCallBackDpc, Context);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ GetSubnetMaskPrefixLength (
|
||||
Len++;
|
||||
}
|
||||
|
||||
return (UINT8) (32 - Len);
|
||||
return (UINT8)(32 - Len);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +73,6 @@ Ip4Config2StrToIp (
|
||||
Index = 0;
|
||||
|
||||
while (*Str != L'\0') {
|
||||
|
||||
if (Index > 3) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -88,7 +87,7 @@ Ip4Config2StrToIp (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Ip->Addr[Index] = (UINT8) Number;
|
||||
Ip->Addr[Index] = (UINT8)Number;
|
||||
|
||||
if ((*Str != L'\0') && (*Str != L'.')) {
|
||||
//
|
||||
@ -178,7 +177,7 @@ Ip4Config2StrToIpList (
|
||||
//
|
||||
// Allocate buffer for IpList.
|
||||
//
|
||||
*PtrIpList = AllocateZeroPool(*IpCount * sizeof(EFI_IPv4_ADDRESS));
|
||||
*PtrIpList = AllocateZeroPool (*IpCount * sizeof (EFI_IPv4_ADDRESS));
|
||||
if (*PtrIpList == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -189,21 +188,21 @@ Ip4Config2StrToIpList (
|
||||
Index = 0;
|
||||
while (*(Str + Index) != L'\0') {
|
||||
if (*(Str + Index) == L' ') {
|
||||
if(!SpaceTag) {
|
||||
StrTemp = AllocateZeroPool((EndIndex - BeginIndex + 1) * sizeof(CHAR16));
|
||||
if (!SpaceTag) {
|
||||
StrTemp = AllocateZeroPool ((EndIndex - BeginIndex + 1) * sizeof (CHAR16));
|
||||
if (StrTemp == NULL) {
|
||||
FreePool(*PtrIpList);
|
||||
FreePool (*PtrIpList);
|
||||
*PtrIpList = NULL;
|
||||
*IpCount = 0;
|
||||
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';
|
||||
|
||||
if (Ip4Config2StrToIp (StrTemp, &((*PtrIpList)[IpIndex])) != EFI_SUCCESS) {
|
||||
FreePool(StrTemp);
|
||||
FreePool(*PtrIpList);
|
||||
FreePool (StrTemp);
|
||||
FreePool (*PtrIpList);
|
||||
*PtrIpList = NULL;
|
||||
*IpCount = 0;
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -212,7 +211,7 @@ Ip4Config2StrToIpList (
|
||||
BeginIndex = EndIndex;
|
||||
IpIndex++;
|
||||
|
||||
FreePool(StrTemp);
|
||||
FreePool (StrTemp);
|
||||
}
|
||||
|
||||
BeginIndex++;
|
||||
@ -227,26 +226,26 @@ Ip4Config2StrToIpList (
|
||||
|
||||
if (*(Str + Index) == L'\0') {
|
||||
if (!SpaceTag) {
|
||||
StrTemp = AllocateZeroPool((EndIndex - BeginIndex + 1) * sizeof(CHAR16));
|
||||
StrTemp = AllocateZeroPool ((EndIndex - BeginIndex + 1) * sizeof (CHAR16));
|
||||
if (StrTemp == NULL) {
|
||||
FreePool(*PtrIpList);
|
||||
FreePool (*PtrIpList);
|
||||
*PtrIpList = NULL;
|
||||
*IpCount = 0;
|
||||
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';
|
||||
|
||||
if (Ip4Config2StrToIp (StrTemp, &((*PtrIpList)[IpIndex])) != EFI_SUCCESS) {
|
||||
FreePool(StrTemp);
|
||||
FreePool(*PtrIpList);
|
||||
FreePool (StrTemp);
|
||||
FreePool (*PtrIpList);
|
||||
*PtrIpList = NULL;
|
||||
*IpCount = 0;
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FreePool(StrTemp);
|
||||
FreePool (StrTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -278,7 +277,6 @@ Ip4Config2IpToStr (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert the IPv4 address list into string consists of several decimal
|
||||
dotted IPv4 addresses separated by space.
|
||||
@ -311,10 +309,10 @@ Ip4Config2IpListToStr (
|
||||
TempStr = NULL;
|
||||
TempIp = NULL;
|
||||
|
||||
for (Index = 0; Index < IpCount; Index ++) {
|
||||
for (Index = 0; Index < IpCount; Index++) {
|
||||
TempIp = Ip + Index;
|
||||
if (TempStr == NULL) {
|
||||
TempStr = AllocateZeroPool(2 * IP4_STR_MAX_SIZE);
|
||||
TempStr = AllocateZeroPool (2 * IP4_STR_MAX_SIZE);
|
||||
if (TempStr == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -330,13 +328,14 @@ Ip4Config2IpListToStr (
|
||||
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 (Index == IpCount - 1) {
|
||||
Str[StrIndex++] = L'\0';
|
||||
} else {
|
||||
Str[StrIndex++] = L' ';
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
Str[StrIndex++] = *(TempStr + TemIndex);
|
||||
@ -345,7 +344,7 @@ Ip4Config2IpListToStr (
|
||||
}
|
||||
|
||||
if (TempStr != NULL) {
|
||||
FreePool(TempStr);
|
||||
FreePool (TempStr);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -365,7 +364,7 @@ Ip4Config2ManualAddressNotify (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
*((BOOLEAN *) Context) = TRUE;
|
||||
*((BOOLEAN *)Context) = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -497,10 +496,10 @@ Ip4Config2ConvertConfigNvDataToIfrNvData (
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
DnsCount = (UINT32) (DnsSize / sizeof (EFI_IPv4_ADDRESS));
|
||||
DnsCount = (UINT32)(DnsSize / sizeof (EFI_IPv4_ADDRESS));
|
||||
|
||||
if (DnsSize > 0) {
|
||||
DnsAddress = AllocateZeroPool(DnsSize);
|
||||
DnsAddress = AllocateZeroPool (DnsSize);
|
||||
if (DnsAddress == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Exit;
|
||||
@ -525,11 +524,11 @@ Ip4Config2ConvertConfigNvDataToIfrNvData (
|
||||
Exit:
|
||||
|
||||
if (DnsAddress != NULL) {
|
||||
FreePool(DnsAddress);
|
||||
FreePool (DnsAddress);
|
||||
}
|
||||
|
||||
if (Ip4Info != NULL) {
|
||||
FreePool(Ip4Info);
|
||||
FreePool (Ip4Info);
|
||||
}
|
||||
|
||||
return Status;
|
||||
@ -582,9 +581,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
TimeoutEvent = NULL;
|
||||
SetAddressEvent = NULL;
|
||||
|
||||
|
||||
|
||||
if (Instance == NULL || IfrFormNvData == NULL) {
|
||||
if ((Instance == NULL) || (IfrFormNvData == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -601,7 +598,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
sizeof (EFI_IP4_CONFIG2_POLICY),
|
||||
&Ip4NvData->Policy
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
@ -618,26 +615,28 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);
|
||||
if (EFI_ERROR (Status) ||
|
||||
(SubnetMask.Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) ||
|
||||
!Ip4StationAddressValid (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])))
|
||||
{
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);
|
||||
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);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount);
|
||||
if (!EFI_ERROR (Status) && DnsCount > 0) {
|
||||
for (Index = 0; Index < DnsCount; Index ++) {
|
||||
if (!EFI_ERROR (Status) && (DnsCount > 0)) {
|
||||
for (Index = 0; Index < DnsCount; Index++) {
|
||||
CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));
|
||||
if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);
|
||||
FreePool(DnsAddress);
|
||||
FreePool (DnsAddress);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
@ -648,37 +647,43 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
}
|
||||
|
||||
if (Ip4NvData->ManualAddress != NULL) {
|
||||
FreePool(Ip4NvData->ManualAddress);
|
||||
FreePool (Ip4NvData->ManualAddress);
|
||||
}
|
||||
|
||||
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 (DnsAddress != NULL) {
|
||||
FreePool(DnsAddress);
|
||||
FreePool (DnsAddress);
|
||||
}
|
||||
|
||||
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) {
|
||||
FreePool(Ip4NvData->GatewayAddress);
|
||||
FreePool (Ip4NvData->GatewayAddress);
|
||||
}
|
||||
|
||||
Ip4NvData->GatewayAddressCount = 1;
|
||||
Ip4NvData->GatewayAddress = AllocateZeroPool(sizeof(EFI_IPv4_ADDRESS));
|
||||
Ip4NvData->GatewayAddress = AllocateZeroPool (sizeof (EFI_IPv4_ADDRESS));
|
||||
if (Ip4NvData->GatewayAddress == NULL) {
|
||||
if (DnsAddress != NULL) {
|
||||
FreePool(DnsAddress);
|
||||
FreePool (DnsAddress);
|
||||
}
|
||||
|
||||
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) {
|
||||
FreePool(Ip4NvData->DnsAddress);
|
||||
FreePool (Ip4NvData->DnsAddress);
|
||||
}
|
||||
Ip4NvData->DnsAddressCount = (UINT32) DnsCount;
|
||||
|
||||
Ip4NvData->DnsAddressCount = (UINT32)DnsCount;
|
||||
Ip4NvData->DnsAddress = DnsAddress;
|
||||
|
||||
//
|
||||
@ -690,7 +695,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
sizeof (EFI_IP4_CONFIG2_POLICY),
|
||||
&Ip4NvData->Policy
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -738,7 +743,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
Ip4Cfg2,
|
||||
Ip4Config2DataTypeManualAddress,
|
||||
DataSize,
|
||||
(VOID *) Ip4NvData->ManualAddress
|
||||
(VOID *)Ip4NvData->ManualAddress
|
||||
);
|
||||
|
||||
if (Status == EFI_NOT_READY) {
|
||||
@ -777,7 +782,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
//
|
||||
// Set DNS addresses.
|
||||
//
|
||||
if (Ip4NvData->DnsAddressCount > 0 && Ip4NvData->DnsAddress != NULL) {
|
||||
if ((Ip4NvData->DnsAddressCount > 0) && (Ip4NvData->DnsAddress != NULL)) {
|
||||
DataSize = Ip4NvData->DnsAddressCount * sizeof (EFI_IPv4_ADDRESS);
|
||||
Status = Ip4Cfg2->SetData (
|
||||
Ip4Cfg2,
|
||||
@ -880,7 +885,7 @@ Ip4FormExtractConfig (
|
||||
UINTN Size;
|
||||
UINTN BufferSize;
|
||||
|
||||
if (Progress == NULL || Results == NULL) {
|
||||
if ((Progress == NULL) || (Results == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -891,8 +896,8 @@ Ip4FormExtractConfig (
|
||||
Size = 0;
|
||||
AllocatedRequest = FALSE;
|
||||
ConfigRequest = Request;
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This);
|
||||
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private);
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
|
||||
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
|
||||
BufferSize = sizeof (IP4_CONFIG2_IFR_NVDATA);
|
||||
*Progress = Request;
|
||||
|
||||
@ -920,6 +925,7 @@ Ip4FormExtractConfig (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
AllocatedRequest = TRUE;
|
||||
|
||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||
@ -932,7 +938,7 @@ Ip4FormExtractConfig (
|
||||
Status = gHiiConfigRouting->BlockToConfig (
|
||||
gHiiConfigRouting,
|
||||
ConfigRequest,
|
||||
(UINT8 *) IfrFormNvData,
|
||||
(UINT8 *)IfrFormNvData,
|
||||
BufferSize,
|
||||
&FormResult,
|
||||
Progress
|
||||
@ -953,7 +959,7 @@ Ip4FormExtractConfig (
|
||||
}
|
||||
}
|
||||
|
||||
if (Request == NULL || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
|
||||
if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
|
||||
*Results = FormResult;
|
||||
} else {
|
||||
return EFI_NOT_FOUND;
|
||||
@ -1022,14 +1028,14 @@ Ip4FormRouteConfig (
|
||||
Status = EFI_SUCCESS;
|
||||
IfrFormNvData = NULL;
|
||||
|
||||
if (Configuration == NULL || Progress == NULL) {
|
||||
if ((Configuration == NULL) || (Progress == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Progress = Configuration;
|
||||
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This);
|
||||
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private);
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
|
||||
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
|
||||
|
||||
//
|
||||
// Check Routing data in <ConfigHdr>.
|
||||
@ -1048,7 +1054,7 @@ Ip4FormRouteConfig (
|
||||
Status = gHiiConfigRouting->ConfigToBlock (
|
||||
gHiiConfigRouting,
|
||||
Configuration,
|
||||
(UINT8 *) IfrFormNvData,
|
||||
(UINT8 *)IfrFormNvData,
|
||||
&BufferSize,
|
||||
Progress
|
||||
);
|
||||
@ -1059,7 +1065,7 @@ Ip4FormRouteConfig (
|
||||
Status = gHiiConfigRouting->ConfigToBlock (
|
||||
gHiiConfigRouting,
|
||||
Configuration,
|
||||
(UINT8 *) IfrFormNvData,
|
||||
(UINT8 *)IfrFormNvData,
|
||||
&BufferSize,
|
||||
Progress
|
||||
);
|
||||
@ -1073,7 +1079,6 @@ Ip4FormRouteConfig (
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1133,8 +1138,8 @@ Ip4FormCallback (
|
||||
DnsAddress = NULL;
|
||||
|
||||
if (Action == EFI_BROWSER_ACTION_CHANGED) {
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This);
|
||||
Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private);
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
|
||||
Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
|
||||
|
||||
IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG2_IFR_NVDATA));
|
||||
if (IfrFormNvData == NULL) {
|
||||
@ -1144,7 +1149,7 @@ Ip4FormCallback (
|
||||
//
|
||||
// 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);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -1158,6 +1163,7 @@ Ip4FormCallback (
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case KEY_SUBNET_MASK:
|
||||
@ -1166,20 +1172,22 @@ Ip4FormCallback (
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case KEY_GATE_WAY:
|
||||
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);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case KEY_DNS:
|
||||
Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount);
|
||||
if (!EFI_ERROR (Status) && DnsCount > 0) {
|
||||
for (Index = 0; Index < DnsCount; Index ++) {
|
||||
if (!EFI_ERROR (Status) && (DnsCount > 0)) {
|
||||
for (Index = 0; Index < DnsCount; Index++) {
|
||||
CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));
|
||||
if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);
|
||||
@ -1193,9 +1201,10 @@ Ip4FormCallback (
|
||||
}
|
||||
}
|
||||
|
||||
if(DnsAddress != NULL) {
|
||||
FreePool(DnsAddress);
|
||||
if (DnsAddress != NULL) {
|
||||
FreePool (DnsAddress);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case KEY_SAVE_CHANGES:
|
||||
@ -1255,7 +1264,7 @@ Ip4Config2FormInit (
|
||||
Status = gBS->HandleProtocol (
|
||||
IpSb->Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath
|
||||
(VOID **)&ParentDevicePath
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -1275,7 +1284,7 @@ Ip4Config2FormInit (
|
||||
SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
|
||||
CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
|
||||
ParentDevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
|
||||
);
|
||||
if (CallbackInfo->HiiVendorDevicePath == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -1306,7 +1315,7 @@ Ip4Config2FormInit (
|
||||
Status = gBS->OpenProtocol (
|
||||
IpSb->Controller,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
(VOID **) &MnpSb,
|
||||
(VOID **)&MnpSb,
|
||||
IpSb->Image,
|
||||
CallbackInfo->ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1426,16 +1435,16 @@ Ip4Config2FormUnload (
|
||||
|
||||
Ip4NvData = &Instance->Ip4NvData;
|
||||
|
||||
if(Ip4NvData->ManualAddress != NULL) {
|
||||
FreePool(Ip4NvData->ManualAddress);
|
||||
if (Ip4NvData->ManualAddress != NULL) {
|
||||
FreePool (Ip4NvData->ManualAddress);
|
||||
}
|
||||
|
||||
if(Ip4NvData->GatewayAddress != NULL) {
|
||||
FreePool(Ip4NvData->GatewayAddress);
|
||||
if (Ip4NvData->GatewayAddress != NULL) {
|
||||
FreePool (Ip4NvData->GatewayAddress);
|
||||
}
|
||||
|
||||
if(Ip4NvData->DnsAddress != NULL) {
|
||||
FreePool(Ip4NvData->DnsAddress);
|
||||
if (Ip4NvData->DnsAddress != NULL) {
|
||||
FreePool (Ip4NvData->DnsAddress);
|
||||
}
|
||||
|
||||
Ip4NvData->ManualAddressCount = 0;
|
||||
|
@ -36,12 +36,13 @@ IpSec2InstalledCallback (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Test if protocol was even found.
|
||||
// Notification function will be called at least once.
|
||||
//
|
||||
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.
|
||||
//
|
||||
@ -114,9 +115,9 @@ Ip4DriverEntryPoint (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL * This,
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@ -170,7 +171,6 @@ Ip4CleanService (
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Create a new IP4 driver service binding private instance.
|
||||
|
||||
@ -316,7 +316,7 @@ Ip4CreateService (
|
||||
Status = gBS->OpenProtocol (
|
||||
IpSb->MnpChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
(VOID **) &IpSb->Mnp,
|
||||
(VOID **)&IpSb->Mnp,
|
||||
ImageHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -375,6 +375,7 @@ Ip4CreateService (
|
||||
//
|
||||
IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN;
|
||||
}
|
||||
|
||||
IpSb->OldMaxPacketSize = IpSb->MaxPacketSize;
|
||||
*Service = IpSb;
|
||||
|
||||
@ -387,7 +388,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up a IP4 service binding instance. It will release all
|
||||
the resource allocated by the instance. The instance may be
|
||||
@ -502,14 +502,14 @@ Ip4DestroyChildEntryInHandleBuffer (
|
||||
UINTN NumberOfChildren;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
|
||||
if (Entry == NULL || Context == NULL) {
|
||||
if ((Entry == NULL) || (Context == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);
|
||||
ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
|
||||
NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
|
||||
ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
|
||||
NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
|
||||
|
||||
if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
|
||||
return EFI_SUCCESS;
|
||||
@ -617,11 +617,11 @@ Ip4DriverBindingStart (
|
||||
DataItem->DataSize,
|
||||
DataItem->Data.Ptr
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto UNINSTALL_PROTOCOL;
|
||||
}
|
||||
|
||||
if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) {
|
||||
if ((Index == Ip4Config2DataTypePolicy) && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -634,7 +634,7 @@ Ip4DriverBindingStart (
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
@ -673,7 +673,6 @@ FREE_SERVICE:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service DisconnectController(). In order to
|
||||
@ -731,7 +730,7 @@ Ip4DriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiIp4ServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
NicHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -758,7 +757,6 @@ Ip4DriverBindingStop (
|
||||
NULL
|
||||
);
|
||||
} else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {
|
||||
|
||||
//
|
||||
// The ARP protocol for the default interface is being uninstalled and all
|
||||
// its IP child handles should have been destroyed before. So, release the
|
||||
@ -772,10 +770,11 @@ Ip4DriverBindingStop (
|
||||
if (IpIf == NULL) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
RouteTable = Ip4CreateRouteTable ();
|
||||
if (RouteTable == NULL) {
|
||||
Ip4FreeInterface (IpIf, NULL);
|
||||
goto ON_ERROR;;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
IpSb->DefaultInterface = IpIf;
|
||||
@ -784,7 +783,6 @@ Ip4DriverBindingStop (
|
||||
Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
|
||||
|
||||
IpSb->State = IP4_SERVICE_UNSTARTED;
|
||||
|
||||
} else if (IsListEmpty (&IpSb->Children)) {
|
||||
State = IpSb->State;
|
||||
//
|
||||
@ -809,6 +807,7 @@ Ip4DriverBindingStop (
|
||||
FreeUnicodeStringTable (gIp4ControllerNameTable);
|
||||
gIp4ControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
FreePool (IpSb);
|
||||
}
|
||||
|
||||
@ -816,7 +815,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
@ -884,7 +882,7 @@ Ip4ServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
IpSb->MnpChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
(VOID **) &Mnp,
|
||||
(VOID **)&Mnp,
|
||||
gIp4DriverBinding.DriverBindingHandle,
|
||||
IpInstance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -913,7 +911,6 @@ Ip4ServiceBindingCreateChild (
|
||||
ON_ERROR:
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
Ip4CleanProtocol (IpInstance);
|
||||
|
||||
FreePool (IpInstance);
|
||||
@ -922,7 +919,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
@ -966,7 +962,7 @@ Ip4ServiceBindingDestroyChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiIp4ProtocolGuid,
|
||||
(VOID **) &Ip4,
|
||||
(VOID **)&Ip4,
|
||||
gIp4DriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1007,7 +1003,7 @@ Ip4ServiceBindingDestroyChild (
|
||||
ChildHandle
|
||||
);
|
||||
|
||||
if (IpInstance->Interface != NULL && IpInstance->Interface->Arp != NULL) {
|
||||
if ((IpInstance->Interface != NULL) && (IpInstance->Interface->Arp != NULL)) {
|
||||
gBS->CloseProtocol (
|
||||
IpInstance->Interface->ArpHandle,
|
||||
&gEfiArpProtocolGuid,
|
||||
|
@ -24,6 +24,7 @@ typedef struct {
|
||||
//
|
||||
// Function prototype for the driver's entry point
|
||||
//
|
||||
|
||||
/**
|
||||
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
|
||||
@ -49,6 +50,7 @@ Ip4DriverEntryPoint (
|
||||
//
|
||||
// Function prototypes for the Driver Binding Protocol
|
||||
//
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. This service
|
||||
is called by the EFI boot service ConnectController(). In
|
||||
@ -70,9 +72,9 @@ Ip4DriverEntryPoint (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL * This,
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
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
|
||||
EFIAPI
|
||||
Ip4DriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL * This,
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
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
|
||||
//
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
@ -181,4 +184,5 @@ Ip4ServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -8,61 +8,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
IP4_ICMP_CLASS
|
||||
mIcmpClass[] = {
|
||||
{ICMP_ECHO_REPLY, ICMP_QUERY_MESSAGE },
|
||||
{1, ICMP_INVALID_MESSAGE},
|
||||
{2, ICMP_INVALID_MESSAGE},
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_ERROR_MESSAGE },
|
||||
{ICMP_SOURCE_QUENCH, ICMP_ERROR_MESSAGE },
|
||||
{ICMP_REDIRECT, ICMP_ERROR_MESSAGE },
|
||||
{6, ICMP_INVALID_MESSAGE},
|
||||
{7, ICMP_INVALID_MESSAGE},
|
||||
{ICMP_ECHO_REQUEST, ICMP_QUERY_MESSAGE },
|
||||
{9, ICMP_INVALID_MESSAGE},
|
||||
{10, ICMP_INVALID_MESSAGE},
|
||||
{ICMP_TIME_EXCEEDED, ICMP_ERROR_MESSAGE },
|
||||
{ICMP_PARAMETER_PROBLEM, ICMP_ERROR_MESSAGE },
|
||||
{ICMP_TIMESTAMP , ICMP_QUERY_MESSAGE },
|
||||
{14, ICMP_INVALID_MESSAGE},
|
||||
{ICMP_INFO_REQUEST , ICMP_QUERY_MESSAGE },
|
||||
{ICMP_INFO_REPLY , ICMP_QUERY_MESSAGE },
|
||||
mIcmpClass[] = {
|
||||
{ ICMP_ECHO_REPLY, ICMP_QUERY_MESSAGE },
|
||||
{ 1, ICMP_INVALID_MESSAGE },
|
||||
{ 2, ICMP_INVALID_MESSAGE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_ERROR_MESSAGE },
|
||||
{ ICMP_SOURCE_QUENCH, ICMP_ERROR_MESSAGE },
|
||||
{ ICMP_REDIRECT, ICMP_ERROR_MESSAGE },
|
||||
{ 6, ICMP_INVALID_MESSAGE },
|
||||
{ 7, ICMP_INVALID_MESSAGE },
|
||||
{ ICMP_ECHO_REQUEST, ICMP_QUERY_MESSAGE },
|
||||
{ 9, ICMP_INVALID_MESSAGE },
|
||||
{ 10, ICMP_INVALID_MESSAGE },
|
||||
{ ICMP_TIME_EXCEEDED, ICMP_ERROR_MESSAGE },
|
||||
{ ICMP_PARAMETER_PROBLEM, ICMP_ERROR_MESSAGE },
|
||||
{ ICMP_TIMESTAMP, ICMP_QUERY_MESSAGE },
|
||||
{ 14, ICMP_INVALID_MESSAGE },
|
||||
{ ICMP_INFO_REQUEST, ICMP_QUERY_MESSAGE },
|
||||
{ ICMP_INFO_REPLY, ICMP_QUERY_MESSAGE },
|
||||
};
|
||||
|
||||
EFI_IP4_ICMP_TYPE
|
||||
mIp4SupportedIcmp[23] = {
|
||||
{ICMP_ECHO_REPLY, ICMP_DEFAULT_CODE },
|
||||
mIp4SupportedIcmp[23] = {
|
||||
{ ICMP_ECHO_REPLY, ICMP_DEFAULT_CODE },
|
||||
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_PROTO_UNREACHABLE },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACHABLE },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_FRAGMENT_FAILED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_SOURCEROUTE_FAILED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNKNOWN },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNKNOWN },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_SOURCE_ISOLATED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_NET_PROHIBITED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_HOST_PROHIBITED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE_TOS },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE_TOS},
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_PROTO_UNREACHABLE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACHABLE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_FRAGMENT_FAILED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_SOURCEROUTE_FAILED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_NET_UNKNOWN },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_HOST_UNKNOWN },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_SOURCE_ISOLATED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_NET_PROHIBITED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_HOST_PROHIBITED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_NET_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_HOST_REDIRECT },
|
||||
{ICMP_REDIRECT, ICMP_NET_TOS_REDIRECT },
|
||||
{ICMP_REDIRECT, ICMP_HOST_TOS_REDIRECT },
|
||||
{ ICMP_REDIRECT, ICMP_NET_REDIRECT },
|
||||
{ ICMP_REDIRECT, ICMP_HOST_REDIRECT },
|
||||
{ ICMP_REDIRECT, ICMP_NET_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_REASSEMBLE },
|
||||
{ ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_IN_TRANSIT },
|
||||
{ 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
|
||||
its route cache.
|
||||
@ -146,7 +144,6 @@ Ip4ProcessIcmpRedirect (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the ICMP error packet. If it is an ICMP redirect packet,
|
||||
update call Ip4ProcessIcmpRedirect to update the IP instance's
|
||||
@ -176,7 +173,7 @@ Ip4ProcessIcmpError (
|
||||
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
|
||||
@ -190,7 +187,6 @@ Ip4ProcessIcmpError (
|
||||
return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Replay an ICMP echo request.
|
||||
|
||||
@ -233,11 +229,11 @@ Ip4IcmpReplyEcho (
|
||||
// use specific destination. See RFC1122. SRR/RR option
|
||||
// update is omitted.
|
||||
//
|
||||
Icmp = (IP4_ICMP_QUERY_HEAD *) NetbufGetByte (Data, 0, NULL);
|
||||
Icmp = (IP4_ICMP_QUERY_HEAD *)NetbufGetByte (Data, 0, NULL);
|
||||
ASSERT (Icmp != NULL);
|
||||
Icmp->Head.Type = ICMP_ECHO_REPLY;
|
||||
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.Fragment = 0;
|
||||
@ -270,7 +266,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the ICMP query message. If it is an ICMP echo
|
||||
request, answer it. Otherwise deliver it to upper layer.
|
||||
@ -299,7 +294,7 @@ Ip4ProcessIcmpQuery (
|
||||
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) {
|
||||
return Ip4IcmpReplyEcho (IpSb, Head, Packet);
|
||||
@ -308,7 +303,6 @@ Ip4ProcessIcmpQuery (
|
||||
return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle the ICMP packet. First validate the message format,
|
||||
then according to the message types, process it as query or
|
||||
@ -338,23 +332,21 @@ Ip4IcmpHandle (
|
||||
goto DROP;
|
||||
}
|
||||
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
|
||||
|
||||
if (Icmp.Type > ICMP_TYPE_MAX) {
|
||||
goto DROP;
|
||||
}
|
||||
|
||||
Checksum = (UINT16) (~NetbufChecksum (Packet));
|
||||
Checksum = (UINT16)(~NetbufChecksum (Packet));
|
||||
if ((Icmp.Checksum != 0) && (Checksum != 0)) {
|
||||
goto DROP;
|
||||
}
|
||||
|
||||
if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_ERROR_MESSAGE) {
|
||||
return Ip4ProcessIcmpError (IpSb, Head, Packet);
|
||||
|
||||
} else if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_QUERY_MESSAGE) {
|
||||
return Ip4ProcessIcmpQuery (IpSb, Head, Packet);
|
||||
|
||||
}
|
||||
|
||||
DROP:
|
||||
|
@ -9,9 +9,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef __EFI_IP4_ICMP_H__
|
||||
#define __EFI_IP4_ICMP_H__
|
||||
|
||||
//
|
||||
// ICMP type definitions
|
||||
//
|
||||
//
|
||||
// ICMP type definitions
|
||||
//
|
||||
#define ICMP_ECHO_REPLY 0
|
||||
#define ICMP_DEST_UNREACHABLE 3
|
||||
#define ICMP_SOURCE_QUENCH 4
|
||||
@ -26,9 +26,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#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_HOST_UNREACHABLE 1
|
||||
#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_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_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_HOST_REDIRECT 1
|
||||
#define ICMP_NET_TOS_REDIRECT 2
|
||||
#define ICMP_HOST_TOS_REDIRECT 3
|
||||
|
||||
//
|
||||
// ICMP message classes, each class of ICMP message shares
|
||||
// a common message format. INVALID_MESSAGE is only a flag.
|
||||
//
|
||||
//
|
||||
// ICMP message classes, each class of ICMP message shares
|
||||
// a common message format. INVALID_MESSAGE is only a flag.
|
||||
//
|
||||
#define ICMP_INVALID_MESSAGE 0
|
||||
#define ICMP_ERROR_MESSAGE 1
|
||||
#define ICMP_QUERY_MESSAGE 2
|
||||
@ -94,4 +94,5 @@ Ip4IcmpHandle (
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -121,7 +121,6 @@ Ip4CancelFrameArp (
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Wrap a transmit request into a newly allocated IP4_LINK_TX_TOKEN.
|
||||
|
||||
@ -154,8 +153,10 @@ Ip4WrapLinkTxToken (
|
||||
EFI_STATUS Status;
|
||||
UINT32 Count;
|
||||
|
||||
Token = AllocatePool (sizeof (IP4_LINK_TX_TOKEN) + \
|
||||
(Packet->BlockOpNum - 1) * sizeof (EFI_MANAGED_NETWORK_FRAGMENT_DATA));
|
||||
Token = AllocatePool (
|
||||
sizeof (IP4_LINK_TX_TOKEN) + \
|
||||
(Packet->BlockOpNum - 1) * sizeof (EFI_MANAGED_NETWORK_FRAGMENT_DATA)
|
||||
);
|
||||
|
||||
if (Token == NULL) {
|
||||
return NULL;
|
||||
@ -200,13 +201,12 @@ Ip4WrapLinkTxToken (
|
||||
|
||||
Count = Packet->BlockOpNum;
|
||||
|
||||
NetbufBuildExt (Packet, (NET_FRAGMENT *) MnpTxData->FragmentTable, &Count);
|
||||
NetbufBuildExt (Packet, (NET_FRAGMENT *)MnpTxData->FragmentTable, &Count);
|
||||
MnpTxData->FragmentCount = (UINT16)Count;
|
||||
|
||||
return Token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the link layer transmit token. It will close the event
|
||||
then free the memory used.
|
||||
@ -225,7 +225,6 @@ Ip4FreeLinkTxToken (
|
||||
FreePool (Token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create an IP_ARP_QUE structure to request ARP service.
|
||||
|
||||
@ -276,7 +275,6 @@ Ip4CreateArpQue (
|
||||
return ArpQue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove all the transmit requests queued on the ARP queue, then free it.
|
||||
|
||||
@ -302,7 +300,6 @@ Ip4FreeArpQue (
|
||||
FreePool (ArpQue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a link layer receive token to wrap the receive request
|
||||
|
||||
@ -358,7 +355,6 @@ Ip4CreateLinkRxToken (
|
||||
return Token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the link layer request token. It will close the event
|
||||
then free the memory used.
|
||||
@ -371,14 +367,12 @@ Ip4FreeFrameRxToken (
|
||||
IN IP4_LINK_RX_TOKEN *Token
|
||||
)
|
||||
{
|
||||
|
||||
NET_CHECK_SIGNATURE (Token, IP4_FRAME_RX_SIGNATURE);
|
||||
|
||||
gBS->CloseEvent (Token->MnpToken.Event);
|
||||
FreePool (Token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -414,7 +408,6 @@ Ip4CancelFrameArp (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove all the frames on the interface that pass the FrameToCancel,
|
||||
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
|
||||
the interface is configured.
|
||||
@ -538,7 +530,6 @@ Ip4CreateInterface (
|
||||
return Interface;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the interface's address, create and configure
|
||||
the ARP child if necessary.
|
||||
@ -621,7 +612,7 @@ Ip4SetAddress (
|
||||
Status = gBS->OpenProtocol (
|
||||
Interface->ArpHandle,
|
||||
&gEfiArpProtocolGuid,
|
||||
(VOID **) &Interface->Arp,
|
||||
(VOID **)&Interface->Arp,
|
||||
Interface->Image,
|
||||
Interface->Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -667,7 +658,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Filter function to cancel all the frame related to an IP instance.
|
||||
|
||||
@ -686,15 +676,13 @@ Ip4CancelInstanceFrame (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
if (Frame->IpInstance == (IP4_PROTOCOL *) Context) {
|
||||
if (Frame->IpInstance == (IP4_PROTOCOL *)Context) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
If there is a pending receive request, cancel it. Don't call
|
||||
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
|
||||
the same Ip/Netmask pair share the same interface. It is reference
|
||||
@ -830,18 +817,22 @@ Ip4SendFrameToDefaultRoute (
|
||||
if (Token->IpInstance != NULL) {
|
||||
RtCacheEntry = Ip4FindRouteCache (Token->IpInstance->RouteTable, NTOHL (ArpQue->Ip), Token->Interface->Ip);
|
||||
}
|
||||
|
||||
if (RtCacheEntry == NULL) {
|
||||
RtCacheEntry = Ip4FindRouteCache (Token->IpSb->DefaultRouteTable, NTOHL (ArpQue->Ip), Token->Interface->Ip);
|
||||
}
|
||||
|
||||
if (RtCacheEntry == NULL) {
|
||||
Status= EFI_NO_MAPPING;
|
||||
Status = EFI_NO_MAPPING;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
DefaultRoute = (IP4_ROUTE_ENTRY*)RtCacheEntry->Tag;
|
||||
|
||||
DefaultRoute = (IP4_ROUTE_ENTRY *)RtCacheEntry->Tag;
|
||||
if (DefaultRoute == NULL) {
|
||||
Status= EFI_NO_MAPPING;
|
||||
Status = EFI_NO_MAPPING;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
Status= EFI_NO_MAPPING;
|
||||
Status = EFI_NO_MAPPING;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
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)) {
|
||||
Status= EFI_NO_MAPPING;
|
||||
Status = EFI_NO_MAPPING;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Ip4FreeRouteCacheEntry (RtCacheEntry);
|
||||
}
|
||||
|
||||
@ -868,12 +861,12 @@ ON_ERROR:
|
||||
if (RtCacheEntry != NULL) {
|
||||
Ip4FreeRouteCacheEntry (RtCacheEntry);
|
||||
}
|
||||
|
||||
Token->CallBack (Token->IpInstance, Token->Packet, Status, 0, Token->Context);
|
||||
Ip4FreeLinkTxToken (Token);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Callback function when ARP request are finished. It will cancel
|
||||
all the queued frame if the ARP requests failed. Or transmit them
|
||||
@ -897,7 +890,7 @@ Ip4OnArpResolvedDpc (
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS IoStatus;
|
||||
|
||||
ArpQue = (IP4_ARP_QUE *) Context;
|
||||
ArpQue = (IP4_ARP_QUE *)Context;
|
||||
NET_CHECK_SIGNATURE (ArpQue, IP4_FRAME_ARP_SIGNATURE);
|
||||
|
||||
RemoveEntryList (&ArpQue->Link);
|
||||
@ -919,6 +912,7 @@ Ip4OnArpResolvedDpc (
|
||||
//
|
||||
IoStatus = Ip4SendFrameToDefaultRoute (ArpQue);
|
||||
}
|
||||
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@ -980,8 +974,6 @@ Ip4OnArpResolved (
|
||||
QueueDpc (TPL_CALLBACK, Ip4OnArpResolvedDpc, Context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Callback function when frame transmission is finished. It will
|
||||
call the frame owner's callback function to tell it the result.
|
||||
@ -997,7 +989,7 @@ Ip4OnFrameSentDpc (
|
||||
{
|
||||
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);
|
||||
|
||||
RemoveEntryList (&Token->Link);
|
||||
@ -1033,8 +1025,6 @@ Ip4OnFrameSent (
|
||||
QueueDpc (TPL_CALLBACK, Ip4OnFrameSentDpc, Context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Send a frame from the interface. If the next hop is broadcast or
|
||||
multicast address, it is transmitted immediately. If the next hop
|
||||
@ -1092,9 +1082,7 @@ Ip4SendFrame (
|
||||
if (NextHop == IP4_ALLONE_ADDRESS) {
|
||||
CopyMem (&Token->DstMac, &Interface->BroadcastMac, sizeof (Token->DstMac));
|
||||
goto SEND_NOW;
|
||||
|
||||
} else if (IP4_IS_MULTICAST (NextHop)) {
|
||||
|
||||
Status = Ip4GetMulticastMac (Interface->Mnp, NextHop, &Token->DstMac);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -1120,7 +1108,6 @@ Ip4SendFrame (
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
goto SEND_NOW;
|
||||
|
||||
} else if (Status != EFI_NOT_READY) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
@ -1187,7 +1174,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Call back function when the received packet is freed.
|
||||
Check Ip4OnFrameReceived for information.
|
||||
@ -1203,14 +1189,13 @@ Ip4RecycleFrame (
|
||||
{
|
||||
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);
|
||||
|
||||
gBS->SignalEvent (Frame->MnpToken.Packet.RxData->RecycleEvent);
|
||||
Ip4FreeFrameRxToken (Frame);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Received a frame from MNP, wrap it in net buffer then deliver
|
||||
it to IP's input function. The ownship of the packet also
|
||||
@ -1235,7 +1220,7 @@ Ip4OnFrameReceivedDpc (
|
||||
NET_BUF *Packet;
|
||||
UINT32 Flag;
|
||||
|
||||
Token = (IP4_LINK_RX_TOKEN *) Context;
|
||||
Token = (IP4_LINK_RX_TOKEN *)Context;
|
||||
NET_CHECK_SIGNATURE (Token, IP4_FRAME_RX_SIGNATURE);
|
||||
|
||||
//
|
||||
@ -1251,7 +1236,7 @@ Ip4OnFrameReceivedDpc (
|
||||
Token->CallBack (Token->IpInstance, NULL, MnpToken->Status, 0, Token->Context);
|
||||
Ip4FreeFrameRxToken (Token);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -1269,7 +1254,7 @@ Ip4OnFrameReceivedDpc (
|
||||
Token->CallBack (Token->IpInstance, NULL, EFI_OUT_OF_RESOURCES, 0, Token->Context);
|
||||
Ip4FreeFrameRxToken (Token);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Flag = (MnpRxData->BroadcastFlag ? IP4_LINK_BROADCAST : 0);
|
||||
@ -1299,7 +1284,6 @@ Ip4OnFrameReceived (
|
||||
QueueDpc (TPL_CALLBACK, Ip4OnFrameReceivedDpc, Context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Request to receive the packet from the interface.
|
||||
|
||||
@ -1345,5 +1329,6 @@ Ip4ReceiveFrame (
|
||||
Ip4FreeFrameRxToken (Token);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
UINT32 mRouteAlertOption = 0x00000494;
|
||||
|
||||
|
||||
/**
|
||||
Init the IGMP control data of the IP4 service instance, configure
|
||||
MNP to receive ALL SYSTEM multicast.
|
||||
@ -74,7 +73,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the IGMP_GROUP structure which contains the status of multicast
|
||||
group Address in this IGMP control block
|
||||
@ -107,7 +105,6 @@ Ip4FindGroup (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Count the number of IP4 multicast groups that are mapped to the
|
||||
same MAC address. Several IP4 multicast address may be mapped to
|
||||
@ -143,7 +140,6 @@ Ip4FindMac (
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send an IGMP protocol message to the Dst, such as IGMP v1 membership report.
|
||||
|
||||
@ -185,7 +181,7 @@ Ip4SendIgmpMessage (
|
||||
//
|
||||
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) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -194,7 +190,7 @@ Ip4SendIgmpMessage (
|
||||
Igmp->MaxRespTime = 0;
|
||||
Igmp->Checksum = 0;
|
||||
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.Protocol = IP4_PROTO_IGMP;
|
||||
@ -208,7 +204,7 @@ Ip4SendIgmpMessage (
|
||||
NULL,
|
||||
Packet,
|
||||
&Head,
|
||||
(UINT8 *) &mRouteAlertOption,
|
||||
(UINT8 *)&mRouteAlertOption,
|
||||
sizeof (UINT32),
|
||||
IP4_ALLZERO_ADDRESS,
|
||||
Ip4SysPacketSent,
|
||||
@ -216,7 +212,6 @@ Ip4SendIgmpMessage (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send an IGMP membership report. Depends on whether the server is
|
||||
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
|
||||
|
||||
@ -323,7 +317,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -393,7 +386,6 @@ Ip4LeaveGroup (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle the received IGMP message for the IP4 service instance.
|
||||
|
||||
@ -494,7 +486,6 @@ Ip4IgmpHandle (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The periodical timer function for IGMP. It does the following
|
||||
things:
|
||||
@ -539,7 +530,6 @@ Ip4IgmpTicking (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Add a group address to the array of group addresses.
|
||||
The caller should make sure that no duplicated address
|
||||
@ -576,7 +566,6 @@ Ip4CombineGroups (
|
||||
return Groups;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove a group address from the array of group addresses.
|
||||
Although the function doesn't assume the byte order of the
|
||||
|
@ -198,4 +198,5 @@ Ip4FindGroup (
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -329,7 +329,7 @@ EfiIp4Poll (
|
||||
);
|
||||
|
||||
EFI_IP4_PROTOCOL
|
||||
mEfiIp4ProtocolTemplete = {
|
||||
mEfiIp4ProtocolTemplete = {
|
||||
EfiIp4GetModeData,
|
||||
EfiIp4Configure,
|
||||
EfiIp4Groups,
|
||||
@ -392,7 +392,7 @@ EfiIp4GetModeData (
|
||||
Ip4ModeData->IsConfigured = FALSE;
|
||||
|
||||
Ip4ModeData->GroupCount = IpInstance->GroupCount;
|
||||
Ip4ModeData->GroupTable = (EFI_IPv4_ADDRESS *) IpInstance->Groups;
|
||||
Ip4ModeData->GroupTable = (EFI_IPv4_ADDRESS *)IpInstance->Groups;
|
||||
|
||||
Ip4ModeData->IcmpTypeCount = 23;
|
||||
Ip4ModeData->IcmpTypeList = mIp4SupportedIcmp;
|
||||
@ -443,7 +443,6 @@ EfiIp4GetModeData (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Config the MNP parameter used by IP. The IP driver use one MNP
|
||||
child to transmit/receive frames. By default, it configures MNP
|
||||
@ -486,7 +485,6 @@ Ip4ServiceConfigMnp (
|
||||
// filter also.
|
||||
//
|
||||
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
|
||||
|
||||
IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);
|
||||
IpIf->PromiscRecv = FALSE;
|
||||
|
||||
@ -523,7 +521,6 @@ Ip4ServiceConfigMnp (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize the IP4_PROTOCOL structure to the unconfigured states.
|
||||
|
||||
@ -557,7 +554,6 @@ Ip4InitProtocol (
|
||||
EfiInitializeLock (&IpInstance->RecycleLock, TPL_NOTIFY);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Configure the IP4 child. If the child is already configured,
|
||||
change the configuration parameter. Otherwise configure it
|
||||
@ -646,7 +642,6 @@ Ip4ConfigProtocol (
|
||||
|
||||
if (IpIf != NULL) {
|
||||
NET_GET_REF (IpIf);
|
||||
|
||||
} else {
|
||||
IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
|
||||
|
||||
@ -687,7 +682,7 @@ Ip4ConfigProtocol (
|
||||
if (Policy != Ip4Config2PolicyDhcp) {
|
||||
Ip4Config2 = &IpSb->Ip4Config2Instance.Ip4Config2;
|
||||
Policy = Ip4Config2PolicyDhcp;
|
||||
Status= Ip4Config2->SetData (
|
||||
Status = Ip4Config2->SetData (
|
||||
Ip4Config2,
|
||||
Ip4Config2DataTypePolicy,
|
||||
sizeof (EFI_IP4_CONFIG2_POLICY),
|
||||
@ -719,7 +714,7 @@ Ip4ConfigProtocol (
|
||||
Status = gBS->OpenProtocol (
|
||||
IpIf->ArpHandle,
|
||||
&gEfiArpProtocolGuid,
|
||||
(VOID **) &Arp,
|
||||
(VOID **)&Arp,
|
||||
gIp4DriverBinding.DriverBindingHandle,
|
||||
IpInstance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -729,6 +724,7 @@ Ip4ConfigProtocol (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink);
|
||||
|
||||
CopyMem (&IpInstance->ConfigData, Config, sizeof (IpInstance->ConfigData));
|
||||
@ -751,7 +747,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
//
|
||||
if (!IsListEmpty (&IpInstance->Delivered)) {
|
||||
;
|
||||
}
|
||||
|
||||
if (IpInstance->Interface != NULL) {
|
||||
@ -793,6 +787,7 @@ Ip4CleanProtocol (
|
||||
IpInstance->Handle
|
||||
);
|
||||
}
|
||||
|
||||
Ip4FreeInterface (IpInstance->Interface, IpInstance);
|
||||
IpInstance->Interface = NULL;
|
||||
}
|
||||
@ -825,7 +820,6 @@ Ip4CleanProtocol (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
|
||||
|
||||
@ -898,7 +892,6 @@ EfiIp4Configure (
|
||||
// Validate the configuration first.
|
||||
//
|
||||
if (IpConfigData != NULL) {
|
||||
|
||||
CopyMem (&IpAddress, &IpConfigData->StationAddress, sizeof (IP4_ADDR));
|
||||
CopyMem (&SubnetMask, &IpConfigData->SubnetMask, sizeof (IP4_ADDR));
|
||||
|
||||
@ -932,7 +925,8 @@ EfiIp4Configure (
|
||||
|
||||
if (!Current->UseDefaultAddress &&
|
||||
(!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;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -971,10 +965,8 @@ EfiIp4Configure (
|
||||
ON_EXIT:
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Change the IP4 child's multicast setting. The caller
|
||||
should make sure that the parameters is valid.
|
||||
@ -1045,7 +1037,7 @@ Ip4Groups (
|
||||
// Must iterate from the end to the beginning because the GroupCount
|
||||
// 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);
|
||||
Group = IpInstance->Groups[Index - 1];
|
||||
if ((GroupAddress == NULL) || EFI_IP4_EQUAL (&Group, GroupAddress)) {
|
||||
@ -1072,7 +1064,6 @@ Ip4Groups (
|
||||
return ((GroupAddress != NULL) ? EFI_NOT_FOUND : EFI_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Joins and leaves multicast groups.
|
||||
|
||||
@ -1148,7 +1139,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Adds and deletes routing table entries.
|
||||
|
||||
@ -1221,7 +1211,8 @@ EfiIp4Routes (
|
||||
// First, validate the parameters
|
||||
//
|
||||
if ((This == NULL) || (SubnetAddress == NULL) ||
|
||||
(SubnetMask == NULL) || (GatewayAddress == NULL)) {
|
||||
(SubnetMask == NULL) || (GatewayAddress == NULL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1257,9 +1248,9 @@ EfiIp4Routes (
|
||||
// the gateway address must be a unicast on the connected network if not zero.
|
||||
//
|
||||
if ((Nexthop != IP4_ALLZERO_ADDRESS) &&
|
||||
((IpIf->SubnetMask != IP4_ALLONE_ADDRESS && !IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask)) ||
|
||||
IP4_IS_BROADCAST (Ip4GetNetCast (Nexthop, IpIf)))) {
|
||||
|
||||
(((IpIf->SubnetMask != IP4_ALLONE_ADDRESS) && !IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask)) ||
|
||||
IP4_IS_BROADCAST (Ip4GetNetCast (Nexthop, IpIf))))
|
||||
{
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -1275,7 +1266,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check whether the user's token or event has already
|
||||
been enqueued on IP4's list.
|
||||
@ -1301,8 +1291,8 @@ Ip4TokenExist (
|
||||
EFI_IP4_COMPLETION_TOKEN *Token;
|
||||
EFI_IP4_COMPLETION_TOKEN *TokenInItem;
|
||||
|
||||
Token = (EFI_IP4_COMPLETION_TOKEN *) Context;
|
||||
TokenInItem = (EFI_IP4_COMPLETION_TOKEN *) Item->Key;
|
||||
Token = (EFI_IP4_COMPLETION_TOKEN *)Context;
|
||||
TokenInItem = (EFI_IP4_COMPLETION_TOKEN *)Item->Key;
|
||||
|
||||
if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
|
||||
return EFI_ACCESS_DENIED;
|
||||
@ -1359,8 +1349,8 @@ Ip4TxTokenValid (
|
||||
|
||||
for (Index = 0; Index < TxData->FragmentCount; Index++) {
|
||||
if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) ||
|
||||
(TxData->FragmentTable[Index].FragmentLength == 0)) {
|
||||
|
||||
(TxData->FragmentTable[Index].FragmentLength == 0))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1407,8 +1397,8 @@ Ip4TxTokenValid (
|
||||
|
||||
if ((NetGetIpClass (Src) > IP4_ADDR_CLASSC) ||
|
||||
(Src == IP4_ALLONE_ADDRESS) ||
|
||||
IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf))) {
|
||||
|
||||
IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1419,8 +1409,8 @@ Ip4TxTokenValid (
|
||||
if ((Gateway != IP4_ALLZERO_ADDRESS) &&
|
||||
((NetGetIpClass (Gateway) > IP4_ADDR_CLASSC) ||
|
||||
!IP4_NET_EQUAL (Gateway, IpIf->Ip, IpIf->SubnetMask) ||
|
||||
IP4_IS_BROADCAST (Ip4GetNetCast (Gateway, IpIf)))) {
|
||||
|
||||
IP4_IS_BROADCAST (Ip4GetNetCast (Gateway, IpIf))))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
@ -1431,15 +1421,14 @@ Ip4TxTokenValid (
|
||||
HeadLen = sizeof (IP4_HEAD) + ((TxData->OptionsLength + 3) &~0x03);
|
||||
|
||||
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_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The callback function for the net buffer which wraps the user's
|
||||
transmit token. Although it seems this function is pretty simple,
|
||||
@ -1470,7 +1459,7 @@ Ip4FreeTxToken (
|
||||
IP4_TXTOKEN_WRAP *Wrap;
|
||||
NET_MAP_ITEM *Item;
|
||||
|
||||
Wrap = (IP4_TXTOKEN_WRAP *) Context;
|
||||
Wrap = (IP4_TXTOKEN_WRAP *)Context;
|
||||
|
||||
//
|
||||
// Signal IpSecRecycleEvent to inform IPsec free the memory
|
||||
@ -1501,7 +1490,6 @@ Ip4FreeTxToken (
|
||||
FreePool (Wrap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
// in Ip4FreeTxToken and Ip4Output for information.
|
||||
//
|
||||
Wrap = (IP4_TXTOKEN_WRAP *) Context;
|
||||
Wrap = (IP4_TXTOKEN_WRAP *)Context;
|
||||
Wrap->Token->Status = IoStatus;
|
||||
|
||||
NetbufFree (Wrap->Packet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Places outgoing data packets into the transmit queue.
|
||||
|
||||
@ -1651,13 +1638,13 @@ EfiIp4Transmit (
|
||||
FirstFragment = TxData->FragmentTable[0].FragmentBuffer;
|
||||
CopyMem (&RawHdrLen, FirstFragment, sizeof (UINT8));
|
||||
|
||||
RawHdrLen = (UINT8) (RawHdrLen & 0x0f);
|
||||
RawHdrLen = (UINT8)(RawHdrLen & 0x0f);
|
||||
if (RawHdrLen < 5) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
RawHdrLen = (UINT8) (RawHdrLen << 2);
|
||||
RawHdrLen = (UINT8)(RawHdrLen << 2);
|
||||
|
||||
CopyMem (&Head, FirstFragment, IP4_MIN_HEADLEN);
|
||||
|
||||
@ -1680,13 +1667,13 @@ EfiIp4Transmit (
|
||||
OptionsBuffer = NULL;
|
||||
} else {
|
||||
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.
|
||||
//
|
||||
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment + RawHdrLen;
|
||||
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment + RawHdrLen;
|
||||
TxData->FragmentTable[0].FragmentLength = TxData->FragmentTable[0].FragmentLength - RawHdrLen;
|
||||
} else {
|
||||
CopyMem (&Head.Dst, &TxData->DestinationAddress, sizeof (IP4_ADDR));
|
||||
@ -1717,7 +1704,7 @@ EfiIp4Transmit (
|
||||
HeadLen = (TxData->OptionsLength + 3) & (~0x03);
|
||||
|
||||
OptionsLength = TxData->OptionsLength;
|
||||
OptionsBuffer = (UINT8 *) (TxData->OptionsBuffer);
|
||||
OptionsBuffer = (UINT8 *)(TxData->OptionsBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
@ -1743,7 +1730,7 @@ EfiIp4Transmit (
|
||||
Wrap->Sent = FALSE;
|
||||
Wrap->Life = IP4_US_TO_SEC (Config->TransmitTimeout);
|
||||
Wrap->Packet = NetbufFromExt (
|
||||
(NET_FRAGMENT *) TxData->FragmentTable,
|
||||
(NET_FRAGMENT *)TxData->FragmentTable,
|
||||
TxData->FragmentCount,
|
||||
IP4_MAX_HEADLEN,
|
||||
0,
|
||||
@ -1768,7 +1755,7 @@ EfiIp4Transmit (
|
||||
//
|
||||
// Restore pointer of first fragment in RawData mode.
|
||||
//
|
||||
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment;
|
||||
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
|
||||
}
|
||||
|
||||
NetbufFree (Wrap->Packet);
|
||||
@ -1800,7 +1787,7 @@ EfiIp4Transmit (
|
||||
//
|
||||
// Restore pointer of first fragment in RawData mode.
|
||||
//
|
||||
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment;
|
||||
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
|
||||
}
|
||||
|
||||
NetbufFree (Wrap->Packet);
|
||||
@ -1810,7 +1797,7 @@ EfiIp4Transmit (
|
||||
//
|
||||
// Restore pointer of first fragment in RawData mode.
|
||||
//
|
||||
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment;
|
||||
TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
|
||||
}
|
||||
|
||||
ON_EXIT:
|
||||
@ -1818,7 +1805,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Places a receiving request into the receiving queue.
|
||||
|
||||
@ -1910,7 +1896,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Cancel the transmitted but not recycled packet. If a matching
|
||||
token is found, it will call Ip4CancelPacket to cancel the
|
||||
@ -1939,7 +1924,7 @@ Ip4CancelTxTokens (
|
||||
EFI_IP4_COMPLETION_TOKEN *Token;
|
||||
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
|
||||
@ -1949,7 +1934,7 @@ Ip4CancelTxTokens (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Wrap = (IP4_TXTOKEN_WRAP *) Item->Value;
|
||||
Wrap = (IP4_TXTOKEN_WRAP *)Item->Value;
|
||||
ASSERT (Wrap != NULL);
|
||||
|
||||
//
|
||||
@ -1969,7 +1954,6 @@ Ip4CancelTxTokens (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Cancel the receive request. This is quiet simple, because
|
||||
it is only enqueued in our local receive map.
|
||||
@ -1995,7 +1979,7 @@ Ip4CancelRxTokens (
|
||||
EFI_IP4_COMPLETION_TOKEN *Token;
|
||||
EFI_IP4_COMPLETION_TOKEN *This;
|
||||
|
||||
Token = (EFI_IP4_COMPLETION_TOKEN *) Context;
|
||||
Token = (EFI_IP4_COMPLETION_TOKEN *)Context;
|
||||
This = Item->Key;
|
||||
|
||||
if ((Token != NULL) && (Token != This)) {
|
||||
@ -2015,7 +1999,6 @@ Ip4CancelRxTokens (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Cancel the user's receive/transmit request.
|
||||
|
||||
@ -2083,15 +2066,14 @@ Ip4Cancel (
|
||||
// all of them are cancelled.
|
||||
//
|
||||
if (!NetMapIsEmpty (&IpInstance->TxTokens) ||
|
||||
!NetMapIsEmpty (&IpInstance->RxTokens)) {
|
||||
|
||||
!NetMapIsEmpty (&IpInstance->RxTokens))
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Abort an asynchronous transmit or receive request.
|
||||
|
||||
@ -2157,7 +2139,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Polls for incoming data packets and processes outgoing data packets.
|
||||
|
||||
@ -2237,7 +2218,7 @@ Ip4SentPacketTicking (
|
||||
{
|
||||
IP4_TXTOKEN_WRAP *Wrap;
|
||||
|
||||
Wrap = (IP4_TXTOKEN_WRAP *) Item->Value;
|
||||
Wrap = (IP4_TXTOKEN_WRAP *)Item->Value;
|
||||
ASSERT (Wrap != NULL);
|
||||
|
||||
if ((Wrap->Life > 0) && (--Wrap->Life == 0)) {
|
||||
@ -2265,7 +2246,7 @@ Ip4TimerTicking (
|
||||
{
|
||||
IP4_SERVICE *IpSb;
|
||||
|
||||
IpSb = (IP4_SERVICE *) Context;
|
||||
IpSb = (IP4_SERVICE *)Context;
|
||||
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
|
||||
|
||||
Ip4PacketTimerTicking (IpSb);
|
||||
@ -2296,7 +2277,7 @@ Ip4TimerReconfigChecking (
|
||||
EFI_STATUS Status;
|
||||
EFI_SIMPLE_NETWORK_MODE SnpModeData;
|
||||
|
||||
IpSb = (IP4_SERVICE *) Context;
|
||||
IpSb = (IP4_SERVICE *)Context;
|
||||
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
|
||||
|
||||
OldMediaPresent = IpSb->MediaPresent;
|
||||
|
@ -74,7 +74,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define IP4_SERVICE_CONFIGED 2
|
||||
#define IP4_SERVICE_DESTROY 3
|
||||
|
||||
|
||||
///
|
||||
/// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.
|
||||
/// The user's data is kept in the Packet. When fragment is
|
||||
@ -120,7 +119,6 @@ typedef struct {
|
||||
EFI_IP4_RECEIVE_DATA RxData;
|
||||
} IP4_RXDATA_WRAP;
|
||||
|
||||
|
||||
struct _IP4_PROTOCOL {
|
||||
UINT32 Signature;
|
||||
|
||||
@ -161,7 +159,6 @@ struct _IP4_PROTOCOL {
|
||||
UINT32 GroupCount;
|
||||
|
||||
EFI_IP4_CONFIG_DATA ConfigData;
|
||||
|
||||
};
|
||||
|
||||
struct _IP4_SERVICE {
|
||||
@ -230,7 +227,6 @@ struct _IP4_SERVICE {
|
||||
#define IP4_SERVICE_FROM_CONFIG2_INSTANCE(This) \
|
||||
CR (This, IP4_SERVICE, Ip4Config2Instance, IP4_SERVICE_SIGNATURE)
|
||||
|
||||
|
||||
#define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
|
||||
|
||||
extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user