NetworkPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the NetworkPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
2f88bd3a12
commit
d1050b9dff
@@ -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.
|
||||
|
@@ -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;
|
||||
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.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;
|
||||
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;
|
||||
|
||||
//
|
||||
|
@@ -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
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -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;
|
||||
UINT32 Signature;
|
||||
EFI_DHCP4_PROTOCOL Dhcp4Protocol;
|
||||
LIST_ENTRY Link;
|
||||
EFI_HANDLE Handle;
|
||||
DHCP_SERVICE *Service;
|
||||
|
||||
BOOLEAN InDestroy;
|
||||
BOOLEAN InDestroy;
|
||||
|
||||
EFI_EVENT CompletionEvent;
|
||||
EFI_EVENT RenewRebindEvent;
|
||||
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;
|
||||
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
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
@@ -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},
|
||||
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_IPFORWARD, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_NONLOCAL_SRR, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_POLICY_SRR, DHCP_OPTION_IPPAIR, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_EMTU, DHCP_OPTION_INT16, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_TTL, DHCP_OPTION_INT8, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_PATHMTU_AGE, DHCP_OPTION_INT32, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_PATHMTU_PLATEAU, DHCP_OPTION_INT16, 1, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_IFMTU, DHCP_OPTION_INT16, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_SUBNET_LOCAL, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_BROADCAST, DHCP_OPTION_IP, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_DISCOVER_MASK, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_SUPPLY_MASK, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_DISCOVER_ROUTE, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_ROUTER_SOLICIT, DHCP_OPTION_IP, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_STATIC_ROUTE, DHCP_OPTION_IPPAIR, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_IFMTU, DHCP_OPTION_INT16, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_SUBNET_LOCAL, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_BROADCAST, DHCP_OPTION_IP, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_DISCOVER_MASK, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_SUPPLY_MASK, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_DISCOVER_ROUTE, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_ROUTER_SOLICIT, DHCP_OPTION_IP, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_STATIC_ROUTE, DHCP_OPTION_IPPAIR, 1, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_TRAILER, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_ARPAGE, DHCP_OPTION_INT32, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_ETHER_ENCAP, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{ DHCP4_TAG_TRAILER, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_ARPAGE, DHCP_OPTION_INT32, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_ETHER_ENCAP, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
|
||||
{DHCP4_TAG_TCP_TTL, DHCP_OPTION_INT8, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_KEEP_INTERVAL, DHCP_OPTION_INT32, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_KEEP_GARBAGE, DHCP_OPTION_SWITCH, 1, 1 , FALSE},
|
||||
{ DHCP4_TAG_TCP_TTL, DHCP_OPTION_INT8, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_KEEP_INTERVAL, DHCP_OPTION_INT32, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_KEEP_GARBAGE, DHCP_OPTION_SWITCH, 1, 1, FALSE },
|
||||
|
||||
{DHCP4_TAG_NIS_DOMAIN, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NIS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NTP_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_VENDOR, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NBNS, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NBDD, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NBTYPE, DHCP_OPTION_INT8, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_NBSCOPE, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_XFONT, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_XDM, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_NIS_DOMAIN, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NIS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NTP_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_VENDOR, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NBNS, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NBDD, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NBTYPE, DHCP_OPTION_INT8, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_NBSCOPE, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_XFONT, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_XDM, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_REQUEST_IP, DHCP_OPTION_IP, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_LEASE, DHCP_OPTION_INT32, 1, 1 , TRUE},
|
||||
{DHCP4_TAG_OVERLOAD, DHCP_OPTION_INT8, 1, 1 , TRUE},
|
||||
{DHCP4_TAG_MSG_TYPE, DHCP_OPTION_INT8, 1, 1 , TRUE},
|
||||
{DHCP4_TAG_SERVER_ID, DHCP_OPTION_IP, 1, 1 , TRUE},
|
||||
{DHCP4_TAG_PARA_LIST, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_MESSAGE, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_MAXMSG, DHCP_OPTION_INT16, 1, 1 , FALSE},
|
||||
{DHCP4_TAG_T1, DHCP_OPTION_INT32, 1, 1 , TRUE},
|
||||
{DHCP4_TAG_T2, DHCP_OPTION_INT32, 1, 1 , TRUE},
|
||||
{DHCP4_TAG_VENDOR_CLASS_ID,DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_CLIENT_ID, DHCP_OPTION_INT8, 2, -1 , FALSE},
|
||||
{ DHCP4_TAG_REQUEST_IP, DHCP_OPTION_IP, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_LEASE, DHCP_OPTION_INT32, 1, 1, TRUE },
|
||||
{ DHCP4_TAG_OVERLOAD, DHCP_OPTION_INT8, 1, 1, TRUE },
|
||||
{ DHCP4_TAG_MSG_TYPE, DHCP_OPTION_INT8, 1, 1, TRUE },
|
||||
{ DHCP4_TAG_SERVER_ID, DHCP_OPTION_IP, 1, 1, TRUE },
|
||||
{ DHCP4_TAG_PARA_LIST, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_MESSAGE, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_MAXMSG, DHCP_OPTION_INT16, 1, 1, FALSE },
|
||||
{ DHCP4_TAG_T1, DHCP_OPTION_INT32, 1, 1, TRUE },
|
||||
{ DHCP4_TAG_T2, DHCP_OPTION_INT32, 1, 1, TRUE },
|
||||
{ DHCP4_TAG_VENDOR_CLASS_ID, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_CLIENT_ID, DHCP_OPTION_INT8, 2, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_NISPLUS, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NISPLUS_SERVER, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_NISPLUS, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NISPLUS_SERVER, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_TFTP, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_BOOTFILE, DHCP_OPTION_INT8, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_TFTP, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_BOOTFILE, DHCP_OPTION_INT8, 1, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_MOBILEIP, DHCP_OPTION_IP, 0, -1 , FALSE},
|
||||
{DHCP4_TAG_SMTP, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_POP3, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_NNTP, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_WWW, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_FINGER, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_IRC, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_STTALK, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{DHCP4_TAG_STDA, DHCP_OPTION_IP, 1, -1 , FALSE},
|
||||
{ DHCP4_TAG_MOBILEIP, DHCP_OPTION_IP, 0, -1, FALSE },
|
||||
{ DHCP4_TAG_SMTP, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_POP3, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_NNTP, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_WWW, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_FINGER, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_IRC, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_STTALK, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
{ DHCP4_TAG_STDA, DHCP_OPTION_IP, 1, -1, FALSE },
|
||||
|
||||
{DHCP4_TAG_CLASSLESS_ROUTE,DHCP_OPTION_INT8, 5, -1 , FALSE},
|
||||
{ DHCP4_TAG_CLASSLESS_ROUTE, DHCP_OPTION_INT8, 5, -1, FALSE },
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Binary search the DhcpOptionFormats array to find the format
|
||||
information about a specific option.
|
||||
@@ -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;
|
||||
|
||||
case DHCP4_TAG_SERVER_ID:
|
||||
Para->ServerId = NetGetUint32 (Data);
|
||||
break;
|
||||
if ((Para->DhcpType < 1) || (Para->DhcpType > 9)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
case DHCP4_TAG_T1:
|
||||
Para->T1 = NetGetUint32 (Data);
|
||||
break;
|
||||
break;
|
||||
|
||||
case DHCP4_TAG_T2:
|
||||
Para->T2 = NetGetUint32 (Data);
|
||||
break;
|
||||
case DHCP4_TAG_SERVER_ID:
|
||||
Para->ServerId = 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) {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user