From d1050b9dff1cace252aff86630bfdb59dff5f507 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 5 Dec 2021 14:54:07 -0800 Subject: 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 Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Michael Kubacki Reviewed-by: Maciej Rabeda --- NetworkPkg/ArpDxe/ArpDriver.c | 39 ++++----- NetworkPkg/ArpDxe/ArpDriver.h | 24 +++--- NetworkPkg/ArpDxe/ArpImpl.c | 176 +++++++++++++++++++------------------- NetworkPkg/ArpDxe/ArpImpl.h | 125 ++++++++++++++------------- NetworkPkg/ArpDxe/ArpMain.c | 44 +++++----- NetworkPkg/ArpDxe/ComponentName.c | 32 ++++--- 6 files changed, 216 insertions(+), 224 deletions(-) (limited to 'NetworkPkg/ArpDxe') diff --git a/NetworkPkg/ArpDxe/ArpDriver.c b/NetworkPkg/ArpDxe/ArpDriver.c index eeef7f6..c80da6d 100644 --- a/NetworkPkg/ArpDxe/ArpDriver.c +++ b/NetworkPkg/ArpDxe/ArpDriver.c @@ -9,7 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "ArpDriver.h" #include "ArpImpl.h" -EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = { +EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = { ArpDriverBindingSupported, ArpDriverBindingStart, ArpDriverBindingStop, @@ -18,7 +18,6 @@ EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = { NULL }; - /** Create and initialize the arp service context data. @@ -37,8 +36,8 @@ EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = { **/ EFI_STATUS ArpCreateService ( - IN EFI_HANDLE ImageHandle, - IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ImageHandle, + IN EFI_HANDLE ControllerHandle, IN OUT ARP_SERVICE_DATA *ArpService ) { @@ -176,7 +175,6 @@ ERROR_EXIT: return Status; } - /** Clean the arp service context data. @@ -226,7 +224,7 @@ ArpCleanService ( // // Destroy the mnp child. // - NetLibDestroyServiceChild( + NetLibDestroyServiceChild ( ArpService->ControllerHandle, ArpService->ImageHandle, &gEfiManagedNetworkServiceBindingProtocolGuid, @@ -248,19 +246,19 @@ ArpCleanService ( EFI_STATUS EFIAPI ArpDestroyChildEntryInHandleBuffer ( - IN LIST_ENTRY *Entry, - IN VOID *Context + IN LIST_ENTRY *Entry, + IN VOID *Context ) { ARP_INSTANCE_DATA *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, ARP_INSTANCE_DATA, List, ARP_INSTANCE_DATA_SIGNATURE); - ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; + Instance = NET_LIST_USER_STRUCT_S (Entry, ARP_INSTANCE_DATA, List, ARP_INSTANCE_DATA_SIGNATURE); + ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context; return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); } @@ -334,7 +332,6 @@ ArpDriverBindingSupported ( return Status; } - /** Start this driver on ControllerHandle. @@ -380,7 +377,7 @@ ArpDriverBindingStart ( // // Allocate a zero pool for ArpService. // - ArpService = AllocateZeroPool (sizeof(ARP_SERVICE_DATA)); + ArpService = AllocateZeroPool (sizeof (ARP_SERVICE_DATA)); if (ArpService == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -427,7 +424,6 @@ ERROR: return Status; } - /** Stop this driver on ControllerHandle. @@ -502,7 +498,7 @@ ArpDriverBindingStop ( // // NumberOfChildren is not zero, destroy all the ARP children instances. // - List = &ArpService->ChildrenList; + List = &ArpService->ChildrenList; Status = NetDestroyLinkList ( List, ArpDestroyChildEntryInHandleBuffer, @@ -576,7 +572,7 @@ ArpServiceBindingCreateChild ( // // Allocate memory for the instance context data. // - Instance = AllocateZeroPool (sizeof(ARP_INSTANCE_DATA)); + Instance = AllocateZeroPool (sizeof (ARP_INSTANCE_DATA)); if (Instance == NULL) { DEBUG ((DEBUG_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n")); @@ -615,7 +611,7 @@ ArpServiceBindingCreateChild ( Status = gBS->OpenProtocol ( ArpService->MnpChildHandle, &gEfiManagedNetworkProtocolGuid, - (VOID **) &Mnp, + (VOID **)&Mnp, gArpDriverBinding.DriverBindingHandle, Instance->Handle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER @@ -637,7 +633,6 @@ ArpServiceBindingCreateChild ( ERROR: if (EFI_ERROR (Status)) { - gBS->CloseProtocol ( ArpService->MnpChildHandle, &gEfiManagedNetworkProtocolGuid, @@ -661,7 +656,6 @@ ERROR: return Status; } - /** Destroys a child handle with a protocol installed on it. @@ -746,8 +740,11 @@ ArpServiceBindingDestroyChild ( NULL ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n", - Status)); + DEBUG (( + DEBUG_ERROR, + "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n", + Status + )); Instance->InDestroy = FALSE; return Status; diff --git a/NetworkPkg/ArpDxe/ArpDriver.h b/NetworkPkg/ArpDxe/ArpDriver.h index 7dbc1c1..2966bac 100644 --- a/NetworkPkg/ArpDxe/ArpDriver.h +++ b/NetworkPkg/ArpDxe/ArpDriver.h @@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _ARP_DRIVER_H_ #define _ARP_DRIVER_H_ - #include #include @@ -21,17 +20,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include - // // Global variables // -extern EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gArpComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2; +extern EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding; +extern EFI_COMPONENT_NAME_PROTOCOL gArpComponentName; +extern EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2; // // Function prototypes for the Driver Binding Protocol // + /** Tests to see if this driver supports a given controller. @@ -199,10 +198,10 @@ ArpServiceBindingDestroyChild ( IN EFI_HANDLE ChildHandle ); - // // EFI Component Name Functions // + /** Retrieves a Unicode string that is the user readable name of the driver. @@ -250,7 +249,6 @@ ArpComponentNameGetDriverName ( OUT CHAR16 **DriverName ); - /** Retrieves a Unicode string that is the user readable name of the controller that is being managed by a driver. @@ -322,13 +320,11 @@ ArpComponentNameGetDriverName ( EFI_STATUS EFIAPI ArpComponentNameGetControllerName ( - 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 ); - #endif - diff --git a/NetworkPkg/ArpDxe/ArpImpl.c b/NetworkPkg/ArpDxe/ArpImpl.c index ad5cb3c..9d0d4dc 100644 --- a/NetworkPkg/ArpDxe/ArpImpl.c +++ b/NetworkPkg/ArpDxe/ArpImpl.c @@ -21,7 +21,6 @@ EFI_ARP_PROTOCOL mEfiArpProtocolTemplate = { ArpCancel }; - /** Initialize the instance context data. @@ -51,7 +50,6 @@ ArpInitInstance ( InitializeListHead (&Instance->List); } - /** Process the Arp packets received from Mnp, the procedure conforms to RFC826. @@ -64,7 +62,7 @@ ArpInitInstance ( VOID EFIAPI ArpOnFrameRcvdDpc ( - IN VOID *Context + IN VOID *Context ) { EFI_STATUS Status; @@ -119,7 +117,7 @@ ArpOnFrameRcvdDpc ( // // Convert the byte order of the multi-byte fields. // - Head = (ARP_HEAD *) RxData->PacketData; + Head = (ARP_HEAD *)RxData->PacketData; Head->HwType = NTOHS (Head->HwType); Head->ProtoType = NTOHS (Head->ProtoType); Head->OpCode = NTOHS (Head->OpCode); @@ -129,8 +127,9 @@ ArpOnFrameRcvdDpc ( } if ((Head->HwType != ArpService->SnpMode.IfType) || - (Head->HwAddrLen != ArpService->SnpMode.HwAddressSize) || - (RxData->ProtocolType != ARP_ETHER_PROTO_TYPE)) { + (Head->HwAddrLen != ArpService->SnpMode.HwAddressSize) || + (RxData->ProtocolType != ARP_ETHER_PROTO_TYPE)) + { // // The hardware type or the hardware address length doesn't match. // There is a sanity check for the protocol type too. @@ -182,8 +181,9 @@ ArpOnFrameRcvdDpc ( ConfigData = &Instance->ConfigData; if ((Instance->Configured) && - (Head->ProtoType == ConfigData->SwAddressType) && - (Head->ProtoAddrLen == ConfigData->SwAddressLength)) { + (Head->ProtoType == ConfigData->SwAddressType) && + (Head->ProtoAddrLen == ConfigData->SwAddressLength)) + { // // The protocol type is matched for the received arp packet. // @@ -192,7 +192,8 @@ ArpOnFrameRcvdDpc ( (VOID *)ArpAddress.TargetProtoAddr, ConfigData->StationAddress, ConfigData->SwAddressLength - )) { + )) + { // // The arp driver has the target address required by the received arp packet. // @@ -226,7 +227,7 @@ ArpOnFrameRcvdDpc ( // ArpFillAddressInCacheEntry (CacheEntry, &SenderAddress[Hardware], NULL); CacheEntry->DecayTime = CacheEntry->DefaultDecayTime; - MergeFlag = TRUE; + MergeFlag = TRUE; } if (!IsTarget) { @@ -305,10 +306,15 @@ RESTART_RECEIVE: Status = ArpService->Mnp->Receive (ArpService->Mnp, RxToken); DEBUG_CODE_BEGIN (); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "ArpOnFrameRcvd: ArpService->Mnp->Receive " - "failed, %r\n.", Status)); - } + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ArpOnFrameRcvd: ArpService->Mnp->Receive " + "failed, %r\n.", + Status + )); + } + DEBUG_CODE_END (); } @@ -347,7 +353,7 @@ ArpOnFrameRcvd ( VOID EFIAPI ArpOnFrameSentDpc ( - IN VOID *Context + IN VOID *Context ) { EFI_MANAGED_NETWORK_COMPLETION_TOKEN *TxToken; @@ -359,9 +365,10 @@ ArpOnFrameSentDpc ( TxData = TxToken->Packet.TxData; DEBUG_CODE_BEGIN (); - if (EFI_ERROR (TxToken->Status)) { - DEBUG ((DEBUG_ERROR, "ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status)); - } + if (EFI_ERROR (TxToken->Status)) { + DEBUG ((DEBUG_ERROR, "ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status)); + } + DEBUG_CODE_END (); // @@ -396,7 +403,6 @@ ArpOnFrameSent ( QueueDpc (TPL_CALLBACK, ArpOnFrameSentDpc, Context); } - /** Process the arp cache olding and drive the retrying arp requests. @@ -449,7 +455,7 @@ ArpTimerHandler ( // // resend the ARP request. // - ASSERT (!IsListEmpty(&CacheEntry->UserRequestList)); + ASSERT (!IsListEmpty (&CacheEntry->UserRequestList)); ContextEntry = CacheEntry->UserRequestList.ForwardLink; RequestContext = NET_LIST_USER_STRUCT (ContextEntry, USER_REQUEST_CONTEXT, List); @@ -524,7 +530,6 @@ ArpTimerHandler ( } } - /** Match the two NET_ARP_ADDRESSes. @@ -543,7 +548,8 @@ ArpMatchAddress ( ASSERT (AddressOne != NULL && AddressTwo != NULL); if ((AddressOne->Type != AddressTwo->Type) || - (AddressOne->Length != AddressTwo->Length)) { + (AddressOne->Length != AddressTwo->Length)) + { // // Either Type or Length doesn't match. // @@ -551,11 +557,12 @@ ArpMatchAddress ( } if ((AddressOne->AddressPtr != NULL) && - (CompareMem ( - AddressOne->AddressPtr, - AddressTwo->AddressPtr, - AddressOne->Length - ) != 0)) { + (CompareMem ( + AddressOne->AddressPtr, + AddressTwo->AddressPtr, + AddressOne->Length + ) != 0)) + { // // The address is not the same. // @@ -565,7 +572,6 @@ ArpMatchAddress ( return TRUE; } - /** Find the CacheEntry which matches the requirements in the specified CacheTable. @@ -581,11 +587,11 @@ ArpMatchAddress ( **/ ARP_CACHE_ENTRY * ArpFindNextCacheEntryInTable ( - IN LIST_ENTRY *CacheTable, - IN LIST_ENTRY *StartEntry, - IN FIND_OPTYPE FindOpType, - IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL, - IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL + IN LIST_ENTRY *CacheTable, + IN LIST_ENTRY *StartEntry, + IN FIND_OPTYPE FindOpType, + IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL, + IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL ) { LIST_ENTRY *Entry; @@ -637,7 +643,6 @@ ArpFindNextCacheEntryInTable ( return NULL; } - /** Find the CacheEntry, using ProtocolAddress or HardwareAddress or both, as the keyword, in the DeniedCacheTable. @@ -698,7 +703,6 @@ ArpFindDeniedCacheEntry ( return CacheEntry; } - /** Allocate a cache entry and initialize it. @@ -734,7 +738,7 @@ ArpAllocCacheEntry ( // // Init the address pointers to point to the concrete buffer. // - Address = &CacheEntry->Addresses[Index]; + Address = &CacheEntry->Addresses[Index]; Address->AddressPtr = Address->Buffer.ProtoAddress; } @@ -765,7 +769,6 @@ ArpAllocCacheEntry ( return CacheEntry; } - /** Turn the CacheEntry into the resolved status. @@ -797,7 +800,8 @@ ArpAddressResolved ( Context = NET_LIST_USER_STRUCT (Entry, USER_REQUEST_CONTEXT, List); if (((Instance == NULL) || (Context->Instance == Instance)) && - ((UserEvent == NULL) || (Context->UserRequestEvent == UserEvent))) { + ((UserEvent == NULL) || (Context->UserRequestEvent == UserEvent))) + { // // Copy the address to the user-provided buffer and notify the user. // @@ -826,7 +830,6 @@ ArpAddressResolved ( return Count; } - /** Fill the addresses in the CacheEntry using the information passed in by HwAddr and SwAddr. @@ -881,7 +884,6 @@ ArpFillAddressInCacheEntry ( } } - /** Configure the instance using the ConfigData. ConfigData is already validated. @@ -912,18 +914,18 @@ ArpConfigureInstance ( OldConfigData = &Instance->ConfigData; if (ConfigData != NULL) { - if (Instance->Configured) { // // The instance is configured, check the unchangeable fields. // if ((OldConfigData->SwAddressType != ConfigData->SwAddressType) || - (OldConfigData->SwAddressLength != ConfigData->SwAddressLength) || - (CompareMem ( - OldConfigData->StationAddress, - ConfigData->StationAddress, - OldConfigData->SwAddressLength - ) != 0)) { + (OldConfigData->SwAddressLength != ConfigData->SwAddressLength) || + (CompareMem ( + OldConfigData->StationAddress, + ConfigData->StationAddress, + OldConfigData->SwAddressLength + ) != 0)) + { // // Deny the unallowed changes. // @@ -952,8 +954,11 @@ ArpConfigureInstance ( OldConfigData->StationAddress = AllocatePool (OldConfigData->SwAddressLength); if (OldConfigData->StationAddress == NULL) { - DEBUG ((DEBUG_ERROR, "ArpConfigInstance: AllocatePool for the StationAddress " - "failed.\n")); + DEBUG (( + DEBUG_ERROR, + "ArpConfigInstance: AllocatePool for the StationAddress " + "failed.\n" + )); return EFI_OUT_OF_RESOURCES; } @@ -976,13 +981,13 @@ ArpConfigureInstance ( // Use the implementation specific values if the following field is zero. // OldConfigData->EntryTimeOut = (ConfigData->EntryTimeOut == 0) ? - ARP_DEFAULT_TIMEOUT_VALUE : ConfigData->EntryTimeOut; + ARP_DEFAULT_TIMEOUT_VALUE : ConfigData->EntryTimeOut; - OldConfigData->RetryCount = (ConfigData->RetryCount == 0) ? - ARP_DEFAULT_RETRY_COUNT : ConfigData->RetryCount; + OldConfigData->RetryCount = (ConfigData->RetryCount == 0) ? + ARP_DEFAULT_RETRY_COUNT : ConfigData->RetryCount; OldConfigData->RetryTimeOut = (ConfigData->RetryTimeOut == 0) ? - ARP_DEFAULT_RETRY_INTERVAL : ConfigData->RetryTimeOut; + ARP_DEFAULT_RETRY_INTERVAL : ConfigData->RetryTimeOut; } else { // // Reset the configuration. @@ -1006,7 +1011,6 @@ ArpConfigureInstance ( return EFI_SUCCESS; } - /** Send out an arp frame using the CacheEntry and the ArpOpCode. @@ -1042,7 +1046,7 @@ ArpSendFrame ( // // Allocate memory for the TxToken. // - TxToken = AllocatePool (sizeof(EFI_MANAGED_NETWORK_COMPLETION_TOKEN)); + TxToken = AllocatePool (sizeof (EFI_MANAGED_NETWORK_COMPLETION_TOKEN)); if (TxToken == NULL) { DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxToken failed.\n")); return; @@ -1070,7 +1074,7 @@ ArpSendFrame ( // // Allocate memory for the TxData used in the TxToken. // - TxData = AllocatePool (sizeof(EFI_MANAGED_NETWORK_TRANSMIT_DATA)); + TxData = AllocatePool (sizeof (EFI_MANAGED_NETWORK_TRANSMIT_DATA)); if (TxData == NULL) { DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxData failed.\n")); goto CLEAN_EXIT; @@ -1109,6 +1113,7 @@ ArpSendFrame ( SnpMode->HwAddressSize ); } + TmpPtr += SnpMode->HwAddressSize; // @@ -1121,18 +1126,18 @@ ArpSendFrame ( // The ethernet protocol type. // *(UINT16 *)TmpPtr = HTONS (ARP_ETHER_PROTO_TYPE); - TmpPtr += 2; + TmpPtr += 2; // // The ARP Head. // - ArpHead = (ARP_HEAD *) TmpPtr; + ArpHead = (ARP_HEAD *)TmpPtr; ArpHead->HwType = HTONS ((UINT16)SnpMode->IfType); ArpHead->ProtoType = HTONS (ConfigData->SwAddressType); ArpHead->HwAddrLen = (UINT8)SnpMode->HwAddressSize; ArpHead->ProtoAddrLen = ConfigData->SwAddressLength; ArpHead->OpCode = HTONS (ArpOpCode); - TmpPtr += sizeof (ARP_HEAD); + TmpPtr += sizeof (ARP_HEAD); // // The sender hardware address. @@ -1172,7 +1177,7 @@ ArpSendFrame ( TxData->SourceAddress = NULL; TxData->ProtocolType = 0; TxData->DataLength = TotalLength - SnpMode->MediaHeaderSize; - TxData->HeaderLength = (UINT16) SnpMode->MediaHeaderSize; + TxData->HeaderLength = (UINT16)SnpMode->MediaHeaderSize; TxData->FragmentCount = 1; TxData->FragmentTable[0].FragmentBuffer = Packet; @@ -1212,7 +1217,6 @@ CLEAN_EXIT: FreePool (TxToken); } - /** Delete the cache entries in the specified CacheTable, using the BySwAddress, SwAddressType, AddressBuffer combination as the matching key, if Force is TRUE, @@ -1231,11 +1235,11 @@ CLEAN_EXIT: **/ UINTN ArpDeleteCacheEntryInTable ( - IN LIST_ENTRY *CacheTable, - IN BOOLEAN BySwAddress, - IN UINT16 SwAddressType, - IN UINT8 *AddressBuffer OPTIONAL, - IN BOOLEAN Force + IN LIST_ENTRY *CacheTable, + IN BOOLEAN BySwAddress, + IN UINT16 SwAddressType, + IN UINT8 *AddressBuffer OPTIONAL, + IN BOOLEAN Force ) { LIST_ENTRY *Entry; @@ -1261,11 +1265,12 @@ ArpDeleteCacheEntryInTable ( // Protocol address type matched. Check the address. // if ((AddressBuffer == NULL) || - (CompareMem ( - AddressBuffer, - CacheEntry->Addresses[Protocol].AddressPtr, - CacheEntry->Addresses[Protocol].Length - ) == 0)) { + (CompareMem ( + AddressBuffer, + CacheEntry->Addresses[Protocol].AddressPtr, + CacheEntry->Addresses[Protocol].Length + ) == 0)) + { // // Address matched. // @@ -1274,11 +1279,12 @@ ArpDeleteCacheEntryInTable ( } } else { if ((AddressBuffer == NULL) || - (CompareMem ( - AddressBuffer, - CacheEntry->Addresses[Hardware].AddressPtr, - CacheEntry->Addresses[Hardware].Length - ) == 0)) { + (CompareMem ( + AddressBuffer, + CacheEntry->Addresses[Hardware].AddressPtr, + CacheEntry->Addresses[Hardware].Length + ) == 0)) + { // // Address matched. // @@ -1303,7 +1309,6 @@ MATCHED: return Count; } - /** Delete cache entries in all the cache tables. @@ -1357,7 +1362,6 @@ ArpDeleteCacheEntry ( return Count; } - /** Cancel the arp request. @@ -1392,11 +1396,12 @@ ArpCancelRequest ( CacheEntry = NET_LIST_USER_STRUCT (Entry, ARP_CACHE_ENTRY, List); if ((TargetSwAddress == NULL) || - (CompareMem ( - TargetSwAddress, - CacheEntry->Addresses[Protocol].AddressPtr, - CacheEntry->Addresses[Protocol].Length - ) == 0)) { + (CompareMem ( + TargetSwAddress, + CacheEntry->Addresses[Protocol].AddressPtr, + CacheEntry->Addresses[Protocol].Length + ) == 0)) + { // // This request entry matches the TargetSwAddress or all requests are to be // cancelled as TargetSwAddress is NULL. @@ -1416,7 +1421,6 @@ ArpCancelRequest ( return Count; } - /** Find the cache entry in the cache table. @@ -1572,7 +1576,7 @@ ArpFindCacheEntry ( Status = EFI_SUCCESS; - FoundCount = (UINT32) NetMapGetCount (&FoundEntries); + FoundCount = (UINT32)NetMapGetCount (&FoundEntries); if (FoundCount == 0) { Status = EFI_NOT_FOUND; goto CLEAN_EXIT; @@ -1582,7 +1586,7 @@ ArpFindCacheEntry ( // Found the entry length, make sure its 8 bytes alignment. // FoundEntryLength = (((sizeof (EFI_ARP_FIND_DATA) + Instance->ConfigData.SwAddressLength + - ArpService->SnpMode.HwAddressSize) + 3) & ~(0x3)); + ArpService->SnpMode.HwAddressSize) + 3) & ~(0x3)); if (EntryLength != NULL) { *EntryLength = FoundEntryLength; diff --git a/NetworkPkg/ArpDxe/ArpImpl.h b/NetworkPkg/ArpDxe/ArpImpl.h index 506f3e6..4a528af 100644 --- a/NetworkPkg/ArpDxe/ArpImpl.h +++ b/NetworkPkg/ArpDxe/ArpImpl.h @@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _ARP_IMPL_H_ #define _ARP_IMPL_H_ - #include #include @@ -29,15 +28,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // // Ethernet protocol type definitions. // -#define ARP_ETHER_PROTO_TYPE 0x0806 -#define IPV4_ETHER_PROTO_TYPE 0x0800 -#define IPV6_ETHER_PROTO_TYPE 0x86DD +#define ARP_ETHER_PROTO_TYPE 0x0806 +#define IPV4_ETHER_PROTO_TYPE 0x0800 +#define IPV6_ETHER_PROTO_TYPE 0x86DD // // ARP opcode definitions. // -#define ARP_OPCODE_REQUEST 0x0001 -#define ARP_OPCODE_REPLY 0x0002 +#define ARP_OPCODE_REQUEST 0x0001 +#define ARP_OPCODE_REPLY 0x0002 // // ARP timeout, retry count and interval definitions. @@ -52,11 +51,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // #pragma pack(1) typedef struct { - UINT16 HwType; - UINT16 ProtoType; - UINT8 HwAddrLen; - UINT8 ProtoAddrLen; - UINT16 OpCode; + UINT16 HwType; + UINT16 ProtoType; + UINT8 HwAddrLen; + UINT8 ProtoAddrLen; + UINT16 OpCode; } ARP_HEAD; #pragma pack() @@ -64,10 +63,10 @@ typedef struct { // ARP Address definition for internal use. // typedef struct { - UINT8 *SenderHwAddr; - UINT8 *SenderProtoAddr; - UINT8 *TargetHwAddr; - UINT8 *TargetProtoAddr; + UINT8 *SenderHwAddr; + UINT8 *SenderProtoAddr; + UINT8 *TargetHwAddr; + UINT8 *TargetProtoAddr; } ARP_ADDRESS; #define MATCH_SW_ADDRESS 0x1 @@ -104,20 +103,20 @@ typedef enum { ARP_INSTANCE_DATA_SIGNATURE \ ) -typedef struct _ARP_SERVICE_DATA ARP_SERVICE_DATA; +typedef struct _ARP_SERVICE_DATA ARP_SERVICE_DATA; // // ARP instance context data structure. // typedef struct { - UINT32 Signature; - ARP_SERVICE_DATA *ArpService; - EFI_HANDLE Handle; - EFI_ARP_PROTOCOL ArpProto; - LIST_ENTRY List; - EFI_ARP_CONFIG_DATA ConfigData; - BOOLEAN Configured; - BOOLEAN InDestroy; + UINT32 Signature; + ARP_SERVICE_DATA *ArpService; + EFI_HANDLE Handle; + EFI_ARP_PROTOCOL ArpProto; + LIST_ENTRY List; + EFI_ARP_CONFIG_DATA ConfigData; + BOOLEAN Configured; + BOOLEAN InDestroy; } ARP_INSTANCE_DATA; #define ARP_SERVICE_DATA_SIGNATURE SIGNATURE_32('A', 'R', 'P', 'S') @@ -144,55 +143,55 @@ typedef struct { // ARP service data structure. // struct _ARP_SERVICE_DATA { - UINT32 Signature; - EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; + UINT32 Signature; + EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; - EFI_HANDLE MnpChildHandle; - EFI_HANDLE ImageHandle; - EFI_HANDLE ControllerHandle; + EFI_HANDLE MnpChildHandle; + EFI_HANDLE ImageHandle; + EFI_HANDLE ControllerHandle; - EFI_MANAGED_NETWORK_PROTOCOL *Mnp; - EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData; - EFI_MANAGED_NETWORK_COMPLETION_TOKEN RxToken; + EFI_MANAGED_NETWORK_PROTOCOL *Mnp; + EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData; + EFI_MANAGED_NETWORK_COMPLETION_TOKEN RxToken; - EFI_SIMPLE_NETWORK_MODE SnpMode; + EFI_SIMPLE_NETWORK_MODE SnpMode; - UINTN ChildrenNumber; - LIST_ENTRY ChildrenList; + UINTN ChildrenNumber; + LIST_ENTRY ChildrenList; - LIST_ENTRY PendingRequestTable; - LIST_ENTRY DeniedCacheTable; - LIST_ENTRY ResolvedCacheTable; + LIST_ENTRY PendingRequestTable; + LIST_ENTRY DeniedCacheTable; + LIST_ENTRY ResolvedCacheTable; - EFI_EVENT PeriodicTimer; + EFI_EVENT PeriodicTimer; }; // // User request context structure. // typedef struct { - LIST_ENTRY List; - ARP_INSTANCE_DATA *Instance; - EFI_EVENT UserRequestEvent; - VOID *UserHwAddrBuffer; + LIST_ENTRY List; + ARP_INSTANCE_DATA *Instance; + EFI_EVENT UserRequestEvent; + VOID *UserHwAddrBuffer; } USER_REQUEST_CONTEXT; #define ARP_MAX_PROTOCOL_ADDRESS_LEN sizeof(EFI_IP_ADDRESS) #define ARP_MAX_HARDWARE_ADDRESS_LEN sizeof(EFI_MAC_ADDRESS) typedef union { - UINT8 ProtoAddress[ARP_MAX_PROTOCOL_ADDRESS_LEN]; - UINT8 HwAddress[ARP_MAX_HARDWARE_ADDRESS_LEN]; + UINT8 ProtoAddress[ARP_MAX_PROTOCOL_ADDRESS_LEN]; + UINT8 HwAddress[ARP_MAX_HARDWARE_ADDRESS_LEN]; } NET_ARP_ADDRESS_UNION; // // ARP address structure in an ARP packet. // typedef struct { - UINT16 Type; - UINT8 Length; - UINT8 *AddressPtr; - NET_ARP_ADDRESS_UNION Buffer; + UINT16 Type; + UINT8 Length; + UINT8 *AddressPtr; + NET_ARP_ADDRESS_UNION Buffer; } NET_ARP_ADDRESS; // @@ -207,16 +206,16 @@ typedef enum { // ARP cache entry definition. // typedef struct { - LIST_ENTRY List; + LIST_ENTRY List; - UINT32 RetryCount; - UINT32 DefaultDecayTime; - UINT32 DecayTime; - UINT32 NextRetryTime; + UINT32 RetryCount; + UINT32 DefaultDecayTime; + UINT32 DecayTime; + UINT32 NextRetryTime; - NET_ARP_ADDRESS Addresses[2]; + NET_ARP_ADDRESS Addresses[2]; - LIST_ENTRY UserRequestList; + LIST_ENTRY UserRequestList; } ARP_CACHE_ENTRY; /** @@ -522,11 +521,11 @@ ArpFindDeniedCacheEntry ( **/ ARP_CACHE_ENTRY * ArpFindNextCacheEntryInTable ( - IN LIST_ENTRY *CacheTable, - IN LIST_ENTRY *StartEntry, - IN FIND_OPTYPE FindOpType, - IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL, - IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL + IN LIST_ENTRY *CacheTable, + IN LIST_ENTRY *StartEntry, + IN FIND_OPTYPE FindOpType, + IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL, + IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL ); /** @@ -645,7 +644,7 @@ ArpInitInstance ( VOID EFIAPI ArpOnFrameRcvdDpc ( - IN VOID *Context + IN VOID *Context ); /** @@ -677,7 +676,7 @@ ArpOnFrameRcvd ( VOID EFIAPI ArpOnFrameSentDpc ( - IN VOID *Context + IN VOID *Context ); /** diff --git a/NetworkPkg/ArpDxe/ArpMain.c b/NetworkPkg/ArpDxe/ArpMain.c index 1398cdd..7c5753b 100644 --- a/NetworkPkg/ArpDxe/ArpMain.c +++ b/NetworkPkg/ArpDxe/ArpMain.c @@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "ArpImpl.h" - /** This function is used to assign a station address to the ARP cache for this instance of the ARP driver. @@ -53,9 +52,10 @@ ArpConfigure ( } if ((ConfigData != NULL) && - ((ConfigData->SwAddressLength == 0) || - (ConfigData->StationAddress == NULL) || - (ConfigData->SwAddressType <= 1500))) { + ((ConfigData->SwAddressLength == 0) || + (ConfigData->StationAddress == NULL) || + (ConfigData->SwAddressType <= 1500))) + { return EFI_INVALID_PARAMETER; } @@ -73,7 +73,6 @@ ArpConfigure ( return Status; } - /** This function is used to insert entries into the ARP cache. @@ -143,8 +142,9 @@ ArpAdd ( } if (((!DenyFlag) && ((TargetHwAddress == NULL) || (TargetSwAddress == NULL))) || - (DenyFlag && (TargetHwAddress != NULL) && (TargetSwAddress != NULL)) || - ((TargetHwAddress == NULL) && (TargetSwAddress == NULL))) { + (DenyFlag && (TargetHwAddress != NULL) && (TargetSwAddress != NULL)) || + ((TargetHwAddress == NULL) && (TargetSwAddress == NULL))) + { return EFI_INVALID_PARAMETER; } @@ -162,7 +162,7 @@ ArpAdd ( // Fill the hardware address part in the MatchAddress. // MatchAddress[Hardware].Type = SnpMode->IfType; - MatchAddress[Hardware].Length = (UINT8) SnpMode->HwAddressSize; + MatchAddress[Hardware].Length = (UINT8)SnpMode->HwAddressSize; MatchAddress[Hardware].AddressPtr = TargetHwAddress; // @@ -271,7 +271,6 @@ UNLOCK_EXIT: return Status; } - /** This function searches the ARP cache for matching entries and allocates a buffer into which those entries are copied. @@ -323,12 +322,13 @@ ArpFind ( EFI_TPL OldTpl; if ((This == NULL) || - (!Refresh && (EntryCount == NULL) && (EntryLength == NULL)) || - ((Entries != NULL) && ((EntryLength == NULL) || (EntryCount == NULL)))) { + (!Refresh && (EntryCount == NULL) && (EntryLength == NULL)) || + ((Entries != NULL) && ((EntryLength == NULL) || (EntryCount == NULL)))) + { return EFI_INVALID_PARAMETER; } - Instance = ARP_INSTANCE_DATA_FROM_THIS (This); + Instance = ARP_INSTANCE_DATA_FROM_THIS (This); if (!Instance->Configured) { return EFI_NOT_STARTED; @@ -354,7 +354,6 @@ ArpFind ( return Status; } - /** This function removes specified ARP cache entries. @@ -406,7 +405,6 @@ ArpDelete ( return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS; } - /** This function delete all dynamic entries from the ARP cache that match the specified software protocol type. @@ -451,7 +449,6 @@ ArpFlush ( return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS; } - /** This function tries to resolve the TargetSwAddress and optionally returns a TargetHwAddress if it already exists in the ARP cache. @@ -508,8 +505,9 @@ ArpRequest ( SnpMode = &ArpService->SnpMode; if ((TargetSwAddress == NULL) || - ((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) && - IP4_IS_LOCAL_BROADCAST (*((UINT32 *)TargetSwAddress)))) { + ((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) && + IP4_IS_LOCAL_BROADCAST (*((UINT32 *)TargetSwAddress)))) + { // // Return the hardware broadcast address. // @@ -519,7 +517,8 @@ ArpRequest ( } if ((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) && - IP4_IS_MULTICAST (NTOHL (*((UINT32 *)TargetSwAddress)))) { + IP4_IS_MULTICAST (NTOHL (*((UINT32 *)TargetSwAddress)))) + { // // If the software address is an IPv4 multicast address, invoke Mnp to // resolve the address. @@ -588,7 +587,7 @@ ArpRequest ( // // Create a request context for this arp request. // - RequestContext = AllocatePool (sizeof(USER_REQUEST_CONTEXT)); + RequestContext = AllocatePool (sizeof (USER_REQUEST_CONTEXT)); if (RequestContext == NULL) { DEBUG ((DEBUG_ERROR, "ArpRequest: Allocate memory for RequestContext failed.\n")); @@ -612,7 +611,6 @@ ArpRequest ( NULL ); if (CacheEntry != NULL) { - CacheEntry->NextRetryTime = Instance->ConfigData.RetryTimeOut; CacheEntry->RetryCount = Instance->ConfigData.RetryCount; } else { @@ -668,7 +666,6 @@ SIGNAL_USER: return Status; } - /** This function aborts the previous ARP request (identified by This, TargetSwAddress and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request(). @@ -709,8 +706,9 @@ ArpCancel ( EFI_TPL OldTpl; if ((This == NULL) || - ((TargetSwAddress != NULL) && (ResolvedEvent == NULL)) || - ((TargetSwAddress == NULL) && (ResolvedEvent != NULL))) { + ((TargetSwAddress != NULL) && (ResolvedEvent == NULL)) || + ((TargetSwAddress == NULL) && (ResolvedEvent != NULL))) + { return EFI_INVALID_PARAMETER; } diff --git a/NetworkPkg/ArpDxe/ComponentName.c b/NetworkPkg/ArpDxe/ComponentName.c index bcee1e1..0f78d6f 100644 --- a/NetworkPkg/ArpDxe/ComponentName.c +++ b/NetworkPkg/ArpDxe/ComponentName.c @@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "ArpDriver.h" - // // EFI Component Name Protocol // @@ -21,21 +20,20 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gArpComponentName = { // // EFI Component Name 2 Protocol // -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ArpComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ArpComponentNameGetControllerName, +GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2 = { + (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)ArpComponentNameGetDriverName, + (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)ArpComponentNameGetControllerName, "en" }; - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = { +GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = { { "eng;en", L"ARP Network Service Driver" }, - { NULL, NULL } + { NULL, NULL } }; -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpControllerNameTable[] = { +GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpControllerNameTable[] = { { "eng;en", L"ARP Controller" }, - { NULL, NULL } + { NULL, NULL } }; /** @@ -165,15 +163,15 @@ ArpComponentNameGetDriverName ( EFI_STATUS EFIAPI ArpComponentNameGetControllerName ( - 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_ARP_PROTOCOL *Arp; + EFI_STATUS Status; + EFI_ARP_PROTOCOL *Arp; // // Only provide names for child handles. @@ -200,7 +198,7 @@ ArpComponentNameGetControllerName ( Status = gBS->OpenProtocol ( ChildHandle, &gEfiArpProtocolGuid, - (VOID **)&Arp, + (VOID **)&Arp, NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL -- cgit v1.1