edk2/edk2-NetworkPkg-Apply-uncrustify-changes.p2.patch

16642 lines
530 KiB
Diff
Raw Normal View History

* Wed Jul 03 2024 Miroslav Rezanina <mrezanin@redhat.com> - 20220126gitbb1bba3d77-13.el8_10.1 - edk2-MdeModulePkg-Change-use-of-EFI_D_-to-DEBUG_.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdeModulePkg-Potential-UINT32-overflow-in-S3-ResumeC.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdePkg-Apply-uncrustify-changes.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-NetworkPkg-Apply-uncrustify-changes.p2.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Rename-RdRandGenerateEntropy-to-g.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Remove-ArchGetSupportedRngAlgorit.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Documentation-include-parameter-c.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Check-before-advertising-Cpu-Rng-.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Add-AArch64-RawAlgorithm-support-.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Add-debug-warning-for-NULL-PcdCpu.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Rename-AArch64-RngDxe.c.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Add-Arm-support-of-RngDxe.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Correctly-update-mAvailableAlgoAr.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Conditionally-install-EFI_RNG_PRO.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdeModulePkg-Duplicate-BaseRngLibTimerLib-to-MdeModu.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdePkg-Add-deprecated-warning-to-BaseRngLibTimer.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-SecurityPkg.dec-Move-PcdCpuRngSupportedA.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdePkg-DxeRngLib-Request-raw-algorithm-instead-of-de.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdePkg-Rng-Add-GUID-to-describe-Arm-Rndr-Rng-algorit.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdeModulePkg-Rng-Add-GUID-to-describe-unsafe-Rng-alg.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdePkg-Rng-Add-GetRngGuid-to-RngLib.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Use-GetRngGuid-when-probing-RngLi.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-Simplify-Rng-algorithm-selection-.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-NetworkPkg-SECURITY-PATCH-CVE-2023-45237.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-SecurityPkg-RngDxe-add-rng-test.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-OvmfPkg-wire-up-RngDxe.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-NetworkPkg-TcpDxe-SECURITY-PATCH-CVE-2023-45236.patch [RHEL-21854 RHEL-21856 RHEL-40099] - edk2-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch [RHEL-21854 RHEL-21856 RHEL-40099] - Resolves: RHEL-21854 (CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8]) - Resolves: RHEL-21856 (CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8]) - Resolves: RHEL-40099 (CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z])
2024-07-03 12:35:29 +00:00
From 1a92cf063c3d77f3706a7d9d57fafa9364317554 Mon Sep 17 00:00:00 2001
From: Jon Maloy <jmaloy@redhat.com>
Date: Wed, 12 Jun 2024 18:16:26 -0400
Subject: [PATCH 04/31] NetworkPkg: Apply uncrustify changes
RH-Author: Jon Maloy <jmaloy@redhat.com>
RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes
RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099
RH-Acked-by: Gerd Hoffmann <None>
RH-Commit: [4/31] a42ad4b2dd705cb3492d99cbd00378581207ad65
JIRA: https://issues.redhat.com/browse/RHEL-21856
CVE: CVE-2022-45237
Upstream: Merged
This upstream commit makes it very hard to backport more recent changes
from upstream, since it always causes numerous whitespace conflicts. In
order to make application of the next commits in this series cleaner,
and hopefully to save ourselves some future work, we apply parts of the
commit on some files which will be affected by the next commits.
This commit only contains whitespace changes.
commit d1050b9dff1cace252aff86630bfdb59dff5f507
Author: Michael Kubacki <michael.kubacki@microsoft.com>
Date: Sun Dec 5 14:54:07 2021 -0800
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>
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c | 175 ++-
NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c | 149 +--
NetworkPkg/DnsDxe/DnsDhcp.c | 187 ++-
NetworkPkg/DnsDxe/DnsImpl.c | 819 ++++++------
NetworkPkg/HttpBootDxe/HttpBootDhcp6.c | 438 +++---
NetworkPkg/IScsiDxe/IScsiCHAP.c | 634 ++++-----
NetworkPkg/IScsiDxe/IScsiMisc.c | 779 +++++------
NetworkPkg/Include/Library/NetLib.h | 700 +++++-----
NetworkPkg/Ip4Dxe/Ip4Driver.c | 158 ++-
NetworkPkg/Ip6Dxe/Ip6If.c | 210 ++-
NetworkPkg/Ip6Dxe/Ip6Mld.c | 232 ++--
NetworkPkg/Ip6Dxe/Ip6Nd.c | 1554 +++++++++++-----------
NetworkPkg/Library/DxeNetLib/DxeNetLib.c | 877 ++++++------
NetworkPkg/TcpDxe/TcpDriver.c | 107 +-
NetworkPkg/TcpDxe/TcpMain.h | 150 +--
NetworkPkg/TcpDxe/TcpMisc.c | 436 +++---
NetworkPkg/Udp4Dxe/Udp4Driver.c | 52 +-
NetworkPkg/Udp6Dxe/Udp6Driver.c | 85 +-
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c | 46 +-
NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 365 +++--
20 files changed, 4062 insertions(+), 4091 deletions(-)
diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c
index 970141abfe..8c37e93be3 100644
--- a/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c
+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Dhcp4Impl.h"
#include "Dhcp4Driver.h"
-EFI_DRIVER_BINDING_PROTOCOL gDhcp4DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gDhcp4DriverBinding = {
Dhcp4DriverBindingSupported,
Dhcp4DriverBindingStart,
Dhcp4DriverBindingStop,
@@ -17,7 +17,7 @@ EFI_DRIVER_BINDING_PROTOCOL gDhcp4DriverBinding = {
NULL
};
-EFI_SERVICE_BINDING_PROTOCOL mDhcp4ServiceBindingTemplate = {
+EFI_SERVICE_BINDING_PROTOCOL mDhcp4ServiceBindingTemplate = {
Dhcp4ServiceBindingCreateChild,
Dhcp4ServiceBindingDestroyChild
};
@@ -39,8 +39,8 @@ EFI_SERVICE_BINDING_PROTOCOL mDhcp4ServiceBindingTemplate = {
EFI_STATUS
EFIAPI
Dhcp4DriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (
@@ -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.
@@ -110,35 +107,33 @@ Dhcp4DriverBindingSupported (
EFI_STATUS
EFIAPI
DhcpConfigUdpIo (
- IN UDP_IO *UdpIo,
- IN VOID *Context
+ IN UDP_IO *UdpIo,
+ IN VOID *Context
)
{
- EFI_UDP4_CONFIG_DATA UdpConfigData;
-
- UdpConfigData.AcceptBroadcast = TRUE;
- UdpConfigData.AcceptPromiscuous = FALSE;
- UdpConfigData.AcceptAnyPort = FALSE;
- UdpConfigData.AllowDuplicatePort = TRUE;
- UdpConfigData.TypeOfService = 0;
- UdpConfigData.TimeToLive = 64;
- UdpConfigData.DoNotFragment = FALSE;
- UdpConfigData.ReceiveTimeout = 0;
- UdpConfigData.TransmitTimeout = 0;
-
- UdpConfigData.UseDefaultAddress = FALSE;
- UdpConfigData.StationPort = DHCP_CLIENT_PORT;
- UdpConfigData.RemotePort = DHCP_SERVER_PORT;
+ EFI_UDP4_CONFIG_DATA UdpConfigData;
+
+ UdpConfigData.AcceptBroadcast = TRUE;
+ UdpConfigData.AcceptPromiscuous = FALSE;
+ UdpConfigData.AcceptAnyPort = FALSE;
+ UdpConfigData.AllowDuplicatePort = TRUE;
+ UdpConfigData.TypeOfService = 0;
+ UdpConfigData.TimeToLive = 64;
+ UdpConfigData.DoNotFragment = FALSE;
+ UdpConfigData.ReceiveTimeout = 0;
+ UdpConfigData.TransmitTimeout = 0;
+
+ UdpConfigData.UseDefaultAddress = FALSE;
+ UdpConfigData.StationPort = DHCP_CLIENT_PORT;
+ UdpConfigData.RemotePort = DHCP_SERVER_PORT;
ZeroMem (&UdpConfigData.StationAddress, sizeof (EFI_IPv4_ADDRESS));
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
@@ -151,7 +146,7 @@ DhcpConfigUdpIo (
**/
EFI_STATUS
Dhcp4CloseService (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
)
{
DhcpCleanLease (DhcpSb);
@@ -171,8 +166,6 @@ Dhcp4CloseService (
return EFI_SUCCESS;
}
-
-
/**
Create a new DHCP service binding instance for the controller.
@@ -189,28 +182,28 @@ Dhcp4CloseService (
**/
EFI_STATUS
Dhcp4CreateService (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE ImageHandle,
- OUT DHCP_SERVICE **Service
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE ImageHandle,
+ OUT DHCP_SERVICE **Service
)
{
- DHCP_SERVICE *DhcpSb;
- EFI_STATUS Status;
+ DHCP_SERVICE *DhcpSb;
+ EFI_STATUS Status;
- *Service = NULL;
- DhcpSb = AllocateZeroPool (sizeof (DHCP_SERVICE));
+ *Service = NULL;
+ DhcpSb = AllocateZeroPool (sizeof (DHCP_SERVICE));
if (DhcpSb == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- DhcpSb->Signature = DHCP_SERVICE_SIGNATURE;
- DhcpSb->ServiceState = DHCP_UNCONFIGED;
- DhcpSb->Controller = Controller;
- DhcpSb->Image = ImageHandle;
+ DhcpSb->Signature = DHCP_SERVICE_SIGNATURE;
+ DhcpSb->ServiceState = DHCP_UNCONFIGED;
+ DhcpSb->Controller = Controller;
+ DhcpSb->Image = ImageHandle;
InitializeListHead (&DhcpSb->Children);
- DhcpSb->DhcpState = Dhcp4Stopped;
- DhcpSb->Xid = NET_RANDOM (NetRandomInitSeed ());
+ DhcpSb->DhcpState = Dhcp4Stopped;
+ DhcpSb->Xid = NET_RANDOM (NetRandomInitSeed ());
CopyMem (
&DhcpSb->ServiceBinding,
&mDhcp4ServiceBindingTemplate,
@@ -244,11 +237,11 @@ Dhcp4CreateService (
goto ON_ERROR;
}
- DhcpSb->HwLen = (UINT8) DhcpSb->UdpIo->SnpMode.HwAddressSize;
+ DhcpSb->HwLen = (UINT8)DhcpSb->UdpIo->SnpMode.HwAddressSize;
DhcpSb->HwType = DhcpSb->UdpIo->SnpMode.IfType;
CopyMem (&DhcpSb->Mac, &DhcpSb->UdpIo->SnpMode.CurrentAddress, sizeof (DhcpSb->Mac));
- *Service = DhcpSb;
+ *Service = DhcpSb;
return EFI_SUCCESS;
ON_ERROR:
@@ -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
@@ -285,8 +277,8 @@ Dhcp4DriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- DHCP_SERVICE *DhcpSb;
- EFI_STATUS Status;
+ DHCP_SERVICE *DhcpSb;
+ EFI_STATUS Status;
//
// First: test for the DHCP4 Protocol
@@ -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)) {
@@ -360,24 +354,23 @@ ON_ERROR:
EFI_STATUS
EFIAPI
Dhcp4DestroyChildEntry (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
- DHCP_PROTOCOL *Instance;
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ DHCP_PROTOCOL *Instance;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- if (Entry == NULL || Context == NULL) {
+ if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP_PROTOCOL, Link, DHCP_PROTOCOL_SIGNATURE);
- ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context;
+ Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP_PROTOCOL, Link, DHCP_PROTOCOL_SIGNATURE);
+ ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context;
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
}
-
/**
Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to
@@ -422,10 +415,10 @@ Dhcp4DriverBindingStop (
return EFI_SUCCESS;
}
- Status = gBS->OpenProtocol (
+ Status = gBS->OpenProtocol (
NicHandle,
&gEfiDhcp4ServiceBindingProtocolGuid,
- (VOID **) &ServiceBinding,
+ (VOID **)&ServiceBinding,
This->DriverBindingHandle,
NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -440,23 +433,23 @@ Dhcp4DriverBindingStop (
//
// Destroy all the children instances before destroy the service.
//
- List = &DhcpSb->Children;
+ List = &DhcpSb->Children;
Status = NetDestroyLinkList (
List,
Dhcp4DestroyChildEntry,
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.
@@ -492,25 +485,24 @@ Dhcp4DriverBindingStop (
**/
VOID
DhcpInitProtocol (
- IN DHCP_SERVICE *DhcpSb,
- IN OUT DHCP_PROTOCOL *Instance
+ IN DHCP_SERVICE *DhcpSb,
+ IN OUT DHCP_PROTOCOL *Instance
)
{
- Instance->Signature = DHCP_PROTOCOL_SIGNATURE;
+ Instance->Signature = DHCP_PROTOCOL_SIGNATURE;
CopyMem (&Instance->Dhcp4Protocol, &mDhcp4ProtocolTemplate, sizeof (Instance->Dhcp4Protocol));
InitializeListHead (&Instance->Link);
- Instance->Handle = NULL;
- Instance->Service = DhcpSb;
- Instance->InDestroy = FALSE;
- Instance->CompletionEvent = NULL;
- Instance->RenewRebindEvent = NULL;
- Instance->Token = NULL;
- Instance->UdpIo = NULL;
- Instance->ElaspedTime = 0;
+ Instance->Handle = NULL;
+ Instance->Service = DhcpSb;
+ Instance->InDestroy = FALSE;
+ Instance->CompletionEvent = NULL;
+ Instance->RenewRebindEvent = NULL;
+ Instance->Token = NULL;
+ Instance->UdpIo = NULL;
+ Instance->ElaspedTime = 0;
NetbufQueInit (&Instance->ResponseQueue);
}
-
/**
Creates a child handle and installs a protocol.
@@ -537,11 +529,11 @@ Dhcp4ServiceBindingCreateChild (
IN EFI_HANDLE *ChildHandle
)
{
- DHCP_SERVICE *DhcpSb;
- DHCP_PROTOCOL *Instance;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- VOID *Udp4;
+ DHCP_SERVICE *DhcpSb;
+ DHCP_PROTOCOL *Instance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ VOID *Udp4;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -571,7 +563,7 @@ Dhcp4ServiceBindingCreateChild (
return Status;
}
- Instance->Handle = *ChildHandle;
+ Instance->Handle = *ChildHandle;
//
// Open the Udp4 protocol BY_CHILD.
@@ -579,7 +571,7 @@ Dhcp4ServiceBindingCreateChild (
Status = gBS->OpenProtocol (
DhcpSb->UdpIo->UdpHandle,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Udp4,
+ (VOID **)&Udp4,
gDhcp4DriverBinding.DriverBindingHandle,
Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -606,7 +598,6 @@ Dhcp4ServiceBindingCreateChild (
return EFI_SUCCESS;
}
-
/**
Destroys a child handle with a protocol installed on it.
@@ -632,11 +623,11 @@ Dhcp4ServiceBindingDestroyChild (
IN EFI_HANDLE ChildHandle
)
{
- DHCP_SERVICE *DhcpSb;
- DHCP_PROTOCOL *Instance;
- EFI_DHCP4_PROTOCOL *Dhcp;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
+ DHCP_SERVICE *DhcpSb;
+ DHCP_PROTOCOL *Instance;
+ EFI_DHCP4_PROTOCOL *Dhcp;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -648,7 +639,7 @@ Dhcp4ServiceBindingDestroyChild (
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiDhcp4ProtocolGuid,
- (VOID **) &Dhcp,
+ (VOID **)&Dhcp,
gDhcp4DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -658,8 +649,8 @@ Dhcp4ServiceBindingDestroyChild (
return EFI_UNSUPPORTED;
}
- Instance = DHCP_INSTANCE_FROM_THIS (Dhcp);
- DhcpSb = DHCP_SERVICE_FROM_THIS (This);
+ Instance = DHCP_INSTANCE_FROM_THIS (Dhcp);
+ DhcpSb = DHCP_SERVICE_FROM_THIS (This);
if (Instance->Service != DhcpSb) {
return EFI_INVALID_PARAMETER;
@@ -675,7 +666,7 @@ Dhcp4ServiceBindingDestroyChild (
return EFI_SUCCESS;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
Instance->InDestroy = TRUE;
//
diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
index f0b236835f..b591a4605b 100644
--- a/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
@@ -10,8 +10,7 @@
#include "Dhcp6Impl.h"
-
-EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = {
Dhcp6DriverBindingSupported,
Dhcp6DriverBindingStart,
Dhcp6DriverBindingStop,
@@ -20,7 +19,7 @@ EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = {
NULL
};
-EFI_SERVICE_BINDING_PROTOCOL gDhcp6ServiceBindingTemplate = {
+EFI_SERVICE_BINDING_PROTOCOL gDhcp6ServiceBindingTemplate = {
Dhcp6ServiceBindingCreateChild,
Dhcp6ServiceBindingDestroyChild
};
@@ -39,12 +38,12 @@ EFI_SERVICE_BINDING_PROTOCOL gDhcp6ServiceBindingTemplate = {
EFI_STATUS
EFIAPI
Dhcp6ConfigureUdpIo (
- IN UDP_IO *UdpIo,
- IN VOID *Context
+ IN UDP_IO *UdpIo,
+ IN VOID *Context
)
{
- EFI_UDP6_PROTOCOL *Udp6;
- EFI_UDP6_CONFIG_DATA *Config;
+ EFI_UDP6_PROTOCOL *Udp6;
+ EFI_UDP6_CONFIG_DATA *Config;
Udp6 = UdpIo->Protocol.Udp6;
Config = &(UdpIo->Config.Udp6);
@@ -67,13 +66,12 @@ Dhcp6ConfigureUdpIo (
// will be overridden later. Note that we MUST not limit RemotePort.
// More details, refer to RFC 3315 section 5.2.
//
- Config->StationPort = DHCP6_PORT_CLIENT;
- Config->RemotePort = 0;
+ 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
@@ -84,7 +82,7 @@ Dhcp6ConfigureUdpIo (
**/
VOID
Dhcp6DestroyService (
- IN OUT DHCP6_SERVICE *Service
+ IN OUT DHCP6_SERVICE *Service
)
{
//
@@ -103,7 +101,6 @@ Dhcp6DestroyService (
FreePool (Service);
}
-
/**
Create a new Dhcp6 service for the Nic controller.
@@ -119,13 +116,13 @@ Dhcp6DestroyService (
**/
EFI_STATUS
Dhcp6CreateService (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE ImageHandle,
- OUT DHCP6_SERVICE **Service
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE ImageHandle,
+ OUT DHCP6_SERVICE **Service
)
{
- DHCP6_SERVICE *Dhcp6Srv;
- EFI_STATUS Status;
+ DHCP6_SERVICE *Dhcp6Srv;
+ EFI_STATUS Status;
*Service = NULL;
Dhcp6Srv = AllocateZeroPool (sizeof (DHCP6_SERVICE));
@@ -147,10 +144,10 @@ Dhcp6CreateService (
//
// Initialize the fields of the new Dhcp6 service.
//
- Dhcp6Srv->Signature = DHCP6_SERVICE_SIGNATURE;
- Dhcp6Srv->Controller = Controller;
- Dhcp6Srv->Image = ImageHandle;
- Dhcp6Srv->Xid = (0xffffff & NET_RANDOM (NetRandomInitSeed ()));
+ Dhcp6Srv->Signature = DHCP6_SERVICE_SIGNATURE;
+ Dhcp6Srv->Controller = Controller;
+ Dhcp6Srv->Image = ImageHandle;
+ Dhcp6Srv->Xid = (0xffffff & NET_RANDOM (NetRandomInitSeed ()));
CopyMem (
&Dhcp6Srv->ServiceBinding,
@@ -164,7 +161,7 @@ Dhcp6CreateService (
Status = gBS->HandleProtocol (
Controller,
&gEfiIp6ConfigProtocolGuid,
- (VOID **) &Dhcp6Srv->Ip6Cfg
+ (VOID **)&Dhcp6Srv->Ip6Cfg
);
if (EFI_ERROR (Status)) {
FreePool (Dhcp6Srv);
@@ -175,7 +172,7 @@ Dhcp6CreateService (
// Generate client Duid: If SMBIOS system UUID is located, generate DUID in DUID-UUID format.
// Otherwise, in DUID-LLT format.
//
- Dhcp6Srv->ClientId = Dhcp6GenerateClientId (Dhcp6Srv->Snp->Mode);
+ Dhcp6Srv->ClientId = Dhcp6GenerateClientId (Dhcp6Srv->Snp->Mode);
if (Dhcp6Srv->ClientId == NULL) {
FreePool (Dhcp6Srv);
@@ -206,7 +203,6 @@ Dhcp6CreateService (
return EFI_SUCCESS;
}
-
/**
Destroy the Dhcp6 instance and recycle the resources.
@@ -215,7 +211,7 @@ Dhcp6CreateService (
**/
VOID
Dhcp6DestroyInstance (
- IN OUT DHCP6_INSTANCE *Instance
+ IN OUT DHCP6_INSTANCE *Instance
)
{
//
@@ -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.
@@ -266,12 +262,12 @@ Dhcp6DestroyInstance (
**/
EFI_STATUS
Dhcp6CreateInstance (
- IN DHCP6_SERVICE *Service,
- OUT DHCP6_INSTANCE **Instance
+ IN DHCP6_SERVICE *Service,
+ OUT DHCP6_INSTANCE **Instance
)
{
- EFI_STATUS Status;
- DHCP6_INSTANCE *Dhcp6Ins;
+ EFI_STATUS Status;
+ DHCP6_INSTANCE *Dhcp6Ins;
*Instance = NULL;
Dhcp6Ins = AllocateZeroPool (sizeof (DHCP6_INSTANCE));
@@ -283,11 +279,11 @@ Dhcp6CreateInstance (
//
// Initialize the fields of the new Dhcp6 instance.
//
- Dhcp6Ins->Signature = DHCP6_INSTANCE_SIGNATURE;
- Dhcp6Ins->UdpSts = EFI_ALREADY_STARTED;
- Dhcp6Ins->Service = Service;
- Dhcp6Ins->InDestroy = FALSE;
- Dhcp6Ins->MediaPresent = TRUE;
+ Dhcp6Ins->Signature = DHCP6_INSTANCE_SIGNATURE;
+ Dhcp6Ins->UdpSts = EFI_ALREADY_STARTED;
+ Dhcp6Ins->Service = Service;
+ Dhcp6Ins->InDestroy = FALSE;
+ Dhcp6Ins->MediaPresent = TRUE;
CopyMem (
&Dhcp6Ins->Dhcp6,
@@ -333,24 +329,23 @@ Dhcp6CreateInstance (
EFI_STATUS
EFIAPI
Dhcp6DestroyChildEntry (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
- DHCP6_INSTANCE *Instance;
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ DHCP6_INSTANCE *Instance;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- if (Entry == NULL || Context == NULL) {
+ if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP6_INSTANCE, Link, DHCP6_INSTANCE_SIGNATURE);
- ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context;
+ Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP6_INSTANCE, Link, DHCP6_INSTANCE_SIGNATURE);
+ ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context;
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
}
-
/**
Entry point of the DHCP6 driver to install various protocols.
@@ -364,8 +359,8 @@ Dhcp6DestroyChildEntry (
EFI_STATUS
EFIAPI
Dhcp6DriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (
@@ -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
@@ -441,8 +434,8 @@ Dhcp6DriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- DHCP6_SERVICE *Service;
+ EFI_STATUS Status;
+ DHCP6_SERVICE *Service;
//
// Check the Dhcp6 service whether already started.
@@ -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
@@ -519,12 +511,12 @@ Dhcp6DriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_HANDLE NicHandle;
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- DHCP6_SERVICE *Service;
- LIST_ENTRY *List;
- UINTN ListLength;
+ EFI_STATUS Status;
+ EFI_HANDLE NicHandle;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ DHCP6_SERVICE *Service;
+ LIST_ENTRY *List;
+ UINTN ListLength;
//
// Find and check the Nic handle by the controller handle.
@@ -538,7 +530,7 @@ Dhcp6DriverBindingStop (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiDhcp6ServiceBindingProtocolGuid,
- (VOID **) &ServiceBinding,
+ (VOID **)&ServiceBinding,
This->DriverBindingHandle,
NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -553,23 +545,23 @@ Dhcp6DriverBindingStop (
//
// Destroy all the children instances before destroy the service.
//
- List = &Service->Child;
+ List = &Service->Child;
Status = NetDestroyLinkList (
List,
Dhcp6DestroyChildEntry,
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.
@@ -615,19 +606,19 @@ Dhcp6ServiceBindingCreateChild (
IN OUT EFI_HANDLE *ChildHandle
)
{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- DHCP6_SERVICE *Service;
- DHCP6_INSTANCE *Instance;
- VOID *Udp6;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ DHCP6_SERVICE *Service;
+ DHCP6_INSTANCE *Instance;
+ VOID *Udp6;
- if (This == NULL || ChildHandle == NULL) {
+ if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
Service = DHCP6_SERVICE_FROM_THIS (This);
- Status = Dhcp6CreateInstance (Service, &Instance);
+ Status = Dhcp6CreateInstance (Service, &Instance);
if (EFI_ERROR (Status)) {
return Status;
@@ -670,14 +661,13 @@ Dhcp6ServiceBindingCreateChild (
Status = gBS->OpenProtocol (
Service->UdpIo->UdpHandle,
&gEfiUdp6ProtocolGuid,
- (VOID **) &Udp6,
+ (VOID **)&Udp6,
gDhcp6DriverBinding.DriverBindingHandle,
Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR (Status)) {
-
gBS->UninstallMultipleProtocolInterfaces (
Instance->Handle,
&gEfiDhcp6ProtocolGuid,
@@ -704,7 +694,6 @@ ON_ERROR:
return Status;
}
-
/**
Destroys a child handle with a protocol installed on it.
@@ -730,13 +719,13 @@ Dhcp6ServiceBindingDestroyChild (
IN EFI_HANDLE ChildHandle
)
{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- EFI_DHCP6_PROTOCOL *Dhcp6;
- DHCP6_SERVICE *Service;
- DHCP6_INSTANCE *Instance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ EFI_DHCP6_PROTOCOL *Dhcp6;
+ DHCP6_SERVICE *Service;
+ DHCP6_INSTANCE *Instance;
- if (This == NULL || ChildHandle == NULL) {
+ if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -746,7 +735,7 @@ Dhcp6ServiceBindingDestroyChild (
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiDhcp6ProtocolGuid,
- (VOID **) &Dhcp6,
+ (VOID **)&Dhcp6,
gDhcp6DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
diff --git a/NetworkPkg/DnsDxe/DnsDhcp.c b/NetworkPkg/DnsDxe/DnsDhcp.c
index 8f8b2aab1e..933565a32d 100644
--- a/NetworkPkg/DnsDxe/DnsDhcp.c
+++ b/NetworkPkg/DnsDxe/DnsDhcp.c
@@ -19,22 +19,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
VOID
DnsInitSeedPacket (
- OUT EFI_DHCP4_PACKET *Seed,
- IN EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo
+ OUT EFI_DHCP4_PACKET *Seed,
+ IN EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo
)
{
- EFI_DHCP4_HEADER *Header;
+ EFI_DHCP4_HEADER *Header;
//
// Get IfType and HwAddressSize from SNP mode data.
//
- Seed->Size = sizeof (EFI_DHCP4_PACKET);
- Seed->Length = sizeof (Seed->Dhcp4);
- Header = &Seed->Dhcp4.Header;
+ Seed->Size = sizeof (EFI_DHCP4_PACKET);
+ Seed->Length = sizeof (Seed->Dhcp4);
+ Header = &Seed->Dhcp4.Header;
ZeroMem (Header, sizeof (EFI_DHCP4_HEADER));
- Header->OpCode = DHCP4_OPCODE_REQUEST;
- Header->HwType = InterfaceInfo->IfType;
- Header->HwAddrLen = (UINT8) InterfaceInfo->HwAddressSize;
+ Header->OpCode = DHCP4_OPCODE_REQUEST;
+ Header->HwType = InterfaceInfo->IfType;
+ Header->HwAddrLen = (UINT8)InterfaceInfo->HwAddressSize;
CopyMem (Header->ClientHwAddr, &(InterfaceInfo->HwAddress), Header->HwAddrLen);
Seed->Dhcp4.Magik = DHCP4_MAGIC;
@@ -56,10 +56,10 @@ DhcpCommonNotify (
)
{
if ((Event == NULL) || (Context == NULL)) {
- return ;
+ return;
}
- *((BOOLEAN *) Context) = TRUE;
+ *((BOOLEAN *)Context) = TRUE;
}
/**
@@ -77,26 +77,26 @@ DhcpCommonNotify (
**/
EFI_STATUS
ParseDhcp4Ack (
- IN EFI_DHCP4_PROTOCOL *Dhcp4,
- IN EFI_DHCP4_PACKET *Packet,
- IN DNS4_SERVER_INFOR *DnsServerInfor
+ IN EFI_DHCP4_PROTOCOL *Dhcp4,
+ IN EFI_DHCP4_PACKET *Packet,
+ IN DNS4_SERVER_INFOR *DnsServerInfor
)
{
- EFI_STATUS Status;
- UINT32 OptionCount;
- EFI_DHCP4_PACKET_OPTION **OptionList;
- UINT32 ServerCount;
- EFI_IPv4_ADDRESS *ServerList;
- UINT32 Index;
- UINT32 Count;
+ EFI_STATUS Status;
+ UINT32 OptionCount;
+ EFI_DHCP4_PACKET_OPTION **OptionList;
+ UINT32 ServerCount;
+ EFI_IPv4_ADDRESS *ServerList;
+ UINT32 Index;
+ UINT32 Count;
ServerCount = 0;
- ServerList = NULL;
+ ServerList = NULL;
OptionCount = 0;
OptionList = NULL;
- Status = Dhcp4->Parse (Dhcp4, Packet, &OptionCount, OptionList);
+ Status = Dhcp4->Parse (Dhcp4, Packet, &OptionCount, OptionList);
if (Status != EFI_BUFFER_TOO_SMALL) {
return EFI_DEVICE_ERROR;
}
@@ -119,19 +119,18 @@ 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;
}
ServerCount = OptionList[Index]->Length/4;
- ServerList = AllocatePool (ServerCount * sizeof (EFI_IPv4_ADDRESS));
+ ServerList = AllocatePool (ServerCount * sizeof (EFI_IPv4_ADDRESS));
if (ServerList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- for (Count=0; Count < ServerCount; Count++) {
+ for (Count = 0; Count < ServerCount; Count++) {
CopyMem (ServerList + Count, &OptionList[Index]->Data[4 * Count], sizeof (EFI_IPv4_ADDRESS));
}
@@ -167,25 +166,25 @@ ParseDhcp4Ack (
EFI_STATUS
EFIAPI
ParseDhcp6Ack (
- IN EFI_DHCP6_PROTOCOL *This,
- IN VOID *Context,
- IN EFI_DHCP6_PACKET *Packet
+ IN EFI_DHCP6_PROTOCOL *This,
+ IN VOID *Context,
+ IN EFI_DHCP6_PACKET *Packet
)
{
- EFI_STATUS Status;
- UINT32 OptionCount;
- EFI_DHCP6_PACKET_OPTION **OptionList;
- DNS6_SERVER_INFOR *DnsServerInfor;
- UINT32 ServerCount;
- EFI_IPv6_ADDRESS *ServerList;
- UINT32 Index;
- UINT32 Count;
+ EFI_STATUS Status;
+ UINT32 OptionCount;
+ EFI_DHCP6_PACKET_OPTION **OptionList;
+ DNS6_SERVER_INFOR *DnsServerInfor;
+ UINT32 ServerCount;
+ EFI_IPv6_ADDRESS *ServerList;
+ UINT32 Index;
+ UINT32 Count;
OptionCount = 0;
ServerCount = 0;
ServerList = NULL;
- Status = This->Parse (This, Packet, &OptionCount, NULL);
+ Status = This->Parse (This, Packet, &OptionCount, NULL);
if (Status != EFI_BUFFER_TOO_SMALL) {
return EFI_DEVICE_ERROR;
}
@@ -201,7 +200,7 @@ ParseDhcp6Ack (
return EFI_DEVICE_ERROR;
}
- DnsServerInfor = (DNS6_SERVER_INFOR *) Context;
+ DnsServerInfor = (DNS6_SERVER_INFOR *)Context;
for (Index = 0; Index < OptionCount; Index++) {
OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode);
@@ -211,7 +210,6 @@ ParseDhcp6Ack (
// Get DNS server addresses from this reply packet.
//
if (OptionList[Index]->OpCode == DHCP6_TAG_DNS_SERVER) {
-
if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
Status = EFI_DEVICE_ERROR;
gBS->FreePool (OptionList);
@@ -219,13 +217,13 @@ ParseDhcp6Ack (
}
ServerCount = OptionList[Index]->OpLen/16;
- ServerList = AllocatePool (ServerCount * sizeof (EFI_IPv6_ADDRESS));
+ ServerList = AllocatePool (ServerCount * sizeof (EFI_IPv6_ADDRESS));
if (ServerList == NULL) {
gBS->FreePool (OptionList);
return EFI_OUT_OF_RESOURCES;
}
- for (Count=0; Count < ServerCount; Count++) {
+ for (Count = 0; Count < ServerCount; Count++) {
CopyMem (ServerList + Count, &OptionList[Index]->Data[16 * Count], sizeof (EFI_IPv6_ADDRESS));
}
@@ -237,7 +235,6 @@ ParseDhcp6Ack (
gBS->FreePool (OptionList);
return Status;
-
}
/**
@@ -255,47 +252,47 @@ ParseDhcp6Ack (
**/
EFI_STATUS
GetDns4ServerFromDhcp4 (
- IN DNS_INSTANCE *Instance,
- OUT UINT32 *DnsServerCount,
- OUT EFI_IPv4_ADDRESS **DnsServerList
+ IN DNS_INSTANCE *Instance,
+ OUT UINT32 *DnsServerCount,
+ OUT EFI_IPv4_ADDRESS **DnsServerList
)
{
- EFI_STATUS Status;
- EFI_HANDLE Image;
- EFI_HANDLE Controller;
- EFI_STATUS MediaStatus;
- EFI_HANDLE MnpChildHandle;
- EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
- EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
- EFI_HANDLE Dhcp4Handle;
- EFI_DHCP4_PROTOCOL *Dhcp4;
- EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
- UINTN DataSize;
- VOID *Data;
- EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo;
- EFI_DHCP4_PACKET SeedPacket;
- EFI_DHCP4_PACKET_OPTION *ParaList[2];
- DNS4_SERVER_INFOR DnsServerInfor;
-
- EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN Token;
- BOOLEAN IsDone;
- UINTN Index;
-
- Image = Instance->Service->ImageHandle;
- Controller = Instance->Service->ControllerHandle;
-
- MnpChildHandle = NULL;
- Mnp = NULL;
-
- Dhcp4Handle = NULL;
- Dhcp4 = NULL;
-
- Ip4Config2 = NULL;
- DataSize = 0;
- Data = NULL;
- InterfaceInfo = NULL;
-
- ZeroMem ((UINT8 *) ParaList, sizeof (ParaList));
+ EFI_STATUS Status;
+ EFI_HANDLE Image;
+ EFI_HANDLE Controller;
+ EFI_STATUS MediaStatus;
+ EFI_HANDLE MnpChildHandle;
+ EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
+ EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
+ EFI_HANDLE Dhcp4Handle;
+ EFI_DHCP4_PROTOCOL *Dhcp4;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
+ UINTN DataSize;
+ VOID *Data;
+ EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo;
+ EFI_DHCP4_PACKET SeedPacket;
+ EFI_DHCP4_PACKET_OPTION *ParaList[2];
+ DNS4_SERVER_INFOR DnsServerInfor;
+
+ EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN Token;
+ BOOLEAN IsDone;
+ UINTN Index;
+
+ Image = Instance->Service->ImageHandle;
+ Controller = Instance->Service->ControllerHandle;
+
+ MnpChildHandle = NULL;
+ Mnp = NULL;
+
+ Dhcp4Handle = NULL;
+ Dhcp4 = NULL;
+
+ Ip4Config2 = NULL;
+ DataSize = 0;
+ Data = NULL;
+ InterfaceInfo = NULL;
+
+ ZeroMem ((UINT8 *)ParaList, sizeof (ParaList));
ZeroMem (&MnpConfigData, sizeof (EFI_MANAGED_NETWORK_CONFIG_DATA));
@@ -332,7 +329,7 @@ GetDns4ServerFromDhcp4 (
Status = gBS->OpenProtocol (
MnpChildHandle,
&gEfiManagedNetworkProtocolGuid,
- (VOID **) &Mnp,
+ (VOID **)&Mnp,
Image,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -352,7 +349,7 @@ GetDns4ServerFromDhcp4 (
MnpConfigData.EnableReceiveTimestamps = FALSE;
MnpConfigData.DisableBackgroundPolling = FALSE;
- Status = Mnp->Configure(Mnp, &MnpConfigData);
+ Status = Mnp->Configure (Mnp, &MnpConfigData);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -373,7 +370,7 @@ GetDns4ServerFromDhcp4 (
Status = gBS->OpenProtocol (
Dhcp4Handle,
&gEfiDhcp4ProtocolGuid,
- (VOID **) &Dhcp4,
+ (VOID **)&Dhcp4,
Image,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -385,13 +382,13 @@ GetDns4ServerFromDhcp4 (
//
// Get Ip4Config2 instance info.
//
- Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);
+ Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeInterfaceInfo, &DataSize, Data);
- if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
+ if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
goto ON_EXIT;
}
@@ -470,7 +467,7 @@ GetDns4ServerFromDhcp4 (
Status = Dhcp4->Build (Dhcp4, &SeedPacket, 0, NULL, 2, ParaList, &Token.Packet);
- Token.Packet->Dhcp4.Header.Xid = HTONL(NET_RANDOM (NetRandomInitSeed ()));
+ Token.Packet->Dhcp4.Header.Xid = HTONL (NET_RANDOM (NetRandomInitSeed ()));
Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16)0x8000);
@@ -601,10 +598,10 @@ ON_EXIT:
**/
EFI_STATUS
GetDns6ServerFromDhcp6 (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- OUT UINT32 *DnsServerCount,
- OUT EFI_IPv6_ADDRESS **DnsServerList
+ IN EFI_HANDLE Image,
+ IN EFI_HANDLE Controller,
+ OUT UINT32 *DnsServerCount,
+ OUT EFI_IPv6_ADDRESS **DnsServerList
)
{
EFI_HANDLE Dhcp6Handle;
@@ -651,7 +648,7 @@ GetDns6ServerFromDhcp6 (
Status = gBS->OpenProtocol (
Dhcp6Handle,
&gEfiDhcp6ProtocolGuid,
- (VOID **) &Dhcp6,
+ (VOID **)&Dhcp6,
Image,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -724,7 +721,7 @@ GetDns6ServerFromDhcp6 (
} while (TimerStatus == EFI_NOT_READY);
}
- *DnsServerList = DnsServerInfor.ServerList;
+ *DnsServerList = DnsServerInfor.ServerList;
ON_EXIT:
@@ -753,6 +750,4 @@ ON_EXIT:
);
return Status;
-
}
-
diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c
index 78a56f2b56..d311812800 100644
--- a/NetworkPkg/DnsDxe/DnsImpl.c
+++ b/NetworkPkg/DnsDxe/DnsImpl.c
@@ -20,8 +20,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
Dns4RemoveTokenEntry (
- IN NET_MAP *TokenMap,
- IN DNS4_TOKEN_ENTRY *TokenEntry
+ IN NET_MAP *TokenMap,
+ IN DNS4_TOKEN_ENTRY *TokenEntry
)
{
NET_MAP_ITEM *Item;
@@ -29,7 +29,7 @@ Dns4RemoveTokenEntry (
//
// Find the TokenEntry first.
//
- Item = NetMapFindKey (TokenMap, (VOID *) TokenEntry);
+ Item = NetMapFindKey (TokenMap, (VOID *)TokenEntry);
if (Item != NULL) {
//
@@ -55,8 +55,8 @@ Dns4RemoveTokenEntry (
**/
EFI_STATUS
Dns6RemoveTokenEntry (
- IN NET_MAP *TokenMap,
- IN DNS6_TOKEN_ENTRY *TokenEntry
+ IN NET_MAP *TokenMap,
+ IN DNS6_TOKEN_ENTRY *TokenEntry
)
{
NET_MAP_ITEM *Item;
@@ -64,7 +64,7 @@ Dns6RemoveTokenEntry (
//
// Find the TokenEntry first.
//
- Item = NetMapFindKey (TokenMap, (VOID *) TokenEntry);
+ Item = NetMapFindKey (TokenMap, (VOID *)TokenEntry);
if (Item != NULL) {
//
@@ -102,9 +102,9 @@ Dns4CancelTokens (
IN VOID *Arg OPTIONAL
)
{
- DNS4_TOKEN_ENTRY *TokenEntry;
- NET_BUF *Packet;
- UDP_IO *UdpIo;
+ DNS4_TOKEN_ENTRY *TokenEntry;
+ NET_BUF *Packet;
+ UDP_IO *UdpIo;
if ((Arg != NULL) && (Item->Key != Arg)) {
return EFI_SUCCESS;
@@ -115,8 +115,8 @@ Dns4CancelTokens (
// If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in
// Item->Value.
//
- Packet = (NET_BUF *) (Item->Value);
- UdpIo = (UDP_IO *) (*((UINTN *) &Packet->ProtoData[0]));
+ Packet = (NET_BUF *)(Item->Value);
+ UdpIo = (UDP_IO *)(*((UINTN *)&Packet->ProtoData[0]));
UdpIoCancelSentDatagram (UdpIo, Packet);
}
@@ -124,7 +124,7 @@ Dns4CancelTokens (
//
// Remove TokenEntry from Dns4TxTokens.
//
- TokenEntry = (DNS4_TOKEN_ENTRY *) Item->Key;
+ TokenEntry = (DNS4_TOKEN_ENTRY *)Item->Key;
if (Dns4RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) {
TokenEntry->Token->Status = EFI_ABORTED;
gBS->SignalEvent (TokenEntry->Token->Event);
@@ -162,9 +162,9 @@ Dns6CancelTokens (
IN VOID *Arg OPTIONAL
)
{
- DNS6_TOKEN_ENTRY *TokenEntry;
- NET_BUF *Packet;
- UDP_IO *UdpIo;
+ DNS6_TOKEN_ENTRY *TokenEntry;
+ NET_BUF *Packet;
+ UDP_IO *UdpIo;
if ((Arg != NULL) && (Item->Key != Arg)) {
return EFI_SUCCESS;
@@ -175,8 +175,8 @@ Dns6CancelTokens (
// If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in
// Item->Value.
//
- Packet = (NET_BUF *) (Item->Value);
- UdpIo = (UDP_IO *) (*((UINTN *) &Packet->ProtoData[0]));
+ Packet = (NET_BUF *)(Item->Value);
+ UdpIo = (UDP_IO *)(*((UINTN *)&Packet->ProtoData[0]));
UdpIoCancelSentDatagram (UdpIo, Packet);
}
@@ -184,7 +184,7 @@ Dns6CancelTokens (
//
// Remove TokenEntry from Dns6TxTokens.
//
- TokenEntry = (DNS6_TOKEN_ENTRY *) Item->Key;
+ TokenEntry = (DNS6_TOKEN_ENTRY *)Item->Key;
if (Dns6RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) {
TokenEntry->Token->Status = EFI_ABORTED;
gBS->SignalEvent (TokenEntry->Token->Event);
@@ -212,18 +212,18 @@ Dns6CancelTokens (
EFI_STATUS
EFIAPI
GetDns4TokenEntry (
- IN NET_MAP *TokensMap,
- IN EFI_DNS4_COMPLETION_TOKEN *Token,
- OUT DNS4_TOKEN_ENTRY **TokenEntry
+ IN NET_MAP *TokensMap,
+ IN EFI_DNS4_COMPLETION_TOKEN *Token,
+ OUT DNS4_TOKEN_ENTRY **TokenEntry
)
{
- LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry;
- NET_MAP_ITEM *Item;
+ NET_MAP_ITEM *Item;
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
- Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
- *TokenEntry = (DNS4_TOKEN_ENTRY *) (Item->Key);
+ Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
+ *TokenEntry = (DNS4_TOKEN_ENTRY *)(Item->Key);
if ((*TokenEntry)->Token == Token) {
return EFI_SUCCESS;
}
@@ -248,24 +248,24 @@ GetDns4TokenEntry (
EFI_STATUS
EFIAPI
GetDns6TokenEntry (
- IN NET_MAP *TokensMap,
- IN EFI_DNS6_COMPLETION_TOKEN *Token,
- OUT DNS6_TOKEN_ENTRY **TokenEntry
+ IN NET_MAP *TokensMap,
+ IN EFI_DNS6_COMPLETION_TOKEN *Token,
+ OUT DNS6_TOKEN_ENTRY **TokenEntry
)
{
- LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry;
- NET_MAP_ITEM *Item;
+ NET_MAP_ITEM *Item;
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
- Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
- *TokenEntry = (DNS6_TOKEN_ENTRY *) (Item->Key);
+ Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
+ *TokenEntry = (DNS6_TOKEN_ENTRY *)(Item->Key);
if ((*TokenEntry)->Token == Token) {
return EFI_SUCCESS;
}
}
- *TokenEntry =NULL;
+ *TokenEntry = NULL;
return EFI_NOT_FOUND;
}
@@ -293,7 +293,7 @@ Dns4InstanceCancelToken (
TokenEntry = NULL;
- if(Token != NULL ) {
+ if (Token != NULL ) {
Status = GetDns4TokenEntry (&Instance->Dns4TxTokens, Token, &TokenEntry);
if (EFI_ERROR (Status)) {
return Status;
@@ -313,8 +313,9 @@ Dns4InstanceCancelToken (
// the Dns4TxTokens and returns success.
//
if (NetMapIsEmpty (&Instance->Dns4TxTokens)) {
- Instance->UdpIo->Protocol.Udp4->Cancel (Instance->UdpIo->Protocol.Udp4, &Instance->UdpIo->RecvRequest->Token.Udp4);
+ Instance->UdpIo->Protocol.Udp4->Cancel (Instance->UdpIo->Protocol.Udp4, &Instance->UdpIo->RecvRequest->Token.Udp4);
}
+
return EFI_SUCCESS;
}
@@ -350,7 +351,7 @@ Dns6InstanceCancelToken (
TokenEntry = NULL;
- if(Token != NULL ) {
+ if (Token != NULL ) {
Status = GetDns6TokenEntry (&Instance->Dns6TxTokens, Token, &TokenEntry);
if (EFI_ERROR (Status)) {
return Status;
@@ -370,8 +371,9 @@ Dns6InstanceCancelToken (
// the Dns6TxTokens and returns success.
//
if (NetMapIsEmpty (&Instance->Dns6TxTokens)) {
- Instance->UdpIo->Protocol.Udp6->Cancel (Instance->UdpIo->Protocol.Udp6, &Instance->UdpIo->RecvRequest->Token.Udp6);
+ Instance->UdpIo->Protocol.Udp6->Cancel (Instance->UdpIo->Protocol.Udp6, &Instance->UdpIo->RecvRequest->Token.Udp6);
}
+
return EFI_SUCCESS;
}
@@ -437,8 +439,8 @@ Dns4CopyConfigure (
IN EFI_DNS4_CONFIG_DATA *Src
)
{
- UINTN Len;
- UINT32 Index;
+ UINTN Len;
+ UINT32 Index;
CopyMem (Dst, Src, sizeof (*Dst));
Dst->DnsServerList = NULL;
@@ -479,8 +481,8 @@ Dns6CopyConfigure (
IN EFI_DNS6_CONFIG_DATA *Src
)
{
- UINTN Len;
- UINT32 Index;
+ UINTN Len;
+ UINT32 Index;
CopyMem (Dst, Src, sizeof (*Dst));
Dst->DnsServerList = NULL;
@@ -513,7 +515,7 @@ Dns6CopyConfigure (
VOID
EFIAPI
DnsDummyExtFree (
- IN VOID *Arg
+ IN VOID *Arg
)
{
}
@@ -535,15 +537,15 @@ DnsDummyExtFree (
**/
BOOLEAN
Dns4GetMapping (
- IN DNS_INSTANCE *Instance,
- IN UDP_IO *UdpIo,
- IN EFI_UDP4_CONFIG_DATA *UdpCfgData
+ IN DNS_INSTANCE *Instance,
+ IN UDP_IO *UdpIo,
+ IN EFI_UDP4_CONFIG_DATA *UdpCfgData
)
{
- DNS_SERVICE *Service;
- EFI_IP4_MODE_DATA Ip4Mode;
- EFI_UDP4_PROTOCOL *Udp;
- EFI_STATUS Status;
+ DNS_SERVICE *Service;
+ EFI_IP4_MODE_DATA Ip4Mode;
+ EFI_UDP4_PROTOCOL *Udp;
+ EFI_STATUS Status;
ASSERT (Instance->Dns4CfgData.UseDefaultSetting);
@@ -563,10 +565,10 @@ Dns4GetMapping (
Udp->Poll (Udp);
if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) &&
- Ip4Mode.IsConfigured) {
-
+ Ip4Mode.IsConfigured)
+ {
Udp->Configure (Udp, NULL);
- return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
+ return (BOOLEAN)(Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
}
}
@@ -587,15 +589,15 @@ Dns4GetMapping (
**/
BOOLEAN
Dns6GetMapping (
- IN DNS_INSTANCE *Instance,
- IN UDP_IO *UdpIo,
- IN EFI_UDP6_CONFIG_DATA *UdpCfgData
+ IN DNS_INSTANCE *Instance,
+ IN UDP_IO *UdpIo,
+ IN EFI_UDP6_CONFIG_DATA *UdpCfgData
)
{
- DNS_SERVICE *Service;
- EFI_IP6_MODE_DATA Ip6Mode;
- EFI_UDP6_PROTOCOL *Udp;
- EFI_STATUS Status;
+ DNS_SERVICE *Service;
+ EFI_IP6_MODE_DATA Ip6Mode;
+ EFI_UDP6_PROTOCOL *Udp;
+ EFI_STATUS Status;
Service = Instance->Service;
Udp = UdpIo->Protocol.Udp6;
@@ -661,13 +663,13 @@ Dns6GetMapping (
**/
EFI_STATUS
Dns4ConfigUdp (
- IN DNS_INSTANCE *Instance,
- IN UDP_IO *UdpIo
+ IN DNS_INSTANCE *Instance,
+ IN UDP_IO *UdpIo
)
{
- EFI_DNS4_CONFIG_DATA *Config;
- EFI_UDP4_CONFIG_DATA UdpConfig;
- EFI_STATUS Status;
+ EFI_DNS4_CONFIG_DATA *Config;
+ EFI_UDP4_CONFIG_DATA UdpConfig;
+ EFI_STATUS Status;
Config = &Instance->Dns4CfgData;
@@ -709,13 +711,13 @@ Dns4ConfigUdp (
**/
EFI_STATUS
Dns6ConfigUdp (
- IN DNS_INSTANCE *Instance,
- IN UDP_IO *UdpIo
+ IN DNS_INSTANCE *Instance,
+ IN UDP_IO *UdpIo
)
{
- EFI_DNS6_CONFIG_DATA *Config;
- EFI_UDP6_CONFIG_DATA UdpConfig;
- EFI_STATUS Status;
+ EFI_DNS6_CONFIG_DATA *Config;
+ EFI_UDP6_CONFIG_DATA UdpConfig;
+ EFI_STATUS Status;
Config = &Instance->Dns6CfgData;
@@ -757,16 +759,16 @@ Dns6ConfigUdp (
EFI_STATUS
EFIAPI
UpdateDns4Cache (
- IN LIST_ENTRY *Dns4CacheList,
- IN BOOLEAN DeleteFlag,
- IN BOOLEAN Override,
- IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry
+ IN LIST_ENTRY *Dns4CacheList,
+ IN BOOLEAN DeleteFlag,
+ IN BOOLEAN Override,
+ IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry
)
{
- DNS4_CACHE *NewDnsCache;
- DNS4_CACHE *Item;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
+ DNS4_CACHE *NewDnsCache;
+ DNS4_CACHE *Item;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
NewDnsCache = NULL;
Item = NULL;
@@ -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
//
@@ -855,16 +858,16 @@ UpdateDns4Cache (
EFI_STATUS
EFIAPI
UpdateDns6Cache (
- IN LIST_ENTRY *Dns6CacheList,
- IN BOOLEAN DeleteFlag,
- IN BOOLEAN Override,
- IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry
+ IN LIST_ENTRY *Dns6CacheList,
+ IN BOOLEAN DeleteFlag,
+ IN BOOLEAN Override,
+ IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry
)
{
- DNS6_CACHE *NewDnsCache;
- DNS6_CACHE *Item;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
+ DNS6_CACHE *NewDnsCache;
+ DNS6_CACHE *Item;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
NewDnsCache = NULL;
Item = NULL;
@@ -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
//
@@ -950,14 +954,14 @@ UpdateDns6Cache (
EFI_STATUS
EFIAPI
AddDns4ServerIp (
- IN LIST_ENTRY *Dns4ServerList,
- IN EFI_IPv4_ADDRESS ServerIp
+ IN LIST_ENTRY *Dns4ServerList,
+ IN EFI_IPv4_ADDRESS ServerIp
)
{
- DNS4_SERVER_IP *NewServerIp;
- DNS4_SERVER_IP *Item;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
+ DNS4_SERVER_IP *NewServerIp;
+ DNS4_SERVER_IP *Item;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
NewServerIp = NULL;
Item = NULL;
@@ -1005,14 +1009,14 @@ AddDns4ServerIp (
EFI_STATUS
EFIAPI
AddDns6ServerIp (
- IN LIST_ENTRY *Dns6ServerList,
- IN EFI_IPv6_ADDRESS ServerIp
+ IN LIST_ENTRY *Dns6ServerList,
+ IN EFI_IPv6_ADDRESS ServerIp
)
{
- DNS6_SERVER_IP *NewServerIp;
- DNS6_SERVER_IP *Item;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
+ DNS6_SERVER_IP *NewServerIp;
+ DNS6_SERVER_IP *Item;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
NewServerIp = NULL;
Item = NULL;
@@ -1062,37 +1066,37 @@ AddDns6ServerIp (
**/
BOOLEAN
IsValidDnsResponse (
- IN NET_MAP *TokensMap,
- IN UINT16 Identification,
- IN UINT16 Type,
- IN UINT16 Class,
- OUT NET_MAP_ITEM **Item
+ IN NET_MAP *TokensMap,
+ IN UINT16 Identification,
+ IN UINT16 Type,
+ IN UINT16 Class,
+ OUT NET_MAP_ITEM **Item
)
{
- LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry;
- NET_BUF *Packet;
- UINT8 *TxString;
- DNS_HEADER *DnsHeader;
- CHAR8 *QueryName;
- DNS_QUERY_SECTION *QuerySection;
+ NET_BUF *Packet;
+ UINT8 *TxString;
+ DNS_HEADER *DnsHeader;
+ CHAR8 *QueryName;
+ DNS_QUERY_SECTION *QuerySection;
NET_LIST_FOR_EACH (Entry, &TokensMap->Used) {
- *Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
- Packet = (NET_BUF *) ((*Item)->Value);
+ *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);
ASSERT (TxString != NULL);
- DnsHeader = (DNS_HEADER *) TxString;
- QueryName = (CHAR8 *) (TxString + sizeof (*DnsHeader));
- QuerySection = (DNS_QUERY_SECTION *) (QueryName + AsciiStrLen (QueryName) + 1);
-
- if (NTOHS (DnsHeader->Identification) == Identification &&
- NTOHS (QuerySection->Type) == Type &&
- NTOHS (QuerySection->Class) == Class) {
+ DnsHeader = (DNS_HEADER *)TxString;
+ QueryName = (CHAR8 *)(TxString + sizeof (*DnsHeader));
+ QuerySection = (DNS_QUERY_SECTION *)(QueryName + AsciiStrLen (QueryName) + 1);
+
+ if ((NTOHS (DnsHeader->Identification) == Identification) &&
+ (NTOHS (QuerySection->Type) == Type) &&
+ (NTOHS (QuerySection->Class) == Class))
+ {
return TRUE;
}
}
@@ -1117,33 +1121,33 @@ IsValidDnsResponse (
**/
EFI_STATUS
ParseDnsResponse (
- IN OUT DNS_INSTANCE *Instance,
- IN UINT8 *RxString,
- IN UINT32 Length,
- OUT BOOLEAN *Completed
+ IN OUT DNS_INSTANCE *Instance,
+ IN UINT8 *RxString,
+ IN UINT32 Length,
+ OUT BOOLEAN *Completed
)
{
- DNS_HEADER *DnsHeader;
+ DNS_HEADER *DnsHeader;
- CHAR8 *QueryName;
- UINT32 QueryNameLen;
- DNS_QUERY_SECTION *QuerySection;
+ CHAR8 *QueryName;
+ UINT32 QueryNameLen;
+ DNS_QUERY_SECTION *QuerySection;
- CHAR8 *AnswerName;
- DNS_ANSWER_SECTION *AnswerSection;
- UINT8 *AnswerData;
+ CHAR8 *AnswerName;
+ DNS_ANSWER_SECTION *AnswerSection;
+ UINT8 *AnswerData;
- NET_MAP_ITEM *Item;
- DNS4_TOKEN_ENTRY *Dns4TokenEntry;
- DNS6_TOKEN_ENTRY *Dns6TokenEntry;
+ NET_MAP_ITEM *Item;
+ DNS4_TOKEN_ENTRY *Dns4TokenEntry;
+ DNS6_TOKEN_ENTRY *Dns6TokenEntry;
- UINT32 IpCount;
- UINT32 RRCount;
- UINT32 AnswerSectionNum;
- UINT32 CNameTtl;
+ UINT32 IpCount;
+ UINT32 RRCount;
+ UINT32 AnswerSectionNum;
+ UINT32 CNameTtl;
- EFI_IPv4_ADDRESS *HostAddr4;
- EFI_IPv6_ADDRESS *HostAddr6;
+ EFI_IPv4_ADDRESS *HostAddr4;
+ EFI_IPv6_ADDRESS *HostAddr6;
EFI_DNS4_CACHE_ENTRY *Dns4CacheEntry;
EFI_DNS6_CACHE_ENTRY *Dns6CacheEntry;
@@ -1151,32 +1155,32 @@ ParseDnsResponse (
DNS_RESOURCE_RECORD *Dns4RR;
DNS6_RESOURCE_RECORD *Dns6RR;
- EFI_STATUS Status;
- UINT32 RemainingLength;
+ EFI_STATUS Status;
+ UINT32 RemainingLength;
- EFI_TPL OldTpl;
+ EFI_TPL OldTpl;
- Item = NULL;
- Dns4TokenEntry = NULL;
- Dns6TokenEntry = NULL;
+ Item = NULL;
+ Dns4TokenEntry = NULL;
+ Dns6TokenEntry = NULL;
IpCount = 0;
RRCount = 0;
AnswerSectionNum = 0;
CNameTtl = 0;
- HostAddr4 = NULL;
- HostAddr6 = NULL;
+ HostAddr4 = NULL;
+ HostAddr6 = NULL;
- Dns4CacheEntry = NULL;
- Dns6CacheEntry = NULL;
+ Dns4CacheEntry = NULL;
+ Dns6CacheEntry = NULL;
- Dns4RR = NULL;
- Dns6RR = NULL;
+ Dns4RR = NULL;
+ Dns6RR = NULL;
- *Completed = TRUE;
- Status = EFI_SUCCESS;
- RemainingLength = Length;
+ *Completed = TRUE;
+ Status = EFI_SUCCESS;
+ RemainingLength = Length;
//
// Check whether the remaining packet length is available or not.
@@ -1191,14 +1195,14 @@ ParseDnsResponse (
//
// Get header
//
- DnsHeader = (DNS_HEADER *) RxString;
+ DnsHeader = (DNS_HEADER *)RxString;
DnsHeader->Identification = NTOHS (DnsHeader->Identification);
- DnsHeader->Flags.Uint16 = NTOHS (DnsHeader->Flags.Uint16);
- DnsHeader->QuestionsNum = NTOHS (DnsHeader->QuestionsNum);
- DnsHeader->AnswersNum = NTOHS (DnsHeader->AnswersNum);
- DnsHeader->AuthorityNum = NTOHS (DnsHeader->AuthorityNum);
- DnsHeader->AditionalNum = NTOHS (DnsHeader->AditionalNum);
+ DnsHeader->Flags.Uint16 = NTOHS (DnsHeader->Flags.Uint16);
+ DnsHeader->QuestionsNum = NTOHS (DnsHeader->QuestionsNum);
+ DnsHeader->AnswersNum = NTOHS (DnsHeader->AnswersNum);
+ DnsHeader->AuthorityNum = NTOHS (DnsHeader->AuthorityNum);
+ DnsHeader->AditionalNum = NTOHS (DnsHeader->AditionalNum);
//
// There is always one QuestionsNum in DNS message. The capability to handle more
@@ -1212,9 +1216,9 @@ ParseDnsResponse (
//
// Get Query name
//
- QueryName = (CHAR8 *) (RxString + sizeof (*DnsHeader));
+ QueryName = (CHAR8 *)(RxString + sizeof (*DnsHeader));
- QueryNameLen = (UINT32) AsciiStrLen (QueryName) + 1;
+ QueryNameLen = (UINT32)AsciiStrLen (QueryName) + 1;
//
// Check whether the remaining packet length is available or not.
@@ -1229,8 +1233,8 @@ ParseDnsResponse (
//
// Get query section
//
- QuerySection = (DNS_QUERY_SECTION *) (QueryName + QueryNameLen);
- QuerySection->Type = NTOHS (QuerySection->Type);
+ QuerySection = (DNS_QUERY_SECTION *)(QueryName + QueryNameLen);
+ QuerySection->Type = NTOHS (QuerySection->Type);
QuerySection->Class = NTOHS (QuerySection->Class);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@@ -1245,13 +1249,15 @@ ParseDnsResponse (
QuerySection->Type,
QuerySection->Class,
&Item
- )) {
+ ))
+ {
*Completed = FALSE;
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
goto ON_EXIT;
}
+
ASSERT (Item != NULL);
- Dns4TokenEntry = (DNS4_TOKEN_ENTRY *) (Item->Key);
+ Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(Item->Key);
} else {
if (!IsValidDnsResponse (
&Instance->Dns6TxTokens,
@@ -1259,20 +1265,23 @@ ParseDnsResponse (
QuerySection->Type,
QuerySection->Class,
&Item
- )) {
+ ))
+ {
*Completed = FALSE;
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
goto ON_EXIT;
}
+
ASSERT (Item != NULL);
- Dns6TokenEntry = (DNS6_TOKEN_ENTRY *) (Item->Key);
+ Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(Item->Key);
}
//
// Continue Check Some Errors.
//
- if (DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR || DnsHeader->AnswersNum < 1 || \
- DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE) {
+ if ((DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR) || (DnsHeader->AnswersNum < 1) || \
+ (DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE))
+ {
//
// The domain name referenced in the query does not exist.
//
@@ -1300,6 +1309,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
+
Dns4TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD));
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -1315,6 +1325,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
+
Dns4TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv4_ADDRESS));
if (Dns4TokenEntry->Token->RspData.H2AData->IpList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -1337,6 +1348,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
+
Dns6TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD));
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -1352,6 +1364,7 @@ ParseDnsResponse (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
+
Dns6TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv6_ADDRESS));
if (Dns6TokenEntry->Token->RspData.H2AData->IpList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -1369,7 +1382,7 @@ ParseDnsResponse (
//
// Get Answer name
//
- AnswerName = (CHAR8 *) QuerySection + sizeof (*QuerySection);
+ AnswerName = (CHAR8 *)QuerySection + sizeof (*QuerySection);
//
// Processing AnswerSection.
@@ -1380,7 +1393,7 @@ ParseDnsResponse (
//
if (RemainingLength <= sizeof (UINT16) + sizeof (DNS_ANSWER_SECTION)) {
*Completed = FALSE;
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
goto ON_EXIT;
} else {
RemainingLength -= (sizeof (UINT16) + sizeof (DNS_ANSWER_SECTION));
@@ -1389,7 +1402,7 @@ ParseDnsResponse (
//
// Answer name should be PTR, else EFI_UNSUPPORTED returned.
//
- if ((*(UINT8 *) AnswerName & 0xC0) != 0xC0) {
+ if ((*(UINT8 *)AnswerName & 0xC0) != 0xC0) {
Status = EFI_UNSUPPORTED;
goto ON_EXIT;
}
@@ -1397,10 +1410,10 @@ ParseDnsResponse (
//
// Get Answer section.
//
- AnswerSection = (DNS_ANSWER_SECTION *) (AnswerName + sizeof (UINT16));
- AnswerSection->Type = NTOHS (AnswerSection->Type);
- AnswerSection->Class = NTOHS (AnswerSection->Class);
- AnswerSection->Ttl = NTOHL (AnswerSection->Ttl);
+ AnswerSection = (DNS_ANSWER_SECTION *)(AnswerName + sizeof (UINT16));
+ AnswerSection->Type = NTOHS (AnswerSection->Type);
+ AnswerSection->Class = NTOHS (AnswerSection->Class);
+ AnswerSection->Ttl = NTOHL (AnswerSection->Ttl);
AnswerSection->DataLength = NTOHS (AnswerSection->DataLength);
//
@@ -1408,7 +1421,7 @@ ParseDnsResponse (
//
if (RemainingLength < AnswerSection->DataLength) {
*Completed = FALSE;
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
goto ON_EXIT;
} else {
RemainingLength -= AnswerSection->DataLength;
@@ -1417,9 +1430,9 @@ ParseDnsResponse (
//
// Check whether it's the GeneralLookUp querying.
//
- if (Instance->Service->IpVersion == IP_VERSION_4 && Dns4TokenEntry->GeneralLookUp) {
- Dns4RR = Dns4TokenEntry->Token->RspData.GLookupData->RRList;
- AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
+ if ((Instance->Service->IpVersion == IP_VERSION_4) && Dns4TokenEntry->GeneralLookUp) {
+ Dns4RR = Dns4TokenEntry->Token->RspData.GLookupData->RRList;
+ AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
//
// Fill the ResourceRecord.
@@ -1429,23 +1442,25 @@ 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;
- Dns4RR[RRCount].TTL = AnswerSection->Ttl;
+ Dns4RR[RRCount].QType = AnswerSection->Type;
+ Dns4RR[RRCount].QClass = AnswerSection->Class;
+ Dns4RR[RRCount].TTL = AnswerSection->Ttl;
Dns4RR[RRCount].DataLength = AnswerSection->DataLength;
- Dns4RR[RRCount].RData = AllocateZeroPool (Dns4RR[RRCount].DataLength);
+ Dns4RR[RRCount].RData = AllocateZeroPool (Dns4RR[RRCount].DataLength);
if (Dns4RR[RRCount].RData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
+
CopyMem (Dns4RR[RRCount].RData, AnswerData, Dns4RR[RRCount].DataLength);
- RRCount ++;
+ RRCount++;
Status = EFI_SUCCESS;
- } else if (Instance->Service->IpVersion == IP_VERSION_6 && Dns6TokenEntry->GeneralLookUp) {
- Dns6RR = Dns6TokenEntry->Token->RspData.GLookupData->RRList;
- AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
+ } else if ((Instance->Service->IpVersion == IP_VERSION_6) && Dns6TokenEntry->GeneralLookUp) {
+ Dns6RR = Dns6TokenEntry->Token->RspData.GLookupData->RRList;
+ AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
//
// Fill the ResourceRecord.
@@ -1455,19 +1470,21 @@ 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;
- Dns6RR[RRCount].TTL = AnswerSection->Ttl;
+ Dns6RR[RRCount].QType = AnswerSection->Type;
+ Dns6RR[RRCount].QClass = AnswerSection->Class;
+ Dns6RR[RRCount].TTL = AnswerSection->Ttl;
Dns6RR[RRCount].DataLength = AnswerSection->DataLength;
- Dns6RR[RRCount].RData = AllocateZeroPool (Dns6RR[RRCount].DataLength);
+ Dns6RR[RRCount].RData = AllocateZeroPool (Dns6RR[RRCount].DataLength);
if (Dns6RR[RRCount].RData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
+
CopyMem (Dns6RR[RRCount].RData, AnswerData, Dns6RR[RRCount].DataLength);
- RRCount ++;
+ RRCount++;
Status = EFI_SUCCESS;
} else {
//
@@ -1475,143 +1492,149 @@ ParseDnsResponse (
// Check the Query type, parse the response packet.
//
switch (AnswerSection->Type) {
- case DNS_TYPE_A:
- //
- // This is address entry, get Data.
- //
- ASSERT (Dns4TokenEntry != NULL);
+ case DNS_TYPE_A:
+ //
+ // This is address entry, get Data.
+ //
+ ASSERT (Dns4TokenEntry != NULL);
- if (AnswerSection->DataLength != 4) {
- Status = EFI_ABORTED;
- goto ON_EXIT;
- }
+ if (AnswerSection->DataLength != 4) {
+ Status = EFI_ABORTED;
+ goto ON_EXIT;
+ }
- HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList;
- AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
- CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS));
+ HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList;
+ AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
+ CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS));
- //
- // Allocate new CacheEntry pool to update DNS cache dynamically.
- //
- Dns4CacheEntry = AllocateZeroPool (sizeof (EFI_DNS4_CACHE_ENTRY));
- if (Dns4CacheEntry == NULL) {
- 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));
+ //
+ // Allocate new CacheEntry pool to update DNS cache dynamically.
+ //
+ Dns4CacheEntry = AllocateZeroPool (sizeof (EFI_DNS4_CACHE_ENTRY));
+ if (Dns4CacheEntry == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
- if (CNameTtl != 0 && AnswerSection->Ttl != 0) {
- Dns4CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl);
- } else {
- Dns4CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);
- }
+ Dns4CacheEntry->HostName = AllocateZeroPool (2 * (StrLen (Dns4TokenEntry->QueryHostName) + 1));
+ if (Dns4CacheEntry->HostName == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
- UpdateDns4Cache (&mDriverData->Dns4CacheList, FALSE, TRUE, *Dns4CacheEntry);
+ 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;
+ }
- //
- // Free allocated CacheEntry pool.
- //
- FreePool (Dns4CacheEntry->HostName);
- Dns4CacheEntry->HostName = NULL;
+ CopyMem (Dns4CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv4_ADDRESS));
- FreePool (Dns4CacheEntry->IpAddress);
- Dns4CacheEntry->IpAddress = NULL;
+ if ((CNameTtl != 0) && (AnswerSection->Ttl != 0)) {
+ Dns4CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl);
+ } else {
+ Dns4CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);
+ }
- FreePool (Dns4CacheEntry);
- Dns4CacheEntry = NULL;
+ UpdateDns4Cache (&mDriverData->Dns4CacheList, FALSE, TRUE, *Dns4CacheEntry);
- IpCount ++;
- Status = EFI_SUCCESS;
- break;
- case DNS_TYPE_AAAA:
- //
- // This is address entry, get Data.
- //
- ASSERT (Dns6TokenEntry != NULL);
+ //
+ // Free allocated CacheEntry pool.
+ //
+ FreePool (Dns4CacheEntry->HostName);
+ Dns4CacheEntry->HostName = NULL;
- if (AnswerSection->DataLength != 16) {
- Status = EFI_ABORTED;
- goto ON_EXIT;
- }
+ FreePool (Dns4CacheEntry->IpAddress);
+ Dns4CacheEntry->IpAddress = NULL;
- HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList;
- AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
- CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS));
+ FreePool (Dns4CacheEntry);
+ Dns4CacheEntry = NULL;
- //
- // Allocate new CacheEntry pool to update DNS cache dynamically.
- //
- Dns6CacheEntry = AllocateZeroPool (sizeof (EFI_DNS6_CACHE_ENTRY));
- if (Dns6CacheEntry == NULL) {
- 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));
+ IpCount++;
+ Status = EFI_SUCCESS;
+ break;
+ case DNS_TYPE_AAAA:
+ //
+ // This is address entry, get Data.
+ //
+ ASSERT (Dns6TokenEntry != NULL);
- if (CNameTtl != 0 && AnswerSection->Ttl != 0) {
- Dns6CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl);
- } else {
- Dns6CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);
- }
+ if (AnswerSection->DataLength != 16) {
+ Status = EFI_ABORTED;
+ goto ON_EXIT;
+ }
- UpdateDns6Cache (&mDriverData->Dns6CacheList, FALSE, TRUE, *Dns6CacheEntry);
+ HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList;
+ AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection);
+ CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS));
- //
- // Free allocated CacheEntry pool.
- //
- FreePool (Dns6CacheEntry->HostName);
- Dns6CacheEntry->HostName = NULL;
+ //
+ // Allocate new CacheEntry pool to update DNS cache dynamically.
+ //
+ Dns6CacheEntry = AllocateZeroPool (sizeof (EFI_DNS6_CACHE_ENTRY));
+ if (Dns6CacheEntry == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
- FreePool (Dns6CacheEntry->IpAddress);
- Dns6CacheEntry->IpAddress = NULL;
+ Dns6CacheEntry->HostName = AllocateZeroPool (2 * (StrLen (Dns6TokenEntry->QueryHostName) + 1));
+ if (Dns6CacheEntry->HostName == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
- FreePool (Dns6CacheEntry);
- Dns6CacheEntry = NULL;
+ 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;
+ }
- IpCount ++;
- Status = EFI_SUCCESS;
- break;
- case DNS_TYPE_CNAME:
- //
- // According RFC 1034 - 3.6.2, if the query name is an alias, the name server will include the CNAME
- // record in the response and restart the query at the domain name specified in the data field of the
- // CNAME record. So, just record the TTL value of the CNAME, then skip to parse the next record.
- //
- CNameTtl = AnswerSection->Ttl;
- break;
- default:
- Status = EFI_UNSUPPORTED;
- goto ON_EXIT;
+ CopyMem (Dns6CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv6_ADDRESS));
+
+ if ((CNameTtl != 0) && (AnswerSection->Ttl != 0)) {
+ Dns6CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl);
+ } else {
+ Dns6CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl);
+ }
+
+ UpdateDns6Cache (&mDriverData->Dns6CacheList, FALSE, TRUE, *Dns6CacheEntry);
+
+ //
+ // Free allocated CacheEntry pool.
+ //
+ FreePool (Dns6CacheEntry->HostName);
+ Dns6CacheEntry->HostName = NULL;
+
+ FreePool (Dns6CacheEntry->IpAddress);
+ Dns6CacheEntry->IpAddress = NULL;
+
+ FreePool (Dns6CacheEntry);
+ Dns6CacheEntry = NULL;
+
+ IpCount++;
+ Status = EFI_SUCCESS;
+ break;
+ case DNS_TYPE_CNAME:
+ //
+ // According RFC 1034 - 3.6.2, if the query name is an alias, the name server will include the CNAME
+ // record in the response and restart the query at the domain name specified in the data field of the
+ // CNAME record. So, just record the TTL value of the CNAME, then skip to parse the next record.
+ //
+ CNameTtl = AnswerSection->Ttl;
+ break;
+ default:
+ Status = EFI_UNSUPPORTED;
+ goto ON_EXIT;
}
}
//
// Find next one
//
- AnswerName = (CHAR8 *) AnswerSection + sizeof (*AnswerSection) + AnswerSection->DataLength;
- AnswerSectionNum ++;
+ AnswerName = (CHAR8 *)AnswerSection + sizeof (*AnswerSection) + AnswerSection->DataLength;
+ AnswerSectionNum++;
}
if (Instance->Service->IpVersion == IP_VERSION_4) {
@@ -1646,8 +1669,8 @@ ON_COMPLETE:
//
// Parsing is complete, free the sending packet and signal Event here.
//
- if (Item != NULL && Item->Value != NULL) {
- NetbufFree ((NET_BUF *) (Item->Value));
+ if ((Item != NULL) && (Item->Value != NULL)) {
+ NetbufFree ((NET_BUF *)(Item->Value));
}
if (Instance->Service->IpVersion == IP_VERSION_4) {
@@ -1678,7 +1701,7 @@ ON_EXIT:
if (Dns4TokenEntry->Token->RspData.GLookupData != NULL) {
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList != NULL) {
while (RRCount != 0) {
- RRCount --;
+ RRCount--;
if (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) {
FreePool (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName);
}
@@ -1694,7 +1717,7 @@ ON_EXIT:
FreePool (Dns4TokenEntry->Token->RspData.GLookupData);
}
} else {
- if (QuerySection->Type == DNS_TYPE_A && Dns4TokenEntry->Token->RspData.H2AData != NULL) {
+ if ((QuerySection->Type == DNS_TYPE_A) && (Dns4TokenEntry->Token->RspData.H2AData != NULL)) {
if (Dns4TokenEntry->Token->RspData.H2AData->IpList != NULL) {
FreePool (Dns4TokenEntry->Token->RspData.H2AData->IpList);
}
@@ -1710,7 +1733,7 @@ ON_EXIT:
if (Dns6TokenEntry->Token->RspData.GLookupData != NULL) {
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList != NULL) {
while (RRCount != 0) {
- RRCount --;
+ RRCount--;
if (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) {
FreePool (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName);
}
@@ -1726,7 +1749,7 @@ ON_EXIT:
FreePool (Dns6TokenEntry->Token->RspData.GLookupData);
}
} else {
- if (QuerySection->Type == DNS_TYPE_AAAA && Dns6TokenEntry->Token->RspData.H2AData != NULL) {
+ if ((QuerySection->Type == DNS_TYPE_AAAA) && (Dns6TokenEntry->Token->RspData.H2AData != NULL)) {
if (Dns6TokenEntry->Token->RspData.H2AData->IpList != NULL) {
FreePool (Dns6TokenEntry->Token->RspData.H2AData->IpList);
}
@@ -1778,20 +1801,20 @@ ON_EXIT:
VOID
EFIAPI
DnsOnPacketReceived (
- NET_BUF *Packet,
- UDP_END_POINT *EndPoint,
- EFI_STATUS IoStatus,
- VOID *Context
+ NET_BUF *Packet,
+ UDP_END_POINT *EndPoint,
+ EFI_STATUS IoStatus,
+ VOID *Context
)
{
- DNS_INSTANCE *Instance;
+ DNS_INSTANCE *Instance;
- UINT8 *RcvString;
- UINT32 Len;
+ UINT8 *RcvString;
+ UINT32 Len;
- BOOLEAN Completed;
+ BOOLEAN Completed;
- Instance = (DNS_INSTANCE *) Context;
+ Instance = (DNS_INSTANCE *)Context;
NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE);
RcvString = NULL;
@@ -1836,29 +1859,29 @@ ON_EXIT:
VOID
EFIAPI
DnsOnPacketSent (
- NET_BUF *Packet,
- UDP_END_POINT *EndPoint,
- EFI_STATUS IoStatus,
- VOID *Context
+ NET_BUF *Packet,
+ UDP_END_POINT *EndPoint,
+ EFI_STATUS IoStatus,
+ VOID *Context
)
{
- DNS_INSTANCE *Instance;
- LIST_ENTRY *Entry;
- NET_MAP_ITEM *Item;
- DNS4_TOKEN_ENTRY *Dns4TokenEntry;
- DNS6_TOKEN_ENTRY *Dns6TokenEntry;
+ DNS_INSTANCE *Instance;
+ LIST_ENTRY *Entry;
+ NET_MAP_ITEM *Item;
+ DNS4_TOKEN_ENTRY *Dns4TokenEntry;
+ DNS6_TOKEN_ENTRY *Dns6TokenEntry;
Dns4TokenEntry = NULL;
Dns6TokenEntry = NULL;
- Instance = (DNS_INSTANCE *) Context;
+ Instance = (DNS_INSTANCE *)Context;
NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE);
if (Instance->Service->IpVersion == IP_VERSION_4) {
NET_LIST_FOR_EACH (Entry, &Instance->Dns4TxTokens.Used) {
Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
if (Packet == (NET_BUF *)(Item->Value)) {
- Dns4TokenEntry = ((DNS4_TOKEN_ENTRY *)Item->Key);
+ Dns4TokenEntry = ((DNS4_TOKEN_ENTRY *)Item->Key);
Dns4TokenEntry->PacketToLive = Dns4TokenEntry->Token->RetryInterval;
break;
}
@@ -1867,7 +1890,7 @@ DnsOnPacketSent (
NET_LIST_FOR_EACH (Entry, &Instance->Dns6TxTokens.Used) {
Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
if (Packet == (NET_BUF *)(Item->Value)) {
- Dns6TokenEntry = ((DNS6_TOKEN_ENTRY *)Item->Key);
+ Dns6TokenEntry = ((DNS6_TOKEN_ENTRY *)Item->Key);
Dns6TokenEntry->PacketToLive = Dns6TokenEntry->Token->RetryInterval;
break;
}
@@ -1889,11 +1912,11 @@ DnsOnPacketSent (
**/
EFI_STATUS
DoDnsQuery (
- IN DNS_INSTANCE *Instance,
- IN NET_BUF *Packet
+ IN DNS_INSTANCE *Instance,
+ IN NET_BUF *Packet
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Ready to receive the DNS response.
@@ -1930,16 +1953,16 @@ DoDnsQuery (
**/
EFI_STATUS
ConstructDNSQuery (
- IN DNS_INSTANCE *Instance,
- IN CHAR8 *QueryName,
- IN UINT16 Type,
- IN UINT16 Class,
- OUT NET_BUF **Packet
+ IN DNS_INSTANCE *Instance,
+ IN CHAR8 *QueryName,
+ IN UINT16 Type,
+ IN UINT16 Class,
+ OUT NET_BUF **Packet
)
{
- NET_FRAGMENT Frag;
- DNS_HEADER *DnsHeader;
- DNS_QUERY_SECTION *DnsQuery;
+ NET_FRAGMENT Frag;
+ DNS_HEADER *DnsHeader;
+ DNS_QUERY_SECTION *DnsQuery;
//
// Messages carried by UDP are restricted to 512 bytes (not counting the IP
@@ -1953,23 +1976,23 @@ ConstructDNSQuery (
//
// Fill header
//
- DnsHeader = (DNS_HEADER *) Frag.Bulk;
- DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed());
- DnsHeader->Flags.Uint16 = 0x0000;
- DnsHeader->Flags.Bits.RD = 1;
+ DnsHeader = (DNS_HEADER *)Frag.Bulk;
+ DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed ());
+ DnsHeader->Flags.Uint16 = 0x0000;
+ DnsHeader->Flags.Bits.RD = 1;
DnsHeader->Flags.Bits.OpCode = DNS_FLAGS_OPCODE_STANDARD;
- DnsHeader->Flags.Bits.QR = DNS_FLAGS_QR_QUERY;
- DnsHeader->QuestionsNum = 1;
- DnsHeader->AnswersNum = 0;
- DnsHeader->AuthorityNum = 0;
- DnsHeader->AditionalNum = 0;
+ DnsHeader->Flags.Bits.QR = DNS_FLAGS_QR_QUERY;
+ DnsHeader->QuestionsNum = 1;
+ DnsHeader->AnswersNum = 0;
+ DnsHeader->AuthorityNum = 0;
+ DnsHeader->AditionalNum = 0;
DnsHeader->Identification = HTONS (DnsHeader->Identification);
- DnsHeader->Flags.Uint16 = HTONS (DnsHeader->Flags.Uint16);
- DnsHeader->QuestionsNum = HTONS (DnsHeader->QuestionsNum);
- DnsHeader->AnswersNum = HTONS (DnsHeader->AnswersNum);
- DnsHeader->AuthorityNum = HTONS (DnsHeader->AuthorityNum);
- DnsHeader->AditionalNum = HTONS (DnsHeader->AditionalNum);
+ DnsHeader->Flags.Uint16 = HTONS (DnsHeader->Flags.Uint16);
+ DnsHeader->QuestionsNum = HTONS (DnsHeader->QuestionsNum);
+ DnsHeader->AnswersNum = HTONS (DnsHeader->AnswersNum);
+ DnsHeader->AuthorityNum = HTONS (DnsHeader->AuthorityNum);
+ DnsHeader->AditionalNum = HTONS (DnsHeader->AditionalNum);
Frag.Len = sizeof (*DnsHeader);
@@ -1977,16 +2000,16 @@ ConstructDNSQuery (
// Fill Query name
//
CopyMem (Frag.Bulk + Frag.Len, QueryName, AsciiStrLen (QueryName));
- Frag.Len = (UINT32) (Frag.Len + AsciiStrLen (QueryName));
+ Frag.Len = (UINT32)(Frag.Len + AsciiStrLen (QueryName));
*(Frag.Bulk + Frag.Len) = 0;
- Frag.Len ++;
+ Frag.Len++;
//
// Rest query section
//
- DnsQuery = (DNS_QUERY_SECTION *) (Frag.Bulk + Frag.Len);
+ DnsQuery = (DNS_QUERY_SECTION *)(Frag.Bulk + Frag.Len);
- DnsQuery->Type = HTONS (Type);
+ DnsQuery->Type = HTONS (Type);
DnsQuery->Class = HTONS (Class);
Frag.Len += sizeof (*DnsQuery);
@@ -2003,7 +2026,7 @@ ConstructDNSQuery (
//
// Store the UdpIo in ProtoData.
//
- *((UINTN *) &((*Packet)->ProtoData[0])) = (UINTN) (Instance->UdpIo);
+ *((UINTN *)&((*Packet)->ProtoData[0])) = (UINTN)(Instance->UdpIo);
return EFI_SUCCESS;
}
@@ -2020,13 +2043,13 @@ ConstructDNSQuery (
**/
EFI_STATUS
DnsRetransmit (
- IN DNS_INSTANCE *Instance,
- IN NET_BUF *Packet
+ IN DNS_INSTANCE *Instance,
+ IN NET_BUF *Packet
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- UINT8 *Buffer;
+ UINT8 *Buffer;
ASSERT (Packet != NULL);
@@ -2064,26 +2087,25 @@ DnsRetransmit (
VOID
EFIAPI
DnsOnTimerRetransmit (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- DNS_SERVICE *Service;
+ DNS_SERVICE *Service;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
- DNS_INSTANCE *Instance;
- LIST_ENTRY *EntryNetMap;
- NET_MAP_ITEM *ItemNetMap;
- DNS4_TOKEN_ENTRY *Dns4TokenEntry;
- DNS6_TOKEN_ENTRY *Dns6TokenEntry;
+ DNS_INSTANCE *Instance;
+ LIST_ENTRY *EntryNetMap;
+ NET_MAP_ITEM *ItemNetMap;
+ DNS4_TOKEN_ENTRY *Dns4TokenEntry;
+ DNS6_TOKEN_ENTRY *Dns6TokenEntry;
Dns4TokenEntry = NULL;
Dns6TokenEntry = NULL;
- Service = (DNS_SERVICE *) Context;
-
+ Service = (DNS_SERVICE *)Context;
if (Service->IpVersion == IP_VERSION_4) {
//
@@ -2095,9 +2117,9 @@ DnsOnTimerRetransmit (
EntryNetMap = Instance->Dns4TxTokens.Used.ForwardLink;
while (EntryNetMap != &Instance->Dns4TxTokens.Used) {
- ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link);
+ ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link);
Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(ItemNetMap->Key);
- if (Dns4TokenEntry->PacketToLive == 0 || (--Dns4TokenEntry->PacketToLive > 0)) {
+ if ((Dns4TokenEntry->PacketToLive == 0) || (--Dns4TokenEntry->PacketToLive > 0)) {
EntryNetMap = EntryNetMap->ForwardLink;
continue;
}
@@ -2139,9 +2161,9 @@ DnsOnTimerRetransmit (
EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink;
while (EntryNetMap != &Instance->Dns6TxTokens.Used) {
- ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link);
- Dns6TokenEntry = (DNS6_TOKEN_ENTRY *) (ItemNetMap->Key);
- if (Dns6TokenEntry->PacketToLive == 0 || (--Dns6TokenEntry->PacketToLive > 0)) {
+ ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link);
+ Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(ItemNetMap->Key);
+ if ((Dns6TokenEntry->PacketToLive == 0) || (--Dns6TokenEntry->PacketToLive > 0)) {
EntryNetMap = EntryNetMap->ForwardLink;
continue;
}
@@ -2151,7 +2173,7 @@ DnsOnTimerRetransmit (
// otherwise exit the transfer.
//
if (++Dns6TokenEntry->RetryCounting <= Dns6TokenEntry->Token->RetryCount) {
- DnsRetransmit (Instance, (NET_BUF *) ItemNetMap->Value);
+ DnsRetransmit (Instance, (NET_BUF *)ItemNetMap->Value);
EntryNetMap = EntryNetMap->ForwardLink;
} else {
//
@@ -2166,7 +2188,7 @@ DnsOnTimerRetransmit (
// Free the sending packet.
//
if (ItemNetMap->Value != NULL) {
- NetbufFree ((NET_BUF *) (ItemNetMap->Value));
+ NetbufFree ((NET_BUF *)(ItemNetMap->Value));
}
EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink;
@@ -2186,14 +2208,14 @@ DnsOnTimerRetransmit (
VOID
EFIAPI
DnsOnTimerUpdate (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- DNS4_CACHE *Item4;
- DNS6_CACHE *Item6;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ DNS4_CACHE *Item4;
+ DNS6_CACHE *Item6;
Item4 = NULL;
Item6 = NULL;
@@ -2242,4 +2264,3 @@ DnsOnTimerUpdate (
}
}
}
-
diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
index 4905bca4ad..b22cef4ff5 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
@@ -20,70 +20,70 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
UINT32
HttpBootBuildDhcp6Options (
- IN HTTP_BOOT_PRIVATE_DATA *Private,
- OUT EFI_DHCP6_PACKET_OPTION **OptList,
- IN UINT8 *Buffer
+ IN HTTP_BOOT_PRIVATE_DATA *Private,
+ OUT EFI_DHCP6_PACKET_OPTION **OptList,
+ IN UINT8 *Buffer
)
{
- HTTP_BOOT_DHCP6_OPTION_ENTRY OptEnt;
- UINT16 Value;
- UINT32 Index;
+ HTTP_BOOT_DHCP6_OPTION_ENTRY OptEnt;
+ UINT16 Value;
+ UINT32 Index;
Index = 0;
- OptList[0] = (EFI_DHCP6_PACKET_OPTION *) Buffer;
+ OptList[0] = (EFI_DHCP6_PACKET_OPTION *)Buffer;
//
// Append client option request option
//
- OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
- OptList[Index]->OpLen = HTONS (8);
- OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *) OptList[Index]->Data;
- OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL);
- OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);
- OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS);
- OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS);
+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
+ OptList[Index]->OpLen = HTONS (8);
+ OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *)OptList[Index]->Data;
+ OptEnt.Oro->OpCode[0] = HTONS (DHCP6_OPT_BOOT_FILE_URL);
+ OptEnt.Oro->OpCode[1] = HTONS (DHCP6_OPT_BOOT_FILE_PARAM);
+ OptEnt.Oro->OpCode[2] = HTONS (DHCP6_OPT_DNS_SERVERS);
+ OptEnt.Oro->OpCode[3] = HTONS (DHCP6_OPT_VENDOR_CLASS);
Index++;
- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append client network device interface option
//
- OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
- OptList[Index]->OpLen = HTONS ((UINT16)3);
- OptEnt.Undi = (HTTP_BOOT_DHCP6_OPTION_UNDI *) OptList[Index]->Data;
+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
+ OptList[Index]->OpLen = HTONS ((UINT16)3);
+ OptEnt.Undi = (HTTP_BOOT_DHCP6_OPTION_UNDI *)OptList[Index]->Data;
if (Private->Nii != NULL) {
- OptEnt.Undi->Type = Private->Nii->Type;
- OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
- OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
+ OptEnt.Undi->Type = Private->Nii->Type;
+ OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
+ OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
} else {
- OptEnt.Undi->Type = DEFAULT_UNDI_TYPE;
- OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
- OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
+ OptEnt.Undi->Type = DEFAULT_UNDI_TYPE;
+ OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
+ OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
}
Index++;
- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append client system architecture option
//
- OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
- OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH));
- OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *) OptList[Index]->Data;
- Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
+ OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH));
+ OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *)OptList[Index]->Data;
+ Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
Index++;
- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append vendor class identify option.
//
OptList[Index]->OpCode = HTONS (DHCP6_OPT_VENDOR_CLASS);
- OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS));
- OptEnt.VendorClass = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *) OptList[Index]->Data;
+ OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS));
+ OptEnt.VendorClass = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *)OptList[Index]->Data;
OptEnt.VendorClass->Vendor = HTONL (HTTP_BOOT_DHCP6_ENTERPRISE_NUM);
- OptEnt.VendorClass->ClassLen = HTONS ((UINT16) sizeof (HTTP_BOOT_CLASS_ID));
+ OptEnt.VendorClass->ClassLen = HTONS ((UINT16)sizeof (HTTP_BOOT_CLASS_ID));
CopyMem (
&OptEnt.VendorClass->ClassId,
DEFAULT_CLASS_ID_DATA,
@@ -131,33 +131,30 @@ HttpBootBuildDhcp6Options (
**/
EFI_DHCP6_PACKET_OPTION *
HttpBootParseDhcp6Options (
- IN UINT8 *Buffer,
- IN UINT32 Length,
- IN UINT16 OptTag
+ IN UINT8 *Buffer,
+ IN UINT32 Length,
+ IN UINT16 OptTag
)
{
- EFI_DHCP6_PACKET_OPTION *Option;
- UINT32 Offset;
+ EFI_DHCP6_PACKET_OPTION *Option;
+ UINT32 Offset;
- Option = (EFI_DHCP6_PACKET_OPTION *) Buffer;
- Offset = 0;
+ Option = (EFI_DHCP6_PACKET_OPTION *)Buffer;
+ Offset = 0;
//
// OpLen and OpCode here are both stored in network order.
//
while (Offset < Length) {
-
if (NTOHS (Option->OpCode) == OptTag) {
-
return Option;
}
- Offset += (NTOHS(Option->OpLen) + 4);
- Option = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset);
+ Offset += (NTOHS (Option->OpLen) + 4);
+ Option = (EFI_DHCP6_PACKET_OPTION *)(Buffer + Offset);
}
return NULL;
-
}
/**
@@ -171,40 +168,39 @@ HttpBootParseDhcp6Options (
**/
EFI_STATUS
HttpBootParseDhcp6Packet (
- IN HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6
+ IN HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6
)
{
- EFI_DHCP6_PACKET *Offer;
- EFI_DHCP6_PACKET_OPTION **Options;
- EFI_DHCP6_PACKET_OPTION *Option;
- HTTP_BOOT_OFFER_TYPE OfferType;
- EFI_IPv6_ADDRESS IpAddr;
- BOOLEAN IsProxyOffer;
- BOOLEAN IsHttpOffer;
- BOOLEAN IsDnsOffer;
- BOOLEAN IpExpressedUri;
- EFI_STATUS Status;
- UINT32 Offset;
- UINT32 Length;
+ EFI_DHCP6_PACKET *Offer;
+ EFI_DHCP6_PACKET_OPTION **Options;
+ EFI_DHCP6_PACKET_OPTION *Option;
+ HTTP_BOOT_OFFER_TYPE OfferType;
+ EFI_IPv6_ADDRESS IpAddr;
+ BOOLEAN IsProxyOffer;
+ BOOLEAN IsHttpOffer;
+ BOOLEAN IsDnsOffer;
+ BOOLEAN IpExpressedUri;
+ EFI_STATUS Status;
+ UINT32 Offset;
+ UINT32 Length;
IsDnsOffer = FALSE;
IpExpressedUri = FALSE;
IsProxyOffer = TRUE;
IsHttpOffer = FALSE;
- Offer = &Cache6->Packet.Offer;
- Options = Cache6->OptList;
+ Offer = &Cache6->Packet.Offer;
+ Options = Cache6->OptList;
ZeroMem (Cache6->OptList, sizeof (Cache6->OptList));
- Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option);
- Offset = 0;
- Length = GET_DHCP6_OPTION_SIZE (Offer);
+ Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option);
+ Offset = 0;
+ Length = GET_DHCP6_OPTION_SIZE (Offer);
//
// OpLen and OpCode here are both stored in network order, since they are from original packet.
//
while (Offset < Length) {
-
if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) {
Options[HTTP_BOOT_DHCP6_IDX_IA_NA] = Option;
} else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) {
@@ -221,8 +217,9 @@ HttpBootParseDhcp6Packet (
}
Offset += (NTOHS (Option->OpLen) + 4);
- Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option + Offset);
+ Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option + Offset);
}
+
//
// The offer with assigned client address is NOT a proxy offer.
// An ia_na option, embedded with valid ia_addr option and a status_code of success.
@@ -234,7 +231,7 @@ HttpBootParseDhcp6Packet (
NTOHS (Option->OpLen),
DHCP6_OPT_STATUS_CODE
);
- if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) {
+ if (((Option != NULL) && (Option->Data[0] == 0)) || (Option == NULL)) {
IsProxyOffer = FALSE;
}
}
@@ -244,10 +241,11 @@ 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) {
- IsHttpOffer = TRUE;
+ if ((Option != NULL) &&
+ (NTOHS (Option->OpLen) >= 16) &&
+ (CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0))
+ {
+ IsHttpOffer = TRUE;
}
//
@@ -261,7 +259,7 @@ HttpBootParseDhcp6Packet (
//
// Http offer must have a boot URI.
//
- if (IsHttpOffer && Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL) {
+ if (IsHttpOffer && (Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL)) {
return EFI_DEVICE_ERROR;
}
@@ -270,8 +268,8 @@ HttpBootParseDhcp6Packet (
//
if (IsHttpOffer) {
Status = HttpParseUrl (
- (CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
- (UINT32) AsciiStrLen ((CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data),
+ (CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
+ (UINT32)AsciiStrLen ((CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data),
FALSE,
&Cache6->UriParser
);
@@ -280,7 +278,7 @@ HttpBootParseDhcp6Packet (
}
Status = HttpUrlGetIp6 (
- (CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
+ (CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
Cache6->UriParser,
&IpAddr
);
@@ -304,7 +302,6 @@ HttpBootParseDhcp6Packet (
OfferType = HttpOfferTypeProxyNameUri;
}
}
-
} else {
if (!IsProxyOffer) {
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
@@ -329,8 +326,8 @@ HttpBootParseDhcp6Packet (
**/
EFI_STATUS
HttpBootCacheDhcp6Packet (
- IN EFI_DHCP6_PACKET *Dst,
- IN EFI_DHCP6_PACKET *Src
+ IN EFI_DHCP6_PACKET *Dst,
+ IN EFI_DHCP6_PACKET *Src
)
{
if (Dst->Size < Src->Length) {
@@ -359,10 +356,10 @@ HttpBootCacheDhcp6Offer (
IN EFI_DHCP6_PACKET *RcvdOffer
)
{
- HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6;
- EFI_DHCP6_PACKET *Offer;
- HTTP_BOOT_OFFER_TYPE OfferType;
- EFI_STATUS Status;
+ HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6;
+ EFI_DHCP6_PACKET *Offer;
+ HTTP_BOOT_OFFER_TYPE OfferType;
+ EFI_STATUS Status;
Cache6 = &Private->OfferBuffer[Private->OfferNum].Dhcp6;
Offer = &Cache6->Packet.Offer;
@@ -370,7 +367,7 @@ HttpBootCacheDhcp6Offer (
//
// Cache the content of DHCPv6 packet firstly.
//
- Status = HttpBootCacheDhcp6Packet(Offer, RcvdOffer);
+ Status = HttpBootCacheDhcp6Packet (Offer, RcvdOffer);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -417,86 +414,91 @@ HttpBootCacheDhcp6Offer (
EFI_STATUS
EFIAPI
HttpBootDhcp6CallBack (
- IN EFI_DHCP6_PROTOCOL *This,
- IN VOID *Context,
- IN EFI_DHCP6_STATE CurrentState,
- IN EFI_DHCP6_EVENT Dhcp6Event,
- IN EFI_DHCP6_PACKET *Packet,
- OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL
+ IN EFI_DHCP6_PROTOCOL *This,
+ IN VOID *Context,
+ IN EFI_DHCP6_STATE CurrentState,
+ IN EFI_DHCP6_EVENT Dhcp6Event,
+ IN EFI_DHCP6_PACKET *Packet,
+ OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL
)
{
- HTTP_BOOT_PRIVATE_DATA *Private;
- EFI_DHCP6_PACKET *SelectAd;
- EFI_STATUS Status;
- BOOLEAN Received;
+ HTTP_BOOT_PRIVATE_DATA *Private;
+ EFI_DHCP6_PACKET *SelectAd;
+ EFI_STATUS Status;
+ BOOLEAN Received;
if ((Dhcp6Event != Dhcp6SendSolicit) &&
- (Dhcp6Event != Dhcp6RcvdAdvertise) &&
- (Dhcp6Event != Dhcp6SendRequest) &&
- (Dhcp6Event != Dhcp6RcvdReply) &&
- (Dhcp6Event != Dhcp6SelectAdvertise)) {
+ (Dhcp6Event != Dhcp6RcvdAdvertise) &&
+ (Dhcp6Event != Dhcp6SendRequest) &&
+ (Dhcp6Event != Dhcp6RcvdReply) &&
+ (Dhcp6Event != Dhcp6SelectAdvertise))
+ {
return EFI_SUCCESS;
}
ASSERT (Packet != NULL);
- Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
- Status = EFI_SUCCESS;
- if (Private->HttpBootCallback != NULL && Dhcp6Event != Dhcp6SelectAdvertise) {
- Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
- Status = Private->HttpBootCallback->Callback (
- Private->HttpBootCallback,
- HttpBootDhcp6,
- Received,
- Packet->Length,
- &Packet->Dhcp6
- );
+ Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
+ Status = EFI_SUCCESS;
+ if ((Private->HttpBootCallback != NULL) && (Dhcp6Event != Dhcp6SelectAdvertise)) {
+ Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
+ Status = Private->HttpBootCallback->Callback (
+ Private->HttpBootCallback,
+ HttpBootDhcp6,
+ Received,
+ Packet->Length,
+ &Packet->Dhcp6
+ );
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
}
+
switch (Dhcp6Event) {
+ case Dhcp6RcvdAdvertise:
+ Status = EFI_NOT_READY;
+ if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) {
+ //
+ // Ignore the incoming packets which exceed the maximum length.
+ //
+ break;
+ }
+
+ if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
+ //
+ // Cache the dhcp offers to OfferBuffer[] for select later, and record
+ // the OfferIndex and OfferCount.
+ // If error happens, just ignore this packet and continue to wait more offer.
+ //
+ HttpBootCacheDhcp6Offer (Private, Packet);
+ }
- case Dhcp6RcvdAdvertise:
- Status = EFI_NOT_READY;
- if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) {
- //
- // Ignore the incoming packets which exceed the maximum length.
- //
break;
- }
- if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
+
+ case Dhcp6SelectAdvertise:
//
- // Cache the dhcp offers to OfferBuffer[] for select later, and record
- // the OfferIndex and OfferCount.
- // If error happens, just ignore this packet and continue to wait more offer.
+ // Select offer by the default policy or by order, and record the SelectIndex
+ // and SelectProxyType.
//
- HttpBootCacheDhcp6Offer (Private, Packet);
- }
- break;
-
- case Dhcp6SelectAdvertise:
- //
- // Select offer by the default policy or by order, and record the SelectIndex
- // and SelectProxyType.
- //
- HttpBootSelectDhcpOffer (Private);
+ HttpBootSelectDhcpOffer (Private);
- if (Private->SelectIndex == 0) {
- Status = EFI_ABORTED;
- } else {
- ASSERT (NewPacket != NULL);
- SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
- *NewPacket = AllocateZeroPool (SelectAd->Size);
- if (*NewPacket == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ if (Private->SelectIndex == 0) {
+ Status = EFI_ABORTED;
+ } else {
+ ASSERT (NewPacket != NULL);
+ SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
+ *NewPacket = AllocateZeroPool (SelectAd->Size);
+ if (*NewPacket == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (*NewPacket, SelectAd, SelectAd->Size);
}
- CopyMem (*NewPacket, SelectAd, SelectAd->Size);
- }
- break;
- default:
- break;
+ break;
+
+ default:
+ break;
}
return Status;
@@ -519,18 +521,18 @@ HttpBootDhcp6CallBack (
**/
EFI_STATUS
HttpBootCheckRouteTable (
- IN HTTP_BOOT_PRIVATE_DATA *Private,
- IN UINTN TimeOutInSecond,
- OUT EFI_IPv6_ADDRESS *GatewayAddr
+ IN HTTP_BOOT_PRIVATE_DATA *Private,
+ IN UINTN TimeOutInSecond,
+ OUT EFI_IPv6_ADDRESS *GatewayAddr
)
{
- EFI_STATUS Status;
- EFI_IP6_PROTOCOL *Ip6;
- EFI_IP6_MODE_DATA Ip6ModeData;
- UINTN Index;
- EFI_EVENT TimeOutEvt;
- UINTN RetryCount;
- BOOLEAN GatewayIsFound;
+ EFI_STATUS Status;
+ EFI_IP6_PROTOCOL *Ip6;
+ EFI_IP6_MODE_DATA Ip6ModeData;
+ UINTN Index;
+ EFI_EVENT TimeOutEvt;
+ UINTN RetryCount;
+ BOOLEAN GatewayIsFound;
ASSERT (GatewayAddr != NULL);
ASSERT (Private != NULL);
@@ -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);
}
@@ -634,16 +642,16 @@ ON_EXIT:
**/
EFI_STATUS
HttpBootSetIp6Policy (
- IN HTTP_BOOT_PRIVATE_DATA *Private
+ IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
- EFI_IP6_CONFIG_POLICY Policy;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
- EFI_STATUS Status;
- UINTN DataSize;
+ EFI_IP6_CONFIG_POLICY Policy;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
+ EFI_STATUS Status;
+ UINTN DataSize;
- Ip6Config = Private->Ip6Config;
- DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
+ Ip6Config = Private->Ip6Config;
+ DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
//
// Get and store the current policy of IP6 driver.
@@ -663,13 +671,14 @@ HttpBootSetIp6Policy (
Status = Ip6Config->SetData (
Ip6Config,
Ip6ConfigDataTypePolicy,
- sizeof(EFI_IP6_CONFIG_POLICY),
+ sizeof (EFI_IP6_CONFIG_POLICY),
&Policy
);
if (EFI_ERROR (Status)) {
return Status;
}
}
+
return EFI_SUCCESS;
}
@@ -687,12 +696,12 @@ HttpBootSetIp6Policy (
**/
EFI_STATUS
HttpBootSetIp6Dns (
- IN HTTP_BOOT_PRIVATE_DATA *Private,
- IN UINTN DataLength,
- IN VOID *DnsServerData
+ IN HTTP_BOOT_PRIVATE_DATA *Private,
+ IN UINTN DataLength,
+ IN VOID *DnsServerData
)
{
- EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
ASSERT (Private->UsingIpv6);
@@ -717,11 +726,11 @@ HttpBootSetIp6Dns (
**/
EFI_STATUS
HttpBootSetIp6Gateway (
- IN HTTP_BOOT_PRIVATE_DATA *Private
+ IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
- EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
- EFI_STATUS Status;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
+ EFI_STATUS Status;
ASSERT (Private->UsingIpv6);
Ip6Config = Private->Ip6Config;
@@ -736,7 +745,7 @@ HttpBootSetIp6Gateway (
sizeof (EFI_IPv6_ADDRESS),
&Private->GatewayIp.v6
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
}
@@ -755,21 +764,21 @@ HttpBootSetIp6Gateway (
**/
EFI_STATUS
HttpBootSetIp6Address (
- IN HTTP_BOOT_PRIVATE_DATA *Private
-)
+ IN HTTP_BOOT_PRIVATE_DATA *Private
+ )
{
- EFI_STATUS Status;
- EFI_IP6_PROTOCOL *Ip6;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
- EFI_IP6_CONFIG_POLICY Policy;
- EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr;
- EFI_IPv6_ADDRESS *Ip6Addr;
- EFI_IPv6_ADDRESS GatewayAddr;
- EFI_IP6_CONFIG_DATA Ip6CfgData;
- EFI_EVENT MappedEvt;
- UINTN DataSize;
- BOOLEAN IsAddressOk;
- UINTN Index;
+ EFI_STATUS Status;
+ EFI_IP6_PROTOCOL *Ip6;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
+ EFI_IP6_CONFIG_POLICY Policy;
+ EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr;
+ EFI_IPv6_ADDRESS *Ip6Addr;
+ EFI_IPv6_ADDRESS GatewayAddr;
+ EFI_IP6_CONFIG_DATA Ip6CfgData;
+ EFI_EVENT MappedEvt;
+ UINTN DataSize;
+ BOOLEAN IsAddressOk;
+ UINTN Index;
ASSERT (Private->UsingIpv6);
@@ -783,11 +792,11 @@ HttpBootSetIp6Address (
CopyMem (&CfgAddr, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS));
ZeroMem (&Ip6CfgData, sizeof (EFI_IP6_CONFIG_DATA));
- Ip6CfgData.AcceptIcmpErrors = TRUE;
- Ip6CfgData.DefaultProtocol = IP6_ICMP;
- Ip6CfgData.HopLimit = HTTP_BOOT_DEFAULT_HOPLIMIT;
- Ip6CfgData.ReceiveTimeout = HTTP_BOOT_DEFAULT_LIFETIME;
- Ip6CfgData.TransmitTimeout = HTTP_BOOT_DEFAULT_LIFETIME;
+ Ip6CfgData.AcceptIcmpErrors = TRUE;
+ Ip6CfgData.DefaultProtocol = IP6_ICMP;
+ Ip6CfgData.HopLimit = HTTP_BOOT_DEFAULT_HOPLIMIT;
+ Ip6CfgData.ReceiveTimeout = HTTP_BOOT_DEFAULT_LIFETIME;
+ Ip6CfgData.TransmitTimeout = HTTP_BOOT_DEFAULT_LIFETIME;
Status = Ip6->Configure (Ip6, &Ip6CfgData);
if (EFI_ERROR (Status)) {
@@ -811,7 +820,7 @@ HttpBootSetIp6Address (
Status = Ip6Cfg->SetData (
Ip6Cfg,
Ip6ConfigDataTypePolicy,
- sizeof(EFI_IP6_CONFIG_POLICY),
+ sizeof (EFI_IP6_CONFIG_POLICY),
&Policy
);
if (EFI_ERROR (Status)) {
@@ -840,7 +849,7 @@ HttpBootSetIp6Address (
Ip6ConfigDataTypeManualAddress,
MappedEvt
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -850,7 +859,7 @@ HttpBootSetIp6Address (
sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS),
&CfgAddr
);
- if (EFI_ERROR (Status) && Status != EFI_NOT_READY) {
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
goto ON_EXIT;
} else if (Status == EFI_NOT_READY) {
//
@@ -859,17 +868,18 @@ HttpBootSetIp6Address (
while (!IsAddressOk) {
Ip6->Poll (Ip6);
}
+
//
// Check whether the Ip6 Address setting is successed.
//
DataSize = 0;
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeManualAddress,
- &DataSize,
- NULL
- );
- if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) {
+ Status = Ip6Cfg->GetData (
+ Ip6Cfg,
+ Ip6ConfigDataTypeManualAddress,
+ &DataSize,
+ NULL
+ );
+ if ((Status != EFI_BUFFER_TOO_SMALL) || (DataSize == 0)) {
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
@@ -878,22 +888,24 @@ HttpBootSetIp6Address (
if (Ip6Addr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
Status = Ip6Cfg->GetData (
Ip6Cfg,
Ip6ConfigDataTypeManualAddress,
&DataSize,
- (VOID *) Ip6Addr
+ (VOID *)Ip6Addr
);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
- for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index ++) {
+ for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index++) {
if (CompareMem (Ip6Addr + Index, &CfgAddr, sizeof (EFI_IPv6_ADDRESS)) == 0) {
break;
}
}
+
if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) {
Status = EFI_ABORTED;
goto ON_EXIT;
@@ -928,17 +940,17 @@ ON_EXIT:
**/
EFI_STATUS
HttpBootDhcp6Sarr (
- IN HTTP_BOOT_PRIVATE_DATA *Private
+ IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
- EFI_DHCP6_PROTOCOL *Dhcp6;
- EFI_DHCP6_CONFIG_DATA Config;
- EFI_DHCP6_MODE_DATA Mode;
- EFI_DHCP6_RETRANSMISSION *Retransmit;
- EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_OPTION_MAX_NUM];
- UINT32 OptCount;
- UINT8 Buffer[HTTP_BOOT_DHCP6_OPTION_MAX_SIZE];
- EFI_STATUS Status;
+ EFI_DHCP6_PROTOCOL *Dhcp6;
+ EFI_DHCP6_CONFIG_DATA Config;
+ EFI_DHCP6_MODE_DATA Mode;
+ EFI_DHCP6_RETRANSMISSION *Retransmit;
+ EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_OPTION_MAX_NUM];
+ UINT32 OptCount;
+ UINT8 Buffer[HTTP_BOOT_DHCP6_OPTION_MAX_SIZE];
+ EFI_STATUS Status;
Dhcp6 = Private->Dhcp6;
ASSERT (Dhcp6 != NULL);
@@ -947,7 +959,7 @@ HttpBootDhcp6Sarr (
// Build options list for the request packet.
//
OptCount = HttpBootBuildDhcp6Options (Private, OptList, Buffer);
- ASSERT (OptCount >0);
+ ASSERT (OptCount > 0);
Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
if (Retransmit == NULL) {
@@ -980,11 +992,12 @@ HttpBootDhcp6Sarr (
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
+
//
// Initialize the record fields for DHCPv6 offer in private data.
//
- Private->OfferNum = 0;
- Private->SelectIndex = 0;
+ Private->OfferNum = 0;
+ Private->SelectIndex = 0;
ZeroMem (Private->OfferCount, sizeof (Private->OfferCount));
ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex));
@@ -1021,12 +1034,11 @@ ON_EXIT:
if (Mode.ClientId != NULL) {
FreePool (Mode.ClientId);
}
+
if (Mode.Ia != NULL) {
FreePool (Mode.Ia);
}
}
return Status;
-
}
-
diff --git a/NetworkPkg/IScsiDxe/IScsiCHAP.c b/NetworkPkg/IScsiDxe/IScsiCHAP.c
index 0491ef42db..b507f11cd4 100644
--- a/NetworkPkg/IScsiDxe/IScsiCHAP.c
+++ b/NetworkPkg/IScsiDxe/IScsiCHAP.c
@@ -14,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// macros. CHAP_HASH structures at lower subscripts in the array are preferred
// by the initiator.
//
-STATIC CONST CHAP_HASH mChapHash[] = {
+STATIC CONST CHAP_HASH mChapHash[] = {
{
ISCSI_CHAP_ALGORITHM_SHA256,
SHA256_DIGEST_SIZE,
@@ -23,7 +23,7 @@ STATIC CONST CHAP_HASH mChapHash[] = {
Sha256Update,
Sha256Final
},
-#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
+ #ifdef ENABLE_MD5_DEPRECATED_INTERFACES
//
// Keep the deprecated MD5 entry at the end of the array (making MD5 the
// least preferred choice of the initiator).
@@ -36,7 +36,7 @@ STATIC CONST CHAP_HASH mChapHash[] = {
Md5Update,
Md5Final
},
-#endif // ENABLE_MD5_DEPRECATED_INTERFACES
+ #endif // ENABLE_MD5_DEPRECATED_INTERFACES
};
//
@@ -44,17 +44,17 @@ STATIC CONST CHAP_HASH mChapHash[] = {
// CHAP_A=<A1,A2...> value string, by the IScsiCHAPInitHashList() function. It
// is sent by the initiator in ISCSI_CHAP_STEP_ONE.
//
-STATIC CHAR8 mChapHashListString[
- 3 + // UINT8 identifier in
- // decimal
- (1 + 3) * (ARRAY_SIZE (mChapHash) - 1) + // comma prepended for
- // entries after the
- // first
- 1 + // extra character for
- // AsciiSPrint()
- // truncation check
- 1 // terminating NUL
- ];
+STATIC CHAR8 mChapHashListString[
+ 3 + // UINT8 identifier in
+ // decimal
+ (1 + 3) * (ARRAY_SIZE (mChapHash) - 1) + // comma prepended for
+ // entries after the
+ // first
+ 1 + // extra character for
+ // AsciiSPrint()
+ // truncation check
+ 1 // terminating NUL
+];
/**
Initiator calculates its own expected hash value.
@@ -82,13 +82,13 @@ STATIC CHAR8 mChapHashListString[
**/
EFI_STATUS
IScsiCHAPCalculateResponse (
- IN UINT32 ChapIdentifier,
- IN CHAR8 *ChapSecret,
- IN UINT32 SecretLength,
- IN UINT8 *ChapChallenge,
- IN UINT32 ChallengeLength,
- IN CONST CHAP_HASH *Hash,
- OUT UINT8 *ChapResponse
+ IN UINT32 ChapIdentifier,
+ IN CHAR8 *ChapSecret,
+ IN UINT32 SecretLength,
+ IN UINT8 *ChapChallenge,
+ IN UINT32 ChallengeLength,
+ IN CONST CHAP_HASH *Hash,
+ OUT UINT8 *ChapResponse
)
{
UINTN ContextSize;
@@ -103,7 +103,7 @@ IScsiCHAPCalculateResponse (
ASSERT (Hash != NULL);
ContextSize = Hash->GetContextSize ();
- Ctx = AllocatePool (ContextSize);
+ Ctx = AllocatePool (ContextSize);
if (Ctx == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -117,7 +117,7 @@ IScsiCHAPCalculateResponse (
//
// Hash Identifier - Only calculate 1 byte data (RFC1994)
//
- IdByte[0] = (CHAR8) ChapIdentifier;
+ IdByte[0] = (CHAR8)ChapIdentifier;
if (!Hash->Update (Ctx, IdByte, 1)) {
goto Exit;
}
@@ -170,9 +170,9 @@ IScsiCHAPAuthTarget (
UINT8 VerifyRsp[ISCSI_CHAP_MAX_DIGEST_SIZE];
INTN Mismatch;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
- SecretSize = (UINT32) AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
+ SecretSize = (UINT32)AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
ASSERT (AuthData->Hash != NULL);
@@ -198,7 +198,6 @@ IScsiCHAPAuthTarget (
return Status;
}
-
/**
This function checks the received iSCSI Login Response during the security
negotiation stage.
@@ -216,33 +215,34 @@ IScsiCHAPOnRspReceived (
IN ISCSI_CONNECTION *Conn
)
{
- EFI_STATUS Status;
- ISCSI_SESSION *Session;
- ISCSI_CHAP_AUTH_DATA *AuthData;
- CHAR8 *Value;
- UINT8 *Data;
- UINT32 Len;
- LIST_ENTRY *KeyValueList;
- UINTN Algorithm;
- CHAR8 *Identifier;
- CHAR8 *Challenge;
- CHAR8 *Name;
- CHAR8 *Response;
- UINT8 TargetRsp[ISCSI_CHAP_MAX_DIGEST_SIZE];
- UINT32 RspLen;
- UINTN Result;
- UINTN HashIndex;
+ EFI_STATUS Status;
+ ISCSI_SESSION *Session;
+ ISCSI_CHAP_AUTH_DATA *AuthData;
+ CHAR8 *Value;
+ UINT8 *Data;
+ UINT32 Len;
+ LIST_ENTRY *KeyValueList;
+ UINTN Algorithm;
+ CHAR8 *Identifier;
+ CHAR8 *Challenge;
+ CHAR8 *Name;
+ CHAR8 *Response;
+ UINT8 TargetRsp[ISCSI_CHAP_MAX_DIGEST_SIZE];
+ UINT32 RspLen;
+ UINTN Result;
+ UINTN HashIndex;
ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
ASSERT (Conn->RspQue.BufNum != 0);
- Session = Conn->Session;
- AuthData = &Session->AuthData.CHAP;
- Len = Conn->RspQue.BufSize;
- Data = AllocateZeroPool (Len);
+ Session = Conn->Session;
+ AuthData = &Session->AuthData.CHAP;
+ Len = Conn->RspQue.BufSize;
+ Data = AllocateZeroPool (Len);
if (Data == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Copy the data in case the data spans over multiple PDUs.
//
@@ -251,7 +251,7 @@ IScsiCHAPOnRspReceived (
//
// Build the key-value list from the data segment of the Login Response.
//
- KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len);
+ KeyValueList = IScsiBuildKeyValueList ((CHAR8 *)Data, Len);
if (KeyValueList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
@@ -260,179 +260,184 @@ IScsiCHAPOnRspReceived (
Status = EFI_PROTOCOL_ERROR;
switch (Conn->AuthStep) {
- case ISCSI_AUTH_INITIAL:
- //
- // The first Login Response.
- //
- Value = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_TARGET_PORTAL_GROUP_TAG
- );
- if (Value == NULL) {
- goto ON_EXIT;
- }
-
- Result = IScsiNetNtoi (Value);
- if (Result > 0xFFFF) {
- goto ON_EXIT;
- }
-
- Session->TargetPortalGroupTag = (UINT16) Result;
-
- Value = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_AUTH_METHOD
- );
- 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
- // auth method.
- //
- if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
- if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) != 0) {
+ case ISCSI_AUTH_INITIAL:
+ //
+ // The first Login Response.
+ //
+ Value = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_TARGET_PORTAL_GROUP_TAG
+ );
+ if (Value == NULL) {
goto ON_EXIT;
}
- } else if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
- if (AsciiStrCmp (Value, ISCSI_AUTH_METHOD_CHAP) != 0) {
+
+ Result = IScsiNetNtoi (Value);
+ if (Result > 0xFFFF) {
goto ON_EXIT;
}
- } else {
- goto ON_EXIT;
- }
- //
- // Transit to CHAP step one.
- //
- Conn->AuthStep = ISCSI_CHAP_STEP_ONE;
- Status = EFI_SUCCESS;
- break;
+ Session->TargetPortalGroupTag = (UINT16)Result;
- case ISCSI_CHAP_STEP_TWO:
- //
- // The Target replies with CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
- //
- Value = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_CHAP_ALGORITHM
- );
- if (Value == NULL) {
- goto ON_EXIT;
- }
-
- Algorithm = IScsiNetNtoi (Value);
- for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) {
- if (Algorithm == mChapHash[HashIndex].Algorithm) {
- break;
+ Value = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_AUTH_METHOD
+ );
+ if (Value == NULL) {
+ goto ON_EXIT;
}
- }
- if (HashIndex == ARRAY_SIZE (mChapHash)) {
+
//
- // Unsupported algorithm is chosen by target.
+ // Initiator mandates CHAP authentication but target replies without
+ // "CHAP", or initiator suggets "None" but target replies with some kind of
+ // auth method.
//
- goto ON_EXIT;
- }
- //
- // Remember the target's chosen hash algorithm.
- //
- ASSERT (AuthData->Hash == NULL);
- AuthData->Hash = &mChapHash[HashIndex];
+ if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
+ if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) != 0) {
+ goto ON_EXIT;
+ }
+ } else if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
+ if (AsciiStrCmp (Value, ISCSI_AUTH_METHOD_CHAP) != 0) {
+ goto ON_EXIT;
+ }
+ } else {
+ goto ON_EXIT;
+ }
- Identifier = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_CHAP_IDENTIFIER
- );
- if (Identifier == NULL) {
- goto ON_EXIT;
- }
-
- Challenge = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_CHAP_CHALLENGE
- );
- if (Challenge == NULL) {
- goto ON_EXIT;
- }
- //
- // Process the CHAP identifier and CHAP Challenge from Target.
- // Calculate Response value.
- //
- Result = IScsiNetNtoi (Identifier);
- if (Result > 0xFF) {
- goto ON_EXIT;
- }
-
- AuthData->InIdentifier = (UINT32) Result;
- AuthData->InChallengeLength = (UINT32) sizeof (AuthData->InChallenge);
- Status = IScsiHexToBin (
- (UINT8 *) AuthData->InChallenge,
- &AuthData->InChallengeLength,
- Challenge
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_PROTOCOL_ERROR;
- goto ON_EXIT;
- }
- Status = IScsiCHAPCalculateResponse (
- AuthData->InIdentifier,
- AuthData->AuthConfig->CHAPSecret,
- (UINT32) AsciiStrLen (AuthData->AuthConfig->CHAPSecret),
- AuthData->InChallenge,
- AuthData->InChallengeLength,
- AuthData->Hash,
- AuthData->CHAPResponse
- );
+ //
+ // Transit to CHAP step one.
+ //
+ Conn->AuthStep = ISCSI_CHAP_STEP_ONE;
+ Status = EFI_SUCCESS;
+ break;
- //
- // Transit to next step.
- //
- Conn->AuthStep = ISCSI_CHAP_STEP_THREE;
- break;
+ case ISCSI_CHAP_STEP_TWO:
+ //
+ // The Target replies with CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
+ //
+ Value = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_CHAP_ALGORITHM
+ );
+ if (Value == NULL) {
+ goto ON_EXIT;
+ }
- case ISCSI_CHAP_STEP_THREE:
- //
- // One way CHAP authentication and the target would like to
- // authenticate us.
- //
- Status = EFI_SUCCESS;
- break;
+ Algorithm = IScsiNetNtoi (Value);
+ for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) {
+ if (Algorithm == mChapHash[HashIndex].Algorithm) {
+ break;
+ }
+ }
- case ISCSI_CHAP_STEP_FOUR:
- ASSERT (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL);
- //
- // The forth step, CHAP_N=<N> CHAP_R=<R> is received from Target.
- //
- Name = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_NAME);
- if (Name == NULL) {
- goto ON_EXIT;
- }
-
- Response = IScsiGetValueByKeyFromList (
- KeyValueList,
- ISCSI_KEY_CHAP_RESPONSE
+ if (HashIndex == ARRAY_SIZE (mChapHash)) {
+ //
+ // Unsupported algorithm is chosen by target.
+ //
+ goto ON_EXIT;
+ }
+
+ //
+ // Remember the target's chosen hash algorithm.
+ //
+ ASSERT (AuthData->Hash == NULL);
+ AuthData->Hash = &mChapHash[HashIndex];
+
+ Identifier = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_CHAP_IDENTIFIER
+ );
+ if (Identifier == NULL) {
+ goto ON_EXIT;
+ }
+
+ Challenge = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_CHAP_CHALLENGE
+ );
+ if (Challenge == NULL) {
+ goto ON_EXIT;
+ }
+
+ //
+ // Process the CHAP identifier and CHAP Challenge from Target.
+ // Calculate Response value.
+ //
+ Result = IScsiNetNtoi (Identifier);
+ if (Result > 0xFF) {
+ goto ON_EXIT;
+ }
+
+ AuthData->InIdentifier = (UINT32)Result;
+ AuthData->InChallengeLength = (UINT32)sizeof (AuthData->InChallenge);
+ Status = IScsiHexToBin (
+ (UINT8 *)AuthData->InChallenge,
+ &AuthData->InChallengeLength,
+ Challenge
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_PROTOCOL_ERROR;
+ goto ON_EXIT;
+ }
+
+ Status = IScsiCHAPCalculateResponse (
+ AuthData->InIdentifier,
+ AuthData->AuthConfig->CHAPSecret,
+ (UINT32)AsciiStrLen (AuthData->AuthConfig->CHAPSecret),
+ AuthData->InChallenge,
+ AuthData->InChallengeLength,
+ AuthData->Hash,
+ AuthData->CHAPResponse
);
- if (Response == NULL) {
- goto ON_EXIT;
- }
-
- ASSERT (AuthData->Hash != NULL);
- RspLen = AuthData->Hash->DigestSize;
- Status = IScsiHexToBin (TargetRsp, &RspLen, Response);
- if (EFI_ERROR (Status) || RspLen != AuthData->Hash->DigestSize) {
- Status = EFI_PROTOCOL_ERROR;
- goto ON_EXIT;
- }
- //
- // Check the CHAP Name and Response replied by Target.
- //
- Status = IScsiCHAPAuthTarget (AuthData, TargetRsp);
- break;
+ //
+ // Transit to next step.
+ //
+ Conn->AuthStep = ISCSI_CHAP_STEP_THREE;
+ break;
+
+ case ISCSI_CHAP_STEP_THREE:
+ //
+ // One way CHAP authentication and the target would like to
+ // authenticate us.
+ //
+ Status = EFI_SUCCESS;
+ break;
+
+ case ISCSI_CHAP_STEP_FOUR:
+ ASSERT (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL);
+ //
+ // The forth step, CHAP_N=<N> CHAP_R=<R> is received from Target.
+ //
+ Name = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_NAME);
+ if (Name == NULL) {
+ goto ON_EXIT;
+ }
+
+ Response = IScsiGetValueByKeyFromList (
+ KeyValueList,
+ ISCSI_KEY_CHAP_RESPONSE
+ );
+ if (Response == NULL) {
+ goto ON_EXIT;
+ }
- default:
- break;
+ ASSERT (AuthData->Hash != NULL);
+ RspLen = AuthData->Hash->DigestSize;
+ Status = IScsiHexToBin (TargetRsp, &RspLen, Response);
+ if (EFI_ERROR (Status) || (RspLen != AuthData->Hash->DigestSize)) {
+ Status = EFI_PROTOCOL_ERROR;
+ goto ON_EXIT;
+ }
+
+ //
+ // Check the CHAP Name and Response replied by Target.
+ //
+ Status = IScsiCHAPAuthTarget (AuthData, TargetRsp);
+ break;
+
+ default:
+ break;
}
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.
@@ -467,140 +471,142 @@ IScsiCHAPToSendReq (
IN OUT NET_BUF *Pdu
)
{
- EFI_STATUS Status;
- ISCSI_SESSION *Session;
- ISCSI_LOGIN_REQUEST *LoginReq;
- ISCSI_CHAP_AUTH_DATA *AuthData;
- CHAR8 *Value;
- CHAR8 ValueStr[256];
- CHAR8 *Response;
- UINT32 RspLen;
- CHAR8 *Challenge;
- UINT32 ChallengeLen;
- EFI_STATUS BinToHexStatus;
+ EFI_STATUS Status;
+ ISCSI_SESSION *Session;
+ ISCSI_LOGIN_REQUEST *LoginReq;
+ ISCSI_CHAP_AUTH_DATA *AuthData;
+ CHAR8 *Value;
+ CHAR8 ValueStr[256];
+ CHAR8 *Response;
+ UINT32 RspLen;
+ CHAR8 *Challenge;
+ UINT32 ChallengeLen;
+ EFI_STATUS BinToHexStatus;
ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
- Session = Conn->Session;
- AuthData = &Session->AuthData.CHAP;
- LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0);
+ Session = Conn->Session;
+ AuthData = &Session->AuthData.CHAP;
+ LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufGetByte (Pdu, 0, 0);
if (LoginReq == NULL) {
return EFI_PROTOCOL_ERROR;
}
- Status = EFI_SUCCESS;
- RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
- Response = AllocateZeroPool (RspLen);
+ Status = EFI_SUCCESS;
+
+ RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
+ Response = AllocateZeroPool (RspLen);
if (Response == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- ChallengeLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
- Challenge = AllocateZeroPool (ChallengeLen);
+ ChallengeLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3;
+ Challenge = AllocateZeroPool (ChallengeLen);
if (Challenge == NULL) {
FreePool (Response);
return EFI_OUT_OF_RESOURCES;
}
switch (Conn->AuthStep) {
- case ISCSI_AUTH_INITIAL:
- //
- // It's the initial Login Request. Fill in the key=value pairs mandatory
- // for the initial Login Request.
- //
- IScsiAddKeyValuePair (
- Pdu,
- ISCSI_KEY_INITIATOR_NAME,
- mPrivate->InitiatorName
- );
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal");
- IScsiAddKeyValuePair (
- Pdu,
- ISCSI_KEY_TARGET_NAME,
- Session->ConfigData->SessionConfigData.TargetName
- );
-
- if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
- Value = ISCSI_KEY_VALUE_NONE;
- ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
- } else {
- Value = ISCSI_AUTH_METHOD_CHAP;
- }
-
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_AUTH_METHOD, Value);
+ case ISCSI_AUTH_INITIAL:
+ //
+ // It's the initial Login Request. Fill in the key=value pairs mandatory
+ // for the initial Login Request.
+ //
+ IScsiAddKeyValuePair (
+ Pdu,
+ ISCSI_KEY_INITIATOR_NAME,
+ mPrivate->InitiatorName
+ );
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal");
+ IScsiAddKeyValuePair (
+ Pdu,
+ ISCSI_KEY_TARGET_NAME,
+ Session->ConfigData->SessionConfigData.TargetName
+ );
- break;
+ if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
+ Value = ISCSI_KEY_VALUE_NONE;
+ ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
+ } else {
+ Value = ISCSI_AUTH_METHOD_CHAP;
+ }
- case ISCSI_CHAP_STEP_ONE:
- //
- // First step, send the Login Request with CHAP_A=<A1,A2...> key-value
- // pair.
- //
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, mChapHashListString);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_AUTH_METHOD, Value);
- Conn->AuthStep = ISCSI_CHAP_STEP_TWO;
- break;
+ break;
- case ISCSI_CHAP_STEP_THREE:
- //
- // Third step, send the Login Request with CHAP_N=<N> CHAP_R=<R> or
- // CHAP_N=<N> CHAP_R=<R> CHAP_I=<I> CHAP_C=<C> if target authentication is
- // required too.
- //
- // CHAP_N=<N>
- //
- IScsiAddKeyValuePair (
- Pdu,
- ISCSI_KEY_CHAP_NAME,
- (CHAR8 *) &AuthData->AuthConfig->CHAPName
- );
- //
- // CHAP_R=<R>
- //
- ASSERT (AuthData->Hash != NULL);
- BinToHexStatus = IScsiBinToHex (
- (UINT8 *) AuthData->CHAPResponse,
- AuthData->Hash->DigestSize,
- Response,
- &RspLen
- );
- ASSERT_EFI_ERROR (BinToHexStatus);
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
-
- if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
+ case ISCSI_CHAP_STEP_ONE:
//
- // CHAP_I=<I>
+ // First step, send the Login Request with CHAP_A=<A1,A2...> key-value
+ // pair.
//
- IScsiGenRandom ((UINT8 *) &AuthData->OutIdentifier, 1);
- AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier);
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, mChapHashListString);
+
+ Conn->AuthStep = ISCSI_CHAP_STEP_TWO;
+ break;
+
+ case ISCSI_CHAP_STEP_THREE:
//
- // CHAP_C=<C>
+ // Third step, send the Login Request with CHAP_N=<N> CHAP_R=<R> or
+ // CHAP_N=<N> CHAP_R=<R> CHAP_I=<I> CHAP_C=<C> if target authentication is
+ // required too.
//
- IScsiGenRandom (
- (UINT8 *) AuthData->OutChallenge,
- AuthData->Hash->DigestSize
+ // CHAP_N=<N>
+ //
+ IScsiAddKeyValuePair (
+ Pdu,
+ ISCSI_KEY_CHAP_NAME,
+ (CHAR8 *)&AuthData->AuthConfig->CHAPName
);
+ //
+ // CHAP_R=<R>
+ //
+ ASSERT (AuthData->Hash != NULL);
BinToHexStatus = IScsiBinToHex (
- (UINT8 *) AuthData->OutChallenge,
+ (UINT8 *)AuthData->CHAPResponse,
AuthData->Hash->DigestSize,
- Challenge,
- &ChallengeLen
+ Response,
+ &RspLen
);
ASSERT_EFI_ERROR (BinToHexStatus);
- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
+
+ if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
+ //
+ // CHAP_I=<I>
+ //
+ IScsiGenRandom ((UINT8 *)&AuthData->OutIdentifier, 1);
+ AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr);
+ //
+ // CHAP_C=<C>
+ //
+ IScsiGenRandom (
+ (UINT8 *)AuthData->OutChallenge,
+ AuthData->Hash->DigestSize
+ );
+ BinToHexStatus = IScsiBinToHex (
+ (UINT8 *)AuthData->OutChallenge,
+ AuthData->Hash->DigestSize,
+ Challenge,
+ &ChallengeLen
+ );
+ ASSERT_EFI_ERROR (BinToHexStatus);
+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
+
+ Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
+ }
- Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
- }
- //
- // Set the stage transition flag.
- //
- ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
- break;
+ //
+ // Set the stage transition flag.
+ //
+ ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
+ break;
- default:
- Status = EFI_PROTOCOL_ERROR;
- break;
+ default:
+ Status = EFI_PROTOCOL_ERROR;
+ break;
}
FreePool (Response);
@@ -621,14 +627,14 @@ IScsiCHAPInitHashList (
VOID
)
{
- CHAR8 *Position;
- UINTN Left;
- UINTN HashIndex;
- CONST CHAP_HASH *Hash;
- UINTN Printed;
+ CHAR8 *Position;
+ UINTN Left;
+ UINTN HashIndex;
+ CONST CHAP_HASH *Hash;
+ UINTN Printed;
Position = mChapHashListString;
- Left = sizeof (mChapHashListString);
+ Left = sizeof (mChapHashListString);
for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) {
Hash = &mChapHash[HashIndex];
@@ -657,7 +663,7 @@ IScsiCHAPInitHashList (
ASSERT (Printed + 1 < Left);
Position += Printed;
- Left -= Printed;
+ Left -= Printed;
//
// Sanity-check the digest size for Hash.
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index 4069547867..b3ea90158f 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -21,22 +21,21 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFa
**/
VOID
IScsiStrTrim (
- IN OUT CHAR16 *Str,
- IN CHAR16 CharC
+ IN OUT CHAR16 *Str,
+ IN CHAR16 CharC
)
{
CHAR16 *Pointer1;
CHAR16 *Pointer2;
if (*Str == 0) {
- return ;
+ return;
}
//
// Trim off the leading and trailing characters c
//
for (Pointer1 = Str; (*Pointer1 != 0) && (*Pointer1 == CharC); Pointer1++) {
- ;
}
Pointer2 = Str;
@@ -47,18 +46,18 @@ IScsiStrTrim (
}
} else {
while (*Pointer1 != 0) {
- *Pointer2 = *Pointer1;
- Pointer1++;
- Pointer2++;
+ *Pointer2 = *Pointer1;
+ Pointer1++;
+ Pointer2++;
}
+
*Pointer2 = 0;
}
-
- for (Pointer1 = Str + StrLen(Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) {
- ;
+ for (Pointer1 = Str + StrLen (Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) {
}
- if (Pointer1 != Str + StrLen(Str) - 1) {
+
+ if (Pointer1 != Str + StrLen (Str) - 1) {
*(Pointer1 + 1) = 0;
}
}
@@ -101,10 +100,9 @@ IScsiGetSubnetMaskPrefixLength (
Len++;
}
- return (UINT8) (32 - Len);
+ return (UINT8)(32 - Len);
}
-
/**
Convert the hexadecimal encoded LUN string into the 64-bit LUN.
@@ -128,15 +126,15 @@ IScsiAsciiStrToLun (
ZeroMem (Lun, 8);
ZeroMem (TemStr, 2);
- ZeroMem ((UINT8 *) Value, sizeof (Value));
+ ZeroMem ((UINT8 *)Value, sizeof (Value));
SizeStr = AsciiStrLen (Str);
IndexValue = 0;
IndexNum = 0;
- for (Index = 0; Index < SizeStr; Index ++) {
+ for (Index = 0; Index < SizeStr; Index++) {
TemStr[0] = Str[Index];
- TemValue = (UINT8) AsciiStrHexToUint64 (TemStr);
- if (TemValue == 0 && TemStr[0] != '0') {
+ TemValue = (UINT8)AsciiStrHexToUint64 (TemStr);
+ 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.
//
@@ -172,11 +171,11 @@ IScsiAsciiStrToLun (
//
// Combine UINT16 value.
//
- Value[IndexValue] = (UINT16) ((Value[IndexValue] << 4) + TemValue);
+ Value[IndexValue] = (UINT16)((Value[IndexValue] << 4) + TemValue);
}
- for (Index = 0; Index <= IndexValue; Index ++) {
- *((UINT16 *) &Lun[Index * 2]) = HTONS (Value[Index]);
+ for (Index = 0; Index <= IndexValue; Index++) {
+ *((UINT16 *)&Lun[Index * 2]) = HTONS (Value[Index]);
}
return EFI_SUCCESS;
@@ -201,26 +200,26 @@ 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 {
- TempStr[0] = (CHAR16) IScsiHexString[Lun[2 * Index] >> 4];
- TempStr[1] = (CHAR16) IScsiHexString[Lun[2 * Index] & 0x0F];
- TempStr[2] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] >> 4];
- TempStr[3] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] & 0x0F];
- TempStr[4] = L'-';
- TempStr[5] = 0;
+ TempStr[0] = (CHAR16)IScsiHexString[Lun[2 * Index] >> 4];
+ TempStr[1] = (CHAR16)IScsiHexString[Lun[2 * Index] & 0x0F];
+ TempStr[2] = (CHAR16)IScsiHexString[Lun[2 * Index + 1] >> 4];
+ TempStr[3] = (CHAR16)IScsiHexString[Lun[2 * Index + 1] & 0x0F];
+ TempStr[4] = L'-';
+ TempStr[5] = 0;
IScsiStrTrim (TempStr, L'0');
}
TempStr += StrLen (TempStr);
}
+
//
// Remove the last '-'
//
- ASSERT (StrLen(Str) >= 1);
+ ASSERT (StrLen (Str) >= 1);
Str[StrLen (Str) - 1] = 0;
for (Index = StrLen (Str) - 1; Index > 1; Index = Index - 2) {
@@ -246,26 +245,24 @@ IScsiLunToUnicodeStr (
**/
EFI_STATUS
IScsiAsciiStrToIp (
- IN CHAR8 *Str,
- IN UINT8 IpMode,
- OUT EFI_IP_ADDRESS *Ip
+ IN CHAR8 *Str,
+ IN UINT8 IpMode,
+ OUT EFI_IP_ADDRESS *Ip
)
{
- EFI_STATUS Status;
+ 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;
@@ -292,14 +289,14 @@ IScsiMacAddrToStr (
CHAR16 *String;
for (Index = 0; Index < Len; Index++) {
- Str[3 * Index] = (CHAR16) IScsiHexString[(Mac->Addr[Index] >> 4) & 0x0F];
- Str[3 * Index + 1] = (CHAR16) IScsiHexString[Mac->Addr[Index] & 0x0F];
- Str[3 * Index + 2] = L':';
+ Str[3 * Index] = (CHAR16)IScsiHexString[(Mac->Addr[Index] >> 4) & 0x0F];
+ Str[3 * Index + 1] = (CHAR16)IScsiHexString[Mac->Addr[Index] & 0x0F];
+ Str[3 * Index + 2] = L':';
}
- String = &Str[3 * Index - 1] ;
+ String = &Str[3 * Index - 1];
if (VlanId != 0) {
- String += UnicodeSPrint (String, 6 * sizeof (CHAR16), L"\\%04x", (UINTN) VlanId);
+ String += UnicodeSPrint (String, 6 * sizeof (CHAR16), L"\\%04x", (UINTN)VlanId);
}
*String = L'\0';
@@ -322,15 +319,15 @@ IScsiMacAddrToStr (
**/
EFI_STATUS
IScsiBinToHex (
- IN UINT8 *BinBuffer,
- IN UINT32 BinLength,
- IN OUT CHAR8 *HexStr,
- IN OUT UINT32 *HexLength
+ IN UINT8 *BinBuffer,
+ IN UINT32 BinLength,
+ IN OUT CHAR8 *HexStr,
+ IN OUT UINT32 *HexLength
)
{
- UINT32 HexLengthMin;
- UINT32 HexLengthProvided;
- UINT32 Index;
+ UINT32 HexLengthMin;
+ UINT32 HexLengthProvided;
+ UINT32 Index;
if ((HexStr == NULL) || (BinBuffer == NULL) || (BinLength == 0)) {
return EFI_INVALID_PARAMETER;
@@ -340,12 +337,13 @@ 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;
}
HexLengthProvided = *HexLength;
- *HexLength = HexLengthMin;
+ *HexLength = HexLengthMin;
if (HexLengthProvided < HexLengthMin) {
return EFI_BUFFER_TOO_SMALL;
}
@@ -366,7 +364,6 @@ IScsiBinToHex (
return EFI_SUCCESS;
}
-
/**
Convert the hexadecimal string into a binary encoded buffer.
@@ -385,9 +382,9 @@ IScsiBinToHex (
**/
EFI_STATUS
IScsiHexToBin (
- IN OUT UINT8 *BinBuffer,
- IN OUT UINT32 *BinLength,
- IN CHAR8 *HexStr
+ IN OUT UINT8 *BinBuffer,
+ IN OUT UINT32 *BinLength,
+ IN CHAR8 *HexStr
)
{
UINTN BinLengthMin;
@@ -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,31 +419,33 @@ IScsiHexToBin (
if (BinLengthMin > MAX_UINT32) {
return EFI_BAD_BUFFER_SIZE;
}
+
BinLengthProvided = *BinLength;
- *BinLength = (UINT32)BinLengthMin;
+ *BinLength = (UINT32)BinLengthMin;
if (BinLengthProvided < BinLengthMin) {
return EFI_BUFFER_TOO_SMALL;
}
- for (Index = 0; Index < Length; Index ++) {
+ for (Index = 0; Index < Length; Index++) {
TemStr[0] = HexStr[Index];
- Digit = (UINT8) AsciiStrHexToUint64 (TemStr);
- if (Digit == 0 && TemStr[0] != '0') {
+ Digit = (UINT8)AsciiStrHexToUint64 (TemStr);
+ if ((Digit == 0) && (TemStr[0] != '0')) {
//
// Invalid Hex Char.
//
return EFI_INVALID_PARAMETER;
}
+
if ((Index & 1) == 0) {
- BinBuffer [Index/2] = Digit;
+ BinBuffer[Index/2] = Digit;
} else {
- BinBuffer [Index/2] = (UINT8) ((BinBuffer [Index/2] << 4) + Digit);
+ 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.
@@ -486,12 +485,11 @@ IScsiGenRandom (
while (RandLength > 0) {
Random = NET_RANDOM (NetRandomInitSeed ());
- *Rand++ = (UINT8) (Random);
+ *Rand++ = (UINT8)(Random);
RandLength--;
}
}
-
/**
Check whether UNDI protocol supports IPv6.
@@ -505,22 +503,22 @@ IScsiGenRandom (
**/
EFI_STATUS
IScsiCheckIpv6Support (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE Image,
- OUT BOOLEAN *Ipv6Support
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE Image,
+ OUT BOOLEAN *Ipv6Support
)
{
- EFI_HANDLE Handle;
- EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
- EFI_STATUS Status;
- EFI_GUID *InfoTypesBuffer;
- UINTN InfoTypeBufferCount;
- UINTN TypeIndex;
- BOOLEAN Supported;
- VOID *InfoBlock;
- UINTN InfoBlockSize;
-
- EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
+ EFI_HANDLE Handle;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ EFI_STATUS Status;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypeBufferCount;
+ UINTN TypeIndex;
+ BOOLEAN Supported;
+ VOID *InfoBlock;
+ UINTN InfoBlockSize;
+
+ EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
ASSERT (Ipv6Support != NULL);
@@ -530,7 +528,7 @@ IScsiCheckIpv6Support (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
- (VOID **) &Nii,
+ (VOID **)&Nii,
Image,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -552,16 +550,16 @@ IScsiCheckIpv6Support (
Status = gBS->HandleProtocol (
Handle,
&gEfiAdapterInformationProtocolGuid,
- (VOID *) &Aip
+ (VOID *)&Aip
);
- if (EFI_ERROR (Status) || Aip == NULL) {
+ if (EFI_ERROR (Status) || (Aip == NULL)) {
return EFI_NOT_FOUND;
}
InfoTypesBuffer = NULL;
InfoTypeBufferCount = 0;
- Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
- if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
+ Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
+ if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
FreePool (InfoTypesBuffer);
return EFI_NOT_FOUND;
}
@@ -584,13 +582,13 @@ IScsiCheckIpv6Support (
//
InfoBlock = NULL;
InfoBlockSize = 0;
- Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
- if (EFI_ERROR (Status) || InfoBlock == NULL) {
+ Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
+ if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
FreePool (InfoBlock);
return EFI_NOT_FOUND;
}
- *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support;
+ *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support;
FreePool (InfoBlock);
return EFI_SUCCESS;
@@ -613,12 +611,12 @@ IScsiAddNic (
IN EFI_HANDLE Image
)
{
- EFI_STATUS Status;
- ISCSI_NIC_INFO *NicInfo;
- LIST_ENTRY *Entry;
- EFI_MAC_ADDRESS MacAddr;
- UINTN HwAddressSize;
- UINT16 VlanId;
+ EFI_STATUS Status;
+ ISCSI_NIC_INFO *NicInfo;
+ LIST_ENTRY *Entry;
+ EFI_MAC_ADDRESS MacAddr;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
//
// Get MAC address of this network device.
@@ -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;
//
@@ -672,10 +671,10 @@ IScsiAddNic (
}
CopyMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize);
- NicInfo->HwAddressSize = (UINT32) HwAddressSize;
- NicInfo->VlanId = VlanId;
- NicInfo->NicIndex = (UINT8) (mPrivate->MaxNic + 1);
- mPrivate->MaxNic = NicInfo->NicIndex;
+ NicInfo->HwAddressSize = (UINT32)HwAddressSize;
+ NicInfo->VlanId = VlanId;
+ NicInfo->NicIndex = (UINT8)(mPrivate->MaxNic + 1);
+ mPrivate->MaxNic = NicInfo->NicIndex;
//
// Set IPv6 available flag.
@@ -706,7 +705,6 @@ IScsiAddNic (
return EFI_SUCCESS;
}
-
/**
Delete the recorded NIC info from global structure. Also delete corresponding
attempts.
@@ -722,15 +720,15 @@ IScsiRemoveNic (
IN EFI_HANDLE Controller
)
{
- EFI_STATUS Status;
- ISCSI_NIC_INFO *NicInfo;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- ISCSI_NIC_INFO *ThisNic;
- EFI_MAC_ADDRESS MacAddr;
- UINTN HwAddressSize;
- UINT16 VlanId;
+ EFI_STATUS Status;
+ ISCSI_NIC_INFO *NicInfo;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ ISCSI_NIC_INFO *ThisNic;
+ EFI_MAC_ADDRESS MacAddr;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
//
// Get MAC address of this network device.
@@ -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) {
@@ -815,19 +812,19 @@ IScsiRemoveNic (
**/
EFI_STATUS
IScsiCreateAttempts (
- IN UINTN AttemptNum
-)
+ IN UINTN AttemptNum
+ )
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- ISCSI_SESSION_CONFIG_NVDATA *ConfigData;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINT8 *AttemptOrderTmp;
- UINTN TotalNumber;
- UINT8 Index;
- EFI_STATUS Status;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ ISCSI_SESSION_CONFIG_NVDATA *ConfigData;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINT8 *AttemptOrderTmp;
+ UINTN TotalNumber;
+ UINT8 Index;
+ EFI_STATUS Status;
- for (Index = 1; Index <= AttemptNum; Index ++) {
+ for (Index = 1; Index <= AttemptNum; Index++) {
//
// Get the initialized attempt order. This is used to essure creating attempts by order.
//
@@ -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;
@@ -903,9 +907,9 @@ IScsiCreateAttempts (
//
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigData->AttemptConfigIndex
+ (UINTN)AttemptConfigData->AttemptConfigIndex
);
UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, ATTEMPT_NAME_SIZE);
@@ -918,10 +922,14 @@ IScsiCreateAttempts (
);
FreePool (AttemptConfigData);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: Failed to set variable (mPrivate->PortString) with Guid (%g): "
- "%r\n",
- __FUNCTION__, &gEfiIScsiInitiatorNameProtocolGuid, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Failed to set variable (mPrivate->PortString) with Guid (%g): "
+ "%r\n",
+ __FUNCTION__,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ Status
+ ));
return Status;
}
}
@@ -941,18 +949,18 @@ IScsiCreateAttempts (
**/
EFI_STATUS
IScsiCreateKeywords (
- IN UINTN KeywordNum
-)
+ IN UINTN KeywordNum
+ )
{
- VOID *StartOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *EndLabel;
- UINTN Index;
- EFI_STRING_ID StringToken;
- CHAR16 StringId[64];
- CHAR16 KeywordId[32];
- EFI_STATUS Status;
+ VOID *StartOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ UINTN Index;
+ EFI_STRING_ID StringToken;
+ CHAR16 StringId[64];
+ CHAR16 KeywordId[32];
+ EFI_STATUS Status;
Status = IScsiCreateOpCode (
KEYWORD_ENTRY_LABEL,
@@ -965,7 +973,7 @@ IScsiCreateKeywords (
return EFI_OUT_OF_RESOURCES;
}
- for (Index = 1; Index <= KeywordNum; Index ++) {
+ for (Index = 1; Index <= KeywordNum; Index++) {
//
// Create iSCSIAttemptName Keyword.
//
@@ -980,9 +988,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_ATTEMPT_NAME_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_ATTEMPT_NAME_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_ATTEMPT_NAME_VAR_OFFSET + ATTEMPT_NAME_SIZE * (Index - 1) * sizeof (CHAR16)),
+ (UINT16)(ATTEMPT_ATTEMPT_NAME_VAR_OFFSET + ATTEMPT_NAME_SIZE * (Index - 1) * sizeof (CHAR16)),
StringToken,
StringToken,
EFI_IFR_FLAG_READ_ONLY,
@@ -1006,9 +1014,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_BOOTENABLE_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_BOOTENABLE_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_BOOTENABLE_VAR_OFFSET + (Index - 1)),
+ (UINT16)(ATTEMPT_BOOTENABLE_VAR_OFFSET + (Index - 1)),
StringToken,
StringToken,
0,
@@ -1033,9 +1041,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_ADDRESS_TYPE_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_ADDRESS_TYPE_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_ADDRESS_TYPE_VAR_OFFSET + (Index - 1)),
+ (UINT16)(ATTEMPT_ADDRESS_TYPE_VAR_OFFSET + (Index - 1)),
StringToken,
StringToken,
0,
@@ -1060,9 +1068,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CONNECT_RETRY_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CONNECT_RETRY_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CONNECT_RETRY_VAR_OFFSET + (Index - 1)),
+ (UINT16)(ATTEMPT_CONNECT_RETRY_VAR_OFFSET + (Index - 1)),
StringToken,
StringToken,
0,
@@ -1087,9 +1095,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET + 2 * (Index - 1)),
+ (UINT16)(ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET + 2 * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1114,9 +1122,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_ISID_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_ISID_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
STRING_TOKEN (STR_ISCSI_ISID_HELP),
0,
@@ -1139,19 +1147,19 @@ IScsiCreateKeywords (
UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorInfoViaDHCP:%d", Index);
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
- StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_VIA_DHCP_QUESTION_ID + (Index - 1)),
- CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET + (Index - 1)),
- StringToken,
- StringToken,
- 0,
- 0,
- 0,
- 1,
- 0,
- NULL
- );
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID)(ATTEMPT_INITIATOR_VIA_DHCP_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16)(ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ NULL
+ );
//
// Create iSCSIInitiatorIpAddress Keyword.
@@ -1167,9 +1175,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1193,9 +1201,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1219,9 +1227,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1244,19 +1252,19 @@ IScsiCreateKeywords (
UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetInfoViaDHCP:%d", Index);
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
- StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_TARGET_VIA_DHCP_QUESTION_ID + (Index - 1)),
- CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET + (Index - 1)),
- StringToken,
- StringToken,
- 0,
- 0,
- 0,
- 1,
- 0,
- NULL
- );
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_VIA_DHCP_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16)(ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ NULL
+ );
//
// Create iSCSITargetTcpPort Keyword.
@@ -1272,9 +1280,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_TARGET_TCP_PORT_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_TCP_PORT_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET + 2 * (Index - 1)),
+ (UINT16)(ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET + 2 * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1299,9 +1307,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_TARGET_NAME_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_NAME_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_TARGET_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_TARGET_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1325,9 +1333,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1351,9 +1359,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_LUN_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_LUN_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_LUN_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_LUN_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1376,19 +1384,19 @@ IScsiCreateKeywords (
UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIAuthenticationMethod:%d", Index);
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
- StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_AUTHENTICATION_METHOD_QUESTION_ID + (Index - 1)),
- CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET + (Index - 1)),
- StringToken,
- StringToken,
- 0,
- 0,
- 0,
- 1,
- 0,
- NULL
- );
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID)(ATTEMPT_AUTHENTICATION_METHOD_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16)(ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ NULL
+ );
//
// Create iSCSIChapType Keyword.
@@ -1403,19 +1411,19 @@ IScsiCreateKeywords (
UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIChapType:%d", Index);
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateNumericOpCode (
- StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHARTYPE_QUESTION_ID + (Index - 1)),
- CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CHARTYPE_VAR_OFFSET + (Index - 1)),
- StringToken,
- StringToken,
- 0,
- 0,
- 0,
- 1,
- 0,
- NULL
- );
+ StartOpCodeHandle,
+ (EFI_QUESTION_ID)(ATTEMPT_CHARTYPE_QUESTION_ID + (Index - 1)),
+ CONFIGURATION_VARSTORE_ID,
+ (UINT16)(ATTEMPT_CHARTYPE_VAR_OFFSET + (Index - 1)),
+ StringToken,
+ StringToken,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ NULL
+ );
//
// Create iSCSIChapUsername Keyword.
@@ -1431,9 +1439,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHAR_USER_NAME_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_USER_NAME_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CHAR_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_CHAR_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1457,9 +1465,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHAR_SECRET_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_SECRET_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CHAR_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_CHAR_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1483,9 +1491,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1509,9 +1517,9 @@ IScsiCreateKeywords (
HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns");
HiiCreateStringOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID + (Index - 1)),
+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID + (Index - 1)),
CONFIGURATION_VARSTORE_ID,
- (UINT16) (ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
+ (UINT16)(ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)),
StringToken,
StringToken,
0,
@@ -1544,12 +1552,12 @@ IScsiCreateKeywords (
VOID
IScsiCleanAttemptVariable (
IN VOID
-)
+ )
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINTN Index;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINTN Index;
//
// Get the initialized attempt order.
@@ -1559,14 +1567,14 @@ IScsiCleanAttemptVariable (
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return;
}
for (Index = 1; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
Index
);
@@ -1574,7 +1582,7 @@ IScsiCleanAttemptVariable (
GetVariable2 (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
+ (VOID **)&AttemptConfigData,
NULL
);
@@ -1588,6 +1596,7 @@ IScsiCleanAttemptVariable (
);
}
}
+
return;
}
@@ -1601,11 +1610,11 @@ IScsiCleanAttemptVariable (
**/
ISCSI_NIC_INFO *
IScsiGetNicInfoByIndex (
- IN UINT8 NicIndex
+ IN UINT8 NicIndex
)
{
- LIST_ENTRY *Entry;
- ISCSI_NIC_INFO *NicInfo;
+ LIST_ENTRY *Entry;
+ ISCSI_NIC_INFO *NicInfo;
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
@@ -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.
@@ -1647,7 +1655,7 @@ IScsiGetNICPciLocation (
Status = gBS->HandleProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
+ (VOID **)&DevicePath
);
if (EFI_ERROR (Status)) {
return 0;
@@ -1662,7 +1670,7 @@ IScsiGetNICPciLocation (
return 0;
}
- Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, (VOID **) &PciIo);
+ Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, (VOID **)&PciIo);
if (EFI_ERROR (Status)) {
return 0;
}
@@ -1672,10 +1680,9 @@ IScsiGetNICPciLocation (
return 0;
}
- return (UINT16) ((*Bus << 8) | (*Device << 3) | *Function);
+ 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.
@@ -1691,9 +1698,9 @@ IScsiGetNICPciLocation (
**/
VOID *
IScsiGetVariableAndSize (
- IN CHAR16 *Name,
- IN EFI_GUID *VendorGuid,
- OUT UINTN *VariableSize
+ IN CHAR16 *Name,
+ IN EFI_GUID *VendorGuid,
+ OUT UINTN *VariableSize
)
{
EFI_STATUS Status;
@@ -1705,8 +1712,8 @@ IScsiGetVariableAndSize (
//
// Pass in a zero size buffer to find the required buffer size.
//
- BufferSize = 0;
- Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
+ BufferSize = 0;
+ Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate the buffer to return
@@ -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.
@@ -1745,8 +1752,8 @@ IScsiCreateDriverData (
IN EFI_HANDLE Controller
)
{
- ISCSI_DRIVER_DATA *Private;
- EFI_STATUS Status;
+ ISCSI_DRIVER_DATA *Private;
+ EFI_STATUS Status;
Private = AllocateZeroPool (sizeof (ISCSI_DRIVER_DATA));
if (Private == NULL) {
@@ -1776,7 +1783,7 @@ IScsiCreateDriverData (
}
Private->ExtScsiPassThruHandle = NULL;
- CopyMem(&Private->IScsiExtScsiPassThru, &gIScsiExtScsiPassThruProtocolTemplate, sizeof(EFI_EXT_SCSI_PASS_THRU_PROTOCOL));
+ CopyMem (&Private->IScsiExtScsiPassThru, &gIScsiExtScsiPassThruProtocolTemplate, sizeof (EFI_EXT_SCSI_PASS_THRU_PROTOCOL));
//
// 0 is designated to the TargetId, so use another value for the AdapterId.
@@ -1789,7 +1796,6 @@ IScsiCreateDriverData (
return Private;
}
-
/**
Clean the iSCSI driver data.
@@ -1804,7 +1810,7 @@ IScsiCleanDriverData (
IN ISCSI_DRIVER_DATA *Private
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
@@ -1859,24 +1865,24 @@ IScsiDhcpIsConfigured (
IN UINT8 IpVersion
)
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINTN Index;
- EFI_STATUS Status;
- EFI_MAC_ADDRESS MacAddr;
- UINTN HwAddressSize;
- UINT16 VlanId;
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
- CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
- CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_MAC_ADDRESS MacAddr;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder",
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return FALSE;
}
@@ -1884,29 +1890,30 @@ IScsiDhcpIsConfigured (
// Get MAC address of this network device.
//
Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);
- if(EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
return FALSE;
}
+
//
// Get VLAN ID of this network device.
//
VlanId = NetLibGetVlanId (Controller);
- IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);
+ IScsiMacAddrToStr (&MacAddr, (UINT32)HwAddressSize, VlanId, MacString);
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
AttemptName,
- (UINTN) 128,
+ (UINTN)128,
L"Attempt %d",
- (UINTN) AttemptConfigOrder[Index]
+ (UINTN)AttemptConfigOrder[Index]
);
Status = GetVariable2 (
AttemptName,
&gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptTmp,
+ (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;
@@ -1958,24 +1967,24 @@ IScsiDnsIsConfigured (
IN EFI_HANDLE Controller
)
{
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- UINTN Index;
- EFI_STATUS Status;
- EFI_MAC_ADDRESS MacAddr;
- UINTN HwAddressSize;
- UINT16 VlanId;
- CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
- CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_MAC_ADDRESS MacAddr;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder",
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return FALSE;
}
@@ -1983,30 +1992,31 @@ IScsiDnsIsConfigured (
// Get MAC address of this network device.
//
Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);
- if(EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
return FALSE;
}
+
//
// Get VLAN ID of this network device.
//
VlanId = NetLibGetVlanId (Controller);
- IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);
+ IScsiMacAddrToStr (&MacAddr, (UINT32)HwAddressSize, VlanId, MacString);
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
AttemptName,
- (UINTN) 128,
+ (UINTN)128,
L"Attempt %d",
- (UINTN) AttemptConfigOrder[Index]
+ (UINTN)AttemptConfigOrder[Index]
);
Status = GetVariable2 (
AttemptName,
&gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptTmp,
+ (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;
-
}
/**
@@ -2050,17 +2058,17 @@ IScsiGetConfigData (
IN ISCSI_DRIVER_DATA *Private
)
{
- EFI_STATUS Status;
- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
- CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
- UINTN Index;
- ISCSI_NIC_INFO *NicInfo;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
- UINT8 *AttemptConfigOrder;
- UINTN AttemptConfigOrderSize;
- CHAR16 IScsiMode[64];
- CHAR16 IpMode[64];
+ EFI_STATUS Status;
+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
+ UINTN Index;
+ ISCSI_NIC_INFO *NicInfo;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
+ UINT8 *AttemptConfigOrder;
+ UINTN AttemptConfigOrderSize;
+ CHAR16 IScsiMode[64];
+ CHAR16 IpMode[64];
//
// There should be at least one attempt configured.
@@ -2070,19 +2078,19 @@ IScsiGetConfigData (
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) {
return EFI_NOT_FOUND;
}
//
// Get the iSCSI Initiator Name.
//
- mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE;
- Status = gIScsiInitiatorName.Get (
- &gIScsiInitiatorName,
- &mPrivate->InitiatorNameLength,
- mPrivate->InitiatorName
- );
+ mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE;
+ Status = gIScsiInitiatorName.Get (
+ &gIScsiInitiatorName,
+ &mPrivate->InitiatorNameLength,
+ mPrivate->InitiatorName
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -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.
//
@@ -2121,7 +2131,7 @@ IScsiGetConfigData (
// Try another approach for this autoconfigure path.
//
AttemptTmp->AutoConfigureMode =
- (UINT8) (mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);
+ (UINT8)(mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);
AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp = TRUE;
AttemptTmp->SessionConfigData.TargetInfoFromDhcp = TRUE;
AttemptTmp->DhcpSuccess = FALSE;
@@ -2146,9 +2156,9 @@ IScsiGetConfigData (
//
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptTmp->AttemptConfigIndex
+ (UINTN)AttemptTmp->AttemptConfigIndex
);
gRT->SetVariable (
@@ -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.
@@ -2186,9 +2197,9 @@ IScsiGetConfigData (
//
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptTmp->AttemptConfigIndex
+ (UINTN)AttemptTmp->AttemptConfigIndex
);
gRT->SetVariable (
@@ -2200,7 +2211,6 @@ IScsiGetConfigData (
);
continue;
-
} else {
continue;
}
@@ -2215,21 +2225,22 @@ IScsiGetConfigData (
IScsiMacAddrToStr (&NicInfo->PermanentAddress, NicInfo->HwAddressSize, NicInfo->VlanId, MacString);
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigOrder[Index]
+ (UINTN)AttemptConfigOrder[Index]
);
GetVariable2 (
mPrivate->PortString,
&gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
+ (VOID **)&AttemptConfigData,
NULL
);
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;
}
@@ -2237,7 +2248,7 @@ IScsiGetConfigData (
AttemptConfigData->NicIndex = NicInfo->NicIndex;
AttemptConfigData->DhcpSuccess = FALSE;
- AttemptConfigData->ValidiBFTPath = (BOOLEAN) (mPrivate->EnableMpio ? TRUE : FALSE);
+ AttemptConfigData->ValidiBFTPath = (BOOLEAN)(mPrivate->EnableMpio ? TRUE : FALSE);
AttemptConfigData->ValidPath = FALSE;
if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) {
@@ -2245,26 +2256,28 @@ IScsiGetConfigData (
AttemptConfigData->SessionConfigData.TargetInfoFromDhcp = TRUE;
AttemptConfigData->AutoConfigureMode =
- (UINT8) (mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);
+ (UINT8)(mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);
AttemptConfigData->AutoConfigureSuccess = FALSE;
}
//
// 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;
@@ -2276,9 +2289,9 @@ IScsiGetConfigData (
//
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"Attempt %d",
- (UINTN) AttemptConfigData->AttemptConfigIndex
+ (UINTN)AttemptConfigData->AttemptConfigIndex
);
gRT->SetVariable (
@@ -2312,7 +2325,7 @@ IScsiGetConfigData (
UnicodeSPrint (
mPrivate->PortString,
- (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE,
L"MAC: %s, PFA: Bus %d | Dev %d | Func %d, iSCSI mode: %s, IP version: %s",
MacString,
NicInfo->BusNumber,
@@ -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.
@@ -2395,7 +2408,7 @@ IScsiGetConfigData (
**/
EFI_DEVICE_PATH_PROTOCOL *
IScsiGetTcpConnDevicePath (
- IN ISCSI_SESSION *Session
+ IN ISCSI_SESSION *Session
)
{
ISCSI_CONNECTION *Conn;
@@ -2418,28 +2431,29 @@ IScsiGetTcpConnDevicePath (
Status = gBS->HandleProtocol (
Conn->TcpIo.Handle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
+ (VOID **)&DevicePath
);
if (EFI_ERROR (Status)) {
return NULL;
}
+
//
// Duplicate it.
//
- DevicePath = DuplicateDevicePath (DevicePath);
+ DevicePath = DuplicateDevicePath (DevicePath);
if (DevicePath == NULL) {
return NULL;
}
- DPathNode = (EFI_DEV_PATH *) DevicePath;
+ DPathNode = (EFI_DEV_PATH *)DevicePath;
while (!IsDevicePathEnd (&DPathNode->DevPath)) {
if (DevicePathType (&DPathNode->DevPath) == MESSAGING_DEVICE_PATH) {
- if (!Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP) {
- DPathNode->Ipv4.LocalPort = 0;
+ if (!Conn->Ipv6Flag && (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP)) {
+ DPathNode->Ipv4.LocalPort = 0;
DPathNode->Ipv4.StaticIpAddress =
- (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
+ (BOOLEAN)(!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
//
// Add a judgement here to support previous versions of IPv4_DEVICE_PATH.
@@ -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,8 +2477,8 @@ IScsiGetTcpConnDevicePath (
}
break;
- } else if (Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP) {
- DPathNode->Ipv6.LocalPort = 0;
+ } else if (Conn->Ipv6Flag && (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP)) {
+ DPathNode->Ipv6.LocalPort = 0;
//
// Add a judgement here to support previous versions of IPv6_DEVICE_PATH.
@@ -2478,32 +2491,28 @@ 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.
//
*((UINT8 *)(&DPathNode->Ipv6) + IP6_OLD_IPADDRESS_OFFSET) =
- (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
+ (BOOLEAN)(!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);
}
break;
}
}
- DPathNode = (EFI_DEV_PATH *) NextDevicePathNode (&DPathNode->DevPath);
+ DPathNode = (EFI_DEV_PATH *)NextDevicePathNode (&DPathNode->DevPath);
}
return DevicePath;
}
-
/**
Abort the session when the transition from BS to RT is initiated.
@@ -2518,9 +2527,9 @@ IScsiOnExitBootService (
IN VOID *Context
)
{
- ISCSI_DRIVER_DATA *Private;
+ ISCSI_DRIVER_DATA *Private;
- Private = (ISCSI_DRIVER_DATA *) Context;
+ Private = (ISCSI_DRIVER_DATA *)Context;
gBS->CloseEvent (Private->ExitBootServiceEvent);
Private->ExitBootServiceEvent = NULL;
@@ -2556,14 +2565,14 @@ IScsiOnExitBootService (
EFI_STATUS
EFIAPI
IScsiTestManagedDevice (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE DriverBindingHandle,
- IN EFI_GUID *ProtocolGuid
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_GUID *ProtocolGuid
)
{
- EFI_STATUS Status;
- VOID *ManagedInterface;
- EFI_HANDLE NicControllerHandle;
+ EFI_STATUS Status;
+ VOID *ManagedInterface;
+ EFI_HANDLE NicControllerHandle;
ASSERT (ProtocolGuid != NULL);
@@ -2574,7 +2583,7 @@ IScsiTestManagedDevice (
Status = gBS->OpenProtocol (
ControllerHandle,
- (EFI_GUID *) ProtocolGuid,
+ (EFI_GUID *)ProtocolGuid,
&ManagedInterface,
DriverBindingHandle,
NicControllerHandle,
@@ -2583,7 +2592,7 @@ IScsiTestManagedDevice (
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
ControllerHandle,
- (EFI_GUID *) ProtocolGuid,
+ (EFI_GUID *)ProtocolGuid,
DriverBindingHandle,
NicControllerHandle
);
diff --git a/NetworkPkg/Include/Library/NetLib.h b/NetworkPkg/Include/Library/NetLib.h
index 6c09248631..53495aa494 100644
--- a/NetworkPkg/Include/Library/NetLib.h
+++ b/NetworkPkg/Include/Library/NetLib.h
@@ -15,16 +15,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
-typedef UINT32 IP4_ADDR;
-typedef UINT32 TCP_SEQNO;
-typedef UINT16 TCP_PORTNO;
+typedef UINT32 IP4_ADDR;
+typedef UINT32 TCP_SEQNO;
+typedef UINT16 TCP_PORTNO;
+#define NET_ETHER_ADDR_LEN 6
+#define NET_IFTYPE_ETHERNET 0x01
-#define NET_ETHER_ADDR_LEN 6
-#define NET_IFTYPE_ETHERNET 0x01
-
-#define NET_VLAN_TAG_LEN 4
-#define ETHER_TYPE_VLAN 0x8100
+#define NET_VLAN_TAG_LEN 4
+#define ETHER_TYPE_VLAN 0x8100
#define EFI_IP_PROTO_UDP 0x11
#define EFI_IP_PROTO_TCP 0x06
@@ -37,73 +36,72 @@ typedef UINT16 TCP_PORTNO;
//
// The address classification
//
-#define IP4_ADDR_CLASSA 1 // Deprecated
-#define IP4_ADDR_CLASSB 2 // Deprecated
-#define IP4_ADDR_CLASSC 3 // Deprecated
-#define IP4_ADDR_CLASSD 4
-#define IP4_ADDR_CLASSE 5
+#define IP4_ADDR_CLASSA 1 // Deprecated
+#define IP4_ADDR_CLASSB 2 // Deprecated
+#define IP4_ADDR_CLASSC 3 // Deprecated
+#define IP4_ADDR_CLASSD 4
+#define IP4_ADDR_CLASSE 5
-#define IP4_MASK_NUM 33
-#define IP6_PREFIX_NUM 129
+#define IP4_MASK_NUM 33
+#define IP6_PREFIX_NUM 129
-#define IP4_MASK_MAX 32
-#define IP6_PREFIX_MAX 128
+#define IP4_MASK_MAX 32
+#define IP6_PREFIX_MAX 128
-#define IP6_HOP_BY_HOP 0
-#define IP6_DESTINATION 60
-#define IP6_ROUTING 43
-#define IP6_FRAGMENT 44
-#define IP6_AH 51
-#define IP6_ESP 50
-#define IP6_NO_NEXT_HEADER 59
+#define IP6_HOP_BY_HOP 0
+#define IP6_DESTINATION 60
+#define IP6_ROUTING 43
+#define IP6_FRAGMENT 44
+#define IP6_AH 51
+#define IP6_ESP 50
+#define IP6_NO_NEXT_HEADER 59
-#define IP_VERSION_4 4
-#define IP_VERSION_6 6
+#define IP_VERSION_4 4
+#define IP_VERSION_6 6
-#define IP6_PREFIX_LENGTH 64
+#define IP6_PREFIX_LENGTH 64
//
// DNS QTYPE values
//
-#define DNS_TYPE_A 1
-#define DNS_TYPE_NS 2
-#define DNS_TYPE_CNAME 5
-#define DNS_TYPE_SOA 6
-#define DNS_TYPE_WKS 11
-#define DNS_TYPE_PTR 12
-#define DNS_TYPE_HINFO 13
-#define DNS_TYPE_MINFO 14
-#define DNS_TYPE_MX 15
-#define DNS_TYPE_TXT 16
-#define DNS_TYPE_AAAA 28
-#define DNS_TYPE_SRV_RR 33
-#define DNS_TYPE_AXFR 252
-#define DNS_TYPE_MAILB 253
-#define DNS_TYPE_ANY 255
+#define DNS_TYPE_A 1
+#define DNS_TYPE_NS 2
+#define DNS_TYPE_CNAME 5
+#define DNS_TYPE_SOA 6
+#define DNS_TYPE_WKS 11
+#define DNS_TYPE_PTR 12
+#define DNS_TYPE_HINFO 13
+#define DNS_TYPE_MINFO 14
+#define DNS_TYPE_MX 15
+#define DNS_TYPE_TXT 16
+#define DNS_TYPE_AAAA 28
+#define DNS_TYPE_SRV_RR 33
+#define DNS_TYPE_AXFR 252
+#define DNS_TYPE_MAILB 253
+#define DNS_TYPE_ANY 255
//
// DNS QCLASS values
//
-#define DNS_CLASS_INET 1
-#define DNS_CLASS_CH 3
-#define DNS_CLASS_HS 4
-#define DNS_CLASS_ANY 255
+#define DNS_CLASS_INET 1
+#define DNS_CLASS_CH 3
+#define DNS_CLASS_HS 4
+#define DNS_CLASS_ANY 255
//
// Number of 100ns units time Interval for network media state detect
//
#define MEDIA_STATE_DETECT_TIME_INTERVAL 1000000U
-
#pragma pack(1)
//
// Ethernet head definition
//
typedef struct {
- UINT8 DstMac [NET_ETHER_ADDR_LEN];
- UINT8 SrcMac [NET_ETHER_ADDR_LEN];
- UINT16 EtherType;
+ UINT8 DstMac[NET_ETHER_ADDR_LEN];
+ UINT8 SrcMac[NET_ETHER_ADDR_LEN];
+ UINT16 EtherType;
} ETHER_HEAD;
//
@@ -111,11 +109,11 @@ typedef struct {
//
typedef union {
struct {
- UINT16 Vid : 12; // Unique VLAN identifier (0 to 4094)
- UINT16 Cfi : 1; // Canonical Format Indicator
- UINT16 Priority : 3; // 802.1Q priority level (0 to 7)
+ UINT16 Vid : 12; // Unique VLAN identifier (0 to 4094)
+ UINT16 Cfi : 1; // Canonical Format Indicator
+ UINT16 Priority : 3; // 802.1Q priority level (0 to 7)
} Bits;
- UINT16 Uint16;
+ UINT16 Uint16;
} VLAN_TCI;
#define VLAN_TCI_CFI_CANONICAL_MAC 0
@@ -128,83 +126,82 @@ typedef union {
// directly. This is why there is an internal representation.
//
typedef struct {
- UINT8 HeadLen : 4;
- UINT8 Ver : 4;
- UINT8 Tos;
- UINT16 TotalLen;
- UINT16 Id;
- UINT16 Fragment;
- UINT8 Ttl;
- UINT8 Protocol;
- UINT16 Checksum;
- IP4_ADDR Src;
- IP4_ADDR Dst;
+ UINT8 HeadLen : 4;
+ UINT8 Ver : 4;
+ UINT8 Tos;
+ UINT16 TotalLen;
+ UINT16 Id;
+ UINT16 Fragment;
+ UINT8 Ttl;
+ UINT8 Protocol;
+ UINT16 Checksum;
+ IP4_ADDR Src;
+ 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.
//
typedef struct {
- UINT8 Type;
- UINT8 Code;
- UINT16 Checksum;
+ UINT8 Type;
+ UINT8 Code;
+ UINT16 Checksum;
} IP4_ICMP_HEAD;
typedef struct {
- IP4_ICMP_HEAD Head;
- UINT32 Fourth; // 4th filed of the head, it depends on Type.
- IP4_HEAD IpHead;
+ IP4_ICMP_HEAD Head;
+ UINT32 Fourth; // 4th filed of the head, it depends on Type.
+ IP4_HEAD IpHead;
} IP4_ICMP_ERROR_HEAD;
typedef struct {
- IP4_ICMP_HEAD Head;
- UINT16 Id;
- UINT16 Seq;
+ IP4_ICMP_HEAD Head;
+ UINT16 Id;
+ UINT16 Seq;
} IP4_ICMP_QUERY_HEAD;
typedef struct {
- UINT8 Type;
- UINT8 Code;
- UINT16 Checksum;
+ UINT8 Type;
+ UINT8 Code;
+ UINT16 Checksum;
} IP6_ICMP_HEAD;
typedef struct {
- IP6_ICMP_HEAD Head;
- UINT32 Fourth;
- EFI_IP6_HEADER IpHead;
+ IP6_ICMP_HEAD Head;
+ UINT32 Fourth;
+ EFI_IP6_HEADER IpHead;
} IP6_ICMP_ERROR_HEAD;
typedef struct {
- IP6_ICMP_HEAD Head;
- UINT32 Fourth;
+ IP6_ICMP_HEAD Head;
+ UINT32 Fourth;
} IP6_ICMP_INFORMATION_HEAD;
//
// UDP header definition
//
typedef struct {
- UINT16 SrcPort;
- UINT16 DstPort;
- UINT16 Length;
- UINT16 Checksum;
+ UINT16 SrcPort;
+ UINT16 DstPort;
+ UINT16 Length;
+ UINT16 Checksum;
} EFI_UDP_HEADER;
//
// TCP header definition
//
typedef struct {
- TCP_PORTNO SrcPort;
- TCP_PORTNO DstPort;
- TCP_SEQNO Seq;
- TCP_SEQNO Ack;
- UINT8 Res : 4;
- UINT8 HeadLen : 4;
- UINT8 Flag;
- UINT16 Wnd;
- UINT16 Checksum;
- UINT16 Urg;
+ TCP_PORTNO SrcPort;
+ TCP_PORTNO DstPort;
+ TCP_SEQNO Seq;
+ TCP_SEQNO Ack;
+ UINT8 Res : 4;
+ UINT8 HeadLen : 4;
+ UINT8 Flag;
+ UINT16 Wnd;
+ UINT16 Checksum;
+ UINT16 Urg;
} TCP_HEAD;
#pragma pack()
@@ -221,11 +218,11 @@ typedef struct {
#define NTOHS(x) SwapBytes16 (x)
-#define HTONS(x) NTOHS(x)
-#define NTOHLL(x) SwapBytes64 (x)
-#define HTONLL(x) NTOHLL(x)
-#define NTOHLLL(x) Ip6Swap128 (x)
-#define HTONLLL(x) NTOHLLL(x)
+#define HTONS(x) NTOHS(x)
+#define NTOHLL(x) SwapBytes64 (x)
+#define HTONLL(x) NTOHLL(x)
+#define NTOHLLL(x) Ip6Swap128 (x)
+#define HTONLLL(x) NTOHLLL(x)
//
// Test the IP's attribute, All the IPs are in host byte order.
@@ -236,7 +233,7 @@ typedef struct {
#define IP4_NET_EQUAL(Ip1, Ip2, NetMask) (((Ip1) & (NetMask)) == ((Ip2) & (NetMask)))
#define IP4_IS_VALID_NETMASK(Ip) (NetGetMaskLength (Ip) != (IP4_MASK_MAX + 1))
-#define IP6_IS_MULTICAST(Ip6) (((Ip6)->Addr[0]) == 0xFF)
+#define IP6_IS_MULTICAST(Ip6) (((Ip6)->Addr[0]) == 0xFF)
//
// Convert the EFI_IP4_ADDRESS to plain UINT32 IP4 address.
@@ -247,17 +244,17 @@ typedef struct {
#define EFI_IP6_EQUAL(Ip1, Ip2) (CompareMem ((Ip1), (Ip2), sizeof (EFI_IPv6_ADDRESS)) == 0)
-#define IP4_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv4_ADDRESS)))
-#define IP6_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv6_ADDRESS)))
-#define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)))
+#define IP4_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv4_ADDRESS)))
+#define IP6_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv6_ADDRESS)))
+#define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)))
//
// The debug level definition. This value is also used as the
// syslog's severity level. Don't change it.
//
-#define NETDEBUG_LEVEL_TRACE 5
-#define NETDEBUG_LEVEL_WARNING 4
-#define NETDEBUG_LEVEL_ERROR 3
+#define NETDEBUG_LEVEL_TRACE 5
+#define NETDEBUG_LEVEL_WARNING 4
+#define NETDEBUG_LEVEL_ERROR 3
//
// Network debug message is sent out as syslog packet.
@@ -326,7 +323,7 @@ typedef struct {
CHAR8 *
EFIAPI
NetDebugASPrint (
- IN CHAR8 *Format,
+ IN CHAR8 *Format,
...
);
@@ -350,14 +347,13 @@ NetDebugASPrint (
EFI_STATUS
EFIAPI
NetDebugOutput (
- IN UINT32 Level,
- IN UINT8 *Module,
- IN UINT8 *File,
- IN UINT32 Line,
- IN UINT8 *Message
+ IN UINT32 Level,
+ IN UINT8 *Module,
+ IN UINT8 *File,
+ IN UINT32 Line,
+ IN UINT8 *Message
);
-
/**
Return the length of the mask.
@@ -373,7 +369,7 @@ NetDebugOutput (
INTN
EFIAPI
NetGetMaskLength (
- IN IP4_ADDR NetMask
+ IN IP4_ADDR NetMask
);
/**
@@ -405,7 +401,7 @@ NetGetMaskLength (
INTN
EFIAPI
NetGetIpClass (
- IN IP4_ADDR Addr
+ IN IP4_ADDR Addr
);
/**
@@ -428,8 +424,8 @@ NetGetIpClass (
BOOLEAN
EFIAPI
NetIp4IsUnicast (
- IN IP4_ADDR Ip,
- IN IP4_ADDR NetMask
+ IN IP4_ADDR Ip,
+ IN IP4_ADDR NetMask
);
/**
@@ -451,10 +447,9 @@ NetIp4IsUnicast (
BOOLEAN
EFIAPI
NetIp6IsValidUnicast (
- IN EFI_IPv6_ADDRESS *Ip6
+ IN EFI_IPv6_ADDRESS *Ip6
);
-
/**
Check whether the incoming Ipv6 address is the unspecified address or not.
@@ -469,7 +464,7 @@ NetIp6IsValidUnicast (
BOOLEAN
EFIAPI
NetIp6IsUnspecifiedAddr (
- IN EFI_IPv6_ADDRESS *Ip6
+ IN EFI_IPv6_ADDRESS *Ip6
);
/**
@@ -486,7 +481,7 @@ NetIp6IsUnspecifiedAddr (
BOOLEAN
EFIAPI
NetIp6IsLinkLocalAddr (
- IN EFI_IPv6_ADDRESS *Ip6
+ IN EFI_IPv6_ADDRESS *Ip6
);
/**
@@ -506,9 +501,9 @@ NetIp6IsLinkLocalAddr (
BOOLEAN
EFIAPI
NetIp6IsNetEqual (
- EFI_IPv6_ADDRESS *Ip1,
- EFI_IPv6_ADDRESS *Ip2,
- UINT8 PrefixLength
+ EFI_IPv6_ADDRESS *Ip1,
+ EFI_IPv6_ADDRESS *Ip2,
+ UINT8 PrefixLength
);
/**
@@ -528,11 +523,10 @@ NetIp6IsNetEqual (
EFI_IPv6_ADDRESS *
EFIAPI
Ip6Swap128 (
- EFI_IPv6_ADDRESS *Ip6
+ EFI_IPv6_ADDRESS *Ip6
);
-extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM];
-
+extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM];
extern EFI_IPv4_ADDRESS mZeroIp4Addr;
@@ -542,10 +536,10 @@ extern EFI_IPv4_ADDRESS mZeroIp4Addr;
#define NET_IS_LOWER_CASE_CHAR(Ch) (('a' <= (Ch)) && ((Ch) <= 'z'))
#define NET_IS_UPPER_CASE_CHAR(Ch) (('A' <= (Ch)) && ((Ch) <= 'Z'))
-#define TICKS_PER_MS 10000U
-#define TICKS_PER_SECOND 10000000U
+#define TICKS_PER_MS 10000U
+#define TICKS_PER_SECOND 10000000U
-#define NET_RANDOM(Seed) ((UINT32) ((UINT32) (Seed) * 1103515245UL + 12345) % 4294967295UL)
+#define NET_RANDOM(Seed) ((UINT32) ((UINT32) (Seed) * 1103515245UL + 12345) % 4294967295UL)
/**
Extract a UINT32 from a byte stream.
@@ -563,7 +557,7 @@ extern EFI_IPv4_ADDRESS mZeroIp4Addr;
UINT32
EFIAPI
NetGetUint32 (
- IN UINT8 *Buf
+ IN UINT8 *Buf
);
/**
@@ -581,8 +575,8 @@ NetGetUint32 (
VOID
EFIAPI
NetPutUint32 (
- IN OUT UINT8 *Buf,
- IN UINT32 Data
+ IN OUT UINT8 *Buf,
+ IN UINT32 Data
);
/**
@@ -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.
@@ -657,7 +649,7 @@ NetRandomInitSeed (
LIST_ENTRY *
EFIAPI
NetListRemoveHead (
- IN OUT LIST_ENTRY *Head
+ IN OUT LIST_ENTRY *Head
);
/**
@@ -681,7 +673,7 @@ NetListRemoveHead (
LIST_ENTRY *
EFIAPI
NetListRemoveTail (
- IN OUT LIST_ENTRY *Head
+ IN OUT LIST_ENTRY *Head
);
/**
@@ -699,8 +691,8 @@ NetListRemoveTail (
VOID
EFIAPI
NetListInsertAfter (
- IN OUT LIST_ENTRY *PrevEntry,
- IN OUT LIST_ENTRY *NewEntry
+ IN OUT LIST_ENTRY *PrevEntry,
+ IN OUT LIST_ENTRY *NewEntry
);
/**
@@ -718,8 +710,8 @@ NetListInsertAfter (
VOID
EFIAPI
NetListInsertBefore (
- IN OUT LIST_ENTRY *PostEntry,
- IN OUT LIST_ENTRY *NewEntry
+ IN OUT LIST_ENTRY *PostEntry,
+ IN OUT LIST_ENTRY *NewEntry
);
/**
@@ -734,7 +726,7 @@ NetListInsertBefore (
**/
typedef
EFI_STATUS
-(EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK) (
+(EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK)(
IN LIST_ENTRY *Entry,
IN VOID *Context OPTIONAL
);
@@ -785,9 +777,9 @@ NetDestroyLinkList (
BOOLEAN
EFIAPI
NetIsInHandleBuffer (
- IN EFI_HANDLE Handle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_HANDLE Handle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
);
//
@@ -795,15 +787,15 @@ NetIsInHandleBuffer (
// tokens. The drivers can share code to manage those objects.
//
typedef struct {
- LIST_ENTRY Link;
- VOID *Key;
- VOID *Value;
+ LIST_ENTRY Link;
+ VOID *Key;
+ VOID *Value;
} NET_MAP_ITEM;
typedef struct {
- LIST_ENTRY Used;
- LIST_ENTRY Recycled;
- UINTN Count;
+ LIST_ENTRY Used;
+ LIST_ENTRY Recycled;
+ UINTN Count;
} NET_MAP;
#define NET_MAP_INCREAMENT 64
@@ -825,7 +817,7 @@ typedef struct {
VOID
EFIAPI
NetMapInit (
- IN OUT NET_MAP *Map
+ IN OUT NET_MAP *Map
);
/**
@@ -843,7 +835,7 @@ NetMapInit (
VOID
EFIAPI
NetMapClean (
- IN OUT NET_MAP *Map
+ IN OUT NET_MAP *Map
);
/**
@@ -861,7 +853,7 @@ NetMapClean (
BOOLEAN
EFIAPI
NetMapIsEmpty (
- IN NET_MAP *Map
+ IN NET_MAP *Map
);
/**
@@ -877,7 +869,7 @@ NetMapIsEmpty (
UINTN
EFIAPI
NetMapGetCount (
- IN NET_MAP *Map
+ IN NET_MAP *Map
);
/**
@@ -901,9 +893,9 @@ NetMapGetCount (
EFI_STATUS
EFIAPI
NetMapInsertHead (
- IN OUT NET_MAP *Map,
- IN VOID *Key,
- IN VOID *Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ IN VOID *Key,
+ IN VOID *Value OPTIONAL
);
/**
@@ -927,9 +919,9 @@ NetMapInsertHead (
EFI_STATUS
EFIAPI
NetMapInsertTail (
- IN OUT NET_MAP *Map,
- IN VOID *Key,
- IN VOID *Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ IN VOID *Key,
+ IN VOID *Value OPTIONAL
);
/**
@@ -950,8 +942,8 @@ NetMapInsertTail (
NET_MAP_ITEM *
EFIAPI
NetMapFindKey (
- IN NET_MAP *Map,
- IN VOID *Key
+ IN NET_MAP *Map,
+ IN VOID *Key
);
/**
@@ -976,9 +968,9 @@ NetMapFindKey (
VOID *
EFIAPI
NetMapRemoveItem (
- IN OUT NET_MAP *Map,
- IN OUT NET_MAP_ITEM *Item,
- OUT VOID **Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ IN OUT NET_MAP_ITEM *Item,
+ OUT VOID **Value OPTIONAL
);
/**
@@ -1001,8 +993,8 @@ NetMapRemoveItem (
VOID *
EFIAPI
NetMapRemoveHead (
- IN OUT NET_MAP *Map,
- OUT VOID **Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ OUT VOID **Value OPTIONAL
);
/**
@@ -1025,13 +1017,13 @@ NetMapRemoveHead (
VOID *
EFIAPI
NetMapRemoveTail (
- IN OUT NET_MAP *Map,
- OUT VOID **Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ OUT VOID **Value OPTIONAL
);
typedef
EFI_STATUS
-(EFIAPI *NET_MAP_CALLBACK) (
+(EFIAPI *NET_MAP_CALLBACK)(
IN NET_MAP *Map,
IN NET_MAP_ITEM *Item,
IN VOID *Arg
@@ -1059,15 +1051,15 @@ EFI_STATUS
EFI_STATUS
EFIAPI
NetMapIterate (
- IN NET_MAP *Map,
- IN NET_MAP_CALLBACK CallBack,
- IN VOID *Arg OPTIONAL
+ IN NET_MAP *Map,
+ IN NET_MAP_CALLBACK CallBack,
+ 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.
@@ -1088,10 +1080,10 @@ NetMapIterate (
EFI_STATUS
EFIAPI
NetLibCreateServiceChild (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Image,
- IN EFI_GUID *ServiceBindingGuid,
- IN OUT EFI_HANDLE *ChildHandle
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Image,
+ IN EFI_GUID *ServiceBindingGuid,
+ IN OUT EFI_HANDLE *ChildHandle
);
/**
@@ -1113,10 +1105,10 @@ NetLibCreateServiceChild (
EFI_STATUS
EFIAPI
NetLibDestroyServiceChild (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Image,
- IN EFI_GUID *ServiceBindingGuid,
- IN EFI_HANDLE ChildHandle
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Image,
+ IN EFI_GUID *ServiceBindingGuid,
+ IN EFI_HANDLE ChildHandle
);
/**
@@ -1138,8 +1130,8 @@ NetLibDestroyServiceChild (
EFI_HANDLE
EFIAPI
NetLibGetSnpHandle (
- IN EFI_HANDLE ServiceHandle,
- OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL
+ IN EFI_HANDLE ServiceHandle,
+ OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL
);
/**
@@ -1158,7 +1150,7 @@ NetLibGetSnpHandle (
UINT16
EFIAPI
NetLibGetVlanId (
- IN EFI_HANDLE ServiceHandle
+ IN EFI_HANDLE ServiceHandle
);
/**
@@ -1178,8 +1170,8 @@ NetLibGetVlanId (
EFI_HANDLE
EFIAPI
NetLibGetVlanHandle (
- IN EFI_HANDLE ControllerHandle,
- IN UINT16 VlanId
+ IN EFI_HANDLE ControllerHandle,
+ IN UINT16 VlanId
);
/**
@@ -1204,9 +1196,9 @@ NetLibGetVlanHandle (
EFI_STATUS
EFIAPI
NetLibGetMacAddress (
- IN EFI_HANDLE ServiceHandle,
- OUT EFI_MAC_ADDRESS *MacAddress,
- OUT UINTN *AddressSize
+ IN EFI_HANDLE ServiceHandle,
+ OUT EFI_MAC_ADDRESS *MacAddress,
+ OUT UINTN *AddressSize
);
/**
@@ -1274,8 +1266,8 @@ NetLibGetMacString (
EFI_STATUS
EFIAPI
NetLibDetectMedia (
- IN EFI_HANDLE ServiceHandle,
- OUT BOOLEAN *MediaPresent
+ IN EFI_HANDLE ServiceHandle,
+ OUT BOOLEAN *MediaPresent
);
/**
@@ -1305,12 +1297,11 @@ NetLibDetectMedia (
EFI_STATUS
EFIAPI
NetLibDetectMediaWaitTimeout (
- IN EFI_HANDLE ServiceHandle,
- IN UINT64 Timeout,
- OUT EFI_STATUS *MediaState
+ IN EFI_HANDLE ServiceHandle,
+ IN UINT64 Timeout,
+ 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.
@@ -1400,8 +1390,8 @@ NetLibCreateIPv6DPathNode (
EFI_HANDLE
EFIAPI
NetLibGetNicHandle (
- IN EFI_HANDLE Controller,
- IN EFI_GUID *ProtocolGuid
+ IN EFI_HANDLE Controller,
+ IN EFI_GUID *ProtocolGuid
);
/**
@@ -1419,7 +1409,7 @@ NetLibGetNicHandle (
EFI_STATUS
EFIAPI
NetLibDefaultUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
);
/**
@@ -1435,8 +1425,8 @@ NetLibDefaultUnload (
EFI_STATUS
EFIAPI
NetLibAsciiStrToIp4 (
- IN CONST CHAR8 *String,
- OUT EFI_IPv4_ADDRESS *Ip4Address
+ IN CONST CHAR8 *String,
+ OUT EFI_IPv4_ADDRESS *Ip4Address
);
/**
@@ -1453,8 +1443,8 @@ NetLibAsciiStrToIp4 (
EFI_STATUS
EFIAPI
NetLibAsciiStrToIp6 (
- IN CONST CHAR8 *String,
- OUT EFI_IPv6_ADDRESS *Ip6Address
+ IN CONST CHAR8 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address
);
/**
@@ -1470,8 +1460,8 @@ NetLibAsciiStrToIp6 (
EFI_STATUS
EFIAPI
NetLibStrToIp4 (
- IN CONST CHAR16 *String,
- OUT EFI_IPv4_ADDRESS *Ip4Address
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv4_ADDRESS *Ip4Address
);
/**
@@ -1488,8 +1478,8 @@ NetLibStrToIp4 (
EFI_STATUS
EFIAPI
NetLibStrToIp6 (
- IN CONST CHAR16 *String,
- OUT EFI_IPv6_ADDRESS *Ip6Address
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address
);
/**
@@ -1508,9 +1498,9 @@ NetLibStrToIp6 (
EFI_STATUS
EFIAPI
NetLibStrToIp6andPrefix (
- IN CONST CHAR16 *String,
- OUT EFI_IPv6_ADDRESS *Ip6Address,
- OUT UINT8 *PrefixLength
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address,
+ OUT UINT8 *PrefixLength
);
/**
@@ -1530,23 +1520,22 @@ NetLibStrToIp6andPrefix (
EFI_STATUS
EFIAPI
NetLibIp6ToStr (
- IN EFI_IPv6_ADDRESS *Ip6Address,
- OUT CHAR16 *String,
- IN UINTN StringSize
+ IN EFI_IPv6_ADDRESS *Ip6Address,
+ OUT CHAR16 *String,
+ IN UINTN StringSize
);
//
// Various signatures
//
-#define NET_BUF_SIGNATURE SIGNATURE_32 ('n', 'b', 'u', 'f')
-#define NET_VECTOR_SIGNATURE SIGNATURE_32 ('n', 'v', 'e', 'c')
-#define NET_QUE_SIGNATURE SIGNATURE_32 ('n', 'b', 'q', 'u')
-
+#define NET_BUF_SIGNATURE SIGNATURE_32 ('n', 'b', 'u', 'f')
+#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
-#define NET_VECTOR_OWN_FIRST 0x01 // We allocated the 1st block in the vector
+#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
+#define NET_VECTOR_OWN_FIRST 0x01 // We allocated the 1st block in the vector
#define NET_CHECK_SIGNATURE(PData, SIGNATURE) \
ASSERT (((PData) != NULL) && ((PData)->Signature == (SIGNATURE)))
@@ -1555,39 +1544,39 @@ NetLibIp6ToStr (
// Single memory block in the vector.
//
typedef struct {
- UINT32 Len; // The block's length
- UINT8 *Bulk; // The block's Data
+ UINT32 Len; // The block's length
+ UINT8 *Bulk; // The block's Data
} NET_BLOCK;
-typedef VOID (EFIAPI *NET_VECTOR_EXT_FREE) (VOID *Arg);
+typedef VOID (EFIAPI *NET_VECTOR_EXT_FREE)(VOID *Arg);
//
-//NET_VECTOR contains several blocks to hold all packet's
-//fragments and other house-keeping stuff for sharing. It
-//doesn't specify the where actual packet fragment begins.
+// NET_VECTOR contains several blocks to hold all packet's
+// fragments and other house-keeping stuff for sharing. It
+// doesn't specify the where actual packet fragment begins.
//
typedef struct {
- UINT32 Signature;
- INTN RefCnt; // Reference count to share NET_VECTOR.
- NET_VECTOR_EXT_FREE Free; // external function to free NET_VECTOR
- VOID *Arg; // opaque argument to Free
- UINT32 Flag; // Flags, NET_VECTOR_OWN_FIRST
- UINT32 Len; // Total length of the associated BLOCKs
-
- UINT32 BlockNum;
- NET_BLOCK Block[1];
+ UINT32 Signature;
+ INTN RefCnt; // Reference count to share NET_VECTOR.
+ NET_VECTOR_EXT_FREE Free; // external function to free NET_VECTOR
+ VOID *Arg; // opaque argument to Free
+ UINT32 Flag; // Flags, NET_VECTOR_OWN_FIRST
+ UINT32 Len; // Total length of the associated BLOCKs
+
+ UINT32 BlockNum;
+ NET_BLOCK Block[1];
} NET_VECTOR;
//
-//NET_BLOCK_OP operates on the NET_BLOCK. It specifies
-//where the actual fragment begins and ends
+// NET_BLOCK_OP operates on the NET_BLOCK. It specifies
+// where the actual fragment begins and ends
//
typedef struct {
- UINT8 *BlockHead; // Block's head, or the smallest valid Head
- UINT8 *BlockTail; // Block's tail. BlockTail-BlockHead=block length
- UINT8 *Head; // 1st byte of the data in the block
- UINT8 *Tail; // Tail of the data in the block, Tail-Head=Size
- UINT32 Size; // The size of the data
+ UINT8 *BlockHead; // Block's head, or the smallest valid Head
+ UINT8 *BlockTail; // Block's tail. BlockTail-BlockHead=block length
+ UINT8 *Head; // 1st byte of the data in the block
+ UINT8 *Tail; // Tail of the data in the block, Tail-Head=Size
+ UINT32 Size; // The size of the data
} NET_BLOCK_OP;
typedef union {
@@ -1596,44 +1585,44 @@ typedef union {
} NET_IP_HEAD;
//
-//NET_BUF is the buffer manage structure used by the
-//network stack. Every network packet may be fragmented. The Vector points to
-//memory blocks used by each fragment, and BlockOp
-//specifies where each fragment begins and ends.
+// NET_BUF is the buffer manage structure used by the
+// network stack. Every network packet may be fragmented. The Vector points to
+// memory blocks used by each fragment, and BlockOp
+// specifies where each fragment begins and ends.
//
-//It also contains an opaque area for the protocol to store
-//per-packet information. Protocol must be careful not
-//to overwrite the members after that.
+// It also contains an opaque area for the protocol to store
+// per-packet information. Protocol must be careful not
+// to overwrite the members after that.
//
typedef struct {
- UINT32 Signature;
- INTN RefCnt;
- LIST_ENTRY List; // The List this NET_BUF is on
+ UINT32 Signature;
+ INTN RefCnt;
+ LIST_ENTRY List; // The List this NET_BUF is on
- NET_IP_HEAD Ip; // Network layer header, for fast access
- TCP_HEAD *Tcp; // Transport layer header, for fast access
- EFI_UDP_HEADER *Udp; // User Datagram Protocol header
- UINT8 ProtoData [NET_PROTO_DATA]; //Protocol specific data
+ NET_IP_HEAD Ip; // Network layer header, for fast access
+ TCP_HEAD *Tcp; // Transport layer header, for fast access
+ EFI_UDP_HEADER *Udp; // User Datagram Protocol header
+ UINT8 ProtoData[NET_PROTO_DATA]; // Protocol specific data
- NET_VECTOR *Vector; // The vector containing the packet
+ NET_VECTOR *Vector; // The vector containing the packet
- UINT32 BlockOpNum; // Total number of BlockOp in the buffer
- UINT32 TotalSize; // Total size of the actual packet
- NET_BLOCK_OP BlockOp[1]; // Specify the position of actual packet
+ UINT32 BlockOpNum; // Total number of BlockOp in the buffer
+ UINT32 TotalSize; // Total size of the actual packet
+ NET_BLOCK_OP BlockOp[1]; // Specify the position of actual packet
} NET_BUF;
//
-//A queue of NET_BUFs. It is a thin extension of
-//NET_BUF functions.
+// A queue of NET_BUFs. It is a thin extension of
+// NET_BUF functions.
//
typedef struct {
- UINT32 Signature;
- INTN RefCnt;
- LIST_ENTRY List; // The List this buffer queue is on
+ UINT32 Signature;
+ INTN RefCnt;
+ LIST_ENTRY List; // The List this buffer queue is on
- LIST_ENTRY BufList; // list of queued buffers
- UINT32 BufSize; // total length of DATA in the buffers
- UINT32 BufNum; // total number of buffers on the chain
+ LIST_ENTRY BufList; // list of queued buffers
+ UINT32 BufSize; // total length of DATA in the buffers
+ UINT32 BufNum; // total number of buffers on the chain
} NET_BUF_QUEUE;
//
@@ -1641,19 +1630,19 @@ typedef struct {
//
#pragma pack(1)
typedef struct {
- IP4_ADDR SrcIp;
- IP4_ADDR DstIp;
- UINT8 Reserved;
- UINT8 Protocol;
- UINT16 Len;
+ IP4_ADDR SrcIp;
+ IP4_ADDR DstIp;
+ UINT8 Reserved;
+ UINT8 Protocol;
+ UINT16 Len;
} NET_PSEUDO_HDR;
typedef struct {
EFI_IPv6_ADDRESS SrcIp;
EFI_IPv6_ADDRESS DstIp;
UINT32 Len;
- UINT32 Reserved:24;
- UINT32 NextHeader:8;
+ UINT32 Reserved : 24;
+ UINT32 NextHeader : 8;
} NET_IP6_PSEUDO_HDR;
#pragma pack()
@@ -1663,13 +1652,13 @@ typedef struct {
// the two in case that NET_BLOCK be enhanced later.
//
typedef struct {
- UINT32 Len;
- UINT8 *Bulk;
+ UINT32 Len;
+ UINT8 *Bulk;
} NET_FRAGMENT;
-#define NET_GET_REF(PData) ((PData)->RefCnt++)
-#define NET_PUT_REF(PData) ((PData)->RefCnt--)
-#define NETBUF_FROM_PROTODATA(Info) BASE_CR((Info), NET_BUF, ProtoData)
+#define NET_GET_REF(PData) ((PData)->RefCnt++)
+#define NET_PUT_REF(PData) ((PData)->RefCnt--)
+#define NETBUF_FROM_PROTODATA(Info) BASE_CR((Info), NET_BUF, ProtoData)
#define NET_BUF_SHARED(Buf) \
(((Buf)->RefCnt > 1) || ((Buf)->Vector->RefCnt > 1))
@@ -1699,7 +1688,7 @@ typedef struct {
NET_BUF *
EFIAPI
NetbufAlloc (
- IN UINT32 Len
+ IN UINT32 Len
);
/**
@@ -1717,7 +1706,7 @@ NetbufAlloc (
VOID
EFIAPI
NetbufFree (
- IN NET_BUF *Nbuf
+ IN NET_BUF *Nbuf
);
/**
@@ -1740,9 +1729,9 @@ NetbufFree (
UINT8 *
EFIAPI
NetbufGetByte (
- IN NET_BUF *Nbuf,
- IN UINT32 Offset,
- OUT UINT32 *Index OPTIONAL
+ IN NET_BUF *Nbuf,
+ IN UINT32 Offset,
+ OUT UINT32 *Index OPTIONAL
);
/**
@@ -1760,7 +1749,7 @@ NetbufGetByte (
NET_BUF *
EFIAPI
NetbufClone (
- IN NET_BUF *Nbuf
+ IN NET_BUF *Nbuf
);
/**
@@ -1782,9 +1771,9 @@ NetbufClone (
NET_BUF *
EFIAPI
NetbufDuplicate (
- IN NET_BUF *Nbuf,
- IN OUT NET_BUF *Duplicate OPTIONAL,
- IN UINT32 HeadSpace
+ IN NET_BUF *Nbuf,
+ IN OUT NET_BUF *Duplicate OPTIONAL,
+ IN UINT32 HeadSpace
);
/**
@@ -1807,10 +1796,10 @@ NetbufDuplicate (
NET_BUF *
EFIAPI
NetbufGetFragment (
- IN NET_BUF *Nbuf,
- IN UINT32 Offset,
- IN UINT32 Len,
- IN UINT32 HeadSpace
+ IN NET_BUF *Nbuf,
+ IN UINT32 Offset,
+ IN UINT32 Len,
+ IN UINT32 HeadSpace
);
/**
@@ -1828,8 +1817,8 @@ NetbufGetFragment (
VOID
EFIAPI
NetbufReserve (
- IN OUT NET_BUF *Nbuf,
- IN UINT32 Len
+ IN OUT NET_BUF *Nbuf,
+ IN UINT32 Len
);
/**
@@ -1844,12 +1833,12 @@ NetbufReserve (
or NULL, if there is no sufficient space.
**/
-UINT8*
+UINT8 *
EFIAPI
NetbufAllocSpace (
- IN OUT NET_BUF *Nbuf,
- IN UINT32 Len,
- IN BOOLEAN FromHead
+ IN OUT NET_BUF *Nbuf,
+ IN UINT32 Len,
+ IN BOOLEAN FromHead
);
/**
@@ -1867,9 +1856,9 @@ NetbufAllocSpace (
UINT32
EFIAPI
NetbufTrim (
- IN OUT NET_BUF *Nbuf,
- IN UINT32 Len,
- IN BOOLEAN FromHead
+ IN OUT NET_BUF *Nbuf,
+ IN UINT32 Len,
+ IN BOOLEAN FromHead
);
/**
@@ -1890,10 +1879,10 @@ NetbufTrim (
UINT32
EFIAPI
NetbufCopy (
- IN NET_BUF *Nbuf,
- IN UINT32 Offset,
- IN UINT32 Len,
- IN UINT8 *Dest
+ IN NET_BUF *Nbuf,
+ IN UINT32 Offset,
+ IN UINT32 Len,
+ IN UINT8 *Dest
);
/**
@@ -1921,12 +1910,12 @@ NetbufCopy (
NET_BUF *
EFIAPI
NetbufFromExt (
- IN NET_FRAGMENT *ExtFragment,
- IN UINT32 ExtNum,
- IN UINT32 HeadSpace,
- IN UINT32 HeadLen,
- IN NET_VECTOR_EXT_FREE ExtFree,
- IN VOID *Arg OPTIONAL
+ IN NET_FRAGMENT *ExtFragment,
+ IN UINT32 ExtNum,
+ IN UINT32 HeadSpace,
+ IN UINT32 HeadLen,
+ IN NET_VECTOR_EXT_FREE ExtFree,
+ IN VOID *Arg OPTIONAL
);
/**
@@ -1945,9 +1934,9 @@ NetbufFromExt (
EFI_STATUS
EFIAPI
NetbufBuildExt (
- IN NET_BUF *Nbuf,
- IN OUT NET_FRAGMENT *ExtFragment,
- IN OUT UINT32 *ExtNum
+ IN NET_BUF *Nbuf,
+ IN OUT NET_FRAGMENT *ExtFragment,
+ IN OUT UINT32 *ExtNum
);
/**
@@ -1970,11 +1959,11 @@ NetbufBuildExt (
NET_BUF *
EFIAPI
NetbufFromBufList (
- IN LIST_ENTRY *BufList,
- IN UINT32 HeadSpace,
- IN UINT32 HeaderLen,
- IN NET_VECTOR_EXT_FREE ExtFree,
- IN VOID *Arg OPTIONAL
+ IN LIST_ENTRY *BufList,
+ IN UINT32 HeadSpace,
+ IN UINT32 HeaderLen,
+ IN NET_VECTOR_EXT_FREE ExtFree,
+ IN VOID *Arg OPTIONAL
);
/**
@@ -1986,7 +1975,7 @@ NetbufFromBufList (
VOID
EFIAPI
NetbufFreeList (
- IN OUT LIST_ENTRY *Head
+ IN OUT LIST_ENTRY *Head
);
/**
@@ -1998,7 +1987,7 @@ NetbufFreeList (
VOID
EFIAPI
NetbufQueInit (
- IN OUT NET_BUF_QUEUE *NbufQue
+ IN OUT NET_BUF_QUEUE *NbufQue
);
/**
@@ -2027,7 +2016,7 @@ NetbufQueAlloc (
VOID
EFIAPI
NetbufQueFree (
- IN NET_BUF_QUEUE *NbufQue
+ IN NET_BUF_QUEUE *NbufQue
);
/**
@@ -2042,7 +2031,7 @@ NetbufQueFree (
NET_BUF *
EFIAPI
NetbufQueRemove (
- IN OUT NET_BUF_QUEUE *NbufQue
+ IN OUT NET_BUF_QUEUE *NbufQue
);
/**
@@ -2055,8 +2044,8 @@ NetbufQueRemove (
VOID
EFIAPI
NetbufQueAppend (
- IN OUT NET_BUF_QUEUE *NbufQue,
- IN OUT NET_BUF *Nbuf
+ IN OUT NET_BUF_QUEUE *NbufQue,
+ IN OUT NET_BUF *Nbuf
);
/**
@@ -2078,10 +2067,10 @@ NetbufQueAppend (
UINT32
EFIAPI
NetbufQueCopy (
- IN NET_BUF_QUEUE *NbufQue,
- IN UINT32 Offset,
- IN UINT32 Len,
- OUT UINT8 *Dest
+ IN NET_BUF_QUEUE *NbufQue,
+ IN UINT32 Offset,
+ IN UINT32 Len,
+ OUT UINT8 *Dest
);
/**
@@ -2100,11 +2089,10 @@ NetbufQueCopy (
UINT32
EFIAPI
NetbufQueTrim (
- IN OUT NET_BUF_QUEUE *NbufQue,
- IN UINT32 Len
+ IN OUT NET_BUF_QUEUE *NbufQue,
+ IN UINT32 Len
);
-
/**
Flush the net buffer queue.
@@ -2114,7 +2102,7 @@ NetbufQueTrim (
VOID
EFIAPI
NetbufQueFlush (
- IN OUT NET_BUF_QUEUE *NbufQue
+ IN OUT NET_BUF_QUEUE *NbufQue
);
/**
@@ -2129,8 +2117,8 @@ NetbufQueFlush (
UINT16
EFIAPI
NetblockChecksum (
- IN UINT8 *Bulk,
- IN UINT32 Len
+ IN UINT8 *Bulk,
+ IN UINT32 Len
);
/**
@@ -2145,8 +2133,8 @@ NetblockChecksum (
UINT16
EFIAPI
NetAddChecksum (
- IN UINT16 Checksum1,
- IN UINT16 Checksum2
+ IN UINT16 Checksum1,
+ IN UINT16 Checksum2
);
/**
@@ -2160,7 +2148,7 @@ NetAddChecksum (
UINT16
EFIAPI
NetbufChecksum (
- IN NET_BUF *Nbuf
+ IN NET_BUF *Nbuf
);
/**
@@ -2179,10 +2167,10 @@ NetbufChecksum (
UINT16
EFIAPI
NetPseudoHeadChecksum (
- IN IP4_ADDR Src,
- IN IP4_ADDR Dst,
- IN UINT8 Proto,
- IN UINT16 Len
+ IN IP4_ADDR Src,
+ IN IP4_ADDR Dst,
+ IN UINT8 Proto,
+ IN UINT16 Len
);
/**
@@ -2201,10 +2189,10 @@ NetPseudoHeadChecksum (
UINT16
EFIAPI
NetIp6PseudoHeadChecksum (
- IN EFI_IPv6_ADDRESS *Src,
- IN EFI_IPv6_ADDRESS *Dst,
- IN UINT8 NextHeader,
- IN UINT32 Len
+ IN EFI_IPv6_ADDRESS *Src,
+ IN EFI_IPv6_ADDRESS *Dst,
+ IN UINT8 NextHeader,
+ IN UINT32 Len
);
/**
@@ -2220,7 +2208,7 @@ NetIp6PseudoHeadChecksum (
**/
VOID
NetIpSecNetbufFree (
- NET_BUF *Nbuf
+ NET_BUF *Nbuf
);
/**
@@ -2237,7 +2225,7 @@ NetIpSecNetbufFree (
EFI_STATUS
EFIAPI
NetLibGetSystemGuid (
- OUT EFI_GUID *SystemGuid
+ OUT EFI_GUID *SystemGuid
);
/**
@@ -2260,7 +2248,7 @@ NetLibGetSystemGuid (
CHAR8 *
EFIAPI
NetLibCreateDnsQName (
- IN CHAR16 *DomainName
+ IN CHAR16 *DomainName
);
#endif
diff --git a/NetworkPkg/Ip4Dxe/Ip4Driver.c b/NetworkPkg/Ip4Dxe/Ip4Driver.c
index 7fed659ca1..ec483ff01f 100644
--- a/NetworkPkg/Ip4Dxe/Ip4Driver.c
+++ b/NetworkPkg/Ip4Dxe/Ip4Driver.c
@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Ip4Impl.h"
-EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding = {
Ip4DriverBindingSupported,
Ip4DriverBindingStart,
Ip4DriverBindingStop,
@@ -35,13 +35,14 @@ IpSec2InstalledCallback (
IN VOID *Context
)
{
- EFI_STATUS Status;
+ 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.
//
@@ -69,11 +70,11 @@ IpSec2InstalledCallback (
EFI_STATUS
EFIAPI
Ip4DriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- VOID *Registration;
+ VOID *Registration;
EfiCreateProtocolNotifyEvent (
&gEfiIpSec2ProtocolGuid,
@@ -114,12 +115,12 @@ Ip4DriverEntryPoint (
EFI_STATUS
EFIAPI
Ip4DriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Test for the MNP service binding Protocol
@@ -167,10 +168,9 @@ Ip4DriverBindingSupported (
**/
EFI_STATUS
Ip4CleanService (
- IN IP4_SERVICE *IpSb
+ IN IP4_SERVICE *IpSb
);
-
/**
Create a new IP4 driver service binding private instance.
@@ -187,13 +187,13 @@ Ip4CleanService (
**/
EFI_STATUS
Ip4CreateService (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE ImageHandle,
- OUT IP4_SERVICE **Service
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE ImageHandle,
+ OUT IP4_SERVICE **Service
)
{
- IP4_SERVICE *IpSb;
- EFI_STATUS Status;
+ IP4_SERVICE *IpSb;
+ EFI_STATUS Status;
ASSERT (Service != NULL);
@@ -215,23 +215,23 @@ Ip4CreateService (
IpSb->ServiceBinding.DestroyChild = Ip4ServiceBindingDestroyChild;
IpSb->State = IP4_SERVICE_UNSTARTED;
- IpSb->NumChildren = 0;
+ IpSb->NumChildren = 0;
InitializeListHead (&IpSb->Children);
InitializeListHead (&IpSb->Interfaces);
- IpSb->DefaultInterface = NULL;
- IpSb->DefaultRouteTable = NULL;
+ IpSb->DefaultInterface = NULL;
+ IpSb->DefaultRouteTable = NULL;
Ip4InitAssembleTable (&IpSb->Assemble);
- IpSb->IgmpCtrl.Igmpv1QuerySeen = 0;
+ IpSb->IgmpCtrl.Igmpv1QuerySeen = 0;
InitializeListHead (&IpSb->IgmpCtrl.Groups);
- IpSb->Image = ImageHandle;
- IpSb->Controller = Controller;
+ IpSb->Image = ImageHandle;
+ IpSb->Controller = Controller;
- IpSb->MnpChildHandle = NULL;
- IpSb->Mnp = NULL;
+ IpSb->MnpChildHandle = NULL;
+ IpSb->Mnp = NULL;
IpSb->MnpConfigData.ReceivedQueueTimeoutValue = 0;
IpSb->MnpConfigData.TransmitQueueTimeoutValue = 0;
@@ -246,7 +246,7 @@ Ip4CreateService (
ZeroMem (&IpSb->SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE));
- IpSb->Timer = NULL;
+ IpSb->Timer = NULL;
IpSb->ReconfigCheckTimer = NULL;
IpSb->ReconfigEvent = NULL;
@@ -316,7 +316,7 @@ Ip4CreateService (
Status = gBS->OpenProtocol (
IpSb->MnpChildHandle,
&gEfiManagedNetworkProtocolGuid,
- (VOID **) &IpSb->Mnp,
+ (VOID **)&IpSb->Mnp,
ImageHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -345,7 +345,7 @@ Ip4CreateService (
}
IpSb->MacString = NULL;
- Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);
+ Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
@@ -375,8 +375,9 @@ Ip4CreateService (
//
IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN;
}
+
IpSb->OldMaxPacketSize = IpSb->MaxPacketSize;
- *Service = IpSb;
+ *Service = IpSb;
return EFI_SUCCESS;
@@ -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
@@ -403,12 +403,12 @@ ON_ERROR:
**/
EFI_STATUS
Ip4CleanService (
- IN IP4_SERVICE *IpSb
+ IN IP4_SERVICE *IpSb
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- IpSb->State = IP4_SERVICE_DESTROY;
+ IpSb->State = IP4_SERVICE_DESTROY;
if (IpSb->Timer != NULL) {
gBS->SetTimer (IpSb->Timer, TimerCancel, 0);
@@ -493,8 +493,8 @@ Ip4CleanService (
EFI_STATUS
EFIAPI
Ip4DestroyChildEntryInHandleBuffer (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
IP4_PROTOCOL *IpInstance;
@@ -502,14 +502,14 @@ Ip4DestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
- if (Entry == NULL || Context == NULL) {
+ if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
- IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);
- ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
- NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
- ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
+ IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);
+ ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
+ NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
+ ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS;
@@ -544,11 +544,11 @@ Ip4DriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- IP4_SERVICE *IpSb;
- EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
- UINTN Index;
- IP4_CONFIG2_DATA_ITEM *DataItem;
+ EFI_STATUS Status;
+ IP4_SERVICE *IpSb;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
+ UINTN Index;
+ IP4_CONFIG2_DATA_ITEM *DataItem;
IpSb = NULL;
Ip4Cfg2 = NULL;
@@ -578,7 +578,7 @@ Ip4DriverBindingStart (
ASSERT (IpSb != NULL);
- Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2;
+ Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2;
//
// Install the Ip4ServiceBinding Protocol onto ControllerHandle
@@ -617,11 +617,11 @@ Ip4DriverBindingStart (
DataItem->DataSize,
DataItem->Data.Ptr
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto UNINSTALL_PROTOCOL;
}
- if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) {
+ if ((Index == Ip4Config2DataTypePolicy) && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) {
break;
}
}
@@ -634,7 +634,7 @@ Ip4DriverBindingStart (
//
Status = Ip4ReceiveFrame (IpSb->DefaultInterface, NULL, Ip4AccpetFrame, IpSb);
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
goto UNINSTALL_PROTOCOL;
}
@@ -673,7 +673,6 @@ FREE_SERVICE:
return Status;
}
-
/**
Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to
@@ -711,9 +710,9 @@ Ip4DriverBindingStop (
IP4_INTERFACE *IpIf;
IP4_ROUTE_TABLE *RouteTable;
- BOOLEAN IsDhcp4;
+ BOOLEAN IsDhcp4;
- IsDhcp4 = FALSE;
+ IsDhcp4 = FALSE;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
if (NicHandle == NULL) {
@@ -731,7 +730,7 @@ Ip4DriverBindingStop (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiIp4ServiceBindingProtocolGuid,
- (VOID **) &ServiceBinding,
+ (VOID **)&ServiceBinding,
This->DriverBindingHandle,
NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -747,18 +746,17 @@ Ip4DriverBindingStop (
gBS->CloseEvent (IpSb->Ip4Config2Instance.Dhcp4Event);
IpSb->Ip4Config2Instance.Dhcp4Event = NULL;
} else if (NumberOfChildren != 0) {
- List = &IpSb->Children;
+ List = &IpSb->Children;
Context.ServiceBinding = ServiceBinding;
Context.NumberOfChildren = NumberOfChildren;
Context.ChildHandleBuffer = ChildHandleBuffer;
- Status = NetDestroyLinkList (
- List,
- Ip4DestroyChildEntryInHandleBuffer,
- &Context,
- NULL
- );
+ Status = NetDestroyLinkList (
+ List,
+ Ip4DestroyChildEntryInHandleBuffer,
+ &Context,
+ 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,21 +770,21 @@ Ip4DriverBindingStop (
if (IpIf == NULL) {
goto ON_ERROR;
}
+
RouteTable = Ip4CreateRouteTable ();
if (RouteTable == NULL) {
Ip4FreeInterface (IpIf, NULL);
- goto ON_ERROR;;
+ goto ON_ERROR;
}
- IpSb->DefaultInterface = IpIf;
+ IpSb->DefaultInterface = IpIf;
InsertHeadList (&IpSb->Interfaces, &IpIf->Link);
IpSb->DefaultRouteTable = RouteTable;
Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
IpSb->State = IP4_SERVICE_UNSTARTED;
-
} else if (IsListEmpty (&IpSb->Children)) {
- State = IpSb->State;
+ State = IpSb->State;
//
// OK, clean other resources then uninstall the service binding protocol.
//
@@ -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.
@@ -843,11 +841,11 @@ Ip4ServiceBindingCreateChild (
IN OUT EFI_HANDLE *ChildHandle
)
{
- IP4_SERVICE *IpSb;
- IP4_PROTOCOL *IpInstance;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- VOID *Mnp;
+ IP4_SERVICE *IpSb;
+ IP4_PROTOCOL *IpInstance;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ VOID *Mnp;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -884,7 +882,7 @@ Ip4ServiceBindingCreateChild (
Status = gBS->OpenProtocol (
IpSb->MnpChildHandle,
&gEfiManagedNetworkProtocolGuid,
- (VOID **) &Mnp,
+ (VOID **)&Mnp,
gIp4DriverBinding.DriverBindingHandle,
IpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -913,7 +911,6 @@ Ip4ServiceBindingCreateChild (
ON_ERROR:
if (EFI_ERROR (Status)) {
-
Ip4CleanProtocol (IpInstance);
FreePool (IpInstance);
@@ -922,7 +919,6 @@ ON_ERROR:
return Status;
}
-
/**
Destroys a child handle with a protocol installed on it.
@@ -948,11 +944,11 @@ Ip4ServiceBindingDestroyChild (
IN EFI_HANDLE ChildHandle
)
{
- EFI_STATUS Status;
- IP4_SERVICE *IpSb;
- IP4_PROTOCOL *IpInstance;
- EFI_IP4_PROTOCOL *Ip4;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ IP4_SERVICE *IpSb;
+ IP4_PROTOCOL *IpInstance;
+ EFI_IP4_PROTOCOL *Ip4;
+ EFI_TPL OldTpl;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -961,12 +957,12 @@ Ip4ServiceBindingDestroyChild (
//
// Retrieve the private context data structures
//
- IpSb = IP4_SERVICE_FROM_PROTOCOL (This);
+ IpSb = IP4_SERVICE_FROM_PROTOCOL (This);
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiIp4ProtocolGuid,
- (VOID **) &Ip4,
+ (VOID **)&Ip4,
gIp4DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1007,7 +1003,7 @@ Ip4ServiceBindingDestroyChild (
ChildHandle
);
- if (IpInstance->Interface != NULL && IpInstance->Interface->Arp != NULL) {
+ if ((IpInstance->Interface != NULL) && (IpInstance->Interface->Arp != NULL)) {
gBS->CloseProtocol (
IpInstance->Interface->ArpHandle,
&gEfiArpProtocolGuid,
diff --git a/NetworkPkg/Ip6Dxe/Ip6If.c b/NetworkPkg/Ip6Dxe/Ip6If.c
index 5b46971057..4629c05f25 100644
--- a/NetworkPkg/Ip6Dxe/Ip6If.c
+++ b/NetworkPkg/Ip6Dxe/Ip6If.c
@@ -19,8 +19,8 @@
VOID
EFIAPI
Ip6OnFrameSent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -37,11 +37,11 @@ Ip6OnFrameSent (
**/
BOOLEAN
Ip6CancelInstanceFrame (
- IN IP6_LINK_TX_TOKEN *Frame,
- IN VOID *Context
+ IN IP6_LINK_TX_TOKEN *Frame,
+ IN VOID *Context
)
{
- if (Frame->IpInstance == (IP6_PROTOCOL *) Context) {
+ if (Frame->IpInstance == (IP6_PROTOCOL *)Context) {
return TRUE;
}
@@ -73,14 +73,14 @@ Ip6CancelInstanceFrame (
**/
EFI_STATUS
Ip6SetAddress (
- IN IP6_INTERFACE *Interface,
- IN EFI_IPv6_ADDRESS *Ip6Addr,
- IN BOOLEAN IsAnycast,
- IN UINT8 PrefixLength,
- IN UINT32 ValidLifetime,
- IN UINT32 PreferredLifetime,
- IN IP6_DAD_CALLBACK DadCallback OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_INTERFACE *Interface,
+ IN EFI_IPv6_ADDRESS *Ip6Addr,
+ IN BOOLEAN IsAnycast,
+ IN UINT8 PrefixLength,
+ IN UINT32 ValidLifetime,
+ IN UINT32 PreferredLifetime,
+ IN IP6_DAD_CALLBACK DadCallback OPTIONAL,
+ IN VOID *Context OPTIONAL
)
{
IP6_SERVICE *IpSb;
@@ -109,12 +109,12 @@ Ip6SetAddress (
return EFI_SUCCESS;
}
- AddressInfo = (IP6_ADDRESS_INFO *) AllocatePool (sizeof (IP6_ADDRESS_INFO));
+ AddressInfo = (IP6_ADDRESS_INFO *)AllocatePool (sizeof (IP6_ADDRESS_INFO));
if (AddressInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- AddressInfo->Signature = IP6_ADDR_INFO_SIGNATURE;
+ AddressInfo->Signature = IP6_ADDR_INFO_SIGNATURE;
IP6_COPY_ADDRESS (&AddressInfo->Address, Ip6Addr);
AddressInfo->IsAnycast = IsAnycast;
AddressInfo->PrefixLength = PrefixLength;
@@ -158,24 +158,23 @@ Ip6SetAddress (
AddressInfo->PrefixLength = IP6_LINK_LOCAL_PREFIX_LENGTH;
}
-
//
// Node should delay joining the solicited-node multicast address by a random delay
// between 0 and MAX_RTR_SOLICITATION_DELAY (1 second).
// Thus queue the address to be processed in Duplicate Address Detection module
// after the delay time (in milliseconds).
//
- Delay = (UINT64) NET_RANDOM (NetRandomInitSeed ());
+ Delay = (UINT64)NET_RANDOM (NetRandomInitSeed ());
Delay = MultU64x32 (Delay, IP6_ONE_SECOND_IN_MS);
Delay = RShiftU64 (Delay, 32);
- DelayNode = (IP6_DELAY_JOIN_LIST *) AllocatePool (sizeof (IP6_DELAY_JOIN_LIST));
+ DelayNode = (IP6_DELAY_JOIN_LIST *)AllocatePool (sizeof (IP6_DELAY_JOIN_LIST));
if (DelayNode == NULL) {
FreePool (AddressInfo);
return EFI_OUT_OF_RESOURCES;
}
- DelayNode->DelayTime = (UINT32) (DivU64x32 (Delay, IP6_TIMER_INTERVAL_IN_MS));
+ DelayNode->DelayTime = (UINT32)(DivU64x32 (Delay, IP6_TIMER_INTERVAL_IN_MS));
DelayNode->Interface = Interface;
DelayNode->AddressInfo = AddressInfo;
DelayNode->DadCallback = DadCallback;
@@ -197,13 +196,13 @@ Ip6SetAddress (
**/
IP6_INTERFACE *
Ip6CreateInterface (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN LinkLocal
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN LinkLocal
)
{
- EFI_STATUS Status;
- IP6_INTERFACE *Interface;
- EFI_IPv6_ADDRESS *Ip6Addr;
+ EFI_STATUS Status;
+ IP6_INTERFACE *Interface;
+ EFI_IPv6_ADDRESS *Ip6Addr;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -212,27 +211,27 @@ Ip6CreateInterface (
return NULL;
}
- Interface->Signature = IP6_INTERFACE_SIGNATURE;
- Interface->RefCnt = 1;
+ Interface->Signature = IP6_INTERFACE_SIGNATURE;
+ Interface->RefCnt = 1;
InitializeListHead (&Interface->AddressList);
- Interface->AddressCount = 0;
- Interface->Configured = FALSE;
+ Interface->AddressCount = 0;
+ Interface->Configured = FALSE;
- Interface->Service = IpSb;
- Interface->Controller = IpSb->Controller;
- Interface->Image = IpSb->Image;
+ Interface->Service = IpSb;
+ Interface->Controller = IpSb->Controller;
+ Interface->Image = IpSb->Image;
InitializeListHead (&Interface->ArpQues);
InitializeListHead (&Interface->SentFrames);
- Interface->DupAddrDetect = IpSb->Ip6ConfigInstance.DadXmits.DupAddrDetectTransmits;
+ Interface->DupAddrDetect = IpSb->Ip6ConfigInstance.DadXmits.DupAddrDetectTransmits;
InitializeListHead (&Interface->DupAddrDetectList);
InitializeListHead (&Interface->DelayJoinList);
InitializeListHead (&Interface->IpInstances);
- Interface->PromiscRecv = FALSE;
+ Interface->PromiscRecv = FALSE;
if (!LinkLocal) {
return Interface;
@@ -254,8 +253,8 @@ Ip6CreateInterface (
Ip6Addr,
FALSE,
IP6_LINK_LOCAL_PREFIX_LENGTH,
- (UINT32) IP6_INFINIT_LIFETIME,
- (UINT32) IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
NULL,
NULL
);
@@ -288,12 +287,12 @@ ON_ERROR:
**/
VOID
Ip6CleanInterface (
- IN IP6_INTERFACE *Interface,
- IN IP6_PROTOCOL *IpInstance OPTIONAL
+ IN IP6_INTERFACE *Interface,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL
)
{
- IP6_DAD_ENTRY *Duplicate;
- IP6_DELAY_JOIN_LIST *Delay;
+ IP6_DAD_ENTRY *Duplicate;
+ IP6_DELAY_JOIN_LIST *Delay;
NET_CHECK_SIGNATURE (Interface, IP6_INTERFACE_SIGNATURE);
ASSERT (Interface->RefCnt > 0);
@@ -352,11 +351,11 @@ Ip6CleanInterface (
**/
IP6_LINK_TX_TOKEN *
Ip6CreateLinkTxToken (
- IN IP6_INTERFACE *Interface,
- IN IP6_PROTOCOL *IpInstance OPTIONAL,
- IN NET_BUF *Packet,
- IN IP6_FRAME_CALLBACK CallBack,
- IN VOID *Context
+ IN IP6_INTERFACE *Interface,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL,
+ IN NET_BUF *Packet,
+ IN IP6_FRAME_CALLBACK CallBack,
+ IN VOID *Context
)
{
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken;
@@ -381,8 +380,8 @@ Ip6CreateLinkTxToken (
ZeroMem (&Token->DstMac, sizeof (EFI_MAC_ADDRESS));
IP6_COPY_LINK_ADDRESS (&Token->SrcMac, &Interface->Service->SnpMode.CurrentAddress);
- MnpToken = &(Token->MnpToken);
- MnpToken->Status = EFI_NOT_READY;
+ MnpToken = &(Token->MnpToken);
+ MnpToken->Status = EFI_NOT_READY;
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
@@ -397,8 +396,8 @@ Ip6CreateLinkTxToken (
return NULL;
}
- MnpTxData = &Token->MnpTxData;
- MnpToken->Packet.TxData = MnpTxData;
+ MnpTxData = &Token->MnpTxData;
+ MnpToken->Packet.TxData = MnpTxData;
MnpTxData->DestinationAddress = &Token->DstMac;
MnpTxData->SourceAddress = &Token->SrcMac;
@@ -406,10 +405,10 @@ Ip6CreateLinkTxToken (
MnpTxData->DataLength = Packet->TotalSize;
MnpTxData->HeaderLength = 0;
- Count = Packet->BlockOpNum;
+ Count = Packet->BlockOpNum;
- NetbufBuildExt (Packet, (NET_FRAGMENT *) MnpTxData->FragmentTable, &Count);
- MnpTxData->FragmentCount = (UINT16)Count;
+ NetbufBuildExt (Packet, (NET_FRAGMENT *)MnpTxData->FragmentTable, &Count);
+ MnpTxData->FragmentCount = (UINT16)Count;
return Token;
}
@@ -423,7 +422,7 @@ Ip6CreateLinkTxToken (
**/
VOID
Ip6FreeLinkTxToken (
- IN IP6_LINK_TX_TOKEN *Token
+ IN IP6_LINK_TX_TOKEN *Token
)
{
NET_CHECK_SIGNATURE (Token, IP6_LINK_TX_SIGNATURE);
@@ -442,12 +441,12 @@ Ip6FreeLinkTxToken (
VOID
EFIAPI
Ip6RecycleFrame (
- IN VOID *Context
+ IN VOID *Context
)
{
EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData;
- RxData = (EFI_MANAGED_NETWORK_RECEIVE_DATA *) Context;
+ RxData = (EFI_MANAGED_NETWORK_RECEIVE_DATA *)Context;
gBS->SignalEvent (RxData->RecycleEvent);
}
@@ -466,7 +465,7 @@ Ip6RecycleFrame (
VOID
EFIAPI
Ip6OnFrameReceivedDpc (
- IN VOID *Context
+ IN VOID *Context
)
{
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken;
@@ -477,23 +476,22 @@ Ip6OnFrameReceivedDpc (
UINT32 Flag;
IP6_SERVICE *IpSb;
- Token = (IP6_LINK_RX_TOKEN *) Context;
+ Token = (IP6_LINK_RX_TOKEN *)Context;
NET_CHECK_SIGNATURE (Token, IP6_LINK_RX_SIGNATURE);
//
// First clear the interface's receive request in case the
// caller wants to call Ip6ReceiveFrame in the callback.
//
- IpSb = (IP6_SERVICE *) Token->Context;
+ IpSb = (IP6_SERVICE *)Token->Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
-
MnpToken = &Token->MnpToken;
MnpRxData = MnpToken->Packet.RxData;
if (EFI_ERROR (MnpToken->Status) || (MnpRxData == NULL)) {
Token->CallBack (NULL, MnpToken->Status, 0, Token->Context);
- return ;
+ return;
}
//
@@ -510,7 +508,7 @@ Ip6OnFrameReceivedDpc (
Token->CallBack (NULL, EFI_OUT_OF_RESOURCES, 0, Token->Context);
- return ;
+ return;
}
Flag = (MnpRxData->BroadcastFlag ? IP6_LINK_BROADCAST : 0);
@@ -530,8 +528,8 @@ Ip6OnFrameReceivedDpc (
VOID
EFIAPI
Ip6OnFrameReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -553,18 +551,18 @@ Ip6OnFrameReceived (
**/
EFI_STATUS
Ip6ReceiveFrame (
- IN IP6_FRAME_CALLBACK CallBack,
- IN IP6_SERVICE *IpSb
+ IN IP6_FRAME_CALLBACK CallBack,
+ IN IP6_SERVICE *IpSb
)
{
- EFI_STATUS Status;
- IP6_LINK_RX_TOKEN *Token;
+ EFI_STATUS Status;
+ IP6_LINK_RX_TOKEN *Token;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
Token = &IpSb->RecvRequest;
Token->CallBack = CallBack;
- Token->Context = (VOID *) IpSb;
+ Token->Context = (VOID *)IpSb;
Status = IpSb->Mnp->Receive (IpSb->Mnp, &Token->MnpToken);
if (EFI_ERROR (Status)) {
@@ -584,22 +582,22 @@ Ip6ReceiveFrame (
VOID
EFIAPI
Ip6OnFrameSentDpc (
- IN VOID *Context
+ IN VOID *Context
)
{
- IP6_LINK_TX_TOKEN *Token;
+ IP6_LINK_TX_TOKEN *Token;
- Token = (IP6_LINK_TX_TOKEN *) Context;
+ Token = (IP6_LINK_TX_TOKEN *)Context;
NET_CHECK_SIGNATURE (Token, IP6_LINK_TX_SIGNATURE);
RemoveEntryList (&Token->Link);
Token->CallBack (
- Token->Packet,
- Token->MnpToken.Status,
- 0,
- Token->Context
- );
+ Token->Packet,
+ Token->MnpToken.Status,
+ 0,
+ Token->Context
+ );
Ip6FreeLinkTxToken (Token);
}
@@ -614,8 +612,8 @@ Ip6OnFrameSentDpc (
VOID
EFIAPI
Ip6OnFrameSent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -646,20 +644,20 @@ Ip6OnFrameSent (
**/
EFI_STATUS
Ip6SendFrame (
- IN IP6_INTERFACE *Interface,
- IN IP6_PROTOCOL *IpInstance OPTIONAL,
- IN NET_BUF *Packet,
- IN EFI_IPv6_ADDRESS *NextHop,
- IN IP6_FRAME_CALLBACK CallBack,
- IN VOID *Context
+ IN IP6_INTERFACE *Interface,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL,
+ IN NET_BUF *Packet,
+ IN EFI_IPv6_ADDRESS *NextHop,
+ IN IP6_FRAME_CALLBACK CallBack,
+ IN VOID *Context
)
{
- IP6_SERVICE *IpSb;
- IP6_LINK_TX_TOKEN *Token;
- EFI_STATUS Status;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- LIST_ENTRY *Entry;
- IP6_NEIGHBOR_ENTRY *ArpQue;
+ IP6_SERVICE *IpSb;
+ IP6_LINK_TX_TOKEN *Token;
+ EFI_STATUS Status;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ LIST_ENTRY *Entry;
+ IP6_NEIGHBOR_ENTRY *ArpQue;
IpSb = Interface->Service;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -706,21 +704,21 @@ Ip6SendFrame (
}
switch (NeighborCache->State) {
- case EfiNeighborStale:
- NeighborCache->State = EfiNeighborDelay;
- NeighborCache->Ticks = (UINT32) IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME);
+ case EfiNeighborStale:
+ NeighborCache->State = EfiNeighborDelay;
+ NeighborCache->Ticks = (UINT32)IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME);
//
// Fall through
//
- case EfiNeighborReachable:
- case EfiNeighborDelay:
- case EfiNeighborProbe:
- IP6_COPY_LINK_ADDRESS (&Token->DstMac, &NeighborCache->LinkAddress);
- goto SendNow;
- break;
-
- default:
- break;
+ case EfiNeighborReachable:
+ case EfiNeighborDelay:
+ case EfiNeighborProbe:
+ IP6_COPY_LINK_ADDRESS (&Token->DstMac, &NeighborCache->LinkAddress);
+ goto SendNow;
+ break;
+
+ default:
+ break;
}
//
@@ -747,7 +745,7 @@ Ip6SendFrame (
return EFI_SUCCESS;
SendNow:
- //
+ //
// Insert the tx token into the SentFrames list before calling Mnp->Transmit.
// Remove it if the returned status is not EFI_SUCCESS.
//
@@ -777,13 +775,13 @@ Error:
VOID
EFIAPI
Ip6TimerTicking (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- IP6_SERVICE *IpSb;
+ IP6_SERVICE *IpSb;
- IpSb = (IP6_SERVICE *) Context;
+ IpSb = (IP6_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
Ip6PacketTimerTicking (IpSb);
diff --git a/NetworkPkg/Ip6Dxe/Ip6Mld.c b/NetworkPkg/Ip6Dxe/Ip6Mld.c
index ba12089dee..e6b2b653e2 100644
--- a/NetworkPkg/Ip6Dxe/Ip6Mld.c
+++ b/NetworkPkg/Ip6Dxe/Ip6Mld.c
@@ -21,12 +21,12 @@
**/
IP6_MLD_GROUP *
Ip6CreateMldEntry (
- IN OUT IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *MulticastAddr,
- IN UINT32 DelayTimer
+ IN OUT IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *MulticastAddr,
+ IN UINT32 DelayTimer
)
{
- IP6_MLD_GROUP *Entry;
+ IP6_MLD_GROUP *Entry;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr));
@@ -54,12 +54,12 @@ Ip6CreateMldEntry (
**/
IP6_MLD_GROUP *
Ip6FindMldEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *MulticastAddr
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *MulticastAddr
)
{
- LIST_ENTRY *Entry;
- IP6_MLD_GROUP *Group;
+ LIST_ENTRY *Entry;
+ IP6_MLD_GROUP *Group;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr));
@@ -88,13 +88,13 @@ Ip6FindMldEntry (
**/
INTN
Ip6FindMac (
- IN IP6_MLD_SERVICE_DATA *MldCtrl,
- IN EFI_MAC_ADDRESS *Mac
+ IN IP6_MLD_SERVICE_DATA *MldCtrl,
+ IN EFI_MAC_ADDRESS *Mac
)
{
- LIST_ENTRY *Entry;
- IP6_MLD_GROUP *Group;
- INTN Count;
+ LIST_ENTRY *Entry;
+ IP6_MLD_GROUP *Group;
+ INTN Count;
Count = 0;
@@ -125,20 +125,20 @@ Ip6FindMac (
**/
EFI_STATUS
Ip6SendMldReport (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface OPTIONAL,
- IN EFI_IPv6_ADDRESS *MulticastAddr
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface OPTIONAL,
+ IN EFI_IPv6_ADDRESS *MulticastAddr
)
{
- IP6_MLD_HEAD *MldHead;
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- UINT16 PayloadLen;
- UINTN OptionLen;
- UINT8 *Options;
- EFI_STATUS Status;
- UINT16 HeadChecksum;
- UINT16 PseudoChecksum;
+ IP6_MLD_HEAD *MldHead;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ UINT16 PayloadLen;
+ UINTN OptionLen;
+ UINT8 *Options;
+ EFI_STATUS Status;
+ UINT16 HeadChecksum;
+ UINT16 PseudoChecksum;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr));
@@ -149,11 +149,11 @@ Ip6SendMldReport (
//
OptionLen = 0;
- Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP);
+ Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP);
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
- PayloadLen = (UINT16) (OptionLen + sizeof (IP6_MLD_HEAD));
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ PayloadLen = (UINT16)(OptionLen + sizeof (IP6_MLD_HEAD));
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -163,11 +163,11 @@ Ip6SendMldReport (
// RFC3590: Use link-local address as source address if it is available,
// otherwise use the unspecified address.
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_HOP_BY_HOP;
- Head.HopLimit = 1;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_HOP_BY_HOP;
+ Head.HopLimit = 1;
IP6_COPY_ADDRESS (&Head.DestinationAddress, MulticastAddr);
//
@@ -180,7 +180,7 @@ Ip6SendMldReport (
//
// Fill a IPv6 Router Alert option in a Hop-by-Hop Options Header
//
- Options = NetbufAllocSpace (Packet, (UINT32) OptionLen, FALSE);
+ Options = NetbufAllocSpace (Packet, (UINT32)OptionLen, FALSE);
ASSERT (Options != NULL);
Status = Ip6FillHopByHop (Options, &OptionLen, IP6_ICMP);
if (EFI_ERROR (Status)) {
@@ -192,14 +192,14 @@ Ip6SendMldReport (
//
// Fill in MLD message - Report
//
- MldHead = (IP6_MLD_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE);
+ MldHead = (IP6_MLD_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE);
ASSERT (MldHead != NULL);
ZeroMem (MldHead, sizeof (IP6_MLD_HEAD));
MldHead->Head.Type = ICMP_V6_LISTENER_REPORT;
MldHead->Head.Code = 0;
IP6_COPY_ADDRESS (&MldHead->Group, MulticastAddr);
- HeadChecksum = NetblockChecksum ((UINT8 *) MldHead, sizeof (IP6_MLD_HEAD));
+ HeadChecksum = NetblockChecksum ((UINT8 *)MldHead, sizeof (IP6_MLD_HEAD));
PseudoChecksum = NetIp6PseudoHeadChecksum (
&Head.SourceAddress,
&Head.DestinationAddress,
@@ -229,20 +229,20 @@ Ip6SendMldReport (
**/
EFI_STATUS
Ip6SendMldDone (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *MulticastAddr
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *MulticastAddr
)
{
- IP6_MLD_HEAD *MldHead;
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- UINT16 PayloadLen;
- UINTN OptionLen;
- UINT8 *Options;
- EFI_STATUS Status;
- EFI_IPv6_ADDRESS Destination;
- UINT16 HeadChecksum;
- UINT16 PseudoChecksum;
+ IP6_MLD_HEAD *MldHead;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ UINT16 PayloadLen;
+ UINTN OptionLen;
+ UINT8 *Options;
+ EFI_STATUS Status;
+ EFI_IPv6_ADDRESS Destination;
+ UINT16 HeadChecksum;
+ UINT16 PseudoChecksum;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr));
@@ -253,11 +253,11 @@ Ip6SendMldDone (
//
OptionLen = 0;
- Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP);
+ Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP);
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
- PayloadLen = (UINT16) (OptionLen + sizeof (IP6_MLD_HEAD));
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ PayloadLen = (UINT16)(OptionLen + sizeof (IP6_MLD_HEAD));
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -265,11 +265,11 @@ Ip6SendMldDone (
//
// Create the basic IPv6 header.
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_HOP_BY_HOP;
- Head.HopLimit = 1;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_HOP_BY_HOP;
+ Head.HopLimit = 1;
//
// If Link-Local address is not ready, we use unspecified address.
@@ -284,7 +284,7 @@ Ip6SendMldDone (
//
// Fill a IPv6 Router Alert option in a Hop-by-Hop Options Header
//
- Options = NetbufAllocSpace (Packet, (UINT32) OptionLen, FALSE);
+ Options = NetbufAllocSpace (Packet, (UINT32)OptionLen, FALSE);
ASSERT (Options != NULL);
Status = Ip6FillHopByHop (Options, &OptionLen, IP6_ICMP);
if (EFI_ERROR (Status)) {
@@ -296,14 +296,14 @@ Ip6SendMldDone (
//
// Fill in MLD message - Done
//
- MldHead = (IP6_MLD_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE);
+ MldHead = (IP6_MLD_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE);
ASSERT (MldHead != NULL);
ZeroMem (MldHead, sizeof (IP6_MLD_HEAD));
MldHead->Head.Type = ICMP_V6_LISTENER_DONE;
MldHead->Head.Code = 0;
IP6_COPY_ADDRESS (&MldHead->Group, MulticastAddr);
- HeadChecksum = NetblockChecksum ((UINT8 *) MldHead, sizeof (IP6_MLD_HEAD));
+ HeadChecksum = NetblockChecksum ((UINT8 *)MldHead, sizeof (IP6_MLD_HEAD));
PseudoChecksum = NetIp6PseudoHeadChecksum (
&Head.SourceAddress,
&Head.DestinationAddress,
@@ -332,12 +332,12 @@ Ip6SendMldDone (
**/
EFI_STATUS
Ip6InitMld (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- EFI_IPv6_ADDRESS AllNodes;
- IP6_MLD_GROUP *Group;
- EFI_STATUS Status;
+ EFI_IPv6_ADDRESS AllNodes;
+ IP6_MLD_GROUP *Group;
+ EFI_STATUS Status;
//
// Join the link-scope all-nodes multicast address (FF02::1).
@@ -347,7 +347,7 @@ Ip6InitMld (
Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
- Group = Ip6CreateMldEntry (IpSb, &AllNodes, (UINT32) IP6_INFINIT_LIFETIME);
+ Group = Ip6CreateMldEntry (IpSb, &AllNodes, (UINT32)IP6_INFINIT_LIFETIME);
if (Group == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -388,11 +388,11 @@ ERROR:
**/
EFI_STATUS
Ip6CombineGroups (
- IN OUT IP6_PROTOCOL *IpInstance,
- IN EFI_IPv6_ADDRESS *Group
+ IN OUT IP6_PROTOCOL *IpInstance,
+ IN EFI_IPv6_ADDRESS *Group
)
{
- EFI_IPv6_ADDRESS *GroupList;
+ EFI_IPv6_ADDRESS *GroupList;
NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE);
ASSERT (Group != NULL && IP6_IS_MULTICAST (Group));
@@ -437,12 +437,12 @@ Ip6CombineGroups (
**/
EFI_STATUS
Ip6RemoveGroup (
- IN OUT IP6_PROTOCOL *IpInstance,
- IN EFI_IPv6_ADDRESS *Group
+ IN OUT IP6_PROTOCOL *IpInstance,
+ IN EFI_IPv6_ADDRESS *Group
)
{
- UINT32 Index;
- UINT32 Count;
+ UINT32 Index;
+ UINT32 Count;
Count = IpInstance->GroupCount;
@@ -481,13 +481,13 @@ Ip6RemoveGroup (
**/
EFI_STATUS
Ip6JoinGroup (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface,
- IN EFI_IPv6_ADDRESS *Address
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface,
+ IN EFI_IPv6_ADDRESS *Address
)
{
- IP6_MLD_GROUP *Group;
- EFI_STATUS Status;
+ IP6_MLD_GROUP *Group;
+ EFI_STATUS Status;
Group = Ip6FindMldEntry (IpSb, Address);
if (Group != NULL) {
@@ -545,12 +545,12 @@ ERROR:
**/
EFI_STATUS
Ip6LeaveGroup (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Address
)
{
- IP6_MLD_GROUP *Group;
- EFI_STATUS Status;
+ IP6_MLD_GROUP *Group;
+ EFI_STATUS Status;
Group = Ip6FindMldEntry (IpSb, Address);
if (Group == NULL) {
@@ -611,15 +611,15 @@ Ip6LeaveGroup (
**/
EFI_STATUS
Ip6Groups (
- IN IP6_PROTOCOL *IpInstance,
- IN BOOLEAN JoinFlag,
- IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
+ IN IP6_PROTOCOL *IpInstance,
+ IN BOOLEAN JoinFlag,
+ IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
)
{
- EFI_STATUS Status;
- IP6_SERVICE *IpSb;
- UINT32 Index;
- EFI_IPv6_ADDRESS *Group;
+ EFI_STATUS Status;
+ IP6_SERVICE *IpSb;
+ UINT32 Index;
+ EFI_IPv6_ADDRESS *Group;
IpSb = IpInstance->Service;
@@ -690,13 +690,13 @@ Ip6Groups (
**/
EFI_STATUS
Ip6UpdateDelayTimer (
- IN IP6_SERVICE *IpSb,
- IN UINT16 MaxRespDelay,
- IN EFI_IPv6_ADDRESS *MulticastAddr,
- IN OUT IP6_MLD_GROUP *Group
+ IN IP6_SERVICE *IpSb,
+ IN UINT16 MaxRespDelay,
+ IN EFI_IPv6_ADDRESS *MulticastAddr,
+ IN OUT IP6_MLD_GROUP *Group
)
{
- UINT32 Delay;
+ UINT32 Delay;
//
// If the Query packet specifies a Maximum Response Delay of zero, perform timer
@@ -707,14 +707,14 @@ Ip6UpdateDelayTimer (
return Ip6SendMldReport (IpSb, NULL, MulticastAddr);
}
- Delay = (UINT32) (MaxRespDelay / 1000);
+ Delay = (UINT32)(MaxRespDelay / 1000);
//
// Sets a delay timer to a random value selected from the range [0, Maximum Response Delay]
// If a timer is already running, resets it if the request Maximum Response Delay
// is less than the remaining value of the running timer.
//
- if (Group->DelayTimer == 0 || Delay < Group->DelayTimer) {
+ if ((Group->DelayTimer == 0) || (Delay < Group->DelayTimer)) {
Group->DelayTimer = Delay / 4294967295UL * NET_RANDOM (NetRandomInitSeed ());
}
@@ -736,16 +736,16 @@ Ip6UpdateDelayTimer (
**/
EFI_STATUS
Ip6ProcessMldQuery (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- EFI_IPv6_ADDRESS AllNodes;
- IP6_MLD_GROUP *Group;
- IP6_MLD_HEAD MldPacket;
- LIST_ENTRY *Entry;
- EFI_STATUS Status;
+ EFI_IPv6_ADDRESS AllNodes;
+ IP6_MLD_GROUP *Group;
+ IP6_MLD_HEAD MldPacket;
+ LIST_ENTRY *Entry;
+ EFI_STATUS Status;
Status = EFI_INVALID_PARAMETER;
@@ -756,14 +756,14 @@ Ip6ProcessMldQuery (
goto Exit;
}
- if (Head->HopLimit != 1 || !IP6_IS_MULTICAST (&Head->DestinationAddress)) {
+ if ((Head->HopLimit != 1) || !IP6_IS_MULTICAST (&Head->DestinationAddress)) {
goto Exit;
}
//
// The Packet points to MLD report raw data without Hop-By-Hop option.
//
- NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *) &MldPacket);
+ NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *)&MldPacket);
MldPacket.MaxRespDelay = NTOHS (MldPacket.MaxRespDelay);
Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
@@ -774,6 +774,7 @@ Ip6ProcessMldQuery (
if (!EFI_IP6_EQUAL (&Head->DestinationAddress, &MldPacket.Group)) {
goto Exit;
}
+
//
// The node is not listening but it receives the specific query. Just return.
//
@@ -824,14 +825,14 @@ Exit:
**/
EFI_STATUS
Ip6ProcessMldReport (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_MLD_HEAD MldPacket;
- IP6_MLD_GROUP *Group;
- EFI_STATUS Status;
+ IP6_MLD_HEAD MldPacket;
+ IP6_MLD_GROUP *Group;
+ EFI_STATUS Status;
Status = EFI_INVALID_PARAMETER;
@@ -842,14 +843,14 @@ Ip6ProcessMldReport (
goto Exit;
}
- if (Head->HopLimit != 1 || !IP6_IS_MULTICAST (&Head->DestinationAddress)) {
+ if ((Head->HopLimit != 1) || !IP6_IS_MULTICAST (&Head->DestinationAddress)) {
goto Exit;
}
//
// The Packet points to MLD report raw data without Hop-By-Hop option.
//
- NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *) &MldPacket);
+ NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *)&MldPacket);
if (!EFI_IP6_EQUAL (&Head->DestinationAddress, &MldPacket.Group)) {
goto Exit;
}
@@ -883,11 +884,11 @@ Exit:
**/
VOID
Ip6MldTimerTicking (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- IP6_MLD_GROUP *Group;
- LIST_ENTRY *Entry;
+ IP6_MLD_GROUP *Group;
+ LIST_ENTRY *Entry;
//
// Send solicited report when timer expires
@@ -899,4 +900,3 @@ Ip6MldTimerTicking (
}
}
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.c b/NetworkPkg/Ip6Dxe/Ip6Nd.c
index 0780a98cb3..c10c7017f8 100644
--- a/NetworkPkg/Ip6Dxe/Ip6Nd.c
+++ b/NetworkPkg/Ip6Dxe/Ip6Nd.c
@@ -9,7 +9,7 @@
#include "Ip6Impl.h"
-EFI_MAC_ADDRESS mZeroMacAddress;
+EFI_MAC_ADDRESS mZeroMacAddress;
/**
Update the ReachableTime in IP6 service binding instance data, in milliseconds.
@@ -22,10 +22,10 @@ Ip6UpdateReachableTime (
IN OUT IP6_SERVICE *IpSb
)
{
- UINT32 Random;
+ UINT32 Random;
- Random = (NetRandomInitSeed () / 4294967295UL) * IP6_RANDOM_FACTOR_SCALE;
- Random = Random + IP6_MIN_RANDOM_FACTOR_SCALED;
+ Random = (NetRandomInitSeed () / 4294967295UL) * IP6_RANDOM_FACTOR_SCALE;
+ Random = Random + IP6_MIN_RANDOM_FACTOR_SCALED;
IpSb->ReachableTime = (IpSb->BaseReachableTime * Random) / IP6_RANDOM_FACTOR_SCALE;
}
@@ -43,17 +43,17 @@ Ip6UpdateReachableTime (
**/
EFI_STATUS
Ip6BuildEfiNeighborCache (
- IN IP6_PROTOCOL *IpInstance,
- OUT UINT32 *NeighborCount,
- OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache
+ IN IP6_PROTOCOL *IpInstance,
+ OUT UINT32 *NeighborCount,
+ OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache
)
{
- IP6_NEIGHBOR_ENTRY *Neighbor;
- LIST_ENTRY *Entry;
- IP6_SERVICE *IpSb;
- UINT32 Count;
- EFI_IP6_NEIGHBOR_CACHE *EfiNeighborCache;
- EFI_IP6_NEIGHBOR_CACHE *NeighborCacheTmp;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
+ LIST_ENTRY *Entry;
+ IP6_SERVICE *IpSb;
+ UINT32 Count;
+ EFI_IP6_NEIGHBOR_CACHE *EfiNeighborCache;
+ EFI_IP6_NEIGHBOR_CACHE *NeighborCacheTmp;
NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE);
ASSERT (NeighborCount != NULL && NeighborCache != NULL);
@@ -82,7 +82,7 @@ Ip6BuildEfiNeighborCache (
EfiNeighborCache = NeighborCacheTmp + Count;
- EfiNeighborCache->State = Neighbor->State;
+ EfiNeighborCache->State = Neighbor->State;
IP6_COPY_ADDRESS (&EfiNeighborCache->Neighbor, &Neighbor->Neighbor);
IP6_COPY_LINK_ADDRESS (&EfiNeighborCache->LinkAddress, &Neighbor->LinkAddress);
@@ -114,12 +114,12 @@ Ip6BuildPrefixTable (
OUT EFI_IP6_ADDRESS_INFO **PrefixTable
)
{
- LIST_ENTRY *Entry;
- IP6_SERVICE *IpSb;
- UINT32 Count;
- IP6_PREFIX_LIST_ENTRY *PrefixList;
- EFI_IP6_ADDRESS_INFO *EfiPrefix;
- EFI_IP6_ADDRESS_INFO *PrefixTableTmp;
+ LIST_ENTRY *Entry;
+ IP6_SERVICE *IpSb;
+ UINT32 Count;
+ IP6_PREFIX_LIST_ENTRY *PrefixList;
+ EFI_IP6_ADDRESS_INFO *EfiPrefix;
+ EFI_IP6_ADDRESS_INFO *PrefixTableTmp;
NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE);
ASSERT (PrefixCount != NULL && PrefixTable != NULL);
@@ -178,21 +178,21 @@ Ip6BuildPrefixTable (
**/
IP6_PREFIX_LIST_ENTRY *
Ip6CreatePrefixListEntry (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN OnLinkOrAuto,
- IN UINT32 ValidLifetime,
- IN UINT32 PreferredLifetime,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *Prefix
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN OnLinkOrAuto,
+ IN UINT32 ValidLifetime,
+ IN UINT32 PreferredLifetime,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *Prefix
)
{
- IP6_PREFIX_LIST_ENTRY *PrefixEntry;
- IP6_ROUTE_ENTRY *RtEntry;
- LIST_ENTRY *ListHead;
- LIST_ENTRY *Entry;
- IP6_PREFIX_LIST_ENTRY *TmpPrefixEntry;
+ IP6_PREFIX_LIST_ENTRY *PrefixEntry;
+ IP6_ROUTE_ENTRY *RtEntry;
+ LIST_ENTRY *ListHead;
+ LIST_ENTRY *Entry;
+ IP6_PREFIX_LIST_ENTRY *TmpPrefixEntry;
- if (Prefix == NULL || PreferredLifetime > ValidLifetime || PrefixLength > IP6_PREFIX_MAX) {
+ if ((Prefix == NULL) || (PreferredLifetime > ValidLifetime) || (PrefixLength > IP6_PREFIX_MAX)) {
return NULL;
}
@@ -205,7 +205,7 @@ Ip6CreatePrefixListEntry (
Prefix
);
if (PrefixEntry != NULL) {
- PrefixEntry->RefCnt ++;
+ PrefixEntry->RefCnt++;
return PrefixEntry;
}
@@ -242,7 +242,7 @@ Ip6CreatePrefixListEntry (
// is put ahead in the list.
//
NET_LIST_FOR_EACH (Entry, ListHead) {
- TmpPrefixEntry = NET_LIST_USER_STRUCT(Entry, IP6_PREFIX_LIST_ENTRY, Link);
+ TmpPrefixEntry = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link);
if (TmpPrefixEntry->PrefixLength < PrefixEntry->PrefixLength) {
break;
@@ -274,26 +274,26 @@ Ip6DestroyPrefixListEntry (
IN BOOLEAN ImmediateDelete
)
{
- LIST_ENTRY *Entry;
- IP6_INTERFACE *IpIf;
- EFI_STATUS Status;
+ LIST_ENTRY *Entry;
+ IP6_INTERFACE *IpIf;
+ EFI_STATUS Status;
if ((!ImmediateDelete) && (PrefixEntry->RefCnt > 0) && ((--PrefixEntry->RefCnt) > 0)) {
- return ;
+ return;
}
if (OnLinkOrAuto) {
- //
- // Remove the direct route for onlink prefix from route table.
- //
- do {
- Status = Ip6DelRoute (
- IpSb->RouteTable,
- &PrefixEntry->Prefix,
- PrefixEntry->PrefixLength,
- NULL
- );
- } while (Status != EFI_NOT_FOUND);
+ //
+ // Remove the direct route for onlink prefix from route table.
+ //
+ do {
+ Status = Ip6DelRoute (
+ IpSb->RouteTable,
+ &PrefixEntry->Prefix,
+ PrefixEntry->PrefixLength,
+ NULL
+ );
+ } while (Status != EFI_NOT_FOUND);
} else {
//
// Remove the corresponding addresses generated from this autonomous prefix.
@@ -324,15 +324,15 @@ Ip6DestroyPrefixListEntry (
**/
IP6_PREFIX_LIST_ENTRY *
Ip6FindPrefixListEntry (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN OnLinkOrAuto,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *Prefix
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN OnLinkOrAuto,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *Prefix
)
{
- IP6_PREFIX_LIST_ENTRY *PrefixList;
- LIST_ENTRY *Entry;
- LIST_ENTRY *ListHead;
+ IP6_PREFIX_LIST_ENTRY *PrefixList;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *ListHead;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Prefix != NULL);
@@ -349,8 +349,9 @@ Ip6FindPrefixListEntry (
//
// Perform exactly prefix match.
//
- if (PrefixList->PrefixLength == PrefixLength &&
- NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixLength)) {
+ if ((PrefixList->PrefixLength == PrefixLength) &&
+ NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixLength))
+ {
return PrefixList;
}
} else {
@@ -377,14 +378,14 @@ Ip6FindPrefixListEntry (
**/
VOID
Ip6CleanPrefixListTable (
- IN IP6_SERVICE *IpSb,
- IN LIST_ENTRY *ListHead
+ IN IP6_SERVICE *IpSb,
+ IN LIST_ENTRY *ListHead
)
{
- IP6_PREFIX_LIST_ENTRY *PrefixList;
- BOOLEAN OnLink;
+ IP6_PREFIX_LIST_ENTRY *PrefixList;
+ BOOLEAN OnLink;
- OnLink = (BOOLEAN) (ListHead == &IpSb->OnlinkPrefix);
+ OnLink = (BOOLEAN)(ListHead == &IpSb->OnlinkPrefix);
while (!IsListEmpty (ListHead)) {
PrefixList = NET_LIST_HEAD (ListHead, IP6_PREFIX_LIST_ENTRY, Link);
@@ -402,25 +403,25 @@ Ip6CleanPrefixListTable (
**/
VOID
Ip6OnArpResolved (
- IN VOID *Context
+ IN VOID *Context
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_NEIGHBOR_ENTRY *ArpQue;
- IP6_SERVICE *IpSb;
- IP6_LINK_TX_TOKEN *Token;
- EFI_STATUS Status;
- BOOLEAN Sent;
-
- ArpQue = (IP6_NEIGHBOR_ENTRY *) Context;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_NEIGHBOR_ENTRY *ArpQue;
+ IP6_SERVICE *IpSb;
+ IP6_LINK_TX_TOKEN *Token;
+ EFI_STATUS Status;
+ BOOLEAN Sent;
+
+ ArpQue = (IP6_NEIGHBOR_ENTRY *)Context;
if ((ArpQue == NULL) || (ArpQue->Interface == NULL)) {
- return ;
+ return;
}
- IpSb = ArpQue->Interface->Service;
+ IpSb = ArpQue->Interface->Service;
if ((IpSb == NULL) || (IpSb->Signature != IP6_SERVICE_SIGNATURE)) {
- return ;
+ return;
}
//
@@ -430,7 +431,7 @@ Ip6OnArpResolved (
//
if (NET_MAC_EQUAL (&ArpQue->LinkAddress, &mZeroMacAddress, IpSb->SnpMode.HwAddressSize)) {
Ip6FreeNeighborEntry (IpSb, ArpQue, FALSE, TRUE, EFI_NO_MAPPING, NULL, NULL);
- return ;
+ return;
}
//
@@ -471,7 +472,7 @@ Ip6OnArpResolved (
if (Sent && (ArpQue->State == EfiNeighborStale)) {
ArpQue->State = EfiNeighborDelay;
- ArpQue->Ticks = (UINT32) IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME);
+ ArpQue->Ticks = (UINT32)IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME);
}
}
@@ -491,17 +492,17 @@ Ip6OnArpResolved (
**/
IP6_NEIGHBOR_ENTRY *
Ip6CreateNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN IP6_ARP_CALLBACK CallBack,
- IN EFI_IPv6_ADDRESS *Ip6Address,
- IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_ARP_CALLBACK CallBack,
+ IN EFI_IPv6_ADDRESS *Ip6Address,
+ IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL
)
{
- IP6_NEIGHBOR_ENTRY *Entry;
- IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_NEIGHBOR_ENTRY *Entry;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
- ASSERT (Ip6Address!= NULL);
+ ASSERT (Ip6Address != NULL);
Entry = AllocateZeroPool (sizeof (IP6_NEIGHBOR_ENTRY));
if (Entry == NULL) {
@@ -552,13 +553,13 @@ Ip6CreateNeighborEntry (
**/
IP6_NEIGHBOR_ENTRY *
Ip6FindNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_NEIGHBOR_ENTRY *Neighbor;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Ip6Address != NULL);
@@ -599,25 +600,25 @@ Ip6FindNeighborEntry (
**/
EFI_STATUS
Ip6FreeNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN IP6_NEIGHBOR_ENTRY *NeighborCache,
- IN BOOLEAN SendIcmpError,
- IN BOOLEAN FullFree,
- IN EFI_STATUS IoStatus,
- IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_NEIGHBOR_ENTRY *NeighborCache,
+ IN BOOLEAN SendIcmpError,
+ IN BOOLEAN FullFree,
+ IN EFI_STATUS IoStatus,
+ IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
+ IN VOID *Context OPTIONAL
)
{
- IP6_LINK_TX_TOKEN *TxToken;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_LINK_TX_TOKEN *TxToken;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
//
// If FrameToCancel fails, the token will not be released.
// To avoid the memory leak, stop this usage model.
//
- if (FullFree && FrameToCancel != NULL) {
+ if (FullFree && (FrameToCancel != NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -677,13 +678,13 @@ Ip6FreeNeighborEntry (
**/
IP6_DEFAULT_ROUTER *
Ip6CreateDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address,
- IN UINT16 RouterLifetime
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address,
+ IN UINT16 RouterLifetime
)
{
- IP6_DEFAULT_ROUTER *Entry;
- IP6_ROUTE_ENTRY *RtEntry;
+ IP6_DEFAULT_ROUTER *Entry;
+ IP6_ROUTE_ENTRY *RtEntry;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Ip6Address != NULL);
@@ -724,11 +725,11 @@ Ip6CreateDefaultRouter (
**/
VOID
Ip6DestroyDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN IP6_DEFAULT_ROUTER *DefaultRouter
+ IN IP6_SERVICE *IpSb,
+ IN IP6_DEFAULT_ROUTER *DefaultRouter
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
RemoveEntryList (&DefaultRouter->Link);
@@ -751,10 +752,10 @@ Ip6DestroyDefaultRouter (
**/
VOID
Ip6CleanDefaultRouterList (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
while (!IsListEmpty (&IpSb->DefaultRouterList)) {
DefaultRouter = NET_LIST_HEAD (&IpSb->DefaultRouterList, IP6_DEFAULT_ROUTER, Link);
@@ -774,12 +775,12 @@ Ip6CleanDefaultRouterList (
**/
IP6_DEFAULT_ROUTER *
Ip6FindDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address
)
{
- LIST_ENTRY *Entry;
- IP6_DEFAULT_ROUTER *DefaultRouter;
+ LIST_ENTRY *Entry;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Ip6Address != NULL);
@@ -846,10 +847,10 @@ Ip6OnDADFinished (
// Set the exta options to send. Here we only want the option request option
// with DNS SERVERS.
//
- Oro = (EFI_DHCP6_PACKET_OPTION *) OptBuf;
- Oro->OpCode = HTONS (DHCP6_OPT_ORO);
- Oro->OpLen = HTONS (2);
- *((UINT16 *) &Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS);
+ Oro = (EFI_DHCP6_PACKET_OPTION *)OptBuf;
+ Oro->OpCode = HTONS (DHCP6_OPT_ORO);
+ Oro->OpLen = HTONS (2);
+ *((UINT16 *)&Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS);
InfoReqReXmit.Irt = 4;
InfoReqReXmit.Mrc = 64;
@@ -875,12 +876,11 @@ Ip6OnDADFinished (
Ip6CreatePrefixListEntry (
IpSb,
TRUE,
- (UINT32) IP6_INFINIT_LIFETIME,
- (UINT32) IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
IP6_LINK_LOCAL_PREFIX_LENGTH,
&IpSb->LinkLocalAddr
);
-
} else {
//
// Global scope unicast address.
@@ -928,7 +928,7 @@ Ip6OnDADFinished (
IpSb->Mnp->Configure (IpSb->Mnp, NULL);
gBS->SetTimer (IpSb->Timer, TimerCancel, 0);
gBS->SetTimer (IpSb->FasterTimer, TimerCancel, 0);
- return ;
+ return;
}
if (!IsDadPassed || NetIp6IsLinkLocalAddr (&AddrInfo->Address)) {
@@ -961,10 +961,10 @@ Ip6OnDADFinished (
**/
EFI_STATUS
Ip6InitDADProcess (
- IN IP6_INTERFACE *IpIf,
- IN IP6_ADDRESS_INFO *AddressInfo,
- IN IP6_DAD_CALLBACK Callback OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_INTERFACE *IpIf,
+ IN IP6_ADDRESS_INFO *AddressInfo,
+ IN IP6_DAD_CALLBACK Callback OPTIONAL,
+ IN VOID *Context OPTIONAL
)
{
IP6_DAD_ENTRY *Entry;
@@ -1009,15 +1009,15 @@ Ip6InitDADProcess (
return Status;
}
- Entry->Signature = IP6_DAD_ENTRY_SIGNATURE;
- Entry->MaxTransmit = DadXmits->DupAddrDetectTransmits;
- Entry->Transmit = 0;
- Entry->Receive = 0;
- MaxDelayTick = IP6_MAX_RTR_SOLICITATION_DELAY / IP6_TIMER_INTERVAL_IN_MS;
- Entry->RetransTick = (MaxDelayTick * ((NET_RANDOM (NetRandomInitSeed ()) % 5) + 1)) / 5;
- Entry->AddressInfo = AddressInfo;
- Entry->Callback = Callback;
- Entry->Context = Context;
+ Entry->Signature = IP6_DAD_ENTRY_SIGNATURE;
+ Entry->MaxTransmit = DadXmits->DupAddrDetectTransmits;
+ Entry->Transmit = 0;
+ Entry->Receive = 0;
+ MaxDelayTick = IP6_MAX_RTR_SOLICITATION_DELAY / IP6_TIMER_INTERVAL_IN_MS;
+ Entry->RetransTick = (MaxDelayTick * ((NET_RANDOM (NetRandomInitSeed ()) % 5) + 1)) / 5;
+ Entry->AddressInfo = AddressInfo;
+ Entry->Callback = Callback;
+ Entry->Context = Context;
InsertTailList (&IpIf->DupAddrDetectList, &Entry->Link);
if (Entry->MaxTransmit == 0) {
@@ -1044,16 +1044,16 @@ Ip6InitDADProcess (
**/
IP6_DAD_ENTRY *
Ip6FindDADEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Target,
- OUT IP6_INTERFACE **Interface OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Target,
+ OUT IP6_INTERFACE **Interface OPTIONAL
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Entry2;
- IP6_INTERFACE *IpIf;
- IP6_DAD_ENTRY *DupAddrDetect;
- IP6_ADDRESS_INFO *AddrInfo;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry2;
+ IP6_INTERFACE *IpIf;
+ IP6_DAD_ENTRY *DupAddrDetect;
+ IP6_ADDRESS_INFO *AddrInfo;
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
IpIf = NET_LIST_USER_STRUCT (Entry, IP6_INTERFACE, Link);
@@ -1065,6 +1065,7 @@ Ip6FindDADEntry (
if (Interface != NULL) {
*Interface = IpIf;
}
+
return DupAddrDetect;
}
}
@@ -1093,24 +1094,24 @@ Ip6FindDADEntry (
**/
EFI_STATUS
Ip6SendRouterSolicit (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface OPTIONAL,
- IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
- IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL,
- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface OPTIONAL,
+ IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
+ IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL,
+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
)
{
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- IP6_ICMP_INFORMATION_HEAD *IcmpHead;
- IP6_ETHER_ADDR_OPTION *LinkLayerOption;
- UINT16 PayloadLen;
- IP6_INTERFACE *IpIf;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ IP6_ICMP_INFORMATION_HEAD *IcmpHead;
+ IP6_ETHER_ADDR_OPTION *LinkLayerOption;
+ UINT16 PayloadLen;
+ IP6_INTERFACE *IpIf;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
IpIf = Interface;
- if (IpIf == NULL && IpSb->DefaultInterface != NULL) {
+ if ((IpIf == NULL) && (IpSb->DefaultInterface != NULL)) {
IpIf = IpSb->DefaultInterface;
}
@@ -1118,12 +1119,12 @@ Ip6SendRouterSolicit (
// Generate the packet to be sent
//
- PayloadLen = (UINT16) sizeof (IP6_ICMP_INFORMATION_HEAD);
+ PayloadLen = (UINT16)sizeof (IP6_ICMP_INFORMATION_HEAD);
if (SourceLinkAddress != NULL) {
PayloadLen += sizeof (IP6_ETHER_ADDR_OPTION);
}
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1131,11 +1132,11 @@ Ip6SendRouterSolicit (
//
// Create the basic IPv6 header.
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_ICMP;
- Head.HopLimit = IP6_HOP_LIMIT;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_ICMP;
+ Head.HopLimit = IP6_HOP_LIMIT;
if (SourceAddress != NULL) {
IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress);
@@ -1143,7 +1144,6 @@ Ip6SendRouterSolicit (
ZeroMem (&Head.SourceAddress, sizeof (EFI_IPv6_ADDRESS));
}
-
if (DestinationAddress != NULL) {
IP6_COPY_ADDRESS (&Head.DestinationAddress, DestinationAddress);
} else {
@@ -1156,7 +1156,7 @@ Ip6SendRouterSolicit (
// Fill in the ICMP header, and Source link-layer address if contained.
//
- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
ASSERT (IcmpHead != NULL);
ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD));
IcmpHead->Head.Type = ICMP_V6_ROUTER_SOLICIT;
@@ -1164,14 +1164,14 @@ Ip6SendRouterSolicit (
LinkLayerOption = NULL;
if (SourceLinkAddress != NULL) {
- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace (
- Packet,
- sizeof (IP6_ETHER_ADDR_OPTION),
- FALSE
- );
+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace (
+ Packet,
+ sizeof (IP6_ETHER_ADDR_OPTION),
+ FALSE
+ );
ASSERT (LinkLayerOption != NULL);
LinkLayerOption->Type = Ip6OptionEtherSource;
- LinkLayerOption->Length = (UINT8) sizeof (IP6_ETHER_ADDR_OPTION);
+ LinkLayerOption->Length = (UINT8)sizeof (IP6_ETHER_ADDR_OPTION);
CopyMem (LinkLayerOption->EtherAddr, SourceLinkAddress, 6);
}
@@ -1205,22 +1205,22 @@ Ip6SendRouterSolicit (
**/
EFI_STATUS
Ip6SendNeighborAdvertise (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *SourceAddress,
- IN EFI_IPv6_ADDRESS *DestinationAddress,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress,
- IN BOOLEAN IsRouter,
- IN BOOLEAN Override,
- IN BOOLEAN Solicited
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *SourceAddress,
+ IN EFI_IPv6_ADDRESS *DestinationAddress,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress,
+ IN BOOLEAN IsRouter,
+ IN BOOLEAN Override,
+ IN BOOLEAN Solicited
)
{
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- IP6_ICMP_INFORMATION_HEAD *IcmpHead;
- IP6_ETHER_ADDR_OPTION *LinkLayerOption;
- EFI_IPv6_ADDRESS *Target;
- UINT16 PayloadLen;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ IP6_ICMP_INFORMATION_HEAD *IcmpHead;
+ IP6_ETHER_ADDR_OPTION *LinkLayerOption;
+ EFI_IPv6_ADDRESS *Target;
+ UINT16 PayloadLen;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -1232,13 +1232,13 @@ Ip6SendNeighborAdvertise (
//
ASSERT (DestinationAddress != NULL && TargetIp6Address != NULL && TargetLinkAddress != NULL);
- PayloadLen = (UINT16) (sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS) + sizeof (IP6_ETHER_ADDR_OPTION));
+ PayloadLen = (UINT16)(sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS) + sizeof (IP6_ETHER_ADDR_OPTION));
//
// Generate the packet to be sent
//
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1246,11 +1246,11 @@ Ip6SendNeighborAdvertise (
//
// Create the basic IPv6 header.
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_ICMP;
- Head.HopLimit = IP6_HOP_LIMIT;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_ICMP;
+ Head.HopLimit = IP6_HOP_LIMIT;
IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress);
IP6_COPY_ADDRESS (&Head.DestinationAddress, DestinationAddress);
@@ -1262,7 +1262,7 @@ Ip6SendNeighborAdvertise (
// Set the Router flag, Solicited flag and Override flag.
//
- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
ASSERT (IcmpHead != NULL);
ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD));
IcmpHead->Head.Type = ICMP_V6_NEIGHBOR_ADVERTISE;
@@ -1280,15 +1280,15 @@ Ip6SendNeighborAdvertise (
IcmpHead->Fourth |= IP6_OVERRIDE_FLAG;
}
- Target = (EFI_IPv6_ADDRESS *) NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE);
+ Target = (EFI_IPv6_ADDRESS *)NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE);
ASSERT (Target != NULL);
IP6_COPY_ADDRESS (Target, TargetIp6Address);
- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace (
- Packet,
- sizeof (IP6_ETHER_ADDR_OPTION),
- FALSE
- );
+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace (
+ Packet,
+ sizeof (IP6_ETHER_ADDR_OPTION),
+ FALSE
+ );
ASSERT (LinkLayerOption != NULL);
LinkLayerOption->Type = Ip6OptionEtherTarget;
LinkLayerOption->Length = 1;
@@ -1320,33 +1320,33 @@ Ip6SendNeighborAdvertise (
**/
EFI_STATUS
Ip6SendNeighborSolicit (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *SourceAddress,
- IN EFI_IPv6_ADDRESS *DestinationAddress,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *SourceAddress,
+ IN EFI_IPv6_ADDRESS *DestinationAddress,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
)
{
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- IP6_ICMP_INFORMATION_HEAD *IcmpHead;
- IP6_ETHER_ADDR_OPTION *LinkLayerOption;
- EFI_IPv6_ADDRESS *Target;
- BOOLEAN IsDAD;
- UINT16 PayloadLen;
- IP6_NEIGHBOR_ENTRY *Neighbor;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ IP6_ICMP_INFORMATION_HEAD *IcmpHead;
+ IP6_ETHER_ADDR_OPTION *LinkLayerOption;
+ EFI_IPv6_ADDRESS *Target;
+ BOOLEAN IsDAD;
+ UINT16 PayloadLen;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
//
// Check input parameters
//
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
- if (DestinationAddress == NULL || TargetIp6Address == NULL) {
+ if ((DestinationAddress == NULL) || (TargetIp6Address == NULL)) {
return EFI_INVALID_PARAMETER;
}
IsDAD = FALSE;
- if (SourceAddress == NULL || (SourceAddress != NULL && NetIp6IsUnspecifiedAddr (SourceAddress))) {
+ if ((SourceAddress == NULL) || ((SourceAddress != NULL) && NetIp6IsUnspecifiedAddr (SourceAddress))) {
IsDAD = TRUE;
}
@@ -1355,21 +1355,21 @@ Ip6SendNeighborSolicit (
// if the solicitation is not sent by performing DAD - Duplicate Address Detection.
// Otherwise must not include it.
//
- PayloadLen = (UINT16) (sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS));
+ PayloadLen = (UINT16)(sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS));
if (!IsDAD) {
if (SourceLinkAddress == NULL) {
return EFI_INVALID_PARAMETER;
}
- PayloadLen = (UINT16) (PayloadLen + sizeof (IP6_ETHER_ADDR_OPTION));
+ PayloadLen = (UINT16)(PayloadLen + sizeof (IP6_ETHER_ADDR_OPTION));
}
//
// Generate the packet to be sent
//
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1377,11 +1377,11 @@ Ip6SendNeighborSolicit (
//
// Create the basic IPv6 header
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_ICMP;
- Head.HopLimit = IP6_HOP_LIMIT;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_ICMP;
+ Head.HopLimit = IP6_HOP_LIMIT;
if (SourceAddress != NULL) {
IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress);
@@ -1396,27 +1396,26 @@ Ip6SendNeighborSolicit (
//
// Fill in the ICMP header, Target address, and Source link-layer address.
//
- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
ASSERT (IcmpHead != NULL);
ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD));
IcmpHead->Head.Type = ICMP_V6_NEIGHBOR_SOLICIT;
IcmpHead->Head.Code = 0;
- Target = (EFI_IPv6_ADDRESS *) NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE);
+ Target = (EFI_IPv6_ADDRESS *)NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE);
ASSERT (Target != NULL);
IP6_COPY_ADDRESS (Target, TargetIp6Address);
LinkLayerOption = NULL;
if (!IsDAD) {
-
//
// Fill in the source link-layer address option
//
- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace (
- Packet,
- sizeof (IP6_ETHER_ADDR_OPTION),
- FALSE
- );
+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace (
+ Packet,
+ sizeof (IP6_ETHER_ADDR_OPTION),
+ FALSE
+ );
ASSERT (LinkLayerOption != NULL);
LinkLayerOption->Type = Ip6OptionEtherSource;
LinkLayerOption->Length = 1;
@@ -1457,30 +1456,30 @@ Ip6SendNeighborSolicit (
**/
EFI_STATUS
Ip6ProcessNeighborSolicit (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD Icmp;
- EFI_IPv6_ADDRESS Target;
- IP6_ETHER_ADDR_OPTION LinkLayerOption;
- BOOLEAN IsDAD;
- BOOLEAN IsUnicast;
- BOOLEAN IsMaintained;
- IP6_DAD_ENTRY *DupAddrDetect;
- IP6_INTERFACE *IpIf;
- IP6_NEIGHBOR_ENTRY *Neighbor;
- BOOLEAN Solicited;
- BOOLEAN UpdateCache;
- EFI_IPv6_ADDRESS Dest;
- UINT16 OptionLen;
- UINT8 *Option;
- BOOLEAN Provided;
- EFI_STATUS Status;
- VOID *MacAddress;
-
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ IP6_ICMP_INFORMATION_HEAD Icmp;
+ EFI_IPv6_ADDRESS Target;
+ IP6_ETHER_ADDR_OPTION LinkLayerOption;
+ BOOLEAN IsDAD;
+ BOOLEAN IsUnicast;
+ BOOLEAN IsMaintained;
+ IP6_DAD_ENTRY *DupAddrDetect;
+ IP6_INTERFACE *IpIf;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
+ BOOLEAN Solicited;
+ BOOLEAN UpdateCache;
+ EFI_IPv6_ADDRESS Dest;
+ UINT16 OptionLen;
+ UINT8 *Option;
+ BOOLEAN Provided;
+ EFI_STATUS Status;
+ VOID *MacAddress;
+
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
NetbufCopy (Packet, sizeof (Icmp), sizeof (Target), Target.Addr);
//
@@ -1492,7 +1491,7 @@ Ip6ProcessNeighborSolicit (
//
Status = EFI_INVALID_PARAMETER;
- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 || !NetIp6IsValidUnicast (&Target)) {
+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) || !NetIp6IsValidUnicast (&Target)) {
goto Exit;
}
@@ -1503,9 +1502,9 @@ Ip6ProcessNeighborSolicit (
if (Head->PayloadLength < IP6_ND_LENGTH) {
goto Exit;
} else {
- OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH);
+ OptionLen = (UINT16)(Head->PayloadLength - IP6_ND_LENGTH);
if (OptionLen != 0) {
- Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
+ Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
ASSERT (Option != NULL);
//
@@ -1527,7 +1526,7 @@ Ip6ProcessNeighborSolicit (
Packet,
IP6_ND_LENGTH,
sizeof (IP6_ETHER_ADDR_OPTION),
- (UINT8 *) &LinkLayerOption
+ (UINT8 *)&LinkLayerOption
);
//
// The solicitation for neighbor discovery should include a source link-layer
@@ -1591,7 +1590,8 @@ Ip6ProcessNeighborSolicit (
MacAddress,
&IpSb->SnpMode.CurrentAddress,
IpSb->SnpMode.HwAddressSize
- ) != 0) {
+ ) != 0)
+ {
//
// The NS is from another node to performing DAD on the same address.
// Fail DAD for the tentative address.
@@ -1607,6 +1607,7 @@ Ip6ProcessNeighborSolicit (
}
}
}
+
goto Exit;
}
@@ -1624,6 +1625,7 @@ Ip6ProcessNeighborSolicit (
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
+
UpdateCache = TRUE;
} else {
if (CompareMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6) != 0) {
@@ -1633,12 +1635,12 @@ Ip6ProcessNeighborSolicit (
if (UpdateCache) {
Neighbor->State = EfiNeighborStale;
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
CopyMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6);
//
// Send queued packets if exist.
//
- Neighbor->CallBack ((VOID *) Neighbor);
+ Neighbor->CallBack ((VOID *)Neighbor);
}
}
@@ -1686,28 +1688,28 @@ Exit:
**/
EFI_STATUS
Ip6ProcessNeighborAdvertise (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD Icmp;
- EFI_IPv6_ADDRESS Target;
- IP6_ETHER_ADDR_OPTION LinkLayerOption;
- BOOLEAN Provided;
- INTN Compare;
- IP6_NEIGHBOR_ENTRY *Neighbor;
- IP6_DEFAULT_ROUTER *DefaultRouter;
- BOOLEAN Solicited;
- BOOLEAN IsRouter;
- BOOLEAN Override;
- IP6_DAD_ENTRY *DupAddrDetect;
- IP6_INTERFACE *IpIf;
- UINT16 OptionLen;
- UINT8 *Option;
- EFI_STATUS Status;
-
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ IP6_ICMP_INFORMATION_HEAD Icmp;
+ EFI_IPv6_ADDRESS Target;
+ IP6_ETHER_ADDR_OPTION LinkLayerOption;
+ BOOLEAN Provided;
+ INTN Compare;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
+ BOOLEAN Solicited;
+ BOOLEAN IsRouter;
+ BOOLEAN Override;
+ IP6_DAD_ENTRY *DupAddrDetect;
+ IP6_INTERFACE *IpIf;
+ UINT16 OptionLen;
+ UINT8 *Option;
+ EFI_STATUS Status;
+
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
NetbufCopy (Packet, sizeof (Icmp), sizeof (Target), Target.Addr);
//
@@ -1720,7 +1722,7 @@ Ip6ProcessNeighborAdvertise (
// ICMP Code is 0.
// Target Address is not a multicast address.
//
- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 || !NetIp6IsValidUnicast (&Target)) {
+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) || !NetIp6IsValidUnicast (&Target)) {
goto Exit;
}
@@ -1732,9 +1734,9 @@ Ip6ProcessNeighborAdvertise (
if (Head->PayloadLength < IP6_ND_LENGTH) {
goto Exit;
} else {
- OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH);
+ OptionLen = (UINT16)(Head->PayloadLength - IP6_ND_LENGTH);
if (OptionLen != 0) {
- Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
+ Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
ASSERT (Option != NULL);
//
@@ -1753,6 +1755,7 @@ Ip6ProcessNeighborAdvertise (
if ((Icmp.Fourth & IP6_SOLICITED_FLAG) == IP6_SOLICITED_FLAG) {
Solicited = TRUE;
}
+
if (IP6_IS_MULTICAST (&Head->DestinationAddress) && Solicited) {
goto Exit;
}
@@ -1787,6 +1790,7 @@ Ip6ProcessNeighborAdvertise (
if ((Icmp.Fourth & IP6_IS_ROUTER_FLAG) == IP6_IS_ROUTER_FLAG) {
IsRouter = TRUE;
}
+
if ((Icmp.Fourth & IP6_OVERRIDE_FLAG) == IP6_OVERRIDE_FLAG) {
Override = TRUE;
}
@@ -1799,7 +1803,7 @@ Ip6ProcessNeighborAdvertise (
Packet,
IP6_ND_LENGTH,
sizeof (IP6_ETHER_ADDR_OPTION),
- (UINT8 *) &LinkLayerOption
+ (UINT8 *)&LinkLayerOption
);
if (LinkLayerOption.Type == Ip6OptionEtherTarget) {
@@ -1828,6 +1832,7 @@ Ip6ProcessNeighborAdvertise (
if (!Provided) {
goto Exit;
}
+
//
// Update the Neighbor Cache
//
@@ -1837,17 +1842,16 @@ Ip6ProcessNeighborAdvertise (
Neighbor->Ticks = IP6_GET_TICKS (IpSb->ReachableTime);
} else {
Neighbor->State = EfiNeighborStale;
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
//
// Send any packets queued for the neighbor awaiting address resolution.
//
- Neighbor->CallBack ((VOID *) Neighbor);
+ Neighbor->CallBack ((VOID *)Neighbor);
}
Neighbor->IsRouter = IsRouter;
-
} else {
- if (!Override && Compare != 0) {
+ if (!Override && (Compare != 0)) {
//
// When the Override Flag is clear and supplied link-layer address differs from
// that in the cache, if the state of the entry is not REACHABLE, ignore the
@@ -1856,12 +1860,13 @@ Ip6ProcessNeighborAdvertise (
//
if (Neighbor->State == EfiNeighborReachable) {
Neighbor->State = EfiNeighborStale;
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
}
} else {
if (Compare != 0) {
CopyMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6);
}
+
//
// Update the entry's state
//
@@ -1871,7 +1876,7 @@ Ip6ProcessNeighborAdvertise (
} else {
if (Compare != 0) {
Neighbor->State = EfiNeighborStale;
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
}
}
@@ -1892,7 +1897,7 @@ Ip6ProcessNeighborAdvertise (
}
if (Neighbor->State == EfiNeighborReachable) {
- Neighbor->CallBack ((VOID *) Neighbor);
+ Neighbor->CallBack ((VOID *)Neighbor);
}
Status = EFI_SUCCESS;
@@ -1918,36 +1923,36 @@ Exit:
**/
EFI_STATUS
Ip6ProcessRouterAdvertise (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD Icmp;
- UINT32 ReachableTime;
- UINT32 RetransTimer;
- UINT16 RouterLifetime;
- UINT32 Offset;
- UINT8 Type;
- UINT8 Length;
- IP6_ETHER_ADDR_OPTION LinkLayerOption;
- UINT32 Fourth;
- UINT8 CurHopLimit;
- BOOLEAN Mflag;
- BOOLEAN Oflag;
- IP6_DEFAULT_ROUTER *DefaultRouter;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- EFI_MAC_ADDRESS LinkLayerAddress;
- IP6_MTU_OPTION MTUOption;
- IP6_PREFIX_INFO_OPTION PrefixOption;
- IP6_PREFIX_LIST_ENTRY *PrefixList;
- BOOLEAN OnLink;
- BOOLEAN Autonomous;
- EFI_IPv6_ADDRESS StatelessAddress;
- EFI_STATUS Status;
- UINT16 OptionLen;
- UINT8 *Option;
- INTN Result;
+ IP6_ICMP_INFORMATION_HEAD Icmp;
+ UINT32 ReachableTime;
+ UINT32 RetransTimer;
+ UINT16 RouterLifetime;
+ UINT32 Offset;
+ UINT8 Type;
+ UINT8 Length;
+ IP6_ETHER_ADDR_OPTION LinkLayerOption;
+ UINT32 Fourth;
+ UINT8 CurHopLimit;
+ BOOLEAN Mflag;
+ BOOLEAN Oflag;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ EFI_MAC_ADDRESS LinkLayerAddress;
+ IP6_MTU_OPTION MTUOption;
+ IP6_PREFIX_INFO_OPTION PrefixOption;
+ IP6_PREFIX_LIST_ENTRY *PrefixList;
+ BOOLEAN OnLink;
+ BOOLEAN Autonomous;
+ EFI_IPv6_ADDRESS StatelessAddress;
+ EFI_STATUS Status;
+ UINT16 OptionLen;
+ UINT8 *Option;
+ INTN Result;
Status = EFI_INVALID_PARAMETER;
@@ -1958,7 +1963,7 @@ Ip6ProcessRouterAdvertise (
goto Exit;
}
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
//
// Validate the incoming Router Advertisement
@@ -1970,23 +1975,25 @@ Ip6ProcessRouterAdvertise (
if (!NetIp6IsLinkLocalAddr (&Head->SourceAddress)) {
goto Exit;
}
+
//
// The IP Hop Limit field has a value of 255, i.e. the packet
// could not possibly have been forwarded by a router.
// ICMP Code is 0.
// ICMP length (derived from the IP length) is 16 or more octets.
//
- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 ||
- Head->PayloadLength < IP6_RA_LENGTH) {
+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) ||
+ (Head->PayloadLength < IP6_RA_LENGTH))
+ {
goto Exit;
}
//
// All included options have a length that is greater than zero.
//
- OptionLen = (UINT16) (Head->PayloadLength - IP6_RA_LENGTH);
+ OptionLen = (UINT16)(Head->PayloadLength - IP6_RA_LENGTH);
if (OptionLen != 0) {
- Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL);
+ Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL);
ASSERT (Option != NULL);
if (!Ip6IsNDOptionValid (Option, OptionLen)) {
@@ -2035,17 +2042,17 @@ Ip6ProcessRouterAdvertise (
}
}
- CurHopLimit = *((UINT8 *) &Fourth + 3);
+ CurHopLimit = *((UINT8 *)&Fourth + 3);
if (CurHopLimit != 0) {
IpSb->CurHopLimit = CurHopLimit;
}
Mflag = FALSE;
Oflag = FALSE;
- if ((*((UINT8 *) &Fourth + 2) & IP6_M_ADDR_CONFIG_FLAG) == IP6_M_ADDR_CONFIG_FLAG) {
+ if ((*((UINT8 *)&Fourth + 2) & IP6_M_ADDR_CONFIG_FLAG) == IP6_M_ADDR_CONFIG_FLAG) {
Mflag = TRUE;
} else {
- if ((*((UINT8 *) &Fourth + 2) & IP6_O_CONFIG_FLAG) == IP6_O_CONFIG_FLAG) {
+ if ((*((UINT8 *)&Fourth + 2) & IP6_O_CONFIG_FLAG) == IP6_O_CONFIG_FLAG) {
Oflag = TRUE;
}
}
@@ -2060,12 +2067,12 @@ Ip6ProcessRouterAdvertise (
//
// Process Reachable Time and Retrans Timer fields.
//
- NetbufCopy (Packet, sizeof (Icmp), sizeof (UINT32), (UINT8 *) &ReachableTime);
- NetbufCopy (Packet, sizeof (Icmp) + sizeof (UINT32), sizeof (UINT32), (UINT8 *) &RetransTimer);
+ NetbufCopy (Packet, sizeof (Icmp), sizeof (UINT32), (UINT8 *)&ReachableTime);
+ NetbufCopy (Packet, sizeof (Icmp) + sizeof (UINT32), sizeof (UINT32), (UINT8 *)&RetransTimer);
ReachableTime = NTOHL (ReachableTime);
RetransTimer = NTOHL (RetransTimer);
- if (ReachableTime != 0 && ReachableTime != IpSb->BaseReachableTime) {
+ if ((ReachableTime != 0) && (ReachableTime != IpSb->BaseReachableTime)) {
//
// If new value is not unspecified and differs from the previous one, record it
// in BaseReachableTime and recompute a ReachableTime.
@@ -2098,262 +2105,266 @@ Ip6ProcessRouterAdvertise (
// fit within the input packet.
//
Offset = 16;
- while (Offset < (UINT32) Head->PayloadLength) {
+ while (Offset < (UINT32)Head->PayloadLength) {
NetbufCopy (Packet, Offset, sizeof (UINT8), &Type);
switch (Type) {
- case Ip6OptionEtherSource:
- //
- // Update the neighbor cache
- //
- NetbufCopy (Packet, Offset, sizeof (IP6_ETHER_ADDR_OPTION), (UINT8 *) &LinkLayerOption);
+ case Ip6OptionEtherSource:
+ //
+ // Update the neighbor cache
+ //
+ NetbufCopy (Packet, Offset, sizeof (IP6_ETHER_ADDR_OPTION), (UINT8 *)&LinkLayerOption);
- //
- // Option size validity ensured by Ip6IsNDOptionValid().
- //
- ASSERT (LinkLayerOption.Length != 0);
- ASSERT (Offset + (UINT32) LinkLayerOption.Length * 8 <= (UINT32) Head->PayloadLength);
+ //
+ // Option size validity ensured by Ip6IsNDOptionValid().
+ //
+ ASSERT (LinkLayerOption.Length != 0);
+ ASSERT (Offset + (UINT32)LinkLayerOption.Length * 8 <= (UINT32)Head->PayloadLength);
- ZeroMem (&LinkLayerAddress, sizeof (EFI_MAC_ADDRESS));
- CopyMem (&LinkLayerAddress, LinkLayerOption.EtherAddr, 6);
+ ZeroMem (&LinkLayerAddress, sizeof (EFI_MAC_ADDRESS));
+ CopyMem (&LinkLayerAddress, LinkLayerOption.EtherAddr, 6);
- if (NeighborCache == NULL) {
- NeighborCache = Ip6CreateNeighborEntry (
- IpSb,
- Ip6OnArpResolved,
- &Head->SourceAddress,
- &LinkLayerAddress
- );
if (NeighborCache == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
+ NeighborCache = Ip6CreateNeighborEntry (
+ IpSb,
+ Ip6OnArpResolved,
+ &Head->SourceAddress,
+ &LinkLayerAddress
+ );
+ if (NeighborCache == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+
+ NeighborCache->IsRouter = TRUE;
+ NeighborCache->State = EfiNeighborStale;
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
+ } else {
+ Result = CompareMem (&LinkLayerAddress, &NeighborCache->LinkAddress, 6);
+
+ //
+ // If the link-local address is the same as that already in the cache,
+ // the cache entry's state remains unchanged. Otherwise update the
+ // reachability state to STALE.
+ //
+ if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) {
+ CopyMem (&NeighborCache->LinkAddress, &LinkLayerAddress, 6);
+
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
+
+ if (NeighborCache->State == EfiNeighborInComplete) {
+ //
+ // Send queued packets if exist.
+ //
+ NeighborCache->State = EfiNeighborStale;
+ NeighborCache->CallBack ((VOID *)NeighborCache);
+ } else {
+ NeighborCache->State = EfiNeighborStale;
+ }
+ }
}
- NeighborCache->IsRouter = TRUE;
- NeighborCache->State = EfiNeighborStale;
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
- } else {
- Result = CompareMem (&LinkLayerAddress, &NeighborCache->LinkAddress, 6);
+
+ Offset += (UINT32)LinkLayerOption.Length * 8;
+ break;
+ case Ip6OptionPrefixInfo:
+ NetbufCopy (Packet, Offset, sizeof (IP6_PREFIX_INFO_OPTION), (UINT8 *)&PrefixOption);
//
- // If the link-local address is the same as that already in the cache,
- // the cache entry's state remains unchanged. Otherwise update the
- // reachability state to STALE.
+ // Option size validity ensured by Ip6IsNDOptionValid().
//
- if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) {
- CopyMem (&NeighborCache->LinkAddress, &LinkLayerAddress, 6);
+ ASSERT (PrefixOption.Length == 4);
+ ASSERT (Offset + (UINT32)PrefixOption.Length * 8 <= (UINT32)Head->PayloadLength);
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ PrefixOption.ValidLifetime = NTOHL (PrefixOption.ValidLifetime);
+ PrefixOption.PreferredLifetime = NTOHL (PrefixOption.PreferredLifetime);
- if (NeighborCache->State == EfiNeighborInComplete) {
- //
- // Send queued packets if exist.
- //
- NeighborCache->State = EfiNeighborStale;
- NeighborCache->CallBack ((VOID *) NeighborCache);
- } else {
- NeighborCache->State = EfiNeighborStale;
- }
+ //
+ // Get L and A flag, recorded in the lower 2 bits of Reserved1
+ //
+ OnLink = FALSE;
+ if ((PrefixOption.Reserved1 & IP6_ON_LINK_FLAG) == IP6_ON_LINK_FLAG) {
+ OnLink = TRUE;
}
- }
-
- Offset += (UINT32) LinkLayerOption.Length * 8;
- break;
- case Ip6OptionPrefixInfo:
- NetbufCopy (Packet, Offset, sizeof (IP6_PREFIX_INFO_OPTION), (UINT8 *) &PrefixOption);
- //
- // Option size validity ensured by Ip6IsNDOptionValid().
- //
- ASSERT (PrefixOption.Length == 4);
- ASSERT (Offset + (UINT32) PrefixOption.Length * 8 <= (UINT32) Head->PayloadLength);
-
- PrefixOption.ValidLifetime = NTOHL (PrefixOption.ValidLifetime);
- PrefixOption.PreferredLifetime = NTOHL (PrefixOption.PreferredLifetime);
+ Autonomous = FALSE;
+ if ((PrefixOption.Reserved1 & IP6_AUTO_CONFIG_FLAG) == IP6_AUTO_CONFIG_FLAG) {
+ Autonomous = TRUE;
+ }
- //
- // Get L and A flag, recorded in the lower 2 bits of Reserved1
- //
- OnLink = FALSE;
- if ((PrefixOption.Reserved1 & IP6_ON_LINK_FLAG) == IP6_ON_LINK_FLAG) {
- OnLink = TRUE;
- }
- Autonomous = FALSE;
- if ((PrefixOption.Reserved1 & IP6_AUTO_CONFIG_FLAG) == IP6_AUTO_CONFIG_FLAG) {
- Autonomous = TRUE;
- }
+ //
+ // If the prefix is the link-local prefix, silently ignore the prefix option.
+ //
+ if ((PrefixOption.PrefixLength == IP6_LINK_LOCAL_PREFIX_LENGTH) &&
+ NetIp6IsLinkLocalAddr (&PrefixOption.Prefix)
+ )
+ {
+ Offset += sizeof (IP6_PREFIX_INFO_OPTION);
+ break;
+ }
- //
- // If the prefix is the link-local prefix, silently ignore the prefix option.
- //
- if (PrefixOption.PrefixLength == IP6_LINK_LOCAL_PREFIX_LENGTH &&
- NetIp6IsLinkLocalAddr (&PrefixOption.Prefix)
- ) {
- Offset += sizeof (IP6_PREFIX_INFO_OPTION);
- break;
- }
- //
- // Do following if on-link flag is set according to RFC4861.
- //
- if (OnLink) {
- PrefixList = Ip6FindPrefixListEntry (
- IpSb,
- TRUE,
- PrefixOption.PrefixLength,
- &PrefixOption.Prefix
- );
//
- // Create a new entry for the prefix, if the ValidLifetime is zero,
- // silently ignore the prefix option.
+ // Do following if on-link flag is set according to RFC4861.
//
- if (PrefixList == NULL && PrefixOption.ValidLifetime != 0) {
- PrefixList = Ip6CreatePrefixListEntry (
+ if (OnLink) {
+ PrefixList = Ip6FindPrefixListEntry (
IpSb,
TRUE,
- PrefixOption.ValidLifetime,
- PrefixOption.PreferredLifetime,
PrefixOption.PrefixLength,
&PrefixOption.Prefix
);
- if (PrefixList == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
- } else if (PrefixList != NULL) {
- if (PrefixOption.ValidLifetime != 0) {
- PrefixList->ValidLifetime = PrefixOption.ValidLifetime;
- } else {
- //
- // If the prefix exists and incoming ValidLifetime is zero, immediately
- // remove the prefix.
- Ip6DestroyPrefixListEntry (IpSb, PrefixList, OnLink, TRUE);
- }
- }
- }
-
- //
- // Do following if Autonomous flag is set according to RFC4862.
- //
- if (Autonomous && PrefixOption.PreferredLifetime <= PrefixOption.ValidLifetime) {
- PrefixList = Ip6FindPrefixListEntry (
- IpSb,
- FALSE,
- PrefixOption.PrefixLength,
- &PrefixOption.Prefix
- );
- //
- // Create a new entry for the prefix, and form an address by prefix + interface id
- // If the sum of the prefix length and interface identifier length
- // does not equal 128 bits, the Prefix Information option MUST be ignored.
- //
- if (PrefixList == NULL &&
- PrefixOption.ValidLifetime != 0 &&
- PrefixOption.PrefixLength + IpSb->InterfaceIdLen * 8 == 128
- ) {
//
- // Form the address in network order.
+ // Create a new entry for the prefix, if the ValidLifetime is zero,
+ // silently ignore the prefix option.
//
- CopyMem (&StatelessAddress, &PrefixOption.Prefix, sizeof (UINT64));
- CopyMem (&StatelessAddress.Addr[8], IpSb->InterfaceId, sizeof (UINT64));
-
- //
- // If the address is not yet in the assigned address list, adds it into.
- //
- if (!Ip6IsOneOfSetAddress (IpSb, &StatelessAddress, NULL, NULL)) {
- //
- // And also not in the DAD process, check its uniqueness firstly.
- //
- if (Ip6FindDADEntry (IpSb, &StatelessAddress, NULL) == NULL) {
- Status = Ip6SetAddress (
- IpSb->DefaultInterface,
- &StatelessAddress,
- FALSE,
- PrefixOption.PrefixLength,
- PrefixOption.ValidLifetime,
- PrefixOption.PreferredLifetime,
- NULL,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
+ if ((PrefixList == NULL) && (PrefixOption.ValidLifetime != 0)) {
+ PrefixList = Ip6CreatePrefixListEntry (
+ IpSb,
+ TRUE,
+ PrefixOption.ValidLifetime,
+ PrefixOption.PreferredLifetime,
+ PrefixOption.PrefixLength,
+ &PrefixOption.Prefix
+ );
+ if (PrefixList == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+ } else if (PrefixList != NULL) {
+ if (PrefixOption.ValidLifetime != 0) {
+ PrefixList->ValidLifetime = PrefixOption.ValidLifetime;
+ } else {
+ //
+ // If the prefix exists and incoming ValidLifetime is zero, immediately
+ // remove the prefix.
+ Ip6DestroyPrefixListEntry (IpSb, PrefixList, OnLink, TRUE);
}
}
+ }
- //
- // Adds the prefix option to stateless prefix option list.
- //
- PrefixList = Ip6CreatePrefixListEntry (
+ //
+ // Do following if Autonomous flag is set according to RFC4862.
+ //
+ if (Autonomous && (PrefixOption.PreferredLifetime <= PrefixOption.ValidLifetime)) {
+ PrefixList = Ip6FindPrefixListEntry (
IpSb,
FALSE,
- PrefixOption.ValidLifetime,
- PrefixOption.PreferredLifetime,
PrefixOption.PrefixLength,
&PrefixOption.Prefix
);
- if (PrefixList == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
- } else if (PrefixList != NULL) {
-
//
- // Reset the preferred lifetime of the address if the advertised prefix exists.
- // Perform specific action to valid lifetime together.
+ // Create a new entry for the prefix, and form an address by prefix + interface id
+ // If the sum of the prefix length and interface identifier length
+ // does not equal 128 bits, the Prefix Information option MUST be ignored.
//
- PrefixList->PreferredLifetime = PrefixOption.PreferredLifetime;
- if ((PrefixOption.ValidLifetime > 7200) ||
- (PrefixOption.ValidLifetime > PrefixList->ValidLifetime)) {
+ if ((PrefixList == NULL) &&
+ (PrefixOption.ValidLifetime != 0) &&
+ (PrefixOption.PrefixLength + IpSb->InterfaceIdLen * 8 == 128)
+ )
+ {
//
- // If the received Valid Lifetime is greater than 2 hours or
- // greater than RemainingLifetime, set the valid lifetime of the
- // corresponding address to the advertised Valid Lifetime.
+ // Form the address in network order.
//
- PrefixList->ValidLifetime = PrefixOption.ValidLifetime;
+ CopyMem (&StatelessAddress, &PrefixOption.Prefix, sizeof (UINT64));
+ CopyMem (&StatelessAddress.Addr[8], IpSb->InterfaceId, sizeof (UINT64));
- } else if (PrefixList->ValidLifetime <= 7200) {
//
- // If RemainingLifetime is less than or equals to 2 hours, ignore the
- // Prefix Information option with regards to the valid lifetime.
- // TODO: If this option has been authenticated, set the valid lifetime.
+ // If the address is not yet in the assigned address list, adds it into.
//
- } else {
+ if (!Ip6IsOneOfSetAddress (IpSb, &StatelessAddress, NULL, NULL)) {
+ //
+ // And also not in the DAD process, check its uniqueness firstly.
+ //
+ if (Ip6FindDADEntry (IpSb, &StatelessAddress, NULL) == NULL) {
+ Status = Ip6SetAddress (
+ IpSb->DefaultInterface,
+ &StatelessAddress,
+ FALSE,
+ PrefixOption.PrefixLength,
+ PrefixOption.ValidLifetime,
+ PrefixOption.PreferredLifetime,
+ NULL,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+ }
+ }
+
//
- // Otherwise, reset the valid lifetime of the corresponding
- // address to 2 hours.
+ // Adds the prefix option to stateless prefix option list.
+ //
+ PrefixList = Ip6CreatePrefixListEntry (
+ IpSb,
+ FALSE,
+ PrefixOption.ValidLifetime,
+ PrefixOption.PreferredLifetime,
+ PrefixOption.PrefixLength,
+ &PrefixOption.Prefix
+ );
+ if (PrefixList == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+ } else if (PrefixList != NULL) {
//
- PrefixList->ValidLifetime = 7200;
+ // Reset the preferred lifetime of the address if the advertised prefix exists.
+ // Perform specific action to valid lifetime together.
+ //
+ PrefixList->PreferredLifetime = PrefixOption.PreferredLifetime;
+ if ((PrefixOption.ValidLifetime > 7200) ||
+ (PrefixOption.ValidLifetime > PrefixList->ValidLifetime))
+ {
+ //
+ // If the received Valid Lifetime is greater than 2 hours or
+ // greater than RemainingLifetime, set the valid lifetime of the
+ // corresponding address to the advertised Valid Lifetime.
+ //
+ PrefixList->ValidLifetime = PrefixOption.ValidLifetime;
+ } else if (PrefixList->ValidLifetime <= 7200) {
+ //
+ // If RemainingLifetime is less than or equals to 2 hours, ignore the
+ // Prefix Information option with regards to the valid lifetime.
+ // TODO: If this option has been authenticated, set the valid lifetime.
+ //
+ } else {
+ //
+ // Otherwise, reset the valid lifetime of the corresponding
+ // address to 2 hours.
+ //
+ PrefixList->ValidLifetime = 7200;
+ }
}
}
- }
- Offset += sizeof (IP6_PREFIX_INFO_OPTION);
- break;
- case Ip6OptionMtu:
- NetbufCopy (Packet, Offset, sizeof (IP6_MTU_OPTION), (UINT8 *) &MTUOption);
+ Offset += sizeof (IP6_PREFIX_INFO_OPTION);
+ break;
+ case Ip6OptionMtu:
+ NetbufCopy (Packet, Offset, sizeof (IP6_MTU_OPTION), (UINT8 *)&MTUOption);
- //
- // Option size validity ensured by Ip6IsNDOptionValid().
- //
- ASSERT (MTUOption.Length == 1);
- ASSERT (Offset + (UINT32) MTUOption.Length * 8 <= (UINT32) Head->PayloadLength);
+ //
+ // Option size validity ensured by Ip6IsNDOptionValid().
+ //
+ ASSERT (MTUOption.Length == 1);
+ ASSERT (Offset + (UINT32)MTUOption.Length * 8 <= (UINT32)Head->PayloadLength);
- //
- // Use IPv6 minimum link MTU 1280 bytes as the maximum packet size in order
- // to omit implementation of Path MTU Discovery. Thus ignore the MTU option
- // in Router Advertisement.
- //
+ //
+ // Use IPv6 minimum link MTU 1280 bytes as the maximum packet size in order
+ // to omit implementation of Path MTU Discovery. Thus ignore the MTU option
+ // in Router Advertisement.
+ //
- Offset += sizeof (IP6_MTU_OPTION);
- break;
- default:
- //
- // Silently ignore unrecognized options
- //
- NetbufCopy (Packet, Offset + sizeof (UINT8), sizeof (UINT8), &Length);
+ Offset += sizeof (IP6_MTU_OPTION);
+ break;
+ default:
+ //
+ // Silently ignore unrecognized options
+ //
+ NetbufCopy (Packet, Offset + sizeof (UINT8), sizeof (UINT8), &Length);
- ASSERT (Length != 0);
+ ASSERT (Length != 0);
- Offset += (UINT32) Length * 8;
- break;
+ Offset += (UINT32)Length * 8;
+ break;
}
}
@@ -2382,31 +2393,31 @@ Exit:
**/
EFI_STATUS
Ip6ProcessRedirect (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD *Icmp;
- EFI_IPv6_ADDRESS *Target;
- EFI_IPv6_ADDRESS *IcmpDest;
- UINT8 *Option;
- UINT16 OptionLen;
- IP6_ROUTE_ENTRY *RouteEntry;
- IP6_ROUTE_CACHE_ENTRY *RouteCache;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- INT32 Length;
- UINT8 OptLen;
- IP6_ETHER_ADDR_OPTION *LinkLayerOption;
- EFI_MAC_ADDRESS Mac;
- UINT32 Index;
- BOOLEAN IsRouter;
- EFI_STATUS Status;
- INTN Result;
+ IP6_ICMP_INFORMATION_HEAD *Icmp;
+ EFI_IPv6_ADDRESS *Target;
+ EFI_IPv6_ADDRESS *IcmpDest;
+ UINT8 *Option;
+ UINT16 OptionLen;
+ IP6_ROUTE_ENTRY *RouteEntry;
+ IP6_ROUTE_CACHE_ENTRY *RouteCache;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ INT32 Length;
+ UINT8 OptLen;
+ IP6_ETHER_ADDR_OPTION *LinkLayerOption;
+ EFI_MAC_ADDRESS Mac;
+ UINT32 Index;
+ BOOLEAN IsRouter;
+ EFI_STATUS Status;
+ INTN Result;
Status = EFI_INVALID_PARAMETER;
- Icmp = (IP6_ICMP_INFORMATION_HEAD *) NetbufGetByte (Packet, 0, NULL);
+ Icmp = (IP6_ICMP_INFORMATION_HEAD *)NetbufGetByte (Packet, 0, NULL);
if (Icmp == NULL) {
goto Exit;
}
@@ -2421,8 +2432,9 @@ Ip6ProcessRedirect (
// ICMP Code is 0.
// ICMP length (derived from the IP length) is 40 or more octets.
//
- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp->Head.Code != 0 ||
- Head->PayloadLength < IP6_REDITECT_LENGTH) {
+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp->Head.Code != 0) ||
+ (Head->PayloadLength < IP6_REDITECT_LENGTH))
+ {
goto Exit;
}
@@ -2443,9 +2455,9 @@ Ip6ProcessRedirect (
//
// All included options have a length that is greater than zero.
//
- OptionLen = (UINT16) (Head->PayloadLength - IP6_REDITECT_LENGTH);
+ OptionLen = (UINT16)(Head->PayloadLength - IP6_REDITECT_LENGTH);
if (OptionLen != 0) {
- Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL);
+ Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL);
ASSERT (Option != NULL);
if (!Ip6IsNDOptionValid (Option, OptionLen)) {
@@ -2453,7 +2465,7 @@ Ip6ProcessRedirect (
}
}
- Target = (EFI_IPv6_ADDRESS *) (Icmp + 1);
+ Target = (EFI_IPv6_ADDRESS *)(Icmp + 1);
IcmpDest = Target + 1;
//
@@ -2479,32 +2491,34 @@ Ip6ProcessRedirect (
// address option.
//
Length = Packet->TotalSize - 40;
- Option = (UINT8 *) (IcmpDest + 1);
+ Option = (UINT8 *)(IcmpDest + 1);
LinkLayerOption = NULL;
while (Length > 0) {
switch (*Option) {
- case Ip6OptionEtherTarget:
+ case Ip6OptionEtherTarget:
- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) Option;
- OptLen = LinkLayerOption->Length;
- if (OptLen != 1) {
- //
- // For ethernet, the length must be 1.
- //
- goto Exit;
- }
- break;
+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)Option;
+ OptLen = LinkLayerOption->Length;
+ if (OptLen != 1) {
+ //
+ // For ethernet, the length must be 1.
+ //
+ goto Exit;
+ }
- default:
+ break;
- OptLen = *(Option + 1);
- if (OptLen == 0) {
- //
- // A length of 0 is invalid.
- //
- goto Exit;
- }
- break;
+ default:
+
+ OptLen = *(Option + 1);
+ if (OptLen == 0) {
+ //
+ // A length of 0 is invalid.
+ //
+ goto Exit;
+ }
+
+ break;
}
Length -= 8 * OptLen;
@@ -2535,10 +2549,9 @@ Ip6ProcessRedirect (
IP6_COPY_ADDRESS (&RouteCache->NextHop, Target);
if (!IsRouter) {
- RouteEntry = (IP6_ROUTE_ENTRY *) RouteCache->Tag;
+ RouteEntry = (IP6_ROUTE_ENTRY *)RouteCache->Tag;
RouteEntry->Flag = RouteEntry->Flag | IP6_DIRECT_ROUTE;
}
-
} else {
//
// Get the Route Entry.
@@ -2563,7 +2576,7 @@ Ip6ProcessRedirect (
IcmpDest,
&Head->DestinationAddress,
Target,
- (UINTN) RouteEntry
+ (UINTN)RouteEntry
);
if (RouteCache == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -2600,7 +2613,7 @@ Ip6ProcessRedirect (
}
NeighborCache->State = EfiNeighborStale;
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
} else {
Result = CompareMem (LinkLayerOption->EtherAddr, &NeighborCache->LinkAddress, 6);
@@ -2612,14 +2625,14 @@ Ip6ProcessRedirect (
if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) {
CopyMem (&NeighborCache->LinkAddress, LinkLayerOption->EtherAddr, 6);
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
if (NeighborCache->State == EfiNeighborInComplete) {
//
// Send queued packets if exist.
//
NeighborCache->State = EfiNeighborStale;
- NeighborCache->CallBack ((VOID *) NeighborCache);
+ NeighborCache->CallBack ((VOID *)NeighborCache);
} else {
NeighborCache->State = EfiNeighborStale;
}
@@ -2627,7 +2640,7 @@ Ip6ProcessRedirect (
}
}
- if (NeighborCache != NULL && IsRouter) {
+ if ((NeighborCache != NULL) && IsRouter) {
//
// The Target is a router, set IsRouter to TRUE.
//
@@ -2667,14 +2680,14 @@ Exit:
**/
EFI_STATUS
Ip6AddNeighbor (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
- IN UINT32 Timeout,
- IN BOOLEAN Override
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
+ IN UINT32 Timeout,
+ IN BOOLEAN Override
)
{
- IP6_NEIGHBOR_ENTRY *Neighbor;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
Neighbor = Ip6FindNeighborEntry (IpSb, TargetIp6Address);
if (Neighbor != NULL) {
@@ -2702,7 +2715,7 @@ Ip6AddNeighbor (
Neighbor->Ticks = IP6_GET_TICKS (Timeout / TICKS_PER_MS);
Neighbor->Dynamic = TRUE;
} else {
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
}
return EFI_SUCCESS;
@@ -2729,14 +2742,14 @@ Ip6AddNeighbor (
**/
EFI_STATUS
Ip6DelNeighbor (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
- IN UINT32 Timeout,
- IN BOOLEAN Override
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
+ IN UINT32 Timeout,
+ IN BOOLEAN Override
)
{
- IP6_NEIGHBOR_ENTRY *Neighbor;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
Neighbor = Ip6FindNeighborEntry (IpSb, TargetIp6Address);
if (Neighbor == NULL) {
@@ -2761,24 +2774,24 @@ Ip6DelNeighbor (
VOID
EFIAPI
Ip6NdFasterTimerTicking (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- LIST_ENTRY *Entry2;
- IP6_INTERFACE *IpIf;
- IP6_DELAY_JOIN_LIST *DelayNode;
- EFI_IPv6_ADDRESS Source;
- IP6_DAD_ENTRY *DupAddrDetect;
- EFI_STATUS Status;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- EFI_IPv6_ADDRESS Destination;
- IP6_SERVICE *IpSb;
- BOOLEAN Flag;
-
- IpSb = (IP6_SERVICE *) Context;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ LIST_ENTRY *Entry2;
+ IP6_INTERFACE *IpIf;
+ IP6_DELAY_JOIN_LIST *DelayNode;
+ EFI_IPv6_ADDRESS Source;
+ IP6_DAD_ENTRY *DupAddrDetect;
+ EFI_STATUS Status;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ EFI_IPv6_ADDRESS Destination;
+ IP6_SERVICE *IpSb;
+ BOOLEAN Flag;
+
+ IpSb = (IP6_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ZeroMem (&Source, sizeof (EFI_IPv6_ADDRESS));
@@ -2790,13 +2803,14 @@ Ip6NdFasterTimerTicking (
//
if ((IpSb->Ip6ConfigInstance.Policy == Ip6ConfigPolicyAutomatic) &&
!IpSb->RouterAdvertiseReceived &&
- IpSb->SolicitTimer > 0
- ) {
+ (IpSb->SolicitTimer > 0)
+ )
+ {
if ((IpSb->Ticks == 0) || (--IpSb->Ticks == 0)) {
Status = Ip6SendRouterSolicit (IpSb, NULL, NULL, NULL, NULL);
if (!EFI_ERROR (Status)) {
IpSb->SolicitTimer--;
- IpSb->Ticks = (UINT32) IP6_GET_TICKS (IP6_RTR_SOLICITATION_INTERVAL);
+ IpSb->Ticks = (UINT32)IP6_GET_TICKS (IP6_RTR_SOLICITATION_INTERVAL);
}
}
}
@@ -2864,7 +2878,8 @@ Ip6NdFasterTimerTicking (
//
Flag = FALSE;
if ((DupAddrDetect->Receive == 0) ||
- (DupAddrDetect->Transmit <= DupAddrDetect->Receive)) {
+ (DupAddrDetect->Transmit <= DupAddrDetect->Receive))
+ {
Flag = TRUE;
}
@@ -2881,149 +2896,111 @@ Ip6NdFasterTimerTicking (
NeighborCache = NET_LIST_USER_STRUCT (Entry, IP6_NEIGHBOR_ENTRY, Link);
switch (NeighborCache->State) {
- case EfiNeighborInComplete:
- if (NeighborCache->Ticks > 0) {
- --NeighborCache->Ticks;
- }
-
- //
- // Retransmit Neighbor Solicitation messages approximately every
- // RetransTimer milliseconds while awaiting a response.
- //
- if (NeighborCache->Ticks == 0) {
- if (NeighborCache->Transmit > 1) {
- //
- // Send out multicast neighbor solicitation for address resolution.
- // After last neighbor solicitation message has been sent out, wait
- // for RetransTimer and then remove entry if no response is received.
- //
- Ip6CreateSNMulticastAddr (&NeighborCache->Neighbor, &Destination);
- Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
- if (EFI_ERROR (Status)) {
- return;
- }
-
- Status = Ip6SendNeighborSolicit (
- IpSb,
- &Source,
- &Destination,
- &NeighborCache->Neighbor,
- &IpSb->SnpMode.CurrentAddress
- );
- if (EFI_ERROR (Status)) {
- return;
- }
+ case EfiNeighborInComplete:
+ if (NeighborCache->Ticks > 0) {
+ --NeighborCache->Ticks;
}
//
- // Update the retransmit times.
+ // Retransmit Neighbor Solicitation messages approximately every
+ // RetransTimer milliseconds while awaiting a response.
//
- if (NeighborCache->Transmit > 0) {
- --NeighborCache->Transmit;
- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
- }
- }
-
- if (NeighborCache->Transmit == 0) {
- //
- // Timeout, send ICMP destination unreachable packet and then remove entry
- //
- Status = Ip6FreeNeighborEntry (
- IpSb,
- NeighborCache,
- TRUE,
- TRUE,
- EFI_ICMP_ERROR,
- NULL,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return;
- }
- }
+ if (NeighborCache->Ticks == 0) {
+ if (NeighborCache->Transmit > 1) {
+ //
+ // Send out multicast neighbor solicitation for address resolution.
+ // After last neighbor solicitation message has been sent out, wait
+ // for RetransTimer and then remove entry if no response is received.
+ //
+ Ip6CreateSNMulticastAddr (&NeighborCache->Neighbor, &Destination);
+ Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
- break;
+ Status = Ip6SendNeighborSolicit (
+ IpSb,
+ &Source,
+ &Destination,
+ &NeighborCache->Neighbor,
+ &IpSb->SnpMode.CurrentAddress
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ }
- case EfiNeighborReachable:
- //
- // This entry is inserted by EfiIp6Neighbors() as static entry
- // and will not timeout.
- //
- if (!NeighborCache->Dynamic && (NeighborCache->Ticks == IP6_INFINIT_LIFETIME)) {
- break;
- }
+ //
+ // Update the retransmit times.
+ //
+ if (NeighborCache->Transmit > 0) {
+ --NeighborCache->Transmit;
+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
+ }
+ }
- if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) {
- if (NeighborCache->Dynamic) {
+ if (NeighborCache->Transmit == 0) {
//
- // This entry is inserted by EfiIp6Neighbors() as dynamic entry
- // and will be deleted after timeout.
+ // Timeout, send ICMP destination unreachable packet and then remove entry
//
Status = Ip6FreeNeighborEntry (
IpSb,
NeighborCache,
- FALSE,
TRUE,
- EFI_TIMEOUT,
+ TRUE,
+ EFI_ICMP_ERROR,
NULL,
NULL
);
if (EFI_ERROR (Status)) {
return;
}
- } else {
- NeighborCache->State = EfiNeighborStale;
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
}
- }
- break;
-
- case EfiNeighborDelay:
- if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) {
+ break;
- NeighborCache->State = EfiNeighborProbe;
- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
- NeighborCache->Transmit = IP6_MAX_UNICAST_SOLICIT + 1;
+ case EfiNeighborReachable:
//
- // Send out unicast neighbor solicitation for Neighbor Unreachability Detection
+ // This entry is inserted by EfiIp6Neighbors() as static entry
+ // and will not timeout.
//
- Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
- if (EFI_ERROR (Status)) {
- return;
+ if (!NeighborCache->Dynamic && (NeighborCache->Ticks == IP6_INFINIT_LIFETIME)) {
+ break;
}
- Status = Ip6SendNeighborSolicit (
- IpSb,
- &Source,
- &NeighborCache->Neighbor,
- &NeighborCache->Neighbor,
- &IpSb->SnpMode.CurrentAddress
- );
- if (EFI_ERROR (Status)) {
- return;
+ if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) {
+ if (NeighborCache->Dynamic) {
+ //
+ // This entry is inserted by EfiIp6Neighbors() as dynamic entry
+ // and will be deleted after timeout.
+ //
+ Status = Ip6FreeNeighborEntry (
+ IpSb,
+ NeighborCache,
+ FALSE,
+ TRUE,
+ EFI_TIMEOUT,
+ NULL,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ } else {
+ NeighborCache->State = EfiNeighborStale;
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
+ }
}
- NeighborCache->Transmit--;
- }
-
- break;
-
- case EfiNeighborProbe:
- if (NeighborCache->Ticks > 0) {
- --NeighborCache->Ticks;
- }
+ break;
- //
- // Retransmit Neighbor Solicitation messages approximately every
- // RetransTimer milliseconds while awaiting a response.
- //
- if (NeighborCache->Ticks == 0) {
- if (NeighborCache->Transmit > 1) {
+ case EfiNeighborDelay:
+ if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) {
+ NeighborCache->State = EfiNeighborProbe;
+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
+ NeighborCache->Transmit = IP6_MAX_UNICAST_SOLICIT + 1;
//
- // Send out unicast neighbor solicitation for Neighbor Unreachability
- // Detection. After last neighbor solicitation message has been sent out,
- // wait for RetransTimer and then remove entry if no response is received.
+ // Send out unicast neighbor solicitation for Neighbor Unreachability Detection
//
Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
if (EFI_ERROR (Status)) {
@@ -3040,39 +3017,76 @@ Ip6NdFasterTimerTicking (
if (EFI_ERROR (Status)) {
return;
}
+
+ NeighborCache->Transmit--;
}
- //
- // Update the retransmit times.
- //
- if (NeighborCache->Transmit > 0) {
- --NeighborCache->Transmit;
- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
+ break;
+
+ case EfiNeighborProbe:
+ if (NeighborCache->Ticks > 0) {
+ --NeighborCache->Ticks;
}
- }
- if (NeighborCache->Transmit == 0) {
//
- // Delete the neighbor entry.
+ // Retransmit Neighbor Solicitation messages approximately every
+ // RetransTimer milliseconds while awaiting a response.
//
- Status = Ip6FreeNeighborEntry (
- IpSb,
- NeighborCache,
- FALSE,
- TRUE,
- EFI_TIMEOUT,
- NULL,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return;
+ if (NeighborCache->Ticks == 0) {
+ if (NeighborCache->Transmit > 1) {
+ //
+ // Send out unicast neighbor solicitation for Neighbor Unreachability
+ // Detection. After last neighbor solicitation message has been sent out,
+ // wait for RetransTimer and then remove entry if no response is received.
+ //
+ Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ Status = Ip6SendNeighborSolicit (
+ IpSb,
+ &Source,
+ &NeighborCache->Neighbor,
+ &NeighborCache->Neighbor,
+ &IpSb->SnpMode.CurrentAddress
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ }
+
+ //
+ // Update the retransmit times.
+ //
+ if (NeighborCache->Transmit > 0) {
+ --NeighborCache->Transmit;
+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
+ }
}
- }
- break;
+ if (NeighborCache->Transmit == 0) {
+ //
+ // Delete the neighbor entry.
+ //
+ Status = Ip6FreeNeighborEntry (
+ IpSb,
+ NeighborCache,
+ FALSE,
+ TRUE,
+ EFI_TIMEOUT,
+ NULL,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ }
- default:
- break;
+ break;
+
+ default:
+ break;
}
}
}
@@ -3087,15 +3101,15 @@ Ip6NdFasterTimerTicking (
**/
VOID
Ip6NdTimerTicking (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_DEFAULT_ROUTER *DefaultRouter;
- IP6_PREFIX_LIST_ENTRY *PrefixOption;
- UINT8 Index;
- IP6_ROUTE_CACHE_ENTRY *RouteCache;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_PREFIX_LIST_ENTRY *PrefixOption;
+ UINT8 Index;
+ IP6_ROUTE_CACHE_ENTRY *RouteCache;
//
// Decrease the lifetime of default router, if expires remove it from default router list.
@@ -3114,11 +3128,12 @@ Ip6NdTimerTicking (
//
NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpSb->AutonomousPrefix) {
PrefixOption = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link);
- if (PrefixOption->ValidLifetime != (UINT32) IP6_INFINIT_LIFETIME) {
+ if (PrefixOption->ValidLifetime != (UINT32)IP6_INFINIT_LIFETIME) {
if ((PrefixOption->ValidLifetime > 0) && (--PrefixOption->ValidLifetime > 0)) {
- if ((PrefixOption->PreferredLifetime != (UINT32) IP6_INFINIT_LIFETIME) &&
+ if ((PrefixOption->PreferredLifetime != (UINT32)IP6_INFINIT_LIFETIME) &&
(PrefixOption->PreferredLifetime > 0)
- ) {
+ )
+ {
--PrefixOption->PreferredLifetime;
}
} else {
@@ -3129,7 +3144,7 @@ Ip6NdTimerTicking (
NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpSb->OnlinkPrefix) {
PrefixOption = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link);
- if (PrefixOption->ValidLifetime != (UINT32) IP6_INFINIT_LIFETIME) {
+ if (PrefixOption->ValidLifetime != (UINT32)IP6_INFINIT_LIFETIME) {
if ((PrefixOption->ValidLifetime == 0) || (--PrefixOption->ValidLifetime == 0)) {
Ip6DestroyPrefixListEntry (IpSb, PrefixOption, TRUE, TRUE);
}
@@ -3156,4 +3171,3 @@ Ip6NdTimerTicking (
}
}
}
-
diff --git a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c
index 0f95ce4b71..0428abdda0 100644
--- a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c
+++ b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c
@@ -32,8 +32,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
-#define NIC_ITEM_CONFIG_SIZE (sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE)
-#define DEFAULT_ZERO_START ((UINTN) ~0)
+#define NIC_ITEM_CONFIG_SIZE (sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE)
+#define DEFAULT_ZERO_START ((UINTN) ~0)
//
// All the supported IP4 masks in host byte order.
@@ -77,25 +77,27 @@ GLOBAL_REMOVE_IF_UNREFERENCED IP4_ADDR gIp4AllMasks[IP4_MASK_NUM] = {
0xFFFFFFFF,
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_IPv4_ADDRESS mZeroIp4Addr = {{0, 0, 0, 0}};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_IPv4_ADDRESS mZeroIp4Addr = {
+ { 0, 0, 0, 0 }
+};
//
// Any error level digitally larger than mNetDebugLevelMax
// will be silently discarded.
//
-GLOBAL_REMOVE_IF_UNREFERENCED UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR;
-GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogPacketSeq = 0xDEADBEEF;
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR;
+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogPacketSeq = 0xDEADBEEF;
//
// You can change mSyslogDstMac mSyslogDstIp and mSyslogSrcIp
// here to direct the syslog packets to the syslog deamon. The
// default is broadcast to both the ethernet and IP.
//
-GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mSyslogDstMac[NET_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogDstIp = 0xffffffff;
-GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogSrcIp = 0;
+GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mSyslogDstMac[NET_ETHER_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogDstIp = 0xffffffff;
+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogSrcIp = 0;
-GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mMonthName[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mMonthName[] = {
"Jan",
"Feb",
"Mar",
@@ -113,13 +115,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mMonthName[] = {
//
// VLAN device path node template
//
-GLOBAL_REMOVE_IF_UNREFERENCED VLAN_DEVICE_PATH mNetVlanDevicePathTemplate = {
+GLOBAL_REMOVE_IF_UNREFERENCED VLAN_DEVICE_PATH mNetVlanDevicePathTemplate = {
{
MESSAGING_DEVICE_PATH,
MSG_VLAN_DP,
{
- (UINT8) (sizeof (VLAN_DEVICE_PATH)),
- (UINT8) ((sizeof (VLAN_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VLAN_DEVICE_PATH)),
+ (UINT8)((sizeof (VLAN_DEVICE_PATH)) >> 8)
}
},
0
@@ -138,11 +140,11 @@ SyslogLocateSnp (
VOID
)
{
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- EFI_STATUS Status;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN Index;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
//
// Locate the handles which has SNP installed.
@@ -169,13 +171,13 @@ SyslogLocateSnp (
Status = gBS->HandleProtocol (
Handles[Index],
&gEfiSimpleNetworkProtocolGuid,
- (VOID **) &Snp
+ (VOID **)&Snp
);
if ((Status == EFI_SUCCESS) && (Snp != NULL) &&
(Snp->Mode->IfType == NET_IFTYPE_ETHERNET) &&
- (Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN)) {
-
+ (Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN))
+ {
break;
}
@@ -204,15 +206,15 @@ SyslogLocateSnp (
**/
EFI_STATUS
SyslogSendPacket (
- IN CHAR8 *Packet,
- IN UINT32 Length
+ IN CHAR8 *Packet,
+ IN UINT32 Length
)
{
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- ETHER_HEAD *Ether;
- EFI_STATUS Status;
- EFI_EVENT TimeoutEvent;
- UINT8 *TxBuf;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ ETHER_HEAD *Ether;
+ EFI_STATUS Status;
+ EFI_EVENT TimeoutEvent;
+ UINT8 *TxBuf;
ASSERT (Packet != NULL);
@@ -222,7 +224,7 @@ SyslogSendPacket (
return EFI_DEVICE_ERROR;
}
- Ether = (ETHER_HEAD *) Packet;
+ Ether = (ETHER_HEAD *)Packet;
CopyMem (Ether->SrcMac, Snp->Mode->CurrentAddress.Addr, NET_ETHER_ADDR_LEN);
//
@@ -246,7 +248,7 @@ SyslogSendPacket (
goto ON_EXIT;
}
- for (;;) {
+ for ( ; ;) {
//
// Transmit the packet through SNP.
//
@@ -268,13 +270,12 @@ SyslogSendPacket (
//
// Get the recycled transmit buffer status.
//
- Snp->GetStatus (Snp, NULL, (VOID **) &TxBuf);
+ Snp->GetStatus (Snp, NULL, (VOID **)&TxBuf);
if (!EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
Status = EFI_TIMEOUT;
break;
}
-
} while (TxBuf == NULL);
if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) {
@@ -312,71 +313,71 @@ ON_EXIT:
**/
UINT32
SyslogBuildPacket (
- IN UINT32 Level,
- IN UINT8 *Module,
- IN UINT8 *File,
- IN UINT32 Line,
- IN UINT8 *Message,
- IN UINT32 BufLen,
- OUT CHAR8 *Buf
+ IN UINT32 Level,
+ IN UINT8 *Module,
+ IN UINT8 *File,
+ IN UINT32 Line,
+ IN UINT8 *Message,
+ IN UINT32 BufLen,
+ OUT CHAR8 *Buf
)
{
- EFI_STATUS Status;
- ETHER_HEAD *Ether;
- IP4_HEAD *Ip4;
- EFI_UDP_HEADER *Udp4;
- EFI_TIME Time;
- UINT32 Pri;
- UINT32 Len;
+ EFI_STATUS Status;
+ ETHER_HEAD *Ether;
+ IP4_HEAD *Ip4;
+ EFI_UDP_HEADER *Udp4;
+ EFI_TIME Time;
+ UINT32 Pri;
+ UINT32 Len;
//
// Fill in the Ethernet header. Leave alone the source MAC.
// SyslogSendPacket will fill in the address for us.
//
- Ether = (ETHER_HEAD *) Buf;
+ Ether = (ETHER_HEAD *)Buf;
CopyMem (Ether->DstMac, mSyslogDstMac, NET_ETHER_ADDR_LEN);
ZeroMem (Ether->SrcMac, NET_ETHER_ADDR_LEN);
Ether->EtherType = HTONS (0x0800); // IPv4 protocol
- Buf += sizeof (ETHER_HEAD);
- BufLen -= sizeof (ETHER_HEAD);
+ Buf += sizeof (ETHER_HEAD);
+ BufLen -= sizeof (ETHER_HEAD);
//
// Fill in the IP header
//
- Ip4 = (IP4_HEAD *) Buf;
- Ip4->HeadLen = 5;
- Ip4->Ver = 4;
- Ip4->Tos = 0;
- Ip4->TotalLen = 0;
- Ip4->Id = (UINT16) mSyslogPacketSeq;
- Ip4->Fragment = 0;
- Ip4->Ttl = 16;
- Ip4->Protocol = 0x11;
- Ip4->Checksum = 0;
- Ip4->Src = mSyslogSrcIp;
- Ip4->Dst = mSyslogDstIp;
+ Ip4 = (IP4_HEAD *)Buf;
+ Ip4->HeadLen = 5;
+ Ip4->Ver = 4;
+ Ip4->Tos = 0;
+ Ip4->TotalLen = 0;
+ Ip4->Id = (UINT16)mSyslogPacketSeq;
+ Ip4->Fragment = 0;
+ Ip4->Ttl = 16;
+ Ip4->Protocol = 0x11;
+ Ip4->Checksum = 0;
+ Ip4->Src = mSyslogSrcIp;
+ Ip4->Dst = mSyslogDstIp;
- Buf += sizeof (IP4_HEAD);
- BufLen -= sizeof (IP4_HEAD);
+ Buf += sizeof (IP4_HEAD);
+ BufLen -= sizeof (IP4_HEAD);
//
// Fill in the UDP header, Udp checksum is optional. Leave it zero.
//
- Udp4 = (EFI_UDP_HEADER *) Buf;
- Udp4->SrcPort = HTONS (514);
- Udp4->DstPort = HTONS (514);
- Udp4->Length = 0;
- Udp4->Checksum = 0;
+ Udp4 = (EFI_UDP_HEADER *)Buf;
+ Udp4->SrcPort = HTONS (514);
+ Udp4->DstPort = HTONS (514);
+ Udp4->Length = 0;
+ Udp4->Checksum = 0;
- Buf += sizeof (EFI_UDP_HEADER);
- BufLen -= sizeof (EFI_UDP_HEADER);
+ Buf += sizeof (EFI_UDP_HEADER);
+ BufLen -= sizeof (EFI_UDP_HEADER);
//
// Build the syslog message body with <PRI> Timestamp machine module Message
//
- Pri = ((NET_SYSLOG_FACILITY & 31) << 3) | (Level & 7);
+ Pri = ((NET_SYSLOG_FACILITY & 31) << 3) | (Level & 7);
Status = gRT->GetTime (&Time, NULL);
if (EFI_ERROR (Status)) {
return 0;
@@ -386,38 +387,38 @@ SyslogBuildPacket (
// Use %a to format the ASCII strings, %s to format UNICODE strings
//
Len = 0;
- Len += (UINT32) AsciiSPrint (
- Buf,
- BufLen,
- "<%d> %a %d %d:%d:%d ",
- Pri,
- mMonthName [Time.Month-1],
- Time.Day,
- Time.Hour,
- Time.Minute,
- Time.Second
- );
+ Len += (UINT32)AsciiSPrint (
+ Buf,
+ BufLen,
+ "<%d> %a %d %d:%d:%d ",
+ Pri,
+ mMonthName[Time.Month-1],
+ Time.Day,
+ Time.Hour,
+ Time.Minute,
+ Time.Second
+ );
- Len += (UINT32) AsciiSPrint (
- Buf + Len,
- BufLen - Len,
- "Tiano %a: %a (Line: %d File: %a)",
- Module,
- Message,
- Line,
- File
- );
- Len ++;
+ Len += (UINT32)AsciiSPrint (
+ Buf + Len,
+ BufLen - Len,
+ "Tiano %a: %a (Line: %d File: %a)",
+ Module,
+ Message,
+ Line,
+ File
+ );
+ Len++;
//
// OK, patch the IP length/checksum and UDP length fields.
//
- Len += sizeof (EFI_UDP_HEADER);
- Udp4->Length = HTONS ((UINT16) Len);
+ Len += sizeof (EFI_UDP_HEADER);
+ Udp4->Length = HTONS ((UINT16)Len);
- Len += sizeof (IP4_HEAD);
- Ip4->TotalLen = HTONS ((UINT16) Len);
- Ip4->Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Ip4, sizeof (IP4_HEAD)));
+ Len += sizeof (IP4_HEAD);
+ Ip4->TotalLen = HTONS ((UINT16)Len);
+ Ip4->Checksum = (UINT16)(~NetblockChecksum ((UINT8 *)Ip4, sizeof (IP4_HEAD)));
return Len + sizeof (ETHER_HEAD);
}
@@ -451,16 +452,16 @@ SyslogBuildPacket (
CHAR8 *
EFIAPI
NetDebugASPrint (
- IN CHAR8 *Format,
+ IN CHAR8 *Format,
...
)
{
- VA_LIST Marker;
- CHAR8 *Buf;
+ VA_LIST Marker;
+ CHAR8 *Buf;
ASSERT (Format != NULL);
- Buf = (CHAR8 *) AllocatePool (NET_DEBUG_MSG_LEN);
+ Buf = (CHAR8 *)AllocatePool (NET_DEBUG_MSG_LEN);
if (Buf == NULL) {
return NULL;
@@ -494,21 +495,21 @@ NetDebugASPrint (
EFI_STATUS
EFIAPI
NetDebugOutput (
- IN UINT32 Level,
- IN UINT8 *Module,
- IN UINT8 *File,
- IN UINT32 Line,
- IN UINT8 *Message
+ IN UINT32 Level,
+ IN UINT8 *Module,
+ IN UINT8 *File,
+ IN UINT32 Line,
+ IN UINT8 *Message
)
{
- CHAR8 *Packet;
- UINT32 Len;
- EFI_STATUS Status;
+ CHAR8 *Packet;
+ UINT32 Len;
+ EFI_STATUS Status;
//
// Check whether the message should be sent out
//
- if (Message == NULL || File == NULL || Module == NULL) {
+ if ((Message == NULL) || (File == NULL) || (Module == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -522,7 +523,7 @@ NetDebugOutput (
// that the message plus the ethernet/ip/udp header is shorter
// than this
//
- Packet = (CHAR8 *) AllocatePool (NET_SYSLOG_PACKET_LEN);
+ Packet = (CHAR8 *)AllocatePool (NET_SYSLOG_PACKET_LEN);
if (Packet == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -554,6 +555,7 @@ ON_EXIT:
FreePool (Message);
return Status;
}
+
/**
Return the length of the mask.
@@ -569,10 +571,10 @@ ON_EXIT:
INTN
EFIAPI
NetGetMaskLength (
- IN IP4_ADDR NetMask
+ IN IP4_ADDR NetMask
)
{
- INTN Index;
+ INTN Index;
for (Index = 0; Index <= IP4_MASK_MAX; Index++) {
if (NetMask == gIp4AllMasks[Index]) {
@@ -583,8 +585,6 @@ NetGetMaskLength (
return Index;
}
-
-
/**
Return the class of the IP address, such as class A, B, C.
Addr is in host byte order.
@@ -614,32 +614,26 @@ NetGetMaskLength (
INTN
EFIAPI
NetGetIpClass (
- IN IP4_ADDR Addr
+ IN IP4_ADDR Addr
)
{
- UINT8 ByteOne;
+ UINT8 ByteOne;
- ByteOne = (UINT8) (Addr >> 24);
+ ByteOne = (UINT8)(Addr >> 24);
if ((ByteOne & 0x80) == 0) {
return IP4_ADDR_CLASSA;
-
} else if ((ByteOne & 0xC0) == 0x80) {
return IP4_ADDR_CLASSB;
-
} else if ((ByteOne & 0xE0) == 0xC0) {
return IP4_ADDR_CLASSC;
-
} else if ((ByteOne & 0xF0) == 0xE0) {
return IP4_ADDR_CLASSD;
-
} else {
return IP4_ADDR_CLASSE;
-
}
}
-
/**
Check whether the IP is a valid unicast address according to
the netmask.
@@ -660,15 +654,15 @@ NetGetIpClass (
BOOLEAN
EFIAPI
NetIp4IsUnicast (
- IN IP4_ADDR Ip,
- IN IP4_ADDR NetMask
+ IN IP4_ADDR Ip,
+ IN IP4_ADDR NetMask
)
{
- INTN MaskLength;
+ INTN MaskLength;
ASSERT (NetMask != 0);
- if (Ip == 0 || IP4_IS_LOCAL_BROADCAST (Ip)) {
+ if ((Ip == 0) || IP4_IS_LOCAL_BROADCAST (Ip)) {
return FALSE;
}
@@ -702,11 +696,11 @@ NetIp4IsUnicast (
BOOLEAN
EFIAPI
NetIp6IsValidUnicast (
- IN EFI_IPv6_ADDRESS *Ip6
+ IN EFI_IPv6_ADDRESS *Ip6
)
{
- UINT8 Byte;
- UINT8 Index;
+ UINT8 Byte;
+ UINT8 Index;
ASSERT (Ip6 != NULL);
@@ -722,7 +716,7 @@ NetIp6IsValidUnicast (
Byte = Ip6->Addr[Index];
- if (Byte == 0x0 || Byte == 0x1) {
+ if ((Byte == 0x0) || (Byte == 0x1)) {
return FALSE;
}
@@ -743,10 +737,10 @@ NetIp6IsValidUnicast (
BOOLEAN
EFIAPI
NetIp6IsUnspecifiedAddr (
- IN EFI_IPv6_ADDRESS *Ip6
+ IN EFI_IPv6_ADDRESS *Ip6
)
{
- UINT8 Index;
+ UINT8 Index;
ASSERT (Ip6 != NULL);
@@ -773,10 +767,10 @@ NetIp6IsUnspecifiedAddr (
BOOLEAN
EFIAPI
NetIp6IsLinkLocalAddr (
- IN EFI_IPv6_ADDRESS *Ip6
+ IN EFI_IPv6_ADDRESS *Ip6
)
{
- UINT8 Index;
+ UINT8 Index;
ASSERT (Ip6 != NULL);
@@ -814,14 +808,14 @@ NetIp6IsLinkLocalAddr (
BOOLEAN
EFIAPI
NetIp6IsNetEqual (
- EFI_IPv6_ADDRESS *Ip1,
- EFI_IPv6_ADDRESS *Ip2,
- UINT8 PrefixLength
+ EFI_IPv6_ADDRESS *Ip1,
+ EFI_IPv6_ADDRESS *Ip2,
+ UINT8 PrefixLength
)
{
- UINT8 Byte;
- UINT8 Bit;
- UINT8 Mask;
+ UINT8 Byte;
+ UINT8 Bit;
+ UINT8 Mask;
ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength < IP6_PREFIX_MAX));
@@ -829,20 +823,21 @@ NetIp6IsNetEqual (
return TRUE;
}
- Byte = (UINT8) (PrefixLength / 8);
- Bit = (UINT8) (PrefixLength % 8);
+ Byte = (UINT8)(PrefixLength / 8);
+ Bit = (UINT8)(PrefixLength % 8);
if (CompareMem (Ip1, Ip2, Byte) != 0) {
return FALSE;
}
if (Bit > 0) {
- Mask = (UINT8) (0xFF << (8 - Bit));
+ Mask = (UINT8)(0xFF << (8 - Bit));
ASSERT (Byte < 16);
if (Byte >= 16) {
return FALSE;
}
+
if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
return FALSE;
}
@@ -851,7 +846,6 @@ NetIp6IsNetEqual (
return TRUE;
}
-
/**
Switches the endianess of an IPv6 address
@@ -869,11 +863,11 @@ NetIp6IsNetEqual (
EFI_IPv6_ADDRESS *
EFIAPI
Ip6Swap128 (
- EFI_IPv6_ADDRESS *Ip6
+ EFI_IPv6_ADDRESS *Ip6
)
{
- UINT64 High;
- UINT64 Low;
+ UINT64 High;
+ UINT64 Low;
ASSERT (Ip6 != NULL);
@@ -905,22 +899,21 @@ NetRandomInitSeed (
VOID
)
{
- EFI_TIME Time;
- UINT32 Seed;
- UINT64 MonotonicCount;
+ EFI_TIME Time;
+ UINT32 Seed;
+ UINT64 MonotonicCount;
gRT->GetTime (&Time, NULL);
- Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);
+ Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);
Seed ^= Time.Nanosecond;
Seed ^= Time.Year << 7;
gBS->GetNextMonotonicCount (&MonotonicCount);
- Seed += (UINT32) MonotonicCount;
+ Seed += (UINT32)MonotonicCount;
return Seed;
}
-
/**
Extract a UINT32 from a byte stream.
@@ -937,10 +930,10 @@ NetRandomInitSeed (
UINT32
EFIAPI
NetGetUint32 (
- IN UINT8 *Buf
+ IN UINT8 *Buf
)
{
- UINT32 Value;
+ UINT32 Value;
ASSERT (Buf != NULL);
@@ -948,7 +941,6 @@ NetGetUint32 (
return NTOHL (Value);
}
-
/**
Put a UINT32 to the byte stream in network byte order.
@@ -964,8 +956,8 @@ NetGetUint32 (
VOID
EFIAPI
NetPutUint32 (
- IN OUT UINT8 *Buf,
- IN UINT32 Data
+ IN OUT UINT8 *Buf,
+ IN UINT32 Data
)
{
ASSERT (Buf != NULL);
@@ -974,7 +966,6 @@ NetPutUint32 (
CopyMem (Buf, &Data, sizeof (UINT32));
}
-
/**
Remove the first node entry on the list, and return the removed node entry.
@@ -996,10 +987,10 @@ NetPutUint32 (
LIST_ENTRY *
EFIAPI
NetListRemoveHead (
- IN OUT LIST_ENTRY *Head
+ IN OUT LIST_ENTRY *Head
)
{
- LIST_ENTRY *First;
+ LIST_ENTRY *First;
ASSERT (Head != NULL);
@@ -1007,19 +998,18 @@ NetListRemoveHead (
return NULL;
}
- First = Head->ForwardLink;
- Head->ForwardLink = First->ForwardLink;
- First->ForwardLink->BackLink = Head;
+ First = Head->ForwardLink;
+ Head->ForwardLink = First->ForwardLink;
+ First->ForwardLink->BackLink = Head;
DEBUG_CODE (
- First->ForwardLink = (LIST_ENTRY *) NULL;
- First->BackLink = (LIST_ENTRY *) NULL;
- );
+ First->ForwardLink = (LIST_ENTRY *)NULL;
+ First->BackLink = (LIST_ENTRY *)NULL;
+ );
return First;
}
-
/**
Remove the last node entry on the list and and return the removed node entry.
@@ -1041,10 +1031,10 @@ NetListRemoveHead (
LIST_ENTRY *
EFIAPI
NetListRemoveTail (
- IN OUT LIST_ENTRY *Head
+ IN OUT LIST_ENTRY *Head
)
{
- LIST_ENTRY *Last;
+ LIST_ENTRY *Last;
ASSERT (Head != NULL);
@@ -1057,14 +1047,13 @@ NetListRemoveTail (
Last->BackLink->ForwardLink = Head;
DEBUG_CODE (
- Last->ForwardLink = (LIST_ENTRY *) NULL;
- Last->BackLink = (LIST_ENTRY *) NULL;
- );
+ Last->ForwardLink = (LIST_ENTRY *)NULL;
+ Last->BackLink = (LIST_ENTRY *)NULL;
+ );
return Last;
}
-
/**
Insert a new node entry after a designated node entry of a doubly linked list.
@@ -1080,19 +1069,18 @@ NetListRemoveTail (
VOID
EFIAPI
NetListInsertAfter (
- IN OUT LIST_ENTRY *PrevEntry,
- IN OUT LIST_ENTRY *NewEntry
+ IN OUT LIST_ENTRY *PrevEntry,
+ IN OUT LIST_ENTRY *NewEntry
)
{
ASSERT (PrevEntry != NULL && NewEntry != NULL);
- NewEntry->BackLink = PrevEntry;
- NewEntry->ForwardLink = PrevEntry->ForwardLink;
- PrevEntry->ForwardLink->BackLink = NewEntry;
- PrevEntry->ForwardLink = NewEntry;
+ NewEntry->BackLink = PrevEntry;
+ NewEntry->ForwardLink = PrevEntry->ForwardLink;
+ PrevEntry->ForwardLink->BackLink = NewEntry;
+ PrevEntry->ForwardLink = NewEntry;
}
-
/**
Insert a new node entry before a designated node entry of a doubly linked list.
@@ -1108,16 +1096,16 @@ NetListInsertAfter (
VOID
EFIAPI
NetListInsertBefore (
- IN OUT LIST_ENTRY *PostEntry,
- IN OUT LIST_ENTRY *NewEntry
+ IN OUT LIST_ENTRY *PostEntry,
+ IN OUT LIST_ENTRY *NewEntry
)
{
ASSERT (PostEntry != NULL && NewEntry != NULL);
- NewEntry->ForwardLink = PostEntry;
- NewEntry->BackLink = PostEntry->BackLink;
- PostEntry->BackLink->ForwardLink = NewEntry;
- PostEntry->BackLink = NewEntry;
+ NewEntry->ForwardLink = PostEntry;
+ NewEntry->BackLink = PostEntry->BackLink;
+ PostEntry->BackLink->ForwardLink = NewEntry;
+ PostEntry->BackLink = NewEntry;
}
/**
@@ -1151,25 +1139,26 @@ NetDestroyLinkList (
OUT UINTN *ListLength OPTIONAL
)
{
- UINTN PreviousLength;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Ptr;
- UINTN Length;
- EFI_STATUS Status;
+ UINTN PreviousLength;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Ptr;
+ UINTN Length;
+ EFI_STATUS Status;
- if (List == NULL || CallBack == NULL) {
+ if ((List == NULL) || (CallBack == NULL)) {
return EFI_INVALID_PARAMETER;
}
Length = 0;
do {
PreviousLength = Length;
- Entry = GetFirstNode (List);
+ Entry = GetFirstNode (List);
while (!IsNull (List, Entry)) {
Status = CallBack (Entry, Context);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Walk through the list to see whether the Entry has been removed or not.
// If the Entry still exists, just try to destroy the next one.
@@ -1180,18 +1169,22 @@ NetDestroyLinkList (
break;
}
}
+
if (Ptr == Entry) {
Entry = GetNextNode (List, Entry);
} else {
Entry = GetFirstNode (List);
}
}
- for (Length = 0, Ptr = List->ForwardLink; Ptr != List; Length++, Ptr = Ptr->ForwardLink);
+
+ for (Length = 0, Ptr = List->ForwardLink; Ptr != List; Length++, Ptr = Ptr->ForwardLink) {
+ }
} while (Length != PreviousLength);
if (ListLength != NULL) {
*ListLength = Length;
}
+
return EFI_SUCCESS;
}
@@ -1210,14 +1203,14 @@ NetDestroyLinkList (
BOOLEAN
EFIAPI
NetIsInHandleBuffer (
- IN EFI_HANDLE Handle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_HANDLE Handle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
- UINTN Index;
+ UINTN Index;
- if (NumberOfChildren == 0 || ChildHandleBuffer == NULL) {
+ if ((NumberOfChildren == 0) || (ChildHandleBuffer == NULL)) {
return FALSE;
}
@@ -1230,7 +1223,6 @@ NetIsInHandleBuffer (
return FALSE;
}
-
/**
Initialize the netmap. Netmap is a reposity to keep the <Key, Value> pairs.
@@ -1248,7 +1240,7 @@ NetIsInHandleBuffer (
VOID
EFIAPI
NetMapInit (
- IN OUT NET_MAP *Map
+ IN OUT NET_MAP *Map
)
{
ASSERT (Map != NULL);
@@ -1258,7 +1250,6 @@ NetMapInit (
Map->Count = 0;
}
-
/**
To clean up the netmap, that is, release allocated memories.
@@ -1274,12 +1265,12 @@ NetMapInit (
VOID
EFIAPI
NetMapClean (
- IN OUT NET_MAP *Map
+ IN OUT NET_MAP *Map
)
{
- NET_MAP_ITEM *Item;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
+ NET_MAP_ITEM *Item;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
ASSERT (Map != NULL);
@@ -1304,7 +1295,6 @@ NetMapClean (
ASSERT (IsListEmpty (&Map->Recycled));
}
-
/**
Test whether the netmap is empty and return true if it is.
@@ -1320,14 +1310,13 @@ NetMapClean (
BOOLEAN
EFIAPI
NetMapIsEmpty (
- IN NET_MAP *Map
+ IN NET_MAP *Map
)
{
ASSERT (Map != NULL);
- return (BOOLEAN) (Map->Count == 0);
+ return (BOOLEAN)(Map->Count == 0);
}
-
/**
Return the number of the <Key, Value> pairs in the netmap.
@@ -1341,14 +1330,13 @@ NetMapIsEmpty (
UINTN
EFIAPI
NetMapGetCount (
- IN NET_MAP *Map
+ IN NET_MAP *Map
)
{
ASSERT (Map != NULL);
return Map->Count;
}
-
/**
Return one allocated item.
@@ -1367,12 +1355,12 @@ NetMapGetCount (
**/
NET_MAP_ITEM *
NetMapAllocItem (
- IN OUT NET_MAP *Map
+ IN OUT NET_MAP *Map
)
{
- NET_MAP_ITEM *Item;
- LIST_ENTRY *Head;
- UINTN Index;
+ NET_MAP_ITEM *Item;
+ LIST_ENTRY *Head;
+ UINTN Index;
ASSERT (Map != NULL);
@@ -1400,7 +1388,6 @@ NetMapAllocItem (
return Item;
}
-
/**
Allocate an item to save the <Key, Value> pair to the head of the netmap.
@@ -1422,12 +1409,12 @@ NetMapAllocItem (
EFI_STATUS
EFIAPI
NetMapInsertHead (
- IN OUT NET_MAP *Map,
- IN VOID *Key,
- IN VOID *Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ IN VOID *Key,
+ IN VOID *Value OPTIONAL
)
{
- NET_MAP_ITEM *Item;
+ NET_MAP_ITEM *Item;
ASSERT (Map != NULL && Key != NULL);
@@ -1445,7 +1432,6 @@ NetMapInsertHead (
return EFI_SUCCESS;
}
-
/**
Allocate an item to save the <Key, Value> pair to the tail of the netmap.
@@ -1467,12 +1453,12 @@ NetMapInsertHead (
EFI_STATUS
EFIAPI
NetMapInsertTail (
- IN OUT NET_MAP *Map,
- IN VOID *Key,
- IN VOID *Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ IN VOID *Key,
+ IN VOID *Value OPTIONAL
)
{
- NET_MAP_ITEM *Item;
+ NET_MAP_ITEM *Item;
ASSERT (Map != NULL && Key != NULL);
@@ -1491,7 +1477,6 @@ NetMapInsertTail (
return EFI_SUCCESS;
}
-
/**
Check whether the item is in the Map and return TRUE if it is.
@@ -1506,11 +1491,11 @@ NetMapInsertTail (
**/
BOOLEAN
NetItemInMap (
- IN NET_MAP *Map,
- IN NET_MAP_ITEM *Item
+ IN NET_MAP *Map,
+ IN NET_MAP_ITEM *Item
)
{
- LIST_ENTRY *ListEntry;
+ LIST_ENTRY *ListEntry;
ASSERT (Map != NULL && Item != NULL);
@@ -1523,7 +1508,6 @@ NetItemInMap (
return FALSE;
}
-
/**
Find the key in the netmap and returns the point to the item contains the Key.
@@ -1542,12 +1526,12 @@ NetItemInMap (
NET_MAP_ITEM *
EFIAPI
NetMapFindKey (
- IN NET_MAP *Map,
- IN VOID *Key
+ IN NET_MAP *Map,
+ IN VOID *Key
)
{
- LIST_ENTRY *Entry;
- NET_MAP_ITEM *Item;
+ LIST_ENTRY *Entry;
+ NET_MAP_ITEM *Item;
ASSERT (Map != NULL && Key != NULL);
@@ -1562,7 +1546,6 @@ NetMapFindKey (
return NULL;
}
-
/**
Remove the node entry of the item from the netmap and return the key of the removed item.
@@ -1585,9 +1568,9 @@ NetMapFindKey (
VOID *
EFIAPI
NetMapRemoveItem (
- IN OUT NET_MAP *Map,
- IN OUT NET_MAP_ITEM *Item,
- OUT VOID **Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ IN OUT NET_MAP_ITEM *Item,
+ OUT VOID **Value OPTIONAL
)
{
ASSERT ((Map != NULL) && (Item != NULL));
@@ -1604,7 +1587,6 @@ NetMapRemoveItem (
return Item->Key;
}
-
/**
Remove the first node entry on the netmap and return the key of the removed item.
@@ -1625,8 +1607,8 @@ NetMapRemoveItem (
VOID *
EFIAPI
NetMapRemoveHead (
- IN OUT NET_MAP *Map,
- OUT VOID **Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ OUT VOID **Value OPTIONAL
)
{
NET_MAP_ITEM *Item;
@@ -1649,7 +1631,6 @@ NetMapRemoveHead (
return Item->Key;
}
-
/**
Remove the last node entry on the netmap and return the key of the removed item.
@@ -1670,11 +1651,11 @@ NetMapRemoveHead (
VOID *
EFIAPI
NetMapRemoveTail (
- IN OUT NET_MAP *Map,
- OUT VOID **Value OPTIONAL
+ IN OUT NET_MAP *Map,
+ OUT VOID **Value OPTIONAL
)
{
- NET_MAP_ITEM *Item;
+ NET_MAP_ITEM *Item;
//
// Often, it indicates a programming error to remove
@@ -1694,7 +1675,6 @@ NetMapRemoveTail (
return Item->Key;
}
-
/**
Iterate through the netmap and call CallBack for each item.
@@ -1717,17 +1697,16 @@ NetMapRemoveTail (
EFI_STATUS
EFIAPI
NetMapIterate (
- IN NET_MAP *Map,
- IN NET_MAP_CALLBACK CallBack,
- IN VOID *Arg OPTIONAL
+ IN NET_MAP *Map,
+ IN NET_MAP_CALLBACK CallBack,
+ IN VOID *Arg OPTIONAL
)
{
-
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- LIST_ENTRY *Head;
- NET_MAP_ITEM *Item;
- EFI_STATUS Result;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ LIST_ENTRY *Head;
+ NET_MAP_ITEM *Item;
+ EFI_STATUS Result;
ASSERT ((Map != NULL) && (CallBack != NULL));
@@ -1749,7 +1728,6 @@ NetMapIterate (
return EFI_SUCCESS;
}
-
/**
This is the default unload handle for all the network drivers.
@@ -1765,17 +1743,17 @@ NetMapIterate (
EFI_STATUS
EFIAPI
NetLibDefaultUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- EFI_HANDLE *DeviceHandleBuffer;
- UINTN DeviceHandleCount;
- UINTN Index;
- UINTN Index2;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ EFI_STATUS Status;
+ EFI_HANDLE *DeviceHandleBuffer;
+ UINTN DeviceHandleCount;
+ UINTN Index;
+ UINTN Index2;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
// Get the list of all the handles in the handle database.
@@ -1798,7 +1776,7 @@ NetLibDefaultUnload (
Status = gBS->HandleProtocol (
DeviceHandleBuffer[Index],
&gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding
+ (VOID **)&DriverBinding
);
if (EFI_ERROR (Status)) {
continue;
@@ -1824,15 +1802,15 @@ NetLibDefaultUnload (
// Uninstall all the protocols installed in the driver entry point
//
gBS->UninstallProtocolInterface (
- DriverBinding->DriverBindingHandle,
- &gEfiDriverBindingProtocolGuid,
- DriverBinding
- );
+ DriverBinding->DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
+ DriverBinding
+ );
Status = gBS->HandleProtocol (
DeviceHandleBuffer[Index],
&gEfiComponentNameProtocolGuid,
- (VOID **) &ComponentName
+ (VOID **)&ComponentName
);
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
@@ -1845,7 +1823,7 @@ NetLibDefaultUnload (
Status = gBS->HandleProtocol (
DeviceHandleBuffer[Index],
&gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
+ (VOID **)&ComponentName2
);
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
@@ -1866,8 +1844,6 @@ NetLibDefaultUnload (
return EFI_SUCCESS;
}
-
-
/**
Create a child of the service that is identified by ServiceBindingGuid.
@@ -1888,16 +1864,15 @@ NetLibDefaultUnload (
EFI_STATUS
EFIAPI
NetLibCreateServiceChild (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Image,
- IN EFI_GUID *ServiceBindingGuid,
- IN OUT EFI_HANDLE *ChildHandle
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Image,
+ IN EFI_GUID *ServiceBindingGuid,
+ IN OUT EFI_HANDLE *ChildHandle
)
{
EFI_STATUS Status;
EFI_SERVICE_BINDING_PROTOCOL *Service;
-
ASSERT ((ServiceBindingGuid != NULL) && (ChildHandle != NULL));
//
@@ -1906,7 +1881,7 @@ NetLibCreateServiceChild (
Status = gBS->OpenProtocol (
Controller,
ServiceBindingGuid,
- (VOID **) &Service,
+ (VOID **)&Service,
Image,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1923,7 +1898,6 @@ NetLibCreateServiceChild (
return Status;
}
-
/**
Destroy a child of the service that is identified by ServiceBindingGuid.
@@ -1943,10 +1917,10 @@ NetLibCreateServiceChild (
EFI_STATUS
EFIAPI
NetLibDestroyServiceChild (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Image,
- IN EFI_GUID *ServiceBindingGuid,
- IN EFI_HANDLE ChildHandle
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Image,
+ IN EFI_GUID *ServiceBindingGuid,
+ IN EFI_HANDLE ChildHandle
)
{
EFI_STATUS Status;
@@ -1960,7 +1934,7 @@ NetLibDestroyServiceChild (
Status = gBS->OpenProtocol (
Controller,
ServiceBindingGuid,
- (VOID **) &Service,
+ (VOID **)&Service,
Image,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1996,8 +1970,8 @@ NetLibDestroyServiceChild (
EFI_HANDLE
EFIAPI
NetLibGetSnpHandle (
- IN EFI_HANDLE ServiceHandle,
- OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL
+ IN EFI_HANDLE ServiceHandle,
+ OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL
)
{
EFI_STATUS Status;
@@ -2009,11 +1983,12 @@ NetLibGetSnpHandle (
// Try to open SNP from ServiceHandle
//
SnpInstance = NULL;
- Status = gBS->HandleProtocol (ServiceHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **) &SnpInstance);
+ Status = gBS->HandleProtocol (ServiceHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&SnpInstance);
if (!EFI_ERROR (Status)) {
if (Snp != NULL) {
*Snp = SnpInstance;
}
+
return ServiceHandle;
}
@@ -2026,7 +2001,7 @@ NetLibGetSnpHandle (
}
SnpHandle = NULL;
- Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &DevicePath, &SnpHandle);
+ Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &DevicePath, &SnpHandle);
if (EFI_ERROR (Status)) {
//
// Failed to find SNP handle
@@ -2034,11 +2009,12 @@ NetLibGetSnpHandle (
return NULL;
}
- Status = gBS->HandleProtocol (SnpHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **) &SnpInstance);
+ Status = gBS->HandleProtocol (SnpHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&SnpInstance);
if (!EFI_ERROR (Status)) {
if (Snp != NULL) {
*Snp = SnpInstance;
}
+
return SnpHandle;
}
@@ -2061,7 +2037,7 @@ NetLibGetSnpHandle (
UINT16
EFIAPI
NetLibGetVlanId (
- IN EFI_HANDLE ServiceHandle
+ IN EFI_HANDLE ServiceHandle
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
@@ -2074,9 +2050,10 @@ NetLibGetVlanId (
Node = DevicePath;
while (!IsDevicePathEnd (Node)) {
- if (Node->Type == MESSAGING_DEVICE_PATH && Node->SubType == MSG_VLAN_DP) {
- return ((VLAN_DEVICE_PATH *) Node)->VlanId;
+ if ((Node->Type == MESSAGING_DEVICE_PATH) && (Node->SubType == MSG_VLAN_DP)) {
+ return ((VLAN_DEVICE_PATH *)Node)->VlanId;
}
+
Node = NextDevicePathNode (Node);
}
@@ -2100,8 +2077,8 @@ NetLibGetVlanId (
EFI_HANDLE
EFIAPI
NetLibGetVlanHandle (
- IN EFI_HANDLE ControllerHandle,
- IN UINT16 VlanId
+ IN EFI_HANDLE ControllerHandle,
+ IN UINT16 VlanId
)
{
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
@@ -2120,10 +2097,10 @@ NetLibGetVlanHandle (
//
CopyMem (&VlanNode, &mNetVlanDevicePathTemplate, sizeof (VLAN_DEVICE_PATH));
VlanNode.VlanId = VlanId;
- VlanDevicePath = AppendDevicePathNode (
- ParentDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &VlanNode
- );
+ VlanDevicePath = AppendDevicePathNode (
+ ParentDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&VlanNode
+ );
if (VlanDevicePath == NULL) {
return NULL;
}
@@ -2131,7 +2108,7 @@ NetLibGetVlanHandle (
//
// Find VLAN device handle
//
- Handle = NULL;
+ Handle = NULL;
DevicePath = VlanDevicePath;
gBS->LocateDevicePath (
&gEfiDevicePathProtocolGuid,
@@ -2171,19 +2148,19 @@ NetLibGetVlanHandle (
EFI_STATUS
EFIAPI
NetLibGetMacAddress (
- IN EFI_HANDLE ServiceHandle,
- OUT EFI_MAC_ADDRESS *MacAddress,
- OUT UINTN *AddressSize
+ IN EFI_HANDLE ServiceHandle,
+ OUT EFI_MAC_ADDRESS *MacAddress,
+ OUT UINTN *AddressSize
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- EFI_SIMPLE_NETWORK_MODE *SnpMode;
- EFI_SIMPLE_NETWORK_MODE SnpModeData;
- EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
- EFI_SERVICE_BINDING_PROTOCOL *MnpSb;
- EFI_HANDLE SnpHandle;
- EFI_HANDLE MnpChildHandle;
+ EFI_STATUS Status;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ EFI_SIMPLE_NETWORK_MODE *SnpMode;
+ EFI_SIMPLE_NETWORK_MODE SnpModeData;
+ EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
+ EFI_SERVICE_BINDING_PROTOCOL *MnpSb;
+ EFI_HANDLE SnpHandle;
+ EFI_HANDLE MnpChildHandle;
ASSERT (MacAddress != NULL);
ASSERT (AddressSize != NULL);
@@ -2191,7 +2168,7 @@ NetLibGetMacAddress (
//
// Try to get SNP handle
//
- Snp = NULL;
+ Snp = NULL;
SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp);
if (SnpHandle != NULL) {
//
@@ -2203,11 +2180,11 @@ NetLibGetMacAddress (
// Failed to get SNP handle, try to get MAC address from MNP
//
MnpChildHandle = NULL;
- Status = gBS->HandleProtocol (
- ServiceHandle,
- &gEfiManagedNetworkServiceBindingProtocolGuid,
- (VOID **) &MnpSb
- );
+ Status = gBS->HandleProtocol (
+ ServiceHandle,
+ &gEfiManagedNetworkServiceBindingProtocolGuid,
+ (VOID **)&MnpSb
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2226,7 +2203,7 @@ NetLibGetMacAddress (
Status = gBS->HandleProtocol (
MnpChildHandle,
&gEfiManagedNetworkProtocolGuid,
- (VOID **) &Mnp
+ (VOID **)&Mnp
);
if (EFI_ERROR (Status)) {
MnpSb->DestroyChild (MnpSb, MnpChildHandle);
@@ -2241,6 +2218,7 @@ NetLibGetMacAddress (
MnpSb->DestroyChild (MnpSb, MnpChildHandle);
return Status;
}
+
SnpMode = &SnpModeData;
//
@@ -2287,14 +2265,14 @@ NetLibGetMacString (
OUT CHAR16 **MacString
)
{
- EFI_STATUS Status;
- EFI_MAC_ADDRESS MacAddress;
- UINT8 *HwAddress;
- UINTN HwAddressSize;
- UINT16 VlanId;
- CHAR16 *String;
- UINTN Index;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ EFI_MAC_ADDRESS MacAddress;
+ UINT8 *HwAddress;
+ UINTN HwAddressSize;
+ UINT16 VlanId;
+ CHAR16 *String;
+ UINTN Index;
+ UINTN BufferSize;
ASSERT (MacString != NULL);
@@ -2312,10 +2290,11 @@ NetLibGetMacString (
// Plus one unicode character for the null-terminator.
//
BufferSize = (2 * HwAddressSize + 5 + 1) * sizeof (CHAR16);
- String = AllocateZeroPool (BufferSize);
+ String = AllocateZeroPool (BufferSize);
if (String == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
*MacString = String;
//
@@ -2390,8 +2369,8 @@ NetLibGetMacString (
EFI_STATUS
EFIAPI
NetLibDetectMedia (
- IN EFI_HANDLE ServiceHandle,
- OUT BOOLEAN *MediaPresent
+ IN EFI_HANDLE ServiceHandle,
+ OUT BOOLEAN *MediaPresent
)
{
EFI_STATUS Status;
@@ -2410,7 +2389,7 @@ NetLibDetectMedia (
//
// Get SNP handle
//
- Snp = NULL;
+ Snp = NULL;
SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp);
if (SnpHandle == NULL) {
return EFI_INVALID_PARAMETER;
@@ -2485,6 +2464,7 @@ NetLibDetectMedia (
if (!EFI_ERROR (Status)) {
Status = Snp->Stop (Snp);
}
+
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -2496,6 +2476,7 @@ NetLibDetectMedia (
if (!EFI_ERROR (Status)) {
Status = Snp->Initialize (Snp, 0, 0);
}
+
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -2599,9 +2580,9 @@ Exit:
EFI_STATUS
EFIAPI
NetLibDetectMediaWaitTimeout (
- IN EFI_HANDLE ServiceHandle,
- IN UINT64 Timeout,
- OUT EFI_STATUS *MediaState
+ IN EFI_HANDLE ServiceHandle,
+ IN UINT64 Timeout,
+ OUT EFI_STATUS *MediaState
)
{
EFI_STATUS Status;
@@ -2618,13 +2599,14 @@ NetLibDetectMediaWaitTimeout (
if (MediaState == NULL) {
return EFI_INVALID_PARAMETER;
}
+
*MediaState = EFI_SUCCESS;
MediaInfo = NULL;
//
// Get SNP handle
//
- Snp = NULL;
+ Snp = NULL;
SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp);
if (SnpHandle == NULL) {
return EFI_INVALID_PARAMETER;
@@ -2633,12 +2615,11 @@ NetLibDetectMediaWaitTimeout (
Status = gBS->HandleProtocol (
SnpHandle,
&gEfiAdapterInformationProtocolGuid,
- (VOID *) &Aip
+ (VOID *)&Aip
);
if (EFI_ERROR (Status)) {
-
MediaPresent = TRUE;
- Status = NetLibDetectMedia (ServiceHandle, &MediaPresent);
+ Status = NetLibDetectMedia (ServiceHandle, &MediaPresent);
if (!EFI_ERROR (Status)) {
if (MediaPresent) {
*MediaState = EFI_SUCCESS;
@@ -2656,30 +2637,26 @@ NetLibDetectMediaWaitTimeout (
Status = Aip->GetInformation (
Aip,
&gEfiAdapterInfoMediaStateGuid,
- (VOID **) &MediaInfo,
+ (VOID **)&MediaInfo,
&DataSize
);
if (!EFI_ERROR (Status)) {
-
*MediaState = MediaInfo->MediaState;
FreePool (MediaInfo);
- if (*MediaState != EFI_NOT_READY || Timeout < MEDIA_STATE_DETECT_TIME_INTERVAL) {
-
+ if ((*MediaState != EFI_NOT_READY) || (Timeout < MEDIA_STATE_DETECT_TIME_INTERVAL)) {
return EFI_SUCCESS;
}
} else {
-
if (MediaInfo != NULL) {
FreePool (MediaInfo);
}
if (Status == EFI_UNSUPPORTED) {
-
//
// If gEfiAdapterInfoMediaStateGuid is not supported, call NetLibDetectMedia to get media state!
//
MediaPresent = TRUE;
- Status = NetLibDetectMedia (ServiceHandle, &MediaPresent);
+ Status = NetLibDetectMedia (ServiceHandle, &MediaPresent);
if (!EFI_ERROR (Status)) {
if (MediaPresent) {
*MediaState = EFI_SUCCESS;
@@ -2687,6 +2664,7 @@ NetLibDetectMediaWaitTimeout (
*MediaState = EFI_NO_MEDIA;
}
}
+
return Status;
}
@@ -2699,7 +2677,7 @@ NetLibDetectMediaWaitTimeout (
Timer = NULL;
TimeRemained = Timeout;
- Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer);
+ Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -2711,39 +2689,37 @@ NetLibDetectMediaWaitTimeout (
MEDIA_STATE_DETECT_TIME_INTERVAL
);
if (EFI_ERROR (Status)) {
- gBS->CloseEvent(Timer);
+ gBS->CloseEvent (Timer);
return EFI_DEVICE_ERROR;
}
do {
TimerStatus = gBS->CheckEvent (Timer);
if (!EFI_ERROR (TimerStatus)) {
-
TimeRemained -= MEDIA_STATE_DETECT_TIME_INTERVAL;
- Status = Aip->GetInformation (
- Aip,
- &gEfiAdapterInfoMediaStateGuid,
- (VOID **) &MediaInfo,
- &DataSize
- );
+ Status = Aip->GetInformation (
+ Aip,
+ &gEfiAdapterInfoMediaStateGuid,
+ (VOID **)&MediaInfo,
+ &DataSize
+ );
if (!EFI_ERROR (Status)) {
-
*MediaState = MediaInfo->MediaState;
FreePool (MediaInfo);
} else {
-
if (MediaInfo != NULL) {
FreePool (MediaInfo);
}
- gBS->CloseEvent(Timer);
+
+ gBS->CloseEvent (Timer);
return Status;
}
}
} while (TimerStatus == EFI_NOT_READY);
} while (*MediaState == EFI_NOT_READY && TimeRemained >= MEDIA_STATE_DETECT_TIME_INTERVAL);
- gBS->CloseEvent(Timer);
- if (*MediaState == EFI_NOT_READY && TimeRemained < MEDIA_STATE_DETECT_TIME_INTERVAL) {
+ gBS->CloseEvent (Timer);
+ if ((*MediaState == EFI_NOT_READY) && (TimeRemained < MEDIA_STATE_DETECT_TIME_INTERVAL)) {
return EFI_TIMEOUT;
} else {
return EFI_SUCCESS;
@@ -2770,22 +2746,22 @@ NetLibDefaultAddressIsStatic (
IN EFI_HANDLE Controller
)
{
- EFI_STATUS Status;
- EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
- UINTN DataSize;
- EFI_IP4_CONFIG2_POLICY Policy;
- BOOLEAN IsStatic;
+ EFI_STATUS Status;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
+ UINTN DataSize;
+ EFI_IP4_CONFIG2_POLICY Policy;
+ BOOLEAN IsStatic;
Ip4Config2 = NULL;
DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
- IsStatic = TRUE;
+ IsStatic = TRUE;
//
// Get Ip4Config2 policy.
//
- Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);
+ Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -2795,7 +2771,7 @@ NetLibDefaultAddressIsStatic (
goto ON_EXIT;
}
- IsStatic = (BOOLEAN) (Policy == Ip4Config2PolicyStatic);
+ IsStatic = (BOOLEAN)(Policy == Ip4Config2PolicyStatic);
ON_EXIT:
@@ -2907,7 +2883,7 @@ NetLibCreateIPv6DPathNode (
Node->LocalPort = LocalPort;
Node->RemotePort = RemotePort;
- Node->Protocol = Protocol;
+ Node->Protocol = Protocol;
//
// Set default value to IPAddressOrigin, PrefixLength.
@@ -2940,15 +2916,15 @@ NetLibCreateIPv6DPathNode (
EFI_HANDLE
EFIAPI
NetLibGetNicHandle (
- IN EFI_HANDLE Controller,
- IN EFI_GUID *ProtocolGuid
+ IN EFI_HANDLE Controller,
+ IN EFI_GUID *ProtocolGuid
)
{
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenBuffer;
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- UINTN OpenCount;
- UINTN Index;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenBuffer;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINTN OpenCount;
+ UINTN Index;
ASSERT (ProtocolGuid != NULL);
@@ -2989,12 +2965,12 @@ NetLibGetNicHandle (
EFI_STATUS
EFIAPI
NetLibAsciiStrToIp4 (
- IN CONST CHAR8 *String,
- OUT EFI_IPv4_ADDRESS *Ip4Address
+ IN CONST CHAR8 *String,
+ OUT EFI_IPv4_ADDRESS *Ip4Address
)
{
- RETURN_STATUS Status;
- CHAR8 *EndPointer;
+ RETURN_STATUS Status;
+ CHAR8 *EndPointer;
Status = AsciiStrToIpv4Address (String, &EndPointer, Ip4Address, NULL);
if (RETURN_ERROR (Status) || (*EndPointer != '\0')) {
@@ -3004,7 +2980,6 @@ NetLibAsciiStrToIp4 (
}
}
-
/**
Convert one Null-terminated ASCII string to EFI_IPv6_ADDRESS. The format of the
string is defined in RFC 4291 - Text Representation of Addresses.
@@ -3019,12 +2994,12 @@ NetLibAsciiStrToIp4 (
EFI_STATUS
EFIAPI
NetLibAsciiStrToIp6 (
- IN CONST CHAR8 *String,
- OUT EFI_IPv6_ADDRESS *Ip6Address
+ IN CONST CHAR8 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address
)
{
- RETURN_STATUS Status;
- CHAR8 *EndPointer;
+ RETURN_STATUS Status;
+ CHAR8 *EndPointer;
Status = AsciiStrToIpv6Address (String, &EndPointer, Ip6Address, NULL);
if (RETURN_ERROR (Status) || (*EndPointer != '\0')) {
@@ -3034,7 +3009,6 @@ NetLibAsciiStrToIp6 (
}
}
-
/**
Convert one Null-terminated Unicode string (decimal dotted) to EFI_IPv4_ADDRESS.
@@ -3048,12 +3022,12 @@ NetLibAsciiStrToIp6 (
EFI_STATUS
EFIAPI
NetLibStrToIp4 (
- IN CONST CHAR16 *String,
- OUT EFI_IPv4_ADDRESS *Ip4Address
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv4_ADDRESS *Ip4Address
)
{
- RETURN_STATUS Status;
- CHAR16 *EndPointer;
+ RETURN_STATUS Status;
+ CHAR16 *EndPointer;
Status = StrToIpv4Address (String, &EndPointer, Ip4Address, NULL);
if (RETURN_ERROR (Status) || (*EndPointer != L'\0')) {
@@ -3063,7 +3037,6 @@ NetLibStrToIp4 (
}
}
-
/**
Convert one Null-terminated Unicode string to EFI_IPv6_ADDRESS. The format of
the string is defined in RFC 4291 - Text Representation of Addresses.
@@ -3078,12 +3051,12 @@ NetLibStrToIp4 (
EFI_STATUS
EFIAPI
NetLibStrToIp6 (
- IN CONST CHAR16 *String,
- OUT EFI_IPv6_ADDRESS *Ip6Address
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address
)
{
- RETURN_STATUS Status;
- CHAR16 *EndPointer;
+ RETURN_STATUS Status;
+ CHAR16 *EndPointer;
Status = StrToIpv6Address (String, &EndPointer, Ip6Address, NULL);
if (RETURN_ERROR (Status) || (*EndPointer != L'\0')) {
@@ -3109,13 +3082,13 @@ NetLibStrToIp6 (
EFI_STATUS
EFIAPI
NetLibStrToIp6andPrefix (
- IN CONST CHAR16 *String,
- OUT EFI_IPv6_ADDRESS *Ip6Address,
- OUT UINT8 *PrefixLength
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address,
+ OUT UINT8 *PrefixLength
)
{
- RETURN_STATUS Status;
- CHAR16 *EndPointer;
+ RETURN_STATUS Status;
+ CHAR16 *EndPointer;
Status = StrToIpv6Address (String, &EndPointer, Ip6Address, PrefixLength);
if (RETURN_ERROR (Status) || (*EndPointer != L'\0')) {
@@ -3142,21 +3115,21 @@ NetLibStrToIp6andPrefix (
EFI_STATUS
EFIAPI
NetLibIp6ToStr (
- IN EFI_IPv6_ADDRESS *Ip6Address,
- OUT CHAR16 *String,
- IN UINTN StringSize
+ IN EFI_IPv6_ADDRESS *Ip6Address,
+ OUT CHAR16 *String,
+ IN UINTN StringSize
)
{
- UINT16 Ip6Addr[8];
- UINTN Index;
- UINTN LongestZerosStart;
- UINTN LongestZerosLength;
- UINTN CurrentZerosStart;
- UINTN CurrentZerosLength;
- CHAR16 Buffer[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
- CHAR16 *Ptr;
-
- if (Ip6Address == NULL || String == NULL || StringSize == 0) {
+ UINT16 Ip6Addr[8];
+ UINTN Index;
+ UINTN LongestZerosStart;
+ UINTN LongestZerosLength;
+ UINTN CurrentZerosStart;
+ UINTN CurrentZerosLength;
+ CHAR16 Buffer[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
+ CHAR16 *Ptr;
+
+ if ((Ip6Address == NULL) || (String == NULL) || (StringSize == 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -3178,25 +3151,26 @@ NetLibIp6ToStr (
for (Index = 0; Index < 8; Index++) {
if (Ip6Addr[Index] == 0) {
if (CurrentZerosStart == DEFAULT_ZERO_START) {
- CurrentZerosStart = Index;
+ CurrentZerosStart = Index;
CurrentZerosLength = 1;
} else {
CurrentZerosLength++;
}
} else {
if (CurrentZerosStart != DEFAULT_ZERO_START) {
- if (CurrentZerosLength > 2 && (LongestZerosStart == (DEFAULT_ZERO_START) || CurrentZerosLength > LongestZerosLength)) {
+ if ((CurrentZerosLength > 2) && ((LongestZerosStart == (DEFAULT_ZERO_START)) || (CurrentZerosLength > LongestZerosLength))) {
LongestZerosStart = CurrentZerosStart;
LongestZerosLength = CurrentZerosLength;
}
+
CurrentZerosStart = DEFAULT_ZERO_START;
CurrentZerosLength = 0;
}
}
}
- if (CurrentZerosStart != DEFAULT_ZERO_START && CurrentZerosLength > 2) {
- if (LongestZerosStart == DEFAULT_ZERO_START || LongestZerosLength < CurrentZerosLength) {
+ if ((CurrentZerosStart != DEFAULT_ZERO_START) && (CurrentZerosLength > 2)) {
+ if ((LongestZerosStart == DEFAULT_ZERO_START) || (LongestZerosLength < CurrentZerosLength)) {
LongestZerosStart = CurrentZerosStart;
LongestZerosLength = CurrentZerosLength;
}
@@ -3204,21 +3178,25 @@ NetLibIp6ToStr (
Ptr = Buffer;
for (Index = 0; Index < 8; Index++) {
- if (LongestZerosStart != DEFAULT_ZERO_START && Index >= LongestZerosStart && Index < LongestZerosStart + LongestZerosLength) {
+ if ((LongestZerosStart != DEFAULT_ZERO_START) && (Index >= LongestZerosStart) && (Index < LongestZerosStart + LongestZerosLength)) {
if (Index == LongestZerosStart) {
*Ptr++ = L':';
}
+
continue;
}
+
if (Index != 0) {
*Ptr++ = L':';
}
- Ptr += UnicodeSPrint(Ptr, 10, L"%x", Ip6Addr[Index]);
+
+ Ptr += UnicodeSPrint (Ptr, 10, L"%x", Ip6Addr[Index]);
}
- if (LongestZerosStart != DEFAULT_ZERO_START && LongestZerosStart + LongestZerosLength == 8) {
+ if ((LongestZerosStart != DEFAULT_ZERO_START) && (LongestZerosStart + LongestZerosLength == 8)) {
*Ptr++ = L':';
}
+
*Ptr = L'\0';
if ((UINTN)Ptr - (UINTN)Buffer > StringSize) {
@@ -3244,7 +3222,7 @@ NetLibIp6ToStr (
EFI_STATUS
EFIAPI
NetLibGetSystemGuid (
- OUT EFI_GUID *SystemGuid
+ OUT EFI_GUID *SystemGuid
)
{
EFI_STATUS Status;
@@ -3257,17 +3235,18 @@ NetLibGetSystemGuid (
ASSERT (SystemGuid != NULL);
SmbiosTable = NULL;
- Status = EfiGetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID **) &Smbios30Table);
- if (!(EFI_ERROR (Status) || Smbios30Table == NULL)) {
- Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) Smbios30Table->TableAddress;
- SmbiosEnd.Raw = (UINT8 *) (UINTN) (Smbios30Table->TableAddress + Smbios30Table->TableMaximumSize);
+ Status = EfiGetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID **)&Smbios30Table);
+ if (!(EFI_ERROR (Status) || (Smbios30Table == NULL))) {
+ Smbios.Hdr = (SMBIOS_STRUCTURE *)(UINTN)Smbios30Table->TableAddress;
+ SmbiosEnd.Raw = (UINT8 *)(UINTN)(Smbios30Table->TableAddress + Smbios30Table->TableMaximumSize);
} else {
- Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **) &SmbiosTable);
- if (EFI_ERROR (Status) || SmbiosTable == NULL) {
+ Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **)&SmbiosTable);
+ if (EFI_ERROR (Status) || (SmbiosTable == NULL)) {
return EFI_NOT_FOUND;
}
- Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress;
- SmbiosEnd.Raw = (UINT8 *) ((UINTN) SmbiosTable->TableAddress + SmbiosTable->TableLength);
+
+ Smbios.Hdr = (SMBIOS_STRUCTURE *)(UINTN)SmbiosTable->TableAddress;
+ SmbiosEnd.Raw = (UINT8 *)((UINTN)SmbiosTable->TableAddress + SmbiosTable->TableLength);
}
do {
@@ -3296,7 +3275,7 @@ NetLibGetSystemGuid (
//
// Step 1: Skip over formatted section.
//
- String = (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length);
+ String = (CHAR8 *)(Smbios.Raw + Smbios.Hdr->Length);
//
// Step 2: Skip over unformatted string section.
@@ -3309,7 +3288,7 @@ NetLibGetSystemGuid (
for ( ; *String != 0; String++) {
}
- if (*(UINT8*)++String == 0) {
+ if (*(UINT8 *)++String == 0) {
//
// Pointer to the next SMBIOS structure.
//
@@ -3318,6 +3297,7 @@ NetLibGetSystemGuid (
}
} while (TRUE);
} while (Smbios.Raw < SmbiosEnd.Raw);
+
return EFI_NOT_FOUND;
}
@@ -3341,15 +3321,15 @@ NetLibGetSystemGuid (
CHAR8 *
EFIAPI
NetLibCreateDnsQName (
- IN CHAR16 *DomainName
+ IN CHAR16 *DomainName
)
{
- CHAR8 *QueryName;
- UINTN QueryNameSize;
- CHAR8 *Header;
- CHAR8 *Tail;
- UINTN Len;
- UINTN Index;
+ CHAR8 *QueryName;
+ UINTN QueryNameSize;
+ CHAR8 *Header;
+ CHAR8 *Tail;
+ UINTN Len;
+ UINTN Index;
ASSERT (DomainName != NULL);
@@ -3373,22 +3353,23 @@ NetLibCreateDnsQName (
}
Header = QueryName;
- Tail = Header + 1;
- Len = 0;
+ Tail = Header + 1;
+ Len = 0;
for (Index = 0; DomainName[Index] != 0; Index++) {
- *Tail = (CHAR8) DomainName[Index];
+ *Tail = (CHAR8)DomainName[Index];
if (*Tail == '.') {
- *Header = (CHAR8) Len;
- Header = Tail;
- Tail ++;
+ *Header = (CHAR8)Len;
+ Header = Tail;
+ Tail++;
Len = 0;
} else {
Tail++;
Len++;
}
}
- *Header = (CHAR8) Len;
- *Tail = 0;
+
+ *Header = (CHAR8)Len;
+ *Tail = 0;
return QueryName;
}
diff --git a/NetworkPkg/TcpDxe/TcpDriver.c b/NetworkPkg/TcpDxe/TcpDriver.c
index c4dcb5e193..8a75b4b55b 100644
--- a/NetworkPkg/TcpDxe/TcpDriver.c
+++ b/NetworkPkg/TcpDxe/TcpDriver.c
@@ -9,15 +9,15 @@
#include "TcpMain.h"
-UINT16 mTcp4RandomPort;
-UINT16 mTcp6RandomPort;
+UINT16 mTcp4RandomPort;
+UINT16 mTcp6RandomPort;
-TCP_HEARTBEAT_TIMER mTcpTimer = {
+TCP_HEARTBEAT_TIMER mTcpTimer = {
NULL,
0
};
-EFI_TCP4_PROTOCOL gTcp4ProtocolTemplate = {
+EFI_TCP4_PROTOCOL gTcp4ProtocolTemplate = {
Tcp4GetModeData,
Tcp4Configure,
Tcp4Routes,
@@ -30,7 +30,7 @@ EFI_TCP4_PROTOCOL gTcp4ProtocolTemplate = {
Tcp4Poll
};
-EFI_TCP6_PROTOCOL gTcp6ProtocolTemplate = {
+EFI_TCP6_PROTOCOL gTcp6ProtocolTemplate = {
Tcp6GetModeData,
Tcp6Configure,
Tcp6Connect,
@@ -42,7 +42,7 @@ EFI_TCP6_PROTOCOL gTcp6ProtocolTemplate = {
Tcp6Poll
};
-SOCK_INIT_DATA mTcpDefaultSockData = {
+SOCK_INIT_DATA mTcpDefaultSockData = {
SockStream,
SO_CLOSED,
NULL,
@@ -60,7 +60,7 @@ SOCK_INIT_DATA mTcpDefaultSockData = {
NULL,
};
-EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding = {
Tcp4DriverBindingSupported,
Tcp4DriverBindingStart,
Tcp4DriverBindingStop,
@@ -69,7 +69,7 @@ EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding = {
NULL
};
-EFI_DRIVER_BINDING_PROTOCOL gTcp6DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gTcp6DriverBinding = {
Tcp6DriverBindingSupported,
Tcp6DriverBindingStart,
Tcp6DriverBindingStop,
@@ -83,7 +83,6 @@ EFI_SERVICE_BINDING_PROTOCOL gTcpServiceBinding = {
TcpServiceBindingDestroyChild
};
-
/**
Create and start the heartbeat timer for the TCP driver.
@@ -101,7 +100,6 @@ TcpCreateTimer (
Status = EFI_SUCCESS;
if (mTcpTimer.RefCnt == 0) {
-
Status = gBS->CreateEvent (
EVT_TIMER | EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
@@ -110,17 +108,15 @@ TcpCreateTimer (
&mTcpTimer.TimerEvent
);
if (!EFI_ERROR (Status)) {
-
Status = gBS->SetTimer (
mTcpTimer.TimerEvent,
TimerPeriodic,
- (UINT64) (TICKS_PER_SECOND / TCP_TICK_HZ)
+ (UINT64)(TICKS_PER_SECOND / TCP_TICK_HZ)
);
}
}
if (!EFI_ERROR (Status)) {
-
mTcpTimer.RefCnt++;
}
@@ -209,7 +205,7 @@ TcpDriverEntryPoint (
//
Seed = NetRandomInitSeed ();
mTcpGlobalIss = NET_RANDOM (Seed) % mTcpGlobalIss;
- mTcp4RandomPort = (UINT16) (TCP_PORT_KNOWN + (NET_RANDOM (Seed) % TCP_PORT_KNOWN));
+ mTcp4RandomPort = (UINT16)(TCP_PORT_KNOWN + (NET_RANDOM (Seed) % TCP_PORT_KNOWN));
mTcp6RandomPort = mTcp4RandomPort;
return EFI_SUCCESS;
@@ -233,11 +229,11 @@ TcpCreateService (
IN UINT8 IpVersion
)
{
- EFI_STATUS Status;
- EFI_GUID *IpServiceBindingGuid;
- EFI_GUID *TcpServiceBindingGuid;
- TCP_SERVICE_DATA *TcpServiceData;
- IP_IO_OPEN_DATA OpenData;
+ EFI_STATUS Status;
+ EFI_GUID *IpServiceBindingGuid;
+ EFI_GUID *TcpServiceBindingGuid;
+ TCP_SERVICE_DATA *TcpServiceData;
+ IP_IO_OPEN_DATA OpenData;
if (IpVersion == IP_VERSION_4) {
IpServiceBindingGuid = &gEfiIp4ServiceBindingProtocolGuid;
@@ -279,10 +275,10 @@ TcpCreateService (
return EFI_OUT_OF_RESOURCES;
}
- TcpServiceData->Signature = TCP_DRIVER_SIGNATURE;
- TcpServiceData->ControllerHandle = Controller;
- TcpServiceData->DriverBindingHandle = Image;
- TcpServiceData->IpVersion = IpVersion;
+ TcpServiceData->Signature = TCP_DRIVER_SIGNATURE;
+ TcpServiceData->ControllerHandle = Controller;
+ TcpServiceData->DriverBindingHandle = Image;
+ TcpServiceData->IpVersion = IpVersion;
CopyMem (
&TcpServiceData->ServiceBinding,
&gTcpServiceBinding,
@@ -295,7 +291,6 @@ TcpCreateService (
goto ON_ERROR;
}
-
InitializeListHead (&TcpServiceData->SocketList);
ZeroMem (&OpenData, sizeof (IP_IO_OPEN_DATA));
@@ -315,8 +310,8 @@ TcpCreateService (
OpenData.IpConfigData.Ip6CfgData.DefaultProtocol = EFI_IP_PROTO_TCP;
}
- OpenData.PktRcvdNotify = TcpRxCallback;
- Status = IpIoOpen (TcpServiceData->IpIo, &OpenData);
+ OpenData.PktRcvdNotify = TcpRxCallback;
+ Status = IpIoOpen (TcpServiceData->IpIo, &OpenData);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
@@ -365,8 +360,8 @@ ON_ERROR:
EFI_STATUS
EFIAPI
TcpDestroyChildEntryInHandleBuffer (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
SOCKET *Sock;
@@ -374,14 +369,14 @@ TcpDestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
- if (Entry == NULL || Context == NULL) {
+ if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Sock = NET_LIST_USER_STRUCT_S (Entry, SOCKET, Link, SOCK_SIGNATURE);
- ServiceBinding = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
- NumberOfChildren = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
- ChildHandleBuffer = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
+ Sock = NET_LIST_USER_STRUCT_S (Entry, SOCKET, Link, SOCK_SIGNATURE);
+ ServiceBinding = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
+ NumberOfChildren = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
+ ChildHandleBuffer = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (Sock->SockHandle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS;
@@ -415,13 +410,13 @@ TcpDestroyService (
IN UINT8 IpVersion
)
{
- EFI_HANDLE NicHandle;
- EFI_GUID *IpProtocolGuid;
- EFI_GUID *ServiceBindingGuid;
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- TCP_SERVICE_DATA *TcpServiceData;
- EFI_STATUS Status;
- LIST_ENTRY *List;
+ EFI_HANDLE NicHandle;
+ EFI_GUID *IpProtocolGuid;
+ EFI_GUID *ServiceBindingGuid;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ TCP_SERVICE_DATA *TcpServiceData;
+ EFI_STATUS Status;
+ LIST_ENTRY *List;
TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6));
@@ -442,7 +437,7 @@ TcpDestroyService (
Status = gBS->OpenProtocol (
NicHandle,
ServiceBindingGuid,
- (VOID **) &ServiceBinding,
+ (VOID **)&ServiceBinding,
ImageHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -454,16 +449,16 @@ TcpDestroyService (
TcpServiceData = TCP_SERVICE_FROM_THIS (ServiceBinding);
if (NumberOfChildren != 0) {
- List = &TcpServiceData->SocketList;
- Context.ServiceBinding = ServiceBinding;
- Context.NumberOfChildren = NumberOfChildren;
+ List = &TcpServiceData->SocketList;
+ Context.ServiceBinding = ServiceBinding;
+ Context.NumberOfChildren = NumberOfChildren;
Context.ChildHandleBuffer = ChildHandleBuffer;
- Status = NetDestroyLinkList (
- List,
- TcpDestroyChildEntryInHandleBuffer,
- &Context,
- NULL
- );
+ Status = NetDestroyLinkList (
+ List,
+ TcpDestroyChildEntryInHandleBuffer,
+ &Context,
+ NULL
+ );
} else if (IsListEmpty (&TcpServiceData->SocketList)) {
//
// Uninstall TCP servicebinding protocol
@@ -758,7 +753,7 @@ TcpCreateSocketCallback (
IpProtocolGuid = &gEfiIp6ProtocolGuid;
}
- TcpServiceData = ((TCP_PROTO_DATA *) This->ProtoReserved)->TcpService;
+ TcpServiceData = ((TCP_PROTO_DATA *)This->ProtoReserved)->TcpService;
//
// Open the default IP protocol of IP_IO BY_DRIVER.
@@ -781,7 +776,7 @@ TcpCreateSocketCallback (
Status = gBS->OpenProtocol (
TcpServiceData->ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &This->ParentDevicePath,
+ (VOID **)&This->ParentDevicePath,
TcpServiceData->DriverBindingHandle,
This->SockHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -825,7 +820,7 @@ TcpDestroySocketCallback (
IpProtocolGuid = &gEfiIp6ProtocolGuid;
}
- TcpServiceData = ((TCP_PROTO_DATA *) This->ProtoReserved)->TcpService;
+ TcpServiceData = ((TCP_PROTO_DATA *)This->ProtoReserved)->TcpService;
//
// Remove this node from the list.
@@ -876,7 +871,7 @@ TcpServiceBindingCreateChild (
EFI_STATUS Status;
EFI_TPL OldTpl;
- if (NULL == This || NULL == ChildHandle) {
+ if ((NULL == This) || (NULL == ChildHandle)) {
return EFI_INVALID_PARAMETER;
}
@@ -914,7 +909,7 @@ TcpServiceBindingCreateChild (
*ChildHandle = Sock->SockHandle;
}
- mTcpDefaultSockData.ProtoData = NULL;
+ mTcpDefaultSockData.ProtoData = NULL;
gBS->RestoreTPL (OldTpl);
return Status;
@@ -949,7 +944,7 @@ TcpServiceBindingDestroyChild (
VOID *Tcp;
SOCKET *Sock;
- if (NULL == This || NULL == ChildHandle) {
+ if ((NULL == This) || (NULL == ChildHandle)) {
return EFI_INVALID_PARAMETER;
}
diff --git a/NetworkPkg/TcpDxe/TcpMain.h b/NetworkPkg/TcpDxe/TcpMain.h
index 35f12a16a8..0709298bbf 100644
--- a/NetworkPkg/TcpDxe/TcpMain.h
+++ b/NetworkPkg/TcpDxe/TcpMain.h
@@ -3,7 +3,6 @@
It is the common head file for all Tcp*.c in TCP driver.
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -29,19 +28,19 @@ extern EFI_COMPONENT_NAME_PROTOCOL gTcpComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gTcpComponentName2;
extern EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable;
-extern LIST_ENTRY mTcpRunQue;
-extern LIST_ENTRY mTcpListenQue;
-extern TCP_SEQNO mTcpGlobalIss;
-extern UINT32 mTcpTick;
+extern LIST_ENTRY mTcpRunQue;
+extern LIST_ENTRY mTcpListenQue;
+extern TCP_SEQNO mTcpGlobalIss;
+extern UINT32 mTcpTick;
///
/// 30 seconds.
///
-#define TCP6_KEEP_NEIGHBOR_TIME 30
+#define TCP6_KEEP_NEIGHBOR_TIME 30
///
/// 5 seconds, since 1 tick equals 200ms.
///
-#define TCP6_REFRESH_NEIGHBOR_TICK 25
+#define TCP6_REFRESH_NEIGHBOR_TICK 25
#define TCP_EXPIRE_TIME 65535
@@ -53,43 +52,44 @@ extern UINT32 mTcpTick;
#define TCP_ISS_INCREMENT_1 2048
#define TCP_ISS_INCREMENT_2 100
+
typedef union {
- EFI_TCP4_CONFIG_DATA Tcp4CfgData;
- EFI_TCP6_CONFIG_DATA Tcp6CfgData;
+ EFI_TCP4_CONFIG_DATA Tcp4CfgData;
+ EFI_TCP6_CONFIG_DATA Tcp6CfgData;
} TCP_CONFIG_DATA;
typedef union {
- EFI_TCP4_ACCESS_POINT Tcp4Ap;
- EFI_TCP6_ACCESS_POINT Tcp6Ap;
+ EFI_TCP4_ACCESS_POINT Tcp4Ap;
+ EFI_TCP6_ACCESS_POINT Tcp6Ap;
} TCP_ACCESS_POINT;
typedef struct _TCP4_MODE_DATA {
- EFI_TCP4_CONNECTION_STATE *Tcp4State;
- EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;
- EFI_IP4_MODE_DATA *Ip4ModeData;
- EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
- EFI_SIMPLE_NETWORK_MODE *SnpModeData;
+ EFI_TCP4_CONNECTION_STATE *Tcp4State;
+ EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;
+ EFI_IP4_MODE_DATA *Ip4ModeData;
+ EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
+ EFI_SIMPLE_NETWORK_MODE *SnpModeData;
} TCP4_MODE_DATA;
typedef struct _TCP6_MODE_DATA {
- EFI_TCP6_CONNECTION_STATE *Tcp6State;
- EFI_TCP6_CONFIG_DATA *Tcp6ConfigData;
- EFI_IP6_MODE_DATA *Ip6ModeData;
- EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
- EFI_SIMPLE_NETWORK_MODE *SnpModeData;
+ EFI_TCP6_CONNECTION_STATE *Tcp6State;
+ EFI_TCP6_CONFIG_DATA *Tcp6ConfigData;
+ EFI_IP6_MODE_DATA *Ip6ModeData;
+ EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
+ EFI_SIMPLE_NETWORK_MODE *SnpModeData;
} TCP6_MODE_DATA;
typedef struct _TCP4_ROUTE_INFO {
- BOOLEAN DeleteRoute;
- EFI_IPv4_ADDRESS *SubnetAddress;
- EFI_IPv4_ADDRESS *SubnetMask;
- EFI_IPv4_ADDRESS *GatewayAddress;
+ BOOLEAN DeleteRoute;
+ EFI_IPv4_ADDRESS *SubnetAddress;
+ EFI_IPv4_ADDRESS *SubnetMask;
+ EFI_IPv4_ADDRESS *GatewayAddress;
} TCP4_ROUTE_INFO;
typedef struct {
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- UINTN NumberOfChildren;
- EFI_HANDLE *ChildHandleBuffer;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ UINTN NumberOfChildren;
+ EFI_HANDLE *ChildHandleBuffer;
} TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
//
@@ -122,12 +122,12 @@ typedef struct {
EFI_STATUS
EFIAPI
Tcp4GetModeData (
- IN EFI_TCP4_PROTOCOL *This,
- OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
- OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
- OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ IN EFI_TCP4_PROTOCOL *This,
+ OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
+ OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
);
/**
@@ -155,8 +155,8 @@ Tcp4GetModeData (
EFI_STATUS
EFIAPI
Tcp4Configure (
- IN EFI_TCP4_PROTOCOL * This,
- IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
);
/**
@@ -187,11 +187,11 @@ Tcp4Configure (
EFI_STATUS
EFIAPI
Tcp4Routes (
- IN EFI_TCP4_PROTOCOL *This,
- IN BOOLEAN DeleteRoute,
- IN EFI_IPv4_ADDRESS *SubnetAddress,
- IN EFI_IPv4_ADDRESS *SubnetMask,
- IN EFI_IPv4_ADDRESS *GatewayAddress
+ IN EFI_TCP4_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv4_ADDRESS *SubnetAddress,
+ IN EFI_IPv4_ADDRESS *SubnetMask,
+ IN EFI_IPv4_ADDRESS *GatewayAddress
);
/**
@@ -216,8 +216,8 @@ Tcp4Routes (
EFI_STATUS
EFIAPI
Tcp4Connect (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
);
/**
@@ -243,8 +243,8 @@ Tcp4Connect (
EFI_STATUS
EFIAPI
Tcp4Accept (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_LISTEN_TOKEN *ListenToken
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_LISTEN_TOKEN *ListenToken
);
/**
@@ -279,8 +279,8 @@ Tcp4Accept (
EFI_STATUS
EFIAPI
Tcp4Transmit (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_IO_TOKEN *Token
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_IO_TOKEN *Token
);
/**
@@ -317,8 +317,8 @@ Tcp4Transmit (
EFI_STATUS
EFIAPI
Tcp4Receive (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_IO_TOKEN *Token
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_IO_TOKEN *Token
);
/**
@@ -346,8 +346,8 @@ Tcp4Receive (
EFI_STATUS
EFIAPI
Tcp4Close (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_CLOSE_TOKEN *CloseToken
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_CLOSE_TOKEN *CloseToken
);
/**
@@ -377,8 +377,8 @@ Tcp4Close (
EFI_STATUS
EFIAPI
Tcp4Cancel (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
);
/**
@@ -398,7 +398,7 @@ Tcp4Cancel (
EFI_STATUS
EFIAPI
Tcp4Poll (
- IN EFI_TCP4_PROTOCOL *This
+ IN EFI_TCP4_PROTOCOL *This
);
//
@@ -436,12 +436,12 @@ Tcp4Poll (
EFI_STATUS
EFIAPI
Tcp6GetModeData (
- IN EFI_TCP6_PROTOCOL *This,
- OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL,
- OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL,
- OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ IN EFI_TCP6_PROTOCOL *This,
+ OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL,
+ OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL,
+ OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
);
/**
@@ -494,8 +494,8 @@ Tcp6GetModeData (
EFI_STATUS
EFIAPI
Tcp6Configure (
- IN EFI_TCP6_PROTOCOL *This,
- IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL
+ IN EFI_TCP6_PROTOCOL *This,
+ IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL
);
/**
@@ -531,8 +531,8 @@ Tcp6Configure (
EFI_STATUS
EFIAPI
Tcp6Connect (
- IN EFI_TCP6_PROTOCOL *This,
- IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken
+ IN EFI_TCP6_PROTOCOL *This,
+ IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken
);
/**
@@ -574,8 +574,8 @@ Tcp6Connect (
EFI_STATUS
EFIAPI
Tcp6Accept (
- IN EFI_TCP6_PROTOCOL *This,
- IN EFI_TCP6_LISTEN_TOKEN *ListenToken
+ IN EFI_TCP6_PROTOCOL *This,
+ IN EFI_TCP6_LISTEN_TOKEN *ListenToken
);
/**
@@ -618,8 +618,8 @@ Tcp6Accept (
EFI_STATUS
EFIAPI
Tcp6Transmit (
- IN EFI_TCP6_PROTOCOL *This,
- IN EFI_TCP6_IO_TOKEN *Token
+ IN EFI_TCP6_PROTOCOL *This,
+ IN EFI_TCP6_IO_TOKEN *Token
);
/**
@@ -671,8 +671,8 @@ Tcp6Transmit (
EFI_STATUS
EFIAPI
Tcp6Receive (
- IN EFI_TCP6_PROTOCOL *This,
- IN EFI_TCP6_IO_TOKEN *Token
+ IN EFI_TCP6_PROTOCOL *This,
+ IN EFI_TCP6_IO_TOKEN *Token
);
/**
@@ -705,8 +705,8 @@ Tcp6Receive (
EFI_STATUS
EFIAPI
Tcp6Close (
- IN EFI_TCP6_PROTOCOL *This,
- IN EFI_TCP6_CLOSE_TOKEN *CloseToken
+ IN EFI_TCP6_PROTOCOL *This,
+ IN EFI_TCP6_CLOSE_TOKEN *CloseToken
);
/**
@@ -747,8 +747,8 @@ Tcp6Close (
EFI_STATUS
EFIAPI
Tcp6Cancel (
- IN EFI_TCP6_PROTOCOL *This,
- IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL
+ IN EFI_TCP6_PROTOCOL *This,
+ IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL
);
/**
@@ -771,7 +771,7 @@ Tcp6Cancel (
EFI_STATUS
EFIAPI
Tcp6Poll (
- IN EFI_TCP6_PROTOCOL *This
+ IN EFI_TCP6_PROTOCOL *This
);
#endif
diff --git a/NetworkPkg/TcpDxe/TcpMisc.c b/NetworkPkg/TcpDxe/TcpMisc.c
index 73ed33de85..3fa9d90d9f 100644
--- a/NetworkPkg/TcpDxe/TcpMisc.c
+++ b/NetworkPkg/TcpDxe/TcpMisc.c
@@ -3,26 +3,25 @@
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
-
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "TcpMain.h"
-LIST_ENTRY mTcpRunQue = {
+LIST_ENTRY mTcpRunQue = {
&mTcpRunQue,
&mTcpRunQue
};
-LIST_ENTRY mTcpListenQue = {
+LIST_ENTRY mTcpListenQue = {
&mTcpListenQue,
&mTcpListenQue
};
TCP_SEQNO mTcpGlobalIss = TCP_BASE_ISS;
-CHAR16 *mTcpStateName[] = {
+CHAR16 *mTcpStateName[] = {
L"TCP_CLOSED",
L"TCP_LISTEN",
L"TCP_SYN_SENT",
@@ -36,7 +35,6 @@ CHAR16 *mTcpStateName[] = {
L"TCP_LAST_ACK"
};
-
/**
Initialize the Tcb local related members.
@@ -53,18 +51,18 @@ TcpInitTcbLocal (
//
if (Tcb->Sk->IpVersion == IP_VERSION_4) {
Tcb->HeadSum = NetPseudoHeadChecksum (
- Tcb->LocalEnd.Ip.Addr[0],
- Tcb->RemoteEnd.Ip.Addr[0],
- 0x06,
- 0
- );
+ Tcb->LocalEnd.Ip.Addr[0],
+ Tcb->RemoteEnd.Ip.Addr[0],
+ 0x06,
+ 0
+ );
} else {
Tcb->HeadSum = NetIp6PseudoHeadChecksum (
- &Tcb->LocalEnd.Ip.v6,
- &Tcb->RemoteEnd.Ip.v6,
- 0x06,
- 0
- );
+ &Tcb->LocalEnd.Ip.v6,
+ &Tcb->RemoteEnd.Ip.v6,
+ 0x06,
+ 0
+ );
}
Tcb->Iss = TcpGetIss ();
@@ -79,7 +77,7 @@ TcpInitTcbLocal (
//
// First window size is never scaled
//
- Tcb->RcvWndScale = 0;
+ Tcb->RcvWndScale = 0;
Tcb->RetxmitSeqMax = 0;
Tcb->ProbeTimerOn = FALSE;
@@ -95,9 +93,9 @@ TcpInitTcbLocal (
**/
VOID
TcpInitTcbPeer (
- IN OUT TCP_CB *Tcb,
- IN TCP_SEG *Seg,
- IN TCP_OPTION *Opt
+ IN OUT TCP_CB *Tcb,
+ IN TCP_SEG *Seg,
+ IN TCP_OPTION *Opt
)
{
UINT16 RcvMss;
@@ -105,9 +103,9 @@ TcpInitTcbPeer (
ASSERT ((Tcb != NULL) && (Seg != NULL) && (Opt != NULL));
ASSERT (TCP_FLG_ON (Seg->Flag, TCP_FLG_SYN));
- Tcb->SndWnd = Seg->Wnd;
- Tcb->SndWndMax = Tcb->SndWnd;
- Tcb->SndWl1 = Seg->Seq;
+ Tcb->SndWnd = Seg->Wnd;
+ Tcb->SndWndMax = Tcb->SndWnd;
+ Tcb->SndWl1 = Seg->Seq;
if (TCP_FLG_ON (Seg->Flag, TCP_FLG_ACK)) {
Tcb->SndWl2 = Seg->Ack;
@@ -116,13 +114,12 @@ TcpInitTcbPeer (
}
if (TCP_FLG_ON (Opt->Flag, TCP_OPTION_RCVD_MSS)) {
- Tcb->SndMss = (UINT16) MAX (64, Opt->Mss);
+ Tcb->SndMss = (UINT16)MAX (64, Opt->Mss);
- RcvMss = TcpGetRcvMss (Tcb->Sk);
+ RcvMss = TcpGetRcvMss (Tcb->Sk);
if (Tcb->SndMss > RcvMss) {
Tcb->SndMss = RcvMss;
}
-
} else {
//
// One end doesn't support MSS option, use default.
@@ -130,7 +127,7 @@ TcpInitTcbPeer (
Tcb->RcvMss = 536;
}
- Tcb->CWnd = Tcb->SndMss;
+ Tcb->CWnd = Tcb->SndMss;
Tcb->Irs = Seg->Seq;
Tcb->RcvNxt = Tcb->Irs + 1;
@@ -138,12 +135,10 @@ TcpInitTcbPeer (
Tcb->RcvWl2 = Tcb->RcvNxt;
if (TCP_FLG_ON (Opt->Flag, TCP_OPTION_RCVD_WS) && !TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_NO_WS)) {
+ Tcb->SndWndScale = Opt->WndScale;
- Tcb->SndWndScale = Opt->WndScale;
-
- Tcb->RcvWndScale = TcpComputeScale (Tcb);
+ Tcb->RcvWndScale = TcpComputeScale (Tcb);
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_RCVD_WS);
-
} else {
//
// One end doesn't support window scale option. use zero.
@@ -152,7 +147,6 @@ TcpInitTcbPeer (
}
if (TCP_FLG_ON (Opt->Flag, TCP_OPTION_RCVD_TS) && !TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_NO_TS)) {
-
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_SND_TS);
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_RCVD_TS);
@@ -189,9 +183,9 @@ TcpIsIpEqual (
ASSERT ((Version == IP_VERSION_4) || (Version == IP_VERSION_6));
if (Version == IP_VERSION_4) {
- return (BOOLEAN) (Ip1->Addr[0] == Ip2->Addr[0]);
+ return (BOOLEAN)(Ip1->Addr[0] == Ip2->Addr[0]);
} else {
- return (BOOLEAN) EFI_IP6_EQUAL (&Ip1->v6, &Ip2->v6);
+ return (BOOLEAN)EFI_IP6_EQUAL (&Ip1->v6, &Ip2->v6);
}
}
@@ -208,17 +202,17 @@ TcpIsIpEqual (
**/
BOOLEAN
TcpIsIpZero (
- IN EFI_IP_ADDRESS *Ip,
- IN UINT8 Version
+ IN EFI_IP_ADDRESS *Ip,
+ IN UINT8 Version
)
{
ASSERT ((Version == IP_VERSION_4) || (Version == IP_VERSION_6));
if (Version == IP_VERSION_4) {
- return (BOOLEAN) (Ip->Addr[0] == 0);
+ return (BOOLEAN)(Ip->Addr[0] == 0);
} else {
- return (BOOLEAN) ((Ip->Addr[0] == 0) && (Ip->Addr[1] == 0) &&
- (Ip->Addr[2] == 0) && (Ip->Addr[3] == 0));
+ return (BOOLEAN)((Ip->Addr[0] == 0) && (Ip->Addr[1] == 0) &&
+ (Ip->Addr[2] == 0) && (Ip->Addr[3] == 0));
}
}
@@ -236,16 +230,16 @@ TcpIsIpZero (
**/
TCP_CB *
TcpLocateListenTcb (
- IN TCP_PEER *Local,
- IN TCP_PEER *Remote,
- IN UINT8 Version
+ IN TCP_PEER *Local,
+ IN TCP_PEER *Remote,
+ IN UINT8 Version
)
{
- LIST_ENTRY *Entry;
- TCP_CB *Node;
- TCP_CB *Match;
- INTN Last;
- INTN Cur;
+ LIST_ENTRY *Entry;
+ TCP_CB *Node;
+ TCP_CB *Match;
+ INTN Last;
+ INTN Cur;
Last = 4;
Match = NULL;
@@ -257,8 +251,8 @@ TcpLocateListenTcb (
(Local->Port != Node->LocalEnd.Port) ||
!TCP_PEER_MATCH (Remote, &Node->RemoteEnd, Version) ||
!TCP_PEER_MATCH (Local, &Node->LocalEnd, Version)
- ) {
-
+ )
+ {
continue;
}
@@ -311,9 +305,9 @@ TcpFindTcbByPeer (
IN UINT8 Version
)
{
- TCP_PORTNO LocalPort;
- LIST_ENTRY *Entry;
- TCP_CB *Tcb;
+ TCP_PORTNO LocalPort;
+ LIST_ENTRY *Entry;
+ TCP_CB *Tcb;
ASSERT ((Addr != NULL) && (Port != 0));
@@ -323,10 +317,10 @@ TcpFindTcbByPeer (
Tcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);
if ((Version == Tcb->Sk->IpVersion) &&
- TcpIsIpEqual (Addr, &Tcb->LocalEnd.Ip, Version) &&
+ TcpIsIpEqual (Addr, &Tcb->LocalEnd.Ip, Version) &&
(LocalPort == Tcb->LocalEnd.Port)
- ) {
-
+ )
+ {
return TRUE;
}
}
@@ -335,10 +329,10 @@ TcpFindTcbByPeer (
Tcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);
if ((Version == Tcb->Sk->IpVersion) &&
- TcpIsIpEqual (Addr, &Tcb->LocalEnd.Ip, Version) &&
+ TcpIsIpEqual (Addr, &Tcb->LocalEnd.Ip, Version) &&
(LocalPort == Tcb->LocalEnd.Port)
- ) {
-
+ )
+ {
return TRUE;
}
}
@@ -370,10 +364,10 @@ TcpLocateTcb (
IN BOOLEAN Syn
)
{
- TCP_PEER Local;
- TCP_PEER Remote;
- LIST_ENTRY *Entry;
- TCP_CB *Tcb;
+ TCP_PEER Local;
+ TCP_PEER Remote;
+ LIST_ENTRY *Entry;
+ TCP_CB *Tcb;
Local.Port = LocalPort;
Remote.Port = RemotePort;
@@ -390,8 +384,8 @@ TcpLocateTcb (
if ((Version == Tcb->Sk->IpVersion) &&
TCP_PEER_EQUAL (&Remote, &Tcb->RemoteEnd, Version) &&
TCP_PEER_EQUAL (&Local, &Tcb->LocalEnd, Version)
- ) {
-
+ )
+ {
RemoveEntryList (&Tcb->List);
InsertHeadList (&mTcpRunQue, &Tcb->List);
@@ -420,20 +414,20 @@ TcpLocateTcb (
**/
INTN
TcpInsertTcb (
- IN TCP_CB *Tcb
+ IN TCP_CB *Tcb
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Head;
- TCP_CB *Node;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Head;
+ TCP_CB *Node;
ASSERT (
(Tcb != NULL) &&
(
- (Tcb->State == TCP_LISTEN) ||
- (Tcb->State == TCP_SYN_SENT) ||
- (Tcb->State == TCP_SYN_RCVD) ||
- (Tcb->State == TCP_CLOSED)
+ (Tcb->State == TCP_LISTEN) ||
+ (Tcb->State == TCP_SYN_SENT) ||
+ (Tcb->State == TCP_SYN_RCVD) ||
+ (Tcb->State == TCP_CLOSED)
)
);
@@ -455,15 +449,14 @@ TcpInsertTcb (
if (TCP_PEER_EQUAL (&Tcb->LocalEnd, &Node->LocalEnd, Tcb->Sk->IpVersion) &&
TCP_PEER_EQUAL (&Tcb->RemoteEnd, &Node->RemoteEnd, Tcb->Sk->IpVersion)
- ) {
-
+ )
+ {
return -1;
}
}
InsertHeadList (Head, &Tcb->List);
-
return 0;
}
@@ -477,10 +470,10 @@ TcpInsertTcb (
**/
TCP_CB *
TcpCloneTcb (
- IN TCP_CB *Tcb
+ IN TCP_CB *Tcb
)
{
- TCP_CB *Clone;
+ TCP_CB *Clone;
Clone = AllocateZeroPool (sizeof (TCP_CB));
@@ -506,7 +499,7 @@ TcpCloneTcb (
return NULL;
}
- ((TCP_PROTO_DATA *) (Clone->Sk->ProtoReserved))->TcpPcb = Clone;
+ ((TCP_PROTO_DATA *)(Clone->Sk->ProtoReserved))->TcpPcb = Clone;
return Clone;
}
@@ -539,25 +532,25 @@ TcpGetRcvMss (
IN SOCKET *Sock
)
{
- EFI_IP4_MODE_DATA Ip4Mode;
- EFI_IP6_MODE_DATA Ip6Mode;
- EFI_IP4_PROTOCOL *Ip4;
- EFI_IP6_PROTOCOL *Ip6;
- TCP_PROTO_DATA *TcpProto;
+ EFI_IP4_MODE_DATA Ip4Mode;
+ EFI_IP6_MODE_DATA Ip6Mode;
+ EFI_IP4_PROTOCOL *Ip4;
+ EFI_IP6_PROTOCOL *Ip6;
+ TCP_PROTO_DATA *TcpProto;
ASSERT (Sock != NULL);
ZeroMem (&Ip4Mode, sizeof (EFI_IP4_MODE_DATA));
ZeroMem (&Ip6Mode, sizeof (EFI_IP6_MODE_DATA));
- TcpProto = (TCP_PROTO_DATA *) Sock->ProtoReserved;
+ TcpProto = (TCP_PROTO_DATA *)Sock->ProtoReserved;
if (Sock->IpVersion == IP_VERSION_4) {
Ip4 = TcpProto->TcpService->IpIo->Ip.Ip4;
ASSERT (Ip4 != NULL);
Ip4->GetModeData (Ip4, &Ip4Mode, NULL, NULL);
- return (UINT16) (Ip4Mode.MaxPacketSize - sizeof (TCP_HEAD));
+ return (UINT16)(Ip4Mode.MaxPacketSize - sizeof (TCP_HEAD));
} else {
Ip6 = TcpProto->TcpService->IpIo->Ip.Ip6;
ASSERT (Ip6 != NULL);
@@ -587,7 +580,7 @@ TcpGetRcvMss (
}
}
- return (UINT16) (Ip6Mode.MaxPacketSize - sizeof (TCP_HEAD));
+ return (UINT16)(Ip6Mode.MaxPacketSize - sizeof (TCP_HEAD));
}
}
@@ -600,8 +593,8 @@ TcpGetRcvMss (
**/
VOID
TcpSetState (
- IN TCP_CB *Tcb,
- IN UINT8 State
+ IN TCP_CB *Tcb,
+ IN UINT8 State
)
{
ASSERT (Tcb->State < (sizeof (mTcpStateName) / sizeof (CHAR16 *)));
@@ -609,36 +602,36 @@ TcpSetState (
DEBUG (
(EFI_D_NET,
- "Tcb (%p) state %s --> %s\n",
- Tcb,
- mTcpStateName[Tcb->State],
- mTcpStateName[State])
+ "Tcb (%p) state %s --> %s\n",
+ Tcb,
+ mTcpStateName[Tcb->State],
+ mTcpStateName[State])
);
Tcb->State = State;
switch (State) {
- case TCP_ESTABLISHED:
+ case TCP_ESTABLISHED:
- SockConnEstablished (Tcb->Sk);
+ SockConnEstablished (Tcb->Sk);
- if (Tcb->Parent != NULL) {
- //
- // A new connection is accepted by a listening socket. Install
- // the device path.
- //
- TcpInstallDevicePath (Tcb->Sk);
- }
+ if (Tcb->Parent != NULL) {
+ //
+ // A new connection is accepted by a listening socket. Install
+ // the device path.
+ //
+ TcpInstallDevicePath (Tcb->Sk);
+ }
- break;
+ break;
- case TCP_CLOSED:
+ case TCP_CLOSED:
- SockConnClosed (Tcb->Sk);
+ SockConnClosed (Tcb->Sk);
- break;
- default:
- break;
+ break;
+ default:
+ break;
}
}
@@ -653,21 +646,21 @@ TcpSetState (
**/
UINT16
TcpChecksum (
- IN NET_BUF *Nbuf,
- IN UINT16 HeadSum
+ IN NET_BUF *Nbuf,
+ IN UINT16 HeadSum
)
{
UINT16 Checksum;
- Checksum = NetbufChecksum (Nbuf);
- Checksum = NetAddChecksum (Checksum, HeadSum);
+ Checksum = NetbufChecksum (Nbuf);
+ Checksum = NetAddChecksum (Checksum, HeadSum);
Checksum = NetAddChecksum (
- Checksum,
- HTONS ((UINT16) Nbuf->TotalSize)
- );
+ Checksum,
+ HTONS ((UINT16)Nbuf->TotalSize)
+ );
- return (UINT16) (~Checksum);
+ return (UINT16)(~Checksum);
}
/**
@@ -682,22 +675,22 @@ TcpChecksum (
**/
TCP_SEG *
TcpFormatNetbuf (
- IN TCP_CB *Tcb,
- IN OUT NET_BUF *Nbuf
+ IN TCP_CB *Tcb,
+ IN OUT NET_BUF *Nbuf
)
{
TCP_SEG *Seg;
TCP_HEAD *Head;
- Seg = TCPSEG_NETBUF (Nbuf);
- Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
+ Seg = TCPSEG_NETBUF (Nbuf);
+ Head = (TCP_HEAD *)NetbufGetByte (Nbuf, 0, NULL);
ASSERT (Head != NULL);
Nbuf->Tcp = Head;
- Seg->Seq = NTOHL (Head->Seq);
- Seg->Ack = NTOHL (Head->Ack);
- Seg->End = Seg->Seq + (Nbuf->TotalSize - (Head->HeadLen << 2));
+ Seg->Seq = NTOHL (Head->Seq);
+ Seg->Ack = NTOHL (Head->Ack);
+ Seg->End = Seg->Seq + (Nbuf->TotalSize - (Head->HeadLen << 2));
Seg->Urg = NTOHS (Head->Urg);
Seg->Wnd = (NTOHS (Head->Wnd) << Tcb->SndWndScale);
@@ -726,7 +719,6 @@ TcpFormatNetbuf (
@param[in, out] Tcb Pointer to the TCP_CB that wants to initiate a
connection.
-
**/
VOID
TcpOnAppConnect (
@@ -749,17 +741,16 @@ TcpOnAppConnect (
**/
VOID
TcpOnAppClose (
- IN OUT TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
ASSERT (Tcb != NULL);
- if (!IsListEmpty (&Tcb->RcvQue) || GET_RCV_DATASIZE (Tcb->Sk) != 0) {
-
+ if (!IsListEmpty (&Tcb->RcvQue) || (GET_RCV_DATASIZE (Tcb->Sk) != 0)) {
DEBUG (
(EFI_D_WARN,
- "TcpOnAppClose: connection reset because data is lost for TCB %p\n",
- Tcb)
+ "TcpOnAppClose: connection reset because data is lost for TCB %p\n",
+ Tcb)
);
TcpResetConnection (Tcb);
@@ -768,22 +759,22 @@ TcpOnAppClose (
}
switch (Tcb->State) {
- case TCP_CLOSED:
- case TCP_LISTEN:
- case TCP_SYN_SENT:
- TcpSetState (Tcb, TCP_CLOSED);
- break;
-
- case TCP_SYN_RCVD:
- case TCP_ESTABLISHED:
- TcpSetState (Tcb, TCP_FIN_WAIT_1);
- break;
-
- case TCP_CLOSE_WAIT:
- TcpSetState (Tcb, TCP_LAST_ACK);
- break;
- default:
- break;
+ case TCP_CLOSED:
+ case TCP_LISTEN:
+ case TCP_SYN_SENT:
+ TcpSetState (Tcb, TCP_CLOSED);
+ break;
+
+ case TCP_SYN_RCVD:
+ case TCP_ESTABLISHED:
+ TcpSetState (Tcb, TCP_FIN_WAIT_1);
+ break;
+
+ case TCP_CLOSE_WAIT:
+ TcpSetState (Tcb, TCP_LAST_ACK);
+ break;
+ default:
+ break;
}
TcpToSendData (Tcb, 1);
@@ -801,35 +792,34 @@ TcpOnAppClose (
**/
INTN
TcpOnAppSend (
- IN OUT TCP_CB *Tcb
+ IN OUT TCP_CB *Tcb
)
{
-
switch (Tcb->State) {
- case TCP_CLOSED:
- return -1;
+ case TCP_CLOSED:
+ return -1;
- case TCP_LISTEN:
- return -1;
+ case TCP_LISTEN:
+ return -1;
- case TCP_SYN_SENT:
- case TCP_SYN_RCVD:
- return 0;
+ case TCP_SYN_SENT:
+ case TCP_SYN_RCVD:
+ return 0;
- case TCP_ESTABLISHED:
- case TCP_CLOSE_WAIT:
- TcpToSendData (Tcb, 0);
- return 0;
+ case TCP_ESTABLISHED:
+ case TCP_CLOSE_WAIT:
+ TcpToSendData (Tcb, 0);
+ return 0;
- case TCP_FIN_WAIT_1:
- case TCP_FIN_WAIT_2:
- case TCP_CLOSING:
- case TCP_LAST_ACK:
- case TCP_TIME_WAIT:
- return -1;
+ case TCP_FIN_WAIT_1:
+ case TCP_FIN_WAIT_2:
+ case TCP_CLOSING:
+ case TCP_LAST_ACK:
+ case TCP_TIME_WAIT:
+ return -1;
- default:
- break;
+ default:
+ break;
}
return 0;
@@ -844,41 +834,38 @@ TcpOnAppSend (
**/
VOID
TcpOnAppConsume (
- IN TCP_CB *Tcb
+ IN TCP_CB *Tcb
)
{
- UINT32 TcpOld;
+ UINT32 TcpOld;
switch (Tcb->State) {
- case TCP_ESTABLISHED:
- TcpOld = TcpRcvWinOld (Tcb);
- if (TcpRcvWinNow (Tcb) > TcpOld) {
-
- if (TcpOld < Tcb->RcvMss) {
-
- DEBUG (
- (EFI_D_NET,
- "TcpOnAppConsume: send a window update for a window closed Tcb %p\n",
- Tcb)
- );
-
- TcpSendAck (Tcb);
- } else if (Tcb->DelayedAck == 0) {
-
- DEBUG (
- (EFI_D_NET,
- "TcpOnAppConsume: scheduled a delayed ACK to update window for Tcb %p\n",
- Tcb)
- );
-
- Tcb->DelayedAck = 1;
+ case TCP_ESTABLISHED:
+ TcpOld = TcpRcvWinOld (Tcb);
+ if (TcpRcvWinNow (Tcb) > TcpOld) {
+ if (TcpOld < Tcb->RcvMss) {
+ DEBUG (
+ (EFI_D_NET,
+ "TcpOnAppConsume: send a window update for a window closed Tcb %p\n",
+ Tcb)
+ );
+
+ TcpSendAck (Tcb);
+ } else if (Tcb->DelayedAck == 0) {
+ DEBUG (
+ (EFI_D_NET,
+ "TcpOnAppConsume: scheduled a delayed ACK to update window for Tcb %p\n",
+ Tcb)
+ );
+
+ Tcb->DelayedAck = 1;
+ }
}
- }
- break;
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -891,25 +878,25 @@ TcpOnAppConsume (
**/
VOID
TcpOnAppAbort (
- IN TCP_CB *Tcb
+ IN TCP_CB *Tcb
)
{
DEBUG (
(EFI_D_WARN,
- "TcpOnAppAbort: connection reset issued by application for TCB %p\n",
- Tcb)
+ "TcpOnAppAbort: connection reset issued by application for TCB %p\n",
+ Tcb)
);
switch (Tcb->State) {
- case TCP_SYN_RCVD:
- case TCP_ESTABLISHED:
- case TCP_FIN_WAIT_1:
- case TCP_FIN_WAIT_2:
- case TCP_CLOSE_WAIT:
- TcpResetConnection (Tcb);
- break;
- default:
- break;
+ case TCP_SYN_RCVD:
+ case TCP_ESTABLISHED:
+ case TCP_FIN_WAIT_1:
+ case TCP_FIN_WAIT_2:
+ case TCP_CLOSE_WAIT:
+ TcpResetConnection (Tcb);
+ break;
+ default:
+ break;
}
TcpSetState (Tcb, TCP_CLOSED);
@@ -923,7 +910,7 @@ TcpOnAppAbort (
**/
VOID
TcpResetConnection (
- IN TCP_CB *Tcb
+ IN TCP_CB *Tcb
)
{
NET_BUF *Nbuf;
@@ -932,10 +919,10 @@ TcpResetConnection (
Nbuf = NetbufAlloc (TCP_MAX_HEAD);
if (Nbuf == NULL) {
- return ;
+ return;
}
- Nhead = (TCP_HEAD *) NetbufAllocSpace (
+ Nhead = (TCP_HEAD *)NetbufAllocSpace (
Nbuf,
sizeof (TCP_HEAD),
NET_BUF_TAIL
@@ -943,14 +930,14 @@ TcpResetConnection (
ASSERT (Nhead != NULL);
- Nbuf->Tcp = Nhead;
+ Nbuf->Tcp = Nhead;
Nhead->Flag = TCP_FLG_RST;
Nhead->Seq = HTONL (Tcb->SndNxt);
Nhead->Ack = HTONL (Tcb->RcvNxt);
Nhead->SrcPort = Tcb->LocalEnd.Port;
Nhead->DstPort = Tcb->RemoteEnd.Port;
- Nhead->HeadLen = (UINT8) (sizeof (TCP_HEAD) >> 2);
+ Nhead->HeadLen = (UINT8)(sizeof (TCP_HEAD) >> 2);
Nhead->Res = 0;
Nhead->Wnd = HTONS (0xFFFF);
Nhead->Checksum = 0;
@@ -973,24 +960,24 @@ TcpResetConnection (
**/
EFI_STATUS
TcpInstallDevicePath (
- IN SOCKET *Sock
+ IN SOCKET *Sock
)
{
- TCP_PROTO_DATA *TcpProto;
- TCP_SERVICE_DATA *TcpService;
- TCP_CB *Tcb;
- IPv4_DEVICE_PATH Ip4DPathNode;
- IPv6_DEVICE_PATH Ip6DPathNode;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_STATUS Status;
- TCP_PORTNO LocalPort;
- TCP_PORTNO RemotePort;
-
- TcpProto = (TCP_PROTO_DATA *) Sock->ProtoReserved;
+ TCP_PROTO_DATA *TcpProto;
+ TCP_SERVICE_DATA *TcpService;
+ TCP_CB *Tcb;
+ IPv4_DEVICE_PATH Ip4DPathNode;
+ IPv6_DEVICE_PATH Ip6DPathNode;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ TCP_PORTNO LocalPort;
+ TCP_PORTNO RemotePort;
+
+ TcpProto = (TCP_PROTO_DATA *)Sock->ProtoReserved;
TcpService = TcpProto->TcpService;
Tcb = TcpProto->TcpPcb;
- LocalPort = NTOHS (Tcb->LocalEnd.Port);
+ LocalPort = NTOHS (Tcb->LocalEnd.Port);
RemotePort = NTOHS (Tcb->RemoteEnd.Port);
if (Sock->IpVersion == IP_VERSION_4) {
NetLibCreateIPv4DPathNode (
@@ -1006,7 +993,7 @@ TcpInstallDevicePath (
IP4_COPY_ADDRESS (&Ip4DPathNode.SubnetMask, &Tcb->SubnetMask);
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &Ip4DPathNode;
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&Ip4DPathNode;
} else {
NetLibCreateIPv6DPathNode (
&Ip6DPathNode,
@@ -1018,7 +1005,7 @@ TcpInstallDevicePath (
EFI_IP_PROTO_TCP
);
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &Ip6DPathNode;
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&Ip6DPathNode;
}
Sock->DevicePath = AppendDevicePathNode (Sock->ParentDevicePath, DevicePath);
@@ -1039,4 +1026,3 @@ TcpInstallDevicePath (
return Status;
}
-
diff --git a/NetworkPkg/Udp4Dxe/Udp4Driver.c b/NetworkPkg/Udp4Dxe/Udp4Driver.c
index 44032682e2..cb917fcfc9 100644
--- a/NetworkPkg/Udp4Dxe/Udp4Driver.c
+++ b/NetworkPkg/Udp4Dxe/Udp4Driver.c
@@ -5,10 +5,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Udp4Impl.h"
-EFI_DRIVER_BINDING_PROTOCOL gUdp4DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gUdp4DriverBinding = {
Udp4DriverBindingSupported,
Udp4DriverBindingStart,
Udp4DriverBindingStop,
@@ -17,7 +16,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUdp4DriverBinding = {
NULL
};
-EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding = {
+EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding = {
Udp4ServiceBindingCreateChild,
Udp4ServiceBindingDestroyChild
};
@@ -35,8 +34,8 @@ EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding = {
EFI_STATUS
EFIAPI
Udp4DestroyChildEntryInHandleBuffer (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
UDP4_INSTANCE_DATA *Instance;
@@ -44,14 +43,14 @@ Udp4DestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
- if (Entry == NULL || Context == NULL) {
+ if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Instance = NET_LIST_USER_STRUCT_S (Entry, UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE);
- ServiceBinding = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
- NumberOfChildren = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
- ChildHandleBuffer = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
+ Instance = NET_LIST_USER_STRUCT_S (Entry, UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE);
+ ServiceBinding = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
+ NumberOfChildren = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
+ ChildHandleBuffer = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS;
@@ -60,7 +59,6 @@ Udp4DestroyChildEntryInHandleBuffer (
return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
}
-
/**
Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In
@@ -119,7 +117,6 @@ Udp4DriverBindingSupported (
return Status;
}
-
/**
Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make
@@ -180,7 +177,6 @@ Udp4DriverBindingStart (
return Status;
}
-
/**
Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to
@@ -229,7 +225,7 @@ Udp4DriverBindingStop (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiUdp4ServiceBindingProtocolGuid,
- (VOID **) &ServiceBinding,
+ (VOID **)&ServiceBinding,
This->DriverBindingHandle,
NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -243,16 +239,16 @@ Udp4DriverBindingStop (
//
// NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.
//
- List = &Udp4Service->ChildrenList;
+ List = &Udp4Service->ChildrenList;
Context.ServiceBinding = ServiceBinding;
Context.NumberOfChildren = NumberOfChildren;
Context.ChildHandleBuffer = ChildHandleBuffer;
- Status = NetDestroyLinkList (
- List,
- Udp4DestroyChildEntryInHandleBuffer,
- &Context,
- NULL
- );
+ Status = NetDestroyLinkList (
+ List,
+ Udp4DestroyChildEntryInHandleBuffer,
+ &Context,
+ NULL
+ );
} else {
gBS->UninstallMultipleProtocolInterfaces (
NicHandle,
@@ -267,13 +263,13 @@ Udp4DriverBindingStop (
FreeUnicodeStringTable (gUdpControllerNameTable);
gUdpControllerNameTable = NULL;
}
+
FreePool (Udp4Service);
}
return Status;
}
-
/**
Creates a child handle and installs a protocol.
@@ -352,7 +348,7 @@ Udp4ServiceBindingCreateChild (
Status = gBS->OpenProtocol (
Udp4Service->IpIo->ChildHandle,
&gEfiIp4ProtocolGuid,
- (VOID **) &Ip4,
+ (VOID **)&Ip4,
gUdp4DriverBinding.DriverBindingHandle,
Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -367,7 +363,7 @@ Udp4ServiceBindingCreateChild (
Status = gBS->OpenProtocol (
Instance->IpInfo->ChildHandle,
&gEfiIp4ProtocolGuid,
- (VOID **) &Ip4,
+ (VOID **)&Ip4,
gUdp4DriverBinding.DriverBindingHandle,
Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -410,7 +406,6 @@ ON_ERROR:
return Status;
}
-
/**
Destroys a child handle with a protocol installed on it.
@@ -454,7 +449,7 @@ Udp4ServiceBindingDestroyChild (
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Udp4Proto,
+ (VOID **)&Udp4Proto,
gUdp4DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -499,7 +494,7 @@ Udp4ServiceBindingDestroyChild (
Status = gBS->UninstallMultipleProtocolInterfaces (
ChildHandle,
&gEfiUdp4ProtocolGuid,
- (VOID *) &Instance->Udp4Proto,
+ (VOID *)&Instance->Udp4Proto,
NULL
);
if (EFI_ERROR (Status)) {
@@ -576,9 +571,8 @@ Udp4DriverEntryPoint (
//
// Initialize the UDP random port.
//
- mUdp4RandomPort = (UINT16) (((UINT16) NetRandomInitSeed ()) % UDP4_PORT_KNOWN + UDP4_PORT_KNOWN);
+ mUdp4RandomPort = (UINT16)(((UINT16)NetRandomInitSeed ()) % UDP4_PORT_KNOWN + UDP4_PORT_KNOWN);
}
return Status;
}
-
diff --git a/NetworkPkg/Udp6Dxe/Udp6Driver.c b/NetworkPkg/Udp6Dxe/Udp6Driver.c
index 6021bb3699..ae96fb9966 100644
--- a/NetworkPkg/Udp6Dxe/Udp6Driver.c
+++ b/NetworkPkg/Udp6Dxe/Udp6Driver.c
@@ -9,7 +9,7 @@
#include "Udp6Impl.h"
-EFI_DRIVER_BINDING_PROTOCOL gUdp6DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gUdp6DriverBinding = {
Udp6DriverBindingSupported,
Udp6DriverBindingStart,
Udp6DriverBindingStop,
@@ -18,7 +18,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUdp6DriverBinding = {
NULL
};
-EFI_SERVICE_BINDING_PROTOCOL mUdp6ServiceBinding = {
+EFI_SERVICE_BINDING_PROTOCOL mUdp6ServiceBinding = {
Udp6ServiceBindingCreateChild,
Udp6ServiceBindingDestroyChild
};
@@ -74,6 +74,7 @@ Udp6DriverBindingSupported (
)
{
EFI_STATUS Status;
+
//
// Test for the Udp6ServiceBinding Protocol
//
@@ -88,6 +89,7 @@ Udp6DriverBindingSupported (
if (!EFI_ERROR (Status)) {
return EFI_ALREADY_STARTED;
}
+
//
// Test for the Ip6ServiceBinding Protocol
//
@@ -166,6 +168,7 @@ EXIT:
FreePool (Udp6Service);
}
}
+
return Status;
}
@@ -183,8 +186,8 @@ EXIT:
EFI_STATUS
EFIAPI
Udp6DestroyChildEntryInHandleBuffer (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
UDP6_INSTANCE_DATA *Instance;
@@ -192,14 +195,14 @@ Udp6DestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
- if (Entry == NULL || Context == NULL) {
+ if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Instance = NET_LIST_USER_STRUCT_S (Entry, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE);
- ServiceBinding = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
- NumberOfChildren = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
- ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
+ Instance = NET_LIST_USER_STRUCT_S (Entry, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE);
+ ServiceBinding = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
+ NumberOfChildren = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
+ ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS;
@@ -258,7 +261,7 @@ Udp6DriverBindingStop (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiUdp6ServiceBindingProtocolGuid,
- (VOID **) &ServiceBinding,
+ (VOID **)&ServiceBinding,
This->DriverBindingHandle,
NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -273,23 +276,23 @@ Udp6DriverBindingStop (
//
// NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.
//
- List = &Udp6Service->ChildrenList;
+ List = &Udp6Service->ChildrenList;
Context.ServiceBinding = ServiceBinding;
Context.NumberOfChildren = NumberOfChildren;
Context.ChildHandleBuffer = ChildHandleBuffer;
- Status = NetDestroyLinkList (
- List,
- Udp6DestroyChildEntryInHandleBuffer,
- &Context,
- NULL
- );
+ Status = NetDestroyLinkList (
+ List,
+ Udp6DestroyChildEntryInHandleBuffer,
+ &Context,
+ NULL
+ );
} else if (IsListEmpty (&Udp6Service->ChildrenList)) {
Status = gBS->UninstallMultipleProtocolInterfaces (
- NicHandle,
- &gEfiUdp6ServiceBindingProtocolGuid,
- &Udp6Service->ServiceBinding,
- NULL
- );
+ NicHandle,
+ &gEfiUdp6ServiceBindingProtocolGuid,
+ &Udp6Service->ServiceBinding,
+ NULL
+ );
Udp6CleanService (Udp6Service);
FreePool (Udp6Service);
@@ -376,7 +379,7 @@ Udp6ServiceBindingCreateChild (
Status = gBS->OpenProtocol (
Udp6Service->IpIo->ChildHandle,
&gEfiIp6ProtocolGuid,
- (VOID **) &Ip6,
+ (VOID **)&Ip6,
gUdp6DriverBinding.DriverBindingHandle,
Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -391,7 +394,7 @@ Udp6ServiceBindingCreateChild (
Status = gBS->OpenProtocol (
Instance->IpInfo->ChildHandle,
&gEfiIp6ProtocolGuid,
- (VOID **) &Ip6,
+ (VOID **)&Ip6,
gUdp6DriverBinding.DriverBindingHandle,
Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -478,7 +481,7 @@ Udp6ServiceBindingDestroyChild (
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiUdp6ProtocolGuid,
- (VOID **) &Udp6Proto,
+ (VOID **)&Udp6Proto,
gUdp6DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -502,11 +505,11 @@ Udp6ServiceBindingDestroyChild (
// Close the Ip6 protocol on the default IpIo.
//
Status = gBS->CloseProtocol (
- Udp6Service->IpIo->ChildHandle,
- &gEfiIp6ProtocolGuid,
- gUdp6DriverBinding.DriverBindingHandle,
- Instance->ChildHandle
- );
+ Udp6Service->IpIo->ChildHandle,
+ &gEfiIp6ProtocolGuid,
+ gUdp6DriverBinding.DriverBindingHandle,
+ Instance->ChildHandle
+ );
if (EFI_ERROR (Status)) {
Instance->InDestroy = FALSE;
return Status;
@@ -516,11 +519,11 @@ Udp6ServiceBindingDestroyChild (
// Close the Ip6 protocol on this instance's IpInfo.
//
Status = gBS->CloseProtocol (
- Instance->IpInfo->ChildHandle,
- &gEfiIp6ProtocolGuid,
- gUdp6DriverBinding.DriverBindingHandle,
- Instance->ChildHandle
- );
+ Instance->IpInfo->ChildHandle,
+ &gEfiIp6ProtocolGuid,
+ gUdp6DriverBinding.DriverBindingHandle,
+ Instance->ChildHandle
+ );
if (EFI_ERROR (Status)) {
Instance->InDestroy = FALSE;
return Status;
@@ -532,7 +535,7 @@ Udp6ServiceBindingDestroyChild (
Status = gBS->UninstallMultipleProtocolInterfaces (
ChildHandle,
&gEfiUdp6ProtocolGuid,
- (VOID *) &Instance->Udp6Proto,
+ (VOID *)&Instance->Udp6Proto,
NULL
);
if (EFI_ERROR (Status)) {
@@ -611,13 +614,11 @@ Udp6DriverEntryPoint (
// Initialize the UDP random port.
//
mUdp6RandomPort = (UINT16)(
- ((UINT16) NetRandomInitSeed ()) %
- UDP6_PORT_KNOWN +
- UDP6_PORT_KNOWN
- );
+ ((UINT16)NetRandomInitSeed ()) %
+ UDP6_PORT_KNOWN +
+ UDP6_PORT_KNOWN
+ );
}
return Status;
}
-
-
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
index fb63cf61a9..874fc2c37b 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
@@ -27,7 +27,6 @@ UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = {
//
UINT32 mPxeDhcpTimeout[4] = {4, 8, 16, 32};
-
/**
Parse a certain dhcp4 option by OptTag in Buffer, and return with start pointer.
@@ -53,7 +52,6 @@ PxeBcParseDhcp4Options (
Offset = 0;
while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
-
if (Option->OpCode == OptTag) {
//
// Found the required option.
@@ -76,7 +74,6 @@ PxeBcParseDhcp4Options (
return NULL;
}
-
/**
Parse the PXE vendor options and extract the information from them.
@@ -107,7 +104,6 @@ PxeBcParseVendorOptions (
// Parse all the interesting PXE vendor options one by one.
//
switch (PxeOption->OpCode) {
-
case PXEBC_VENDOR_TAG_MTFTP_IP:
CopyMem (&VendorOption->MtftpIp, PxeOption->Data, sizeof (EFI_IPv4_ADDRESS));
@@ -205,7 +201,6 @@ PxeBcParseVendorOptions (
}
}
-
/**
Build the options buffer for the DHCPv4 request packet.
@@ -377,7 +372,6 @@ PxeBcBuildDhcp4Options (
return Index;
}
-
/**
Create a template DHCPv4 packet as a seed.
@@ -412,7 +406,6 @@ PxeBcSeedDhcp4Packet (
Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP;
}
-
/**
Cache the DHCPv4 packet.
@@ -439,7 +432,6 @@ PxeBcCacheDhcp4Packet (
return EFI_SUCCESS;
}
-
/**
Parse the cached DHCPv4 packet, including all the options.
@@ -485,6 +477,7 @@ PxeBcParseDhcp4Packet (
mInterestedDhcp4Tags[Index]
);
}
+
//
// Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132.
// If yes, try to parse options from the BootFileName field, then ServerName field.
@@ -503,6 +496,7 @@ PxeBcParseDhcp4Packet (
}
}
}
+
if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_SERVER_NAME) != 0) {
for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
if (Options[Index] == NULL) {
@@ -528,7 +522,8 @@ PxeBcParseDhcp4Packet (
//
Option = Options[PXEBC_DHCP4_TAG_INDEX_CLASS_ID];
if ((Option != NULL) && (Option->Length >= 9) &&
- (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) == 0)) {
+ (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) == 0))
+ {
IsPxeOffer = TRUE;
}
@@ -563,7 +558,6 @@ PxeBcParseDhcp4Packet (
Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *)
(&Offer->Dhcp4.Header.BootFileName[0] -
OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0]));
-
}
//
@@ -584,7 +578,6 @@ PxeBcParseDhcp4Packet (
return EFI_DEVICE_ERROR;
}
} else {
-
if (IS_VALID_DISCOVER_VENDOR_OPTION (Cache4->VendorOpt.BitMap)) {
//
// It's a PXE10 offer with PXEClient and discover vendor option.
@@ -614,7 +607,6 @@ PxeBcParseDhcp4Packet (
return EFI_SUCCESS;
}
-
/**
Cache the DHCPv4 ack packet, and parse it on demand.
@@ -655,7 +647,6 @@ PxeBcCopyDhcp4Ack (
return EFI_SUCCESS;
}
-
/**
Cache the DHCPv4 proxy offer packet according to the received order.
@@ -701,7 +692,6 @@ PxeBcCopyProxyOffer (
return EFI_SUCCESS;
}
-
/**
Retry to request bootfile name by the BINL offer.
@@ -725,8 +715,10 @@ PxeBcRetryBinlOffer (
EFI_DHCP4_PACKET *Reply;
ASSERT (Index < PXEBC_OFFER_MAX_NUM);
- ASSERT (Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpBinl ||
- Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeProxyBinl);
+ ASSERT (
+ Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpBinl ||
+ Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeProxyBinl
+ );
Offer = &Private->OfferBuffer[Index].Dhcp4.Packet.Offer;
@@ -866,7 +858,8 @@ PxeBcCacheDhcp4Offer (
Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum;
Private->OfferCount[OfferType]++;
} else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeProxyWfm11a) &&
- Private->OfferCount[OfferType] < 1) {
+ Private->OfferCount[OfferType] < 1)
+ {
//
// Only cache the first PXE10/WFM11a offer, and discard the others.
//
@@ -889,7 +882,6 @@ PxeBcCacheDhcp4Offer (
return EFI_SUCCESS;
}
-
/**
Select an DHCPv4 offer, and record SelectIndex and SelectProxyType.
@@ -916,15 +908,14 @@ PxeBcSelectDhcp4Offer (
// 1. DhcpPxe10 offer
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpPxe10][0] + 1;
-
} else if (Private->OfferCount[PxeOfferTypeDhcpWfm11a] > 0) {
//
// 2. DhcpWfm11a offer
//
Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpWfm11a][0] + 1;
-
} else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
- Private->OfferCount[PxeOfferTypeProxyPxe10] > 0) {
+ Private->OfferCount[PxeOfferTypeProxyPxe10] > 0)
+ {
//
// 3. DhcpOnly offer and ProxyPxe10 offer.
//
@@ -1007,7 +998,6 @@ PxeBcSelectDhcp4Offer (
}
}
-
/**
Handle the DHCPv4 offer packet.
@@ -1280,8 +1270,10 @@ PxeBcDhcp4CallBack (
DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios table!\n"));
ZeroMem (Packet->Dhcp4.Header.ClientHwAddr, sizeof (EFI_GUID));
}
+
Packet->Dhcp4.Header.HwAddrLen = (UINT8) sizeof (EFI_GUID);
}
+
break;
case Dhcp4RcvdOffer:
@@ -1292,6 +1284,7 @@ PxeBcDhcp4CallBack (
//
break;
}
+
if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) {
//
// Cache the DHCPv4 offers to OfferBuffer[] for select later, and record
@@ -1300,6 +1293,7 @@ PxeBcDhcp4CallBack (
//
PxeBcCacheDhcp4Offer (Private, Packet);
}
+
break;
case Dhcp4SelectOffer:
@@ -1316,6 +1310,7 @@ PxeBcDhcp4CallBack (
} else {
*NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer;
}
+
break;
case Dhcp4RcvdAck:
@@ -1520,7 +1515,6 @@ PxeBcDhcp4Discover (
}
if (!EFI_ERROR (Status)) {
-
RepIndex = 0;
SrvIndex = 0;
Response = Token.ResponseList;
@@ -1539,10 +1533,13 @@ PxeBcDhcp4Discover (
if (SrvList[SrvIndex].AcceptAnyResponse) {
break;
}
+
if ((SrvList[SrvIndex].Type == Type) &&
- EFI_IP4_EQUAL (&Response->Dhcp4.Header.ServerAddr, &SrvList[SrvIndex].IpAddr)) {
+ EFI_IP4_EQUAL (&Response->Dhcp4.Header.ServerAddr, &SrvList[SrvIndex].IpAddr))
+ {
break;
}
+
SrvIndex++;
}
@@ -1565,6 +1562,7 @@ PxeBcDhcp4Discover (
if (EFI_ERROR(Status)) {
goto ON_EXIT;
}
+
CopyMem (&Mode->PxeDiscover, &Token.Packet->Dhcp4, Token.Packet->Length);
} else {
Status = PxeBcCacheDhcp4Packet (&Private->ProxyOffer.Dhcp4.Packet.Offer, Response);
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
index 0e2675be3c..d84aca7e85 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
@@ -10,8 +10,7 @@
#include "PxeBcImpl.h"
-
-EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = {
PxeBcIp4DriverBindingSupported,
PxeBcIp4DriverBindingStart,
PxeBcIp4DriverBindingStop,
@@ -20,7 +19,7 @@ EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = {
NULL
};
-EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = {
PxeBcIp6DriverBindingSupported,
PxeBcIp6DriverBindingStart,
PxeBcIp6DriverBindingStop,
@@ -39,10 +38,10 @@ EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = {
**/
EFI_HANDLE
PxeBcGetNicByIp4Children (
- IN EFI_HANDLE ControllerHandle
+ IN EFI_HANDLE ControllerHandle
)
{
- EFI_HANDLE NicHandle;
+ EFI_HANDLE NicHandle;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid);
if (NicHandle == NULL) {
@@ -64,7 +63,6 @@ PxeBcGetNicByIp4Children (
return NicHandle;
}
-
/**
Get the Nic handle using any child handle in the IPv6 stack.
@@ -75,10 +73,10 @@ PxeBcGetNicByIp4Children (
**/
EFI_HANDLE
PxeBcGetNicByIp6Children (
- IN EFI_HANDLE ControllerHandle
+ IN EFI_HANDLE ControllerHandle
)
{
- EFI_HANDLE NicHandle;
+ EFI_HANDLE NicHandle;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid);
if (NicHandle == NULL) {
@@ -97,7 +95,6 @@ PxeBcGetNicByIp6Children (
return NicHandle;
}
-
/**
Destroy the opened instances based on IPv4.
@@ -111,7 +108,7 @@ PxeBcDestroyIp4Children (
IN PXEBC_PRIVATE_DATA *Private
)
{
- ASSERT(Private != NULL);
+ ASSERT (Private != NULL);
if (Private->ArpChild != NULL) {
//
@@ -175,11 +172,11 @@ PxeBcDestroyIp4Children (
// Close Udp4 for PxeBc->UdpRead and destroy the instance.
//
gBS->CloseProtocol (
- Private->Udp4ReadChild,
- &gEfiUdp4ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Udp4ReadChild,
+ &gEfiUdp4ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -194,11 +191,11 @@ PxeBcDestroyIp4Children (
// Close Mtftp4 for PxeBc->Mtftp4 and destroy the instance.
//
gBS->CloseProtocol (
- Private->Mtftp4Child,
- &gEfiMtftp4ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Mtftp4Child,
+ &gEfiMtftp4ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -213,11 +210,11 @@ PxeBcDestroyIp4Children (
// Close Dhcp4 for PxeBc->Dhcp4 and destroy the instance.
//
gBS->CloseProtocol (
- Private->Dhcp4Child,
- &gEfiDhcp4ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Dhcp4Child,
+ &gEfiDhcp4ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -267,19 +264,19 @@ PxeBcDestroyIp4Children (
Private->Snp
);
}
+
FreePool (Private->Ip4Nic);
}
- Private->ArpChild = NULL;
- Private->Ip4Child = NULL;
- Private->Udp4WriteChild = NULL;
- Private->Udp4ReadChild = NULL;
- Private->Mtftp4Child = NULL;
- Private->Dhcp4Child = NULL;
- Private->Ip4Nic = NULL;
+ Private->ArpChild = NULL;
+ Private->Ip4Child = NULL;
+ Private->Udp4WriteChild = NULL;
+ Private->Udp4ReadChild = NULL;
+ Private->Mtftp4Child = NULL;
+ Private->Dhcp4Child = NULL;
+ Private->Ip4Nic = NULL;
}
-
/**
Destroy the opened instances based on IPv6.
@@ -293,18 +290,18 @@ PxeBcDestroyIp6Children (
IN PXEBC_PRIVATE_DATA *Private
)
{
- ASSERT(Private != NULL);
+ ASSERT (Private != NULL);
if (Private->Ip6Child != NULL) {
//
// Close Ip6 for Ip6->Ip6Config and destroy the instance.
//
gBS->CloseProtocol (
- Private->Ip6Child,
- &gEfiIp6ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Ip6Child,
+ &gEfiIp6ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -337,11 +334,11 @@ PxeBcDestroyIp6Children (
// Close Udp6 for PxeBc->UdpRead and destroy the instance.
//
gBS->CloseProtocol (
- Private->Udp6ReadChild,
- &gEfiUdp6ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Udp6ReadChild,
+ &gEfiUdp6ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
This->DriverBindingHandle,
@@ -355,11 +352,11 @@ PxeBcDestroyIp6Children (
// Close Mtftp6 for PxeBc->Mtftp and destroy the instance.
//
gBS->CloseProtocol (
- Private->Mtftp6Child,
- &gEfiMtftp6ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Mtftp6Child,
+ &gEfiMtftp6ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -374,11 +371,11 @@ PxeBcDestroyIp6Children (
// Close Dhcp6 for PxeBc->Dhcp and destroy the instance.
//
gBS->CloseProtocol (
- Private->Dhcp6Child,
- &gEfiDhcp6ProtocolGuid,
- This->DriverBindingHandle,
- Private->Controller
- );
+ Private->Dhcp6Child,
+ &gEfiDhcp6ProtocolGuid,
+ This->DriverBindingHandle,
+ Private->Controller
+ );
NetLibDestroyServiceChild (
Private->Controller,
@@ -427,6 +424,7 @@ PxeBcDestroyIp6Children (
Private->Snp
);
}
+
FreePool (Private->Ip6Nic);
}
@@ -452,20 +450,20 @@ PxeBcDestroyIp6Children (
**/
EFI_STATUS
PxeBcCheckIpv6Support (
- IN EFI_HANDLE ControllerHandle,
- IN PXEBC_PRIVATE_DATA *Private,
- OUT BOOLEAN *Ipv6Support
+ IN EFI_HANDLE ControllerHandle,
+ IN PXEBC_PRIVATE_DATA *Private,
+ OUT BOOLEAN *Ipv6Support
)
{
- EFI_HANDLE Handle;
- EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
- EFI_STATUS Status;
- EFI_GUID *InfoTypesBuffer;
- UINTN InfoTypeBufferCount;
- UINTN TypeIndex;
- BOOLEAN Supported;
- VOID *InfoBlock;
- UINTN InfoBlockSize;
+ EFI_HANDLE Handle;
+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+ EFI_STATUS Status;
+ EFI_GUID *InfoTypesBuffer;
+ UINTN InfoTypeBufferCount;
+ UINTN TypeIndex;
+ BOOLEAN Supported;
+ VOID *InfoBlock;
+ UINTN InfoBlockSize;
ASSERT (Private != NULL && Ipv6Support != NULL);
@@ -493,16 +491,16 @@ PxeBcCheckIpv6Support (
Status = gBS->HandleProtocol (
Handle,
&gEfiAdapterInformationProtocolGuid,
- (VOID *) &Aip
+ (VOID *)&Aip
);
- if (EFI_ERROR (Status) || Aip == NULL) {
+ if (EFI_ERROR (Status) || (Aip == NULL)) {
return EFI_NOT_FOUND;
}
InfoTypesBuffer = NULL;
InfoTypeBufferCount = 0;
- Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
- if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
+ Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
+ if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
FreePool (InfoTypesBuffer);
return EFI_NOT_FOUND;
}
@@ -525,16 +523,15 @@ PxeBcCheckIpv6Support (
//
InfoBlock = NULL;
InfoBlockSize = 0;
- Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
- if (EFI_ERROR (Status) || InfoBlock == NULL) {
+ Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
+ if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
FreePool (InfoBlock);
return EFI_NOT_FOUND;
}
- *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support;
+ *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support;
FreePool (InfoBlock);
return EFI_SUCCESS;
-
}
/**
@@ -555,14 +552,14 @@ PxeBcCreateIp4Children (
IN PXEBC_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- IPv4_DEVICE_PATH Ip4Node;
- EFI_PXE_BASE_CODE_MODE *Mode;
- EFI_UDP4_CONFIG_DATA *Udp4CfgData;
- EFI_IP4_CONFIG_DATA *Ip4CfgData;
- EFI_IP4_MODE_DATA Ip4ModeData;
- PXEBC_PRIVATE_PROTOCOL *Id;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ EFI_STATUS Status;
+ IPv4_DEVICE_PATH Ip4Node;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+ EFI_UDP4_CONFIG_DATA *Udp4CfgData;
+ EFI_IP4_CONFIG_DATA *Ip4CfgData;
+ EFI_IP4_MODE_DATA Ip4ModeData;
+ PXEBC_PRIVATE_PROTOCOL *Id;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
if (Private->Ip4Nic != NULL) {
//
@@ -587,7 +584,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid,
- (VOID **) &Private->Dhcp4,
+ (VOID **)&Private->Dhcp4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -612,7 +609,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Mtftp4Child,
&gEfiMtftp4ProtocolGuid,
- (VOID **) &Private->Mtftp4,
+ (VOID **)&Private->Mtftp4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -637,7 +634,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Udp4ReadChild,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Private->Udp4Read,
+ (VOID **)&Private->Udp4Read,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -662,7 +659,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Udp4WriteChild,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Private->Udp4Write,
+ (VOID **)&Private->Udp4Write,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -687,7 +684,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->ArpChild,
&gEfiArpProtocolGuid,
- (VOID **) &Private->Arp,
+ (VOID **)&Private->Arp,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -712,7 +709,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Ip4Child,
&gEfiIp4ProtocolGuid,
- (VOID **) &Private->Ip4,
+ (VOID **)&Private->Ip4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -739,13 +736,13 @@ PxeBcCreateIp4Children (
Private->Ip4Nic->Private = Private;
Private->Ip4Nic->Signature = PXEBC_VIRTUAL_NIC_SIGNATURE;
- //
+ //
// Locate Ip4->Ip4Config2 and store it for set IPv4 Policy.
//
Status = gBS->HandleProtocol (
ControllerHandle,
&gEfiIp4Config2ProtocolGuid,
- (VOID **) &Private->Ip4Config2
+ (VOID **)&Private->Ip4Config2
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
@@ -814,7 +811,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
Private->Ip4Nic->Controller,
&gEfiSimpleNetworkProtocolGuid,
- (VOID **) &Snp,
+ (VOID **)&Snp,
This->DriverBindingHandle,
Private->Ip4Nic->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE
@@ -831,7 +828,7 @@ PxeBcCreateIp4Children (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
- (VOID **) &Id,
+ (VOID **)&Id,
This->DriverBindingHandle,
Private->Ip4Nic->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -843,9 +840,9 @@ PxeBcCreateIp4Children (
//
// Set default configure data for Udp4Read and Ip4 instance.
//
- Mode = Private->PxeBc.Mode;
- Udp4CfgData = &Private->Udp4CfgData;
- Ip4CfgData = &Private->Ip4CfgData;
+ Mode = Private->PxeBc.Mode;
+ Udp4CfgData = &Private->Udp4CfgData;
+ Ip4CfgData = &Private->Ip4CfgData;
Udp4CfgData->AcceptBroadcast = FALSE;
Udp4CfgData->AcceptAnyPort = TRUE;
@@ -855,12 +852,12 @@ PxeBcCreateIp4Children (
Udp4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
Udp4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
- Ip4CfgData->AcceptIcmpErrors = TRUE;
- Ip4CfgData->DefaultProtocol = EFI_IP_PROTO_ICMP;
- Ip4CfgData->TypeOfService = Mode->ToS;
- Ip4CfgData->TimeToLive = Mode->TTL;
- Ip4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
- Ip4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
+ Ip4CfgData->AcceptIcmpErrors = TRUE;
+ Ip4CfgData->DefaultProtocol = EFI_IP_PROTO_ICMP;
+ Ip4CfgData->TypeOfService = Mode->ToS;
+ Ip4CfgData->TimeToLive = Mode->TTL;
+ Ip4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
+ Ip4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
return EFI_SUCCESS;
@@ -869,7 +866,6 @@ ON_ERROR:
return Status;
}
-
/**
Create the opened instances based on IPv6.
@@ -888,14 +884,14 @@ PxeBcCreateIp6Children (
IN PXEBC_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- IPv6_DEVICE_PATH Ip6Node;
- EFI_UDP6_CONFIG_DATA *Udp6CfgData;
- EFI_IP6_CONFIG_DATA *Ip6CfgData;
- EFI_IP6_MODE_DATA Ip6ModeData;
- PXEBC_PRIVATE_PROTOCOL *Id;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- UINTN Index;
+ EFI_STATUS Status;
+ IPv6_DEVICE_PATH Ip6Node;
+ EFI_UDP6_CONFIG_DATA *Udp6CfgData;
+ EFI_IP6_CONFIG_DATA *Ip6CfgData;
+ EFI_IP6_MODE_DATA Ip6ModeData;
+ PXEBC_PRIVATE_PROTOCOL *Id;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ UINTN Index;
if (Private->Ip6Nic != NULL) {
//
@@ -929,7 +925,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Dhcp6Child,
&gEfiDhcp6ProtocolGuid,
- (VOID **) &Private->Dhcp6,
+ (VOID **)&Private->Dhcp6,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -964,7 +960,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Mtftp6Child,
&gEfiMtftp6ProtocolGuid,
- (VOID **) &Private->Mtftp6,
+ (VOID **)&Private->Mtftp6,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -989,7 +985,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Udp6ReadChild,
&gEfiUdp6ProtocolGuid,
- (VOID **) &Private->Udp6Read,
+ (VOID **)&Private->Udp6Read,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1014,7 +1010,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Udp6WriteChild,
&gEfiUdp6ProtocolGuid,
- (VOID **) &Private->Udp6Write,
+ (VOID **)&Private->Udp6Write,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1039,7 +1035,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Ip6Child,
&gEfiIp6ProtocolGuid,
- (VOID **) &Private->Ip6,
+ (VOID **)&Private->Ip6,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1088,7 +1084,7 @@ PxeBcCreateIp6Children (
Status = gBS->HandleProtocol (
ControllerHandle,
&gEfiIp6ConfigProtocolGuid,
- (VOID **) &Private->Ip6Cfg
+ (VOID **)&Private->Ip6Cfg
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
@@ -1098,9 +1094,9 @@ PxeBcCreateIp6Children (
// Create a device path node for Ipv6 virtual nic, and append it.
//
ZeroMem (&Ip6Node, sizeof (IPv6_DEVICE_PATH));
- Ip6Node.Header.Type = MESSAGING_DEVICE_PATH;
- Ip6Node.Header.SubType = MSG_IPv6_DP;
- Ip6Node.PrefixLength = IP6_PREFIX_LENGTH;
+ Ip6Node.Header.Type = MESSAGING_DEVICE_PATH;
+ Ip6Node.Header.SubType = MSG_IPv6_DP;
+ Ip6Node.PrefixLength = IP6_PREFIX_LENGTH;
SetDevicePathNodeLength (&Ip6Node.Header, sizeof (Ip6Node));
@@ -1157,7 +1153,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
Private->Ip6Nic->Controller,
&gEfiSimpleNetworkProtocolGuid,
- (VOID **) &Snp,
+ (VOID **)&Snp,
This->DriverBindingHandle,
Private->Ip6Nic->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE
@@ -1174,7 +1170,7 @@ PxeBcCreateIp6Children (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
- (VOID **) &Id,
+ (VOID **)&Id,
This->DriverBindingHandle,
Private->Ip6Nic->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -1192,15 +1188,15 @@ PxeBcCreateIp6Children (
//
// Fail to get the data whether UNDI supports IPv6. Set default value.
//
- Private->Mode.Ipv6Available = TRUE;
+ Private->Mode.Ipv6Available = TRUE;
}
if (!Private->Mode.Ipv6Available) {
goto ON_ERROR;
}
- Udp6CfgData = &Private->Udp6CfgData;
- Ip6CfgData = &Private->Ip6CfgData;
+ Udp6CfgData = &Private->Udp6CfgData;
+ Ip6CfgData = &Private->Ip6CfgData;
Udp6CfgData->AcceptAnyPort = TRUE;
Udp6CfgData->AllowDuplicatePort = TRUE;
@@ -1208,11 +1204,11 @@ PxeBcCreateIp6Children (
Udp6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
Udp6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
- Ip6CfgData->AcceptIcmpErrors = TRUE;
- Ip6CfgData->DefaultProtocol = IP6_ICMP;
- Ip6CfgData->HopLimit = PXEBC_DEFAULT_HOPLIMIT;
- Ip6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
- Ip6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
+ Ip6CfgData->AcceptIcmpErrors = TRUE;
+ Ip6CfgData->DefaultProtocol = IP6_ICMP;
+ Ip6CfgData->HopLimit = PXEBC_DEFAULT_HOPLIMIT;
+ Ip6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
+ Ip6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME;
return EFI_SUCCESS;
@@ -1221,7 +1217,6 @@ ON_ERROR:
return Status;
}
-
/**
The entry point for UefiPxeBc driver that installs the driver
binding and component name protocol on its image.
@@ -1236,13 +1231,13 @@ ON_ERROR:
EFI_STATUS
EFIAPI
PxeBcDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
- if ((PcdGet8(PcdIPv4PXESupport) == PXE_DISABLED) && (PcdGet8(PcdIPv6PXESupport) == PXE_DISABLED)) {
+ if ((PcdGet8 (PcdIPv4PXESupport) == PXE_DISABLED) && (PcdGet8 (PcdIPv6PXESupport) == PXE_DISABLED)) {
return EFI_UNSUPPORTED;
}
@@ -1300,20 +1295,22 @@ PxeBcSupported (
IN UINT8 IpVersion
)
{
- EFI_STATUS Status;
- EFI_GUID *DhcpServiceBindingGuid;
- EFI_GUID *MtftpServiceBindingGuid;
+ EFI_STATUS Status;
+ EFI_GUID *DhcpServiceBindingGuid;
+ EFI_GUID *MtftpServiceBindingGuid;
if (IpVersion == IP_VERSION_4) {
- if (PcdGet8(PcdIPv4PXESupport) == PXE_DISABLED) {
+ if (PcdGet8 (PcdIPv4PXESupport) == PXE_DISABLED) {
return EFI_UNSUPPORTED;
}
+
DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
MtftpServiceBindingGuid = &gEfiMtftp4ServiceBindingProtocolGuid;
} else {
- if (PcdGet8(PcdIPv6PXESupport) == PXE_DISABLED) {
+ if (PcdGet8 (PcdIPv6PXESupport) == PXE_DISABLED) {
return EFI_UNSUPPORTED;
}
+
DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid;
MtftpServiceBindingGuid = &gEfiMtftp6ServiceBindingProtocolGuid;
}
@@ -1322,22 +1319,22 @@ PxeBcSupported (
// Try to open the Mtftp and Dhcp protocol to test whether IP stack is ready.
//
Status = gBS->OpenProtocol (
- ControllerHandle,
- DhcpServiceBindingGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
+ ControllerHandle,
+ DhcpServiceBindingGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
- ControllerHandle,
- MtftpServiceBindingGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
+ ControllerHandle,
+ MtftpServiceBindingGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
}
//
@@ -1375,20 +1372,20 @@ PxeBcStart (
IN UINT8 IpVersion
)
{
- PXEBC_PRIVATE_DATA *Private;
- EFI_STATUS Status;
- PXEBC_PRIVATE_PROTOCOL *Id;
- BOOLEAN FirstStart;
+ PXEBC_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ PXEBC_PRIVATE_PROTOCOL *Id;
+ BOOLEAN FirstStart;
FirstStart = FALSE;
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiCallerIdGuid,
- (VOID **) &Id,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ (VOID **)&Id,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
//
// Skip the initialization if the driver has been started already.
@@ -1425,7 +1422,7 @@ PxeBcStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &Private->DevicePath,
+ (VOID **)&Private->DevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1441,7 +1438,7 @@ PxeBcStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
- (VOID **) &Private->Nii,
+ (VOID **)&Private->Nii,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1469,7 +1466,7 @@ PxeBcStart (
//
// Try to locate SNP protocol.
//
- NetLibGetSnpHandle(ControllerHandle, &Private->Snp);
+ NetLibGetSnpHandle (ControllerHandle, &Private->Snp);
}
if (IpVersion == IP_VERSION_4) {
@@ -1483,6 +1480,7 @@ PxeBcStart (
//
Status = PxeBcCreateIp6Children (This, ControllerHandle, Private);
}
+
if (EFI_ERROR (Status)) {
//
// Failed to start PXE driver if IPv4 and IPv6 stack are both not available.
@@ -1508,14 +1506,13 @@ ON_ERROR:
PxeBcDestroyIp6Children (This, Private);
}
- if (FirstStart && Private != NULL) {
+ if (FirstStart && (Private != NULL)) {
FreePool (Private);
}
return Status;
}
-
/**
Stop this driver on ControllerHandle. This is the worker function for
PxeBcIp4(6)DriverBindingStop.
@@ -1542,12 +1539,12 @@ PxeBcStop (
IN UINT8 IpVersion
)
{
- PXEBC_PRIVATE_DATA *Private;
- PXEBC_VIRTUAL_NIC *VirtualNic;
- EFI_LOAD_FILE_PROTOCOL *LoadFile;
- EFI_STATUS Status;
- EFI_HANDLE NicHandle;
- PXEBC_PRIVATE_PROTOCOL *Id;
+ PXEBC_PRIVATE_DATA *Private;
+ PXEBC_VIRTUAL_NIC *VirtualNic;
+ EFI_LOAD_FILE_PROTOCOL *LoadFile;
+ EFI_STATUS Status;
+ EFI_HANDLE NicHandle;
+ PXEBC_PRIVATE_PROTOCOL *Id;
Private = NULL;
NicHandle = NULL;
@@ -1558,7 +1555,7 @@ PxeBcStop (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiLoadFileProtocolGuid,
- (VOID **) &LoadFile,
+ (VOID **)&LoadFile,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1572,6 +1569,7 @@ PxeBcStop (
} else {
NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);
}
+
if (NicHandle == NULL) {
return EFI_SUCCESS;
}
@@ -1582,7 +1580,7 @@ PxeBcStop (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiCallerIdGuid,
- (VOID **) &Id,
+ (VOID **)&Id,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1590,8 +1588,8 @@ PxeBcStop (
if (EFI_ERROR (Status)) {
return Status;
}
- Private = PXEBC_PRIVATE_DATA_FROM_ID (Id);
+ Private = PXEBC_PRIVATE_DATA_FROM_ID (Id);
} else {
//
// It's a virtual handle with LoadFileProtocol.
@@ -1599,7 +1597,7 @@ PxeBcStop (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiLoadFileProtocolGuid,
- (VOID **) &LoadFile,
+ (VOID **)&LoadFile,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1617,20 +1615,19 @@ PxeBcStop (
// Stop functionality of PXE Base Code protocol
//
Status = Private->PxeBc.Stop (&Private->PxeBc);
- if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
+ if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
return Status;
}
-
- if (Private->Ip4Nic != NULL && IpVersion == IP_VERSION_4) {
+ if ((Private->Ip4Nic != NULL) && (IpVersion == IP_VERSION_4)) {
PxeBcDestroyIp4Children (This, Private);
}
- if (Private->Ip6Nic != NULL && IpVersion == IP_VERSION_6) {
+ if ((Private->Ip6Nic != NULL) && (IpVersion == IP_VERSION_6)) {
PxeBcDestroyIp6Children (This, Private);
}
- if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
+ if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
gBS->UninstallProtocolInterface (
NicHandle,
&gEfiCallerIdGuid,
--
2.39.3