Use Mde library and definition instead of some native definitions in NetLib, to simply network library.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4693 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2008-02-14 09:40:22 +00:00
parent bb8ffffd1c
commit e48e37fce2
102 changed files with 1697 additions and 2477 deletions

View File

@@ -1,30 +0,0 @@
/** @file
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ArpDebug.h
Abstract:
**/
#ifndef _ARP_DEBUG_H_
#define _ARP_DEBUG_H_
#define ARP_DEBUG_TRACE(PrintArg) NET_DEBUG_TRACE ("Arp", PrintArg)
#define ARP_DEBUG_WARN(PrintArg) NET_DEBUG_WARNING ("Arp", PrintArg)
#define ARP_DEBUG_ERROR(PrintArg) NET_DEBUG_ERROR ("Arp", PrintArg)
#endif

View File

@@ -1,6 +1,6 @@
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -142,7 +142,7 @@ ArpCreateService (
//
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
NET_TPL_EVENT,
TPL_NOTIFY,
ArpOnFrameRcvd,
ArpService,
&ArpService->RxToken.Event
@@ -156,7 +156,7 @@ ArpCreateService (
//
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL | EVT_TIMER,
NET_TPL_TIMER,
TPL_CALLBACK,
ArpTimerHandler,
ArpService,
&ArpService->PeriodicTimer
@@ -180,10 +180,10 @@ ArpCreateService (
//
// Init the lists.
//
NetListInit (&ArpService->ChildrenList);
NetListInit (&ArpService->PendingRequestTable);
NetListInit (&ArpService->DeniedCacheTable);
NetListInit (&ArpService->ResolvedCacheTable);
InitializeListHead (&ArpService->ChildrenList);
InitializeListHead (&ArpService->PendingRequestTable);
InitializeListHead (&ArpService->DeniedCacheTable);
InitializeListHead (&ArpService->ResolvedCacheTable);
ERROR_EXIT:
@@ -332,7 +332,7 @@ ArpDriverBindingStart (
//
// Allocate a zero pool for ArpService.
//
ArpService = NetAllocateZeroPool (sizeof(ARP_SERVICE_DATA));
ArpService = AllocateZeroPool (sizeof(ARP_SERVICE_DATA));
if (ArpService == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -374,7 +374,7 @@ ERROR:
// On error, clean the arp service context data, and free the memory allocated.
//
ArpCleanService (ArpService);
NetFreePool (ArpService);
gBS->FreePool (ArpService);
return Status;
}
@@ -428,7 +428,7 @@ ArpDriverBindingStop (
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
ARP_DEBUG_ERROR (("ArpDriverBindingStop: Open ArpSb failed, %r.\n", Status));
DEBUG ((EFI_D_ERROR, "ArpDriverBindingStop: Open ArpSb failed, %r.\n", Status));
return EFI_DEVICE_ERROR;
}
@@ -450,18 +450,18 @@ ArpDriverBindingStop (
//
ArpCleanService (ArpService);
NetFreePool (ArpService);
gBS->FreePool (ArpService);
} else {
while (!NetListIsEmpty (&ArpService->ChildrenList)) {
while (!IsListEmpty (&ArpService->ChildrenList)) {
Instance = NET_LIST_HEAD (&ArpService->ChildrenList, ARP_INSTANCE_DATA, List);
ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
}
ASSERT (NetListIsEmpty (&ArpService->PendingRequestTable));
ASSERT (NetListIsEmpty (&ArpService->DeniedCacheTable));
ASSERT (NetListIsEmpty (&ArpService->ResolvedCacheTable));
ASSERT (IsListEmpty (&ArpService->PendingRequestTable));
ASSERT (IsListEmpty (&ArpService->DeniedCacheTable));
ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable));
}
return EFI_SUCCESS;
@@ -505,9 +505,9 @@ ArpServiceBindingCreateChild (
//
// Allocate memory for the instance context data.
//
Instance = NetAllocateZeroPool (sizeof(ARP_INSTANCE_DATA));
Instance = AllocateZeroPool (sizeof(ARP_INSTANCE_DATA));
if (Instance == NULL) {
ARP_DEBUG_ERROR (("ArpSBCreateChild: Failed to allocate memory for Instance.\n"));
DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: Failed to allocate memory for Instance.\n"));
return EFI_OUT_OF_RESOURCES;
}
@@ -527,9 +527,9 @@ ArpServiceBindingCreateChild (
NULL
);
if (EFI_ERROR (Status)) {
ARP_DEBUG_ERROR (("ArpSBCreateChild: faild to install ARP protocol, %r.\n", Status));
DEBUG ((EFI_D_ERROR, "ArpSBCreateChild: faild to install ARP protocol, %r.\n", Status));
NetFreePool (Instance);
gBS->FreePool (Instance);
return Status;
}
@@ -553,15 +553,15 @@ ArpServiceBindingCreateChild (
goto ERROR;
}
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Insert the instance into children list managed by the arp service context data.
//
NetListInsertTail (&ArpService->ChildrenList, &Instance->List);
InsertTailList (&ArpService->ChildrenList, &Instance->List);
ArpService->ChildrenNumber++;
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
ERROR:
@@ -584,7 +584,7 @@ ERROR:
//
// Free the allocated memory.
//
NetFreePool (Instance);
gBS->FreePool (Instance);
}
return Status;
@@ -672,14 +672,14 @@ ArpServiceBindingDestroyChild (
NULL
);
if (EFI_ERROR (Status)) {
ARP_DEBUG_ERROR (("ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",
DEBUG ((EFI_D_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",
Status));
Instance->Destroyed = FALSE;
return Status;
}
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (Instance->Configured) {
//
@@ -696,12 +696,12 @@ ArpServiceBindingDestroyChild (
//
// Remove this instance from the ChildrenList.
//
NetListRemoveEntry (&Instance->List);
RemoveEntryList (&Instance->List);
ArpService->ChildrenNumber--;
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
NetFreePool (Instance);
gBS->FreePool (Instance);
return Status;
}

View File

@@ -33,7 +33,6 @@ Abstract:
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include "ArpDebug.h"
//
// Global variables

View File

@@ -37,7 +37,6 @@
ComponentName.c
ArpImpl.h
ArpImpl.c
ArpDebug.h
ArpDriver.c

View File

@@ -37,7 +37,6 @@
</LibraryClassDefinitions>
<SourceFiles>
<Filename>ArpDriver.c</Filename>
<Filename>ArpDebug.h</Filename>
<Filename>ArpImpl.c</Filename>
<Filename>ArpImpl.h</Filename>
<Filename>ComponentName.c</Filename>

View File

@@ -20,7 +20,6 @@ Abstract:
#include "ArpImpl.h"
#include "ArpDebug.h"
EFI_ARP_PROTOCOL mEfiArpProtocolTemplate = {
ArpConfigure,
@@ -59,7 +58,7 @@ ArpInitInstance (
Instance->Configured = FALSE;
Instance->Destroyed = FALSE;
NetListInit (&Instance->List);
InitializeListHead (&Instance->List);
}
@@ -85,7 +84,7 @@ ArpOnFrameRcvdDpc (
ARP_HEAD *Head;
ARP_ADDRESS ArpAddress;
ARP_CACHE_ENTRY *CacheEntry;
NET_LIST_ENTRY *Entry;
LIST_ENTRY *Entry;
ARP_INSTANCE_DATA *Instance;
EFI_ARP_CONFIG_DATA *ConfigData;
NET_ARP_ADDRESS SenderAddress[2];
@@ -186,7 +185,7 @@ ArpOnFrameRcvdDpc (
// The protocol type is matched for the received arp packet.
//
ProtoMatched = TRUE;
if (0 == NetCompareMem (
if (0 == CompareMem (
(VOID *)ArpAddress.TargetProtoAddr,
ConfigData->StationAddress,
ConfigData->SwAddressLength
@@ -257,7 +256,7 @@ ArpOnFrameRcvdDpc (
}
if (!IsListEmpty (&CacheEntry->List)) {
NetListRemoveEntry (&CacheEntry->List);
RemoveEntryList (&CacheEntry->List);
}
//
@@ -277,7 +276,7 @@ ArpOnFrameRcvdDpc (
//
// Add this entry into the ResolvedCacheTable
//
NetListInsertHead (&ArpService->ResolvedCacheTable, &CacheEntry->List);
InsertHeadList (&ArpService->ResolvedCacheTable, &CacheEntry->List);
}
if (Head->OpCode == ARP_OPCODE_REQUEST) {
@@ -304,7 +303,7 @@ RESTART_RECEIVE:
DEBUG_CODE (
if (EFI_ERROR (Status)) {
ARP_DEBUG_ERROR (("ArpOnFrameRcvd: ArpService->Mnp->Receive "
DEBUG ((EFI_D_ERROR, "ArpOnFrameRcvd: ArpService->Mnp->Receive "
"failed, %r\n.", Status));
}
);
@@ -358,17 +357,17 @@ ArpOnFrameSentDpc (
DEBUG_CODE (
if (EFI_ERROR (TxToken->Status)) {
ARP_DEBUG_ERROR (("ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status));
DEBUG ((EFI_D_ERROR, "ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status));
}
);
//
// Free the allocated memory and close the event.
//
NetFreePool (TxData->FragmentTable[0].FragmentBuffer);
NetFreePool (TxData);
gBS->FreePool (TxData->FragmentTable[0].FragmentBuffer);
gBS->FreePool (TxData);
gBS->CloseEvent (TxToken->Event);
NetFreePool (TxToken);
gBS->FreePool (TxToken);
}
/**
@@ -413,9 +412,9 @@ ArpTimerHandler (
)
{
ARP_SERVICE_DATA *ArpService;
NET_LIST_ENTRY *Entry;
NET_LIST_ENTRY *NextEntry;
NET_LIST_ENTRY *ContextEntry;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
LIST_ENTRY *ContextEntry;
ARP_CACHE_ENTRY *CacheEntry;
USER_REQUEST_CONTEXT *RequestContext;
@@ -439,15 +438,15 @@ ArpTimerHandler (
// Abort this request.
//
ArpAddressResolved (CacheEntry, NULL, NULL);
ASSERT (NetListIsEmpty (&CacheEntry->UserRequestList));
ASSERT (IsListEmpty (&CacheEntry->UserRequestList));
NetListRemoveEntry (&CacheEntry->List);
NetFreePool (CacheEntry);
RemoveEntryList (&CacheEntry->List);
gBS->FreePool (CacheEntry);
} else {
//
// resend the ARP request.
//
ASSERT (!NetListIsEmpty(&CacheEntry->UserRequestList));
ASSERT (!IsListEmpty(&CacheEntry->UserRequestList));
ContextEntry = CacheEntry->UserRequestList.ForwardLink;
RequestContext = NET_LIST_USER_STRUCT (ContextEntry, USER_REQUEST_CONTEXT, List);
@@ -470,7 +469,7 @@ ArpTimerHandler (
//
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &ArpService->DeniedCacheTable) {
CacheEntry = NET_LIST_USER_STRUCT (Entry, ARP_CACHE_ENTRY, List);
ASSERT (NetListIsEmpty (&CacheEntry->UserRequestList));
ASSERT (IsListEmpty (&CacheEntry->UserRequestList));
if (CacheEntry->DefaultDecayTime == 0) {
//
@@ -483,8 +482,8 @@ ArpTimerHandler (
//
// Time out, remove it.
//
NetListRemoveEntry (&CacheEntry->List);
NetFreePool (CacheEntry);
RemoveEntryList (&CacheEntry->List);
gBS->FreePool (CacheEntry);
} else {
//
// Update the DecayTime.
@@ -498,7 +497,7 @@ ArpTimerHandler (
//
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &ArpService->ResolvedCacheTable) {
CacheEntry = NET_LIST_USER_STRUCT (Entry, ARP_CACHE_ENTRY, List);
ASSERT (NetListIsEmpty (&CacheEntry->UserRequestList));
ASSERT (IsListEmpty (&CacheEntry->UserRequestList));
if (CacheEntry->DefaultDecayTime == 0) {
//
@@ -511,8 +510,8 @@ ArpTimerHandler (
//
// Time out, remove it.
//
NetListRemoveEntry (&CacheEntry->List);
NetFreePool (CacheEntry);
RemoveEntryList (&CacheEntry->List);
gBS->FreePool (CacheEntry);
} else {
//
// Update the DecayTime.
@@ -548,7 +547,7 @@ ArpMatchAddress (
}
if ((AddressOne->AddressPtr != NULL) &&
(NetCompareMem (
(CompareMem (
AddressOne->AddressPtr,
AddressTwo->AddressPtr,
AddressOne->Length
@@ -578,14 +577,14 @@ ArpMatchAddress (
**/
ARP_CACHE_ENTRY *
ArpFindNextCacheEntryInTable (
IN NET_LIST_ENTRY *CacheTable,
IN NET_LIST_ENTRY *StartEntry,
IN LIST_ENTRY *CacheTable,
IN LIST_ENTRY *StartEntry,
IN FIND_OPTYPE FindOpType,
IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL,
IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL
)
{
NET_LIST_ENTRY *Entry;
LIST_ENTRY *Entry;
ARP_CACHE_ENTRY *CacheEntry;
if (StartEntry == NULL) {
@@ -716,7 +715,7 @@ ArpAllocCacheEntry (
//
// Allocate memory for the cache entry.
//
CacheEntry = NetAllocatePool (sizeof (ARP_CACHE_ENTRY));
CacheEntry = AllocatePool (sizeof (ARP_CACHE_ENTRY));
if (CacheEntry == NULL) {
return NULL;
}
@@ -724,8 +723,8 @@ ArpAllocCacheEntry (
//
// Init the lists.
//
NetListInit (&CacheEntry->List);
NetListInit (&CacheEntry->UserRequestList);
InitializeListHead (&CacheEntry->List);
InitializeListHead (&CacheEntry->UserRequestList);
for (Index = 0; Index < 2; Index++) {
//
@@ -738,7 +737,7 @@ ArpAllocCacheEntry (
//
// Zero the hardware address first.
//
NetZeroMem (CacheEntry->Addresses[Hardware].AddressPtr, ARP_MAX_HARDWARE_ADDRESS_LEN);
ZeroMem (CacheEntry->Addresses[Hardware].AddressPtr, ARP_MAX_HARDWARE_ADDRESS_LEN);
if (Instance != NULL) {
//
@@ -780,8 +779,8 @@ ArpAddressResolved (
IN EFI_EVENT UserEvent OPTIONAL
)
{
NET_LIST_ENTRY *Entry;
NET_LIST_ENTRY *NextEntry;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
USER_REQUEST_CONTEXT *Context;
UINTN Count;
@@ -798,7 +797,7 @@ ArpAddressResolved (
//
// Copy the address to the user-provided buffer and notify the user.
//
NetCopyMem (
CopyMem (
Context->UserHwAddrBuffer,
CacheEntry->Addresses[Hardware].AddressPtr,
CacheEntry->Addresses[Hardware].Length
@@ -808,8 +807,8 @@ ArpAddressResolved (
//
// Remove this user request and free the context data.
//
NetListRemoveEntry (&Context->List);
NetFreePool (Context);
RemoveEntryList (&Context->List);
gBS->FreePool (Context);
Count++;
}
@@ -863,7 +862,7 @@ ArpFillAddressInCacheEntry (
//
// Copy it if the AddressPtr points to some buffer.
//
NetCopyMem (
CopyMem (
CacheAddress->AddressPtr,
Address[Index]->AddressPtr,
CacheAddress->Length
@@ -872,7 +871,7 @@ ArpFillAddressInCacheEntry (
//
// Zero the corresponding address buffer in the CacheEntry.
//
NetZeroMem (CacheAddress->AddressPtr, CacheAddress->Length);
ZeroMem (CacheAddress->AddressPtr, CacheAddress->Length);
}
}
}
@@ -916,7 +915,7 @@ ArpConfigureInstance (
//
if ((OldConfigData->SwAddressType != ConfigData->SwAddressType) ||
(OldConfigData->SwAddressLength != ConfigData->SwAddressLength) ||
(NetCompareMem (
(CompareMem (
OldConfigData->StationAddress,
ConfigData->StationAddress,
OldConfigData->SwAddressLength
@@ -932,7 +931,7 @@ ArpConfigureInstance (
//
if (ConfigData->SwAddressType == IPv4_ETHER_PROTO_TYPE) {
NetCopyMem (&Ip, ConfigData->StationAddress, sizeof (IP4_ADDR));
CopyMem (&Ip, ConfigData->StationAddress, sizeof (IP4_ADDR));
if (!Ip4IsUnicast (NTOHL (Ip), 0)) {
//
@@ -947,9 +946,9 @@ ArpConfigureInstance (
//
CopyMem (OldConfigData, ConfigData, sizeof (*OldConfigData));
OldConfigData->StationAddress = NetAllocatePool (OldConfigData->SwAddressLength);
OldConfigData->StationAddress = AllocatePool (OldConfigData->SwAddressLength);
if (OldConfigData->StationAddress == NULL) {
ARP_DEBUG_ERROR (("ArpConfigInstance: NetAllocatePool for the StationAddress "
DEBUG ((EFI_D_ERROR, "ArpConfigInstance: AllocatePool for the StationAddress "
"failed.\n"));
return EFI_OUT_OF_RESOURCES;
}
@@ -957,7 +956,7 @@ ArpConfigureInstance (
//
// Save the StationAddress.
//
NetCopyMem (
CopyMem (
OldConfigData->StationAddress,
ConfigData->StationAddress,
OldConfigData->SwAddressLength
@@ -994,7 +993,7 @@ ArpConfigureInstance (
//
// Free the buffer previously allocated to hold the station address.
//
NetFreePool (OldConfigData->StationAddress);
gBS->FreePool (OldConfigData->StationAddress);
}
Instance->Configured = FALSE;
@@ -1039,9 +1038,9 @@ ArpSendFrame (
//
// Allocate memory for the TxToken.
//
TxToken = NetAllocatePool (sizeof(EFI_MANAGED_NETWORK_COMPLETION_TOKEN));
TxToken = AllocatePool (sizeof(EFI_MANAGED_NETWORK_COMPLETION_TOKEN));
if (TxToken == NULL) {
ARP_DEBUG_ERROR (("ArpSendFrame: Allocate memory for TxToken failed.\n"));
DEBUG ((EFI_D_ERROR, "ArpSendFrame: Allocate memory for TxToken failed.\n"));
return;
}
@@ -1054,22 +1053,22 @@ ArpSendFrame (
//
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
NET_TPL_EVENT,
TPL_NOTIFY,
ArpOnFrameSent,
(VOID *)TxToken,
&TxToken->Event
);
if (EFI_ERROR (Status)) {
ARP_DEBUG_ERROR (("ArpSendFrame: CreateEvent failed for TxToken->Event.\n"));
DEBUG ((EFI_D_ERROR, "ArpSendFrame: CreateEvent failed for TxToken->Event.\n"));
goto CLEAN_EXIT;
}
//
// Allocate memory for the TxData used in the TxToken.
//
TxData = NetAllocatePool (sizeof(EFI_MANAGED_NETWORK_TRANSMIT_DATA));
TxData = AllocatePool (sizeof(EFI_MANAGED_NETWORK_TRANSMIT_DATA));
if (TxData == NULL) {
ARP_DEBUG_ERROR (("ArpSendFrame: Allocate memory for TxData failed.\n"));
DEBUG ((EFI_D_ERROR, "ArpSendFrame: Allocate memory for TxData failed.\n"));
goto CLEAN_EXIT;
}
@@ -1086,9 +1085,9 @@ ArpSendFrame (
//
// Allocate buffer for the arp frame.
//
Packet = NetAllocatePool (TotalLength);
Packet = AllocatePool (TotalLength);
if (Packet == NULL) {
ARP_DEBUG_ERROR (("ArpSendFrame: Allocate memory for Packet failed.\n"));
DEBUG ((EFI_D_ERROR, "ArpSendFrame: Allocate memory for Packet failed.\n"));
}
TmpPtr = Packet;
@@ -1097,9 +1096,9 @@ ArpSendFrame (
// The destination MAC address.
//
if (ArpOpCode == ARP_OPCODE_REQUEST) {
NetCopyMem (TmpPtr, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize);
CopyMem (TmpPtr, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize);
} else {
NetCopyMem (
CopyMem (
TmpPtr,
CacheEntry->Addresses[Hardware].AddressPtr,
SnpMode->HwAddressSize
@@ -1110,7 +1109,7 @@ ArpSendFrame (
//
// The source MAC address.
//
NetCopyMem (TmpPtr, &SnpMode->CurrentAddress, SnpMode->HwAddressSize);
CopyMem (TmpPtr, &SnpMode->CurrentAddress, SnpMode->HwAddressSize);
TmpPtr += SnpMode->HwAddressSize;
//
@@ -1133,19 +1132,19 @@ ArpSendFrame (
//
// The sender hardware address.
//
NetCopyMem (TmpPtr, &SnpMode->CurrentAddress, SnpMode->HwAddressSize);
CopyMem (TmpPtr, &SnpMode->CurrentAddress, SnpMode->HwAddressSize);
TmpPtr += SnpMode->HwAddressSize;
//
// The sender protocol address.
//
NetCopyMem (TmpPtr, ConfigData->StationAddress, ConfigData->SwAddressLength);
CopyMem (TmpPtr, ConfigData->StationAddress, ConfigData->SwAddressLength);
TmpPtr += ConfigData->SwAddressLength;
//
// The target hardware address.
//
NetCopyMem (
CopyMem (
TmpPtr,
CacheEntry->Addresses[Hardware].AddressPtr,
SnpMode->HwAddressSize
@@ -1155,7 +1154,7 @@ ArpSendFrame (
//
// The target protocol address.
//
NetCopyMem (
CopyMem (
TmpPtr,
CacheEntry->Addresses[Protocol].AddressPtr,
ConfigData->SwAddressLength
@@ -1185,7 +1184,7 @@ ArpSendFrame (
//
Status = ArpService->Mnp->Transmit (ArpService->Mnp, TxToken);
if (EFI_ERROR (Status)) {
ARP_DEBUG_ERROR (("Mnp->Transmit failed, %r.\n", Status));
DEBUG ((EFI_D_ERROR, "Mnp->Transmit failed, %r.\n", Status));
goto CLEAN_EXIT;
}
@@ -1194,18 +1193,18 @@ ArpSendFrame (
CLEAN_EXIT:
if (Packet != NULL) {
NetFreePool (Packet);
gBS->FreePool (Packet);
}
if (TxData != NULL) {
NetFreePool (TxData);
gBS->FreePool (TxData);
}
if (TxToken->Event != NULL) {
gBS->CloseEvent (TxToken->Event);
}
NetFreePool (TxToken);
gBS->FreePool (TxToken);
}
@@ -1228,15 +1227,15 @@ CLEAN_EXIT:
STATIC
UINTN
ArpDeleteCacheEntryInTable (
IN NET_LIST_ENTRY *CacheTable,
IN LIST_ENTRY *CacheTable,
IN BOOLEAN BySwAddress,
IN UINT16 SwAddressType,
IN UINT8 *AddressBuffer OPTIONAL,
IN BOOLEAN Force
)
{
NET_LIST_ENTRY *Entry;
NET_LIST_ENTRY *NextEntry;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
ARP_CACHE_ENTRY *CacheEntry;
UINTN Count;
@@ -1258,7 +1257,7 @@ ArpDeleteCacheEntryInTable (
// Protocol address type matched. Check the address.
//
if ((AddressBuffer == NULL) ||
(NetCompareMem (
(CompareMem (
AddressBuffer,
CacheEntry->Addresses[Protocol].AddressPtr,
CacheEntry->Addresses[Protocol].Length
@@ -1271,7 +1270,7 @@ ArpDeleteCacheEntryInTable (
}
} else {
if ((AddressBuffer == NULL) ||
(NetCompareMem (
(CompareMem (
AddressBuffer,
CacheEntry->Addresses[Hardware].AddressPtr,
CacheEntry->Addresses[Hardware].Length
@@ -1290,9 +1289,9 @@ MATCHED:
//
// Delete this entry.
//
NetListRemoveEntry (&CacheEntry->List);
ASSERT (NetListIsEmpty (&CacheEntry->UserRequestList));
NetFreePool (CacheEntry);
RemoveEntryList (&CacheEntry->List);
ASSERT (IsListEmpty (&CacheEntry->UserRequestList));
gBS->FreePool (CacheEntry);
Count++;
}
@@ -1375,8 +1374,8 @@ ArpCancelRequest (
)
{
ARP_SERVICE_DATA *ArpService;
NET_LIST_ENTRY *Entry;
NET_LIST_ENTRY *NextEntry;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
ARP_CACHE_ENTRY *CacheEntry;
UINTN Count;
@@ -1389,7 +1388,7 @@ ArpCancelRequest (
CacheEntry = NET_LIST_USER_STRUCT (Entry, ARP_CACHE_ENTRY, List);
if ((TargetSwAddress == NULL) ||
(NetCompareMem (
(CompareMem (
TargetSwAddress,
CacheEntry->Addresses[Protocol].AddressPtr,
CacheEntry->Addresses[Protocol].Length
@@ -1400,12 +1399,12 @@ ArpCancelRequest (
//
Count += ArpAddressResolved (CacheEntry, Instance, UserEvent);
if (NetListIsEmpty (&CacheEntry->UserRequestList)) {
if (IsListEmpty (&CacheEntry->UserRequestList)) {
//
// No user requests any more, remove this request cache entry.
//
NetListRemoveEntry (&CacheEntry->List);
NetFreePool (CacheEntry);
RemoveEntryList (&CacheEntry->List);
gBS->FreePool (CacheEntry);
}
}
}
@@ -1452,12 +1451,12 @@ ArpFindCacheEntry (
ARP_SERVICE_DATA *ArpService;
NET_ARP_ADDRESS MatchAddress;
FIND_OPTYPE FindOpType;
NET_LIST_ENTRY *StartEntry;
LIST_ENTRY *StartEntry;
ARP_CACHE_ENTRY *CacheEntry;
NET_MAP FoundEntries;
UINT32 FoundCount;
EFI_ARP_FIND_DATA *FindData;
NET_LIST_ENTRY *CacheTable;
LIST_ENTRY *CacheTable;
ArpService = Instance->ArpService;
@@ -1596,9 +1595,9 @@ ArpFindCacheEntry (
//
// Allocate buffer to copy the found entries.
//
FindData = NetAllocatePool (FoundCount * (*EntryLength));
FindData = AllocatePool (FoundCount * (*EntryLength));
if (FindData == NULL) {
ARP_DEBUG_ERROR (("ArpFindCacheEntry: Failed to allocate memory.\n"));
DEBUG ((EFI_D_ERROR, "ArpFindCacheEntry: Failed to allocate memory.\n"));
Status = EFI_OUT_OF_RESOURCES;
goto CLEAN_EXIT;
}
@@ -1631,7 +1630,7 @@ ArpFindCacheEntry (
//
// Copy the software address.
//
NetCopyMem (
CopyMem (
FindData + 1,
CacheEntry->Addresses[Protocol].AddressPtr,
FindData->SwAddressLength
@@ -1640,7 +1639,7 @@ ArpFindCacheEntry (
//
// Copy the hardware address.
//
NetCopyMem (
CopyMem (
(UINT8 *)(FindData + 1) + FindData->SwAddressLength,
CacheEntry->Addresses[Hardware].AddressPtr,
FindData->HwAddressLength

View File

@@ -37,7 +37,6 @@ Abstract:
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include "ArpDebug.h"
#define ARP_ETHER_PROTO_TYPE 0x0806
#define IPv4_ETHER_PROTO_TYPE 0x0800
@@ -95,7 +94,7 @@ typedef struct _ARP_INSTANCE_DATA {
ARP_SERVICE_DATA *ArpService;
EFI_HANDLE Handle;
EFI_ARP_PROTOCOL ArpProto;
NET_LIST_ENTRY List;
LIST_ENTRY List;
EFI_ARP_CONFIG_DATA ConfigData;
BOOLEAN Configured;
BOOLEAN Destroyed;
@@ -126,17 +125,17 @@ struct _ARP_SERVICE_DATA {
EFI_SIMPLE_NETWORK_MODE SnpMode;
UINTN ChildrenNumber;
NET_LIST_ENTRY ChildrenList;
LIST_ENTRY ChildrenList;
NET_LIST_ENTRY PendingRequestTable;
NET_LIST_ENTRY DeniedCacheTable;
NET_LIST_ENTRY ResolvedCacheTable;
LIST_ENTRY PendingRequestTable;
LIST_ENTRY DeniedCacheTable;
LIST_ENTRY ResolvedCacheTable;
EFI_EVENT PeriodicTimer;
};
typedef struct _USER_REQUEST_CONTEXT {
NET_LIST_ENTRY List;
LIST_ENTRY List;
ARP_INSTANCE_DATA *Instance;
EFI_EVENT UserRequestEvent;
VOID *UserHwAddrBuffer;
@@ -161,7 +160,7 @@ typedef enum {
} ARP_ADDRESS_TYPE;
typedef struct _ARP_CACHE_ENTRY {
NET_LIST_ENTRY List;
LIST_ENTRY List;
UINT32 RetryCount;
UINT32 DefaultDecayTime;
@@ -170,7 +169,7 @@ typedef struct _ARP_CACHE_ENTRY {
NET_ARP_ADDRESS Addresses[2];
NET_LIST_ENTRY UserRequestList;
LIST_ENTRY UserRequestList;
} ARP_CACHE_ENTRY;
EFI_STATUS
@@ -249,8 +248,8 @@ ArpFindDeniedCacheEntry (
ARP_CACHE_ENTRY *
ArpFindNextCacheEntryInTable (
IN NET_LIST_ENTRY *CacheTable,
IN NET_LIST_ENTRY *StartEntry,
IN LIST_ENTRY *CacheTable,
IN LIST_ENTRY *StartEntry,
IN FIND_OPTYPE FindOpType,
IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL,
IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL

View File

@@ -66,14 +66,14 @@ ArpConfigure (
Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Configure this instance, the ConfigData has already passed the basic checks.
//
Status = ArpConfigureInstance (Instance, ConfigData);
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
return Status;
}
@@ -166,7 +166,7 @@ ArpAdd (
MatchAddress[Protocol].Length = Instance->ConfigData.SwAddressLength;
MatchAddress[Protocol].AddressPtr = TargetSwAddress;
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// See whether the entry to add exists. Check the DeinedCacheTable first.
@@ -215,7 +215,7 @@ ArpAdd (
//
// Remove it from the Table.
//
NetListRemoveEntry (&CacheEntry->List);
RemoveEntryList (&CacheEntry->List);
} else {
//
// It's a new entry, allocate memory for the entry.
@@ -223,7 +223,7 @@ ArpAdd (
CacheEntry = ArpAllocCacheEntry (Instance);
if (CacheEntry == NULL) {
ARP_DEBUG_ERROR (("ArpAdd: Failed to allocate pool for CacheEntry.\n"));
DEBUG ((EFI_D_ERROR, "ArpAdd: Failed to allocate pool for CacheEntry.\n"));
Status = EFI_OUT_OF_RESOURCES;
goto UNLOCK_EXIT;
}
@@ -253,14 +253,14 @@ ArpAdd (
// Add this CacheEntry to the corresponding CacheTable.
//
if (DenyFlag) {
NetListInsertHead (&ArpService->DeniedCacheTable, &CacheEntry->List);
InsertHeadList (&ArpService->DeniedCacheTable, &CacheEntry->List);
} else {
NetListInsertHead (&ArpService->ResolvedCacheTable, &CacheEntry->List);
InsertHeadList (&ArpService->ResolvedCacheTable, &CacheEntry->List);
}
UNLOCK_EXIT:
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
return Status;
}
@@ -321,7 +321,7 @@ ArpFind (
return EFI_NOT_STARTED;
}
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// All the check passed, find the cache entries now.
@@ -336,7 +336,7 @@ ArpFind (
Refresh
);
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
return Status;
}
@@ -381,14 +381,14 @@ ArpDelete (
return EFI_NOT_STARTED;
}
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Delete the specified cache entries.
//
Count = ArpDeleteCacheEntry (Instance, BySwAddress, AddressBuffer, TRUE);
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
}
@@ -426,14 +426,14 @@ ArpFlush (
return EFI_NOT_STARTED;
}
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Delete the dynamic entries from the cache table.
//
Count = ArpDeleteCacheEntry (Instance, FALSE, NULL, FALSE);
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
}
@@ -500,7 +500,7 @@ ArpRequest (
//
// Return the hardware broadcast address.
//
NetCopyMem (TargetHwAddress, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize);
CopyMem (TargetHwAddress, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize);
goto SIGNAL_USER;
}
@@ -531,9 +531,9 @@ ArpRequest (
//
// Initialize the TargetHwAddrss to a zero address.
//
NetZeroMem (TargetHwAddress, SnpMode->HwAddressSize);
ZeroMem (TargetHwAddress, SnpMode->HwAddressSize);
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Check whether the software address is in the denied table.
@@ -558,7 +558,7 @@ ArpRequest (
//
// Resolved, copy the address into the user buffer.
//
NetCopyMem (
CopyMem (
TargetHwAddress,
CacheEntry->Addresses[Hardware].AddressPtr,
CacheEntry->Addresses[Hardware].Length
@@ -575,9 +575,9 @@ ArpRequest (
//
// Create a request context for this arp request.
//
RequestContext = NetAllocatePool (sizeof(USER_REQUEST_CONTEXT));
RequestContext = AllocatePool (sizeof(USER_REQUEST_CONTEXT));
if (RequestContext == NULL) {
ARP_DEBUG_ERROR (("ArpRequest: Allocate memory for RequestContext failed.\n"));
DEBUG ((EFI_D_ERROR, "ArpRequest: Allocate memory for RequestContext failed.\n"));
Status = EFI_OUT_OF_RESOURCES;
goto UNLOCK_EXIT;
@@ -586,7 +586,7 @@ ArpRequest (
RequestContext->Instance = Instance;
RequestContext->UserRequestEvent = ResolvedEvent;
RequestContext->UserHwAddrBuffer = TargetHwAddress;
NetListInit (&RequestContext->List);
InitializeListHead (&RequestContext->List);
//
// Check whether there is a same request.
@@ -608,8 +608,8 @@ ArpRequest (
//
CacheEntry = ArpAllocCacheEntry (Instance);
if (CacheEntry == NULL) {
ARP_DEBUG_ERROR (("ArpRequest: Allocate memory for CacheEntry failed.\n"));
NetFreePool (RequestContext);
DEBUG ((EFI_D_ERROR, "ArpRequest: Allocate memory for CacheEntry failed.\n"));
gBS->FreePool (RequestContext);
Status = EFI_OUT_OF_RESOURCES;
goto UNLOCK_EXIT;
@@ -623,13 +623,13 @@ ArpRequest (
//
// Add this entry into the PendingRequestTable.
//
NetListInsertTail (&ArpService->PendingRequestTable, &CacheEntry->List);
InsertTailList (&ArpService->PendingRequestTable, &CacheEntry->List);
}
//
// Link this request context into the cache entry.
//
NetListInsertHead (&CacheEntry->UserRequestList, &RequestContext->List);
InsertHeadList (&CacheEntry->UserRequestList, &RequestContext->List);
//
// Send out the ARP Request frame.
@@ -639,7 +639,7 @@ ArpRequest (
UNLOCK_EXIT:
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
SIGNAL_USER:
@@ -701,7 +701,7 @@ ArpCancel (
return EFI_NOT_STARTED;
}
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Cancel the specified request.
@@ -714,7 +714,7 @@ ArpCancel (
//
NetLibDispatchDpc ();
NET_RESTORE_TPL (OldTpl);
gBS->RestoreTPL (OldTpl);
return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
}