NetworkPkg: Apply uncrustify changes

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

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

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

View File

@ -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;
}

View File

@ -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.
@ -255,7 +253,7 @@ ArpDestroyChildEntryInHandleBuffer (
ARP_INSTANCE_DATA *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
if (Entry == NULL || Context == NULL) {
if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -334,7 +332,6 @@ ArpDriverBindingSupported (
return Status;
}
/**
Start this driver on ControllerHandle.
@ -427,7 +424,6 @@ ERROR:
return Status;
}
/**
Stop this driver on ControllerHandle.
@ -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;

View File

@ -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

View File

@ -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.
@ -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.
@ -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.
@ -1109,6 +1113,7 @@ ArpSendFrame (
SnpMode->HwAddressSize
);
}
TmpPtr += SnpMode->HwAddressSize;
//
@ -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.

View File

@ -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>

View File

@ -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;
}
@ -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.
@ -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;
}

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "ArpDriver.h"
//
// EFI Component Name Protocol
//
@ -27,7 +26,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2 =
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = {
{ "eng;en", L"ARP Network Service Driver" },
{ NULL, NULL }

View File

@ -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
//
@ -156,7 +154,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] = {
{
"eng;en",

View File

@ -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.
@ -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,7 +361,7 @@ Dhcp4DestroyChildEntry (
DHCP_PROTOCOL *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
if (Entry == NULL || Context == NULL) {
if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -377,7 +371,6 @@ Dhcp4DestroyChildEntry (
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
}
/**
Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to
@ -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.
@ -606,7 +598,6 @@ Dhcp4ServiceBindingCreateChild (
return EFI_SUCCESS;
}
/**
Destroys a child handle with a protocol installed on it.

View File

@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "Dhcp4Impl.h"
/**
@ -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.
@ -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.
@ -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;
}
@ -1293,6 +1280,7 @@ Dhcp4InstanceCreateUdpIo (
UdpIoFreeIo (Instance->UdpIo);
Instance->UdpIo = NULL;
}
return Status;
}
}
@ -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;
}
@ -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
@ -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
@ -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;
}

View File

@ -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;

View File

@ -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.
@ -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
@ -127,7 +124,6 @@ DhcpCallUser (
return EFI_ABORTED;
}
/**
Notify the user about the operation result.
@ -149,23 +145,21 @@ DhcpNotifyUser (
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
@ -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
@ -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;
}
@ -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.
@ -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;
}
@ -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
@ -1223,8 +1201,8 @@ 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);
@ -1242,12 +1220,10 @@ 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);
@ -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;
}
@ -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);
}
@ -1393,7 +1368,6 @@ DhcpSendMessage (
return EFI_SUCCESS;
}
/**
Retransmit a saved packet. Only DISCOVER and REQUEST messages
will be retransmitted.
@ -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.
@ -1500,7 +1473,7 @@ DhcpOnTimerTick (
//
// 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,12 +1481,10 @@ 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)) {
@ -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;
@ -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
@ -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
@ -1643,7 +1606,7 @@ 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);
}
}

View File

@ -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

View File

@ -101,7 +101,6 @@ DHCP_OPTION_FORMAT DhcpOptionFormats[] = {
{ 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
@ -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
@ -466,7 +463,6 @@ DhcpGetOptionLen (
return EFI_SUCCESS;
}
/**
Call back function to DhcpIterateOptions to consolidate each option's
data. There are maybe several occurrence of the same option.
@ -513,7 +509,6 @@ DhcpFillOption (
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
@ -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.
@ -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.

View File

@ -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.
//

View File

@ -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
//
@ -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)
);
}

View File

@ -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.
@ -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,7 +336,7 @@ Dhcp6DestroyChildEntry (
DHCP6_INSTANCE *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
if (Entry == NULL || Context == NULL) {
if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -350,7 +346,6 @@ Dhcp6DestroyChildEntry (
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
@ -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;
}
@ -677,7 +668,6 @@ Dhcp6ServiceBindingCreateChild (
);
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;
}

View File

@ -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,
@ -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;
}
@ -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;
}
}
@ -513,14 +522,13 @@ EfiDhcp6Configure (
gBS->RestoreTPL (OldTpl);
return EFI_OUT_OF_RESOURCES;
}
CopyMem (
&Instance->IaCb.Ia->Descriptor,
&Dhcp6CfgData->IaDescriptor,
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;
}
}
@ -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;
}
@ -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;
}
@ -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;
}
@ -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;
}
@ -1208,7 +1216,6 @@ EfiDhcp6Parse (
Start = Packet->Dhcp6.Option;
while (Start < End) {
PacketOptionList[OptCnt] = (EFI_DHCP6_PACKET_OPTION *)Start;
DataLen = ((EFI_DHCP6_PACKET_OPTION *)Start)->OpLen;
Start += (NTOHS (DataLen) + 4);
@ -1217,4 +1224,3 @@ EfiDhcp6Parse (
return EFI_SUCCESS;
}

View File

@ -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;

View File

@ -10,7 +10,6 @@
#include "Dhcp6Impl.h"
/**
Enqueue the packet into the retry list in case of timeout.
@ -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);
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,6 +266,7 @@ Dhcp6DequeueRetry (
}
}
}
//
// Remove the retransmit node.
//
@ -286,7 +281,6 @@ Dhcp6DequeueRetry (
return EFI_NOT_FOUND;
}
/**
Clean up the specific nodes in the retry list.
@ -308,10 +302,8 @@ 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);
@ -326,13 +318,11 @@ 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);
@ -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);
}
@ -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.
@ -618,9 +605,10 @@ Dhcp6UpdateIaInfo (
// 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);
} else {
@ -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.
@ -807,7 +793,6 @@ Dhcp6SeekStsOption (
return EFI_SUCCESS;
}
/**
Transmit Dhcp6 message by udpio.
@ -899,7 +884,6 @@ Dhcp6TransmitPacket (
return EFI_SUCCESS;
}
/**
Create the solicit message and send it.
@ -985,7 +969,6 @@ Dhcp6SendSolicitMsg (
// Append user-defined when configurate Dhcp6 service.
//
for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
UserOpt = Instance->Config->OptionList[Index];
Cursor = Dhcp6AppendOption (
Cursor,
@ -1061,7 +1044,6 @@ Dhcp6InitSolicitMsg (
return Dhcp6SendSolicitMsg (Instance);
}
/**
Create the request message and send it.
@ -1174,7 +1156,6 @@ Dhcp6SendRequestMsg (
// Append user-defined when configurate Dhcp6 service.
//
for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
UserOpt = Instance->Config->OptionList[Index];
Cursor = Dhcp6AppendOption (
Cursor,
@ -1223,7 +1204,6 @@ Dhcp6SendRequestMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
}
/**
Create the decline message and send it.
@ -1361,7 +1341,6 @@ Dhcp6SendDeclineMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
}
/**
Create the release message and send it.
@ -1494,7 +1473,6 @@ Dhcp6SendReleaseMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);
}
/**
Create the renew/rebind message and send it.
@ -1618,7 +1596,6 @@ Dhcp6SendRenewRebindMsg (
// Append user-defined when configurate Dhcp6 service.
//
for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
UserOpt = Instance->Config->OptionList[Index];
Cursor = Dhcp6AppendOption (
Cursor,
@ -1876,7 +1853,6 @@ Dhcp6SendInfoRequestMsg (
// Append user-defined when configurate Dhcp6 service.
//
for (Index = 0; Index < OptionCount; Index++) {
UserOpt = OptionList[Index];
Cursor = Dhcp6AppendOption (
Cursor,
@ -1913,7 +1889,6 @@ Dhcp6SendInfoRequestMsg (
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, Retransmission);
}
/**
Create the Confirm message and send it.
@ -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,7 +2207,6 @@ Dhcp6HandleReplyMsg (
}
goto ON_EXIT;
} else if (Option != NULL) {
//
// Any error status code option is found.
@ -2259,6 +2230,7 @@ Dhcp6HandleReplyMsg (
FreePool (Instance->Unicast);
Instance->Unicast = NULL;
}
break;
case Dhcp6StsNotOnLink:
@ -2279,10 +2251,11 @@ 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.
@ -2292,6 +2265,7 @@ Dhcp6HandleReplyMsg (
return Status;
}
}
break;
default:
@ -2317,7 +2291,6 @@ ON_EXIT:
return Status;
}
/**
Select the appointed Dhcp6 advertisement message.
@ -2376,7 +2349,6 @@ Dhcp6SelectAdvertiseMsg (
);
if (Option != NULL) {
Instance->Unicast = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS));
if (Instance->Unicast == NULL) {
@ -2401,7 +2373,6 @@ Dhcp6SelectAdvertiseMsg (
return Dhcp6SendRequestMsg (Instance);
}
/**
Handle with the Dhcp6 advertisement message.
@ -2441,8 +2412,7 @@ Dhcp6HandleAdvertiseMsg (
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
@ -2514,7 +2483,7 @@ Dhcp6HandleAdvertiseMsg (
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,7 +2562,7 @@ 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;
}
@ -2608,7 +2575,7 @@ Dhcp6HandleStateful (
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;
}
@ -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.
@ -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.
@ -2998,7 +2963,6 @@ Dhcp6OnTimerTick (
// 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.
//
@ -3136,25 +3099,29 @@ Dhcp6OnTimerTick (
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,

View File

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

View File

@ -10,7 +10,6 @@
#include "Dhcp6Impl.h"
/**
Generate client Duid in the format of Duid-llt.
@ -31,7 +30,6 @@ 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.
@ -92,9 +90,7 @@ Dhcp6GenerateClientId (
WriteUnaligned16 ((UINT16 *)(Duid->Duid), HTONS (Dhcp6DuidTypeUuid));
CopyMem (Duid->Duid + 2, &Uuid, sizeof (EFI_GUID));
} else {
//
//
// The format of DUID-LLT:
@ -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.
@ -348,19 +338,12 @@ 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);
} else if (IsFirstRt && !Signed) {
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);
} else {
Expire = 2 * Base + (UINT32)(Base * Seed / DHCP6_10_BIT_MASK / 10);
}
@ -369,7 +352,6 @@ Dhcp6CalculateExpireTime (
return Expire;
}
/**
Calculate the lease time by the algorithm defined in rfc.
@ -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.
@ -660,7 +636,6 @@ Dhcp6AppendIaAddrOption (
IN UINT32 MessageType
)
{
// The format of the IA Address option is:
//
// 0 1 2 3
@ -702,17 +677,18 @@ Dhcp6AppendIaAddrOption (
if (MessageType != Dhcp6MsgConfirm) {
WriteUnaligned32 ((UINT32 *)Buf, HTONL (IaAddr->PreferredLifetime));
}
Buf += 4;
if (MessageType != Dhcp6MsgConfirm) {
WriteUnaligned32 ((UINT32 *)Buf, HTONL (IaAddr->ValidLifetime));
}
Buf += 4;
return Buf;
}
/**
Append the appointed Ia option to Buf, and move Buf to the end.
@ -902,10 +878,10 @@ SetElapsedTime (
ElapsedTimeValue = 0xffff;
}
}
WriteUnaligned16 (Elapsed, HTONS ((UINT16)ElapsedTimeValue));
}
/**
Seek the address of the first byte of the option header.
@ -941,6 +917,7 @@ Dhcp6SeekOption (
Option = Cursor;
break;
}
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
Cursor += (DataLen + 4);
}
@ -948,7 +925,6 @@ Dhcp6SeekOption (
return Option;
}
/**
Seek the address of the first byte of the Ia option header.
@ -982,10 +958,11 @@ Dhcp6SeekIaOption (
while (Cursor < Buf + SeekLen) {
OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
IaId = ReadUnaligned32 ((UINT32 *)(Cursor + 4));
if (OpCode == HTONS (IaDesc->Type) && IaId == HTONL (IaDesc->IaId)) {
if ((OpCode == HTONS (IaDesc->Type)) && (IaId == HTONL (IaDesc->IaId))) {
Option = Cursor;
break;
}
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
Cursor += (DataLen + 4);
}
@ -1019,6 +996,7 @@ Dhcp6AddrIsInCurrentIa (
return TRUE;
}
}
return FALSE;
}
@ -1090,22 +1068,24 @@ Dhcp6ParseAddrOption (
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 ((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));
}
(*AddrNum)++;
}
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;
}
@ -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;
}

View File

@ -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

View File

@ -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
///
@ -208,6 +208,7 @@ UpdateDns4Name (
if (ModeData.DnsCacheList != NULL) {
FreePool (ModeData.DnsCacheList);
}
if (ModeData.DnsServerList != NULL) {
FreePool (ModeData.DnsServerList);
}
@ -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);
}

View File

@ -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;
@ -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);
@ -237,7 +235,6 @@ ParseDhcp6Ack (
gBS->FreePool (OptionList);
return Status;
}
/**
@ -391,7 +388,7 @@ GetDns4ServerFromDhcp4 (
}
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;
}
@ -753,6 +750,4 @@ ON_EXIT:
);
return Status;
}

View File

@ -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

View File

@ -146,7 +146,7 @@ DnsDestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) {
if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -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;
@ -760,7 +762,7 @@ Dns4DriverBindingStop (
);
}
if (NumberOfChildren == 0 && IsListEmpty (&DnsSb->Dns4ChildrenList)) {
if ((NumberOfChildren == 0) && IsListEmpty (&DnsSb->Dns4ChildrenList)) {
gBS->UninstallProtocolInterface (
NicHandle,
&gEfiDns4ServiceBindingProtocolGuid,
@ -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);
//
@ -1330,6 +1333,7 @@ Dns6ServiceBindingCreateChild (
if (EFI_ERROR (Status)) {
return Status;
}
ASSERT (Instance != NULL);
//

View File

@ -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

View File

@ -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;
}
@ -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,8 +565,8 @@ 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);
}
@ -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
//
@ -1081,7 +1085,6 @@ IsValidDnsResponse (
*Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
Packet = (NET_BUF *)((*Item)->Value);
if (Packet == NULL) {
continue;
} else {
TxString = NetbufGetByte (Packet, 0, NULL);
@ -1090,9 +1093,10 @@ IsValidDnsResponse (
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;
}
}
@ -1245,11 +1249,13 @@ ParseDnsResponse (
QuerySection->Type,
QuerySection->Class,
&Item
)) {
))
{
*Completed = FALSE;
Status = EFI_ABORTED;
goto ON_EXIT;
}
ASSERT (Item != NULL);
Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(Item->Key);
} else {
@ -1259,11 +1265,13 @@ ParseDnsResponse (
QuerySection->Type,
QuerySection->Class,
&Item
)) {
))
{
*Completed = FALSE;
Status = EFI_ABORTED;
goto ON_EXIT;
}
ASSERT (Item != NULL);
Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(Item->Key);
}
@ -1271,8 +1279,9 @@ ParseDnsResponse (
//
// 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;
@ -1417,7 +1430,7 @@ 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);
@ -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,11 +1453,12 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
CopyMem (Dns4RR[RRCount].RData, AnswerData, Dns4RR[RRCount].DataLength);
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);
@ -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,6 +1481,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
CopyMem (Dns6RR[RRCount].RData, AnswerData, Dns6RR[RRCount].DataLength);
RRCount++;
@ -1498,20 +1515,23 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
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));
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);
@ -1557,20 +1577,23 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
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));
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);
@ -1646,7 +1669,7 @@ ON_COMPLETE:
//
// Parsing is complete, free the sending packet and signal Event here.
//
if (Item != NULL && Item->Value != NULL) {
if ((Item != NULL) && (Item->Value != NULL)) {
NetbufFree ((NET_BUF *)(Item->Value));
}
@ -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);
}
@ -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);
}
@ -2084,7 +2107,6 @@ DnsOnTimerRetransmit (
Service = (DNS_SERVICE *)Context;
if (Service->IpVersion == IP_VERSION_4) {
//
// Iterate through all the children of the DNS service instance. Time
@ -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;
}
@ -2141,7 +2163,7 @@ DnsOnTimerRetransmit (
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)) {
if ((Dns6TokenEntry->PacketToLive == 0) || (--Dns6TokenEntry->PacketToLive > 0)) {
EntryNetMap = EntryNetMap->ForwardLink;
continue;
}
@ -2242,4 +2264,3 @@ DnsOnTimerUpdate (
}
}
}

View File

@ -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.

View File

@ -73,7 +73,6 @@ Dns4GetModeData (
CacheList = NULL;
Status = EFI_SUCCESS;
if ((This == NULL) || (DnsModeData == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -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;
}
@ -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;
}
@ -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++;
}
@ -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;
}
@ -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;
}
@ -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;
}
@ -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;
@ -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;
}
@ -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;
}

View File

@ -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;
}

View File

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

View File

@ -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));
@ -84,6 +86,7 @@ HttpBootUpdateDevicePath (
FreePool (TmpIpDevicePath);
return EFI_OUT_OF_RESOURCES;
}
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_DNS_DP;
SetDevicePathNodeLength (Node, Length);
@ -108,11 +111,14 @@ 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);
@ -126,6 +132,7 @@ HttpBootUpdateDevicePath (
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,13 +217,15 @@ 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;
} else {
@ -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);
@ -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,13 +361,15 @@ 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;
} else {
@ -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);
@ -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,6 +580,7 @@ HttpBootHttpIoCallback (
{
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_STATUS Status;
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
if (Private->HttpBootCallback != NULL) {
Status = Private->HttpBootCallback->Callback (
@ -576,6 +592,7 @@ HttpBootHttpIoCallback (
);
return Status;
}
return EFI_SUCCESS;
}
@ -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.
//
@ -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;
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;
@ -1081,6 +1110,7 @@ HttpBootGetBootFile (
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;
}
@ -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,12 +1242,13 @@ 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 {
@ -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);

View File

@ -139,7 +139,7 @@ HttpBootDxeComponentNameGetControllerName (
EFI_HANDLE NicHandle;
UINT32 *Id;
if (ControllerHandle == NULL || ChildHandle != NULL) {
if ((ControllerHandle == NULL) || (ChildHandle != NULL)) {
return EFI_UNSUPPORTED;
}
@ -173,5 +173,4 @@ HttpBootDxeComponentNameGetControllerName (
ControllerName,
(BOOLEAN)(This != &gHttpBootDxeComponentName2)
);
}

View File

@ -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);
FreePool (Node);
if (TmpDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Update the URI node with the input boot file URI.
//
@ -106,6 +111,7 @@ HttpBootAddBootOption (
FreePool (TmpDevicePath);
goto ON_EXIT;
}
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, Length);
@ -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);
@ -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) {
@ -451,7 +460,7 @@ HttpBootFormCallback (
AsciiUri = NULL;
Status = EFI_SUCCESS;
if (This == NULL || Value == NULL) {
if ((This == NULL) || (Value == 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 (
@ -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.
//

View File

@ -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;

View File

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

View File

@ -98,6 +98,7 @@ HttpBootBuildDhcp4Options (
//
ZeroMem (OptEnt.Uuid->Guid, sizeof (EFI_GUID));
}
Index++;
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
@ -185,7 +186,6 @@ HttpBootParseDhcp4Options (
Offset = 0;
while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
if (Option->OpCode == OptTag) {
//
// Found the required option.
@ -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.
@ -302,6 +303,7 @@ HttpBootParseDhcp4Packet (
}
}
}
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) {
@ -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;
}
@ -355,7 +358,7 @@ HttpBootParseDhcp4Packet (
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;
}
@ -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) {
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,7 +595,8 @@ HttpBootDhcp4CallBack (
(Dhcp4Event != Dhcp4RcvdOffer) &&
(Dhcp4Event != Dhcp4SendRequest) &&
(Dhcp4Event != Dhcp4RcvdAck) &&
(Dhcp4Event != Dhcp4SelectOffer)) {
(Dhcp4Event != Dhcp4SelectOffer))
{
return EFI_SUCCESS;
}
@ -634,7 +618,7 @@ HttpBootDhcp4CallBack (
//
// Callback to user if any packets sent or received.
//
if (Private->HttpBootCallback != NULL && Dhcp4Event != Dhcp4SelectOffer) {
if ((Private->HttpBootCallback != NULL) && (Dhcp4Event != Dhcp4SelectOffer)) {
Received = (BOOLEAN)(Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback,
@ -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.

View File

@ -146,9 +146,7 @@ HttpBootParseDhcp6Options (
// OpLen and OpCode here are both stored in network order.
//
while (Offset < Length) {
if (NTOHS (Option->OpCode) == OptTag) {
return Option;
}
@ -157,7 +155,6 @@ HttpBootParseDhcp6Options (
}
return NULL;
}
/**
@ -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) {
@ -223,6 +219,7 @@ HttpBootParseDhcp6Packet (
Offset += (NTOHS (Option->OpLen) + 4);
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;
}
@ -304,7 +302,6 @@ HttpBootParseDhcp6Packet (
OfferType = HttpOfferTypeProxyNameUri;
}
}
} else {
if (!IsProxyOffer) {
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
@ -434,7 +431,8 @@ HttpBootDhcp6CallBack (
(Dhcp6Event != Dhcp6RcvdAdvertise) &&
(Dhcp6Event != Dhcp6SendRequest) &&
(Dhcp6Event != Dhcp6RcvdReply) &&
(Dhcp6Event != Dhcp6SelectAdvertise)) {
(Dhcp6Event != Dhcp6SelectAdvertise))
{
return EFI_SUCCESS;
}
@ -442,7 +440,7 @@ HttpBootDhcp6CallBack (
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
Status = EFI_SUCCESS;
if (Private->HttpBootCallback != NULL && Dhcp6Event != Dhcp6SelectAdvertise) {
if ((Private->HttpBootCallback != NULL) && (Dhcp6Event != Dhcp6SelectAdvertise)) {
Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback,
@ -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);
}
@ -670,6 +678,7 @@ HttpBootSetIp6Policy (
return Status;
}
}
return EFI_SUCCESS;
}
@ -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,6 +888,7 @@ HttpBootSetIp6Address (
if (Ip6Addr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = Ip6Cfg->GetData (
Ip6Cfg,
Ip6ConfigDataTypeManualAddress,
@ -894,6 +905,7 @@ HttpBootSetIp6Address (
break;
}
}
if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) {
Status = EFI_ABORTED;
goto ON_EXIT;
@ -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;
}

View File

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

View File

@ -29,8 +29,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
NULL
};
/**
Check whether UNDI protocol supports IPv6.
@ -81,14 +79,14 @@ HttpBootCheckIpv6Support (
&gEfiAdapterInformationProtocolGuid,
(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,7 +110,7 @@ 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;
}
@ -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) {
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.
@ -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);
@ -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;
@ -544,6 +539,7 @@ 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));
@ -563,6 +559,7 @@ 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));
@ -629,7 +626,6 @@ ON_ERROR:
return Status;
}
/**
Stops a device controller or a bus controller.
@ -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;
}
/**
@ -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);
@ -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;
@ -1075,6 +1071,7 @@ 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;
@ -1094,6 +1091,7 @@ 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));
@ -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
@ -1327,6 +1326,6 @@ HttpBootDxeDriverEntryPoint (
&gHttpBootDxeComponentName2
);
}
return Status;
}

View File

@ -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

View File

@ -41,7 +41,6 @@ HttpBootInstallCallback (
(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;
}
@ -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;
}
@ -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");
@ -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;
@ -682,11 +688,13 @@ HttpBootCallback (
case HttpBootHttpRequest:
if (Data != NULL) {
HttpMessage = (EFI_HTTP_MESSAGE *)Data;
if (HttpMessage->Data.Request->Method == HttpMethodGet &&
HttpMessage->Data.Request->Url != NULL) {
if ((HttpMessage->Data.Request->Method == HttpMethodGet) &&
(HttpMessage->Data.Request->Url != NULL))
{
Print (L"\n URI: %s\n", HttpMessage->Data.Request->Url);
}
}
break;
case HttpBootHttpResponse:
@ -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,6 +744,7 @@ 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);
if (Private->Percentage != Percentage) {
@ -749,11 +760,12 @@ HttpBootCallback (
Print (L"\r Downloading...%lu Bytes", Private->ReceivedSize);
}
}
break;
default:
break;
};
}
return EFI_SUCCESS;
}

View File

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

View File

@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "HttpBootDxe.h"
/**
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);
@ -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 (":");
@ -283,7 +285,6 @@ HttpBootPrintErrorMessage (
break;
default:;
}
}
@ -364,6 +365,7 @@ HttpBootDns (
}
}
}
//
// Create a DNSv6 child instance and get the protocol.
//
@ -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,7 +586,8 @@ HttpBootParseFilePath (
TempDevicePath = FilePath;
while (!IsDevicePathEnd (TempDevicePath)) {
if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (TempDevicePath) == MSG_URI_DP)) {
(DevicePathSubType (TempDevicePath) == MSG_URI_DP))
{
UriDevicePath = (URI_DEVICE_PATH *)TempDevicePath;
//
// UEFI Spec doesn't require the URI to be a NULL-terminated string
@ -591,15 +600,18 @@ HttpBootParseFilePath (
//
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';
*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;
}
@ -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;
}

View File

@ -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

View File

@ -40,7 +40,6 @@ HttpDns4 (
EFI_IPv4_ADDRESS *DnsServerList;
UINTN DataSize;
Service = HttpInstance->Service;
ASSERT (Service != NULL);
@ -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);
@ -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);
}

View File

@ -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;
}
if (!UsingIpv6) {
if (HttpService->Tcp4ChildHandle != NULL) {
gBS->CloseProtocol (
@ -127,7 +126,6 @@ HttpCleanService (
HttpService->Tcp6ChildHandle = NULL;
}
}
}
/**
@ -154,7 +152,7 @@ HttpUtilitiesInstalledCallback (
//
// Close the event if Http utilities protocol is located.
//
if (mHttpUtilities != NULL && Event != NULL) {
if ((mHttpUtilities != NULL) && (Event != NULL)) {
gBS->CloseEvent (Event);
}
}
@ -230,6 +228,7 @@ HttpDxeDriverEntryPoint (
&gHttpDxeComponentName2
);
}
return Status;
}
@ -256,7 +255,7 @@ HttpDestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) {
if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -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;
}
/**
@ -540,7 +533,6 @@ HttpDxeStop (
);
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.

View File

@ -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.
//
@ -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;
}
@ -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;
}
/**
@ -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,7 +937,7 @@ HttpBodyParserCallback (
return EFI_SUCCESS;
}
if (Data == NULL || Length != 0 || Context == NULL) {
if ((Data == NULL) || (Length != 0) || (Context == NULL)) {
return EFI_SUCCESS;
}
@ -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
@ -1193,7 +1196,6 @@ HttpResponseWorker (
FreePool (HttpHeaders);
HttpHeaders = NULL;
//
// Init message-body parser by header information.
//
@ -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) {
//
@ -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);
}

View File

@ -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.

View File

@ -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);
}
/**
@ -159,7 +156,6 @@ HttpTcpReceiveNotifyDpc (
return;
}
} else {
gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);
Wrap->TcpWrap.Rx4Token.CompletionToken.Event = NULL;
@ -232,6 +228,7 @@ HttpTcpReceiveNotifyDpc (
if (HttpInstance->CacheBody == NULL) {
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.
@ -393,7 +386,6 @@ HttpCloseTcpConnCloseEvent (
gBS->CloseEvent (HttpInstance->Tcp6CloseToken.CompletionToken.Event);
HttpInstance->Tcp6CloseToken.CompletionToken.Event = NULL;
}
} else {
if (NULL != HttpInstance->Tcp4ConnToken.CompletionToken.Event) {
gBS->CloseEvent (HttpInstance->Tcp4ConnToken.CompletionToken.Event);
@ -405,7 +397,6 @@ HttpCloseTcpConnCloseEvent (
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,
@ -464,7 +454,6 @@ HttpCreateTcpTxEvent (
TcpWrap->Tx6Data.FragmentCount = 1;
TcpWrap->Tx6Token.Packet.TxData = &Wrap->TcpWrap.Tx6Data;
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,
@ -517,10 +505,8 @@ HttpCreateTcpRxEventForHeader (
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,
@ -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;
@ -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));
@ -1196,7 +1175,6 @@ HttpConfigureTcp6 (
HttpInstance->State = HTTP_STATE_TCP_CONFIGED;
return EFI_SUCCESS;
}
/**
@ -1218,8 +1196,7 @@ 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;
}
@ -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;
}
@ -1406,6 +1383,7 @@ HttpInitSession (
)
{
EFI_STATUS Status;
ASSERT (HttpInstance != NULL);
//
@ -1457,7 +1435,6 @@ HttpInitSession (
}
return EFI_SUCCESS;
}
/**
@ -1590,7 +1567,6 @@ HttpTransmitTcp (
DEBUG ((DEBUG_ERROR, "Transmit failed: %r\n", Status));
goto ON_ERROR;
}
} else {
Tcp6 = HttpInstance->Tcp6;
Tx6Token = &Wrap->TcpWrap.Tx6Token;
@ -1662,7 +1638,7 @@ HttpTokenExist (
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;
}
@ -1755,7 +1731,7 @@ HttpTcpTransmit (
);
FreePool (Url);
if (EFI_ERROR (Status) || NULL == RequestMsg){
if (EFI_ERROR (Status) || (NULL == RequestMsg)) {
return Status;
}
@ -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;
@ -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;
@ -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;
}
}
}
/**
@ -2248,6 +2220,7 @@ HttpNotify (
);
}
}
FreePool (Handles);
}
}

View File

@ -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) \

View File

@ -56,7 +56,8 @@ AsciiStrCaseStr (
FirstMatch = String;
while ( (*SearchStringTmp != '\0')
&& (*String != '\0')) {
&& (*String != '\0'))
{
Src = *String;
Dst = *SearchStringTmp;
@ -123,7 +124,7 @@ IsHttpsUrl (
Tmp = NULL;
Tmp = AsciiStrCaseStr (Url, HTTPS_FLAG);
if (Tmp != NULL && Tmp == Url) {
if ((Tmp != NULL) && (Tmp == Url)) {
return TRUE;
}
@ -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;
}
@ -432,57 +433,77 @@ TlsConfigCertificate (
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));
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;
@ -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;
}
@ -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;
}
@ -1042,15 +1066,16 @@ TlsReceiveOnePdu (
}
RecordHeader = *(TLS_RECORD_HEADER *)Header;
if ((RecordHeader.ContentType == TlsContentTypeHandshake ||
RecordHeader.ContentType == TlsContentTypeAlert ||
RecordHeader.ContentType == TlsContentTypeChangeCipherSpec ||
RecordHeader.ContentType == TlsContentTypeApplicationData) &&
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;
@ -1190,6 +1215,7 @@ TlsConnectSession (
&BufferOutSize
);
}
if (EFI_ERROR (Status)) {
FreePool (BufferOut);
return Status;
@ -1216,7 +1242,8 @@ TlsConnectSession (
}
while (HttpInstance->TlsSessionState != EfiTlsSessionDataTransferring && \
((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout)))) {
((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout))))
{
//
// Receive one TLS record.
//
@ -1335,6 +1362,7 @@ TlsConnectSession (
&GetSessionDataBufferSize
);
}
if (EFI_ERROR (Status)) {
FreePool (GetSessionDataBuffer);
return Status;
@ -1578,6 +1606,7 @@ ON_EXIT:
if ( FragmentTable == OriginalFragmentTable) {
FragmentTable = NULL;
}
FreePool (OriginalFragmentTable);
OriginalFragmentTable = NULL;
}
@ -1665,10 +1694,11 @@ HttpsReceive (
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,6 +1748,7 @@ HttpsReceive (
&BufferOutSize
);
}
if (EFI_ERROR (Status)) {
FreePool (BufferOut);
return Status;
@ -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) {
@ -1863,6 +1894,7 @@ HttpsReceive (
&GetSessionDataBufferSize
);
}
if (EFI_ERROR (Status)) {
FreePool (GetSessionDataBuffer);
return Status;

View File

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

View File

@ -9,7 +9,6 @@
#include "HttpUtilitiesDxe.h"
/**
Unloads an image.
@ -31,7 +30,6 @@ HttpUtilitiesDxeUnload (
UINT32 Index;
EFI_HTTP_UTILITIES_PROTOCOL *HttpUtilitiesProtocol;
HandleBuffer = NULL;
//
@ -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;
}

View File

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

View File

@ -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,7 +105,7 @@ HttpUtilitiesBuild (
//
// Handle DeleteList
//
if (SeedFieldCount != 0 && DeleteCount != 0) {
if ((SeedFieldCount != 0) && (DeleteCount != 0)) {
TempHeaderFields = AllocateZeroPool (SeedFieldCount * sizeof (EFI_HTTP_HEADER));
if (TempHeaderFields == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@ -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++;
}
}
@ -198,6 +199,7 @@ HttpUtilitiesBuild (
StrLength = sizeof ("\r\n") - 1;
*NewMessageSize += StrLength;
}
StrLength = sizeof ("\r\n") - 1;
*NewMessageSize += StrLength;
@ -228,6 +230,7 @@ HttpUtilitiesBuild (
CopyMem (NewMessagePtr, "\r\n", StrLength);
NewMessagePtr += StrLength;
}
StrLength = sizeof ("\r\n") - 1;
CopyMem (NewMessagePtr, "\r\n", StrLength);
NewMessagePtr += StrLength;
@ -253,7 +256,6 @@ ON_EXIT:
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;
}
@ -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;
}

View File

@ -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.
//
@ -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.
@ -375,6 +379,7 @@ IScsiCHAPOnRspReceived (
Status = EFI_PROTOCOL_ERROR;
goto ON_EXIT;
}
Status = IScsiCHAPCalculateResponse (
AuthData->InIdentifier,
AuthData->AuthConfig->CHAPSecret,
@ -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.
@ -487,6 +491,7 @@ IScsiCHAPToSendReq (
if (LoginReq == NULL) {
return EFI_PROTOCOL_ERROR;
}
Status = EFI_SUCCESS;
RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
@ -592,6 +597,7 @@ IScsiCHAPToSendReq (
Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
}
//
// Set the stage transition flag.
//

View File

@ -35,7 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define ISCSI_CHAP_STEP_THREE 3
#define ISCSI_CHAP_STEP_FOUR 4
#pragma pack(1)
typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
@ -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

View File

@ -33,7 +33,6 @@ HII_VENDOR_DEVICE_PATH mIScsiHiiVendorDevicePath = {
}
};
/**
Convert the IP address into a dotted string.
@ -77,10 +76,11 @@ IScsiIpToStr (
for (Index = 0; Index < 15; Index = Index + 2) {
if (!Short &&
Index % 2 == 0 &&
Ip6->Addr[Index] == 0 &&
Ip6->Addr[Index + 1] == 0
) {
(Index % 2 == 0) &&
(Ip6->Addr[Index] == 0) &&
(Ip6->Addr[Index + 1] == 0)
)
{
//
// Deal with the case of ::.
//
@ -159,6 +159,7 @@ IpIsUnicast (
if (IP4_IS_UNSPECIFIED (NTOHL (Ip->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip->Addr[0]))) {
return FALSE;
}
return TRUE;
} else if (IpMode == IP_MODE_IP6) {
return NetIp6IsValidUnicast (&Ip->v6);
@ -197,7 +198,7 @@ IScsiParseIsIdFromString (
IsIdStr = (CHAR16 *)String;
if (StrLen (IsIdStr) != 6 && StrLen (IsIdStr) != 12) {
if ((StrLen (IsIdStr) != 6) && (StrLen (IsIdStr) != 12)) {
UnicodeSPrint (
PortString,
(UINTN)ISCSI_NAME_IFR_MAX_SIZE,
@ -274,7 +275,6 @@ IScsiConvertIsIdToString (
L"%X",
(UINTN)IsId[Index]
);
}
String = String + Number;
@ -329,6 +329,7 @@ IScsiGetValue (
while (*StringPtr != L'\0' && *StringPtr != L'&') {
StringPtr++;
}
Length = StringPtr - TmpPtr;
Len = Length + 1;
@ -404,7 +405,6 @@ IScsiConfigGetAttemptByConfigIndex (
return NULL;
}
/**
Get the existing attempt config data from global structure by the NicIndex.
@ -428,8 +428,9 @@ IScsiConfigGetAttemptByNic (
NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
if (Attempt != NewAttempt && Attempt->NicIndex == NewAttempt->NicIndex &&
Attempt->SessionConfigData.Enabled == IScsiMode) {
if ((Attempt != NewAttempt) && (Attempt->NicIndex == NewAttempt->NicIndex) &&
(Attempt->SessionConfigData.Enabled == IScsiMode))
{
return Attempt;
}
}
@ -476,6 +477,7 @@ IScsiGetAttemptIndexList (
if (AttemptStr == NULL) {
return EFI_INVALID_PARAMETER;
}
AttemptStr += Len;
AttemptIndex = (UINT8)(*AttemptStr - L'0');
AttemptConfigData = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
@ -493,6 +495,7 @@ IScsiGetAttemptIndexList (
Index++;
AttemptStr += 2;
}
return EFI_SUCCESS;
}
@ -538,7 +541,6 @@ IScsiConvertAttemptConfigDataToIfrNvData (
CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof (EFI_IPv4_ADDRESS));
IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp);
}
} else if (IfrNvData->IpMode == IP_MODE_IP6) {
ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
if (SessionConfigData->TargetIp.v6.Addr[0] != '\0') {
@ -804,7 +806,7 @@ IScsiConvertIfrNvDataToAttemptConfigData (
UINTN TotalNumber;
EFI_STATUS Status;
if (IfrNvData == NULL || Attempt == NULL) {
if ((IfrNvData == NULL) || (Attempt == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -878,10 +880,11 @@ IScsiConvertIfrNvDataToAttemptConfigData (
}
}
}
//
// Validate target configuration if DHCP isn't deployed.
//
if (!Attempt->SessionConfigData.TargetInfoFromDhcp && Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
if (!Attempt->SessionConfigData.TargetInfoFromDhcp && (Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG)) {
if (!Attempt->SessionConfigData.DnsMode) {
if (!IpIsUnicast (&Attempt->SessionConfigData.TargetIp, IfrNvData->IpMode)) {
CreatePopUp (
@ -937,7 +940,8 @@ IScsiConvertIfrNvDataToAttemptConfigData (
if ((IfrNvData->CHAPType == ISCSI_CHAP_MUTUAL) &&
((IfrNvData->ReverseCHAPName[0] == '\0') || (IfrNvData->ReverseCHAPSecret[0] == '\0'))
) {
)
{
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@ -1048,9 +1052,9 @@ IScsiConvertIfrNvDataToAttemptConfigData (
if (ExistAttempt != NULL) {
ASSERT (ExistAttempt == Attempt);
if (IfrNvData->Enabled == ISCSI_DISABLED &&
Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
if ((IfrNvData->Enabled == ISCSI_DISABLED) &&
(Attempt->SessionConfigData.Enabled != ISCSI_DISABLED))
{
//
// User updates the Attempt from "Enabled"/"Enabled for MPIO" to "Disabled".
//
@ -1066,11 +1070,12 @@ IScsiConvertIfrNvDataToAttemptConfigData (
if (mPrivate->SinglePathCount < 1) {
return EFI_ABORTED;
}
mPrivate->SinglePathCount--;
}
} else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO &&
Attempt->SessionConfigData.Enabled == ISCSI_ENABLED) {
} else if ((IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) &&
(Attempt->SessionConfigData.Enabled == ISCSI_ENABLED))
{
//
// User updates the Attempt from "Enabled" to "Enabled for MPIO".
//
@ -1081,9 +1086,9 @@ IScsiConvertIfrNvDataToAttemptConfigData (
mPrivate->EnableMpio = TRUE;
mPrivate->MpioCount++;
mPrivate->SinglePathCount--;
} else if (IfrNvData->Enabled == ISCSI_ENABLED &&
Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
} else if ((IfrNvData->Enabled == ISCSI_ENABLED) &&
(Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO))
{
//
// User updates the Attempt from "Enabled for MPIO" to "Enabled".
//
@ -1094,22 +1099,21 @@ IScsiConvertIfrNvDataToAttemptConfigData (
if (--mPrivate->MpioCount == 0) {
mPrivate->EnableMpio = FALSE;
}
mPrivate->SinglePathCount++;
} else if (IfrNvData->Enabled != ISCSI_DISABLED &&
Attempt->SessionConfigData.Enabled == ISCSI_DISABLED) {
mPrivate->SinglePathCount++;
} else if ((IfrNvData->Enabled != ISCSI_DISABLED) &&
(Attempt->SessionConfigData.Enabled == ISCSI_DISABLED))
{
//
// User updates the Attempt from "Disabled" to "Enabled"/"Enabled for MPIO".
//
if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) {
mPrivate->EnableMpio = TRUE;
mPrivate->MpioCount++;
} else if (IfrNvData->Enabled == ISCSI_ENABLED) {
mPrivate->SinglePathCount++;
}
}
} else if (ExistAttempt == NULL) {
//
// When a new attempt is created, pointer of the attempt is saved to
@ -1138,6 +1142,7 @@ IScsiConvertIfrNvDataToAttemptConfigData (
if (AttemptConfigOrder != NULL) {
FreePool (AttemptConfigOrder);
}
return EFI_OUT_OF_RESOURCES;
}
@ -1180,6 +1185,7 @@ IScsiConvertIfrNvDataToAttemptConfigData (
IScsiConfigUpdateAttempt ();
}
Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;
//
@ -1237,13 +1243,13 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
if (OffSet < ATTEMPT_BOOTENABLE_VAR_OFFSET) {
return EFI_SUCCESS;
} else if ((OffSet >= ATTEMPT_BOOTENABLE_VAR_OFFSET) && (OffSet < ATTEMPT_ADDRESS_TYPE_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_BOOTENABLE_VAR_OFFSET) + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
IfrNvData->Enabled = IfrNvData->ISCSIBootEnableList[AttemptIndex - 1];
//
// Validate the configuration of attempt.
@ -1288,9 +1294,9 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
}
}
if (IfrNvData->Enabled == ISCSI_DISABLED &&
Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
if ((IfrNvData->Enabled == ISCSI_DISABLED) &&
(Attempt->SessionConfigData.Enabled != ISCSI_DISABLED))
{
//
// User updates the Attempt from "Enabled"/"Enabled for MPIO" to "Disabled".
//
@ -1306,11 +1312,12 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
if (mPrivate->SinglePathCount < 1) {
return EFI_ABORTED;
}
mPrivate->SinglePathCount--;
}
} else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO &&
Attempt->SessionConfigData.Enabled == ISCSI_ENABLED) {
} else if ((IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) &&
(Attempt->SessionConfigData.Enabled == ISCSI_ENABLED))
{
//
// User updates the Attempt from "Enabled" to "Enabled for MPIO".
//
@ -1321,9 +1328,9 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
mPrivate->EnableMpio = TRUE;
mPrivate->MpioCount++;
mPrivate->SinglePathCount--;
} else if (IfrNvData->Enabled == ISCSI_ENABLED &&
Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
} else if ((IfrNvData->Enabled == ISCSI_ENABLED) &&
(Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO))
{
//
// User updates the Attempt from "Enabled for MPIO" to "Enabled".
//
@ -1334,34 +1341,34 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
if (--mPrivate->MpioCount == 0) {
mPrivate->EnableMpio = FALSE;
}
mPrivate->SinglePathCount++;
} else if (IfrNvData->Enabled != ISCSI_DISABLED &&
Attempt->SessionConfigData.Enabled == ISCSI_DISABLED) {
mPrivate->SinglePathCount++;
} else if ((IfrNvData->Enabled != ISCSI_DISABLED) &&
(Attempt->SessionConfigData.Enabled == ISCSI_DISABLED))
{
//
// User updates the Attempt from "Disabled" to "Enabled"/"Enabled for MPIO".
//
if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) {
mPrivate->EnableMpio = TRUE;
mPrivate->MpioCount++;
} else if (IfrNvData->Enabled == ISCSI_ENABLED) {
mPrivate->SinglePathCount++;
}
}
Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;
Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;
} else if ((OffSet >= ATTEMPT_ADDRESS_TYPE_VAR_OFFSET) && (OffSet < ATTEMPT_CONNECT_RETRY_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_ADDRESS_TYPE_VAR_OFFSET) + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
Attempt->SessionConfigData.IpMode = IfrNvData->ISCSIIpAddressTypeList[AttemptIndex - 1];
if (Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
Attempt->AutoConfigureMode = 0;
}
} else if ((OffSet >= ATTEMPT_CONNECT_RETRY_VAR_OFFSET) && (OffSet < ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_CONNECT_RETRY_VAR_OFFSET) + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
@ -1378,8 +1385,8 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ISCSIConnectRetry[AttemptIndex - 1];
Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ISCSIConnectRetry[AttemptIndex - 1];
} else if ((OffSet >= ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) / 2 + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
@ -1388,7 +1395,8 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
}
if ((IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] < CONNECT_MIN_TIMEOUT) ||
(IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] > CONNECT_MAX_TIMEOUT)) {
(IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] > CONNECT_MAX_TIMEOUT))
{
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@ -1402,15 +1410,14 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
if (Attempt->SessionConfigData.ConnectTimeout == 0) {
Attempt->SessionConfigData.ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
}
} else if ((OffSet >= ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
Attempt->SessionConfigData.InitiatorInfoFromDhcp = IfrNvData->ISCSIInitiatorInfoViaDHCP[AttemptIndex - 1];
Attempt->SessionConfigData.InitiatorInfoFromDhcp = IfrNvData->ISCSIInitiatorInfoViaDHCP[AttemptIndex - 1];
} else if ((OffSet >= ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET) + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
@ -1429,13 +1436,13 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET) && (OffSet < ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET) / 2 + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) {
Attempt->SessionConfigData.TargetPort = IfrNvData->ISCSITargetTcpPort[AttemptIndex - 1];
if (Attempt->SessionConfigData.TargetPort == 0) {
@ -1450,7 +1457,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET) && (OffSet < ATTEMPT_CHARTYPE_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET) + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
@ -1459,17 +1465,16 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
}
Attempt->AuthenticationType = IfrNvData->ISCSIAuthenticationMethod[AttemptIndex - 1];
} else if ((OffSet >= ATTEMPT_CHARTYPE_VAR_OFFSET) && (OffSet < ATTEMPT_ISID_VAR_OFFSET)) {
AttemptIndex = (UINT8)((OffSet - ATTEMPT_CHARTYPE_VAR_OFFSET) + 1);
Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex);
if (Attempt == NULL) {
return EFI_INVALID_PARAMETER;
}
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
Attempt->AuthConfigData.CHAP.CHAPType = IfrNvData->ISCSIChapType[AttemptIndex - 1];
}
} else if (OffSet >= ATTEMPT_ISID_VAR_OFFSET) {
Index = (UINT8)((OffSet - ATTEMPT_ISID_VAR_OFFSET) / sizeof (KEYWORD_STR));
AttemptIndex = Index + 1;
@ -1482,7 +1487,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
if ((OffSet >= ATTEMPT_ISID_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET)) {
IScsiParseIsIdFromString (IfrNvData->Keyword[Index].ISCSIIsId, Attempt->SessionConfigData.IsId);
} else if ((OffSet >= ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
//
@ -1490,7 +1494,8 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
//
Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorIpAddress, &HostIp.v4);
if (EFI_ERROR (Status) || ((Attempt->SessionConfigData.SubnetMask.Addr[0] != 0) &&
!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Attempt->SessionConfigData.SubnetMask.Addr)))) {
!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL (*(UINT32 *)Attempt->SessionConfigData.SubnetMask.Addr))))
{
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@ -1510,7 +1515,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorNetmask, &SubnetMask.v4);
@ -1534,13 +1538,13 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_NAME_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) {
Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorGateway, &Gateway.v4);
if (EFI_ERROR (Status) ||
((Gateway.Addr[0] != 0) && (Attempt->SessionConfigData.SubnetMask.Addr[0] != 0) &&
!NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Attempt->SessionConfigData.SubnetMask.Addr)))) {
!NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (*(UINT32 *)Attempt->SessionConfigData.SubnetMask.Addr))))
{
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@ -1560,7 +1564,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_TARGET_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) {
UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSITargetName, IScsiName, ISCSI_NAME_MAX_SIZE);
@ -1575,6 +1578,7 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
} else {
AsciiStrCpyS (Attempt->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName);
}
if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) {
if (Attempt->SessionConfigData.TargetName[0] == L'\0') {
CreatePopUp (
@ -1595,7 +1599,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_LUN_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) {
UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSITargetIpAddress, IpString, sizeof (IpString));
@ -1617,7 +1620,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_LUN_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_USER_NAME_VAR_OFFSET)) {
if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (Attempt->SessionConfigData.TargetInfoFromDhcp == 0)) {
//
@ -1644,7 +1646,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_CHAR_USER_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_SECRET_VAR_OFFSET)) {
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
UnicodeStrToAsciiStrS (
@ -1673,7 +1674,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_CHAR_SECRET_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET)) {
if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
ChapSecretLen = (UINT8)StrLen (IfrNvData->Keyword[Index].ISCSIChapSecret);
@ -1703,7 +1703,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if ((OffSet >= ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET)) {
if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) {
UnicodeStrToAsciiStrS (
@ -1731,7 +1730,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
);
return EFI_INVALID_PARAMETER;
}
} else if (OffSet >= ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET) {
if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) {
ReverseChapSecretLen = (UINT8)StrLen (IfrNvData->Keyword[Index].ISCSIReverseChapSecret);
@ -1764,8 +1762,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
}
}
//
// Record the user configuration information in NVR.
//
@ -1778,7 +1774,6 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
Attempt
);
}
/**
@ -1810,7 +1805,7 @@ IScsiCreateOpCode (
EFI_IFR_GUID_LABEL *InternalStartLabel;
EFI_IFR_GUID_LABEL *InternalEndLabel;
if (StartOpCodeHandle == NULL || StartLabel == NULL || EndOpCodeHandle == NULL || EndLabel == NULL) {
if ((StartOpCodeHandle == NULL) || (StartLabel == NULL) || (EndOpCodeHandle == NULL) || (EndLabel == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -1877,6 +1872,7 @@ Exit:
if (*EndOpCodeHandle != NULL) {
HiiFreeOpCodeHandle (*EndOpCodeHandle);
}
return Status;
}
@ -2118,7 +2114,7 @@ IScsiConfigAddAttemptsByKeywords (
(VOID **)&AttemptConfigData,
NULL
);
if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) {
if ((AttemptConfigData == NULL) || (AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED)) {
return EFI_INVALID_PARAMETER;
}
@ -2180,8 +2176,10 @@ IScsiConfigAddAttemptsByKeywords (
if (AttemptConfigOrder != NULL) {
FreePool (AttemptConfigOrder);
}
return EFI_OUT_OF_RESOURCES;
}
if (AttemptConfigOrder != NULL) {
CopyMem (AttemptConfigOrderTmp, AttemptConfigOrder, AttemptConfigOrderSize);
FreePool (AttemptConfigOrder);
@ -2216,7 +2214,6 @@ IScsiConfigAddAttemptsByKeywords (
sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
AttemptConfigData
);
}
return EFI_SUCCESS;
@ -2324,6 +2321,7 @@ IScsiConfigDeleteAttempts (
if (AttemptConfigData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
ConfigData = &AttemptConfigData->SessionConfigData;
ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT;
ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
@ -2368,6 +2366,7 @@ IScsiConfigDeleteAttempts (
if (mCallbackInfo->Current == AttemptConfigData) {
mCallbackInfo->Current = NULL;
}
FreePool (AttemptConfigData);
//
@ -2411,7 +2410,6 @@ Error:
return Status;
}
/**
Callback function when user presses "Delete Attempts".
@ -2427,7 +2425,6 @@ IScsiConfigDisplayDeleteAttempts (
IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData
)
{
UINT8 *AttemptConfigOrder;
UINTN AttemptConfigOrderSize;
LIST_ENTRY *Entry;
@ -2501,7 +2498,6 @@ IScsiConfigDisplayDeleteAttempts (
return Status;
}
/**
Callback function when user presses "Change Attempt Order".
@ -2536,6 +2532,7 @@ IScsiConfigDisplayOrderAttempts (
if (EFI_ERROR (Status)) {
return Status;
}
ASSERT (StartOpCodeHandle != NULL);
OptionsOpCodeHandle = NULL;
@ -2710,7 +2707,6 @@ Exit:
return Status;
}
/**
Callback function when a user presses "Attempt *" or when a user selects a NIC to
create the new attempt.
@ -2751,14 +2747,15 @@ IScsiConfigProcessDefault (
NewAttempt = FALSE;
if ((KeyValue >= KEY_MAC_ENTRY_BASE) &&
(KeyValue <= (UINT16) (mPrivate->MaxNic + KEY_MAC_ENTRY_BASE))) {
(KeyValue <= (UINT16)(mPrivate->MaxNic + KEY_MAC_ENTRY_BASE)))
{
//
// User has pressed "Add an Attempt" and then selects a NIC.
//
NewAttempt = TRUE;
} else if ((KeyValue >= KEY_ATTEMPT_ENTRY_BASE) &&
(KeyValue < (ISCSI_MAX_ATTEMPTS_NUM + KEY_ATTEMPT_ENTRY_BASE))) {
(KeyValue < (ISCSI_MAX_ATTEMPTS_NUM + KEY_ATTEMPT_ENTRY_BASE)))
{
//
// User has pressed "Attempt *".
//
@ -2806,7 +2803,7 @@ IScsiConfigProcessDefault (
(VOID **)&AttemptConfigData,
NULL
);
if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) {
if ((AttemptConfigData == NULL) || (AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED)) {
continue;
}
@ -2872,7 +2869,6 @@ IScsiConfigProcessDefault (
FreePool (AttemptConfigData);
return EFI_OUT_OF_RESOURCES;
}
} else {
//
// Determine which Attempt user has selected to configure.
@ -2907,7 +2903,6 @@ IScsiConfigProcessDefault (
return EFI_SUCCESS;
}
/**
This function allows the caller to request the current
@ -2998,7 +2993,7 @@ IScsiFormExtractConfig (
BOOLEAN AllocatedRequest;
UINTN Size;
if (This == NULL || Progress == NULL || Results == NULL) {
if ((This == NULL) || (Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -3018,7 +3013,6 @@ IScsiFormExtractConfig (
return EFI_OUT_OF_RESOURCES;
}
if (Private->Current != NULL) {
IScsiConvertAttemptConfigDataToIfrNvData (Private->Current, IfrNvData);
}
@ -3065,6 +3059,7 @@ IScsiFormExtractConfig (
FreePool (InitiatorName);
return EFI_OUT_OF_RESOURCES;
}
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr);
@ -3088,6 +3083,7 @@ IScsiFormExtractConfig (
FreePool (ConfigRequest);
ConfigRequest = NULL;
}
//
// Set Progress string to the original request string.
//
@ -3100,7 +3096,6 @@ IScsiFormExtractConfig (
return Status;
}
/**
This function applies changes in a driver's configuration.
@ -3170,7 +3165,7 @@ IScsiFormRouteConfig (
AttemptList = NULL;
Status = EFI_SUCCESS;
if (This == NULL || Configuration == NULL || Progress == NULL) {
if ((This == NULL) || (Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -3261,13 +3256,13 @@ IScsiFormRouteConfig (
if (EFI_ERROR (Status)) {
goto Exit;
}
} else if (IfrNvData->ISCSIDeleteAttemptList[0] != L'\0') {
AttemptList = (UINT8 *)AllocateZeroPool ((ISCSI_MAX_ATTEMPTS_NUM + 1) * sizeof (UINT8));
if (AttemptList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
Status = IScsiGetAttemptIndexList (IfrNvData->ISCSIDeleteAttemptList, AttemptList, FALSE);
if (EFI_ERROR (Status)) {
CreatePopUp (
@ -3289,8 +3284,10 @@ IScsiFormRouteConfig (
IfrNvData->DeleteAttemptList[Index2] = 1;
break;
}
Index++;
}
Index2++;
Index = 0;
}
@ -3301,7 +3298,6 @@ IScsiFormRouteConfig (
}
FreePool (AttemptList);
} else if (IfrNvData->ISCSIAttemptOrder[0] != L'\0') {
Status = IScsiGetAttemptIndexList (IfrNvData->ISCSIAttemptOrder, IfrNvData->DynamicOrderedList, FALSE);
if (EFI_ERROR (Status)) {
@ -3318,7 +3314,6 @@ IScsiFormRouteConfig (
if (EFI_ERROR (Status)) {
goto Exit;
}
} else if (IfrNvData->ISCSIMacAddr[0] != L'\0') {
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
@ -3338,7 +3333,6 @@ IScsiFormRouteConfig (
Status = EFI_NOT_FOUND;
goto Exit;
}
} else {
Status = IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (IfrNvData, OffSet);
if (EFI_ERROR (Status)) {
@ -3622,7 +3616,8 @@ IScsiFormCallback (
Status = NetLibStrToIp4 (IfrNvData->LocalIp, &HostIp.v4);
if (EFI_ERROR (Status) ||
((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {
!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL (*(UINT32 *)Private->Current->SessionConfigData.SubnetMask.Addr))))
{
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@ -3659,7 +3654,8 @@ IScsiFormCallback (
if (EFI_ERROR (Status) ||
((Gateway.Addr[0] != 0) &&
(Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
!NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {
!NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (*(UINT32 *)Private->Current->SessionConfigData.SubnetMask.Addr))))
{
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@ -3797,7 +3793,6 @@ IScsiFormCallback (
return Status;
}
/**
Initialize the iSCSI configuration form.
@ -3868,7 +3863,6 @@ IScsiConfigFormInit (
return EFI_SUCCESS;
}
/**
Unload the iSCSI configuration form, this includes: delete all the iSCSI
configuration entries, uninstall the form callback protocol, and

View File

@ -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)

View File

@ -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.
@ -51,6 +50,7 @@ IScsiDhcpExtractRootPath (
if ((Length <= IScsiRootPathIdLen) || (CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) {
return EFI_NOT_FOUND;
}
//
// Skip the iSCSI RootPath ID "iscsi:".
//
@ -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,6 +126,7 @@ 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 {
@ -137,6 +139,7 @@ IScsiDhcpExtractRootPath (
goto ON_EXIT;
}
}
//
// Check the protocol type.
//
@ -145,6 +148,7 @@ IScsiDhcpExtractRootPath (
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
//
// Get the port of the iSCSI target.
//
@ -154,6 +158,7 @@ IScsiDhcpExtractRootPath (
} 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.
//
@ -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.
//
@ -534,6 +541,7 @@ IScsiDoDhcp (
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
//
// Parse the ACK to get required information.
//

View File

@ -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.
@ -51,9 +50,11 @@ IScsiDhcp6ExtractRootPath (
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:".
//
@ -100,6 +101,7 @@ IScsiDhcp6ExtractRootPath (
while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) {
Index++;
}
//
// Skip ':'.
//
@ -113,7 +115,6 @@ IScsiDhcp6ExtractRootPath (
// 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];
}
@ -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,6 +166,7 @@ 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 {
@ -184,6 +187,7 @@ IScsiDhcp6ExtractRootPath (
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
//
// Get the port of the iSCSI target.
//
@ -193,6 +197,7 @@ IScsiDhcp6ExtractRootPath (
} 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.
//
@ -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.
//
@ -363,7 +370,6 @@ Exit:
return Status;
}
/**
Parse the DHCP ACK to get the address configuration and DNS information.
@ -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;
}

View File

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

View File

@ -89,7 +89,6 @@ IScsiDns4 (
}
}
//
// Create a DNS child instance and get the protocol.
//
@ -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);
}
@ -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;
}

View File

@ -112,7 +112,7 @@ IScsiCheckAip (
&AipHandleCount,
&AipHandleBuffer
);
if (EFI_ERROR (Status) || AipHandleCount == 0) {
if (EFI_ERROR (Status) || (AipHandleCount == 0)) {
return EFI_NOT_FOUND;
}
@ -134,16 +134,17 @@ IScsiCheckAip (
&gEfiExtScsiPassThruProtocolGuid,
(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,7 +167,7 @@ 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;
}
@ -180,18 +181,20 @@ IScsiCheckAip (
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.
@ -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;
}
}
@ -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.
@ -1102,6 +1113,7 @@ IScsiStop (
TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
}
IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid);
if (IScsiController == NULL) {
return EFI_SUCCESS;
@ -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,
@ -1587,6 +1602,7 @@ IScsiUnload (
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
gIScsiControllerNameTable = NULL;
}
@ -1873,4 +1889,3 @@ Error1:
return Status;
}

View File

@ -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:
@ -274,7 +272,6 @@ IScsiExtScsiPassThruBuildDevicePath (
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;
}
@ -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;
}
}

View File

@ -35,7 +35,6 @@ IScsiInitIbfTableHeader (
CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64));
}
/**
Initialize the control section of the iSCSI Boot Firmware Table.
@ -83,7 +82,6 @@ IScsiInitControlSection (
}
}
/**
Add one item into the heap.
@ -109,7 +107,6 @@ IScsiAddHeapItem (
*(*Heap + Len) = 0;
}
/**
Fill the Initiator section of the iSCSI Boot Firmware Table.
@ -151,7 +148,6 @@ IScsiFillInitiatorSection (
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.
@ -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;
}
@ -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);
}
@ -364,9 +355,9 @@ IScsiFillNICAndTargetSections (
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);
@ -434,7 +425,6 @@ IScsiFillNICAndTargetSections (
}
}
/**
Publish and remove the iSCSI Boot Firmware Table according to the iSCSI
session status.
@ -472,7 +462,7 @@ IScsiPublishIbft (
if (EFI_ERROR (Status) || (Rsdp == NULL)) {
return;
} else if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) {
} else if ((Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) && (Rsdp->XsdtAddress != 0)) {
Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->XsdtAddress;
} else if (Rsdp->RsdtAddress != 0) {
Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->RsdtAddress;
@ -490,14 +480,16 @@ IScsiPublishIbft (
if (EFI_ERROR (Status)) {
return;
}
mIbftInstalled = FALSE;
}
//
// If there is no valid attempt configuration, just return.
//
if ((!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount == 0) ||
(mPrivate->EnableMpio && mPrivate->MpioCount <= mPrivate->Krb5MpioCount)) {
if ((!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount == 0)) ||
(mPrivate->EnableMpio && (mPrivate->MpioCount <= mPrivate->Krb5MpioCount)))
{
return;
}

View File

@ -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,6 +108,7 @@ IScsiSetInitiatorName (
*BufferSize = ISCSI_NAME_MAX_SIZE;
return EFI_INVALID_PARAMETER;
}
//
// Only support iqn iSCSI names.
//

View File

@ -36,7 +36,6 @@ IScsiStrTrim (
// Trim off the leading and trailing characters c
//
for (Pointer1 = Str; (*Pointer1 != 0) && (*Pointer1 == CharC); Pointer1++) {
;
}
Pointer2 = Str;
@ -51,13 +50,13 @@ IScsiStrTrim (
Pointer1++;
Pointer2++;
}
*Pointer2 = 0;
}
for (Pointer1 = Str + StrLen (Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) {
;
}
if (Pointer1 != Str + StrLen (Str) - 1) {
*(Pointer1 + 1) = 0;
}
@ -104,7 +103,6 @@ IScsiGetSubnetMaskPrefixLength (
return (UINT8)(32 - Len);
}
/**
Convert the hexadecimal encoded LUN string into the 64-bit LUN.
@ -136,7 +134,7 @@ IScsiAsciiStrToLun (
for (Index = 0; Index < SizeStr; Index++) {
TemStr[0] = Str[Index];
TemValue = (UINT8)AsciiStrHexToUint64 (TemStr);
if (TemValue == 0 && TemStr[0] != '0') {
if ((TemValue == 0) && (TemStr[0] != '0')) {
if ((TemStr[0] != '-') || (IndexNum == 0)) {
//
// Invalid Lun Char.
@ -155,6 +153,7 @@ IScsiAsciiStrToLun (
//
return EFI_INVALID_PARAMETER;
}
//
// Restart str index for the next lun value.
//
@ -201,7 +200,6 @@ IScsiLunToUnicodeStr (
TempStr = Str;
for (Index = 0; Index < 4; Index++) {
if ((Lun[2 * Index] | Lun[2 * Index + 1]) == 0) {
CopyMem (TempStr, L"0-", sizeof (L"0-"));
} else {
@ -217,6 +215,7 @@ IScsiLunToUnicodeStr (
TempStr += StrLen (TempStr);
}
//
// Remove the last '-'
//
@ -253,19 +252,17 @@ IScsiAsciiStrToIp (
{
EFI_STATUS Status;
if (IpMode == IP_MODE_IP4 || IpMode == IP_MODE_AUTOCONFIG_IP4) {
if ((IpMode == IP_MODE_IP4) || (IpMode == IP_MODE_AUTOCONFIG_IP4)) {
return NetLibAsciiStrToIp4 (Str, &Ip->v4);
} else if (IpMode == IP_MODE_IP6 || IpMode == IP_MODE_AUTOCONFIG_IP6) {
} else if ((IpMode == IP_MODE_IP6) || (IpMode == IP_MODE_AUTOCONFIG_IP6)) {
return NetLibAsciiStrToIp6 (Str, &Ip->v6);
} else if (IpMode == IP_MODE_AUTOCONFIG) {
Status = NetLibAsciiStrToIp4 (Str, &Ip->v4);
if (!EFI_ERROR (Status)) {
return Status;
}
return NetLibAsciiStrToIp6 (Str, &Ip->v6);
return NetLibAsciiStrToIp6 (Str, &Ip->v6);
}
return EFI_INVALID_PARAMETER;
@ -340,7 +337,8 @@ IScsiBinToHex (
// Safely calculate: HexLengthMin := BinLength * 2 + 3.
//
if (RETURN_ERROR (SafeUint32Mult (BinLength, 2, &HexLengthMin)) ||
RETURN_ERROR (SafeUint32Add (HexLengthMin, 3, &HexLengthMin))) {
RETURN_ERROR (SafeUint32Add (HexLengthMin, 3, &HexLengthMin)))
{
return EFI_BAD_BUFFER_SIZE;
}
@ -366,7 +364,6 @@ IScsiBinToHex (
return EFI_SUCCESS;
}
/**
Convert the hexadecimal string into a binary encoded buffer.
@ -411,9 +408,10 @@ IScsiHexToBin (
//
// Reject an empty hex string; reject a stray nibble.
//
if (Length == 0 || Length % 2 != 0) {
if ((Length == 0) || (Length % 2 != 0)) {
return EFI_INVALID_PARAMETER;
}
//
// Check if the caller provides enough room for the decoded blob.
//
@ -421,6 +419,7 @@ IScsiHexToBin (
if (BinLengthMin > MAX_UINT32) {
return EFI_BAD_BUFFER_SIZE;
}
BinLengthProvided = *BinLength;
*BinLength = (UINT32)BinLengthMin;
if (BinLengthProvided < BinLengthMin) {
@ -430,22 +429,23 @@ IScsiHexToBin (
for (Index = 0; Index < Length; Index++) {
TemStr[0] = HexStr[Index];
Digit = (UINT8)AsciiStrHexToUint64 (TemStr);
if (Digit == 0 && TemStr[0] != '0') {
if ((Digit == 0) && (TemStr[0] != '0')) {
//
// Invalid Hex Char.
//
return EFI_INVALID_PARAMETER;
}
if ((Index & 1) == 0) {
BinBuffer[Index/2] = Digit;
} else {
BinBuffer[Index/2] = (UINT8)((BinBuffer[Index/2] << 4) + Digit);
}
}
return EFI_SUCCESS;
}
/**
Convert the decimal-constant string or hex-constant string into a numerical value.
@ -468,7 +468,6 @@ IScsiNetNtoi (
return AsciiStrDecimalToUintn (Str);
}
/**
Generate random numbers.
@ -491,7 +490,6 @@ IScsiGenRandom (
}
}
/**
Check whether UNDI protocol supports IPv6.
@ -554,14 +552,14 @@ IScsiCheckIpv6Support (
&gEfiAdapterInformationProtocolGuid,
(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;
}
@ -585,7 +583,7 @@ IScsiCheckIpv6Support (
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;
}
@ -638,9 +636,10 @@ IScsiAddNic (
//
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
if (NicInfo->HwAddressSize == HwAddressSize &&
CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 &&
NicInfo->VlanId == VlanId) {
if ((NicInfo->HwAddressSize == HwAddressSize) &&
(CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0) &&
(NicInfo->VlanId == VlanId))
{
mPrivate->CurrentNic = NicInfo->NicIndex;
//
@ -706,7 +705,6 @@ IScsiAddNic (
return EFI_SUCCESS;
}
/**
Delete the recorded NIC info from global structure. Also delete corresponding
attempts.
@ -752,10 +750,10 @@ IScsiRemoveNic (
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
if (NicInfo->HwAddressSize == HwAddressSize &&
CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 &&
NicInfo->VlanId == VlanId) {
if ((NicInfo->HwAddressSize == HwAddressSize) &&
(CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0) &&
(NicInfo->VlanId == VlanId))
{
ThisNic = NicInfo;
break;
}
@ -780,16 +778,15 @@ IScsiRemoveNic (
RemoveEntryList (&AttemptConfigData->Link);
mPrivate->AttemptCount--;
if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO && mPrivate->MpioCount > 0) {
if ((AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) && (mPrivate->MpioCount > 0)) {
if (--mPrivate->MpioCount == 0) {
mPrivate->EnableMpio = FALSE;
}
if (AttemptConfigData->AuthenticationType == ISCSI_AUTH_TYPE_KRB && mPrivate->Krb5MpioCount > 0) {
if ((AttemptConfigData->AuthenticationType == ISCSI_AUTH_TYPE_KRB) && (mPrivate->Krb5MpioCount > 0)) {
mPrivate->Krb5MpioCount--;
}
} else if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED && mPrivate->SinglePathCount > 0) {
} else if ((AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED) && (mPrivate->SinglePathCount > 0)) {
mPrivate->SinglePathCount--;
if (mPrivate->ValidSinglePathCount > 0) {
@ -841,6 +838,7 @@ IScsiCreateAttempts (
Status = EFI_SUCCESS;
break;
}
TotalNumber++;
//
@ -851,6 +849,7 @@ IScsiCreateAttempts (
if (AttemptConfigOrder != NULL) {
FreePool (AttemptConfigOrder);
}
return EFI_OUT_OF_RESOURCES;
}
@ -872,10 +871,14 @@ IScsiCreateAttempts (
);
FreePool (AttemptConfigOrder);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: Failed to set 'InitialAttemptOrder' with Guid (%g): "
"%r\n",
__FUNCTION__, &gIScsiConfigGuid, Status));
__FUNCTION__,
&gIScsiConfigGuid,
Status
));
return Status;
}
@ -886,6 +889,7 @@ IScsiCreateAttempts (
if (AttemptConfigData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
ConfigData = &AttemptConfigData->SessionConfigData;
ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT;
ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT;
@ -918,10 +922,14 @@ IScsiCreateAttempts (
);
FreePool (AttemptConfigData);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: Failed to set variable (mPrivate->PortString) with Guid (%g): "
"%r\n",
__FUNCTION__, &gEfiIScsiInitiatorNameProtocolGuid, Status));
__FUNCTION__,
&gEfiIScsiInitiatorNameProtocolGuid,
Status
));
return Status;
}
}
@ -1559,7 +1567,7 @@ IScsiCleanAttemptVariable (
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return;
}
@ -1588,6 +1596,7 @@ IScsiCleanAttemptVariable (
);
}
}
return;
}
@ -1617,7 +1626,6 @@ IScsiGetNicInfoByIndex (
return NULL;
}
/**
Get the NIC's PCI location and return it according to the composited
format defined in iSCSI Boot Firmware Table.
@ -1675,7 +1683,6 @@ IScsiGetNICPciLocation (
return (UINT16)((*Bus << 8) | (*Device << 3) | *Function);
}
/**
Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
buffer, and the size of the buffer. If failure, return NULL.
@ -1715,6 +1722,7 @@ IScsiGetVariableAndSize (
if (Buffer == NULL) {
return NULL;
}
//
// Read variable into the allocated buffer.
//
@ -1728,7 +1736,6 @@ IScsiGetVariableAndSize (
return Buffer;
}
/**
Create the iSCSI driver data.
@ -1789,7 +1796,6 @@ IScsiCreateDriverData (
return Private;
}
/**
Clean the iSCSI driver data.
@ -1876,7 +1882,7 @@ IScsiDhcpIsConfigured (
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return FALSE;
}
@ -1887,6 +1893,7 @@ IScsiDhcpIsConfigured (
if (EFI_ERROR (Status)) {
return FALSE;
}
//
// Get VLAN ID of this network device.
//
@ -1906,7 +1913,7 @@ IScsiDhcpIsConfigured (
(VOID **)&AttemptTmp,
NULL
);
if(AttemptTmp == NULL || EFI_ERROR (Status)) {
if ((AttemptTmp == NULL) || EFI_ERROR (Status)) {
continue;
}
@ -1917,21 +1924,23 @@ IScsiDhcpIsConfigured (
continue;
}
if (AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG &&
AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? IP_MODE_IP4 : IP_MODE_IP6)) {
if ((AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG) &&
(AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? IP_MODE_IP4 : IP_MODE_IP6)))
{
FreePool (AttemptTmp);
continue;
}
AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));
if (AttemptTmp->Actived == ISCSI_ACTIVE_DISABLED || StrCmp (MacString, AttemptMacString)) {
if ((AttemptTmp->Actived == ISCSI_ACTIVE_DISABLED) || StrCmp (MacString, AttemptMacString)) {
continue;
}
if(AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG ||
AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE ||
AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE) {
if ((AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) ||
(AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE) ||
(AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE))
{
FreePool (AttemptTmp);
FreePool (AttemptConfigOrder);
return TRUE;
@ -1975,7 +1984,7 @@ IScsiDnsIsConfigured (
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return FALSE;
}
@ -1986,6 +1995,7 @@ IScsiDnsIsConfigured (
if (EFI_ERROR (Status)) {
return FALSE;
}
//
// Get VLAN ID of this network device.
//
@ -2006,7 +2016,7 @@ IScsiDnsIsConfigured (
(VOID **)&AttemptTmp,
NULL
);
if(AttemptTmp == NULL || EFI_ERROR (Status)) {
if ((AttemptTmp == NULL) || EFI_ERROR (Status)) {
continue;
}
@ -2014,7 +2024,7 @@ IScsiDnsIsConfigured (
AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));
if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED || StrCmp (MacString, AttemptMacString)) {
if ((AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) || StrCmp (MacString, AttemptMacString)) {
FreePool (AttemptTmp);
continue;
}
@ -2027,12 +2037,10 @@ IScsiDnsIsConfigured (
FreePool (AttemptTmp);
continue;
}
}
FreePool (AttemptConfigOrder);
return FALSE;
}
/**
@ -2070,7 +2078,7 @@ IScsiGetConfigData (
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return EFI_NOT_FOUND;
}
@ -2091,27 +2099,29 @@ IScsiGetConfigData (
// Get the normal configuration.
//
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
//
// Check whether the attempt exists in AttemptConfig.
//
AttemptTmp = IScsiConfigGetAttemptByConfigIndex (AttemptConfigOrder[Index]);
if (AttemptTmp != NULL && AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) {
if ((AttemptTmp != NULL) && (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED)) {
continue;
} else if (AttemptTmp != NULL && AttemptTmp->SessionConfigData.Enabled != ISCSI_DISABLED) {
} else if ((AttemptTmp != NULL) && (AttemptTmp->SessionConfigData.Enabled != ISCSI_DISABLED)) {
//
// Check the autoconfig path to see whether it should be retried.
//
if (AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
!AttemptTmp->AutoConfigureSuccess) {
if ((AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) &&
!AttemptTmp->AutoConfigureSuccess)
{
if (mPrivate->Ipv6Flag &&
AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6) {
(AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6))
{
//
// Autoconfigure for IP6 already attempted but failed. Do not try again.
//
continue;
} else if (!mPrivate->Ipv6Flag &&
AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4) {
(AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4))
{
//
// Autoconfigure for IP4 already attempted but failed. Do not try again.
//
@ -2163,7 +2173,8 @@ IScsiGetConfigData (
}
} else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp &&
!AttemptTmp->ValidPath &&
AttemptTmp->NicIndex == mPrivate->CurrentNic) {
(AttemptTmp->NicIndex == mPrivate->CurrentNic))
{
//
// If the attempt associates with the current NIC, we can
// get DHCP information for already added, but failed, attempt.
@ -2200,7 +2211,6 @@ IScsiGetConfigData (
);
continue;
} else {
continue;
}
@ -2228,8 +2238,9 @@ IScsiGetConfigData (
);
AsciiStrToUnicodeStrS (AttemptConfigData->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));
if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_DISABLED ||
StrCmp (MacString, AttemptMacString)) {
if ((AttemptConfigData == NULL) || (AttemptConfigData->Actived == ISCSI_ACTIVE_DISABLED) ||
StrCmp (MacString, AttemptMacString))
{
continue;
}
@ -2252,19 +2263,21 @@ IScsiGetConfigData (
//
// Get some information from dhcp server.
//
if (AttemptConfigData->SessionConfigData.Enabled != ISCSI_DISABLED &&
AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp) {
if ((AttemptConfigData->SessionConfigData.Enabled != ISCSI_DISABLED) &&
AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp)
{
if (!mPrivate->Ipv6Flag &&
(AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4 ||
AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4)) {
((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) ||
(AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4)))
{
Status = IScsiDoDhcp (Private->Image, Private->Controller, AttemptConfigData);
if (!EFI_ERROR (Status)) {
AttemptConfigData->DhcpSuccess = TRUE;
}
} else if (mPrivate->Ipv6Flag &&
(AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6 ||
AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6)) {
((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) ||
(AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6)))
{
Status = IScsiDoDhcp6 (Private->Image, Private->Controller, AttemptConfigData);
if (!EFI_ERROR (Status)) {
AttemptConfigData->DhcpSuccess = TRUE;
@ -2377,13 +2390,13 @@ IScsiGetConfigData (
if (mPrivate->SinglePathCount == 0) {
return EFI_NOT_FOUND;
}
mPrivate->ValidSinglePathCount = mPrivate->SinglePathCount;
}
return EFI_SUCCESS;
}
/**
Get the device path of the iSCSI tcp connection and update it.
@ -2423,6 +2436,7 @@ IScsiGetTcpConnDevicePath (
if (EFI_ERROR (Status)) {
return NULL;
}
//
// Duplicate it.
//
@ -2435,7 +2449,7 @@ IScsiGetTcpConnDevicePath (
while (!IsDevicePathEnd (&DPathNode->DevPath)) {
if (DevicePathType (&DPathNode->DevPath) == MESSAGING_DEVICE_PATH) {
if (!Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP) {
if (!Conn->Ipv6Flag && (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP)) {
DPathNode->Ipv4.LocalPort = 0;
DPathNode->Ipv4.StaticIpAddress =
@ -2451,7 +2465,6 @@ IScsiGetTcpConnDevicePath (
PathLen = DevicePathNodeLength (&DPathNode->Ipv4);
if (PathLen == IP4_NODE_LEN_NEW_VERSIONS) {
IP4_COPY_ADDRESS (
&DPathNode->Ipv4.GatewayIpAddress,
&Session->ConfigData->SessionConfigData.Gateway
@ -2464,7 +2477,7 @@ IScsiGetTcpConnDevicePath (
}
break;
} else if (Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP) {
} else if (Conn->Ipv6Flag && (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP)) {
DPathNode->Ipv6.LocalPort = 0;
//
@ -2478,13 +2491,10 @@ IScsiGetTcpConnDevicePath (
PathLen = DevicePathNodeLength (&DPathNode->Ipv6);
if (PathLen == IP6_NODE_LEN_NEW_VERSIONS ) {
DPathNode->Ipv6.IpAddressOrigin = 0;
DPathNode->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
ZeroMem (&DPathNode->Ipv6.GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS));
}
else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) {
} else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) {
//
// StaticIPAddress is a field in old versions of IPv6_DEVICE_PATH, while ignored in new
// version. Set StaticIPAddress through its' offset in old IPv6_DEVICE_PATH.
@ -2503,7 +2513,6 @@ IScsiGetTcpConnDevicePath (
return DevicePath;
}
/**
Abort the session when the transition from BS to RT is initiated.

View File

@ -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

View File

@ -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.
@ -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.
@ -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,18 +393,23 @@ ON_EXIT:
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);
}
@ -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
@ -696,6 +691,7 @@ IScsiAddKeyValuePair (
if (LoginReq == NULL) {
return EFI_PROTOCOL_ERROR;
}
DataSegLen = NTOH24 (LoginReq->DataSegmentLength);
KeyLen = (UINT32)AsciiStrLen (Key);
@ -714,6 +710,7 @@ IScsiAddKeyValuePair (
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.
@ -771,6 +767,7 @@ IScsiPrepareLoginReq (
NetbufFree (Nbuf);
return NULL;
}
ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST));
//
@ -852,7 +849,6 @@ IScsiPrepareLoginReq (
return Nbuf;
}
/**
Process the iSCSI Login Response.
@ -888,12 +884,14 @@ IScsiProcessLoginRsp (
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,6 +919,7 @@ IScsiProcessLoginRsp (
if (DataSeg == NULL) {
return EFI_PROTOCOL_ERROR;
}
//
// Process the TargetAddress key-value strings in the data segment to update the
// target address info.
@ -928,6 +928,7 @@ IScsiProcessLoginRsp (
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.
@ -1159,7 +1164,6 @@ IScsiUpdateTargetAddress (
*TargetAddress = '\0';
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;
}
@ -1223,6 +1228,7 @@ IScsiUpdateTargetAddress (
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.
@ -1264,7 +1269,6 @@ IScsiFreeNbufList (
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.
@ -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.
//
@ -1610,6 +1617,7 @@ IScsiCheckOpParams (
if (Value != NULL) {
Conn->MaxRecvDataSegmentLength = (UINT32)IScsiNetNtoi (Value);
}
//
// MaxBurstLength: result function is Minimum.
//
@ -1690,6 +1698,7 @@ IScsiCheckOpParams (
} else {
Session->DefaultTime2Wait = (UINT32)MAX (Session->DefaultTime2Wait, NumericValue);
}
//
// DefaultTime2Retain: result function is Minimum.
//
@ -1706,6 +1715,7 @@ IScsiCheckOpParams (
} else {
Session->DefaultTime2Retain = (UINT32)MIN (Session->DefaultTime2Retain, NumericValue);
}
//
// MaxOutstandingR2T: result function is Minimum.
//
@ -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,7 +1915,7 @@ IScsiBuildKeyValueList (
KeyValuePair->Value = Data;
InsertTailList (ListHead, &KeyValuePair->List);;
InsertTailList (ListHead, &KeyValuePair->List);
Data += AsciiStrLen (KeyValuePair->Value) + 1;
Len -= (UINT32)AsciiStrLen (KeyValuePair->Value) + 1;
@ -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.
@ -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.
@ -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.
@ -2211,6 +2211,7 @@ IScsiNewScsiCmdPdu (
NetbufFree (PduHeader);
return NULL;
}
Header = (ISCSI_ADDITIONAL_HEADER *)(ScsiCmd + 1);
ZeroMem (ScsiCmd, Length);
@ -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,6 +2376,7 @@ IScsiNewDataOutPdu (
FreePool (NbufList);
return NULL;
}
//
// Insert the BHS into the buffer list.
//
@ -2385,6 +2387,7 @@ IScsiNewDataOutPdu (
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.
@ -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.
@ -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,9 +2714,11 @@ 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.
//
@ -2720,7 +2728,6 @@ IScsiOnR2TRcvd (
return Status;
}
/**
Process the received iSCSI SCSI Response PDU.
@ -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;
}
@ -2829,7 +2837,6 @@ IScsiOnScsiRspRcvd (
return Status;
}
/**
Process the received NOP In PDU.
@ -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.
@ -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.

View File

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

View File

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

View File

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

View File

@ -325,4 +325,5 @@ HttpIoSendChunkedTransfer (
IN HTTP_IO_SEND_CHUNK_PROCESS *SendChunkProcess,
IN EFI_HTTP_MESSAGE *RequestMessage
);
#endif

View File

@ -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.
@ -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

View File

@ -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
@ -604,4 +602,3 @@ IpIoRefreshNeighbor (
);
#endif

View File

@ -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,7 +93,6 @@ typedef UINT16 TCP_PORTNO;
//
#define MEDIA_STATE_DETECT_TIME_INTERVAL 1000000U
#pragma pack(1)
//
@ -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.
@ -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
@ -2104,7 +2093,6 @@ NetbufQueTrim (
IN UINT32 Len
);
/**
Flush the net buffer queue.

View File

@ -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

View File

@ -85,8 +85,6 @@ typedef struct {
UDP_COMPLETION_TOKEN Token;
} UDP_RX_TOKEN;
///
/// This structure is used internally by UdpIo Library.
///

View File

@ -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.

View File

@ -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
//
@ -155,7 +154,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2 =
"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)
);
}

View File

@ -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

View File

@ -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

View File

@ -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);
}
}
/**
@ -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...
//
@ -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;
}
}
@ -335,10 +331,8 @@ Ip4Config2WriteConfigData (
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);
@ -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;
@ -623,7 +614,6 @@ Ip4Config2SetDefaultIf (
return EFI_SUCCESS;
}
/**
Release all the DHCP related resources.
@ -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.
@ -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
@ -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.
@ -1157,7 +1144,7 @@ Ip4Config2SetPolicy (
}
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,7 +1269,7 @@ Ip4Config2SetManualAddress (
DataItem = &Instance->DataItem[Ip4Config2DataTypeManualAddress];
if (Data != NULL && DataSize != 0) {
if ((Data != NULL) && (DataSize != 0)) {
NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *)Data);
StationAddress = EFI_NTOHL (NewAddress.Address);
@ -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) {
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.
@ -2084,7 +2062,6 @@ Ip4Config2CleanInstance (
}
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;
}
@ -2145,7 +2122,6 @@ Ip4AutoReconfigCallBackDpc (
return;
}
/**
Request Ip4AutoReconfigCallBackDpc as a DPC at TPL_CALLBACK.
@ -2165,4 +2141,3 @@ Ip4AutoReconfigCallBack (
//
QueueDpc (TPL_CALLBACK, Ip4AutoReconfigCallBackDpc, Context);
}

View File

@ -73,7 +73,6 @@ Ip4Config2StrToIp (
Index = 0;
while (*Str != L'\0') {
if (Index > 3) {
return EFI_INVALID_PARAMETER;
}
@ -278,7 +277,6 @@ Ip4Config2IpToStr (
);
}
/**
Convert the IPv4 address list into string consists of several decimal
dotted IPv4 addresses separated by space.
@ -337,6 +335,7 @@ Ip4Config2IpListToStr (
} else {
Str[StrIndex++] = L' ';
}
break;
} else {
Str[StrIndex++] = *(TempStr + TemIndex);
@ -582,9 +581,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
TimeoutEvent = NULL;
SetAddressEvent = NULL;
if (Instance == NULL || IfrFormNvData == NULL) {
if ((Instance == NULL) || (IfrFormNvData == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -618,21 +615,23 @@ 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) {
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))) {
@ -650,6 +649,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
if (Ip4NvData->ManualAddress != NULL) {
FreePool (Ip4NvData->ManualAddress);
}
Ip4NvData->ManualAddressCount = 1;
Ip4NvData->ManualAddress = AllocateZeroPool (sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS));
if (Ip4NvData->ManualAddress == NULL) {
@ -659,25 +659,30 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
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));
if (Ip4NvData->GatewayAddress != NULL) {
FreePool (Ip4NvData->GatewayAddress);
}
Ip4NvData->GatewayAddressCount = 1;
Ip4NvData->GatewayAddress = AllocateZeroPool (sizeof (EFI_IPv4_ADDRESS));
if (Ip4NvData->GatewayAddress == NULL) {
if (DnsAddress != NULL) {
FreePool (DnsAddress);
}
return EFI_OUT_OF_RESOURCES;
}
CopyMem (Ip4NvData->GatewayAddress, &Gateway.v4, sizeof (EFI_IPv4_ADDRESS));
if (Ip4NvData->DnsAddress != NULL) {
FreePool (Ip4NvData->DnsAddress);
}
Ip4NvData->DnsAddressCount = (UINT32)DnsCount;
Ip4NvData->DnsAddress = DnsAddress;
@ -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;
}
@ -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);
@ -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,7 +1028,7 @@ Ip4FormRouteConfig (
Status = EFI_SUCCESS;
IfrFormNvData = NULL;
if (Configuration == NULL || Progress == NULL) {
if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -1073,7 +1079,6 @@ Ip4FormRouteConfig (
}
return Status;
}
/**
@ -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,6 +1172,7 @@ Ip4FormCallback (
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);
Status = EFI_INVALID_PARAMETER;
}
break;
case KEY_GATE_WAY:
@ -1174,11 +1181,12 @@ Ip4FormCallback (
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) {
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))) {
@ -1196,6 +1204,7 @@ Ip4FormCallback (
if (DnsAddress != NULL) {
FreePool (DnsAddress);
}
break;
case KEY_SAVE_CHANGES:

View File

@ -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.
//
@ -170,7 +171,6 @@ Ip4CleanService (
IN IP4_SERVICE *IpSb
);
/**
Create a new IP4 driver service binding private instance.
@ -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,7 +502,7 @@ Ip4DestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) {
if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -621,7 +621,7 @@ Ip4DriverBindingStart (
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
@ -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.
@ -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.
@ -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,

View File

@ -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
@ -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

View File

@ -61,8 +61,6 @@ mIp4SupportedIcmp[23] = {
{ 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
@ -190,7 +187,6 @@ Ip4ProcessIcmpError (
return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
}
/**
Replay an ICMP echo request.
@ -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.
@ -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
@ -351,10 +345,8 @@ Ip4IcmpHandle (
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:

View File

@ -94,4 +94,5 @@ Ip4IcmpHandle (
IN IP4_HEAD *Head,
IN NET_BUF *Packet
);
#endif

View File

@ -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;
@ -206,7 +207,6 @@ Ip4WrapLinkTxToken (
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.
@ -667,7 +658,6 @@ ON_ERROR:
return Status;
}
/**
Filter function to cancel all the frame related to an IP instance.
@ -693,8 +683,6 @@ Ip4CancelInstanceFrame (
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;
goto ON_ERROR;
}
DefaultRoute = (IP4_ROUTE_ENTRY *)RtCacheEntry->Tag;
if (DefaultRoute == NULL) {
Status = EFI_NO_MAPPING;
goto ON_ERROR;
}
//
// Try to send the frame to the default route.
//
@ -853,12 +844,14 @@ Ip4SendFrameToDefaultRoute (
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);
if (EFI_ERROR (Status)) {
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
@ -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.
@ -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.
@ -1210,7 +1196,6 @@ Ip4RecycleFrame (
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
@ -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;
}

View File

@ -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.
@ -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

View File

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

View File

@ -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);
@ -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.
@ -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.
@ -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,
@ -1501,7 +1490,6 @@ Ip4FreeTxToken (
FreePool (Wrap);
}
/**
The callback function to Ip4Output to update the transmit status.
@ -1542,7 +1530,6 @@ Ip4OnPacketSent (
NetbufFree (Wrap->Packet);
}
/**
Places outgoing data packets into the transmit queue.
@ -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
@ -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.
@ -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.

View File

@ -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;

View File

@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Ip4Impl.h"
/**
Create an empty assemble entry for the packet identified by
(Dst, Src, Id, Protocol). The default life for the packet is
@ -33,7 +32,6 @@ Ip4CreateAssembleEntry (
IN UINT8 Protocol
)
{
IP4_ASSEMBLE_ENTRY *Assemble;
Assemble = AllocatePool (sizeof (IP4_ASSEMBLE_ENTRY));
@ -58,7 +56,6 @@ Ip4CreateAssembleEntry (
return Assemble;
}
/**
Release all the fragments of a packet, then free the assemble entry.
@ -84,7 +81,6 @@ Ip4FreeAssembleEntry (
FreePool (Assemble);
}
/**
Initialize an already allocated assemble table. This is generally
the assemble table embedded in the IP4 service instance.
@ -104,7 +100,6 @@ Ip4InitAssembleTable (
}
}
/**
Clean up the assemble table: remove all the fragments
and assemble entries.
@ -132,7 +127,6 @@ Ip4CleanAssembleTable (
}
}
/**
Trim the packet to fit in [Start, End), and update the per
packet information.
@ -174,7 +168,6 @@ Ip4TrimPacket (
}
}
/**
Release all the fragments of the packet. This is the callback for
the assembled packet's OnFree. It will free the assemble entry,
@ -192,7 +185,6 @@ Ip4OnFreeFragments (
Ip4FreeAssembleEntry ((IP4_ASSEMBLE_ENTRY *)Arg);
}
/**
Reassemble the IP fragments. If all the fragments of the packet
have been received, it will wrap the packet in a net buffer then
@ -240,7 +232,8 @@ Ip4Reassemble (
Assemble = NET_LIST_USER_STRUCT (Cur, IP4_ASSEMBLE_ENTRY, Link);
if ((Assemble->Dst == IpHead->Dst) && (Assemble->Src == IpHead->Src) &&
(Assemble->Id == IpHead->Id) && (Assemble->Protocol == IpHead->Protocol)) {
(Assemble->Id == IpHead->Id) && (Assemble->Protocol == IpHead->Protocol))
{
break;
}
}
@ -262,6 +255,7 @@ Ip4Reassemble (
InsertHeadList (&Table->Bucket[Index], &Assemble->Link);
}
//
// Assemble shouldn't be NULL here
//
@ -383,7 +377,6 @@ Ip4Reassemble (
// queue ends at the total length, all data is received.
//
if ((Assemble->TotalLen != 0) && (Assemble->CurLen >= Assemble->TotalLen)) {
RemoveEntryList (&Assemble->Link);
//
@ -512,6 +505,7 @@ Ip4IpSecProcessPacket (
if (!mIpSec2Installed) {
goto ON_EXIT;
}
ASSERT (mIpSec != NULL);
Packet = *Netbuf;
@ -590,7 +584,7 @@ Ip4IpSecProcessPacket (
goto ON_EXIT;
}
if (OriginalFragmentTable == FragmentTable && OriginalFragmentCount == FragmentCount) {
if ((OriginalFragmentTable == FragmentTable) && (OriginalFragmentCount == FragmentCount)) {
//
// For ByPass Packet
//
@ -603,8 +597,7 @@ Ip4IpSecProcessPacket (
FreePool (OriginalFragmentTable);
}
if (Direction == EfiIPsecOutBound && TxWrap != NULL) {
if ((Direction == EfiIPsecOutBound) && (TxWrap != NULL)) {
TxWrap->IpSecRecycleSignal = RecycleEvent;
TxWrap->Packet = NetbufFromExt (
FragmentTable,
@ -629,9 +622,7 @@ Ip4IpSecProcessPacket (
//
NetIpSecNetbufFree (*Netbuf);
*Netbuf = TxWrap->Packet;
} else {
IpSecWrap = AllocateZeroPool (sizeof (IP4_IPSEC_WRAP));
if (IpSecWrap == NULL) {
@ -659,7 +650,7 @@ Ip4IpSecProcessPacket (
goto ON_EXIT;
}
if (Direction == EfiIPsecInBound && 0 != CompareMem (*Head, &ZeroHead, sizeof (IP4_HEAD))) {
if ((Direction == EfiIPsecInBound) && (0 != CompareMem (*Head, &ZeroHead, sizeof (IP4_HEAD)))) {
Ip4PrependHead (Packet, *Head, *Options, *OptionsLen);
Ip4NtohHead (Packet->Ip.Ip4);
NetbufTrim (Packet, ((*Head)->HeadLen << 2), TRUE);
@ -670,6 +661,7 @@ Ip4IpSecProcessPacket (
sizeof (IP4_CLIP_INFO)
);
}
*Netbuf = Packet;
}
@ -722,7 +714,8 @@ Ip4PreProcessPacket (
}
if ((Head->Ver != 4) || (HeadLen < IP4_MIN_HEADLEN) ||
(TotalLen < HeadLen) || (TotalLen != (*Packet)->TotalSize)) {
(TotalLen < HeadLen) || (TotalLen != (*Packet)->TotalSize))
{
return EFI_INVALID_PARAMETER;
}
@ -973,7 +966,6 @@ DROP:
return;
}
/**
Check whether this IP child accepts the packet.
@ -1076,7 +1068,6 @@ Ip4InstanceFrameAcceptable (
return TRUE;
}
/**
Enqueue a shared copy of the packet to the IP4 child if the
packet is acceptable to it. Here the data of the packet is
@ -1133,7 +1124,6 @@ Ip4InstanceEnquePacket (
return EFI_SUCCESS;
}
/**
The signal handle of IP4's recycle event. It is called back
when the upper layer release the packet.
@ -1165,7 +1155,6 @@ Ip4OnRecyclePacket (
FreePool (Wrap);
}
/**
Wrap the received packet to a IP4_RXDATA_WRAP, which will be
delivered to the upper layer. Each IP4 child that accepts the
@ -1249,7 +1238,6 @@ Ip4WrapRxData (
return Wrap;
}
/**
Deliver the received packets to upper layer if there are both received
requests and enqueued packets. If the enqueued packet is shared, it will
@ -1280,8 +1268,8 @@ Ip4InstanceDeliverPacket (
// Deliver a packet if there are both a packet and a receive token.
//
while (!IsListEmpty (&IpInstance->Received) &&
!NetMapIsEmpty (&IpInstance->RxTokens)) {
!NetMapIsEmpty (&IpInstance->RxTokens))
{
Packet = NET_LIST_HEAD (&IpInstance->Received, NET_BUF, List);
if (!NET_BUF_SHARED (Packet)) {
@ -1295,7 +1283,6 @@ Ip4InstanceDeliverPacket (
}
RemoveEntryList (&Packet->List);
} else {
//
// Create a duplicated packet if this packet is shared
@ -1358,7 +1345,6 @@ Ip4InstanceDeliverPacket (
return EFI_SUCCESS;
}
/**
Enqueue a received packet to all the IP children that share
the same interface.
@ -1406,7 +1392,6 @@ Ip4InterfaceEnquePacket (
// that later.
//
LocalType = Info->CastType;
} else {
//
// Check the destination against local IP. If the station
@ -1416,7 +1401,6 @@ Ip4InterfaceEnquePacket (
//
if (IpIf->Ip == IP4_ALLZERO_ADDRESS) {
LocalType = IP4_LOCAL_HOST;
} else {
LocalType = Ip4GetNetCast (Head->Dst, IpIf);
@ -1461,7 +1445,6 @@ Ip4InterfaceEnquePacket (
return Enqueued;
}
/**
Deliver the packet for each IP4 child on the interface.
@ -1488,7 +1471,6 @@ Ip4InterfaceDeliverPacket (
return EFI_SUCCESS;
}
/**
Demultiple the packet. the packet delivery is processed in two
passes. The first pass will enqueue a shared copy of the packet
@ -1565,7 +1547,6 @@ Ip4Demultiplex (
return EFI_SUCCESS;
}
/**
Timeout the fragment and enqueued packets.

View File

@ -42,4 +42,3 @@ typedef struct {
} IP4_CONFIG2_IFR_NVDATA;
#endif

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Ip4Impl.h"
/**
Validate the IP4 option format for both the packets we received
and will transmit.
@ -68,8 +67,8 @@ Ip4OptionIsValid (
// source route option.
//
if ((Option[Cur] != IP4_OPTION_RR) &&
((Rcvd && (Point != Len + 1)) || (!Rcvd && (Point != 4)))) {
((Rcvd && (Point != Len + 1)) || (!Rcvd && (Point != 4))))
{
return FALSE;
}
@ -86,13 +85,11 @@ Ip4OptionIsValid (
Cur = Cur + Len;
break;
}
}
return TRUE;
}
/**
Copy the option from the original option to buffer. It
handles the details such as:
@ -142,18 +139,16 @@ Ip4CopyOption (
OptBuf[Next] = IP4_OPTION_NOP;
Next++;
Cur++;
} else if (Type == IP4_OPTION_EOP) {
//
// Don't append the EOP to avoid including only a EOP option
//
break;
} else {
//
// don't copy options that is only valid for the first fragment
//
if (FirstFragment || (Type & IP4_OPTION_COPY_MASK) != 0) {
if (FirstFragment || ((Type & IP4_OPTION_COPY_MASK) != 0)) {
CopyMem (OptBuf + Next, Option + Cur, Len);
Next += Len;
}

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