diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:07 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | d1050b9dff1cace252aff86630bfdb59dff5f507 (patch) | |
tree | 77f796143980742d97a883f62ce339a270474801 /NetworkPkg/Mtftp4Dxe | |
parent | 2f88bd3a1296c522317f1c21377876de63de5be7 (diff) | |
download | edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.tar.gz edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.tar.bz2 edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.zip |
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/Mtftp4Dxe')
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/ComponentName.c | 54 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c | 145 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Driver.h | 22 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Impl.c | 287 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Impl.h | 125 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Option.c | 152 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Option.h | 53 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Rrq.c | 268 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Support.c | 247 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Support.h | 55 | ||||
-rw-r--r-- | NetworkPkg/Mtftp4Dxe/Mtftp4Wrq.c | 170 |
11 files changed, 751 insertions, 827 deletions
diff --git a/NetworkPkg/Mtftp4Dxe/ComponentName.c b/NetworkPkg/Mtftp4Dxe/ComponentName.c index 8b84caf113..2455a28d27 100644 --- a/NetworkPkg/Mtftp4Dxe/ComponentName.c +++ b/NetworkPkg/Mtftp4Dxe/ComponentName.c @@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// EFI Component Name Functions
//
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -55,10 +56,9 @@ EFIAPI Mtftp4ComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ 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 +130,13 @@ Mtftp4ComponentNameGetDriverName ( EFI_STATUS
EFIAPI
Mtftp4ComponentNameGetControllerName (
- 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 +149,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMtftp4ComponentName ///
/// EFI Component Name 2 Protocol
///
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Mtftp4ComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Mtftp4ComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Mtftp4ComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Mtftp4ComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[] = {
{
"eng;en",
L"MTFTP4 Network Service"
@@ -168,7 +166,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[] }
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gMtftp4ControllerNameTable = NULL;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gMtftp4ControllerNameTable = NULL;
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -214,7 +212,7 @@ EFIAPI Mtftp4ComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
@@ -238,12 +236,12 @@ Mtftp4ComponentNameGetDriverName ( **/
EFI_STATUS
UpdateName (
- IN EFI_MTFTP4_PROTOCOL *Mtftp4
+ IN EFI_MTFTP4_PROTOCOL *Mtftp4
)
{
- EFI_STATUS Status;
- CHAR16 HandleName[80];
- EFI_MTFTP4_MODE_DATA ModeData;
+ EFI_STATUS Status;
+ CHAR16 HandleName[80];
+ EFI_MTFTP4_MODE_DATA ModeData;
if (Mtftp4 == NULL) {
return EFI_INVALID_PARAMETER;
@@ -258,7 +256,9 @@ UpdateName ( return Status;
}
- UnicodeSPrint (HandleName, sizeof (HandleName),
+ UnicodeSPrint (
+ HandleName,
+ sizeof (HandleName),
L"MTFTPv4 (ServerIp=%d.%d.%d.%d, ServerPort=%d)",
ModeData.ConfigData.ServerIp.Addr[0],
ModeData.ConfigData.ServerIp.Addr[1],
@@ -363,15 +363,15 @@ UpdateName ( EFI_STATUS
EFIAPI
Mtftp4ComponentNameGetControllerName (
- 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_MTFTP4_PROTOCOL *Mtftp4;
+ EFI_STATUS Status;
+ EFI_MTFTP4_PROTOCOL *Mtftp4;
//
// Only provide names for child handles.
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c b/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c index a795d26247..b19192bfc2 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c @@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "Mtftp4Impl.h"
-EFI_DRIVER_BINDING_PROTOCOL gMtftp4DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gMtftp4DriverBinding = {
Mtftp4DriverBindingSupported,
Mtftp4DriverBindingStart,
Mtftp4DriverBindingStop,
@@ -22,7 +22,6 @@ EFI_SERVICE_BINDING_PROTOCOL gMtftp4ServiceBindingTemplete = { Mtftp4ServiceBindingDestroyChild
};
-
/**
The driver entry point which installs multiple protocols to the ImageHandle.
@@ -36,8 +35,8 @@ EFI_SERVICE_BINDING_PROTOCOL gMtftp4ServiceBindingTemplete = { EFI_STATUS
EFIAPI
Mtftp4DriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (
@@ -50,7 +49,6 @@ Mtftp4DriverEntryPoint ( );
}
-
/**
Test whether MTFTP driver support this controller.
@@ -75,9 +73,9 @@ Mtftp4DriverEntryPoint ( EFI_STATUS
EFIAPI
Mtftp4DriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
@@ -94,7 +92,6 @@ Mtftp4DriverBindingSupported ( return Status;
}
-
/**
Config a NULL UDP that is used to keep the connection between UDP and MTFTP.
@@ -110,14 +107,13 @@ Mtftp4DriverBindingSupported ( EFI_STATUS
EFIAPI
Mtftp4ConfigNullUdp (
- IN UDP_IO *UdpIo,
- IN VOID *Context
+ IN UDP_IO *UdpIo,
+ IN VOID *Context
)
{
return EFI_SUCCESS;
}
-
/**
Create then initialize a MTFTP service binding instance.
@@ -136,16 +132,16 @@ Mtftp4ConfigNullUdp ( **/
EFI_STATUS
Mtftp4CreateService (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Image,
- OUT MTFTP4_SERVICE **Service
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Image,
+ OUT MTFTP4_SERVICE **Service
)
{
- MTFTP4_SERVICE *MtftpSb;
- EFI_STATUS Status;
+ MTFTP4_SERVICE *MtftpSb;
+ EFI_STATUS Status;
- *Service = NULL;
- MtftpSb = AllocatePool (sizeof (MTFTP4_SERVICE));
+ *Service = NULL;
+ MtftpSb = AllocatePool (sizeof (MTFTP4_SERVICE));
if (MtftpSb == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -229,7 +225,6 @@ Mtftp4CreateService ( return EFI_SUCCESS;
}
-
/**
Release all the resource used the MTFTP service binding instance.
@@ -238,7 +233,7 @@ Mtftp4CreateService ( **/
VOID
Mtftp4CleanService (
- IN MTFTP4_SERVICE *MtftpSb
+ IN MTFTP4_SERVICE *MtftpSb
)
{
UdpIoFreeIo (MtftpSb->ConnectUdp);
@@ -247,7 +242,6 @@ Mtftp4CleanService ( gBS->CloseEvent (MtftpSb->Timer);
}
-
/**
Start the MTFTP driver on this controller.
@@ -272,8 +266,8 @@ Mtftp4DriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- MTFTP4_SERVICE *MtftpSb;
- EFI_STATUS Status;
+ MTFTP4_SERVICE *MtftpSb;
+ EFI_STATUS Status;
//
// Directly return if driver is already running.
@@ -296,6 +290,7 @@ Mtftp4DriverBindingStart ( if (EFI_ERROR (Status)) {
return Status;
}
+
ASSERT (MtftpSb != NULL);
Status = gBS->SetTimer (MtftpSb->Timer, TimerPeriodic, TICKS_PER_SECOND);
@@ -346,8 +341,8 @@ ON_ERROR: EFI_STATUS
EFIAPI
Mtftp4DestroyChildEntryInHandleBuffer (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
MTFTP4_PROTOCOL *Instance;
@@ -355,14 +350,14 @@ Mtftp4DestroyChildEntryInHandleBuffer ( UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
- if (Entry == NULL || Context == NULL) {
+ if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Instance = NET_LIST_USER_STRUCT_S (Entry, MTFTP4_PROTOCOL, Link, MTFTP4_PROTOCOL_SIGNATURE);
- ServiceBinding = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
- NumberOfChildren = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
- ChildHandleBuffer = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
+ Instance = NET_LIST_USER_STRUCT_S (Entry, MTFTP4_PROTOCOL, Link, MTFTP4_PROTOCOL_SIGNATURE);
+ ServiceBinding = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
+ NumberOfChildren = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
+ ChildHandleBuffer = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (Instance->Handle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS;
@@ -387,18 +382,18 @@ Mtftp4DestroyChildEntryInHandleBuffer ( EFI_STATUS
EFIAPI
Mtftp4DriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- MTFTP4_SERVICE *MtftpSb;
- EFI_HANDLE NicHandle;
- EFI_STATUS Status;
- LIST_ENTRY *List;
- MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ MTFTP4_SERVICE *MtftpSb;
+ EFI_HANDLE NicHandle;
+ EFI_STATUS Status;
+ LIST_ENTRY *List;
+ MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
//
// MTFTP driver opens UDP child, So, Controller is a UDP
@@ -414,7 +409,7 @@ Mtftp4DriverBindingStop ( Status = gBS->OpenProtocol (
NicHandle,
&gEfiMtftp4ServiceBindingProtocolGuid,
- (VOID **) &ServiceBinding,
+ (VOID **)&ServiceBinding,
This->DriverBindingHandle,
NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -430,19 +425,19 @@ Mtftp4DriverBindingStop ( //
// Destroy the Mtftp4 child instance in ChildHandleBuffer.
//
- List = &MtftpSb->Children;
+ List = &MtftpSb->Children;
Context.ServiceBinding = ServiceBinding;
Context.NumberOfChildren = NumberOfChildren;
Context.ChildHandleBuffer = ChildHandleBuffer;
- Status = NetDestroyLinkList (
- List,
- Mtftp4DestroyChildEntryInHandleBuffer,
- &Context,
- NULL
- );
+ Status = NetDestroyLinkList (
+ List,
+ Mtftp4DestroyChildEntryInHandleBuffer,
+ &Context,
+ NULL
+ );
}
- if (NumberOfChildren == 0 && IsListEmpty (&MtftpSb->Children)) {
+ if ((NumberOfChildren == 0) && IsListEmpty (&MtftpSb->Children)) {
gBS->UninstallProtocolInterface (
NicHandle,
&gEfiMtftp4ServiceBindingProtocolGuid,
@@ -454,6 +449,7 @@ Mtftp4DriverBindingStop ( FreeUnicodeStringTable (gMtftp4ControllerNameTable);
gMtftp4ControllerNameTable = NULL;
}
+
FreePool (MtftpSb);
Status = EFI_SUCCESS;
@@ -462,7 +458,6 @@ Mtftp4DriverBindingStop ( return Status;
}
-
/**
Initialize a MTFTP protocol instance which is the child of MtftpSb.
@@ -472,8 +467,8 @@ Mtftp4DriverBindingStop ( **/
VOID
Mtftp4InitProtocol (
- IN MTFTP4_SERVICE *MtftpSb,
- OUT MTFTP4_PROTOCOL *Instance
+ IN MTFTP4_SERVICE *MtftpSb,
+ OUT MTFTP4_PROTOCOL *Instance
)
{
ZeroMem (Instance, sizeof (MTFTP4_PROTOCOL));
@@ -481,13 +476,12 @@ Mtftp4InitProtocol ( Instance->Signature = MTFTP4_PROTOCOL_SIGNATURE;
InitializeListHead (&Instance->Link);
CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4));
- Instance->State = MTFTP4_STATE_UNCONFIGED;
- Instance->Service = MtftpSb;
+ Instance->State = MTFTP4_STATE_UNCONFIGED;
+ Instance->Service = MtftpSb;
InitializeListHead (&Instance->Blocks);
}
-
/**
Create a MTFTP child for the service binding instance, then
install the MTFTP protocol to the ChildHandle.
@@ -504,14 +498,14 @@ EFI_STATUS EFIAPI
Mtftp4ServiceBindingCreateChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE *ChildHandle
+ IN EFI_HANDLE *ChildHandle
)
{
- MTFTP4_SERVICE *MtftpSb;
- MTFTP4_PROTOCOL *Instance;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- VOID *Udp4;
+ MTFTP4_SERVICE *MtftpSb;
+ MTFTP4_PROTOCOL *Instance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ VOID *Udp4;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -556,7 +550,7 @@ Mtftp4ServiceBindingCreateChild ( return Status;
}
- Instance->Handle = *ChildHandle;
+ Instance->Handle = *ChildHandle;
//
// Open the Udp4 protocol BY_CHILD.
@@ -564,7 +558,7 @@ Mtftp4ServiceBindingCreateChild ( Status = gBS->OpenProtocol (
MtftpSb->ConnectUdp->UdpHandle,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Udp4,
+ (VOID **)&Udp4,
gMtftp4DriverBinding.DriverBindingHandle,
Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -579,7 +573,7 @@ Mtftp4ServiceBindingCreateChild ( Status = gBS->OpenProtocol (
Instance->UnicastPort->UdpHandle,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Udp4,
+ (VOID **)&Udp4,
gMtftp4DriverBinding.DriverBindingHandle,
Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -625,7 +619,6 @@ ON_ERROR: return Status;
}
-
/**
Destroy one of the service binding's child.
@@ -641,15 +634,15 @@ ON_ERROR: EFI_STATUS
EFIAPI
Mtftp4ServiceBindingDestroyChild (
- IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ChildHandle
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ChildHandle
)
{
- MTFTP4_SERVICE *MtftpSb;
- MTFTP4_PROTOCOL *Instance;
- EFI_MTFTP4_PROTOCOL *Mtftp4;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ MTFTP4_SERVICE *MtftpSb;
+ MTFTP4_PROTOCOL *Instance;
+ EFI_MTFTP4_PROTOCOL *Mtftp4;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -661,7 +654,7 @@ Mtftp4ServiceBindingDestroyChild ( Status = gBS->OpenProtocol (
ChildHandle,
&gEfiMtftp4ProtocolGuid,
- (VOID **) &Mtftp4,
+ (VOID **)&Mtftp4,
gMtftp4DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -671,8 +664,8 @@ Mtftp4ServiceBindingDestroyChild ( return EFI_UNSUPPORTED;
}
- Instance = MTFTP4_PROTOCOL_FROM_THIS (Mtftp4);
- MtftpSb = MTFTP4_SERVICE_FROM_THIS (This);
+ Instance = MTFTP4_PROTOCOL_FROM_THIS (Mtftp4);
+ MtftpSb = MTFTP4_SERVICE_FROM_THIS (This);
if (Instance->Service != MtftpSb) {
return EFI_INVALID_PARAMETER;
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.h b/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.h index 6637c5a93e..82761876d1 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.h +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.h @@ -37,9 +37,9 @@ extern EFI_UNICODE_STRING_TABLE *gMtftp4ControllerNameTable; EFI_STATUS
EFIAPI
Mtftp4DriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -82,10 +82,10 @@ Mtftp4DriverBindingStart ( EFI_STATUS
EFIAPI
Mtftp4DriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
/**
@@ -104,7 +104,7 @@ EFI_STATUS EFIAPI
Mtftp4ServiceBindingCreateChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE *ChildHandle
+ IN EFI_HANDLE *ChildHandle
);
/**
@@ -122,10 +122,8 @@ Mtftp4ServiceBindingCreateChild ( EFI_STATUS
EFIAPI
Mtftp4ServiceBindingDestroyChild (
- IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ChildHandle
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ChildHandle
);
-
-
#endif
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Impl.c b/NetworkPkg/Mtftp4Dxe/Mtftp4Impl.c index 4bb37224cd..211ddbcdcc 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Impl.c +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Impl.c @@ -7,10 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "Mtftp4Impl.h"
-
/**
Clean up the MTFTP session to get ready for new operation.
@@ -20,14 +18,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
VOID
Mtftp4CleanOperation (
- IN OUT MTFTP4_PROTOCOL *Instance,
- IN EFI_STATUS Result
+ IN OUT MTFTP4_PROTOCOL *Instance,
+ IN EFI_STATUS Result
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- MTFTP4_BLOCK_RANGE *Block;
- EFI_MTFTP4_TOKEN *Token;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ MTFTP4_BLOCK_RANGE *Block;
+ EFI_MTFTP4_TOKEN *Token;
//
// Free various resources.
@@ -71,7 +69,7 @@ Mtftp4CleanOperation ( ZeroMem (&Instance->RequestOption, sizeof (MTFTP4_OPTION));
- Instance->Operation = 0;
+ Instance->Operation = 0;
Instance->BlkSize = MTFTP4_DEFAULT_BLKSIZE;
Instance->WindowSize = 1;
@@ -91,7 +89,6 @@ Mtftp4CleanOperation ( Instance->Master = TRUE;
}
-
/**
Check packet for GetInfo.
@@ -109,47 +106,48 @@ Mtftp4CleanOperation ( EFI_STATUS
EFIAPI
Mtftp4GetInfoCheckPacket (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_TOKEN *Token,
- IN UINT16 PacketLen,
- IN EFI_MTFTP4_PACKET *Packet
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token,
+ IN UINT16 PacketLen,
+ IN EFI_MTFTP4_PACKET *Packet
)
{
- MTFTP4_GETINFO_STATE *State;
- EFI_STATUS Status;
- UINT16 OpCode;
+ MTFTP4_GETINFO_STATE *State;
+ EFI_STATUS Status;
+ UINT16 OpCode;
EFI_MTFTP4_ERROR_HEADER *ErrorHeader;
- State = (MTFTP4_GETINFO_STATE *) Token->Context;
- OpCode = NTOHS (Packet->OpCode);
+ State = (MTFTP4_GETINFO_STATE *)Token->Context;
+ OpCode = NTOHS (Packet->OpCode);
//
// Set the GetInfo's return status according to the OpCode.
//
switch (OpCode) {
- case EFI_MTFTP4_OPCODE_ERROR:
- ErrorHeader = (EFI_MTFTP4_ERROR_HEADER *) Packet;
- if (ErrorHeader->ErrorCode == EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND) {
- DEBUG ((DEBUG_ERROR, "TFTP error code 1 (File Not Found)\n"));
- } else {
- DEBUG ((DEBUG_ERROR, "TFTP error code %d\n", ErrorHeader->ErrorCode));
- }
- State->Status = EFI_TFTP_ERROR;
- break;
-
- case EFI_MTFTP4_OPCODE_OACK:
- State->Status = EFI_SUCCESS;
- break;
-
- default:
- State->Status = EFI_PROTOCOL_ERROR;
+ case EFI_MTFTP4_OPCODE_ERROR:
+ ErrorHeader = (EFI_MTFTP4_ERROR_HEADER *)Packet;
+ if (ErrorHeader->ErrorCode == EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND) {
+ DEBUG ((DEBUG_ERROR, "TFTP error code 1 (File Not Found)\n"));
+ } else {
+ DEBUG ((DEBUG_ERROR, "TFTP error code %d\n", ErrorHeader->ErrorCode));
+ }
+
+ State->Status = EFI_TFTP_ERROR;
+ break;
+
+ case EFI_MTFTP4_OPCODE_OACK:
+ State->Status = EFI_SUCCESS;
+ break;
+
+ default:
+ State->Status = EFI_PROTOCOL_ERROR;
}
//
// Allocate buffer then copy the packet over. Use gBS->AllocatePool
// in case AllocatePool will implements something tricky.
//
- Status = gBS->AllocatePool (EfiBootServicesData, PacketLen, (VOID **) State->Packet);
+ Status = gBS->AllocatePool (EfiBootServicesData, PacketLen, (VOID **)State->Packet);
if (EFI_ERROR (Status)) {
State->Status = EFI_OUT_OF_RESOURCES;
@@ -162,7 +160,6 @@ Mtftp4GetInfoCheckPacket ( return EFI_ABORTED;
}
-
/**
Check whether the override data is valid.
@@ -179,14 +176,14 @@ Mtftp4GetInfoCheckPacket ( **/
BOOLEAN
Mtftp4OverrideValid (
- IN MTFTP4_PROTOCOL *Instance,
- IN EFI_MTFTP4_OVERRIDE_DATA *Override
+ IN MTFTP4_PROTOCOL *Instance,
+ IN EFI_MTFTP4_OVERRIDE_DATA *Override
)
{
- EFI_MTFTP4_CONFIG_DATA *Config;
- IP4_ADDR Ip;
- IP4_ADDR Netmask;
- IP4_ADDR Gateway;
+ EFI_MTFTP4_CONFIG_DATA *Config;
+ IP4_ADDR Ip;
+ IP4_ADDR Netmask;
+ IP4_ADDR Gateway;
CopyMem (&Ip, &Override->ServerIp, sizeof (IP4_ADDR));
if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
@@ -205,7 +202,7 @@ Mtftp4OverrideValid ( Netmask = NTOHL (Netmask);
Ip = NTOHL (Ip);
- if ((Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) {
+ if (((Netmask != 0) && !NetIp4IsUnicast (Gateway, Netmask)) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) {
return FALSE;
}
}
@@ -213,7 +210,6 @@ Mtftp4OverrideValid ( return TRUE;
}
-
/**
Poll the UDP to get the IP4 default address, which may be retrieved
by DHCP.
@@ -231,15 +227,15 @@ Mtftp4OverrideValid ( **/
BOOLEAN
Mtftp4GetMapping (
- IN MTFTP4_PROTOCOL *Instance,
- IN UDP_IO *UdpIo,
- IN EFI_UDP4_CONFIG_DATA *UdpCfgData
+ IN MTFTP4_PROTOCOL *Instance,
+ IN UDP_IO *UdpIo,
+ IN EFI_UDP4_CONFIG_DATA *UdpCfgData
)
{
- MTFTP4_SERVICE *Service;
- EFI_IP4_MODE_DATA Ip4Mode;
- EFI_UDP4_PROTOCOL *Udp;
- EFI_STATUS Status;
+ MTFTP4_SERVICE *Service;
+ EFI_IP4_MODE_DATA Ip4Mode;
+ EFI_UDP4_PROTOCOL *Udp;
+ EFI_STATUS Status;
ASSERT (Instance->Config.UseDefaultSetting);
@@ -259,17 +255,16 @@ Mtftp4GetMapping ( Udp->Poll (Udp);
if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) &&
- Ip4Mode.IsConfigured) {
-
+ Ip4Mode.IsConfigured)
+ {
Udp->Configure (Udp, NULL);
- return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
+ return (BOOLEAN)(Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
}
}
return FALSE;
}
-
/**
Configure the UDP port for unicast receiving.
@@ -282,14 +277,14 @@ Mtftp4GetMapping ( **/
EFI_STATUS
Mtftp4ConfigUnicastPort (
- IN UDP_IO *UdpIo,
- IN MTFTP4_PROTOCOL *Instance
+ IN UDP_IO *UdpIo,
+ IN MTFTP4_PROTOCOL *Instance
)
{
- EFI_MTFTP4_CONFIG_DATA *Config;
- EFI_UDP4_CONFIG_DATA UdpConfig;
- EFI_STATUS Status;
- IP4_ADDR Ip;
+ EFI_MTFTP4_CONFIG_DATA *Config;
+ EFI_UDP4_CONFIG_DATA UdpConfig;
+ EFI_STATUS Status;
+ IP4_ADDR Ip;
Config = &Instance->Config;
@@ -305,8 +300,8 @@ Mtftp4ConfigUnicastPort ( UdpConfig.UseDefaultAddress = Config->UseDefaultSetting;
IP4_COPY_ADDRESS (&UdpConfig.StationAddress, &Config->StationIp);
IP4_COPY_ADDRESS (&UdpConfig.SubnetMask, &Config->SubnetMask);
- UdpConfig.StationPort = Config->LocalPort;
- UdpConfig.RemotePort = 0;
+ UdpConfig.StationPort = Config->LocalPort;
+ UdpConfig.RemotePort = 0;
Ip = HTONL (Instance->ServerIp);
IP4_COPY_ADDRESS (&UdpConfig.RemoteAddress, &Ip);
@@ -333,10 +328,10 @@ Mtftp4ConfigUnicastPort ( UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, NULL);
}
}
+
return Status;
}
-
/**
Start the MTFTP session to do the operation, such as read file,
write file, and read directory.
@@ -353,9 +348,9 @@ Mtftp4ConfigUnicastPort ( **/
EFI_STATUS
Mtftp4Start (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_TOKEN *Token,
- IN UINT16 Operation
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token,
+ IN UINT16 Operation
)
{
MTFTP4_PROTOCOL *Instance;
@@ -369,7 +364,8 @@ Mtftp4Start ( // Validate the parameters
//
if ((This == NULL) || (Token == NULL) || (Token->Filename == NULL) ||
- ((Token->OptionCount != 0) && (Token->OptionList == NULL))) {
+ ((Token->OptionCount != 0) && (Token->OptionList == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -377,7 +373,8 @@ Mtftp4Start ( // User must provide at least one method to collect the data for download.
//
if (((Operation == EFI_MTFTP4_OPCODE_RRQ) || (Operation == EFI_MTFTP4_OPCODE_DIR)) &&
- ((Token->Buffer == NULL) && (Token->CheckPacket == NULL))) {
+ ((Token->Buffer == NULL) && (Token->CheckPacket == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -385,7 +382,8 @@ Mtftp4Start ( // User must provide at least one method to provide the data for upload.
//
if ((Operation == EFI_MTFTP4_OPCODE_WRQ) &&
- ((Token->Buffer == NULL) && (Token->PacketNeeded == NULL))) {
+ ((Token->Buffer == NULL) && (Token->PacketNeeded == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -438,30 +436,30 @@ Mtftp4Start ( //
// Set the operation parameters from the configuration or override data.
//
- Config = &Instance->Config;
- Instance->Token = Token;
- Instance->BlkSize = MTFTP4_DEFAULT_BLKSIZE;
- Instance->WindowSize = MTFTP4_DEFAULT_WINDOWSIZE;
+ Config = &Instance->Config;
+ Instance->Token = Token;
+ Instance->BlkSize = MTFTP4_DEFAULT_BLKSIZE;
+ Instance->WindowSize = MTFTP4_DEFAULT_WINDOWSIZE;
CopyMem (&Instance->ServerIp, &Config->ServerIp, sizeof (IP4_ADDR));
- Instance->ServerIp = NTOHL (Instance->ServerIp);
+ Instance->ServerIp = NTOHL (Instance->ServerIp);
Instance->ListeningPort = Config->InitialServerPort;
Instance->ConnectedPort = 0;
CopyMem (&Instance->Gateway, &Config->GatewayIp, sizeof (IP4_ADDR));
- Instance->Gateway = NTOHL (Instance->Gateway);
+ Instance->Gateway = NTOHL (Instance->Gateway);
- Instance->MaxRetry = Config->TryCount;
- Instance->Timeout = Config->TimeoutValue;
- Instance->Master = TRUE;
+ Instance->MaxRetry = Config->TryCount;
+ Instance->Timeout = Config->TimeoutValue;
+ Instance->Master = TRUE;
if (Override != NULL) {
CopyMem (&Instance->ServerIp, &Override->ServerIp, sizeof (IP4_ADDR));
CopyMem (&Instance->Gateway, &Override->GatewayIp, sizeof (IP4_ADDR));
- Instance->ServerIp = NTOHL (Instance->ServerIp);
- Instance->Gateway = NTOHL (Instance->Gateway);
+ Instance->ServerIp = NTOHL (Instance->ServerIp);
+ Instance->Gateway = NTOHL (Instance->Gateway);
Instance->ListeningPort = Override->ServerPort;
Instance->MaxRetry = Override->TryCount;
@@ -508,7 +506,7 @@ Mtftp4Start ( goto ON_ERROR;
}
- gBS->RestoreTPL(OldTpl);
+ gBS->RestoreTPL (OldTpl);
if (Token->Event != NULL) {
return EFI_SUCCESS;
@@ -531,7 +529,6 @@ ON_ERROR: return Status;
}
-
/**
Reads the current operational settings.
@@ -550,8 +547,8 @@ ON_ERROR: EFI_STATUS
EFIAPI
EfiMtftp4GetModeData (
- IN EFI_MTFTP4_PROTOCOL *This,
- OUT EFI_MTFTP4_MODE_DATA *ModeData
+ IN EFI_MTFTP4_PROTOCOL *This,
+ OUT EFI_MTFTP4_MODE_DATA *ModeData
)
{
MTFTP4_PROTOCOL *Instance;
@@ -563,10 +560,10 @@ EfiMtftp4GetModeData ( OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
- CopyMem(&ModeData->ConfigData, &Instance->Config, sizeof (Instance->Config));
+ Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
+ CopyMem (&ModeData->ConfigData, &Instance->Config, sizeof (Instance->Config));
ModeData->SupportedOptionCount = MTFTP4_SUPPORTED_OPTIONS;
- ModeData->SupportedOptoins = (UINT8 **) mMtftp4SupportedOptions;
+ ModeData->SupportedOptoins = (UINT8 **)mMtftp4SupportedOptions;
ModeData->UnsupportedOptionCount = 0;
ModeData->UnsupportedOptoins = NULL;
@@ -575,8 +572,6 @@ EfiMtftp4GetModeData ( return EFI_SUCCESS;
}
-
-
/**
Initializes, changes, or resets the default operational setting for this
EFI MTFTPv4 Protocol driver instance.
@@ -627,16 +622,16 @@ EfiMtftp4GetModeData ( EFI_STATUS
EFIAPI
EfiMtftp4Configure (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_CONFIG_DATA *ConfigData
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_CONFIG_DATA *ConfigData
)
{
- MTFTP4_PROTOCOL *Instance;
- EFI_TPL OldTpl;
- IP4_ADDR Ip;
- IP4_ADDR Netmask;
- IP4_ADDR Gateway;
- IP4_ADDR ServerIp;
+ MTFTP4_PROTOCOL *Instance;
+ EFI_TPL OldTpl;
+ IP4_ADDR Ip;
+ IP4_ADDR Netmask;
+ IP4_ADDR Gateway;
+ IP4_ADDR ServerIp;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -655,7 +650,6 @@ EfiMtftp4Configure ( Instance->State = MTFTP4_STATE_UNCONFIGED;
gBS->RestoreTPL (OldTpl);
-
} else {
//
// Configure the parameters for new operation.
@@ -670,19 +664,19 @@ EfiMtftp4Configure ( Gateway = NTOHL (Gateway);
ServerIp = NTOHL (ServerIp);
- if (ServerIp == 0 || IP4_IS_LOCAL_BROADCAST (ServerIp)) {
+ if ((ServerIp == 0) || IP4_IS_LOCAL_BROADCAST (ServerIp)) {
return EFI_INVALID_PARAMETER;
}
if (!ConfigData->UseDefaultSetting &&
- ((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Ip, Netmask))))) {
-
+ ((!IP4_IS_VALID_NETMASK (Netmask) || ((Netmask != 0) && !NetIp4IsUnicast (Ip, Netmask)))))
+ {
return EFI_INVALID_PARAMETER;
}
if ((Gateway != 0) &&
- ((Netmask != 0xFFFFFFFF && !IP4_NET_EQUAL (Gateway, Ip, Netmask)) || (Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)))) {
-
+ (((Netmask != 0xFFFFFFFF) && !IP4_NET_EQUAL (Gateway, Ip, Netmask)) || ((Netmask != 0) && !NetIp4IsUnicast (Gateway, Netmask))))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -693,7 +687,7 @@ EfiMtftp4Configure ( return EFI_ACCESS_DENIED;
}
- CopyMem(&Instance->Config, ConfigData, sizeof (*ConfigData));;
+ CopyMem (&Instance->Config, ConfigData, sizeof (*ConfigData));
Instance->State = MTFTP4_STATE_CONFIGED;
gBS->RestoreTPL (OldTpl);
@@ -702,8 +696,6 @@ EfiMtftp4Configure ( return EFI_SUCCESS;
}
-
-
/**
Parses the options in an MTFTPv4 OACK packet.
@@ -737,18 +729,18 @@ EfiMtftp4Configure ( EFI_STATUS
EFIAPI
EfiMtftp4ParseOptions (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN UINT32 PacketLen,
- IN EFI_MTFTP4_PACKET *Packet,
- OUT UINT32 *OptionCount,
- OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN UINT32 PacketLen,
+ IN EFI_MTFTP4_PACKET *Packet,
+ OUT UINT32 *OptionCount,
+ OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if ((This == NULL) || (PacketLen < MTFTP4_OPCODE_LEN) ||
- (Packet == NULL) || (OptionCount == NULL)) {
-
+ (Packet == NULL) || (OptionCount == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -765,7 +757,6 @@ EfiMtftp4ParseOptions ( return EFI_SUCCESS;
}
-
/**
Downloads a file from an MTFTPv4 server.
@@ -799,14 +790,13 @@ EfiMtftp4ParseOptions ( EFI_STATUS
EFIAPI
EfiMtftp4ReadFile (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_TOKEN *Token
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token
)
{
return Mtftp4Start (This, Token, EFI_MTFTP4_OPCODE_RRQ);
}
-
/**
Sends a data file to an MTFTPv4 server. May be unsupported in some EFI implementations
@@ -860,14 +850,13 @@ EfiMtftp4ReadFile ( EFI_STATUS
EFIAPI
EfiMtftp4WriteFile (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_TOKEN *Token
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token
)
{
return Mtftp4Start (This, Token, EFI_MTFTP4_OPCODE_WRQ);
}
-
/**
Downloads a data file "directory" from an MTFTPv4 server.
May be unsupported in some EFI implementations
@@ -930,14 +919,13 @@ EfiMtftp4WriteFile ( EFI_STATUS
EFIAPI
EfiMtftp4ReadDirectory (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_TOKEN *Token
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token
)
{
return Mtftp4Start (This, Token, EFI_MTFTP4_OPCODE_DIR);
}
-
/**
Gets information about a file from an MTFTPv4 server.
@@ -995,22 +983,23 @@ EfiMtftp4ReadDirectory ( EFI_STATUS
EFIAPI
EfiMtftp4GetInfo (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData OPTIONAL,
- IN UINT8 *Filename,
- IN UINT8 *ModeStr OPTIONAL,
- IN UINT8 OptionCount,
- IN EFI_MTFTP4_OPTION *OptionList OPTIONAL,
- OUT UINT32 *PacketLength,
- OUT EFI_MTFTP4_PACKET **Packet OPTIONAL
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData OPTIONAL,
+ IN UINT8 *Filename,
+ IN UINT8 *ModeStr OPTIONAL,
+ IN UINT8 OptionCount,
+ IN EFI_MTFTP4_OPTION *OptionList OPTIONAL,
+ OUT UINT32 *PacketLength,
+ OUT EFI_MTFTP4_PACKET **Packet OPTIONAL
)
{
- EFI_MTFTP4_TOKEN Token;
- MTFTP4_GETINFO_STATE State;
- EFI_STATUS Status;
+ EFI_MTFTP4_TOKEN Token;
+ MTFTP4_GETINFO_STATE State;
+ EFI_STATUS Status;
if ((This == NULL) || (Filename == NULL) || (PacketLength == NULL) ||
- ((OptionCount != 0) && (OptionList == NULL))) {
+ ((OptionCount != 0) && (OptionList == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -1018,10 +1007,10 @@ EfiMtftp4GetInfo ( *Packet = NULL;
}
- *PacketLength = 0;
- State.Packet = Packet;
- State.PacketLen = PacketLength;
- State.Status = EFI_SUCCESS;
+ *PacketLength = 0;
+ State.Packet = Packet;
+ State.PacketLen = PacketLength;
+ State.Status = EFI_SUCCESS;
//
// Fill in the Token to issue an synchronous ReadFile operation
@@ -1040,7 +1029,7 @@ EfiMtftp4GetInfo ( Token.TimeoutCallback = NULL;
Token.PacketNeeded = NULL;
- Status = EfiMtftp4ReadFile (This, &Token);
+ Status = EfiMtftp4ReadFile (This, &Token);
if (EFI_ABORTED == Status) {
return State.Status;
@@ -1076,12 +1065,12 @@ EfiMtftp4GetInfo ( EFI_STATUS
EFIAPI
EfiMtftp4Poll (
- IN EFI_MTFTP4_PROTOCOL *This
+ IN EFI_MTFTP4_PROTOCOL *This
)
{
- MTFTP4_PROTOCOL *Instance;
- EFI_UDP4_PROTOCOL *Udp;
- EFI_STATUS Status;
+ MTFTP4_PROTOCOL *Instance;
+ EFI_UDP4_PROTOCOL *Udp;
+ EFI_STATUS Status;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1095,13 +1084,13 @@ EfiMtftp4Poll ( return EFI_DEVICE_ERROR;
}
- Udp = Instance->UnicastPort->Protocol.Udp4;
+ Udp = Instance->UnicastPort->Protocol.Udp4;
Status = Udp->Poll (Udp);
Mtftp4OnTimerTick (NULL, Instance->Service);
return Status;
}
-EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate = {
+EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate = {
EfiMtftp4GetModeData,
EfiMtftp4Configure,
EfiMtftp4GetInfo,
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Impl.h b/NetworkPkg/Mtftp4Dxe/Mtftp4Impl.h index b16ac0a4a4..7789755fe8 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Impl.h +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Impl.h @@ -15,7 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#ifndef __EFI_MTFTP4_IMPL_H__
#define __EFI_MTFTP4_IMPL_H__
@@ -33,19 +32,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;
-typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;
-typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
+typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;
+typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
#include "Mtftp4Driver.h"
#include "Mtftp4Option.h"
#include "Mtftp4Support.h"
-
///
/// Some constant value of Mtftp service.
///
-#define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P')
-#define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p')
+#define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P')
+#define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p')
#define MTFTP4_DEFAULT_SERVER_PORT 69
#define MTFTP4_DEFAULT_TIMEOUT 3
@@ -54,114 +52,113 @@ typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL; #define MTFTP4_DEFAULT_WINDOWSIZE 1
#define MTFTP4_TIME_TO_GETMAP 5
-#define MTFTP4_STATE_UNCONFIGED 0
-#define MTFTP4_STATE_CONFIGED 1
-#define MTFTP4_STATE_DESTROY 2
+#define MTFTP4_STATE_UNCONFIGED 0
+#define MTFTP4_STATE_CONFIGED 1
+#define MTFTP4_STATE_DESTROY 2
///
/// Mtftp service block
///
struct _MTFTP4_SERVICE {
- UINT32 Signature;
- EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
+ UINT32 Signature;
+ EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
- UINT16 ChildrenNum;
- LIST_ENTRY Children;
+ UINT16 ChildrenNum;
+ LIST_ENTRY Children;
- EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients to handle the packet timeout case.
- EFI_EVENT TimerNotifyLevel; ///< Ticking timer for all the MTFTP clients to calculate the packet live time.
- EFI_EVENT TimerToGetMap;
+ EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients to handle the packet timeout case.
+ EFI_EVENT TimerNotifyLevel; ///< Ticking timer for all the MTFTP clients to calculate the packet live time.
+ EFI_EVENT TimerToGetMap;
- EFI_HANDLE Controller;
- EFI_HANDLE Image;
+ EFI_HANDLE Controller;
+ EFI_HANDLE Image;
//
// This UDP child is used to keep the connection between the UDP
// and MTFTP, so MTFTP will be notified when UDP is uninstalled.
//
- UDP_IO *ConnectUdp;
+ UDP_IO *ConnectUdp;
};
-
typedef struct {
- EFI_MTFTP4_PACKET **Packet;
- UINT32 *PacketLen;
- EFI_STATUS Status;
+ EFI_MTFTP4_PACKET **Packet;
+ UINT32 *PacketLen;
+ EFI_STATUS Status;
} MTFTP4_GETINFO_STATE;
struct _MTFTP4_PROTOCOL {
- UINT32 Signature;
- LIST_ENTRY Link;
- EFI_MTFTP4_PROTOCOL Mtftp4;
+ UINT32 Signature;
+ LIST_ENTRY Link;
+ EFI_MTFTP4_PROTOCOL Mtftp4;
- INTN State;
- BOOLEAN InDestroy;
+ INTN State;
+ BOOLEAN InDestroy;
- MTFTP4_SERVICE *Service;
- EFI_HANDLE Handle;
+ MTFTP4_SERVICE *Service;
+ EFI_HANDLE Handle;
- EFI_MTFTP4_CONFIG_DATA Config;
+ EFI_MTFTP4_CONFIG_DATA Config;
//
// Operation parameters: token and requested options.
//
- EFI_MTFTP4_TOKEN *Token;
- MTFTP4_OPTION RequestOption;
- UINT16 Operation;
+ EFI_MTFTP4_TOKEN *Token;
+ MTFTP4_OPTION RequestOption;
+ UINT16 Operation;
//
// Blocks is a list of MTFTP4_BLOCK_RANGE which contains
// holes in the file
//
- UINT16 BlkSize;
- UINT16 LastBlock;
- LIST_ENTRY Blocks;
+ UINT16 BlkSize;
+ UINT16 LastBlock;
+ LIST_ENTRY Blocks;
- UINT16 WindowSize;
+ UINT16 WindowSize;
//
// Record the total received and saved block number.
//
- UINT64 TotalBlock;
+ UINT64 TotalBlock;
//
// Record the acked block number.
//
- UINT64 AckedBlock;
+ UINT64 AckedBlock;
//
// The server's communication end point: IP and two ports. one for
// initial request, one for its selected port.
//
- IP4_ADDR ServerIp;
- UINT16 ListeningPort;
- UINT16 ConnectedPort;
- IP4_ADDR Gateway;
- UDP_IO *UnicastPort;
+ IP4_ADDR ServerIp;
+ UINT16 ListeningPort;
+ UINT16 ConnectedPort;
+ IP4_ADDR Gateway;
+ UDP_IO *UnicastPort;
//
// Timeout and retransmit status
//
- NET_BUF *LastPacket;
- UINT32 PacketToLive;
- BOOLEAN HasTimeout;
- UINT32 CurRetry;
- UINT32 MaxRetry;
- UINT32 Timeout;
+ NET_BUF *LastPacket;
+ UINT32 PacketToLive;
+ BOOLEAN HasTimeout;
+ UINT32 CurRetry;
+ UINT32 MaxRetry;
+ UINT32 Timeout;
//
// Parameter used by RRQ's multicast download.
//
- IP4_ADDR McastIp;
- UINT16 McastPort;
- BOOLEAN Master;
- UDP_IO *McastUdpPort;
+ IP4_ADDR McastIp;
+ UINT16 McastPort;
+ BOOLEAN Master;
+ UDP_IO *McastUdpPort;
};
typedef struct {
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- UINTN NumberOfChildren;
- EFI_HANDLE *ChildHandleBuffer;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ UINTN NumberOfChildren;
+ EFI_HANDLE *ChildHandleBuffer;
} MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
/**
@@ -173,8 +170,8 @@ typedef struct { **/
VOID
Mtftp4CleanOperation (
- IN OUT MTFTP4_PROTOCOL *Instance,
- IN EFI_STATUS Result
+ IN OUT MTFTP4_PROTOCOL *Instance,
+ IN EFI_STATUS Result
);
/**
@@ -193,8 +190,8 @@ Mtftp4CleanOperation ( **/
EFI_STATUS
Mtftp4WrqStart (
- IN MTFTP4_PROTOCOL *Instance,
- IN UINT16 Operation
+ IN MTFTP4_PROTOCOL *Instance,
+ IN UINT16 Operation
);
/**
@@ -213,8 +210,8 @@ Mtftp4WrqStart ( **/
EFI_STATUS
Mtftp4RrqStart (
- IN MTFTP4_PROTOCOL *Instance,
- IN UINT16 Operation
+ IN MTFTP4_PROTOCOL *Instance,
+ IN UINT16 Operation
);
#define MTFTP4_SERVICE_FROM_THIS(a) \
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Option.c b/NetworkPkg/Mtftp4Dxe/Mtftp4Option.c index 21c1e42139..feb8b82fbc 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Option.c +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Option.c @@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "Mtftp4Impl.h"
-CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = {
+CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = {
"blksize",
"windowsize",
"timeout",
@@ -16,7 +16,6 @@ CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = { "multicast"
};
-
/**
Check whether two ascii strings are equal, ignore the case.
@@ -29,16 +28,16 @@ CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = { **/
BOOLEAN
NetStringEqualNoCase (
- IN UINT8 *Str1,
- IN UINT8 *Str2
+ IN UINT8 *Str1,
+ IN UINT8 *Str2
)
{
- UINT8 Ch1;
- UINT8 Ch2;
+ UINT8 Ch1;
+ UINT8 Ch2;
ASSERT ((Str1 != NULL) && (Str2 != NULL));
- for (; (*Str1 != '\0') && (*Str2 != '\0'); Str1++, Str2++) {
+ for ( ; (*Str1 != '\0') && (*Str2 != '\0'); Str1++, Str2++) {
Ch1 = *Str1;
Ch2 = *Str2;
@@ -58,10 +57,9 @@ NetStringEqualNoCase ( }
}
- return (BOOLEAN) (*Str1 == *Str2);
+ return (BOOLEAN)(*Str1 == *Str2);
}
-
/**
Convert a string to a UINT32 number.
@@ -72,23 +70,22 @@ NetStringEqualNoCase ( **/
UINT32
NetStringToU32 (
- IN UINT8 *Str
+ IN UINT8 *Str
)
{
- UINT32 Num;
+ UINT32 Num;
ASSERT (Str != NULL);
Num = 0;
- for (; NET_IS_DIGIT (*Str); Str++) {
+ for ( ; NET_IS_DIGIT (*Str); Str++) {
Num = Num * 10 + (*Str - '0');
}
return Num;
}
-
/**
Convert a string of the format "192.168.0.1" to an IP address.
@@ -101,13 +98,13 @@ NetStringToU32 ( **/
EFI_STATUS
NetStringToIp (
- IN UINT8 *Str,
- OUT IP4_ADDR *Ip
+ IN UINT8 *Str,
+ OUT IP4_ADDR *Ip
)
{
- UINT32 Byte;
- UINT32 Addr;
- UINTN Index;
+ UINT32 Byte;
+ UINT32 Addr;
+ UINTN Index;
*Ip = 0;
Addr = 0;
@@ -144,7 +141,6 @@ NetStringToIp ( return EFI_SUCCESS;
}
-
/**
Go through the packet to fill the Options array with the start
addresses of each MTFTP option name/value pair.
@@ -162,21 +158,21 @@ NetStringToIp ( **/
EFI_STATUS
Mtftp4FillOptions (
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 PacketLen,
- IN OUT UINT32 *Count,
- OUT EFI_MTFTP4_OPTION *Options OPTIONAL
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 PacketLen,
+ IN OUT UINT32 *Count,
+ OUT EFI_MTFTP4_OPTION *Options OPTIONAL
)
{
- UINT8 *Cur;
- UINT8 *Last;
- UINT8 Num;
- UINT8 *Name;
- UINT8 *Value;
+ UINT8 *Cur;
+ UINT8 *Last;
+ UINT8 Num;
+ UINT8 *Name;
+ UINT8 *Value;
- Num = 0;
- Cur = (UINT8 *) Packet + MTFTP4_OPCODE_LEN;
- Last = (UINT8 *) Packet + PacketLen - 1;
+ Num = 0;
+ Cur = (UINT8 *)Packet + MTFTP4_OPCODE_LEN;
+ Last = (UINT8 *)Packet + PacketLen - 1;
//
// process option name and value pairs. The last byte is always zero
@@ -201,8 +197,8 @@ Mtftp4FillOptions ( Num++;
if ((Options != NULL) && (Num <= *Count)) {
- Options[Num - 1].OptionStr = Name;
- Options[Num - 1].ValueStr = Value;
+ Options[Num - 1].OptionStr = Name;
+ Options[Num - 1].ValueStr = Value;
}
Cur++;
@@ -217,7 +213,6 @@ Mtftp4FillOptions ( return EFI_SUCCESS;
}
-
/**
Allocate and fill in a array of Mtftp options from the Packet.
@@ -237,13 +232,13 @@ Mtftp4FillOptions ( **/
EFI_STATUS
Mtftp4ExtractOptions (
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 PacketLen,
- OUT UINT32 *OptionCount,
- OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 PacketLen,
+ OUT UINT32 *OptionCount,
+ OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
*OptionCount = 0;
@@ -262,7 +257,7 @@ Mtftp4ExtractOptions ( //
// The last byte must be zero to terminate the options
//
- if (*((UINT8 *) Packet + PacketLen - 1) != 0) {
+ if (*((UINT8 *)Packet + PacketLen - 1) != 0) {
return EFI_INVALID_PARAMETER;
}
@@ -293,7 +288,6 @@ Mtftp4ExtractOptions ( return EFI_SUCCESS;
}
-
/**
Parse the MTFTP multicast option.
@@ -306,19 +300,19 @@ Mtftp4ExtractOptions ( **/
EFI_STATUS
Mtftp4ExtractMcast (
- IN UINT8 *Value,
- IN OUT MTFTP4_OPTION *Option
+ IN UINT8 *Value,
+ IN OUT MTFTP4_OPTION *Option
)
{
- EFI_STATUS Status;
- UINT32 Num;
+ EFI_STATUS Status;
+ UINT32 Num;
//
// The multicast option is formatted like "204.0.0.1,1857,1"
// The server can also omit the ip and port, use ",,1"
//
if (*Value == ',') {
- Option->McastIp = 0;
+ Option->McastIp = 0;
} else {
Status = NetStringToIp (Value, &Option->McastIp);
@@ -350,7 +344,7 @@ Mtftp4ExtractMcast ( return EFI_INVALID_PARAMETER;
}
- Option->McastPort = (UINT16) Num;
+ Option->McastPort = (UINT16)Num;
while (NET_IS_DIGIT (*Value)) {
Value++;
@@ -372,7 +366,7 @@ Mtftp4ExtractMcast ( return EFI_INVALID_PARAMETER;
}
- Option->Master = (BOOLEAN) (Num == 1);
+ Option->Master = (BOOLEAN)(Num == 1);
while (NET_IS_DIGIT (*Value)) {
Value++;
@@ -385,7 +379,6 @@ Mtftp4ExtractMcast ( return EFI_SUCCESS;
}
-
/**
Parse the option in Options array to MTFTP4_OPTION which program
can access directly.
@@ -405,17 +398,17 @@ Mtftp4ExtractMcast ( **/
EFI_STATUS
Mtftp4ParseOption (
- IN EFI_MTFTP4_OPTION *Options,
- IN UINT32 Count,
- IN BOOLEAN Request,
- IN UINT16 Operation,
- OUT MTFTP4_OPTION *MtftpOption
+ IN EFI_MTFTP4_OPTION *Options,
+ IN UINT32 Count,
+ IN BOOLEAN Request,
+ IN UINT16 Operation,
+ OUT MTFTP4_OPTION *MtftpOption
)
{
- EFI_STATUS Status;
- UINT32 Index;
- UINT32 Value;
- EFI_MTFTP4_OPTION *This;
+ EFI_STATUS Status;
+ UINT32 Index;
+ UINT32 Value;
+ EFI_MTFTP4_OPTION *This;
MtftpOption->Exist = 0;
@@ -426,7 +419,7 @@ Mtftp4ParseOption ( return EFI_INVALID_PARAMETER;
}
- if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "blksize")) {
+ if (NetStringEqualNoCase (This->OptionStr, (UINT8 *)"blksize")) {
//
// block size option, valid value is between [8, 65464]
//
@@ -436,10 +429,9 @@ Mtftp4ParseOption ( return EFI_INVALID_PARAMETER;
}
- MtftpOption->BlkSize = (UINT16) Value;
- MtftpOption->Exist |= MTFTP4_BLKSIZE_EXIST;
-
- } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "timeout")) {
+ MtftpOption->BlkSize = (UINT16)Value;
+ MtftpOption->Exist |= MTFTP4_BLKSIZE_EXIST;
+ } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *)"timeout")) {
//
// timeout option, valid value is between [1, 255]
//
@@ -449,16 +441,14 @@ Mtftp4ParseOption ( return EFI_INVALID_PARAMETER;
}
- MtftpOption->Timeout = (UINT8) Value;
-
- } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "tsize")) {
+ MtftpOption->Timeout = (UINT8)Value;
+ } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *)"tsize")) {
//
// tsize option, the biggest transfer supported is 4GB with block size option
//
- MtftpOption->Tsize = NetStringToU32 (This->ValueStr);
+ MtftpOption->Tsize = NetStringToU32 (This->ValueStr);
MtftpOption->Exist |= MTFTP4_TSIZE_EXIST;
-
- } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "multicast")) {
+ } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *)"multicast")) {
//
// Multicast option, if it is a request, the value must be a zero
// length string, otherwise, it is formatted like "204.0.0.1,1857,1\0"
@@ -467,7 +457,6 @@ Mtftp4ParseOption ( if (*(This->ValueStr) != '\0') {
return EFI_INVALID_PARAMETER;
}
-
} else {
Status = Mtftp4ExtractMcast (This->ValueStr, MtftpOption);
@@ -477,8 +466,7 @@ Mtftp4ParseOption ( }
MtftpOption->Exist |= MTFTP4_MCAST_EXIST;
-
- } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "windowsize")) {
+ } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *)"windowsize")) {
if (Operation == EFI_MTFTP4_OPCODE_WRQ) {
//
// Currently, windowsize is not supported in the write operation.
@@ -492,8 +480,8 @@ Mtftp4ParseOption ( return EFI_INVALID_PARAMETER;
}
- MtftpOption->WindowSize = (UINT16) Value;
- MtftpOption->Exist |= MTFTP4_WINDOWSIZE_EXIST;
+ MtftpOption->WindowSize = (UINT16)Value;
+ MtftpOption->Exist |= MTFTP4_WINDOWSIZE_EXIST;
} else if (Request) {
//
// Ignore the unsupported option if it is a reply, and return
@@ -506,7 +494,6 @@ Mtftp4ParseOption ( return EFI_SUCCESS;
}
-
/**
Parse the options in the OACK packet to MTFTP4_OPTION which program
can access directly.
@@ -523,15 +510,15 @@ Mtftp4ParseOption ( **/
EFI_STATUS
Mtftp4ParseOptionOack (
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 PacketLen,
- IN UINT16 Operation,
- OUT MTFTP4_OPTION *MtftpOption
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 PacketLen,
+ IN UINT16 Operation,
+ OUT MTFTP4_OPTION *MtftpOption
)
{
- EFI_MTFTP4_OPTION *OptionList;
- EFI_STATUS Status;
- UINT32 Count;
+ EFI_MTFTP4_OPTION *OptionList;
+ EFI_STATUS Status;
+ UINT32 Count;
MtftpOption->Exist = 0;
@@ -540,6 +527,7 @@ Mtftp4ParseOptionOack ( if (EFI_ERROR (Status) || (Count == 0)) {
return Status;
}
+
ASSERT (OptionList != NULL);
Status = Mtftp4ParseOption (OptionList, Count, FALSE, Operation, MtftpOption);
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Option.h b/NetworkPkg/Mtftp4Dxe/Mtftp4Option.h index 5f37b0f7b9..9ef6fff1b6 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Option.h +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Option.h @@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#ifndef __EFI_MTFTP4_OPTION_H__
#define __EFI_MTFTP4_OPTION_H__
@@ -16,21 +15,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define MTFTP4_BLKNO_LEN 2
#define MTFTP4_DATA_HEAD_LEN 4
-#define MTFTP4_BLKSIZE_EXIST 0x01
-#define MTFTP4_TIMEOUT_EXIST 0x02
-#define MTFTP4_TSIZE_EXIST 0x04
-#define MTFTP4_MCAST_EXIST 0x08
-#define MTFTP4_WINDOWSIZE_EXIST 0x10
+#define MTFTP4_BLKSIZE_EXIST 0x01
+#define MTFTP4_TIMEOUT_EXIST 0x02
+#define MTFTP4_TSIZE_EXIST 0x04
+#define MTFTP4_MCAST_EXIST 0x08
+#define MTFTP4_WINDOWSIZE_EXIST 0x10
typedef struct {
- UINT16 BlkSize;
- UINT16 WindowSize;
- UINT8 Timeout;
- UINT32 Tsize;
- IP4_ADDR McastIp;
- UINT16 McastPort;
- BOOLEAN Master;
- UINT32 Exist;
+ UINT16 BlkSize;
+ UINT16 WindowSize;
+ UINT8 Timeout;
+ UINT32 Tsize;
+ IP4_ADDR McastIp;
+ UINT16 McastPort;
+ BOOLEAN Master;
+ UINT32 Exist;
} MTFTP4_OPTION;
/**
@@ -52,10 +51,10 @@ typedef struct { **/
EFI_STATUS
Mtftp4ExtractOptions (
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 PacketLen,
- OUT UINT32 *OptionCount,
- OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 PacketLen,
+ OUT UINT32 *OptionCount,
+ OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
);
/**
@@ -77,11 +76,11 @@ Mtftp4ExtractOptions ( **/
EFI_STATUS
Mtftp4ParseOption (
- IN EFI_MTFTP4_OPTION *Options,
- IN UINT32 Count,
- IN BOOLEAN Request,
- IN UINT16 Operation,
- OUT MTFTP4_OPTION *MtftpOption
+ IN EFI_MTFTP4_OPTION *Options,
+ IN UINT32 Count,
+ IN BOOLEAN Request,
+ IN UINT16 Operation,
+ OUT MTFTP4_OPTION *MtftpOption
);
/**
@@ -100,10 +99,10 @@ Mtftp4ParseOption ( **/
EFI_STATUS
Mtftp4ParseOptionOack (
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 PacketLen,
- IN UINT16 Operation,
- OUT MTFTP4_OPTION *MtftpOption
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 PacketLen,
+ IN UINT16 Operation,
+ OUT MTFTP4_OPTION *MtftpOption
);
extern CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS];
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Rrq.c b/NetworkPkg/Mtftp4Dxe/Mtftp4Rrq.c index f1d456a612..75aaa80617 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Rrq.c +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Rrq.c @@ -7,10 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "Mtftp4Impl.h"
-
/**
The packet process callback for MTFTP download.
@@ -23,13 +21,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent VOID
EFIAPI
Mtftp4RrqInput (
- IN NET_BUF *UdpPacket,
- IN UDP_END_POINT *EndPoint,
- IN EFI_STATUS IoStatus,
- IN VOID *Context
+ IN NET_BUF *UdpPacket,
+ IN UDP_END_POINT *EndPoint,
+ IN EFI_STATUS IoStatus,
+ IN VOID *Context
);
-
/**
Start the MTFTP session to download.
@@ -46,11 +43,11 @@ Mtftp4RrqInput ( **/
EFI_STATUS
Mtftp4RrqStart (
- IN MTFTP4_PROTOCOL *Instance,
- IN UINT16 Operation
+ IN MTFTP4_PROTOCOL *Instance,
+ IN UINT16 Operation
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// The valid block number range are [1, 0xffff]. For example:
@@ -73,7 +70,6 @@ Mtftp4RrqStart ( return UdpIoRecvDatagram (Instance->UnicastPort, Mtftp4RrqInput, Instance, 0);
}
-
/**
Build and send a ACK packet for the download session.
@@ -87,13 +83,13 @@ Mtftp4RrqStart ( **/
EFI_STATUS
Mtftp4RrqSendAck (
- IN MTFTP4_PROTOCOL *Instance,
- IN UINT16 BlkNo
+ IN MTFTP4_PROTOCOL *Instance,
+ IN UINT16 BlkNo
)
{
- EFI_MTFTP4_PACKET *Ack;
- NET_BUF *Packet;
- EFI_STATUS Status;
+ EFI_MTFTP4_PACKET *Ack;
+ NET_BUF *Packet;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
@@ -102,11 +98,11 @@ Mtftp4RrqSendAck ( return EFI_OUT_OF_RESOURCES;
}
- Ack = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (
- Packet,
- sizeof (EFI_MTFTP4_ACK_HEADER),
- FALSE
- );
+ Ack = (EFI_MTFTP4_PACKET *)NetbufAllocSpace (
+ Packet,
+ sizeof (EFI_MTFTP4_ACK_HEADER),
+ FALSE
+ );
ASSERT (Ack != NULL);
Ack->Ack.OpCode = HTONS (EFI_MTFTP4_OPCODE_ACK);
@@ -120,7 +116,6 @@ Mtftp4RrqSendAck ( return Status;
}
-
/**
Deliver the received data block to the user, which can be saved
in the user provide buffer or through the CheckPacket callback.
@@ -138,18 +133,18 @@ Mtftp4RrqSendAck ( **/
EFI_STATUS
Mtftp4RrqSaveBlock (
- IN OUT MTFTP4_PROTOCOL *Instance,
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 Len
+ IN OUT MTFTP4_PROTOCOL *Instance,
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 Len
)
{
- EFI_MTFTP4_TOKEN *Token;
- EFI_STATUS Status;
- UINT16 Block;
- UINT64 Start;
- UINT32 DataLen;
- UINT64 BlockCounter;
- BOOLEAN Completed;
+ EFI_MTFTP4_TOKEN *Token;
+ EFI_STATUS Status;
+ UINT16 Block;
+ UINT64 Start;
+ UINT32 DataLen;
+ UINT64 BlockCounter;
+ BOOLEAN Completed;
Completed = FALSE;
Token = Instance->Token;
@@ -160,7 +155,7 @@ Mtftp4RrqSaveBlock ( // This is the last block, save the block no
//
if (DataLen < Instance->BlkSize) {
- Completed = TRUE;
+ Completed = TRUE;
Instance->LastBlock = Block;
Mtftp4SetLastBlockNum (&Instance->Blocks, Block);
}
@@ -181,13 +176,13 @@ Mtftp4RrqSaveBlock ( }
if (Token->CheckPacket != NULL) {
- Status = Token->CheckPacket (&Instance->Mtftp4, Token, (UINT16) Len, Packet);
+ Status = Token->CheckPacket (&Instance->Mtftp4, Token, (UINT16)Len, Packet);
if (EFI_ERROR (Status)) {
Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION,
- (UINT8 *) "User aborted download"
+ (UINT8 *)"User aborted download"
);
return EFI_ABORTED;
@@ -195,10 +190,10 @@ Mtftp4RrqSaveBlock ( }
if (Token->Buffer != NULL) {
- Start = MultU64x32 (BlockCounter - 1, Instance->BlkSize);
+ Start = MultU64x32 (BlockCounter - 1, Instance->BlkSize);
if (Start + DataLen <= Token->BufferSize) {
- CopyMem ((UINT8 *) Token->Buffer + Start, Packet->Data.Data, DataLen);
+ CopyMem ((UINT8 *)Token->Buffer + Start, Packet->Data.Data, DataLen);
//
// Update the file size when received the last block
@@ -206,7 +201,6 @@ Mtftp4RrqSaveBlock ( if ((Instance->LastBlock == Block) && Completed) {
Token->BufferSize = Start + DataLen;
}
-
} else if (Instance->LastBlock != 0) {
//
// Don't save the data if the buffer is too small, return
@@ -218,7 +212,7 @@ Mtftp4RrqSaveBlock ( Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_DISK_FULL,
- (UINT8 *) "User provided memory block is too small"
+ (UINT8 *)"User provided memory block is too small"
);
return EFI_BUFFER_TOO_SMALL;
@@ -228,7 +222,6 @@ Mtftp4RrqSaveBlock ( return EFI_SUCCESS;
}
-
/**
Function to process the received data packets.
@@ -247,21 +240,21 @@ Mtftp4RrqSaveBlock ( **/
EFI_STATUS
Mtftp4RrqHandleData (
- IN MTFTP4_PROTOCOL *Instance,
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 Len,
- IN BOOLEAN Multicast,
- OUT BOOLEAN *Completed
+ IN MTFTP4_PROTOCOL *Instance,
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 Len,
+ IN BOOLEAN Multicast,
+ OUT BOOLEAN *Completed
)
{
- EFI_STATUS Status;
- UINT16 BlockNum;
- INTN Expected;
+ EFI_STATUS Status;
+ UINT16 BlockNum;
+ INTN Expected;
- *Completed = FALSE;
- Status = EFI_SUCCESS;
- BlockNum = NTOHS (Packet->Data.Block);
- Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);
+ *Completed = FALSE;
+ Status = EFI_SUCCESS;
+ BlockNum = NTOHS (Packet->Data.Block);
+ Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);
ASSERT (Expected >= 0);
@@ -274,7 +267,7 @@ Mtftp4RrqHandleData ( //
// If Expected is 0, (UINT16) (Expected - 1) is also the expected Ack number (65535).
//
- return Mtftp4RrqSendAck (Instance, (UINT16) (Expected - 1));
+ return Mtftp4RrqSendAck (Instance, (UINT16)(Expected - 1));
}
Status = Mtftp4RrqSaveBlock (Instance, Packet, Len);
@@ -286,7 +279,7 @@ Mtftp4RrqHandleData ( //
// Record the total received and saved block number.
//
- Instance->TotalBlock ++;
+ Instance->TotalBlock++;
//
// Reset the passive client's timer whenever it received a
@@ -314,21 +307,18 @@ Mtftp4RrqHandleData ( //
BlockNum = Instance->LastBlock;
*Completed = TRUE;
-
} else {
- BlockNum = (UINT16) (Expected - 1);
+ BlockNum = (UINT16)(Expected - 1);
}
- if (Instance->WindowSize == (Instance->TotalBlock - Instance->AckedBlock) || Expected < 0) {
+ if ((Instance->WindowSize == (Instance->TotalBlock - Instance->AckedBlock)) || (Expected < 0)) {
Status = Mtftp4RrqSendAck (Instance, BlockNum);
}
-
}
return Status;
}
-
/**
Validate whether the options received in the server's OACK packet is valid.
@@ -348,12 +338,11 @@ Mtftp4RrqHandleData ( **/
BOOLEAN
Mtftp4RrqOackValid (
- IN MTFTP4_PROTOCOL *This,
- IN MTFTP4_OPTION *Reply,
- IN MTFTP4_OPTION *Request
+ IN MTFTP4_PROTOCOL *This,
+ IN MTFTP4_OPTION *Reply,
+ IN MTFTP4_OPTION *Request
)
{
-
//
// It is invalid for server to return options we don't request
//
@@ -365,10 +354,11 @@ Mtftp4RrqOackValid ( // Server can only specify a smaller block size and window size to be used and
// return the timeout matches that requested.
//
- if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) != 0)&& (Reply->BlkSize > Request->BlkSize)) ||
- (((Reply->Exist & MTFTP4_WINDOWSIZE_EXIST) != 0)&& (Reply->WindowSize > Request->WindowSize)) ||
+ if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) != 0) && (Reply->BlkSize > Request->BlkSize)) ||
+ (((Reply->Exist & MTFTP4_WINDOWSIZE_EXIST) != 0) && (Reply->WindowSize > Request->WindowSize)) ||
(((Reply->Exist & MTFTP4_TIMEOUT_EXIST) != 0) && (Reply->Timeout != Request->Timeout))
- ) {
+ )
+ {
return FALSE;
}
@@ -390,7 +380,6 @@ Mtftp4RrqOackValid ( return TRUE;
}
-
/**
Configure a UDP IO port to receive the multicast.
@@ -405,19 +394,19 @@ Mtftp4RrqOackValid ( EFI_STATUS
EFIAPI
Mtftp4RrqConfigMcastPort (
- IN UDP_IO *McastIo,
- IN VOID *Context
+ IN UDP_IO *McastIo,
+ IN VOID *Context
)
{
- MTFTP4_PROTOCOL *Instance;
- EFI_MTFTP4_CONFIG_DATA *Config;
- EFI_UDP4_CONFIG_DATA UdpConfig;
- EFI_IPv4_ADDRESS Group;
- EFI_STATUS Status;
- IP4_ADDR Ip;
+ MTFTP4_PROTOCOL *Instance;
+ EFI_MTFTP4_CONFIG_DATA *Config;
+ EFI_UDP4_CONFIG_DATA UdpConfig;
+ EFI_IPv4_ADDRESS Group;
+ EFI_STATUS Status;
+ IP4_ADDR Ip;
- Instance = (MTFTP4_PROTOCOL *) Context;
- Config = &Instance->Config;
+ Instance = (MTFTP4_PROTOCOL *)Context;
+ Config = &Instance->Config;
UdpConfig.AcceptBroadcast = FALSE;
UdpConfig.AcceptPromiscuous = FALSE;
@@ -431,8 +420,8 @@ Mtftp4RrqConfigMcastPort ( UdpConfig.UseDefaultAddress = Config->UseDefaultSetting;
IP4_COPY_ADDRESS (&UdpConfig.StationAddress, &Config->StationIp);
IP4_COPY_ADDRESS (&UdpConfig.SubnetMask, &Config->SubnetMask);
- UdpConfig.StationPort = Instance->McastPort;
- UdpConfig.RemotePort = 0;
+ UdpConfig.StationPort = Instance->McastPort;
+ UdpConfig.RemotePort = 0;
Ip = HTONL (Instance->ServerIp);
IP4_COPY_ADDRESS (&UdpConfig.RemoteAddress, &Ip);
@@ -444,7 +433,8 @@ Mtftp4RrqConfigMcastPort ( }
if (!Config->UseDefaultSetting &&
- !EFI_IP4_EQUAL (&mZeroIp4Addr, &Config->GatewayIp)) {
+ !EFI_IP4_EQUAL (&mZeroIp4Addr, &Config->GatewayIp))
+ {
//
// The station IP address is manually configured and the Gateway IP is not 0.
// Add the default route for this UDP instance.
@@ -472,7 +462,6 @@ Mtftp4RrqConfigMcastPort ( return McastIo->Protocol.Udp4->Groups (McastIo->Protocol.Udp4, TRUE, &Group);
}
-
/**
Function to process the OACK.
@@ -492,17 +481,17 @@ Mtftp4RrqConfigMcastPort ( **/
EFI_STATUS
Mtftp4RrqHandleOack (
- IN OUT MTFTP4_PROTOCOL *Instance,
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 Len,
- IN BOOLEAN Multicast,
- OUT BOOLEAN *Completed
+ IN OUT MTFTP4_PROTOCOL *Instance,
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 Len,
+ IN BOOLEAN Multicast,
+ OUT BOOLEAN *Completed
)
{
- MTFTP4_OPTION Reply;
- EFI_STATUS Status;
- INTN Expected;
- EFI_UDP4_PROTOCOL *Udp4;
+ MTFTP4_OPTION Reply;
+ EFI_STATUS Status;
+ INTN Expected;
+ EFI_UDP4_PROTOCOL *Udp4;
*Completed = FALSE;
@@ -525,7 +514,8 @@ Mtftp4RrqHandleOack ( Status = Mtftp4ParseOptionOack (Packet, Len, Instance->Operation, &Reply);
if (EFI_ERROR (Status) ||
- !Mtftp4RrqOackValid (Instance, &Reply, &Instance->RequestOption)) {
+ !Mtftp4RrqOackValid (Instance, &Reply, &Instance->RequestOption))
+ {
//
// Don't send an ERROR packet if the error is EFI_OUT_OF_RESOURCES.
//
@@ -533,7 +523,7 @@ Mtftp4RrqHandleOack ( Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION,
- (UINT8 *) "Malformatted OACK packet"
+ (UINT8 *)"Malformatted OACK packet"
);
}
@@ -541,7 +531,6 @@ Mtftp4RrqHandleOack ( }
if ((Reply.Exist & MTFTP4_MCAST_EXIST) != 0) {
-
//
// Save the multicast info. Always update the Master, only update the
// multicast IP address, block size, window size, timeout at the first time.
@@ -554,7 +543,7 @@ Mtftp4RrqHandleOack ( Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION,
- (UINT8 *) "Illegal multicast setting"
+ (UINT8 *)"Illegal multicast setting"
);
return EFI_TFTP_ERROR;
@@ -563,8 +552,8 @@ Mtftp4RrqHandleOack ( //
// Create a UDP child then start receive the multicast from it.
//
- Instance->McastIp = Reply.McastIp;
- Instance->McastPort = Reply.McastPort;
+ Instance->McastIp = Reply.McastIp;
+ Instance->McastPort = Reply.McastPort;
if (Instance->McastUdpPort == NULL) {
Instance->McastUdpPort = UdpIoCreateIo (
Instance->Service->Controller,
@@ -577,7 +566,7 @@ Mtftp4RrqHandleOack ( Status = gBS->OpenProtocol (
Instance->McastUdpPort->UdpHandle,
&gEfiUdp4ProtocolGuid,
- (VOID **) &Udp4,
+ (VOID **)&Udp4,
Instance->Service->Image,
Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -590,7 +579,6 @@ Mtftp4RrqHandleOack ( }
}
-
if (Instance->McastUdpPort == NULL) {
return EFI_DEVICE_ERROR;
}
@@ -601,7 +589,7 @@ Mtftp4RrqHandleOack ( Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION,
- (UINT8 *) "Failed to create socket to receive multicast packet"
+ (UINT8 *)"Failed to create socket to receive multicast packet"
);
return Status;
@@ -622,7 +610,6 @@ Mtftp4RrqHandleOack ( Instance->Timeout = Reply.Timeout;
}
}
-
} else {
Instance->Master = TRUE;
@@ -643,10 +630,9 @@ Mtftp4RrqHandleOack ( // Send an ACK to (Expected - 1) which is 0 for unicast download,
// or tell the server we want to receive the Expected block.
//
- return Mtftp4RrqSendAck (Instance, (UINT16) (Expected - 1));
+ return Mtftp4RrqSendAck (Instance, (UINT16)(Expected - 1));
}
-
/**
The packet process callback for MTFTP download.
@@ -659,21 +645,21 @@ Mtftp4RrqHandleOack ( VOID
EFIAPI
Mtftp4RrqInput (
- IN NET_BUF *UdpPacket,
- IN UDP_END_POINT *EndPoint,
- IN EFI_STATUS IoStatus,
- IN VOID *Context
+ IN NET_BUF *UdpPacket,
+ IN UDP_END_POINT *EndPoint,
+ IN EFI_STATUS IoStatus,
+ IN VOID *Context
)
{
- MTFTP4_PROTOCOL *Instance;
- EFI_MTFTP4_PACKET *Packet;
- BOOLEAN Completed;
- BOOLEAN Multicast;
- EFI_STATUS Status;
- UINT16 Opcode;
- UINT32 Len;
-
- Instance = (MTFTP4_PROTOCOL *) Context;
+ MTFTP4_PROTOCOL *Instance;
+ EFI_MTFTP4_PACKET *Packet;
+ BOOLEAN Completed;
+ BOOLEAN Multicast;
+ EFI_STATUS Status;
+ UINT16 Opcode;
+ UINT32 Len;
+
+ Instance = (MTFTP4_PROTOCOL *)Context;
NET_CHECK_SIGNATURE (Instance, MTFTP4_PROTOCOL_SIGNATURE);
Status = EFI_SUCCESS;
@@ -691,7 +677,7 @@ Mtftp4RrqInput ( //
// Find the port this packet is from to restart receive correctly.
//
- Multicast = (BOOLEAN) (EndPoint->LocalAddr.Addr[0] == Instance->McastIp);
+ Multicast = (BOOLEAN)(EndPoint->LocalAddr.Addr[0] == Instance->McastIp);
if (UdpPacket->TotalSize < MTFTP4_OPCODE_LEN) {
goto ON_EXIT;
@@ -724,10 +710,9 @@ Mtftp4RrqInput ( goto ON_EXIT;
}
- NetbufCopy (UdpPacket, 0, Len, (UINT8 *) Packet);
-
+ NetbufCopy (UdpPacket, 0, Len, (UINT8 *)Packet);
} else {
- Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL);
+ Packet = (EFI_MTFTP4_PACKET *)NetbufGetByte (UdpPacket, 0, NULL);
ASSERT (Packet != NULL);
}
@@ -738,12 +723,12 @@ Mtftp4RrqInput ( // if CheckPacket returns an EFI_ERROR code.
//
if ((Instance->Token->CheckPacket != NULL) &&
- ((Opcode == EFI_MTFTP4_OPCODE_OACK) || (Opcode == EFI_MTFTP4_OPCODE_ERROR))) {
-
+ ((Opcode == EFI_MTFTP4_OPCODE_OACK) || (Opcode == EFI_MTFTP4_OPCODE_ERROR)))
+ {
Status = Instance->Token->CheckPacket (
&Instance->Mtftp4,
Instance->Token,
- (UINT16) Len,
+ (UINT16)Len,
Packet
);
@@ -755,7 +740,7 @@ Mtftp4RrqInput ( Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
- (UINT8 *) "User aborted the transfer"
+ (UINT8 *)"User aborted the transfer"
);
}
@@ -765,29 +750,30 @@ Mtftp4RrqInput ( }
switch (Opcode) {
- case EFI_MTFTP4_OPCODE_DATA:
- if ((Len > (UINT32) (MTFTP4_DATA_HEAD_LEN + Instance->BlkSize)) ||
- (Len < (UINT32) MTFTP4_DATA_HEAD_LEN)) {
- goto ON_EXIT;
- }
+ case EFI_MTFTP4_OPCODE_DATA:
+ if ((Len > (UINT32)(MTFTP4_DATA_HEAD_LEN + Instance->BlkSize)) ||
+ (Len < (UINT32)MTFTP4_DATA_HEAD_LEN))
+ {
+ goto ON_EXIT;
+ }
- Status = Mtftp4RrqHandleData (Instance, Packet, Len, Multicast, &Completed);
- break;
+ Status = Mtftp4RrqHandleData (Instance, Packet, Len, Multicast, &Completed);
+ break;
- case EFI_MTFTP4_OPCODE_OACK:
- if (Multicast || (Len <= MTFTP4_OPCODE_LEN)) {
- goto ON_EXIT;
- }
+ case EFI_MTFTP4_OPCODE_OACK:
+ if (Multicast || (Len <= MTFTP4_OPCODE_LEN)) {
+ goto ON_EXIT;
+ }
- Status = Mtftp4RrqHandleOack (Instance, Packet, Len, Multicast, &Completed);
- break;
+ Status = Mtftp4RrqHandleOack (Instance, Packet, Len, Multicast, &Completed);
+ break;
- case EFI_MTFTP4_OPCODE_ERROR:
- Status = EFI_TFTP_ERROR;
- break;
+ case EFI_MTFTP4_OPCODE_ERROR:
+ Status = EFI_TFTP_ERROR;
+ break;
- default:
- break;
+ default:
+ break;
}
ON_EXIT:
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Support.c b/NetworkPkg/Mtftp4Dxe/Mtftp4Support.c index 6ca4842107..d303083977 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Support.c +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Support.c @@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "Mtftp4Impl.h"
-
/**
Allocate a MTFTP4 block range, then init it to the range of [Start, End]
@@ -20,11 +19,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
MTFTP4_BLOCK_RANGE *
Mtftp4AllocateRange (
- IN UINT16 Start,
- IN UINT16 End
+ IN UINT16 Start,
+ IN UINT16 End
)
{
- MTFTP4_BLOCK_RANGE *Range;
+ MTFTP4_BLOCK_RANGE *Range;
Range = AllocateZeroPool (sizeof (MTFTP4_BLOCK_RANGE));
@@ -33,14 +32,13 @@ Mtftp4AllocateRange ( }
InitializeListHead (&Range->Link);
- Range->Start = Start;
- Range->End = End;
- Range->Bound = End;
+ Range->Start = Start;
+ Range->End = End;
+ Range->Bound = End;
return Range;
}
-
/**
Initialize the block range for either RRQ or WRQ.
@@ -64,12 +62,12 @@ Mtftp4AllocateRange ( **/
EFI_STATUS
Mtftp4InitBlockRange (
- IN LIST_ENTRY *Head,
- IN UINT16 Start,
- IN UINT16 End
+ IN LIST_ENTRY *Head,
+ IN UINT16 Start,
+ IN UINT16 End
)
{
- MTFTP4_BLOCK_RANGE *Range;
+ MTFTP4_BLOCK_RANGE *Range;
Range = Mtftp4AllocateRange (Start, End);
@@ -81,7 +79,6 @@ Mtftp4InitBlockRange ( return EFI_SUCCESS;
}
-
/**
Get the first valid block number on the range list.
@@ -92,7 +89,7 @@ Mtftp4InitBlockRange ( **/
INTN
Mtftp4GetNextBlockNum (
- IN LIST_ENTRY *Head
+ IN LIST_ENTRY *Head
)
{
MTFTP4_BLOCK_RANGE *Range;
@@ -105,7 +102,6 @@ Mtftp4GetNextBlockNum ( return Range->Start;
}
-
/**
Set the last block number of the block range list.
@@ -119,11 +115,11 @@ Mtftp4GetNextBlockNum ( **/
VOID
Mtftp4SetLastBlockNum (
- IN LIST_ENTRY *Head,
- IN UINT16 Last
+ IN LIST_ENTRY *Head,
+ IN UINT16 Last
)
{
- MTFTP4_BLOCK_RANGE *Range;
+ MTFTP4_BLOCK_RANGE *Range;
//
// Iterate from the tail to head to remove the block number
@@ -142,11 +138,10 @@ Mtftp4SetLastBlockNum ( Range->End = Last;
}
- return ;
+ return;
}
}
-
/**
Remove the block number from the block range list.
@@ -162,18 +157,17 @@ Mtftp4SetLastBlockNum ( **/
EFI_STATUS
Mtftp4RemoveBlockNum (
- IN LIST_ENTRY *Head,
- IN UINT16 Num,
- IN BOOLEAN Completed,
- OUT UINT64 *BlockCounter
+ IN LIST_ENTRY *Head,
+ IN UINT16 Num,
+ IN BOOLEAN Completed,
+ OUT UINT64 *BlockCounter
)
{
- MTFTP4_BLOCK_RANGE *Range;
- MTFTP4_BLOCK_RANGE *NewRange;
- LIST_ENTRY *Entry;
+ MTFTP4_BLOCK_RANGE *Range;
+ MTFTP4_BLOCK_RANGE *NewRange;
+ LIST_ENTRY *Entry;
NET_LIST_FOR_EACH (Entry, Head) {
-
//
// Each block represents a hole [Start, End] in the file,
// skip to the first range with End >= Num
@@ -202,7 +196,6 @@ Mtftp4RemoveBlockNum ( //
if (Range->Start > Num) {
return EFI_NOT_FOUND;
-
} else if (Range->Start == Num) {
Range->Start++;
@@ -214,15 +207,15 @@ Mtftp4RemoveBlockNum ( // wrap to zero, because this is the simplest to implement. Here we choose
// this solution.
//
- *BlockCounter = Num;
+ *BlockCounter = Num;
if (Range->Round > 0) {
- *BlockCounter += Range->Bound + MultU64x32 ((UINTN) (Range->Round -1), (UINT32) (Range->Bound + 1)) + 1;
+ *BlockCounter += Range->Bound + MultU64x32 ((UINTN)(Range->Round -1), (UINT32)(Range->Bound + 1)) + 1;
}
if (Range->Start > Range->Bound) {
Range->Start = 0;
- Range->Round ++;
+ Range->Round++;
}
if ((Range->Start > Range->End) || Completed) {
@@ -231,12 +224,11 @@ Mtftp4RemoveBlockNum ( }
return EFI_SUCCESS;
-
} else {
if (Range->End == Num) {
Range->End--;
} else {
- NewRange = Mtftp4AllocateRange ((UINT16) (Num + 1), (UINT16) Range->End);
+ NewRange = Mtftp4AllocateRange ((UINT16)(Num + 1), (UINT16)Range->End);
if (NewRange == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -253,7 +245,6 @@ Mtftp4RemoveBlockNum ( return EFI_NOT_FOUND;
}
-
/**
Build then transmit the request packet for the MTFTP session.
@@ -266,43 +257,44 @@ Mtftp4RemoveBlockNum ( **/
EFI_STATUS
Mtftp4SendRequest (
- IN MTFTP4_PROTOCOL *Instance
+ IN MTFTP4_PROTOCOL *Instance
)
{
- EFI_MTFTP4_PACKET *Packet;
- EFI_MTFTP4_OPTION *Options;
- EFI_MTFTP4_TOKEN *Token;
- RETURN_STATUS Status;
- NET_BUF *Nbuf;
- UINT8 *Mode;
- UINT8 *Cur;
- UINTN Index;
- UINT32 BufferLength;
- UINTN FileNameLength;
- UINTN ModeLength;
- UINTN OptionStrLength;
- UINTN ValueStrLength;
+ EFI_MTFTP4_PACKET *Packet;
+ EFI_MTFTP4_OPTION *Options;
+ EFI_MTFTP4_TOKEN *Token;
+ RETURN_STATUS Status;
+ NET_BUF *Nbuf;
+ UINT8 *Mode;
+ UINT8 *Cur;
+ UINTN Index;
+ UINT32 BufferLength;
+ UINTN FileNameLength;
+ UINTN ModeLength;
+ UINTN OptionStrLength;
+ UINTN ValueStrLength;
Token = Instance->Token;
Options = Token->OptionList;
Mode = Instance->Token->ModeStr;
if (Mode == NULL) {
- Mode = (UINT8 *) "octet";
+ Mode = (UINT8 *)"octet";
}
//
// Compute the packet length
//
- FileNameLength = AsciiStrLen ((CHAR8 *) Token->Filename);
- ModeLength = AsciiStrLen ((CHAR8 *) Mode);
- BufferLength = (UINT32) FileNameLength + (UINT32) ModeLength + 4;
+ FileNameLength = AsciiStrLen ((CHAR8 *)Token->Filename);
+ ModeLength = AsciiStrLen ((CHAR8 *)Mode);
+ BufferLength = (UINT32)FileNameLength + (UINT32)ModeLength + 4;
for (Index = 0; Index < Token->OptionCount; Index++) {
- OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);
- ValueStrLength = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);
- BufferLength += (UINT32) OptionStrLength + (UINT32) ValueStrLength + 2;
+ OptionStrLength = AsciiStrLen ((CHAR8 *)Options[Index].OptionStr);
+ ValueStrLength = AsciiStrLen ((CHAR8 *)Options[Index].ValueStr);
+ BufferLength += (UINT32)OptionStrLength + (UINT32)ValueStrLength + 2;
}
+
//
// Allocate a packet then copy the data over
//
@@ -310,42 +302,40 @@ Mtftp4SendRequest ( return EFI_OUT_OF_RESOURCES;
}
- Packet = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (Nbuf, BufferLength, FALSE);
+ Packet = (EFI_MTFTP4_PACKET *)NetbufAllocSpace (Nbuf, BufferLength, FALSE);
ASSERT (Packet != NULL);
Packet->OpCode = HTONS (Instance->Operation);
BufferLength -= sizeof (Packet->OpCode);
- Cur = Packet->Rrq.Filename;
- Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Token->Filename);
+ Cur = Packet->Rrq.Filename;
+ Status = AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Token->Filename);
ASSERT_EFI_ERROR (Status);
- BufferLength -= (UINT32) (FileNameLength + 1);
- Cur += FileNameLength + 1;
- Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Mode);
+ BufferLength -= (UINT32)(FileNameLength + 1);
+ Cur += FileNameLength + 1;
+ Status = AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Mode);
ASSERT_EFI_ERROR (Status);
- BufferLength -= (UINT32) (ModeLength + 1);
- Cur += ModeLength + 1;
+ BufferLength -= (UINT32)(ModeLength + 1);
+ Cur += ModeLength + 1;
for (Index = 0; Index < Token->OptionCount; ++Index) {
- OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);
- ValueStrLength = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);
+ OptionStrLength = AsciiStrLen ((CHAR8 *)Options[Index].OptionStr);
+ ValueStrLength = AsciiStrLen ((CHAR8 *)Options[Index].ValueStr);
- Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].OptionStr);
+ Status = AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Options[Index].OptionStr);
ASSERT_EFI_ERROR (Status);
- BufferLength -= (UINT32) (OptionStrLength + 1);
- Cur += OptionStrLength + 1;
+ BufferLength -= (UINT32)(OptionStrLength + 1);
+ Cur += OptionStrLength + 1;
- Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].ValueStr);
+ Status = AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Options[Index].ValueStr);
ASSERT_EFI_ERROR (Status);
- BufferLength -= (UINT32) (ValueStrLength + 1);
- Cur += ValueStrLength + 1;
-
+ BufferLength -= (UINT32)(ValueStrLength + 1);
+ Cur += ValueStrLength + 1;
}
return Mtftp4SendPacket (Instance, Nbuf);
}
-
/**
Build then send an error message.
@@ -360,33 +350,32 @@ Mtftp4SendRequest ( **/
EFI_STATUS
Mtftp4SendError (
- IN MTFTP4_PROTOCOL *Instance,
- IN UINT16 ErrCode,
- IN UINT8 *ErrInfo
+ IN MTFTP4_PROTOCOL *Instance,
+ IN UINT16 ErrCode,
+ IN UINT8 *ErrInfo
)
{
- NET_BUF *Packet;
- EFI_MTFTP4_PACKET *TftpError;
- UINT32 Len;
+ NET_BUF *Packet;
+ EFI_MTFTP4_PACKET *TftpError;
+ UINT32 Len;
- Len = (UINT32) (AsciiStrLen ((CHAR8 *) ErrInfo) + sizeof (EFI_MTFTP4_ERROR_HEADER));
- Packet = NetbufAlloc (Len);
+ Len = (UINT32)(AsciiStrLen ((CHAR8 *)ErrInfo) + sizeof (EFI_MTFTP4_ERROR_HEADER));
+ Packet = NetbufAlloc (Len);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- TftpError = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (Packet, Len, FALSE);
+ TftpError = (EFI_MTFTP4_PACKET *)NetbufAllocSpace (Packet, Len, FALSE);
ASSERT (TftpError != NULL);
- TftpError->OpCode = HTONS (EFI_MTFTP4_OPCODE_ERROR);
+ TftpError->OpCode = HTONS (EFI_MTFTP4_OPCODE_ERROR);
TftpError->Error.ErrorCode = HTONS (ErrCode);
- AsciiStrCpyS ((CHAR8 *) TftpError->Error.ErrorMessage, Len, (CHAR8 *) ErrInfo);
+ AsciiStrCpyS ((CHAR8 *)TftpError->Error.ErrorMessage, Len, (CHAR8 *)ErrInfo);
return Mtftp4SendPacket (Instance, Packet);
}
-
/**
The callback function called when the packet is transmitted.
@@ -401,16 +390,15 @@ Mtftp4SendError ( VOID
EFIAPI
Mtftp4OnPacketSent (
- IN NET_BUF *Packet,
- IN UDP_END_POINT *EndPoint,
- IN EFI_STATUS IoStatus,
- IN VOID *Context
+ IN NET_BUF *Packet,
+ IN UDP_END_POINT *EndPoint,
+ IN EFI_STATUS IoStatus,
+ IN VOID *Context
)
{
NetbufFree (Packet);
}
-
/**
Set the timeout for the instance. User a longer time for passive instances.
@@ -419,7 +407,7 @@ Mtftp4OnPacketSent ( **/
VOID
Mtftp4SetTimeout (
- IN OUT MTFTP4_PROTOCOL *Instance
+ IN OUT MTFTP4_PROTOCOL *Instance
)
{
if (Instance->Master) {
@@ -429,7 +417,6 @@ Mtftp4SetTimeout ( }
}
-
/**
Send the packet for the instance.
@@ -446,14 +433,14 @@ Mtftp4SetTimeout ( **/
EFI_STATUS
Mtftp4SendPacket (
- IN OUT MTFTP4_PROTOCOL *Instance,
- IN OUT NET_BUF *Packet
+ IN OUT MTFTP4_PROTOCOL *Instance,
+ IN OUT NET_BUF *Packet
)
{
- UDP_END_POINT UdpPoint;
- EFI_STATUS Status;
- UINT16 OpCode;
- UINT8 *Buffer;
+ UDP_END_POINT UdpPoint;
+ EFI_STATUS Status;
+ UINT16 OpCode;
+ UINT8 *Buffer;
//
// Save the packet for retransmission
@@ -462,9 +449,9 @@ Mtftp4SendPacket ( NetbufFree (Instance->LastPacket);
}
- Instance->LastPacket = Packet;
+ Instance->LastPacket = Packet;
- Instance->CurRetry = 0;
+ Instance->CurRetry = 0;
Mtftp4SetTimeout (Instance);
ZeroMem (&UdpPoint, sizeof (UdpPoint));
@@ -480,7 +467,8 @@ Mtftp4SendPacket ( if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) ||
(OpCode == EFI_MTFTP4_OPCODE_DIR) ||
- (OpCode == EFI_MTFTP4_OPCODE_WRQ)) {
+ (OpCode == EFI_MTFTP4_OPCODE_WRQ))
+ {
UdpPoint.RemotePort = Instance->ListeningPort;
} else {
UdpPoint.RemotePort = Instance->ConnectedPort;
@@ -504,7 +492,6 @@ Mtftp4SendPacket ( return Status;
}
-
/**
Retransmit the last packet for the instance.
@@ -516,13 +503,13 @@ Mtftp4SendPacket ( **/
EFI_STATUS
Mtftp4Retransmit (
- IN MTFTP4_PROTOCOL *Instance
+ IN MTFTP4_PROTOCOL *Instance
)
{
- UDP_END_POINT UdpPoint;
- EFI_STATUS Status;
- UINT16 OpCode;
- UINT8 *Buffer;
+ UDP_END_POINT UdpPoint;
+ EFI_STATUS Status;
+ UINT16 OpCode;
+ UINT8 *Buffer;
ASSERT (Instance->LastPacket != NULL);
@@ -534,10 +521,11 @@ Mtftp4Retransmit ( //
Buffer = NetbufGetByte (Instance->LastPacket, 0, NULL);
ASSERT (Buffer != NULL);
- OpCode = NTOHS (*(UINT16 *) Buffer);
+ OpCode = NTOHS (*(UINT16 *)Buffer);
if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) || (OpCode == EFI_MTFTP4_OPCODE_DIR) ||
- (OpCode == EFI_MTFTP4_OPCODE_WRQ)) {
+ (OpCode == EFI_MTFTP4_OPCODE_WRQ))
+ {
UdpPoint.RemotePort = Instance->ListeningPort;
} else {
UdpPoint.RemotePort = Instance->ConnectedPort;
@@ -561,7 +549,6 @@ Mtftp4Retransmit ( return Status;
}
-
/**
The timer ticking function in TPL_NOTIFY level for the Mtftp service instance.
@@ -572,16 +559,16 @@ Mtftp4Retransmit ( VOID
EFIAPI
Mtftp4OnTimerTickNotifyLevel (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- MTFTP4_SERVICE *MtftpSb;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- MTFTP4_PROTOCOL *Instance;
+ MTFTP4_SERVICE *MtftpSb;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ MTFTP4_PROTOCOL *Instance;
- MtftpSb = (MTFTP4_SERVICE *) Context;
+ MtftpSb = (MTFTP4_SERVICE *)Context;
//
// Iterate through all the children of the Mtftp service instance. Time
@@ -597,7 +584,6 @@ Mtftp4OnTimerTickNotifyLevel ( }
}
-
/**
The timer ticking function for the Mtftp service instance.
@@ -608,17 +594,17 @@ Mtftp4OnTimerTickNotifyLevel ( VOID
EFIAPI
Mtftp4OnTimerTick (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- MTFTP4_SERVICE *MtftpSb;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- MTFTP4_PROTOCOL *Instance;
- EFI_MTFTP4_TOKEN *Token;
+ MTFTP4_SERVICE *MtftpSb;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ MTFTP4_PROTOCOL *Instance;
+ EFI_MTFTP4_TOKEN *Token;
- MtftpSb = (MTFTP4_SERVICE *) Context;
+ MtftpSb = (MTFTP4_SERVICE *)Context;
//
// Iterate through all the children of the Mtftp service instance.
@@ -636,12 +622,13 @@ Mtftp4OnTimerTick ( //
Token = Instance->Token;
- if (Token != NULL && Token->TimeoutCallback != NULL &&
- EFI_ERROR (Token->TimeoutCallback (&Instance->Mtftp4, Token))) {
+ if ((Token != NULL) && (Token->TimeoutCallback != NULL) &&
+ EFI_ERROR (Token->TimeoutCallback (&Instance->Mtftp4, Token)))
+ {
Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
- (UINT8 *) "User aborted the transfer in time out"
+ (UINT8 *)"User aborted the transfer in time out"
);
Mtftp4CleanOperation (Instance, EFI_ABORTED);
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Support.h b/NetworkPkg/Mtftp4Dxe/Mtftp4Support.h index 95e9bad43e..6267017782 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Support.h +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Support.h @@ -15,14 +15,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // the holes are filled in, then the download or upload has completed.
//
typedef struct {
- LIST_ENTRY Link;
- INTN Start;
- INTN End;
- INTN Round;
- INTN Bound;
+ LIST_ENTRY Link;
+ INTN Start;
+ INTN End;
+ INTN Round;
+ INTN Bound;
} MTFTP4_BLOCK_RANGE;
-
/**
Initialize the block range for either RRQ or WRQ.
@@ -46,9 +45,9 @@ typedef struct { **/
EFI_STATUS
Mtftp4InitBlockRange (
- IN LIST_ENTRY *Head,
- IN UINT16 Start,
- IN UINT16 End
+ IN LIST_ENTRY *Head,
+ IN UINT16 Start,
+ IN UINT16 End
);
/**
@@ -61,7 +60,7 @@ Mtftp4InitBlockRange ( **/
INTN
Mtftp4GetNextBlockNum (
- IN LIST_ENTRY *Head
+ IN LIST_ENTRY *Head
);
/**
@@ -77,8 +76,8 @@ Mtftp4GetNextBlockNum ( **/
VOID
Mtftp4SetLastBlockNum (
- IN LIST_ENTRY *Head,
- IN UINT16 Last
+ IN LIST_ENTRY *Head,
+ IN UINT16 Last
);
/**
@@ -96,10 +95,10 @@ Mtftp4SetLastBlockNum ( **/
EFI_STATUS
Mtftp4RemoveBlockNum (
- IN LIST_ENTRY *Head,
- IN UINT16 Num,
- IN BOOLEAN Completed,
- OUT UINT64 *BlockCounter
+ IN LIST_ENTRY *Head,
+ IN UINT16 Num,
+ IN BOOLEAN Completed,
+ OUT UINT64 *BlockCounter
);
/**
@@ -110,7 +109,7 @@ Mtftp4RemoveBlockNum ( **/
VOID
Mtftp4SetTimeout (
- IN OUT MTFTP4_PROTOCOL *Instance
+ IN OUT MTFTP4_PROTOCOL *Instance
);
/**
@@ -129,8 +128,8 @@ Mtftp4SetTimeout ( **/
EFI_STATUS
Mtftp4SendPacket (
- IN OUT MTFTP4_PROTOCOL *Instance,
- IN OUT NET_BUF *Packet
+ IN OUT MTFTP4_PROTOCOL *Instance,
+ IN OUT NET_BUF *Packet
);
/**
@@ -145,7 +144,7 @@ Mtftp4SendPacket ( **/
EFI_STATUS
Mtftp4SendRequest (
- IN MTFTP4_PROTOCOL *Instance
+ IN MTFTP4_PROTOCOL *Instance
);
/**
@@ -162,12 +161,11 @@ Mtftp4SendRequest ( **/
EFI_STATUS
Mtftp4SendError (
- IN MTFTP4_PROTOCOL *Instance,
- IN UINT16 ErrCode,
- IN UINT8 *ErrInfo
+ IN MTFTP4_PROTOCOL *Instance,
+ IN UINT16 ErrCode,
+ IN UINT8 *ErrInfo
);
-
/**
The timer ticking function in TPL_NOTIFY level for the Mtftp service instance.
@@ -178,8 +176,8 @@ Mtftp4SendError ( VOID
EFIAPI
Mtftp4OnTimerTickNotifyLevel (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -192,7 +190,8 @@ Mtftp4OnTimerTickNotifyLevel ( VOID
EFIAPI
Mtftp4OnTimerTick (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
+
#endif
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Wrq.c b/NetworkPkg/Mtftp4Dxe/Mtftp4Wrq.c index 5d479fad4e..9ebefc74ec 100644 --- a/NetworkPkg/Mtftp4Dxe/Mtftp4Wrq.c +++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Wrq.c @@ -8,8 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "Mtftp4Impl.h"
-
-
/**
Build then send a MTFTP data packet for the MTFTP upload session.
@@ -24,17 +22,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
EFI_STATUS
Mtftp4WrqSendBlock (
- IN OUT MTFTP4_PROTOCOL *Instance,
- IN UINT16 BlockNum
+ IN OUT MTFTP4_PROTOCOL *Instance,
+ IN UINT16 BlockNum
)
{
- EFI_MTFTP4_PACKET *Packet;
- EFI_MTFTP4_TOKEN *Token;
- NET_BUF *UdpPacket;
- EFI_STATUS Status;
- UINT16 DataLen;
- UINT8 *DataBuf;
- UINT64 Start;
+ EFI_MTFTP4_PACKET *Packet;
+ EFI_MTFTP4_TOKEN *Token;
+ NET_BUF *UdpPacket;
+ EFI_STATUS Status;
+ UINT16 DataLen;
+ UINT8 *DataBuf;
+ UINT64 Start;
//
// Allocate a buffer to hold the user data
@@ -45,7 +43,7 @@ Mtftp4WrqSendBlock ( return EFI_OUT_OF_RESOURCES;
}
- Packet = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (UdpPacket, MTFTP4_DATA_HEAD_LEN, FALSE);
+ Packet = (EFI_MTFTP4_PACKET *)NetbufAllocSpace (UdpPacket, MTFTP4_DATA_HEAD_LEN, FALSE);
ASSERT (Packet != NULL);
Packet->Data.OpCode = HTONS (EFI_MTFTP4_OPCODE_DATA);
@@ -61,16 +59,15 @@ Mtftp4WrqSendBlock ( Start = MultU64x32 (BlockNum - 1, Instance->BlkSize);
if (Token->BufferSize < Start + Instance->BlkSize) {
- DataLen = (UINT16) (Token->BufferSize - Start);
+ DataLen = (UINT16)(Token->BufferSize - Start);
Instance->LastBlock = BlockNum;
Mtftp4SetLastBlockNum (&Instance->Blocks, BlockNum);
}
if (DataLen > 0) {
NetbufAllocSpace (UdpPacket, DataLen, FALSE);
- CopyMem (Packet->Data.Data, (UINT8 *) Token->Buffer + Start, DataLen);
+ CopyMem (Packet->Data.Data, (UINT8 *)Token->Buffer + Start, DataLen);
}
-
} else {
//
// Get data from PacketNeeded
@@ -80,7 +77,7 @@ Mtftp4WrqSendBlock ( &Instance->Mtftp4,
Token,
&DataLen,
- (VOID **) &DataBuf
+ (VOID **)&DataBuf
);
if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) {
@@ -95,7 +92,7 @@ Mtftp4WrqSendBlock ( Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
- (UINT8 *) "User aborted the transfer"
+ (UINT8 *)"User aborted the transfer"
);
return EFI_ABORTED;
@@ -116,7 +113,6 @@ Mtftp4WrqSendBlock ( return Mtftp4SendPacket (Instance, UdpPacket);
}
-
/**
Function to handle received ACK packet.
@@ -135,19 +131,19 @@ Mtftp4WrqSendBlock ( **/
EFI_STATUS
Mtftp4WrqHandleAck (
- IN MTFTP4_PROTOCOL *Instance,
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 Len,
- OUT BOOLEAN *Completed
+ IN MTFTP4_PROTOCOL *Instance,
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 Len,
+ OUT BOOLEAN *Completed
)
{
- UINT16 AckNum;
- INTN Expected;
- UINT64 BlockCounter;
+ UINT16 AckNum;
+ INTN Expected;
+ UINT64 BlockCounter;
- *Completed = FALSE;
- AckNum = NTOHS (Packet->Ack.Block[0]);
- Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);
+ *Completed = FALSE;
+ AckNum = NTOHS (Packet->Ack.Block[0]);
+ Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);
ASSERT (Expected >= 0);
@@ -169,7 +165,6 @@ Mtftp4WrqHandleAck ( Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);
if (Expected < 0) {
-
//
// The block range is empty. It may either because the last
// block has been ACKed, or the sequence number just looped back,
@@ -179,22 +174,20 @@ Mtftp4WrqHandleAck ( ASSERT (Instance->LastBlock >= 1);
*Completed = TRUE;
return EFI_SUCCESS;
-
} else {
Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
- (UINT8 *) "Block number rolls back, not supported, try blksize option"
+ (UINT8 *)"Block number rolls back, not supported, try blksize option"
);
return EFI_TFTP_ERROR;
}
}
- return Mtftp4WrqSendBlock (Instance, (UINT16) Expected);
+ return Mtftp4WrqSendBlock (Instance, (UINT16)Expected);
}
-
/**
Check whether the received OACK is valid.
@@ -213,8 +206,8 @@ Mtftp4WrqHandleAck ( **/
BOOLEAN
Mtftp4WrqOackValid (
- IN MTFTP4_OPTION *Reply,
- IN MTFTP4_OPTION *Request
+ IN MTFTP4_OPTION *Reply,
+ IN MTFTP4_OPTION *Request
)
{
//
@@ -229,14 +222,14 @@ Mtftp4WrqOackValid ( // return the timeout matches that requested.
//
if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) != 0) && (Reply->BlkSize > Request->BlkSize)) ||
- (((Reply->Exist & MTFTP4_TIMEOUT_EXIST) != 0) && (Reply->Timeout != Request->Timeout))) {
+ (((Reply->Exist & MTFTP4_TIMEOUT_EXIST) != 0) && (Reply->Timeout != Request->Timeout)))
+ {
return FALSE;
}
return TRUE;
}
-
/**
Function to handle the MTFTP OACK packet.
@@ -254,16 +247,16 @@ Mtftp4WrqOackValid ( **/
EFI_STATUS
Mtftp4WrqHandleOack (
- IN OUT MTFTP4_PROTOCOL *Instance,
- IN EFI_MTFTP4_PACKET *Packet,
- IN UINT32 Len,
- OUT BOOLEAN *Completed
+ IN OUT MTFTP4_PROTOCOL *Instance,
+ IN EFI_MTFTP4_PACKET *Packet,
+ IN UINT32 Len,
+ OUT BOOLEAN *Completed
)
{
- MTFTP4_OPTION Reply;
- EFI_MTFTP4_PACKET Bogus;
- EFI_STATUS Status;
- INTN Expected;
+ MTFTP4_OPTION Reply;
+ EFI_MTFTP4_PACKET Bogus;
+ EFI_STATUS Status;
+ INTN Expected;
*Completed = FALSE;
@@ -291,7 +284,7 @@ Mtftp4WrqHandleOack ( Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION,
- (UINT8 *) "Malformatted OACK packet"
+ (UINT8 *)"Malformatted OACK packet"
);
}
@@ -310,8 +303,8 @@ Mtftp4WrqHandleOack ( // Build a bogus ACK0 packet then pass it to the Mtftp4WrqHandleAck,
// which will start the transmission of the first data block.
//
- Bogus.Ack.OpCode = HTONS (EFI_MTFTP4_OPCODE_ACK);
- Bogus.Ack.Block[0] = 0;
+ Bogus.Ack.OpCode = HTONS (EFI_MTFTP4_OPCODE_ACK);
+ Bogus.Ack.Block[0] = 0;
Status = Mtftp4WrqHandleAck (
Instance,
@@ -323,7 +316,6 @@ Mtftp4WrqHandleOack ( return Status;
}
-
/**
The input process routine for MTFTP upload.
@@ -336,20 +328,20 @@ Mtftp4WrqHandleOack ( VOID
EFIAPI
Mtftp4WrqInput (
- IN NET_BUF *UdpPacket,
- IN UDP_END_POINT *EndPoint,
- IN EFI_STATUS IoStatus,
- IN VOID *Context
+ IN NET_BUF *UdpPacket,
+ IN UDP_END_POINT *EndPoint,
+ IN EFI_STATUS IoStatus,
+ IN VOID *Context
)
{
- MTFTP4_PROTOCOL *Instance;
- EFI_MTFTP4_PACKET *Packet;
- BOOLEAN Completed;
- EFI_STATUS Status;
- UINT32 Len;
- UINT16 Opcode;
-
- Instance = (MTFTP4_PROTOCOL *) Context;
+ MTFTP4_PROTOCOL *Instance;
+ EFI_MTFTP4_PACKET *Packet;
+ BOOLEAN Completed;
+ EFI_STATUS Status;
+ UINT32 Len;
+ UINT16 Opcode;
+
+ Instance = (MTFTP4_PROTOCOL *)Context;
NET_CHECK_SIGNATURE (Instance, MTFTP4_PROTOCOL_SIGNATURE);
Completed = FALSE;
@@ -392,10 +384,9 @@ Mtftp4WrqInput ( goto ON_EXIT;
}
- NetbufCopy (UdpPacket, 0, Len, (UINT8 *) Packet);
-
+ NetbufCopy (UdpPacket, 0, Len, (UINT8 *)Packet);
} else {
- Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL);
+ Packet = (EFI_MTFTP4_PACKET *)NetbufGetByte (UdpPacket, 0, NULL);
ASSERT (Packet != NULL);
}
@@ -406,12 +397,12 @@ Mtftp4WrqInput ( // if CheckPacket returns an EFI_ERROR code.
//
if ((Instance->Token->CheckPacket != NULL) &&
- ((Opcode == EFI_MTFTP4_OPCODE_OACK) || (Opcode == EFI_MTFTP4_OPCODE_ERROR))) {
-
+ ((Opcode == EFI_MTFTP4_OPCODE_OACK) || (Opcode == EFI_MTFTP4_OPCODE_ERROR)))
+ {
Status = Instance->Token->CheckPacket (
&Instance->Mtftp4,
Instance->Token,
- (UINT16) Len,
+ (UINT16)Len,
Packet
);
@@ -423,7 +414,7 @@ Mtftp4WrqInput ( Mtftp4SendError (
Instance,
EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
- (UINT8 *) "User aborted the transfer"
+ (UINT8 *)"User aborted the transfer"
);
}
@@ -433,28 +424,28 @@ Mtftp4WrqInput ( }
switch (Opcode) {
- case EFI_MTFTP4_OPCODE_ACK:
- if (Len != MTFTP4_OPCODE_LEN + MTFTP4_BLKNO_LEN) {
- goto ON_EXIT;
- }
+ case EFI_MTFTP4_OPCODE_ACK:
+ if (Len != MTFTP4_OPCODE_LEN + MTFTP4_BLKNO_LEN) {
+ goto ON_EXIT;
+ }
- Status = Mtftp4WrqHandleAck (Instance, Packet, Len, &Completed);
- break;
+ Status = Mtftp4WrqHandleAck (Instance, Packet, Len, &Completed);
+ break;
- case EFI_MTFTP4_OPCODE_OACK:
- if (Len <= MTFTP4_OPCODE_LEN) {
- goto ON_EXIT;
- }
+ case EFI_MTFTP4_OPCODE_OACK:
+ if (Len <= MTFTP4_OPCODE_LEN) {
+ goto ON_EXIT;
+ }
- Status = Mtftp4WrqHandleOack (Instance, Packet, Len, &Completed);
- break;
+ Status = Mtftp4WrqHandleOack (Instance, Packet, Len, &Completed);
+ break;
- case EFI_MTFTP4_OPCODE_ERROR:
- Status = EFI_TFTP_ERROR;
- break;
+ case EFI_MTFTP4_OPCODE_ERROR:
+ Status = EFI_TFTP_ERROR;
+ break;
- default:
- break;
+ default:
+ break;
}
ON_EXIT:
@@ -482,8 +473,6 @@ ON_EXIT: }
}
-
-
/**
Start the MTFTP session for upload.
@@ -500,11 +489,11 @@ ON_EXIT: **/
EFI_STATUS
Mtftp4WrqStart (
- IN MTFTP4_PROTOCOL *Instance,
- IN UINT16 Operation
+ IN MTFTP4_PROTOCOL *Instance,
+ IN UINT16 Operation
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// The valid block number range are [0, 0xffff]. For example:
@@ -526,4 +515,3 @@ Mtftp4WrqStart ( return UdpIoRecvDatagram (Instance->UnicastPort, Mtftp4WrqInput, Instance, 0);
}
-
|