summaryrefslogtreecommitdiff
path: root/NetworkPkg/Dhcp4Dxe
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:07 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commitd1050b9dff1cace252aff86630bfdb59dff5f507 (patch)
tree77f796143980742d97a883f62ce339a270474801 /NetworkPkg/Dhcp4Dxe
parent2f88bd3a1296c522317f1c21377876de63de5be7 (diff)
downloadedk2-d1050b9dff1cace252aff86630bfdb59dff5f507.zip
edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.tar.gz
edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.tar.bz2
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>
Diffstat (limited to 'NetworkPkg/Dhcp4Dxe')
-rw-r--r--NetworkPkg/Dhcp4Dxe/ComponentName.c47
-rw-r--r--NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c175
-rw-r--r--NetworkPkg/Dhcp4Dxe/Dhcp4Driver.h6
-rw-r--r--NetworkPkg/Dhcp4Dxe/Dhcp4Impl.c317
-rw-r--r--NetworkPkg/Dhcp4Dxe/Dhcp4Impl.h135
-rw-r--r--NetworkPkg/Dhcp4Dxe/Dhcp4Io.c525
-rw-r--r--NetworkPkg/Dhcp4Dxe/Dhcp4Io.h74
-rw-r--r--NetworkPkg/Dhcp4Dxe/Dhcp4Option.c538
-rw-r--r--NetworkPkg/Dhcp4Dxe/Dhcp4Option.h109
9 files changed, 925 insertions, 1001 deletions
diff --git a/NetworkPkg/Dhcp4Dxe/ComponentName.c b/NetworkPkg/Dhcp4Dxe/ComponentName.c
index 7c404fa..cb41563 100644
--- a/NetworkPkg/Dhcp4Dxe/ComponentName.c
+++ b/NetworkPkg/Dhcp4Dxe/ComponentName.c
@@ -5,12 +5,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Dhcp4Impl.h"
//
// EFI Component Name Functions
//
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -58,7 +58,6 @@ DhcpComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -130,14 +129,13 @@ DhcpComponentNameGetDriverName (
EFI_STATUS
EFIAPI
DhcpComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-
//
// EFI Component Name Protocol
//
@@ -150,14 +148,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName =
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) DhcpComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) DhcpComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)DhcpComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)DhcpComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] = {
{
"eng;en",
L"DHCP Protocol Driver"
@@ -168,9 +165,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] =
}
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gDhcpControllerNameTable = NULL;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gDhcpControllerNameTable = NULL;
-CHAR16 *mDhcp4ControllerName[] = {
+CHAR16 *mDhcp4ControllerName[] = {
L"DHCPv4 (State=0, Stopped)",
L"DHCPv4 (State=1, Init)",
L"DHCPv4 (State=2, Selecting)",
@@ -251,11 +248,11 @@ DhcpComponentNameGetDriverName (
**/
EFI_STATUS
UpdateName (
- IN EFI_DHCP4_PROTOCOL *Dhcp4
+ IN EFI_DHCP4_PROTOCOL *Dhcp4
)
{
- EFI_STATUS Status;
- EFI_DHCP4_MODE_DATA Dhcp4ModeData;
+ EFI_STATUS Status;
+ EFI_DHCP4_MODE_DATA Dhcp4ModeData;
if (Dhcp4 == NULL) {
return EFI_INVALID_PARAMETER;
@@ -369,15 +366,15 @@ UpdateName (
EFI_STATUS
EFIAPI
DhcpComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- EFI_DHCP4_PROTOCOL *Dhcp4;
+ EFI_STATUS Status;
+ EFI_DHCP4_PROTOCOL *Dhcp4;
//
// Only provide names for child handles.
diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c
index 970141a..8c37e93 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/Dhcp4Dxe/Dhcp4Driver.h b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.h
index f637058..7c32ef9 100644
--- a/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.h
+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.h
@@ -9,9 +9,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __EFI_DHCP4_DRIVER_H__
#define __EFI_DHCP4_DRIVER_H__
-extern EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2;
-extern EFI_UNICODE_STRING_TABLE *gDhcpControllerNameTable;
+extern EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2;
+extern EFI_UNICODE_STRING_TABLE *gDhcpControllerNameTable;
/**
Test to see if this driver supports ControllerHandle. This service
diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Impl.c b/NetworkPkg/Dhcp4Dxe/Dhcp4Impl.c
index 8290533..24a0693 100644
--- a/NetworkPkg/Dhcp4Dxe/Dhcp4Impl.c
+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Impl.c
@@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Dhcp4Impl.h"
/**
@@ -25,8 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
EfiDhcp4GetModeData (
- IN EFI_DHCP4_PROTOCOL *This,
- OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData
+ IN EFI_DHCP4_PROTOCOL *This,
+ OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData
);
/**
@@ -121,8 +120,8 @@ EfiDhcp4Configure (
EFI_STATUS
EFIAPI
EfiDhcp4Start (
- IN EFI_DHCP4_PROTOCOL *This,
- IN EFI_EVENT CompletionEvent OPTIONAL
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_EVENT CompletionEvent OPTIONAL
);
/**
@@ -166,9 +165,9 @@ EfiDhcp4Start (
EFI_STATUS
EFIAPI
EfiDhcp4RenewRebind (
- IN EFI_DHCP4_PROTOCOL *This,
- IN BOOLEAN RebindRequest,
- IN EFI_EVENT CompletionEvent OPTIONAL
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN BOOLEAN RebindRequest,
+ IN EFI_EVENT CompletionEvent OPTIONAL
);
/**
@@ -195,7 +194,7 @@ EfiDhcp4RenewRebind (
EFI_STATUS
EFIAPI
EfiDhcp4Release (
- IN EFI_DHCP4_PROTOCOL *This
+ IN EFI_DHCP4_PROTOCOL *This
);
/**
@@ -216,7 +215,7 @@ EfiDhcp4Release (
EFI_STATUS
EFIAPI
EfiDhcp4Stop (
- IN EFI_DHCP4_PROTOCOL *This
+ IN EFI_DHCP4_PROTOCOL *This
);
/**
@@ -314,10 +313,10 @@ EfiDhcp4TransmitReceive (
EFI_STATUS
EFIAPI
EfiDhcp4Parse (
- IN EFI_DHCP4_PROTOCOL *This,
- IN EFI_DHCP4_PACKET *Packet,
- IN OUT UINT32 *OptionCount,
- OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_DHCP4_PACKET *Packet,
+ IN OUT UINT32 *OptionCount,
+ OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL
);
EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate = {
@@ -348,15 +347,15 @@ EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate = {
EFI_STATUS
EFIAPI
EfiDhcp4GetModeData (
- IN EFI_DHCP4_PROTOCOL *This,
- OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData
+ IN EFI_DHCP4_PROTOCOL *This,
+ OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData
)
{
- DHCP_PROTOCOL *Instance;
- DHCP_SERVICE *DhcpSb;
- DHCP_PARAMETER *Para;
- EFI_TPL OldTpl;
- IP4_ADDR Ip;
+ DHCP_PROTOCOL *Instance;
+ DHCP_SERVICE *DhcpSb;
+ DHCP_PARAMETER *Para;
+ EFI_TPL OldTpl;
+ IP4_ADDR Ip;
//
// First validate the parameters.
@@ -367,14 +366,14 @@ EfiDhcp4GetModeData (
Instance = DHCP_INSTANCE_FROM_THIS (This);
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- DhcpSb = Instance->Service;
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ DhcpSb = Instance->Service;
//
// Caller can use GetModeData to retrieve current DHCP states
// no matter whether it is the active child or not.
//
- Dhcp4ModeData->State = (EFI_DHCP4_STATE) DhcpSb->DhcpState;
+ Dhcp4ModeData->State = (EFI_DHCP4_STATE)DhcpSb->DhcpState;
CopyMem (&Dhcp4ModeData->ConfigData, &DhcpSb->ActiveConfig, sizeof (Dhcp4ModeData->ConfigData));
CopyMem (&Dhcp4ModeData->ClientMacAddress, &DhcpSb->Mac, sizeof (Dhcp4ModeData->ClientMacAddress));
@@ -404,7 +403,6 @@ EfiDhcp4GetModeData (
return EFI_SUCCESS;
}
-
/**
Free the resource related to the configure parameters.
DHCP driver will make a copy of the user's configure
@@ -418,7 +416,7 @@ DhcpCleanConfigure (
IN OUT EFI_DHCP4_CONFIG_DATA *Config
)
{
- UINT32 Index;
+ UINT32 Index;
if (Config->DiscoverTimeout != NULL) {
FreePool (Config->DiscoverTimeout);
@@ -441,7 +439,6 @@ DhcpCleanConfigure (
ZeroMem (Config, sizeof (EFI_DHCP4_CONFIG_DATA));
}
-
/**
Allocate memory for configure parameter such as timeout value for Dst,
then copy the configure parameter from Src to Dst.
@@ -459,22 +456,22 @@ DhcpCopyConfigure (
IN EFI_DHCP4_CONFIG_DATA *Src
)
{
- EFI_DHCP4_PACKET_OPTION **DstOptions;
- EFI_DHCP4_PACKET_OPTION **SrcOptions;
- UINTN Len;
- UINT32 Index;
+ EFI_DHCP4_PACKET_OPTION **DstOptions;
+ EFI_DHCP4_PACKET_OPTION **SrcOptions;
+ UINTN Len;
+ UINT32 Index;
CopyMem (Dst, Src, sizeof (*Dst));
- Dst->DiscoverTimeout = NULL;
- Dst->RequestTimeout = NULL;
- Dst->OptionList = NULL;
+ Dst->DiscoverTimeout = NULL;
+ Dst->RequestTimeout = NULL;
+ Dst->OptionList = NULL;
//
// Allocate a memory then copy DiscoverTimeout to it
//
if (Src->DiscoverTimeout != NULL) {
- Len = Src->DiscoverTryCount * sizeof (UINT32);
- Dst->DiscoverTimeout = AllocatePool (Len);
+ Len = Src->DiscoverTryCount * sizeof (UINT32);
+ Dst->DiscoverTimeout = AllocatePool (Len);
if (Dst->DiscoverTimeout == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -513,8 +510,8 @@ DhcpCopyConfigure (
goto ON_ERROR;
}
- DstOptions = Dst->OptionList;
- SrcOptions = Src->OptionList;
+ DstOptions = Dst->OptionList;
+ SrcOptions = Src->OptionList;
for (Index = 0; Index < Src->OptionCount; Index++) {
Len = sizeof (EFI_DHCP4_PACKET_OPTION) + MAX (SrcOptions[Index]->Length - 1, 0);
@@ -536,7 +533,6 @@ ON_ERROR:
return EFI_OUT_OF_RESOURCES;
}
-
/**
Give up the control of the DHCP service to let other child
resume. Don't change the service's DHCP state and the Client
@@ -547,21 +543,21 @@ ON_ERROR:
**/
VOID
DhcpYieldControl (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
)
{
- EFI_DHCP4_CONFIG_DATA *Config;
+ EFI_DHCP4_CONFIG_DATA *Config;
- Config = &DhcpSb->ActiveConfig;
+ Config = &DhcpSb->ActiveConfig;
- DhcpSb->ServiceState = DHCP_UNCONFIGED;
- DhcpSb->ActiveChild = NULL;
+ DhcpSb->ServiceState = DHCP_UNCONFIGED;
+ DhcpSb->ActiveChild = NULL;
if (Config->DiscoverTimeout != NULL) {
FreePool (Config->DiscoverTimeout);
- Config->DiscoverTryCount = 0;
- Config->DiscoverTimeout = NULL;
+ Config->DiscoverTryCount = 0;
+ Config->DiscoverTimeout = NULL;
}
if (Config->RequestTimeout != NULL) {
@@ -575,7 +571,6 @@ DhcpYieldControl (
Config->CallbackContext = NULL;
}
-
/**
Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver.
@@ -625,13 +620,13 @@ EfiDhcp4Configure (
IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL
)
{
- EFI_DHCP4_CONFIG_DATA *Config;
- DHCP_PROTOCOL *Instance;
- DHCP_SERVICE *DhcpSb;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- UINT32 Index;
- IP4_ADDR Ip;
+ EFI_DHCP4_CONFIG_DATA *Config;
+ DHCP_PROTOCOL *Instance;
+ DHCP_SERVICE *DhcpSb;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ UINT32 Index;
+ IP4_ADDR Ip;
//
// First validate the parameters
@@ -654,7 +649,7 @@ EfiDhcp4Configure (
}
CopyMem (&Ip, &Dhcp4CfgData->ClientAddress, sizeof (IP4_ADDR));
- if (IP4_IS_LOCAL_BROADCAST(NTOHL (Ip))) {
+ if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
return EFI_INVALID_PARAMETER;
}
}
@@ -665,18 +660,18 @@ EfiDhcp4Configure (
return EFI_INVALID_PARAMETER;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- DhcpSb = Instance->Service;
- Config = &DhcpSb->ActiveConfig;
+ DhcpSb = Instance->Service;
+ Config = &DhcpSb->ActiveConfig;
- Status = EFI_ACCESS_DENIED;
+ Status = EFI_ACCESS_DENIED;
if ((DhcpSb->DhcpState != Dhcp4Stopped) &&
(DhcpSb->DhcpState != Dhcp4Init) &&
(DhcpSb->DhcpState != Dhcp4InitReboot) &&
- (DhcpSb->DhcpState != Dhcp4Bound)) {
-
+ (DhcpSb->DhcpState != Dhcp4Bound))
+ {
goto ON_EXIT;
}
@@ -710,9 +705,8 @@ EfiDhcp4Configure (
}
}
- DhcpSb->ServiceState = DHCP_CONFIGED;
- Status = EFI_SUCCESS;
-
+ DhcpSb->ServiceState = DHCP_CONFIGED;
+ Status = EFI_SUCCESS;
} else if (DhcpSb->ActiveChild == Instance) {
Status = EFI_SUCCESS;
DhcpYieldControl (DhcpSb);
@@ -723,7 +717,6 @@ ON_EXIT:
return Status;
}
-
/**
Starts the DHCP configuration process.
@@ -768,15 +761,15 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiDhcp4Start (
- IN EFI_DHCP4_PROTOCOL *This,
- IN EFI_EVENT CompletionEvent OPTIONAL
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_EVENT CompletionEvent OPTIONAL
)
{
- DHCP_PROTOCOL *Instance;
- DHCP_SERVICE *DhcpSb;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- EFI_STATUS MediaStatus;
+ DHCP_PROTOCOL *Instance;
+ DHCP_SERVICE *DhcpSb;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ EFI_STATUS MediaStatus;
//
// First validate the parameters
@@ -791,8 +784,8 @@ EfiDhcp4Start (
return EFI_INVALID_PARAMETER;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- DhcpSb = Instance->Service;
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ DhcpSb = Instance->Service;
if (DhcpSb->DhcpState == Dhcp4Stopped) {
Status = EFI_NOT_STARTED;
@@ -820,7 +813,6 @@ EfiDhcp4Start (
goto ON_ERROR;
}
-
Instance->CompletionEvent = CompletionEvent;
//
@@ -843,7 +835,6 @@ ON_ERROR:
return Status;
}
-
/**
Extends the lease time by sending a request packet.
@@ -885,15 +876,15 @@ ON_ERROR:
EFI_STATUS
EFIAPI
EfiDhcp4RenewRebind (
- IN EFI_DHCP4_PROTOCOL *This,
- IN BOOLEAN RebindRequest,
- IN EFI_EVENT CompletionEvent OPTIONAL
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN BOOLEAN RebindRequest,
+ IN EFI_EVENT CompletionEvent OPTIONAL
)
{
- DHCP_PROTOCOL *Instance;
- DHCP_SERVICE *DhcpSb;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ DHCP_PROTOCOL *Instance;
+ DHCP_SERVICE *DhcpSb;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
//
// First validate the parameters
@@ -908,8 +899,8 @@ EfiDhcp4RenewRebind (
return EFI_INVALID_PARAMETER;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- DhcpSb = Instance->Service;
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ DhcpSb = Instance->Service;
if (DhcpSb->DhcpState == Dhcp4Stopped) {
Status = EFI_NOT_STARTED;
@@ -946,7 +937,7 @@ EfiDhcp4RenewRebind (
DhcpSb->Selected,
DhcpSb->Para,
DHCP_MSG_REQUEST,
- (UINT8 *) "Extra renew/rebind by the application"
+ (UINT8 *)"Extra renew/rebind by the application"
);
if (EFI_ERROR (Status)) {
@@ -954,16 +945,15 @@ EfiDhcp4RenewRebind (
goto ON_EXIT;
}
- DhcpSb->ExtraRefresh = TRUE;
- DhcpSb->IoStatus = EFI_ALREADY_STARTED;
- Instance->RenewRebindEvent = CompletionEvent;
+ DhcpSb->ExtraRefresh = TRUE;
+ DhcpSb->IoStatus = EFI_ALREADY_STARTED;
+ Instance->RenewRebindEvent = CompletionEvent;
gBS->RestoreTPL (OldTpl);
if (CompletionEvent == NULL) {
while (DhcpSb->IoStatus == EFI_ALREADY_STARTED) {
DhcpSb->UdpIo->Protocol.Udp4->Poll (DhcpSb->UdpIo->Protocol.Udp4);
-
}
return DhcpSb->IoStatus;
@@ -976,7 +966,6 @@ ON_EXIT:
return Status;
}
-
/**
Releases the current address configuration.
@@ -1001,13 +990,13 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiDhcp4Release (
- IN EFI_DHCP4_PROTOCOL *This
+ IN EFI_DHCP4_PROTOCOL *This
)
{
- DHCP_PROTOCOL *Instance;
- DHCP_SERVICE *DhcpSb;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ DHCP_PROTOCOL *Instance;
+ DHCP_SERVICE *DhcpSb;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
//
// First validate the parameters
@@ -1022,9 +1011,9 @@ EfiDhcp4Release (
return EFI_INVALID_PARAMETER;
}
- Status = EFI_SUCCESS;
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- DhcpSb = Instance->Service;
+ Status = EFI_SUCCESS;
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ DhcpSb = Instance->Service;
if ((DhcpSb->DhcpState != Dhcp4InitReboot) && (DhcpSb->DhcpState != Dhcp4Bound)) {
Status = EFI_ACCESS_DENIED;
@@ -1053,7 +1042,6 @@ ON_EXIT:
return Status;
}
-
/**
Stops the current address configuration.
@@ -1072,12 +1060,12 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiDhcp4Stop (
- IN EFI_DHCP4_PROTOCOL *This
+ IN EFI_DHCP4_PROTOCOL *This
)
{
- DHCP_PROTOCOL *Instance;
- DHCP_SERVICE *DhcpSb;
- EFI_TPL OldTpl;
+ DHCP_PROTOCOL *Instance;
+ DHCP_SERVICE *DhcpSb;
+ EFI_TPL OldTpl;
//
// First validate the parameters
@@ -1092,19 +1080,18 @@ EfiDhcp4Stop (
return EFI_INVALID_PARAMETER;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- DhcpSb = Instance->Service;
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ DhcpSb = Instance->Service;
DhcpCleanLease (DhcpSb);
- DhcpSb->DhcpState = Dhcp4Stopped;
- DhcpSb->ServiceState = DHCP_UNCONFIGED;
+ DhcpSb->DhcpState = Dhcp4Stopped;
+ DhcpSb->ServiceState = DHCP_UNCONFIGED;
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
-
/**
Builds a DHCP packet, given the options to be appended or deleted or replaced.
@@ -1152,15 +1139,15 @@ EfiDhcp4Build (
}
if ((SeedPacket == NULL) || (SeedPacket->Dhcp4.Magik != DHCP_OPTION_MAGIC) ||
- EFI_ERROR (DhcpValidateOptions (SeedPacket, NULL))) {
-
+ EFI_ERROR (DhcpValidateOptions (SeedPacket, NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
if (((DeleteCount == 0) && (AppendCount == 0)) ||
((DeleteCount != 0) && (DeleteList == NULL)) ||
- ((AppendCount != 0) && (AppendList == NULL))) {
-
+ ((AppendCount != 0) && (AppendList == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -1188,8 +1175,8 @@ EfiDhcp4Build (
EFI_STATUS
EFIAPI
Dhcp4InstanceConfigUdpIo (
- IN UDP_IO *UdpIo,
- IN VOID *Context
+ IN UDP_IO *UdpIo,
+ IN VOID *Context
)
{
DHCP_PROTOCOL *Instance;
@@ -1201,7 +1188,7 @@ Dhcp4InstanceConfigUdpIo (
INTN Class;
IP4_ADDR SubnetMask;
- Instance = (DHCP_PROTOCOL *) Context;
+ Instance = (DHCP_PROTOCOL *)Context;
DhcpSb = Instance->Service;
Token = Instance->Token;
@@ -1213,7 +1200,7 @@ Dhcp4InstanceConfigUdpIo (
UdpConfigData.DoNotFragment = TRUE;
ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr);
- Ip = HTONL (ClientAddr);
+ Ip = HTONL (ClientAddr);
CopyMem (&UdpConfigData.StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
if (DhcpSb->Netmask == 0) {
@@ -1284,7 +1271,7 @@ Dhcp4InstanceCreateUdpIo (
Status = gBS->OpenProtocol (
Instance->UdpIo->UdpHandle,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Udp4,
+ (VOID **)&Udp4,
Instance->Service->Image,
Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -1293,6 +1280,7 @@ Dhcp4InstanceCreateUdpIo (
UdpIoFreeIo (Instance->UdpIo);
Instance->UdpIo = NULL;
}
+
return Status;
}
}
@@ -1306,7 +1294,7 @@ Dhcp4InstanceCreateUdpIo (
VOID
EFIAPI
DhcpDummyExtFree (
- IN VOID *Arg
+ IN VOID *Arg
)
{
}
@@ -1326,10 +1314,10 @@ DhcpDummyExtFree (
VOID
EFIAPI
PxeDhcpInput (
- NET_BUF *UdpPacket,
- UDP_END_POINT *EndPoint,
- EFI_STATUS IoStatus,
- VOID *Context
+ NET_BUF *UdpPacket,
+ UDP_END_POINT *EndPoint,
+ EFI_STATUS IoStatus,
+ VOID *Context
)
{
DHCP_PROTOCOL *Instance;
@@ -1341,14 +1329,14 @@ PxeDhcpInput (
EFI_STATUS Status;
Wrap = NULL;
- Instance = (DHCP_PROTOCOL *) Context;
+ Instance = (DHCP_PROTOCOL *)Context;
Token = Instance->Token;
//
// Don't restart receive if error occurs or DHCP is destroyed.
//
if (EFI_ERROR (IoStatus)) {
- return ;
+ return;
}
ASSERT (UdpPacket != NULL);
@@ -1370,12 +1358,12 @@ PxeDhcpInput (
goto RESTART;
}
- Packet = (EFI_DHCP4_PACKET *) NetbufAllocSpace (Wrap, Len, NET_BUF_TAIL);
+ Packet = (EFI_DHCP4_PACKET *)NetbufAllocSpace (Wrap, Len, NET_BUF_TAIL);
ASSERT (Packet != NULL);
Packet->Size = Len;
Head = &Packet->Dhcp4.Header;
- Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *) Head);
+ Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *)Head);
if (Packet->Length != UdpPacket->TotalSize) {
goto RESTART;
@@ -1386,7 +1374,8 @@ PxeDhcpInput (
//
if ((Head->OpCode != BOOTP_REPLY) ||
(Head->Xid != Token->Packet->Dhcp4.Header.Xid) ||
- (CompareMem (&Token->Packet->Dhcp4.Header.ClientHwAddr[0], Head->ClientHwAddr, Head->HwAddrLen) != 0)) {
+ (CompareMem (&Token->Packet->Dhcp4.Header.ClientHwAddr[0], Head->ClientHwAddr, Head->HwAddrLen) != 0))
+ {
goto RESTART;
}
@@ -1395,8 +1384,8 @@ PxeDhcpInput (
//
if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) &&
(Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) &&
- EFI_ERROR (DhcpValidateOptions (Packet, NULL))) {
-
+ EFI_ERROR (DhcpValidateOptions (Packet, NULL)))
+ {
goto RESTART;
}
@@ -1437,7 +1426,7 @@ PxeDhcpDone (
Token->ResponseCount = Instance->ResponseQueue.BufNum;
if (Token->ResponseCount != 0) {
- Token->ResponseList = (EFI_DHCP4_PACKET *) AllocatePool (Instance->ResponseQueue.BufSize);
+ Token->ResponseList = (EFI_DHCP4_PACKET *)AllocatePool (Instance->ResponseQueue.BufSize);
if (Token->ResponseList == NULL) {
Token->Status = EFI_OUT_OF_RESOURCES;
goto SIGNAL_USER;
@@ -1446,7 +1435,7 @@ PxeDhcpDone (
//
// Copy the received DHCP responses.
//
- NetbufQueCopy (&Instance->ResponseQueue, 0, Instance->ResponseQueue.BufSize, (UINT8 *) Token->ResponseList);
+ NetbufQueCopy (&Instance->ResponseQueue, 0, Instance->ResponseQueue.BufSize, (UINT8 *)Token->ResponseList);
Token->Status = EFI_SUCCESS;
} else {
Token->ResponseList = NULL;
@@ -1474,7 +1463,6 @@ SIGNAL_USER:
}
}
-
/**
Transmits a DHCP formatted packet and optionally waits for responses.
@@ -1501,16 +1489,16 @@ EfiDhcp4TransmitReceive (
IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token
)
{
- DHCP_PROTOCOL *Instance;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- NET_FRAGMENT Frag;
- NET_BUF *Wrap;
- UDP_END_POINT EndPoint;
- IP4_ADDR Ip;
- DHCP_SERVICE *DhcpSb;
- EFI_IP_ADDRESS Gateway;
- IP4_ADDR ClientAddr;
+ DHCP_PROTOCOL *Instance;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ NET_FRAGMENT Frag;
+ NET_BUF *Wrap;
+ UDP_END_POINT EndPoint;
+ IP4_ADDR Ip;
+ DHCP_SERVICE *DhcpSb;
+ EFI_IP_ADDRESS Gateway;
+ IP4_ADDR ClientAddr;
if ((This == NULL) || (Token == NULL) || (Token->Packet == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -1532,7 +1520,8 @@ EfiDhcp4TransmitReceive (
((Token->ListenPointCount != 0) && (Token->ListenPoints == NULL)) ||
EFI_ERROR (DhcpValidateOptions (Token->Packet, NULL)) ||
EFI_IP4_EQUAL (&Token->RemoteAddress, &mZeroIp4Addr)
- ) {
+ )
+ {
//
// The DHCP packet isn't well-formed, the Transaction ID is already used,
// the timeout value is zero, the ListenPoint is invalid, or the
@@ -1575,7 +1564,7 @@ EfiDhcp4TransmitReceive (
//
// Wrap the DHCP packet into a net buffer.
//
- Frag.Bulk = (UINT8 *) &Token->Packet->Dhcp4;
+ Frag.Bulk = (UINT8 *)&Token->Packet->Dhcp4;
Frag.Len = Token->Packet->Length;
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
if (Wrap == NULL) {
@@ -1667,7 +1656,6 @@ ON_ERROR:
return Status;
}
-
/**
Callback function for DhcpIterateOptions. This callback sets the
EFI_DHCP4_PACKET_OPTION array in the DHCP_PARSE_CONTEXT to point
@@ -1683,15 +1671,15 @@ ON_ERROR:
**/
EFI_STATUS
Dhcp4ParseCheckOption (
- IN UINT8 Tag,
- IN UINT8 Len,
- IN UINT8 *Data,
- IN VOID *Context
+ IN UINT8 Tag,
+ IN UINT8 Len,
+ IN UINT8 *Data,
+ IN VOID *Context
)
{
- DHCP_PARSE_CONTEXT *Parse;
+ DHCP_PARSE_CONTEXT *Parse;
- Parse = (DHCP_PARSE_CONTEXT *) Context;
+ Parse = (DHCP_PARSE_CONTEXT *)Context;
Parse->Index++;
if (Parse->Index <= Parse->OptionCount) {
@@ -1706,7 +1694,6 @@ Dhcp4ParseCheckOption (
return EFI_SUCCESS;
}
-
/**
Parses the packed DHCP option data.
@@ -1737,14 +1724,14 @@ Dhcp4ParseCheckOption (
EFI_STATUS
EFIAPI
EfiDhcp4Parse (
- IN EFI_DHCP4_PROTOCOL *This,
- IN EFI_DHCP4_PACKET *Packet,
- IN OUT UINT32 *OptionCount,
- OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_DHCP4_PACKET *Packet,
+ IN OUT UINT32 *OptionCount,
+ OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL
)
{
- DHCP_PARSE_CONTEXT Context;
- EFI_STATUS Status;
+ DHCP_PARSE_CONTEXT Context;
+ EFI_STATUS Status;
//
// First validate the parameters
@@ -1755,8 +1742,8 @@ EfiDhcp4Parse (
if ((Packet->Size < Packet->Length + 2 * sizeof (UINT32)) ||
(Packet->Dhcp4.Magik != DHCP_OPTION_MAGIC) ||
- EFI_ERROR (DhcpValidateOptions (Packet, NULL))) {
-
+ EFI_ERROR (DhcpValidateOptions (Packet, NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -1770,7 +1757,7 @@ EfiDhcp4Parse (
Context.OptionCount = *OptionCount;
Context.Index = 0;
- Status = DhcpIterateOptions (Packet, Dhcp4ParseCheckOption, &Context);
+ Status = DhcpIterateOptions (Packet, Dhcp4ParseCheckOption, &Context);
if (EFI_ERROR (Status)) {
return Status;
@@ -1794,9 +1781,9 @@ EfiDhcp4Parse (
**/
VOID
SetElapsedTime (
- IN UINT16 *Elapsed,
- IN DHCP_PROTOCOL *Instance
+ IN UINT16 *Elapsed,
+ IN DHCP_PROTOCOL *Instance
)
{
- WriteUnaligned16 (Elapsed, HTONS(Instance->ElaspedTime));
+ WriteUnaligned16 (Elapsed, HTONS (Instance->ElaspedTime));
}
diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Impl.h b/NetworkPkg/Dhcp4Dxe/Dhcp4Impl.h
index 8c2cd3d..7e5409d 100644
--- a/NetworkPkg/Dhcp4Dxe/Dhcp4Impl.h
+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Impl.h
@@ -14,8 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __EFI_DHCP4_IMPL_H__
#define __EFI_DHCP4_IMPL_H__
-
-
#include <Uefi.h>
#include <Protocol/Dhcp4.h>
@@ -28,8 +26,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseLib.h>
#include <Library/NetLib.h>
-typedef struct _DHCP_SERVICE DHCP_SERVICE;
-typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
+typedef struct _DHCP_SERVICE DHCP_SERVICE;
+typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
#include "Dhcp4Option.h"
#include "Dhcp4Io.h"
@@ -37,7 +35,7 @@ typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
#define DHCP_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', 'C', 'P')
#define DHCP_PROTOCOL_SIGNATURE SIGNATURE_32 ('d', 'h', 'c', 'p')
-#define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
+#define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
//
// The state of the DHCP service. It starts as UNCONFIGED. If
@@ -46,28 +44,27 @@ typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
// goes back to UNCONFIGED. It becomes DESTROY if it is (partly)
// destroyed.
//
-#define DHCP_UNCONFIGED 0
-#define DHCP_CONFIGED 1
-#define DHCP_DESTROY 2
-
+#define DHCP_UNCONFIGED 0
+#define DHCP_CONFIGED 1
+#define DHCP_DESTROY 2
struct _DHCP_PROTOCOL {
- UINT32 Signature;
- EFI_DHCP4_PROTOCOL Dhcp4Protocol;
- LIST_ENTRY Link;
- EFI_HANDLE Handle;
- DHCP_SERVICE *Service;
-
- BOOLEAN InDestroy;
-
- EFI_EVENT CompletionEvent;
- EFI_EVENT RenewRebindEvent;
-
- EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;
- UDP_IO *UdpIo; // The UDP IO used for TransmitReceive.
- UINT32 Timeout;
- UINT16 ElaspedTime;
- NET_BUF_QUEUE ResponseQueue;
+ UINT32 Signature;
+ EFI_DHCP4_PROTOCOL Dhcp4Protocol;
+ LIST_ENTRY Link;
+ EFI_HANDLE Handle;
+ DHCP_SERVICE *Service;
+
+ BOOLEAN InDestroy;
+
+ EFI_EVENT CompletionEvent;
+ EFI_EVENT RenewRebindEvent;
+
+ EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;
+ UDP_IO *UdpIo; // The UDP IO used for TransmitReceive.
+ UINT32 Timeout;
+ UINT16 ElaspedTime;
+ NET_BUF_QUEUE ResponseQueue;
};
//
@@ -75,62 +72,62 @@ struct _DHCP_PROTOCOL {
// has a service binding, there can be only one active child.
//
struct _DHCP_SERVICE {
- UINT32 Signature;
- EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
+ UINT32 Signature;
+ EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
- INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTROY
+ INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTROY
- EFI_HANDLE Controller;
- EFI_HANDLE Image;
+ EFI_HANDLE Controller;
+ EFI_HANDLE Image;
- LIST_ENTRY Children;
- UINTN NumChildren;
+ LIST_ENTRY Children;
+ UINTN NumChildren;
- INTN DhcpState;
- EFI_STATUS IoStatus; // the result of last user operation
- UINT32 Xid;
+ INTN DhcpState;
+ EFI_STATUS IoStatus; // the result of last user operation
+ UINT32 Xid;
- IP4_ADDR ClientAddr; // lease IP or configured client address
- IP4_ADDR Netmask;
- IP4_ADDR ServerAddr;
+ IP4_ADDR ClientAddr; // lease IP or configured client address
+ IP4_ADDR Netmask;
+ IP4_ADDR ServerAddr;
- EFI_DHCP4_PACKET *LastOffer; // The last received offer
- EFI_DHCP4_PACKET *Selected;
- DHCP_PARAMETER *Para;
+ EFI_DHCP4_PACKET *LastOffer; // The last received offer
+ EFI_DHCP4_PACKET *Selected;
+ DHCP_PARAMETER *Para;
- UINT32 Lease;
- UINT32 T1;
- UINT32 T2;
- INTN ExtraRefresh; // This refresh is reqested by user
+ UINT32 Lease;
+ UINT32 T1;
+ UINT32 T2;
+ INTN ExtraRefresh; // This refresh is reqested by user
- UDP_IO *UdpIo; // Udp child receiving all DHCP message
- UDP_IO *LeaseIoPort; // Udp child with lease IP
- EFI_DHCP4_PACKET *LastPacket; // The last sent packet for retransmission
- EFI_MAC_ADDRESS Mac;
- UINT8 HwType;
- UINT8 HwLen;
- UINT8 ClientAddressSendOut[16];
+ UDP_IO *UdpIo; // Udp child receiving all DHCP message
+ UDP_IO *LeaseIoPort; // Udp child with lease IP
+ EFI_DHCP4_PACKET *LastPacket; // The last sent packet for retransmission
+ EFI_MAC_ADDRESS Mac;
+ UINT8 HwType;
+ UINT8 HwLen;
+ UINT8 ClientAddressSendOut[16];
- DHCP_PROTOCOL *ActiveChild;
- EFI_DHCP4_CONFIG_DATA ActiveConfig;
- UINT32 UserOptionLen;
+ DHCP_PROTOCOL *ActiveChild;
+ EFI_DHCP4_CONFIG_DATA ActiveConfig;
+ UINT32 UserOptionLen;
//
// Timer event and various timer
//
- EFI_EVENT Timer;
+ EFI_EVENT Timer;
- UINT32 PacketToLive; // Retransmission timer for our packets
- UINT32 LastTimeout; // Record the init value of PacketToLive every time
- INTN CurRetry;
- INTN MaxRetries;
- UINT32 LeaseLife;
+ UINT32 PacketToLive; // Retransmission timer for our packets
+ UINT32 LastTimeout; // Record the init value of PacketToLive every time
+ INTN CurRetry;
+ INTN MaxRetries;
+ UINT32 LeaseLife;
};
typedef struct {
- EFI_DHCP4_PACKET_OPTION **Option;
- UINT32 OptionCount;
- UINT32 Index;
+ EFI_DHCP4_PACKET_OPTION **Option;
+ UINT32 OptionCount;
+ UINT32 Index;
} DHCP_PARSE_CONTEXT;
#define DHCP_INSTANCE_FROM_THIS(Proto) \
@@ -139,7 +136,7 @@ typedef struct {
#define DHCP_SERVICE_FROM_THIS(Sb) \
CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)
-extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;
+extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;
/**
Give up the control of the DHCP service to let other child
@@ -151,7 +148,7 @@ extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;
**/
VOID
DhcpYieldControl (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
);
/**
@@ -187,7 +184,7 @@ DhcpCleanConfigure (
VOID
EFIAPI
DhcpDummyExtFree (
- IN VOID *Arg
+ IN VOID *Arg
);
/**
@@ -199,8 +196,8 @@ DhcpDummyExtFree (
**/
VOID
SetElapsedTime (
- IN UINT16 *Elapsed,
- IN DHCP_PROTOCOL *Instance
+ IN UINT16 *Elapsed,
+ IN DHCP_PROTOCOL *Instance
);
#endif
diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Io.c b/NetworkPkg/Dhcp4Dxe/Dhcp4Io.c
index f073eed..238e186 100644
--- a/NetworkPkg/Dhcp4Dxe/Dhcp4Io.c
+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Io.c
@@ -6,12 +6,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Dhcp4Impl.h"
UINT32 mDhcp4DefaultTimeout[4] = { 4, 8, 16, 32 };
-
/**
Send an initial DISCOVER or REQUEST message according to the
DHCP service's current state.
@@ -24,17 +22,17 @@ UINT32 mDhcp4DefaultTimeout[4] = { 4, 8, 16, 32 };
**/
EFI_STATUS
DhcpInitRequest (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT ((DhcpSb->DhcpState == Dhcp4Init) || (DhcpSb->DhcpState == Dhcp4InitReboot));
//
// Clear initial time to make sure that elapsed-time is set to 0 for first Discover or REQUEST message.
//
- DhcpSb->ActiveChild->ElaspedTime= 0;
+ DhcpSb->ActiveChild->ElaspedTime = 0;
if (DhcpSb->DhcpState == Dhcp4Init) {
DhcpSetState (DhcpSb, Dhcp4Selecting, FALSE);
@@ -57,7 +55,6 @@ DhcpInitRequest (
return EFI_SUCCESS;
}
-
/**
Call user provided callback function, and return the value the
function returns. If the user doesn't provide a callback, a
@@ -76,14 +73,14 @@ DhcpInitRequest (
**/
EFI_STATUS
DhcpCallUser (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_DHCP4_EVENT Event,
- IN EFI_DHCP4_PACKET *Packet OPTIONAL,
- OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
+ IN DHCP_SERVICE *DhcpSb,
+ IN EFI_DHCP4_EVENT Event,
+ IN EFI_DHCP4_PACKET *Packet OPTIONAL,
+ OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
)
{
- EFI_DHCP4_CONFIG_DATA *Config;
- EFI_STATUS Status;
+ EFI_DHCP4_CONFIG_DATA *Config;
+ EFI_STATUS Status;
if (NewPacket != NULL) {
*NewPacket = NULL;
@@ -109,7 +106,7 @@ DhcpCallUser (
Status = Config->Dhcp4Callback (
&DhcpSb->ActiveChild->Dhcp4Protocol,
Config->CallbackContext,
- (EFI_DHCP4_STATE) DhcpSb->DhcpState,
+ (EFI_DHCP4_STATE)DhcpSb->DhcpState,
Event,
Packet,
NewPacket
@@ -127,7 +124,6 @@ DhcpCallUser (
return EFI_ABORTED;
}
-
/**
Notify the user about the operation result.
@@ -137,35 +133,33 @@ DhcpCallUser (
**/
VOID
DhcpNotifyUser (
- IN DHCP_SERVICE *DhcpSb,
- IN INTN Which
+ IN DHCP_SERVICE *DhcpSb,
+ IN INTN Which
)
{
- DHCP_PROTOCOL *Child;
+ DHCP_PROTOCOL *Child;
if ((Child = DhcpSb->ActiveChild) == NULL) {
- return ;
+ return;
}
if ((Child->CompletionEvent != NULL) &&
((Which == DHCP_NOTIFY_COMPLETION) || (Which == DHCP_NOTIFY_ALL))
- ) {
-
+ )
+ {
gBS->SignalEvent (Child->CompletionEvent);
Child->CompletionEvent = NULL;
}
if ((Child->RenewRebindEvent != NULL) &&
((Which == DHCP_NOTIFY_RENEWREBIND) || (Which == DHCP_NOTIFY_ALL))
- ) {
-
+ )
+ {
gBS->SignalEvent (Child->RenewRebindEvent);
Child->RenewRebindEvent = NULL;
}
}
-
-
/**
Set the DHCP state. If CallUser is true, it will try to notify
the user before change the state by DhcpNotifyUser. It returns
@@ -183,25 +177,22 @@ DhcpNotifyUser (
**/
EFI_STATUS
DhcpSetState (
- IN OUT DHCP_SERVICE *DhcpSb,
- IN INTN State,
- IN BOOLEAN CallUser
+ IN OUT DHCP_SERVICE *DhcpSb,
+ IN INTN State,
+ IN BOOLEAN CallUser
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (CallUser) {
Status = EFI_SUCCESS;
if (State == Dhcp4Renewing) {
Status = DhcpCallUser (DhcpSb, Dhcp4EnterRenewing, NULL, NULL);
-
} else if (State == Dhcp4Rebinding) {
Status = DhcpCallUser (DhcpSb, Dhcp4EnterRebinding, NULL, NULL);
-
} else if (State == Dhcp4Bound) {
Status = DhcpCallUser (DhcpSb, Dhcp4BoundCompleted, NULL, NULL);
-
}
if (EFI_ERROR (Status)) {
@@ -224,14 +215,13 @@ DhcpSetState (
DhcpSb->MaxRetries = 4;
}
- DhcpSb->CurRetry = 0;
- DhcpSb->PacketToLive = 0;
- DhcpSb->LastTimeout = 0;
- DhcpSb->DhcpState = State;
+ DhcpSb->CurRetry = 0;
+ DhcpSb->PacketToLive = 0;
+ DhcpSb->LastTimeout = 0;
+ DhcpSb->DhcpState = State;
return EFI_SUCCESS;
}
-
/**
Set the retransmit timer for the packet. It will select from either
the discover timeouts/request timeouts or the default timeout values.
@@ -241,10 +231,10 @@ DhcpSetState (
**/
VOID
DhcpSetTransmitTimer (
- IN OUT DHCP_SERVICE *DhcpSb
+ IN OUT DHCP_SERVICE *DhcpSb
)
{
- UINT32 *Times;
+ UINT32 *Times;
ASSERT (DhcpSb->MaxRetries > DhcpSb->CurRetry);
@@ -275,8 +265,8 @@ DhcpSetTransmitTimer (
**/
VOID
DhcpComputeLease (
- IN OUT DHCP_SERVICE *DhcpSb,
- IN DHCP_PARAMETER *Para
+ IN OUT DHCP_SERVICE *DhcpSb,
+ IN DHCP_PARAMETER *Para
)
{
ASSERT (Para != NULL);
@@ -298,7 +288,6 @@ DhcpComputeLease (
}
}
-
/**
Configure a UDP IO port to use the acquired lease address.
DHCP driver needs this port to unicast packet to the server
@@ -314,32 +303,32 @@ DhcpComputeLease (
EFI_STATUS
EFIAPI
DhcpConfigLeaseIoPort (
- IN UDP_IO *UdpIo,
- IN VOID *Context
+ IN UDP_IO *UdpIo,
+ IN VOID *Context
)
{
- EFI_UDP4_CONFIG_DATA UdpConfigData;
- EFI_IPv4_ADDRESS Subnet;
- EFI_IPv4_ADDRESS Gateway;
- DHCP_SERVICE *DhcpSb;
- EFI_STATUS Status;
- IP4_ADDR Ip;
-
- DhcpSb = (DHCP_SERVICE *) Context;
-
- UdpConfigData.AcceptBroadcast = FALSE;
- UdpConfigData.AcceptPromiscuous = FALSE;
- UdpConfigData.AcceptAnyPort = FALSE;
- UdpConfigData.AllowDuplicatePort = TRUE;
- UdpConfigData.TypeOfService = 0;
- UdpConfigData.TimeToLive = 64;
- UdpConfigData.DoNotFragment = FALSE;
- UdpConfigData.ReceiveTimeout = 1;
- UdpConfigData.TransmitTimeout = 0;
-
- UdpConfigData.UseDefaultAddress = FALSE;
- UdpConfigData.StationPort = DHCP_CLIENT_PORT;
- UdpConfigData.RemotePort = DHCP_SERVER_PORT;
+ EFI_UDP4_CONFIG_DATA UdpConfigData;
+ EFI_IPv4_ADDRESS Subnet;
+ EFI_IPv4_ADDRESS Gateway;
+ DHCP_SERVICE *DhcpSb;
+ EFI_STATUS Status;
+ IP4_ADDR Ip;
+
+ DhcpSb = (DHCP_SERVICE *)Context;
+
+ UdpConfigData.AcceptBroadcast = FALSE;
+ UdpConfigData.AcceptPromiscuous = FALSE;
+ UdpConfigData.AcceptAnyPort = FALSE;
+ UdpConfigData.AllowDuplicatePort = TRUE;
+ UdpConfigData.TypeOfService = 0;
+ UdpConfigData.TimeToLive = 64;
+ UdpConfigData.DoNotFragment = FALSE;
+ UdpConfigData.ReceiveTimeout = 1;
+ UdpConfigData.TransmitTimeout = 0;
+
+ UdpConfigData.UseDefaultAddress = FALSE;
+ UdpConfigData.StationPort = DHCP_CLIENT_PORT;
+ UdpConfigData.RemotePort = DHCP_SERVER_PORT;
Ip = HTONL (DhcpSb->ClientAddr);
CopyMem (&UdpConfigData.StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
@@ -370,7 +359,6 @@ DhcpConfigLeaseIoPort (
return EFI_SUCCESS;
}
-
/**
Update the lease states when a new lease is acquired. It will not only
save the acquired the address and lease time, it will also create a UDP
@@ -384,14 +372,14 @@ DhcpConfigLeaseIoPort (
**/
EFI_STATUS
DhcpLeaseAcquired (
- IN OUT DHCP_SERVICE *DhcpSb
+ IN OUT DHCP_SERVICE *DhcpSb
)
{
DhcpSb->ClientAddr = EFI_NTOHL (DhcpSb->Selected->Dhcp4.Header.YourAddr);
if (DhcpSb->Para != NULL) {
- DhcpSb->Netmask = DhcpSb->Para->NetMask;
- DhcpSb->ServerAddr = DhcpSb->Para->ServerId;
+ DhcpSb->Netmask = DhcpSb->Para->NetMask;
+ DhcpSb->ServerAddr = DhcpSb->Para->ServerId;
}
if (DhcpSb->Netmask == 0) {
@@ -426,7 +414,6 @@ DhcpLeaseAcquired (
return DhcpSetState (DhcpSb, Dhcp4Bound, TRUE);
}
-
/**
Clean up the DHCP related states, IoStatus isn't reset.
@@ -435,14 +422,14 @@ DhcpLeaseAcquired (
**/
VOID
DhcpCleanLease (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
)
{
- DhcpSb->DhcpState = Dhcp4Init;
- DhcpSb->Xid = DhcpSb->Xid + 1;
- DhcpSb->ClientAddr = 0;
- DhcpSb->Netmask = 0;
- DhcpSb->ServerAddr = 0;
+ DhcpSb->DhcpState = Dhcp4Init;
+ DhcpSb->Xid = DhcpSb->Xid + 1;
+ DhcpSb->ClientAddr = 0;
+ DhcpSb->Netmask = 0;
+ DhcpSb->ServerAddr = 0;
if (DhcpSb->LastOffer != NULL) {
FreePool (DhcpSb->LastOffer);
@@ -459,10 +446,10 @@ DhcpCleanLease (
DhcpSb->Para = NULL;
}
- DhcpSb->Lease = 0;
- DhcpSb->T1 = 0;
- DhcpSb->T2 = 0;
- DhcpSb->ExtraRefresh = FALSE;
+ DhcpSb->Lease = 0;
+ DhcpSb->T1 = 0;
+ DhcpSb->T2 = 0;
+ DhcpSb->ExtraRefresh = FALSE;
if (DhcpSb->LeaseIoPort != NULL) {
UdpIoFreeIo (DhcpSb->LeaseIoPort);
@@ -474,11 +461,11 @@ DhcpCleanLease (
DhcpSb->LastPacket = NULL;
}
- DhcpSb->PacketToLive = 0;
- DhcpSb->LastTimeout = 0;
- DhcpSb->CurRetry = 0;
- DhcpSb->MaxRetries = 0;
- DhcpSb->LeaseLife = 0;
+ DhcpSb->PacketToLive = 0;
+ DhcpSb->LastTimeout = 0;
+ DhcpSb->CurRetry = 0;
+ DhcpSb->MaxRetries = 0;
+ DhcpSb->LeaseLife = 0;
//
// Clean active config data.
@@ -486,7 +473,6 @@ DhcpCleanLease (
DhcpCleanConfigure (&DhcpSb->ActiveConfig);
}
-
/**
Select a offer among all the offers collected. If the offer selected is
of BOOTP, the lease is recorded and user notified. If the offer is of
@@ -499,13 +485,13 @@ DhcpCleanLease (
**/
EFI_STATUS
DhcpChooseOffer (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
)
{
- EFI_DHCP4_PACKET *Selected;
- EFI_DHCP4_PACKET *NewPacket;
- EFI_DHCP4_PACKET *TempPacket;
- EFI_STATUS Status;
+ EFI_DHCP4_PACKET *Selected;
+ EFI_DHCP4_PACKET *NewPacket;
+ EFI_DHCP4_PACKET *TempPacket;
+ EFI_STATUS Status;
ASSERT (DhcpSb->LastOffer != NULL);
@@ -524,7 +510,7 @@ DhcpChooseOffer (
Selected = DhcpSb->LastOffer;
if ((NewPacket != NULL) && !EFI_ERROR (DhcpValidateOptions (NewPacket, NULL))) {
- TempPacket = (EFI_DHCP4_PACKET *) AllocatePool (NewPacket->Size);
+ TempPacket = (EFI_DHCP4_PACKET *)AllocatePool (NewPacket->Size);
if (TempPacket != NULL) {
CopyMem (TempPacket, NewPacket, NewPacket->Size);
FreePool (Selected);
@@ -565,7 +551,6 @@ DhcpChooseOffer (
return DhcpSendMessage (DhcpSb, Selected, DhcpSb->Para, DHCP_MSG_REQUEST, NULL);
}
-
/**
Terminate the current address acquire. All the allocated resources
are released. Be careful when calling this function. A rule related
@@ -578,8 +563,8 @@ DhcpChooseOffer (
**/
VOID
DhcpEndSession (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_STATUS Status
+ IN DHCP_SERVICE *DhcpSb,
+ IN EFI_STATUS Status
)
{
if (DHCP_CONNECTED (DhcpSb->DhcpState)) {
@@ -594,7 +579,6 @@ DhcpEndSession (
DhcpNotifyUser (DhcpSb, DHCP_NOTIFY_ALL);
}
-
/**
Handle packets in DHCP select state.
@@ -609,12 +593,12 @@ DhcpEndSession (
**/
EFI_STATUS
DhcpHandleSelect (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_DHCP4_PACKET *Packet,
- IN DHCP_PARAMETER *Para
+ IN DHCP_SERVICE *DhcpSb,
+ IN EFI_DHCP4_PACKET *Packet,
+ IN DHCP_PARAMETER *Para
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
@@ -626,7 +610,8 @@ DhcpHandleSelect (
//
if (!DHCP_IS_BOOTP (Para) &&
((Para->DhcpType != DHCP_MSG_OFFER) || (Para->ServerId == 0))
- ) {
+ )
+ {
goto ON_EXIT;
}
@@ -646,14 +631,12 @@ DhcpHandleSelect (
DhcpSb->LastOffer = Packet;
return DhcpChooseOffer (DhcpSb);
-
} else if (Status == EFI_NOT_READY) {
if (DhcpSb->LastOffer != NULL) {
FreePool (DhcpSb->LastOffer);
}
DhcpSb->LastOffer = Packet;
-
} else if (Status == EFI_ABORTED) {
//
// DhcpInput will end the session upon error return. Remember
@@ -669,7 +652,6 @@ ON_EXIT:
return Status;
}
-
/**
Handle packets in DHCP request state.
@@ -684,20 +666,20 @@ ON_EXIT:
**/
EFI_STATUS
DhcpHandleRequest (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_DHCP4_PACKET *Packet,
- IN DHCP_PARAMETER *Para
+ IN DHCP_SERVICE *DhcpSb,
+ IN EFI_DHCP4_PACKET *Packet,
+ IN DHCP_PARAMETER *Para
)
{
- EFI_DHCP4_HEADER *Head;
- EFI_DHCP4_HEADER *Selected;
- EFI_STATUS Status;
- UINT8 *Message;
+ EFI_DHCP4_HEADER *Head;
+ EFI_DHCP4_HEADER *Selected;
+ EFI_STATUS Status;
+ UINT8 *Message;
ASSERT (!DHCP_IS_BOOTP (DhcpSb->Para));
- Head = &Packet->Dhcp4.Header;
- Selected = &DhcpSb->Selected->Dhcp4.Header;
+ Head = &Packet->Dhcp4.Header;
+ Selected = &DhcpSb->Selected->Dhcp4.Header;
//
// Ignore the BOOTP message and DHCP messages other than DHCP ACK/NACK.
@@ -705,8 +687,8 @@ DhcpHandleRequest (
if (DHCP_IS_BOOTP (Para) ||
(Para->ServerId != DhcpSb->Para->ServerId) ||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
- ) {
-
+ )
+ {
Status = EFI_SUCCESS;
goto ON_EXIT;
}
@@ -727,14 +709,14 @@ DhcpHandleRequest (
Message = NULL;
if (!EFI_IP4_EQUAL (&Head->YourAddr, &Selected->YourAddr)) {
- Message = (UINT8 *) "Lease confirmed isn't the same as that in the offer";
+ Message = (UINT8 *)"Lease confirmed isn't the same as that in the offer";
goto REJECT;
}
Status = DhcpCallUser (DhcpSb, Dhcp4RcvdAck, Packet, NULL);
if (EFI_ERROR (Status)) {
- Message = (UINT8 *) "Lease is denied upon received ACK";
+ Message = (UINT8 *)"Lease is denied upon received ACK";
goto REJECT;
}
@@ -744,7 +726,7 @@ DhcpHandleRequest (
Status = DhcpLeaseAcquired (DhcpSb);
if (EFI_ERROR (Status)) {
- Message = (UINT8 *) "Lease is denied upon entering bound";
+ Message = (UINT8 *)"Lease is denied upon entering bound";
goto REJECT;
}
@@ -762,7 +744,6 @@ ON_EXIT:
return Status;
}
-
/**
Handle packets in DHCP renew/rebound state.
@@ -777,19 +758,19 @@ ON_EXIT:
**/
EFI_STATUS
DhcpHandleRenewRebind (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_DHCP4_PACKET *Packet,
- IN DHCP_PARAMETER *Para
+ IN DHCP_SERVICE *DhcpSb,
+ IN EFI_DHCP4_PACKET *Packet,
+ IN DHCP_PARAMETER *Para
)
{
- EFI_DHCP4_HEADER *Head;
- EFI_DHCP4_HEADER *Selected;
- EFI_STATUS Status;
+ EFI_DHCP4_HEADER *Head;
+ EFI_DHCP4_HEADER *Selected;
+ EFI_STATUS Status;
ASSERT (!DHCP_IS_BOOTP (DhcpSb->Para));
- Head = &Packet->Dhcp4.Header;
- Selected = &DhcpSb->Selected->Dhcp4.Header;
+ Head = &Packet->Dhcp4.Header;
+ Selected = &DhcpSb->Selected->Dhcp4.Header;
//
// Ignore the BOOTP message and DHCP messages other than DHCP ACK/NACK
@@ -797,8 +778,8 @@ DhcpHandleRenewRebind (
if (DHCP_IS_BOOTP (Para) ||
(Para->ServerId != DhcpSb->Para->ServerId) ||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
- ) {
-
+ )
+ {
Status = EFI_SUCCESS;
goto ON_EXIT;
}
@@ -835,9 +816,9 @@ DhcpHandleRenewRebind (
DhcpSetState (DhcpSb, Dhcp4Bound, TRUE);
if (DhcpSb->ExtraRefresh != 0) {
- DhcpSb->ExtraRefresh = FALSE;
+ DhcpSb->ExtraRefresh = FALSE;
- DhcpSb->IoStatus = EFI_SUCCESS;
+ DhcpSb->IoStatus = EFI_SUCCESS;
DhcpNotifyUser (DhcpSb, DHCP_NOTIFY_RENEWREBIND);
}
@@ -846,7 +827,6 @@ ON_EXIT:
return Status;
}
-
/**
Handle packets in DHCP reboot state.
@@ -861,13 +841,13 @@ ON_EXIT:
**/
EFI_STATUS
DhcpHandleReboot (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_DHCP4_PACKET *Packet,
- IN DHCP_PARAMETER *Para
+ IN DHCP_SERVICE *DhcpSb,
+ IN EFI_DHCP4_PACKET *Packet,
+ IN DHCP_PARAMETER *Para
)
{
- EFI_DHCP4_HEADER *Head;
- EFI_STATUS Status;
+ EFI_DHCP4_HEADER *Head;
+ EFI_STATUS Status;
Head = &Packet->Dhcp4.Header;
@@ -876,8 +856,8 @@ DhcpHandleReboot (
//
if (DHCP_IS_BOOTP (Para) ||
((Para->DhcpType != DHCP_MSG_ACK) && (Para->DhcpType != DHCP_MSG_NAK))
- ) {
-
+ )
+ {
Status = EFI_SUCCESS;
goto ON_EXIT;
}
@@ -888,10 +868,10 @@ DhcpHandleReboot (
if (Para->DhcpType == DHCP_MSG_NAK) {
DhcpCallUser (DhcpSb, Dhcp4RcvdNak, Packet, NULL);
- DhcpSb->ClientAddr = 0;
- DhcpSb->DhcpState = Dhcp4Init;
+ DhcpSb->ClientAddr = 0;
+ DhcpSb->DhcpState = Dhcp4Init;
- Status = DhcpInitRequest (DhcpSb);
+ Status = DhcpInitRequest (DhcpSb);
goto ON_EXIT;
}
@@ -917,8 +897,8 @@ DhcpHandleReboot (
goto ON_EXIT;
}
- DhcpSb->Selected = Packet;
- Status = DhcpLeaseAcquired (DhcpSb);
+ DhcpSb->Selected = Packet;
+ Status = DhcpLeaseAcquired (DhcpSb);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -932,7 +912,6 @@ ON_EXIT:
return Status;
}
-
/**
Handle the received DHCP packets. This function drives the DHCP
state machine.
@@ -946,30 +925,30 @@ ON_EXIT:
VOID
EFIAPI
DhcpInput (
- NET_BUF *UdpPacket,
- UDP_END_POINT *EndPoint,
- EFI_STATUS IoStatus,
- VOID *Context
+ NET_BUF *UdpPacket,
+ UDP_END_POINT *EndPoint,
+ EFI_STATUS IoStatus,
+ VOID *Context
)
{
- DHCP_SERVICE *DhcpSb;
- EFI_DHCP4_HEADER *Head;
- EFI_DHCP4_PACKET *Packet;
- DHCP_PARAMETER *Para;
- EFI_STATUS Status;
- UINT32 Len;
+ DHCP_SERVICE *DhcpSb;
+ EFI_DHCP4_HEADER *Head;
+ EFI_DHCP4_PACKET *Packet;
+ DHCP_PARAMETER *Para;
+ EFI_STATUS Status;
+ UINT32 Len;
- Packet = NULL;
- DhcpSb = (DHCP_SERVICE *) Context;
+ Packet = NULL;
+ DhcpSb = (DHCP_SERVICE *)Context;
//
// Don't restart receive if error occurs or DHCP is destroyed.
//
if (EFI_ERROR (IoStatus)) {
- return ;
+ return;
} else if (DhcpSb->ServiceState == DHCP_DESTROY) {
NetbufFree (UdpPacket);
- return ;
+ return;
}
ASSERT (UdpPacket != NULL);
@@ -988,16 +967,16 @@ DhcpInput (
//
// Copy the DHCP message to a continuous memory block
//
- Len = sizeof (EFI_DHCP4_PACKET) + UdpPacket->TotalSize - sizeof (EFI_DHCP4_HEADER);
- Packet = (EFI_DHCP4_PACKET *) AllocatePool (Len);
+ Len = sizeof (EFI_DHCP4_PACKET) + UdpPacket->TotalSize - sizeof (EFI_DHCP4_HEADER);
+ Packet = (EFI_DHCP4_PACKET *)AllocatePool (Len);
if (Packet == NULL) {
goto RESTART;
}
- Packet->Size = Len;
- Head = &Packet->Dhcp4.Header;
- Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *) Head);
+ Packet->Size = Len;
+ Head = &Packet->Dhcp4.Header;
+ Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *)Head);
if (Packet->Length != UdpPacket->TotalSize) {
goto RESTART;
@@ -1008,7 +987,8 @@ DhcpInput (
//
if ((Head->OpCode != BOOTP_REPLY) ||
(NTOHL (Head->Xid) != DhcpSb->Xid) ||
- (CompareMem (DhcpSb->ClientAddressSendOut, Head->ClientHwAddr, Head->HwAddrLen) != 0)) {
+ (CompareMem (DhcpSb->ClientAddressSendOut, Head->ClientHwAddr, Head->HwAddrLen) != 0))
+ {
goto RESTART;
}
@@ -1018,8 +998,8 @@ DhcpInput (
Para = NULL;
if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) &&
(Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) &&
- EFI_ERROR (DhcpValidateOptions (Packet, &Para))) {
-
+ EFI_ERROR (DhcpValidateOptions (Packet, &Para)))
+ {
goto RESTART;
}
@@ -1035,32 +1015,32 @@ DhcpInput (
Status = EFI_SUCCESS;
switch (DhcpSb->DhcpState) {
- case Dhcp4Selecting:
- Status = DhcpHandleSelect (DhcpSb, Packet, Para);
- break;
+ case Dhcp4Selecting:
+ Status = DhcpHandleSelect (DhcpSb, Packet, Para);
+ break;
- case Dhcp4Requesting:
- Status = DhcpHandleRequest (DhcpSb, Packet, Para);
- break;
+ case Dhcp4Requesting:
+ Status = DhcpHandleRequest (DhcpSb, Packet, Para);
+ break;
- case Dhcp4InitReboot:
- case Dhcp4Init:
- case Dhcp4Bound:
- //
- // Ignore the packet in INITREBOOT, INIT and BOUND states
- //
- FreePool (Packet);
- Status = EFI_SUCCESS;
- break;
+ case Dhcp4InitReboot:
+ case Dhcp4Init:
+ case Dhcp4Bound:
+ //
+ // Ignore the packet in INITREBOOT, INIT and BOUND states
+ //
+ FreePool (Packet);
+ Status = EFI_SUCCESS;
+ break;
- case Dhcp4Renewing:
- case Dhcp4Rebinding:
- Status = DhcpHandleRenewRebind (DhcpSb, Packet, Para);
- break;
+ case Dhcp4Renewing:
+ case Dhcp4Rebinding:
+ Status = DhcpHandleRenewRebind (DhcpSb, Packet, Para);
+ break;
- case Dhcp4Rebooting:
- Status = DhcpHandleReboot (DhcpSb, Packet, Para);
- break;
+ case Dhcp4Rebooting:
+ Status = DhcpHandleReboot (DhcpSb, Packet, Para);
+ break;
}
if (Para != NULL) {
@@ -1073,7 +1053,7 @@ DhcpInput (
NetbufFree (UdpPacket);
UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0);
DhcpEndSession (DhcpSb, Status);
- return ;
+ return;
}
RESTART:
@@ -1102,17 +1082,15 @@ RESTART:
VOID
EFIAPI
DhcpOnPacketSent (
- NET_BUF *Packet,
- UDP_END_POINT *EndPoint,
- EFI_STATUS IoStatus,
- VOID *Context
+ NET_BUF *Packet,
+ UDP_END_POINT *EndPoint,
+ EFI_STATUS IoStatus,
+ VOID *Context
)
{
NetbufFree (Packet);
}
-
-
/**
Build and transmit a DHCP message according to the current states.
This function implement the Table 5. of RFC 2131. Always transits
@@ -1134,28 +1112,28 @@ DhcpOnPacketSent (
**/
EFI_STATUS
DhcpSendMessage (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_DHCP4_PACKET *Seed,
- IN DHCP_PARAMETER *Para,
- IN UINT8 Type,
- IN UINT8 *Msg
+ IN DHCP_SERVICE *DhcpSb,
+ IN EFI_DHCP4_PACKET *Seed,
+ IN DHCP_PARAMETER *Para,
+ IN UINT8 Type,
+ IN UINT8 *Msg
)
{
- EFI_DHCP4_CONFIG_DATA *Config;
- EFI_DHCP4_PACKET *Packet;
- EFI_DHCP4_PACKET *NewPacket;
- EFI_DHCP4_HEADER *Head;
- EFI_DHCP4_HEADER *SeedHead;
- UDP_IO *UdpIo;
- UDP_END_POINT EndPoint;
- NET_BUF *Wrap;
- NET_FRAGMENT Frag;
- EFI_STATUS Status;
- IP4_ADDR IpAddr;
- UINT8 *Buf;
- UINT16 MaxMsg;
- UINT32 Len;
- UINT32 Index;
+ EFI_DHCP4_CONFIG_DATA *Config;
+ EFI_DHCP4_PACKET *Packet;
+ EFI_DHCP4_PACKET *NewPacket;
+ EFI_DHCP4_HEADER *Head;
+ EFI_DHCP4_HEADER *SeedHead;
+ UDP_IO *UdpIo;
+ UDP_END_POINT EndPoint;
+ NET_BUF *Wrap;
+ NET_FRAGMENT Frag;
+ EFI_STATUS Status;
+ IP4_ADDR IpAddr;
+ UINT8 *Buf;
+ UINT16 MaxMsg;
+ UINT32 Len;
+ UINT32 Index;
//
// Allocate a big enough memory block to hold the DHCP packet
@@ -1163,7 +1141,7 @@ DhcpSendMessage (
Len = sizeof (EFI_DHCP4_PACKET) + 128 + DhcpSb->UserOptionLen;
if (Msg != NULL) {
- Len += (UINT32)AsciiStrLen ((CHAR8 *) Msg);
+ Len += (UINT32)AsciiStrLen ((CHAR8 *)Msg);
}
Packet = AllocatePool (Len);
@@ -1172,14 +1150,14 @@ DhcpSendMessage (
return EFI_OUT_OF_RESOURCES;
}
- Packet->Size = Len;
- Packet->Length = sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32);
+ Packet->Size = Len;
+ Packet->Length = sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32);
//
// Fill in the DHCP header fields
//
- Config = &DhcpSb->ActiveConfig;
- SeedHead = NULL;
+ Config = &DhcpSb->ActiveConfig;
+ SeedHead = NULL;
if (Seed != NULL) {
SeedHead = &Seed->Dhcp4.Header;
@@ -1188,11 +1166,11 @@ DhcpSendMessage (
Head = &Packet->Dhcp4.Header;
ZeroMem (Head, sizeof (EFI_DHCP4_HEADER));
- Head->OpCode = BOOTP_REQUEST;
- Head->HwType = DhcpSb->HwType;
- Head->HwAddrLen = DhcpSb->HwLen;
- Head->Xid = HTONL (DhcpSb->Xid);
- Head->Reserved = HTONS (0x8000); //Server, broadcast the message please.
+ Head->OpCode = BOOTP_REQUEST;
+ Head->HwType = DhcpSb->HwType;
+ Head->HwAddrLen = DhcpSb->HwLen;
+ Head->Xid = HTONL (DhcpSb->Xid);
+ Head->Reserved = HTONS (0x8000); // Server, broadcast the message please.
EFI_IP4 (Head->ClientAddr) = HTONL (DhcpSb->ClientAddr);
CopyMem (Head->ClientHwAddr, DhcpSb->Mac.Addr, DhcpSb->HwLen);
@@ -1205,7 +1183,7 @@ DhcpSendMessage (
//
Head->Seconds = DhcpSb->LastPacket->Dhcp4.Header.Seconds;
} else {
- SetElapsedTime(&Head->Seconds, DhcpSb->ActiveChild);
+ SetElapsedTime (&Head->Seconds, DhcpSb->ActiveChild);
}
//
@@ -1223,12 +1201,12 @@ DhcpSendMessage (
//
if ((Type == DHCP_MSG_DECLINE) || (Type == DHCP_MSG_RELEASE) ||
((Type == DHCP_MSG_REQUEST) && (DhcpSb->DhcpState == Dhcp4Requesting))
- ) {
-
+ )
+ {
ASSERT ((Para != NULL) && (Para->ServerId != 0));
- IpAddr = HTONL (Para->ServerId);
- Buf = DhcpAppendOption (Buf, DHCP4_TAG_SERVER_ID, 4, (UINT8 *) &IpAddr);
+ IpAddr = HTONL (Para->ServerId);
+ Buf = DhcpAppendOption (Buf, DHCP4_TAG_SERVER_ID, 4, (UINT8 *)&IpAddr);
}
//
@@ -1242,19 +1220,17 @@ DhcpSendMessage (
if (Type == DHCP_MSG_REQUEST) {
if (DhcpSb->DhcpState == Dhcp4Rebooting) {
IpAddr = EFI_IP4 (Config->ClientAddress);
-
} else if (DhcpSb->DhcpState == Dhcp4Requesting) {
ASSERT (SeedHead != NULL);
IpAddr = EFI_IP4 (SeedHead->YourAddr);
}
-
} else if (Type == DHCP_MSG_DECLINE) {
ASSERT (SeedHead != NULL);
IpAddr = EFI_IP4 (SeedHead->YourAddr);
}
if (IpAddr != 0) {
- Buf = DhcpAppendOption (Buf, DHCP4_TAG_REQUEST_IP, 4, (UINT8 *) &IpAddr);
+ Buf = DhcpAppendOption (Buf, DHCP4_TAG_REQUEST_IP, 4, (UINT8 *)&IpAddr);
}
//
@@ -1263,16 +1239,16 @@ DhcpSendMessage (
// override the BOOTFILE and SERVER fields in the message head.
//
if ((Type != DHCP_MSG_DECLINE) && (Type != DHCP_MSG_RELEASE)) {
- MaxMsg = HTONS (0xFF00);
- Buf = DhcpAppendOption (Buf, DHCP4_TAG_MAXMSG, 2, (UINT8 *) &MaxMsg);
+ MaxMsg = HTONS (0xFF00);
+ Buf = DhcpAppendOption (Buf, DHCP4_TAG_MAXMSG, 2, (UINT8 *)&MaxMsg);
}
//
// Append the user's message if it isn't NULL
//
if (Msg != NULL) {
- Len = MIN ((UINT32) AsciiStrLen ((CHAR8 *) Msg), 255);
- Buf = DhcpAppendOption (Buf, DHCP4_TAG_MESSAGE, (UINT16) Len, Msg);
+ Len = MIN ((UINT32)AsciiStrLen ((CHAR8 *)Msg), 255);
+ Buf = DhcpAppendOption (Buf, DHCP4_TAG_MESSAGE, (UINT16)Len, Msg);
}
//
@@ -1285,7 +1261,8 @@ DhcpSendMessage (
// if it is a DHCP decline or DHCP release .
//
if (((Type == DHCP_MSG_DECLINE) || (Type == DHCP_MSG_RELEASE)) &&
- (Config->OptionList[Index]->OpCode != DHCP4_TAG_CLIENT_ID)) {
+ (Config->OptionList[Index]->OpCode != DHCP4_TAG_CLIENT_ID))
+ {
continue;
}
@@ -1298,8 +1275,8 @@ DhcpSendMessage (
}
}
- *(Buf++) = DHCP4_TAG_EOP;
- Packet->Length += (UINT32) (Buf - Packet->Dhcp4.Option);
+ *(Buf++) = DHCP4_TAG_EOP;
+ Packet->Length += (UINT32)(Buf - Packet->Dhcp4.Option);
//
// OK, the message is built, call the user to override it.
@@ -1309,10 +1286,8 @@ DhcpSendMessage (
if (Type == DHCP_MSG_DISCOVER) {
Status = DhcpCallUser (DhcpSb, Dhcp4SendDiscover, Packet, &NewPacket);
-
} else if (Type == DHCP_MSG_REQUEST) {
Status = DhcpCallUser (DhcpSb, Dhcp4SendRequest, Packet, &NewPacket);
-
} else if (Type == DHCP_MSG_DECLINE) {
Status = DhcpCallUser (DhcpSb, Dhcp4SendDecline, Packet, &NewPacket);
}
@@ -1339,7 +1314,7 @@ DhcpSendMessage (
//
// Wrap it into a netbuf then send it.
//
- Frag.Bulk = (UINT8 *) &Packet->Dhcp4.Header;
+ Frag.Bulk = (UINT8 *)&Packet->Dhcp4.Header;
Frag.Len = Packet->Length;
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
@@ -1393,7 +1368,6 @@ DhcpSendMessage (
return EFI_SUCCESS;
}
-
/**
Retransmit a saved packet. Only DISCOVER and REQUEST messages
will be retransmitted.
@@ -1406,14 +1380,14 @@ DhcpSendMessage (
**/
EFI_STATUS
DhcpRetransmit (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
)
{
- UDP_IO *UdpIo;
- UDP_END_POINT EndPoint;
- NET_BUF *Wrap;
- NET_FRAGMENT Frag;
- EFI_STATUS Status;
+ UDP_IO *UdpIo;
+ UDP_END_POINT EndPoint;
+ NET_BUF *Wrap;
+ NET_FRAGMENT Frag;
+ EFI_STATUS Status;
ASSERT (DhcpSb->LastPacket != NULL);
@@ -1421,13 +1395,13 @@ DhcpRetransmit (
// For REQUEST message in Dhcp4Requesting state, do not change the secs fields.
//
if (DhcpSb->DhcpState != Dhcp4Requesting) {
- SetElapsedTime(&DhcpSb->LastPacket->Dhcp4.Header.Seconds, DhcpSb->ActiveChild);
+ SetElapsedTime (&DhcpSb->LastPacket->Dhcp4.Header.Seconds, DhcpSb->ActiveChild);
}
//
// Wrap it into a netbuf then send it.
//
- Frag.Bulk = (UINT8 *) &DhcpSb->LastPacket->Dhcp4.Header;
+ Frag.Bulk = (UINT8 *)&DhcpSb->LastPacket->Dhcp4.Header;
Frag.Len = DhcpSb->LastPacket->Length;
Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
@@ -1469,7 +1443,6 @@ DhcpRetransmit (
return EFI_SUCCESS;
}
-
/**
Each DHCP service has three timer. Two of them are count down timer.
One for the packet retransmission. The other is to collect the offers.
@@ -1484,23 +1457,23 @@ DhcpRetransmit (
VOID
EFIAPI
DhcpOnTimerTick (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- DHCP_SERVICE *DhcpSb;
- DHCP_PROTOCOL *Instance;
- EFI_STATUS Status;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ DHCP_SERVICE *DhcpSb;
+ DHCP_PROTOCOL *Instance;
+ EFI_STATUS Status;
- DhcpSb = (DHCP_SERVICE *) Context;
+ DhcpSb = (DHCP_SERVICE *)Context;
Instance = DhcpSb->ActiveChild;
//
// 0xffff is the maximum supported value for elapsed time according to RFC.
//
- if (Instance != NULL && Instance->ElaspedTime < 0xffff) {
+ if ((Instance != NULL) && (Instance->ElaspedTime < 0xffff)) {
Instance->ElaspedTime++;
}
@@ -1508,15 +1481,13 @@ DhcpOnTimerTick (
// Check the retransmit timer
//
if ((DhcpSb->PacketToLive > 0) && (--DhcpSb->PacketToLive == 0)) {
-
//
// Select offer at each timeout if any offer received.
//
- if (DhcpSb->DhcpState == Dhcp4Selecting && DhcpSb->LastOffer != NULL) {
-
+ if ((DhcpSb->DhcpState == Dhcp4Selecting) && (DhcpSb->LastOffer != NULL)) {
Status = DhcpChooseOffer (DhcpSb);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
if (DhcpSb->LastOffer != NULL) {
FreePool (DhcpSb->LastOffer);
DhcpSb->LastOffer = NULL;
@@ -1532,9 +1503,7 @@ DhcpOnTimerTick (
//
DhcpRetransmit (DhcpSb);
DhcpSetTransmitTimer (DhcpSb);
-
} else if (DHCP_CONNECTED (DhcpSb->DhcpState)) {
-
//
// Retransmission failed, if the DHCP request is initiated by
// user, adjust the current state according to the lease life.
@@ -1545,16 +1514,12 @@ DhcpOnTimerTick (
if (DhcpSb->LeaseLife < DhcpSb->T1) {
Status = DhcpSetState (DhcpSb, Dhcp4Bound, FALSE);
-
} else if (DhcpSb->LeaseLife < DhcpSb->T2) {
Status = DhcpSetState (DhcpSb, Dhcp4Renewing, FALSE);
-
} else if (DhcpSb->LeaseLife < DhcpSb->Lease) {
Status = DhcpSetState (DhcpSb, Dhcp4Rebinding, FALSE);
-
} else {
goto END_SESSION;
-
}
DhcpSb->IoStatus = EFI_TIMEOUT;
@@ -1577,7 +1542,7 @@ DhcpOnTimerTick (
// requesting extra renew/rebind. Adjust the state after that.
//
if (DhcpSb->ExtraRefresh != 0) {
- return ;
+ return;
}
if (DhcpSb->LeaseLife == DhcpSb->Lease) {
@@ -1585,7 +1550,6 @@ DhcpOnTimerTick (
// Lease expires, end the session
//
goto END_SESSION;
-
} else if (DhcpSb->LeaseLife == DhcpSb->T2) {
//
// T2 expires, transit to rebinding then send a REQUEST to any server
@@ -1595,7 +1559,7 @@ DhcpOnTimerTick (
}
if (Instance != NULL) {
- Instance->ElaspedTime= 0;
+ Instance->ElaspedTime = 0;
}
Status = DhcpSendMessage (
@@ -1609,7 +1573,6 @@ DhcpOnTimerTick (
if (EFI_ERROR (Status)) {
goto END_SESSION;
}
-
} else if (DhcpSb->LeaseLife == DhcpSb->T1) {
//
// T1 expires, transit to renewing, then send a REQUEST to the server
@@ -1619,7 +1582,7 @@ DhcpOnTimerTick (
}
if (Instance != NULL) {
- Instance->ElaspedTime= 0;
+ Instance->ElaspedTime = 0;
}
Status = DhcpSendMessage (
@@ -1643,15 +1606,15 @@ ON_EXIT:
NET_LIST_FOR_EACH_SAFE (Entry, Next, &DhcpSb->Children) {
Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link);
Instance->Timeout--;
- if (Instance->Timeout == 0 && Instance->Token != NULL) {
+ if ((Instance->Timeout == 0) && (Instance->Token != NULL)) {
PxeDhcpDone (Instance);
}
}
- return ;
+ return;
END_SESSION:
DhcpEndSession (DhcpSb, EFI_TIMEOUT);
- return ;
+ return;
}
diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Io.h b/NetworkPkg/Dhcp4Dxe/Dhcp4Io.h
index 0dd6b46..6f7f811 100644
--- a/NetworkPkg/Dhcp4Dxe/Dhcp4Io.h
+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Io.h
@@ -18,37 +18,35 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
-
-
-#define DHCP_WAIT_OFFER 3 // Time to wait the offers
+#define DHCP_WAIT_OFFER 3 // Time to wait the offers
#define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default.
-#define DHCP_SERVER_PORT 67
-#define DHCP_CLIENT_PORT 68
+#define DHCP_SERVER_PORT 67
+#define DHCP_CLIENT_PORT 68
//
// BOOTP header "op" field
//
-#define BOOTP_REQUEST 1
-#define BOOTP_REPLY 2
+#define BOOTP_REQUEST 1
+#define BOOTP_REPLY 2
//
// DHCP message types
//
-#define DHCP_MSG_DISCOVER 1
-#define DHCP_MSG_OFFER 2
-#define DHCP_MSG_REQUEST 3
-#define DHCP_MSG_DECLINE 4
-#define DHCP_MSG_ACK 5
-#define DHCP_MSG_NAK 6
-#define DHCP_MSG_RELEASE 7
-#define DHCP_MSG_INFORM 8
+#define DHCP_MSG_DISCOVER 1
+#define DHCP_MSG_OFFER 2
+#define DHCP_MSG_REQUEST 3
+#define DHCP_MSG_DECLINE 4
+#define DHCP_MSG_ACK 5
+#define DHCP_MSG_NAK 6
+#define DHCP_MSG_RELEASE 7
+#define DHCP_MSG_INFORM 8
//
// DHCP notify user type
//
-#define DHCP_NOTIFY_COMPLETION 1
-#define DHCP_NOTIFY_RENEWREBIND 2
-#define DHCP_NOTIFY_ALL 3
+#define DHCP_NOTIFY_COMPLETION 1
+#define DHCP_NOTIFY_RENEWREBIND 2
+#define DHCP_NOTIFY_ALL 3
#define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
@@ -72,9 +70,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
DhcpSetState (
- IN OUT DHCP_SERVICE *DhcpSb,
- IN INTN State,
- IN BOOLEAN CallUser
+ IN OUT DHCP_SERVICE *DhcpSb,
+ IN INTN State,
+ IN BOOLEAN CallUser
);
/**
@@ -98,11 +96,11 @@ DhcpSetState (
**/
EFI_STATUS
DhcpSendMessage (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_DHCP4_PACKET *Seed,
- IN DHCP_PARAMETER *Para,
- IN UINT8 Type,
- IN UINT8 *Msg
+ IN DHCP_SERVICE *DhcpSb,
+ IN EFI_DHCP4_PACKET *Seed,
+ IN DHCP_PARAMETER *Para,
+ IN UINT8 Type,
+ IN UINT8 *Msg
);
/**
@@ -119,8 +117,8 @@ DhcpSendMessage (
VOID
EFIAPI
DhcpOnTimerTick (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -136,10 +134,10 @@ DhcpOnTimerTick (
VOID
EFIAPI
DhcpInput (
- NET_BUF *UdpPacket,
- UDP_END_POINT *EndPoint,
- EFI_STATUS IoStatus,
- VOID *Context
+ NET_BUF *UdpPacket,
+ UDP_END_POINT *EndPoint,
+ EFI_STATUS IoStatus,
+ VOID *Context
);
/**
@@ -154,7 +152,7 @@ DhcpInput (
**/
EFI_STATUS
DhcpInitRequest (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
);
/**
@@ -165,7 +163,7 @@ DhcpInitRequest (
**/
VOID
DhcpCleanLease (
- IN DHCP_SERVICE *DhcpSb
+ IN DHCP_SERVICE *DhcpSb
);
/**
@@ -180,10 +178,10 @@ DhcpCleanLease (
VOID
EFIAPI
DhcpOnPacketSent (
- NET_BUF *Packet,
- UDP_END_POINT *EndPoint,
- EFI_STATUS IoStatus,
- VOID *Context
+ NET_BUF *Packet,
+ UDP_END_POINT *EndPoint,
+ EFI_STATUS IoStatus,
+ VOID *Context
);
#endif
diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Option.c b/NetworkPkg/Dhcp4Dxe/Dhcp4Option.c
index 37a6302..5959eff 100644
--- a/NetworkPkg/Dhcp4Dxe/Dhcp4Option.c
+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Option.c
@@ -13,95 +13,94 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// to validate a dhcp message. Refere the comments of the
/// DHCP_OPTION_FORMAT structure.
///
-DHCP_OPTION_FORMAT DhcpOptionFormats[] = {
- {DHCP4_TAG_NETMASK, DHCP_OPTION_IP, 1, 1 , TRUE},
- {DHCP4_TAG_TIME_OFFSET, DHCP_OPTION_INT32, 1, 1 , FALSE},
- {DHCP4_TAG_ROUTER, DHCP_OPTION_IP, 1, -1 , TRUE},
- {DHCP4_TAG_TIME_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_NAME_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_DNS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_LOG_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_COOKIE_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_LPR_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_IMPRESS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_RL_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_HOSTNAME, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_BOOTFILE_LEN, DHCP_OPTION_INT16, 1, 1 , FALSE},
- {DHCP4_TAG_DUMP, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_DOMAINNAME, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_SWAP_SERVER, DHCP_OPTION_IP, 1, 1 , FALSE},
- {DHCP4_TAG_ROOTPATH, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_EXTEND_PATH, DHCP_OPTION_INT8, 1, -1 , FALSE},
-
- {DHCP4_TAG_IPFORWARD, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
- {DHCP4_TAG_NONLOCAL_SRR, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
- {DHCP4_TAG_POLICY_SRR, DHCP_OPTION_IPPAIR, 1, -1 , FALSE},
- {DHCP4_TAG_EMTU, DHCP_OPTION_INT16, 1, 1 , FALSE},
- {DHCP4_TAG_TTL, DHCP_OPTION_INT8, 1, 1 , FALSE},
- {DHCP4_TAG_PATHMTU_AGE, DHCP_OPTION_INT32, 1, 1 , FALSE},
- {DHCP4_TAG_PATHMTU_PLATEAU,DHCP_OPTION_INT16, 1, -1 , FALSE},
-
- {DHCP4_TAG_IFMTU, DHCP_OPTION_INT16, 1, 1 , FALSE},
- {DHCP4_TAG_SUBNET_LOCAL, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
- {DHCP4_TAG_BROADCAST, DHCP_OPTION_IP, 1, 1 , FALSE},
- {DHCP4_TAG_DISCOVER_MASK, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
- {DHCP4_TAG_SUPPLY_MASK, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
- {DHCP4_TAG_DISCOVER_ROUTE, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
- {DHCP4_TAG_ROUTER_SOLICIT, DHCP_OPTION_IP, 1, 1 , FALSE},
- {DHCP4_TAG_STATIC_ROUTE, DHCP_OPTION_IPPAIR, 1, -1 , FALSE},
-
- {DHCP4_TAG_TRAILER, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
- {DHCP4_TAG_ARPAGE, DHCP_OPTION_INT32, 1, 1 , FALSE},
- {DHCP4_TAG_ETHER_ENCAP, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
-
- {DHCP4_TAG_TCP_TTL, DHCP_OPTION_INT8, 1, 1 , FALSE},
- {DHCP4_TAG_KEEP_INTERVAL, DHCP_OPTION_INT32, 1, 1 , FALSE},
- {DHCP4_TAG_KEEP_GARBAGE, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
-
- {DHCP4_TAG_NIS_DOMAIN, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_NIS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_NTP_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_VENDOR, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_NBNS, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_NBDD, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_NBTYPE, DHCP_OPTION_INT8, 1, 1 , FALSE},
- {DHCP4_TAG_NBSCOPE, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_XFONT, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_XDM, DHCP_OPTION_IP, 1, -1 , FALSE},
-
- {DHCP4_TAG_REQUEST_IP, DHCP_OPTION_IP, 1, 1 , FALSE},
- {DHCP4_TAG_LEASE, DHCP_OPTION_INT32, 1, 1 , TRUE},
- {DHCP4_TAG_OVERLOAD, DHCP_OPTION_INT8, 1, 1 , TRUE},
- {DHCP4_TAG_MSG_TYPE, DHCP_OPTION_INT8, 1, 1 , TRUE},
- {DHCP4_TAG_SERVER_ID, DHCP_OPTION_IP, 1, 1 , TRUE},
- {DHCP4_TAG_PARA_LIST, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_MESSAGE, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_MAXMSG, DHCP_OPTION_INT16, 1, 1 , FALSE},
- {DHCP4_TAG_T1, DHCP_OPTION_INT32, 1, 1 , TRUE},
- {DHCP4_TAG_T2, DHCP_OPTION_INT32, 1, 1 , TRUE},
- {DHCP4_TAG_VENDOR_CLASS_ID,DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_CLIENT_ID, DHCP_OPTION_INT8, 2, -1 , FALSE},
-
- {DHCP4_TAG_NISPLUS, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_NISPLUS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
-
- {DHCP4_TAG_TFTP, DHCP_OPTION_INT8, 1, -1 , FALSE},
- {DHCP4_TAG_BOOTFILE, DHCP_OPTION_INT8, 1, -1 , FALSE},
-
- {DHCP4_TAG_MOBILEIP, DHCP_OPTION_IP, 0, -1 , FALSE},
- {DHCP4_TAG_SMTP, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_POP3, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_NNTP, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_WWW, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_FINGER, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_IRC, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_STTALK, DHCP_OPTION_IP, 1, -1 , FALSE},
- {DHCP4_TAG_STDA, DHCP_OPTION_IP, 1, -1 , FALSE},
-
- {DHCP4_TAG_CLASSLESS_ROUTE,DHCP_OPTION_INT8, 5, -1 , FALSE},
+DHCP_OPTION_FORMAT DhcpOptionFormats[] = {
+ { DHCP4_TAG_NETMASK, DHCP_OPTION_IP, 1, 1, TRUE },
+ { DHCP4_TAG_TIME_OFFSET, DHCP_OPTION_INT32, 1, 1, FALSE },
+ { DHCP4_TAG_ROUTER, DHCP_OPTION_IP, 1, -1, TRUE },
+ { DHCP4_TAG_TIME_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_NAME_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_DNS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_LOG_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_COOKIE_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_LPR_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_IMPRESS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_RL_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_HOSTNAME, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_BOOTFILE_LEN, DHCP_OPTION_INT16, 1, 1, FALSE },
+ { DHCP4_TAG_DUMP, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_DOMAINNAME, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_SWAP_SERVER, DHCP_OPTION_IP, 1, 1, FALSE },
+ { DHCP4_TAG_ROOTPATH, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_EXTEND_PATH, DHCP_OPTION_INT8, 1, -1, FALSE },
+
+ { DHCP4_TAG_IPFORWARD, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+ { DHCP4_TAG_NONLOCAL_SRR, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+ { DHCP4_TAG_POLICY_SRR, DHCP_OPTION_IPPAIR, 1, -1, FALSE },
+ { DHCP4_TAG_EMTU, DHCP_OPTION_INT16, 1, 1, FALSE },
+ { DHCP4_TAG_TTL, DHCP_OPTION_INT8, 1, 1, FALSE },
+ { DHCP4_TAG_PATHMTU_AGE, DHCP_OPTION_INT32, 1, 1, FALSE },
+ { DHCP4_TAG_PATHMTU_PLATEAU, DHCP_OPTION_INT16, 1, -1, FALSE },
+
+ { DHCP4_TAG_IFMTU, DHCP_OPTION_INT16, 1, 1, FALSE },
+ { DHCP4_TAG_SUBNET_LOCAL, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+ { DHCP4_TAG_BROADCAST, DHCP_OPTION_IP, 1, 1, FALSE },
+ { DHCP4_TAG_DISCOVER_MASK, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+ { DHCP4_TAG_SUPPLY_MASK, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+ { DHCP4_TAG_DISCOVER_ROUTE, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+ { DHCP4_TAG_ROUTER_SOLICIT, DHCP_OPTION_IP, 1, 1, FALSE },
+ { DHCP4_TAG_STATIC_ROUTE, DHCP_OPTION_IPPAIR, 1, -1, FALSE },
+
+ { DHCP4_TAG_TRAILER, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+ { DHCP4_TAG_ARPAGE, DHCP_OPTION_INT32, 1, 1, FALSE },
+ { DHCP4_TAG_ETHER_ENCAP, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+
+ { DHCP4_TAG_TCP_TTL, DHCP_OPTION_INT8, 1, 1, FALSE },
+ { DHCP4_TAG_KEEP_INTERVAL, DHCP_OPTION_INT32, 1, 1, FALSE },
+ { DHCP4_TAG_KEEP_GARBAGE, DHCP_OPTION_SWITCH, 1, 1, FALSE },
+
+ { DHCP4_TAG_NIS_DOMAIN, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_NIS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_NTP_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_VENDOR, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_NBNS, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_NBDD, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_NBTYPE, DHCP_OPTION_INT8, 1, 1, FALSE },
+ { DHCP4_TAG_NBSCOPE, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_XFONT, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_XDM, DHCP_OPTION_IP, 1, -1, FALSE },
+
+ { DHCP4_TAG_REQUEST_IP, DHCP_OPTION_IP, 1, 1, FALSE },
+ { DHCP4_TAG_LEASE, DHCP_OPTION_INT32, 1, 1, TRUE },
+ { DHCP4_TAG_OVERLOAD, DHCP_OPTION_INT8, 1, 1, TRUE },
+ { DHCP4_TAG_MSG_TYPE, DHCP_OPTION_INT8, 1, 1, TRUE },
+ { DHCP4_TAG_SERVER_ID, DHCP_OPTION_IP, 1, 1, TRUE },
+ { DHCP4_TAG_PARA_LIST, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_MESSAGE, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_MAXMSG, DHCP_OPTION_INT16, 1, 1, FALSE },
+ { DHCP4_TAG_T1, DHCP_OPTION_INT32, 1, 1, TRUE },
+ { DHCP4_TAG_T2, DHCP_OPTION_INT32, 1, 1, TRUE },
+ { DHCP4_TAG_VENDOR_CLASS_ID, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_CLIENT_ID, DHCP_OPTION_INT8, 2, -1, FALSE },
+
+ { DHCP4_TAG_NISPLUS, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_NISPLUS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
+
+ { DHCP4_TAG_TFTP, DHCP_OPTION_INT8, 1, -1, FALSE },
+ { DHCP4_TAG_BOOTFILE, DHCP_OPTION_INT8, 1, -1, FALSE },
+
+ { DHCP4_TAG_MOBILEIP, DHCP_OPTION_IP, 0, -1, FALSE },
+ { DHCP4_TAG_SMTP, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_POP3, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_NNTP, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_WWW, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_FINGER, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_IRC, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_STTALK, DHCP_OPTION_IP, 1, -1, FALSE },
+ { DHCP4_TAG_STDA, DHCP_OPTION_IP, 1, -1, FALSE },
+
+ { DHCP4_TAG_CLASSLESS_ROUTE, DHCP_OPTION_INT8, 5, -1, FALSE },
};
-
/**
Binary search the DhcpOptionFormats array to find the format
information about a specific option.
@@ -113,12 +112,12 @@ DHCP_OPTION_FORMAT DhcpOptionFormats[] = {
**/
DHCP_OPTION_FORMAT *
DhcpFindOptionFormat (
- IN UINT8 Tag
+ IN UINT8 Tag
)
{
- INTN Left;
- INTN Right;
- INTN Middle;
+ INTN Left;
+ INTN Right;
+ INTN Middle;
Left = 0;
Right = sizeof (DhcpOptionFormats) / sizeof (DHCP_OPTION_FORMAT) - 1;
@@ -133,14 +132,13 @@ DhcpFindOptionFormat (
if (Tag < DhcpOptionFormats[Middle].Tag) {
Right = Middle - 1;
} else {
- Left = Middle + 1;
+ Left = Middle + 1;
}
}
return NULL;
}
-
/**
Validate whether a single DHCP option is valid according to its format.
@@ -154,35 +152,35 @@ DhcpFindOptionFormat (
**/
BOOLEAN
DhcpOptionIsValid (
- IN DHCP_OPTION_FORMAT *Format,
- IN UINT8 *OptValue,
- IN INTN Len
+ IN DHCP_OPTION_FORMAT *Format,
+ IN UINT8 *OptValue,
+ IN INTN Len
)
{
- INTN Unit;
- INTN Occur;
- INTN Index;
+ INTN Unit;
+ INTN Occur;
+ INTN Index;
Unit = 0;
switch (Format->Type) {
- case DHCP_OPTION_SWITCH:
- case DHCP_OPTION_INT8:
- Unit = 1;
- break;
+ case DHCP_OPTION_SWITCH:
+ case DHCP_OPTION_INT8:
+ Unit = 1;
+ break;
- case DHCP_OPTION_INT16:
- Unit = 2;
- break;
+ case DHCP_OPTION_INT16:
+ Unit = 2;
+ break;
- case DHCP_OPTION_INT32:
- case DHCP_OPTION_IP:
- Unit = 4;
- break;
+ case DHCP_OPTION_INT32:
+ case DHCP_OPTION_IP:
+ Unit = 4;
+ break;
- case DHCP_OPTION_IPPAIR:
- Unit = 8;
- break;
+ case DHCP_OPTION_IPPAIR:
+ Unit = 8;
+ break;
}
ASSERT (Unit != 0);
@@ -201,7 +199,8 @@ DhcpOptionIsValid (
if (((Format->MinOccur != -1) && (Occur < Format->MinOccur)) ||
((Format->MaxOccur != -1) && (Occur > Format->MaxOccur))
- ) {
+ )
+ {
return FALSE;
}
@@ -219,7 +218,6 @@ DhcpOptionIsValid (
return TRUE;
}
-
/**
Extract the client interested options, all the parameters are
converted to host byte order.
@@ -235,61 +233,62 @@ DhcpOptionIsValid (
**/
EFI_STATUS
DhcpGetParameter (
- IN UINT8 Tag,
- IN INTN Len,
- IN UINT8 *Data,
- OUT DHCP_PARAMETER *Para
+ IN UINT8 Tag,
+ IN INTN Len,
+ IN UINT8 *Data,
+ OUT DHCP_PARAMETER *Para
)
{
switch (Tag) {
- case DHCP4_TAG_NETMASK:
- Para->NetMask = NetGetUint32 (Data);
- break;
+ case DHCP4_TAG_NETMASK:
+ Para->NetMask = NetGetUint32 (Data);
+ break;
- case DHCP4_TAG_ROUTER:
- //
- // Return the first router to consumer which is the preferred one
- //
- Para->Router = NetGetUint32 (Data);
- break;
+ case DHCP4_TAG_ROUTER:
+ //
+ // Return the first router to consumer which is the preferred one
+ //
+ Para->Router = NetGetUint32 (Data);
+ break;
- case DHCP4_TAG_LEASE:
- Para->Lease = NetGetUint32 (Data);
- break;
+ case DHCP4_TAG_LEASE:
+ Para->Lease = NetGetUint32 (Data);
+ break;
- case DHCP4_TAG_OVERLOAD:
- Para->Overload = *Data;
+ case DHCP4_TAG_OVERLOAD:
+ Para->Overload = *Data;
- if ((Para->Overload < 1) || (Para->Overload > 3)) {
- return EFI_INVALID_PARAMETER;
- }
- break;
+ if ((Para->Overload < 1) || (Para->Overload > 3)) {
+ return EFI_INVALID_PARAMETER;
+ }
- case DHCP4_TAG_MSG_TYPE:
- Para->DhcpType = *Data;
+ break;
- if ((Para->DhcpType < 1) || (Para->DhcpType > 9)) {
- return EFI_INVALID_PARAMETER;
- }
- break;
+ case DHCP4_TAG_MSG_TYPE:
+ Para->DhcpType = *Data;
+
+ if ((Para->DhcpType < 1) || (Para->DhcpType > 9)) {
+ return EFI_INVALID_PARAMETER;
+ }
- case DHCP4_TAG_SERVER_ID:
- Para->ServerId = NetGetUint32 (Data);
- break;
+ break;
- case DHCP4_TAG_T1:
- Para->T1 = NetGetUint32 (Data);
- break;
+ case DHCP4_TAG_SERVER_ID:
+ Para->ServerId = NetGetUint32 (Data);
+ break;
- case DHCP4_TAG_T2:
- Para->T2 = NetGetUint32 (Data);
- break;
+ case DHCP4_TAG_T1:
+ Para->T1 = NetGetUint32 (Data);
+ break;
+
+ case DHCP4_TAG_T2:
+ Para->T2 = NetGetUint32 (Data);
+ break;
}
return EFI_SUCCESS;
}
-
/**
Inspect all the options in a single buffer. DHCP options may be contained
in several buffers, such as the BOOTP options filed, boot file or server
@@ -308,16 +307,16 @@ DhcpGetParameter (
**/
EFI_STATUS
DhcpIterateBufferOptions (
- IN UINT8 *Buffer,
- IN INTN BufLen,
- IN DHCP_CHECK_OPTION Check OPTIONAL,
- IN VOID *Context,
- OUT UINT8 *Overload OPTIONAL
+ IN UINT8 *Buffer,
+ IN INTN BufLen,
+ IN DHCP_CHECK_OPTION Check OPTIONAL,
+ IN VOID *Context,
+ OUT UINT8 *Overload OPTIONAL
)
{
- INTN Cur;
- UINT8 Tag;
- UINT8 Len;
+ INTN Cur;
+ UINT8 Tag;
+ UINT8 Len;
Cur = 0;
@@ -364,7 +363,6 @@ DhcpIterateBufferOptions (
return EFI_INVALID_PARAMETER;
}
-
/**
Iterate through a DHCP message to visit each option. First inspect
all the options in the OPTION field. Then if overloaded, inspect
@@ -382,23 +380,23 @@ DhcpIterateBufferOptions (
**/
EFI_STATUS
DhcpIterateOptions (
- IN EFI_DHCP4_PACKET *Packet,
- IN DHCP_CHECK_OPTION Check OPTIONAL,
- IN VOID *Context
+ IN EFI_DHCP4_PACKET *Packet,
+ IN DHCP_CHECK_OPTION Check OPTIONAL,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- UINT8 Overload;
+ EFI_STATUS Status;
+ UINT8 Overload;
Overload = 0;
- Status = DhcpIterateBufferOptions (
- Packet->Dhcp4.Option,
- Packet->Length - sizeof (EFI_DHCP4_HEADER) - sizeof (UINT32),
- Check,
- Context,
- &Overload
- );
+ Status = DhcpIterateBufferOptions (
+ Packet->Dhcp4.Option,
+ Packet->Length - sizeof (EFI_DHCP4_HEADER) - sizeof (UINT32),
+ Check,
+ Context,
+ &Overload
+ );
if (EFI_ERROR (Status)) {
return Status;
@@ -406,7 +404,7 @@ DhcpIterateOptions (
if ((Overload == DHCP_OVERLOAD_FILENAME) || (Overload == DHCP_OVERLOAD_BOTH)) {
Status = DhcpIterateBufferOptions (
- (UINT8 *) Packet->Dhcp4.Header.BootFileName,
+ (UINT8 *)Packet->Dhcp4.Header.BootFileName,
128,
Check,
Context,
@@ -420,7 +418,7 @@ DhcpIterateOptions (
if ((Overload == DHCP_OVERLOAD_SVRNAME) || (Overload == DHCP_OVERLOAD_BOTH)) {
Status = DhcpIterateBufferOptions (
- (UINT8 *) Packet->Dhcp4.Header.ServerName,
+ (UINT8 *)Packet->Dhcp4.Header.ServerName,
64,
Check,
Context,
@@ -435,7 +433,6 @@ DhcpIterateOptions (
return EFI_SUCCESS;
}
-
/**
Call back function to DhcpIterateOptions to compute each option's
length. It just adds the data length of all the occurrences of this
@@ -452,21 +449,20 @@ DhcpIterateOptions (
**/
EFI_STATUS
DhcpGetOptionLen (
- IN UINT8 Tag,
- IN UINT8 Len,
- IN UINT8 *Data,
- IN VOID *Context
+ IN UINT8 Tag,
+ IN UINT8 Len,
+ IN UINT8 *Data,
+ IN VOID *Context
)
{
- DHCP_OPTION_COUNT *OpCount;
+ DHCP_OPTION_COUNT *OpCount;
- OpCount = (DHCP_OPTION_COUNT *) Context;
- OpCount[Tag].Offset = (UINT16) (OpCount[Tag].Offset + Len);
+ OpCount = (DHCP_OPTION_COUNT *)Context;
+ OpCount[Tag].Offset = (UINT16)(OpCount[Tag].Offset + Len);
return EFI_SUCCESS;
}
-
/**
Call back function to DhcpIterateOptions to consolidate each option's
data. There are maybe several occurrence of the same option.
@@ -482,24 +478,24 @@ DhcpGetOptionLen (
**/
EFI_STATUS
DhcpFillOption (
- IN UINT8 Tag,
- IN UINT8 Len,
- IN UINT8 *Data,
- IN VOID *Context
+ IN UINT8 Tag,
+ IN UINT8 Len,
+ IN UINT8 *Data,
+ IN VOID *Context
)
{
- DHCP_OPTION_CONTEXT *OptContext;
- DHCP_OPTION_COUNT *OptCount;
- DHCP_OPTION *Options;
- UINT8 *Buf;
- UINT8 Index;
+ DHCP_OPTION_CONTEXT *OptContext;
+ DHCP_OPTION_COUNT *OptCount;
+ DHCP_OPTION *Options;
+ UINT8 *Buf;
+ UINT8 Index;
- OptContext = (DHCP_OPTION_CONTEXT *) Context;
+ OptContext = (DHCP_OPTION_CONTEXT *)Context;
- OptCount = OptContext->OpCount;
- Index = OptCount[Tag].Index;
- Options = OptContext->Options;
- Buf = OptContext->Buf;
+ OptCount = OptContext->OpCount;
+ Index = OptCount[Tag].Index;
+ Options = OptContext->Options;
+ Buf = OptContext->Buf;
if (Options[Index].Data == NULL) {
Options[Index].Tag = Tag;
@@ -508,12 +504,11 @@ DhcpFillOption (
CopyMem (Buf + OptCount[Tag].Offset, Data, Len);
- OptCount[Tag].Offset = (UINT16) (OptCount[Tag].Offset + Len);
- Options[Index].Len = (UINT16) (Options[Index].Len + Len);
+ OptCount[Tag].Offset = (UINT16)(OptCount[Tag].Offset + Len);
+ Options[Index].Len = (UINT16)(Options[Index].Len + Len);
return EFI_SUCCESS;
}
-
/**
Parse the options of a DHCP packet. It supports RFC 3396: Encoding
Long Options in DHCP. That is, it will combine all the option value
@@ -544,18 +539,18 @@ DhcpFillOption (
**/
EFI_STATUS
DhcpParseOption (
- IN EFI_DHCP4_PACKET *Packet,
- OUT INTN *Count,
- OUT DHCP_OPTION **OptionPoint
+ IN EFI_DHCP4_PACKET *Packet,
+ OUT INTN *Count,
+ OUT DHCP_OPTION **OptionPoint
)
{
- DHCP_OPTION_CONTEXT Context;
- DHCP_OPTION *Options;
- DHCP_OPTION_COUNT *OptCount;
- EFI_STATUS Status;
- UINT16 TotalLen;
- INTN OptNum;
- INTN Index;
+ DHCP_OPTION_CONTEXT Context;
+ DHCP_OPTION *Options;
+ DHCP_OPTION_COUNT *OptCount;
+ EFI_STATUS Status;
+ UINT16 TotalLen;
+ INTN OptNum;
+ INTN Index;
ASSERT ((Count != NULL) && (OptionPoint != NULL));
@@ -580,22 +575,22 @@ DhcpParseOption (
// OptCount[Index].Offset specifies the offset into the continuous
// option value buffer to put the data.
//
- TotalLen = 0;
- OptNum = 0;
+ TotalLen = 0;
+ OptNum = 0;
for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) {
if (OptCount[Index].Offset != 0) {
- OptCount[Index].Index = (UINT8) OptNum;
+ OptCount[Index].Index = (UINT8)OptNum;
- TotalLen = (UINT16) (TotalLen + OptCount[Index].Offset);
- OptCount[Index].Offset = (UINT16) (TotalLen - OptCount[Index].Offset);
+ TotalLen = (UINT16)(TotalLen + OptCount[Index].Offset);
+ OptCount[Index].Offset = (UINT16)(TotalLen - OptCount[Index].Offset);
OptNum++;
}
}
- *Count = OptNum;
- *OptionPoint = NULL;
+ *Count = OptNum;
+ *OptionPoint = NULL;
if (OptNum == 0) {
goto ON_EXIT;
@@ -605,7 +600,7 @@ DhcpParseOption (
// Allocate a buffer to hold the DHCP options, and after that, a
// continuous buffer to put all the options' data.
//
- Options = AllocateZeroPool ((UINTN) (OptNum * sizeof (DHCP_OPTION)) + TotalLen);
+ Options = AllocateZeroPool ((UINTN)(OptNum * sizeof (DHCP_OPTION)) + TotalLen);
if (Options == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -614,9 +609,9 @@ DhcpParseOption (
Context.OpCount = OptCount;
Context.Options = Options;
- Context.Buf = (UINT8 *) (Options + OptNum);
+ Context.Buf = (UINT8 *)(Options + OptNum);
- Status = DhcpIterateOptions (Packet, DhcpFillOption, &Context);
+ Status = DhcpIterateOptions (Packet, DhcpFillOption, &Context);
if (EFI_ERROR (Status)) {
FreePool (Options);
@@ -630,7 +625,6 @@ ON_EXIT:
return Status;
}
-
/**
Validate the packet's options. If necessary, allocate
and fill in the interested parameters.
@@ -645,18 +639,18 @@ ON_EXIT:
**/
EFI_STATUS
DhcpValidateOptions (
- IN EFI_DHCP4_PACKET *Packet,
- OUT DHCP_PARAMETER **Para OPTIONAL
+ IN EFI_DHCP4_PACKET *Packet,
+ OUT DHCP_PARAMETER **Para OPTIONAL
)
{
- DHCP_PARAMETER Parameter;
- DHCP_OPTION_FORMAT *Format;
- DHCP_OPTION *AllOption;
- DHCP_OPTION *Option;
- EFI_STATUS Status;
- BOOLEAN Updated;
- INTN Count;
- INTN Index;
+ DHCP_PARAMETER Parameter;
+ DHCP_OPTION_FORMAT *Format;
+ DHCP_OPTION *AllOption;
+ DHCP_OPTION *Option;
+ EFI_STATUS Status;
+ BOOLEAN Updated;
+ INTN Count;
+ INTN Index;
if (Para != NULL) {
*Para = NULL;
@@ -668,6 +662,7 @@ DhcpValidateOptions (
if (EFI_ERROR (Status) || (Count == 0)) {
return Status;
}
+
ASSERT (AllOption != NULL);
Updated = FALSE;
@@ -716,8 +711,6 @@ ON_EXIT:
return Status;
}
-
-
/**
Append an option to the memory, if the option is longer than
255 bytes, splits it into several options.
@@ -732,31 +725,30 @@ ON_EXIT:
**/
UINT8 *
DhcpAppendOption (
- OUT UINT8 *Buf,
- IN UINT8 Tag,
- IN UINT16 DataLen,
- IN UINT8 *Data
+ OUT UINT8 *Buf,
+ IN UINT8 Tag,
+ IN UINT16 DataLen,
+ IN UINT8 *Data
)
{
- INTN Index;
- INTN Len;
+ INTN Index;
+ INTN Len;
ASSERT (DataLen != 0);
for (Index = 0; Index < (DataLen + 254) / 255; Index++) {
- Len = MIN (255, DataLen - Index * 255);
+ Len = MIN (255, DataLen - Index * 255);
*(Buf++) = Tag;
- *(Buf++) = (UINT8) Len;
- CopyMem (Buf, Data + Index * 255, (UINTN) Len);
+ *(Buf++) = (UINT8)Len;
+ CopyMem (Buf, Data + Index * 255, (UINTN)Len);
- Buf += Len;
+ Buf += Len;
}
return Buf;
}
-
/**
Build a new DHCP packet from a seed packet. Options may be deleted or
appended. The caller should free the NewPacket when finished using it.
@@ -776,22 +768,22 @@ DhcpAppendOption (
**/
EFI_STATUS
DhcpBuild (
- IN EFI_DHCP4_PACKET *SeedPacket,
- IN UINT32 DeleteCount,
- IN UINT8 *DeleteList OPTIONAL,
- IN UINT32 AppendCount,
- IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
- OUT EFI_DHCP4_PACKET **NewPacket
+ IN EFI_DHCP4_PACKET *SeedPacket,
+ IN UINT32 DeleteCount,
+ IN UINT8 *DeleteList OPTIONAL,
+ IN UINT32 AppendCount,
+ IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
+ OUT EFI_DHCP4_PACKET **NewPacket
)
{
- DHCP_OPTION *Mark;
- DHCP_OPTION *SeedOptions;
- EFI_DHCP4_PACKET *Packet;
- EFI_STATUS Status;
- INTN Count;
- UINT32 Index;
- UINT32 Len;
- UINT8 *Buf;
+ DHCP_OPTION *Mark;
+ DHCP_OPTION *SeedOptions;
+ EFI_DHCP4_PACKET *Packet;
+ EFI_STATUS Status;
+ INTN Count;
+ UINT32 Index;
+ UINT32 Len;
+ UINT8 *Buf;
//
// Use an array of DHCP_OPTION to mark the existence
@@ -804,7 +796,7 @@ DhcpBuild (
}
for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) {
- Mark[Index].Tag = (UINT8) Index;
+ Mark[Index].Tag = (UINT8)Index;
Mark[Index].Len = 0;
}
@@ -820,7 +812,7 @@ DhcpBuild (
}
if (SeedOptions != NULL) {
- for (Index = 0; Index < (UINT32) Count; Index++) {
+ for (Index = 0; Index < (UINT32)Count; Index++) {
Mark[SeedOptions[Index].Tag] = SeedOptions[Index];
}
}
@@ -854,18 +846,18 @@ DhcpBuild (
}
}
- Status = EFI_OUT_OF_RESOURCES;
- Packet = (EFI_DHCP4_PACKET *) AllocatePool (Len);
+ Status = EFI_OUT_OF_RESOURCES;
+ Packet = (EFI_DHCP4_PACKET *)AllocatePool (Len);
if (Packet == NULL) {
goto ON_ERROR;
}
- Packet->Size = Len;
- Packet->Length = 0;
+ Packet->Size = Len;
+ Packet->Length = 0;
CopyMem (&Packet->Dhcp4.Header, &SeedPacket->Dhcp4.Header, sizeof (Packet->Dhcp4.Header));
- Packet->Dhcp4.Magik = DHCP_OPTION_MAGIC;
- Buf = Packet->Dhcp4.Option;
+ Packet->Dhcp4.Magik = DHCP_OPTION_MAGIC;
+ Buf = Packet->Dhcp4.Option;
for (Index = 0; Index < DHCP_MAX_OPTIONS; Index++) {
if (Mark[Index].Len != 0) {
@@ -873,12 +865,12 @@ DhcpBuild (
}
}
- *(Buf++) = DHCP4_TAG_EOP;
- Packet->Length = sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)
- + (UINT32) (Buf - Packet->Dhcp4.Option);
+ *(Buf++) = DHCP4_TAG_EOP;
+ Packet->Length = sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)
+ + (UINT32)(Buf - Packet->Dhcp4.Option);
- *NewPacket = Packet;
- Status = EFI_SUCCESS;
+ *NewPacket = Packet;
+ Status = EFI_SUCCESS;
ON_ERROR:
if (SeedOptions != NULL) {
diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Option.h b/NetworkPkg/Dhcp4Dxe/Dhcp4Option.h
index a58bb1b..3234d14 100644
--- a/NetworkPkg/Dhcp4Dxe/Dhcp4Option.h
+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Option.h
@@ -13,49 +13,48 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// DHCP option tags (types)
///
-#define DHCP_OPTION_MAGIC 0x63538263 // Network byte order
-#define DHCP_MAX_OPTIONS 256
-
+#define DHCP_OPTION_MAGIC 0x63538263 // Network byte order
+#define DHCP_MAX_OPTIONS 256
//
// DHCP option types, this is used to validate the DHCP options.
//
-#define DHCP_OPTION_SWITCH 1
-#define DHCP_OPTION_INT8 2
-#define DHCP_OPTION_INT16 3
-#define DHCP_OPTION_INT32 4
-#define DHCP_OPTION_IP 5
-#define DHCP_OPTION_IPPAIR 6
+#define DHCP_OPTION_SWITCH 1
+#define DHCP_OPTION_INT8 2
+#define DHCP_OPTION_INT16 3
+#define DHCP_OPTION_INT32 4
+#define DHCP_OPTION_IP 5
+#define DHCP_OPTION_IPPAIR 6
//
// Value of DHCP overload option
//
-#define DHCP_OVERLOAD_FILENAME 1
-#define DHCP_OVERLOAD_SVRNAME 2
-#define DHCP_OVERLOAD_BOTH 3
+#define DHCP_OVERLOAD_FILENAME 1
+#define DHCP_OVERLOAD_SVRNAME 2
+#define DHCP_OVERLOAD_BOTH 3
///
/// The DHCP option structure. This structure extends the EFI_DHCP_OPTION
/// structure to support options longer than 255 bytes, such as classless route.
///
typedef struct {
- UINT8 Tag;
- UINT16 Len;
- UINT8 *Data;
+ UINT8 Tag;
+ UINT16 Len;
+ UINT8 *Data;
} DHCP_OPTION;
///
/// Structures used to parse the DHCP options with RFC3396 support.
///
typedef struct {
- UINT8 Index;
- UINT16 Offset;
+ UINT8 Index;
+ UINT16 Offset;
} DHCP_OPTION_COUNT;
typedef struct {
- DHCP_OPTION_COUNT *OpCount;
- DHCP_OPTION *Options;
- UINT8 *Buf;
+ DHCP_OPTION_COUNT *OpCount;
+ DHCP_OPTION *Options;
+ UINT8 *Buf;
} DHCP_OPTION_CONTEXT;
///
@@ -64,18 +63,18 @@ typedef struct {
/// classless route, who can parse the DHCP offer to get them.
///
typedef struct {
- IP4_ADDR NetMask; // DHCP4_TAG_NETMASK
- IP4_ADDR Router; // DHCP4_TAG_ROUTER, only the first router is used
+ IP4_ADDR NetMask; // DHCP4_TAG_NETMASK
+ IP4_ADDR Router; // DHCP4_TAG_ROUTER, only the first router is used
//
// DHCP specific options
//
- UINT8 DhcpType; // DHCP4_TAG_MSG_TYPE
- UINT8 Overload; // DHCP4_TAG_OVERLOAD
- IP4_ADDR ServerId; // DHCP4_TAG_SERVER_ID
- UINT32 Lease; // DHCP4_TAG_LEASE
- UINT32 T1; // DHCP4_TAG_T1
- UINT32 T2; // DHCP4_TAG_T2
+ UINT8 DhcpType; // DHCP4_TAG_MSG_TYPE
+ UINT8 Overload; // DHCP4_TAG_OVERLOAD
+ IP4_ADDR ServerId; // DHCP4_TAG_SERVER_ID
+ UINT32 Lease; // DHCP4_TAG_LEASE
+ UINT32 T1; // DHCP4_TAG_T1
+ UINT32 T2; // DHCP4_TAG_T2
} DHCP_PARAMETER;
///
@@ -87,20 +86,20 @@ typedef struct {
/// inspect the option to parse DHCP_PARAMETER.
///
typedef struct {
- UINT8 Tag;
- INTN Type;
- INTN MinOccur;
- INTN MaxOccur;
- BOOLEAN Alert;
+ UINT8 Tag;
+ INTN Type;
+ INTN MinOccur;
+ INTN MaxOccur;
+ BOOLEAN Alert;
} DHCP_OPTION_FORMAT;
typedef
EFI_STATUS
(*DHCP_CHECK_OPTION) (
- IN UINT8 Tag,
- IN UINT8 Len,
- IN UINT8 *Data,
- IN VOID *Context
+ IN UINT8 Tag,
+ IN UINT8 Len,
+ IN UINT8 *Data,
+ IN VOID *Context
);
/**
@@ -120,9 +119,9 @@ EFI_STATUS
**/
EFI_STATUS
DhcpIterateOptions (
- IN EFI_DHCP4_PACKET *Packet,
- IN DHCP_CHECK_OPTION Check OPTIONAL,
- IN VOID *Context
+ IN EFI_DHCP4_PACKET *Packet,
+ IN DHCP_CHECK_OPTION Check OPTIONAL,
+ IN VOID *Context
);
/**
@@ -139,8 +138,8 @@ DhcpIterateOptions (
**/
EFI_STATUS
DhcpValidateOptions (
- IN EFI_DHCP4_PACKET *Packet,
- OUT DHCP_PARAMETER **Para OPTIONAL
+ IN EFI_DHCP4_PACKET *Packet,
+ OUT DHCP_PARAMETER **Para OPTIONAL
);
/**
@@ -173,9 +172,9 @@ DhcpValidateOptions (
**/
EFI_STATUS
DhcpParseOption (
- IN EFI_DHCP4_PACKET *Packet,
- OUT INTN *Count,
- OUT DHCP_OPTION **OptionPoint
+ IN EFI_DHCP4_PACKET *Packet,
+ OUT INTN *Count,
+ OUT DHCP_OPTION **OptionPoint
);
/**
@@ -192,10 +191,10 @@ DhcpParseOption (
**/
UINT8 *
DhcpAppendOption (
- OUT UINT8 *Buf,
- IN UINT8 Tag,
- IN UINT16 DataLen,
- IN UINT8 *Data
+ OUT UINT8 *Buf,
+ IN UINT8 Tag,
+ IN UINT16 DataLen,
+ IN UINT8 *Data
);
/**
@@ -217,12 +216,12 @@ DhcpAppendOption (
**/
EFI_STATUS
DhcpBuild (
- IN EFI_DHCP4_PACKET *SeedPacket,
- IN UINT32 DeleteCount,
- IN UINT8 *DeleteList OPTIONAL,
- IN UINT32 AppendCount,
- IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
- OUT EFI_DHCP4_PACKET **NewPacket
+ IN EFI_DHCP4_PACKET *SeedPacket,
+ IN UINT32 DeleteCount,
+ IN UINT8 *DeleteList OPTIONAL,
+ IN UINT32 AppendCount,
+ IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
+ OUT EFI_DHCP4_PACKET **NewPacket
);
#endif