diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-02-14 09:40:22 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-02-14 09:40:22 +0000 |
commit | e48e37fce2611df7a52aff271835ff72ee396d9b (patch) | |
tree | f6427ba11251479c615da9b5a3e38aa8c7b0f943 /MdeModulePkg/Library | |
parent | bb8ffffd1c0ff0ee697c26d377fd9767097cc02b (diff) | |
download | edk2-e48e37fce2611df7a52aff271835ff72ee396d9b.zip edk2-e48e37fce2611df7a52aff271835ff72ee396d9b.tar.gz edk2-e48e37fce2611df7a52aff271835ff72ee396d9b.tar.bz2 |
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
Diffstat (limited to 'MdeModulePkg/Library')
-rw-r--r-- | MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c | 76 | ||||
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 106 | ||||
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf | 2 | ||||
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 92 | ||||
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/NetDebug.c | 536 | ||||
-rw-r--r-- | MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c | 50 |
6 files changed, 163 insertions, 699 deletions
diff --git a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c index 2dd6e60..4674d7d 100644 --- a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c +++ b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c @@ -36,7 +36,7 @@ Abstract: #define ICMP_ERRLEN(IpHdr) \
(sizeof(IP4_ICMP_HEAD) + EFI_IP4_HEADER_LEN(IpHdr) + 8)
-NET_LIST_ENTRY mActiveIpIoList = {
+LIST_ENTRY mActiveIpIoList = {
&mActiveIpIoList,
&mActiveIpIoList
};
@@ -388,7 +388,7 @@ IpIoCreateSndEntry ( //
// Allocate resource for SndEntry
//
- SndEntry = NetAllocatePool (sizeof (IP_IO_SEND_ENTRY));
+ SndEntry = AllocatePool (sizeof (IP_IO_SEND_ENTRY));
if (NULL == SndEntry) {
return NULL;
}
@@ -396,14 +396,14 @@ IpIoCreateSndEntry ( //
// Allocate resource for SndToken
//
- SndToken = NetAllocatePool (sizeof (EFI_IP4_COMPLETION_TOKEN));
+ SndToken = AllocatePool (sizeof (EFI_IP4_COMPLETION_TOKEN));
if (NULL == SndToken) {
goto ReleaseSndEntry;
}
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
- NET_TPL_EVENT,
+ TPL_NOTIFY,
IpIoTransmitHandler,
SndEntry,
&(SndToken->Event)
@@ -415,7 +415,7 @@ IpIoCreateSndEntry ( //
// Allocate resource for TxData
//
- TxData = NetAllocatePool (
+ TxData = AllocatePool (
sizeof (EFI_IP4_TRANSMIT_DATA) +
sizeof (EFI_IP4_FRAGMENT_DATA) * (Pkt->BlockOpNum - 1)
);
@@ -430,7 +430,7 @@ IpIoCreateSndEntry ( OverrideData = NULL;
if (NULL != Override) {
- OverrideData = NetAllocatePool (sizeof (EFI_IP4_OVERRIDE_DATA));
+ OverrideData = AllocatePool (sizeof (EFI_IP4_OVERRIDE_DATA));
if (NULL == OverrideData) {
goto ReleaseResource;
}
@@ -443,7 +443,7 @@ IpIoCreateSndEntry ( //
// Set the fields of TxData
//
- NetCopyMem (&TxData->DestinationAddress, &Dest, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&TxData->DestinationAddress, &Dest, sizeof (EFI_IPv4_ADDRESS));
TxData->OverrideData = OverrideData;
TxData->OptionsLength = 0;
TxData->OptionsBuffer = NULL;
@@ -474,21 +474,21 @@ IpIoCreateSndEntry ( SndEntry->SndToken = SndToken;
- NetListInsertTail (&IpIo->PendingSndList, &SndEntry->Entry);
+ InsertTailList (&IpIo->PendingSndList, &SndEntry->Entry);
return SndEntry;
ReleaseResource:
- NetFreePool (TxData);
+ gBS->FreePool (TxData);
ReleaseEvent:
gBS->CloseEvent (SndToken->Event);
ReleaseSndToken:
- NetFreePool (SndToken);
+ gBS->FreePool (SndToken);
ReleaseSndEntry:
- NetFreePool (SndEntry);
+ gBS->FreePool (SndEntry);
return NULL;
}
@@ -513,17 +513,17 @@ IpIoDestroySndEntry ( TxData = SndEntry->SndToken->Packet.TxData;
if (NULL != TxData->OverrideData) {
- NetFreePool (TxData->OverrideData);
+ gBS->FreePool (TxData->OverrideData);
}
- NetFreePool (TxData);
+ gBS->FreePool (TxData);
NetbufFree (SndEntry->Pkt);
gBS->CloseEvent (SndEntry->SndToken->Event);
- NetFreePool (SndEntry->SndToken);
- NetListRemoveEntry (&SndEntry->Entry);
+ gBS->FreePool (SndEntry->SndToken);
+ RemoveEntryList (&SndEntry->Entry);
- NetFreePool (SndEntry);
+ gBS->FreePool (SndEntry);
}
@@ -791,19 +791,19 @@ IpIoCreate ( EFI_STATUS Status;
IP_IO *IpIo;
- IpIo = NetAllocateZeroPool (sizeof (IP_IO));
+ IpIo = AllocateZeroPool (sizeof (IP_IO));
if (NULL == IpIo) {
return NULL;
}
- NetListInit (&(IpIo->PendingSndList));
- NetListInit (&(IpIo->IpList));
+ InitializeListHead (&(IpIo->PendingSndList));
+ InitializeListHead (&(IpIo->IpList));
IpIo->Controller = Controller;
IpIo->Image = Image;
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
- NET_TPL_EVENT,
+ TPL_NOTIFY,
IpIoListenHandler,
IpIo,
&(IpIo->RcvToken.Event)
@@ -833,7 +833,7 @@ ReleaseIpIo: gBS->CloseEvent (IpIo->RcvToken.Event);
}
- NetFreePool (IpIo);
+ gBS->FreePool (IpIo);
return NULL;
}
@@ -902,7 +902,7 @@ IpIoOpen ( }
IpIo->IsConfigured = TRUE;
- NetListInsertTail (&mActiveIpIoList, &IpIo->Entry);
+ InsertTailList (&mActiveIpIoList, &IpIo->Entry);
ErrorExit:
@@ -935,7 +935,7 @@ IpIoStop ( //
// Remove the IpIo from the active IpIo list.
//
- NetListRemoveEntry (&IpIo->Entry);
+ RemoveEntryList (&IpIo->Entry);
Ip = IpIo->Ip;
@@ -953,7 +953,7 @@ IpIoStop ( // Detroy the Ip List used by IpIo
//
- while (!NetListIsEmpty (&(IpIo->IpList))) {
+ while (!IsListEmpty (&(IpIo->IpList))) {
IpInfo = NET_LIST_HEAD (&(IpIo->IpList), IP_IO_IP_INFO, Entry);
IpIoRemoveIp (IpIo, IpInfo);
@@ -962,7 +962,7 @@ IpIoStop ( //
// All pending snd tokens should be flushed by reseting the IP instances.
//
- ASSERT (NetListIsEmpty (&IpIo->PendingSndList));
+ ASSERT (IsListEmpty (&IpIo->PendingSndList));
//
// Close the receive event.
@@ -998,7 +998,7 @@ IpIoDestroy ( //
IpIoCloseProtocolDestroyIpChild (IpIo->Controller, IpIo->Image, IpIo->ChildHandle);
- NetFreePool (IpIo);
+ gBS->FreePool (IpIo);
return EFI_SUCCESS;
}
@@ -1077,7 +1077,7 @@ IpIoCancelTxToken ( IN VOID *Packet
)
{
- NET_LIST_ENTRY *Node;
+ LIST_ENTRY *Node;
IP_IO_SEND_ENTRY *SndEntry;
EFI_IP4_PROTOCOL *Ip;
@@ -1118,7 +1118,7 @@ IpIoAddIp ( ASSERT (IpIo);
- IpInfo = NetAllocatePool (sizeof (IP_IO_IP_INFO));
+ IpInfo = AllocatePool (sizeof (IP_IO_IP_INFO));
if (IpInfo == NULL) {
return IpInfo;
}
@@ -1127,7 +1127,7 @@ IpIoAddIp ( // Init this IpInfo, set the Addr and SubnetMask to 0 before we configure the IP
// instance.
//
- NetListInit (&IpInfo->Entry);
+ InitializeListHead (&IpInfo->Entry);
IpInfo->ChildHandle = NULL;
IpInfo->Addr = 0;
IpInfo->SubnetMask = 0;
@@ -1151,7 +1151,7 @@ IpIoAddIp ( //
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
- NET_TPL_EVENT,
+ TPL_NOTIFY,
IpIoDummyHandler,
IpInfo,
&IpInfo->DummyRcvToken.Event
@@ -1163,7 +1163,7 @@ IpIoAddIp ( //
// Link this IpInfo into the IpIo.
//
- NetListInsertTail (&IpIo->IpList, &IpInfo->Entry);
+ InsertTailList (&IpIo->IpList, &IpInfo->Entry);
return IpInfo;
@@ -1177,7 +1177,7 @@ ReleaseIpChild: ReleaseIpInfo:
- NetFreePool (IpInfo);
+ gBS->FreePool (IpInfo);
return NULL;
}
@@ -1236,8 +1236,8 @@ IpIoConfigIp ( Ip4ConfigData->SubnetMask = Ip4ModeData.ConfigData.SubnetMask;
}
- NetCopyMem (&IpInfo->Addr, &Ip4ConfigData->StationAddress, sizeof (IP4_ADDR));
- NetCopyMem (&IpInfo->SubnetMask, &Ip4ConfigData->SubnetMask, sizeof (IP4_ADDR));
+ CopyMem (&IpInfo->Addr, &Ip4ConfigData->StationAddress, sizeof (IP4_ADDR));
+ CopyMem (&IpInfo->SubnetMask, &Ip4ConfigData->SubnetMask, sizeof (IP4_ADDR));
Status = Ip->Receive (Ip, &IpInfo->DummyRcvToken);
if (EFI_ERROR (Status)) {
@@ -1283,7 +1283,7 @@ IpIoRemoveIp ( return;
}
- NetListRemoveEntry (&IpInfo->Entry);
+ RemoveEntryList (&IpInfo->Entry);
IpInfo->Ip->Configure (IpInfo->Ip, NULL);
@@ -1291,7 +1291,7 @@ IpIoRemoveIp ( gBS->CloseEvent (IpInfo->DummyRcvToken.Event);
- NetFreePool (IpInfo);
+ gBS->FreePool (IpInfo);
}
@@ -1312,9 +1312,9 @@ IpIoFindSender ( IN IP4_ADDR Src
)
{
- NET_LIST_ENTRY *IpIoEntry;
+ LIST_ENTRY *IpIoEntry;
IP_IO *IpIoPtr;
- NET_LIST_ENTRY *IpInfoEntry;
+ LIST_ENTRY *IpInfoEntry;
IP_IO_IP_INFO *IpInfo;
NET_LIST_FOR_EACH (IpIoEntry, &mActiveIpIoList) {
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index ee8b679..b813db3 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -255,7 +255,7 @@ NetGetUint32 ( {
UINT32 Value;
- NetCopyMem (&Value, Buf, sizeof (UINT32));
+ CopyMem (&Value, Buf, sizeof (UINT32));
return NTOHL (Value);
}
@@ -277,7 +277,7 @@ NetPutUint32 ( )
{
Data = HTONL (Data);
- NetCopyMem (Buf, &Data, sizeof (UINT32));
+ CopyMem (Buf, &Data, sizeof (UINT32));
}
@@ -289,16 +289,16 @@ NetPutUint32 ( @return The entry that is removed from the list, NULL if the list is empty.
**/
-NET_LIST_ENTRY *
+LIST_ENTRY *
NetListRemoveHead (
- NET_LIST_ENTRY *Head
+ LIST_ENTRY *Head
)
{
- NET_LIST_ENTRY *First;
+ LIST_ENTRY *First;
ASSERT (Head != NULL);
- if (NetListIsEmpty (Head)) {
+ if (IsListEmpty (Head)) {
return NULL;
}
@@ -307,8 +307,8 @@ NetListRemoveHead ( First->ForwardLink->BackLink = Head;
DEBUG_CODE (
- First->ForwardLink = (LIST_ENTRY *) NULL;
- First->BackLink = (LIST_ENTRY *) NULL;
+ First->ForwardLink = (LIST_ENTRY *) NULL;
+ First->BackLink = (LIST_ENTRY *) NULL;
);
return First;
@@ -323,16 +323,16 @@ NetListRemoveHead ( @return The entry that is removed from the list, NULL if the list is empty.
**/
-NET_LIST_ENTRY *
+LIST_ENTRY *
NetListRemoveTail (
- NET_LIST_ENTRY *Head
+ LIST_ENTRY *Head
)
{
- NET_LIST_ENTRY *Last;
+ LIST_ENTRY *Last;
ASSERT (Head != NULL);
- if (NetListIsEmpty (Head)) {
+ if (IsListEmpty (Head)) {
return NULL;
}
@@ -341,8 +341,8 @@ NetListRemoveTail ( Last->BackLink->ForwardLink = Head;
DEBUG_CODE (
- Last->ForwardLink = (LIST_ENTRY *) NULL;
- Last->BackLink = (LIST_ENTRY *) NULL;
+ Last->ForwardLink = (LIST_ENTRY *) NULL;
+ Last->BackLink = (LIST_ENTRY *) NULL;
);
return Last;
@@ -360,8 +360,8 @@ NetListRemoveTail ( **/
VOID
NetListInsertAfter (
- IN NET_LIST_ENTRY *PrevEntry,
- IN NET_LIST_ENTRY *NewEntry
+ IN LIST_ENTRY *PrevEntry,
+ IN LIST_ENTRY *NewEntry
)
{
NewEntry->BackLink = PrevEntry;
@@ -382,8 +382,8 @@ NetListInsertAfter ( **/
VOID
NetListInsertBefore (
- IN NET_LIST_ENTRY *PostEntry,
- IN NET_LIST_ENTRY *NewEntry
+ IN LIST_ENTRY *PostEntry,
+ IN LIST_ENTRY *NewEntry
)
{
NewEntry->ForwardLink = PostEntry;
@@ -408,8 +408,8 @@ NetMapInit ( {
ASSERT (Map != NULL);
- NetListInit (&Map->Used);
- NetListInit (&Map->Recycled);
+ InitializeListHead (&Map->Used);
+ InitializeListHead (&Map->Recycled);
Map->Count = 0;
}
@@ -428,30 +428,30 @@ NetMapClean ( )
{
NET_MAP_ITEM *Item;
- NET_LIST_ENTRY *Entry;
- NET_LIST_ENTRY *Next;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
ASSERT (Map != NULL);
NET_LIST_FOR_EACH_SAFE (Entry, Next, &Map->Used) {
Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
- NetListRemoveEntry (&Item->Link);
+ RemoveEntryList (&Item->Link);
Map->Count--;
- NetFreePool (Item);
+ gBS->FreePool (Item);
}
- ASSERT ((Map->Count == 0) && NetListIsEmpty (&Map->Used));
+ ASSERT ((Map->Count == 0) && IsListEmpty (&Map->Used));
NET_LIST_FOR_EACH_SAFE (Entry, Next, &Map->Recycled) {
Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
- NetListRemoveEntry (&Item->Link);
- NetFreePool (Item);
+ RemoveEntryList (&Item->Link);
+ gBS->FreePool (Item);
}
- ASSERT (NetListIsEmpty (&Map->Recycled));
+ ASSERT (IsListEmpty (&Map->Recycled));
}
@@ -506,16 +506,16 @@ NetMapAllocItem ( )
{
NET_MAP_ITEM *Item;
- NET_LIST_ENTRY *Head;
+ LIST_ENTRY *Head;
UINTN Index;
ASSERT (Map != NULL);
Head = &Map->Recycled;
- if (NetListIsEmpty (Head)) {
+ if (IsListEmpty (Head)) {
for (Index = 0; Index < NET_MAP_INCREAMENT; Index++) {
- Item = NetAllocatePool (sizeof (NET_MAP_ITEM));
+ Item = AllocatePool (sizeof (NET_MAP_ITEM));
if (Item == NULL) {
if (Index == 0) {
@@ -525,7 +525,7 @@ NetMapAllocItem ( break;
}
- NetListInsertHead (Head, &Item->Link);
+ InsertHeadList (Head, &Item->Link);
}
}
@@ -566,7 +566,7 @@ NetMapInsertHead ( Item->Key = Key;
Item->Value = Value;
- NetListInsertHead (&Map->Used, &Item->Link);
+ InsertHeadList (&Map->Used, &Item->Link);
Map->Count++;
return EFI_SUCCESS;
@@ -603,7 +603,7 @@ NetMapInsertTail ( Item->Key = Key;
Item->Value = Value;
- NetListInsertTail (&Map->Used, &Item->Link);
+ InsertTailList (&Map->Used, &Item->Link);
Map->Count++;
@@ -627,7 +627,7 @@ NetItemInMap ( IN NET_MAP_ITEM *Item
)
{
- NET_LIST_ENTRY *ListEntry;
+ LIST_ENTRY *ListEntry;
NET_LIST_FOR_EACH (ListEntry, &Map->Used) {
if (ListEntry == &Item->Link) {
@@ -654,7 +654,7 @@ NetMapFindKey ( IN VOID *Key
)
{
- NET_LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry;
NET_MAP_ITEM *Item;
ASSERT (Map != NULL);
@@ -691,9 +691,9 @@ NetMapRemoveItem ( ASSERT ((Map != NULL) && (Item != NULL));
ASSERT (NetItemInMap (Map, Item));
- NetListRemoveEntry (&Item->Link);
+ RemoveEntryList (&Item->Link);
Map->Count--;
- NetListInsertHead (&Map->Recycled, &Item->Link);
+ InsertHeadList (&Map->Recycled, &Item->Link);
if (Value != NULL) {
*Value = Item->Value;
@@ -724,12 +724,12 @@ NetMapRemoveHead ( // Often, it indicates a programming error to remove
// the first entry in an empty list
//
- ASSERT (Map && !NetListIsEmpty (&Map->Used));
+ ASSERT (Map && !IsListEmpty (&Map->Used));
Item = NET_LIST_HEAD (&Map->Used, NET_MAP_ITEM, Link);
- NetListRemoveEntry (&Item->Link);
+ RemoveEntryList (&Item->Link);
Map->Count--;
- NetListInsertHead (&Map->Recycled, &Item->Link);
+ InsertHeadList (&Map->Recycled, &Item->Link);
if (Value != NULL) {
*Value = Item->Value;
@@ -760,12 +760,12 @@ NetMapRemoveTail ( // Often, it indicates a programming error to remove
// the last entry in an empty list
//
- ASSERT (Map && !NetListIsEmpty (&Map->Used));
+ ASSERT (Map && !IsListEmpty (&Map->Used));
Item = NET_LIST_TAIL (&Map->Used, NET_MAP_ITEM, Link);
- NetListRemoveEntry (&Item->Link);
+ RemoveEntryList (&Item->Link);
Map->Count--;
- NetListInsertHead (&Map->Recycled, &Item->Link);
+ InsertHeadList (&Map->Recycled, &Item->Link);
if (Value != NULL) {
*Value = Item->Value;
@@ -796,9 +796,9 @@ NetMapIterate ( )
{
- NET_LIST_ENTRY *Entry;
- NET_LIST_ENTRY *Next;
- NET_LIST_ENTRY *Head;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ LIST_ENTRY *Head;
NET_MAP_ITEM *Item;
EFI_STATUS Result;
@@ -806,7 +806,7 @@ NetMapIterate ( Head = &Map->Used;
- if (NetListIsEmpty (Head)) {
+ if (IsListEmpty (Head)) {
return EFI_SUCCESS;
}
@@ -1088,7 +1088,7 @@ NetLibGetMacString ( // It takes 2 unicode characters to represent a 1 byte binary buffer.
// Plus one unicode character for the null-terminator.
//
- MacAddress = NetAllocatePool ((2 * Mode->HwAddressSize + 1) * sizeof (CHAR16));
+ MacAddress = AllocatePool ((2 * Mode->HwAddressSize + 1) * sizeof (CHAR16));
if (MacAddress == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1146,7 +1146,7 @@ NetLibDefaultAddressIsStatic ( return TRUE;
}
- ConfigInfo = NetAllocatePool (Len);
+ ConfigInfo = AllocatePool (Len);
if (ConfigInfo == NULL) {
return TRUE;
}
@@ -1161,7 +1161,7 @@ NetLibDefaultAddressIsStatic ( ON_EXIT:
- NetFreePool (ConfigInfo);
+ gBS->FreePool (ConfigInfo);
return IsStatic;
}
@@ -1196,8 +1196,8 @@ NetLibCreateIPv4DPathNode ( Node->Header.SubType = MSG_IPv4_DP;
SetDevicePathNodeLength (&Node->Header, 19);
- NetCopyMem (&Node->LocalIpAddress, &LocalIp, sizeof (EFI_IPv4_ADDRESS));
- NetCopyMem (&Node->RemoteIpAddress, &RemoteIp, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&Node->LocalIpAddress, &LocalIp, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&Node->RemoteIpAddress, &RemoteIp, sizeof (EFI_IPv4_ADDRESS));
Node->LocalPort = LocalPort;
Node->RemotePort = RemotePort;
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf index 3ce822d..78fad5b 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf @@ -36,7 +36,7 @@ [Sources.common]
DxeNetLib.c
NetBuffer.c
- NetDebug.c
+
[Packages]
MdePkg/MdePkg.dec
diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c index a9de17f..d1dbd0a 100644 --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c @@ -56,7 +56,7 @@ NetbufAllocStruct ( //
// Allocate three memory blocks.
//
- Nbuf = NetAllocateZeroPool (NET_BUF_SIZE (BlockOpNum));
+ Nbuf = AllocateZeroPool (NET_BUF_SIZE (BlockOpNum));
if (Nbuf == NULL) {
return NULL;
@@ -65,10 +65,10 @@ NetbufAllocStruct ( Nbuf->Signature = NET_BUF_SIGNATURE;
Nbuf->RefCnt = 1;
Nbuf->BlockOpNum = BlockOpNum;
- NetListInit (&Nbuf->List);
+ InitializeListHead (&Nbuf->List);
if (BlockNum != 0) {
- Vector = NetAllocateZeroPool (NET_VECTOR_SIZE (BlockNum));
+ Vector = AllocateZeroPool (NET_VECTOR_SIZE (BlockNum));
if (Vector == NULL) {
goto FreeNbuf;
@@ -84,7 +84,7 @@ NetbufAllocStruct ( FreeNbuf:
- NetFreePool (Nbuf);
+ gBS->FreePool (Nbuf);
return NULL;
}
@@ -116,7 +116,7 @@ NetbufAlloc ( return NULL;
}
- Bulk = NetAllocatePool (Len);
+ Bulk = AllocatePool (Len);
if (Bulk == NULL) {
goto FreeNBuf;
@@ -138,7 +138,7 @@ NetbufAlloc ( return Nbuf;
FreeNBuf:
- NetFreePool (Nbuf);
+ gBS->FreePool (Nbuf);
return NULL;
}
@@ -175,7 +175,7 @@ NetbufFreeVector ( // first block since it is allocated by us
//
if (Vector->Flag & NET_VECTOR_OWN_FIRST) {
- NetFreePool (Vector->Block[0].Bulk);
+ gBS->FreePool (Vector->Block[0].Bulk);
}
Vector->Free (Vector->Arg);
@@ -185,11 +185,11 @@ NetbufFreeVector ( // Free each memory block associated with the Vector
//
for (Index = 0; Index < Vector->BlockNum; Index++) {
- NetFreePool (Vector->Block[Index].Bulk);
+ gBS->FreePool (Vector->Block[Index].Bulk);
}
}
- NetFreePool (Vector);
+ gBS->FreePool (Vector);
}
@@ -217,7 +217,7 @@ NetbufFree ( // all the sharing of Nbuf increse Vector's RefCnt by one
//
NetbufFreeVector (Nbuf->Vector);
- NetFreePool (Nbuf);
+ gBS->FreePool (Nbuf);
}
}
@@ -239,7 +239,7 @@ NetbufClone ( NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
- Clone = NetAllocatePool (NET_BUF_SIZE (Nbuf->BlockOpNum));
+ Clone = AllocatePool (NET_BUF_SIZE (Nbuf->BlockOpNum));
if (Clone == NULL) {
return NULL;
@@ -247,19 +247,19 @@ NetbufClone ( Clone->Signature = NET_BUF_SIGNATURE;
Clone->RefCnt = 1;
- NetListInit (&Clone->List);
+ InitializeListHead (&Clone->List);
Clone->Ip = Nbuf->Ip;
Clone->Tcp = Nbuf->Tcp;
- NetCopyMem (Clone->ProtoData, Nbuf->ProtoData, NET_PROTO_DATA);
+ CopyMem (Clone->ProtoData, Nbuf->ProtoData, NET_PROTO_DATA);
NET_GET_REF (Nbuf->Vector);
Clone->Vector = Nbuf->Vector;
Clone->BlockOpNum = Nbuf->BlockOpNum;
Clone->TotalSize = Nbuf->TotalSize;
- NetCopyMem (Clone->BlockOp, Nbuf->BlockOp, sizeof (NET_BLOCK_OP) * Nbuf->BlockOpNum);
+ CopyMem (Clone->BlockOp, Nbuf->BlockOp, sizeof (NET_BLOCK_OP) * Nbuf->BlockOpNum);
return Clone;
}
@@ -300,7 +300,7 @@ NetbufDuplicate ( // Don't set the IP and TCP head point, since it is most
// like that they are pointing to the memory of Nbuf.
//
- NetCopyMem (Duplicate->ProtoData, Nbuf->ProtoData, NET_PROTO_DATA);
+ CopyMem (Duplicate->ProtoData, Nbuf->ProtoData, NET_PROTO_DATA);
NetbufReserve (Duplicate, HeadSpace);
Dst = NetbufAllocSpace (Duplicate, Nbuf->TotalSize, NET_BUF_TAIL);
@@ -320,11 +320,11 @@ NetbufDuplicate ( **/
VOID
NetbufFreeList (
- IN NET_LIST_ENTRY *Head
+ IN LIST_ENTRY *Head
)
{
- NET_LIST_ENTRY *Entry;
- NET_LIST_ENTRY *Next;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
NET_BUF *Nbuf;
Entry = Head->ForwardLink;
@@ -333,11 +333,11 @@ NetbufFreeList ( Nbuf = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
- NetListRemoveEntry (Entry);
+ RemoveEntryList (Entry);
NetbufFree (Nbuf);
}
- ASSERT (NetListIsEmpty (Head));
+ ASSERT (IsListEmpty (Head));
}
@@ -609,7 +609,7 @@ NetbufGetFragment ( return NULL;
}
- FirstBulk = NetAllocatePool (HeadSpace);
+ FirstBulk = AllocatePool (HeadSpace);
if (FirstBulk == NULL) {
goto FreeChild;
@@ -653,7 +653,7 @@ NetbufGetFragment ( CurBlockOp++
);
- for (Index = First + 1; Index <= Last - 1 ; Index++) {
+ for (Index = First + 1; Index < Last; Index++) {
NetbufSetBlockOp (
Child,
BlockOp[Index].Head,
@@ -671,12 +671,12 @@ NetbufGetFragment ( );
}
- NetCopyMem (Child->ProtoData, Nbuf->ProtoData, NET_PROTO_DATA);
+ CopyMem (Child->ProtoData, Nbuf->ProtoData, NET_PROTO_DATA);
return Child;
FreeChild:
- NetFreePool (Child);
+ gBS->FreePool (Child);
return NULL;
}
@@ -751,7 +751,7 @@ NetbufFromExt ( //
if ((HeadSpace != 0) || (HeadLen != 0)) {
FirstBlockLen = HeadLen + HeadSpace;
- FirstBlock = NetAllocatePool (FirstBlockLen);
+ FirstBlock = AllocatePool (FirstBlockLen);
if (FirstBlock == NULL) {
return NULL;
@@ -771,7 +771,7 @@ NetbufFromExt ( for (Index = 0; Index < ExtNum; Index++) {
if (Len >= ExtFragment[Index].Len) {
- NetCopyMem (Header, ExtFragment[Index].Bulk, ExtFragment[Index].Len);
+ CopyMem (Header, ExtFragment[Index].Bulk, ExtFragment[Index].Len);
Copied += ExtFragment[Index].Len;
Len -= ExtFragment[Index].Len;
@@ -789,7 +789,7 @@ NetbufFromExt ( }
} else {
- NetCopyMem (Header, ExtFragment[Index].Bulk, Len);
+ CopyMem (Header, ExtFragment[Index].Bulk, Len);
Copied += Len;
TotalLen += Len;
@@ -851,7 +851,7 @@ NetbufFromExt ( return Nbuf;
FreeFirstBlock:
- NetFreePool (FirstBlock);
+ gBS->FreePool (FirstBlock);
return NULL;
}
@@ -916,7 +916,7 @@ NetbufBuildExt ( **/
NET_BUF *
NetbufFromBufList (
- IN NET_LIST_ENTRY *BufList,
+ IN LIST_ENTRY *BufList,
IN UINT32 HeadSpace,
IN UINT32 HeaderLen,
IN NET_VECTOR_EXT_FREE ExtFree,
@@ -925,7 +925,7 @@ NetbufFromBufList ( {
NET_FRAGMENT *Fragment;
UINT32 FragmentNum;
- NET_LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry;
NET_BUF *Nbuf;
UINT32 Index;
UINT32 Current;
@@ -944,7 +944,7 @@ NetbufFromBufList ( //
//Allocate and copy block points
//
- Fragment = NetAllocatePool (sizeof (NET_FRAGMENT) * FragmentNum);
+ Fragment = AllocatePool (sizeof (NET_FRAGMENT) * FragmentNum);
if (Fragment == NULL) {
return NULL;
@@ -966,7 +966,7 @@ NetbufFromBufList ( }
Nbuf = NetbufFromExt (Fragment, Current, HeadSpace, HeaderLen, ExtFree, Arg);
- NetFreePool (Fragment);
+ gBS->FreePool (Fragment);
return Nbuf;
}
@@ -1261,11 +1261,11 @@ NetbufCopy ( Left = BlockOp[Index].Size - Skip;
if (Len <= Left) {
- NetCopyMem (Dest, BlockOp[Index].Head + Skip, Len);
+ CopyMem (Dest, BlockOp[Index].Head + Skip, Len);
return Len;
}
- NetCopyMem (Dest, BlockOp[Index].Head + Skip, Left);
+ CopyMem (Dest, BlockOp[Index].Head + Skip, Left);
Dest += Left;
Len -= Left;
@@ -1278,11 +1278,11 @@ NetbufCopy ( Len -= BlockOp[Index].Size;
Copied += BlockOp[Index].Size;
- NetCopyMem (Dest, BlockOp[Index].Head, BlockOp[Index].Size);
+ CopyMem (Dest, BlockOp[Index].Head, BlockOp[Index].Size);
Dest += BlockOp[Index].Size;
} else {
Copied += Len;
- NetCopyMem (Dest, BlockOp[Index].Head, Len);
+ CopyMem (Dest, BlockOp[Index].Head, Len);
break;
}
}
@@ -1306,9 +1306,9 @@ NetbufQueInit ( {
NbufQue->Signature = NET_QUE_SIGNATURE;
NbufQue->RefCnt = 1;
- NetListInit (&NbufQue->List);
+ InitializeListHead (&NbufQue->List);
- NetListInit (&NbufQue->BufList);
+ InitializeListHead (&NbufQue->BufList);
NbufQue->BufSize = 0;
NbufQue->BufNum = 0;
}
@@ -1329,7 +1329,7 @@ NetbufQueAlloc ( {
NET_BUF_QUEUE *NbufQue;
- NbufQue = NetAllocatePool (sizeof (NET_BUF_QUEUE));
+ NbufQue = AllocatePool (sizeof (NET_BUF_QUEUE));
if (NbufQue == NULL) {
return NULL;
}
@@ -1359,7 +1359,7 @@ NetbufQueFree ( if (NbufQue->RefCnt == 0) {
NetbufQueFlush (NbufQue);
- NetFreePool (NbufQue);
+ gBS->FreePool (NbufQue);
}
}
@@ -1382,7 +1382,7 @@ NetbufQueAppend ( NET_CHECK_SIGNATURE (NbufQue, NET_QUE_SIGNATURE);
NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
- NetListInsertTail (&NbufQue->BufList, &Nbuf->List);
+ InsertTailList (&NbufQue->BufList, &Nbuf->List);
NbufQue->BufSize += Nbuf->TotalSize;
NbufQue->BufNum++;
@@ -1440,7 +1440,7 @@ NetbufQueCopy ( IN UINT8 *Dest
)
{
- NET_LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry;
NET_BUF *Nbuf;
UINT32 Skip;
UINT32 Left;
@@ -1533,8 +1533,8 @@ NetbufQueTrim ( IN UINT32 Len
)
{
- NET_LIST_ENTRY *Entry;
- NET_LIST_ENTRY *Next;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
NET_BUF *Nbuf;
UINT32 Trimmed;
@@ -1558,7 +1558,7 @@ NetbufQueTrim ( Trimmed += Nbuf->TotalSize;
Len -= Nbuf->TotalSize;
- NetListRemoveEntry (Entry);
+ RemoveEntryList (Entry);
NetbufFree (Nbuf);
NbufQue->BufNum--;
@@ -1748,7 +1748,7 @@ NetPseudoHeadChecksum ( //
// Zero the memory to relieve align problems
//
- NetZeroMem (&Hdr, sizeof (Hdr));
+ ZeroMem (&Hdr, sizeof (Hdr));
Hdr.SrcIp = Src;
Hdr.DstIp = Dst;
diff --git a/MdeModulePkg/Library/DxeNetLib/NetDebug.c b/MdeModulePkg/Library/DxeNetLib/NetDebug.c deleted file mode 100644 index e182b74..0000000 --- a/MdeModulePkg/Library/DxeNetLib/NetDebug.c +++ /dev/null @@ -1,536 +0,0 @@ -/** @file
-
-Copyright (c) 2005 - 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:
-
- NetDebug.c
-
-Abstract:
-
- Network debug facility. The debug information is wrapped in
- SYSLOG packets, then sent over SNP. This debug facility can't
- be used by SNP. Apply caution when used in MNP and non-network
- module because SNP is most likely not "thread safe". We assume
- that the SNP supports the EHTERNET.
-
-
-**/
-
-
-#include <PiDxe.h>
-
-#include <Protocol/SimpleNetwork.h>
-
-#include <Library/BaseLib.h>
-#include <Library/NetLib.h>
-#include <Library/UefiBootServicesTableLib.h> -#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/PrintLib.h>
-
-
-//
-// Any error level digitally larger than mNetDebugLevelMax
-// will be silently discarded.
-//
-UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR;
-UINT32 mSyslogPacketSeq = 0xDEADBEEF;
-
-//
-// You can change mSyslogDstMac mSyslogDstIp and mSyslogSrcIp
-// here to direct the syslog packets to the syslog deamon. The
-// default is broadcast to both the ethernet and IP.
-//
-UINT8 mSyslogDstMac [NET_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-UINT32 mSyslogDstIp = 0xffffffff;
-UINT32 mSyslogSrcIp = 0;
-
-CHAR8 *
-MonthName[] = {
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
-};
-
-
-/**
- Locate the handles that support SNP, then open one of them
- to send the syslog packets. The caller isn't required to close
- the SNP after use because the SNP is opened by HandleProtocol.
-
- None
-
- @return The point to SNP if one is properly openned. Otherwise NULL
-
-**/
-EFI_SIMPLE_NETWORK_PROTOCOL *
-SyslogLocateSnp (
- VOID
- )
-{
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- EFI_STATUS Status;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN Index;
-
- //
- // Locate the handles which has SNP installed.
- //
- Handles = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &HandleCount,
- &Handles
- );
-
- if (EFI_ERROR (Status) || (HandleCount == 0)) {
- return NULL;
- }
-
- //
- // Try to open one of the ethernet SNP protocol to send packet
- //
- Snp = NULL;
-
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (
- Handles[Index],
- &gEfiSimpleNetworkProtocolGuid,
- (VOID **) &Snp
- );
-
- if ((Status == EFI_SUCCESS) && (Snp != NULL) &&
- (Snp->Mode->IfType == NET_IFTYPE_ETHERNET) &&
- (Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN)) {
-
- break;
- }
-
- Snp = NULL;
- }
-
- gBS->FreePool (Handles);
- return Snp;
-}
-
-
-/**
- Transmit a syslog packet synchronously through SNP. The Packet
- already has the ethernet header prepended. This function should
- fill in the source MAC because it will try to locate a SNP each
- time it is called to avoid the problem if SNP is unloaded.
- This code snip is copied from MNP.
-
- @param Packet The Syslog packet
- @param Length The length of the packet
-
- @retval EFI_DEVICE_ERROR Failed to locate a usable SNP protocol
- @retval EFI_TIMEOUT Timeout happened to send the packet.
- @retval EFI_SUCCESS Packet is sent.
-
-**/
-EFI_STATUS
-SyslogSendPacket (
- IN UINT8 *Packet,
- IN UINT32 Length
- )
-{
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- ETHER_HEAD *Ether;
- EFI_STATUS Status;
- EFI_EVENT TimeoutEvent;
- UINT8 *TxBuf;
-
- Snp = SyslogLocateSnp ();
-
- if (Snp == NULL) {
- return EFI_DEVICE_ERROR;
- }
-
- Ether = (ETHER_HEAD *) Packet;
- CopyMem (Ether->SrcMac, Snp->Mode->CurrentAddress.Addr, NET_ETHER_ADDR_LEN);
-
- //
- // Start the timeout event.
- //
- Status = gBS->CreateEvent (
- EVT_TIMER,
- TPL_NOTIFY,
- NULL,
- NULL,
- &TimeoutEvent
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->SetTimer (TimeoutEvent, TimerRelative, NET_SYSLOG_TX_TIMEOUT);
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- for (;;) {
- //
- // Transmit the packet through SNP.
- //
- Status = Snp->Transmit (Snp, 0, Length, Packet, NULL, NULL, NULL);
-
- if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {
- Status = EFI_DEVICE_ERROR;
- break;
- }
-
- //
- // If Status is EFI_SUCCESS, the packet is put in the transmit queue.
- // if Status is EFI_NOT_READY, the transmit engine of the network
- // interface is busy. Both need to sync SNP.
- //
- TxBuf = NULL;
-
- do {
- //
- // Get the recycled transmit buffer status.
- //
- Snp->GetStatus (Snp, NULL, (VOID **) &TxBuf);
-
- if (!EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
- Status = EFI_TIMEOUT;
- break;
- }
-
- } while (TxBuf == NULL);
-
- if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) {
- break;
- }
-
- //
- // Status is EFI_NOT_READY. Restart the timer event and
- // call Snp->Transmit again.
- //
- gBS->SetTimer (TimeoutEvent, TimerRelative, NET_SYSLOG_TX_TIMEOUT);
- }
-
- gBS->SetTimer (TimeoutEvent, TimerCancel, 0);
-
-ON_EXIT:
- gBS->CloseEvent (TimeoutEvent);
- return Status;
-}
-
-
-/**
- Compute checksum for a bulk of data. This code is copied from the
- Netbuffer library.
-
- @param Bulk Pointer to the data.
- @param Len Length of the data, in bytes.
-
- @retval UINT16 The computed checksum.
-
-**/
-UINT16
-SyslogChecksum (
- IN UINT8 *Bulk,
- IN UINT32 Len
- )
-{
- register UINT32 Sum;
-
- Sum = 0;
-
- while (Len > 1) {
- Sum += *(UINT16 *) Bulk;
- Bulk += 2;
- Len -= 2;
- }
-
- //
- // Add left-over byte, if any
- //
- if (Len > 0) {
- Sum += *(UINT8 *) Bulk;
- }
-
- //
- // Fold 32-bit sum to 16 bits
- //
- while (Sum >> 16) {
- Sum = (Sum & 0xffff) + (Sum >> 16);
- }
-
- return (UINT16) ~Sum;
-}
-
-
-/**
- Build a syslog packet, including the Ethernet/Ip/Udp headers
- and user's message.
-
- @param Buf The buffer to put the packet data
- @param BufLen The lenght of the Buf
- @param Level Syslog servity level
- @param Module The module that generates the log
- @param File The file that contains the current log
- @param Line The line of code in the File that contains the
- current log
- @param Message The log message
-
- @return The length of the syslog packet built.
-
-**/
-UINT32
-SyslogBuildPacket (
- UINT8 *Buf,
- UINT32 BufLen,
- UINT32 Level,
- UINT8 *Module,
- UINT8 *File,
- UINT32 Line,
- UINT8 *Message
- )
-{
- ETHER_HEAD *Ether;
- IP4_HEAD *Ip4;
- EFI_UDP4_HEADER *Udp4;
- EFI_TIME Time;
- UINT32 Pri;
- UINT32 Len;
-
- //
- // Fill in the Ethernet header. Leave alone the source MAC.
- // SyslogSendPacket will fill in the address for us.
- //
- Ether = (ETHER_HEAD *) Buf;
- CopyMem (Ether->DstMac, mSyslogDstMac, NET_ETHER_ADDR_LEN);
- ZeroMem (Ether->SrcMac, NET_ETHER_ADDR_LEN);
-
- Ether->EtherType = HTONS (0x0800); // IP protocol
-
- Buf += sizeof (ETHER_HEAD);
- BufLen -= sizeof (ETHER_HEAD);
-
- //
- // Fill in the IP header
- //
- Ip4 = (IP4_HEAD *) Buf;
- Ip4->HeadLen = 5;
- Ip4->Ver = 4;
- Ip4->Tos = 0;
- Ip4->TotalLen = 0;
- Ip4->Id = (UINT16) mSyslogPacketSeq;
- Ip4->Fragment = 0;
- Ip4->Ttl = 16;
- Ip4->Protocol = 0x11;
- Ip4->Checksum = 0;
- Ip4->Src = mSyslogSrcIp;
- Ip4->Dst = mSyslogDstIp;
-
- Buf += sizeof (IP4_HEAD);
- BufLen -= sizeof (IP4_HEAD);
-
- //
- // Fill in the UDP header, Udp checksum is optional. Leave it zero.
- //
- Udp4 = (EFI_UDP4_HEADER*) Buf;
- Udp4->SrcPort = HTONS (514);
- Udp4->DstPort = HTONS (514);
- Udp4->Length = 0;
- Udp4->Checksum = 0;
-
- Buf += sizeof (EFI_UDP4_HEADER);
- BufLen -= sizeof (EFI_UDP4_HEADER);
-
- //
- // Build the syslog message body with <PRI> Timestamp machine module Message
- //
- Pri = ((NET_SYSLOG_FACILITY & 31) << 3) | (Level & 7);
- gRT->GetTime (&Time, NULL);
-
- //
- // Use %a to format the ASCII strings, %s to format UNICODE strings
- //
- Len = 0;
- Len += (UINT32) AsciiSPrint (
- (CHAR8 *) Buf,
- BufLen,
- "<%d> %a %d %d:%d:%d ",
- Pri,
- MonthName [Time.Month-1],
- Time.Day,
- Time.Hour,
- Time.Minute,
- Time.Second
- );
- Len--;
-
- Len += (UINT32) AsciiSPrint (
- (CHAR8 *) (Buf + Len),
- BufLen - Len,
- "Tiano %a: %a (Line: %d File: %a)",
- Module,
- Message,
- Line,
- File
- );
- Len--;
-
- //
- // OK, patch the IP length/checksum and UDP length fields.
- //
- Len += sizeof (EFI_UDP4_HEADER);
- Udp4->Length = HTONS ((UINT16) Len);
-
- Len += sizeof (IP4_HEAD);
- Ip4->TotalLen = HTONS ((UINT16) Len);
- Ip4->Checksum = SyslogChecksum ((UINT8 *) Ip4, sizeof (IP4_HEAD));
-
- return Len + sizeof (ETHER_HEAD);
-}
-
-
-/**
- Allocate a buffer, then format the message to it. This is a
- help function for the NET_DEBUG_XXX macros. The PrintArg of
- these macros treats the variable length print parameters as a
- single parameter, and pass it to the NetDebugASPrint. For
- example, NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name))
- if extracted to:
- NetDebugOutput (
- NETDEBUG_LEVEL_TRACE,
- "Tcp",
- __FILE__,
- __LINE__,
- NetDebugASPrint ("State transit to %a\n", Name)
- )
- This is exactly what we want.
-
- @param Format The ASCII format string.
- @param ... The variable length parameter whose format is
- determined by the Format string.
-
- @return The buffer containing the formatted message, or NULL if failed to
- @return allocate memory.
-
-**/
-UINT8 *
-NetDebugASPrint (
- UINT8 *Format,
- ...
- )
-{
- VA_LIST Marker;
- UINT8 *Buf;
-
- Buf = AllocatePool (NET_DEBUG_MSG_LEN);
-
- if (Buf == NULL) {
- return NULL;
- }
-
- VA_START (Marker, Format);
- AsciiVSPrint ((CHAR8 *) Buf, NET_DEBUG_MSG_LEN, (CHAR8 *) Format, Marker);
- VA_END (Marker);
-
- return Buf;
-}
-
-
-/**
- Output a debug message to syslog. This function will locate a
- instance of SNP then send the message through it. Because it
- isn't open the SNP BY_DRIVER, apply caution when using it.
-
- @param Level The servity level of the message.
- @param Module The Moudle that generates the log.
- @param File The file that contains the log.
- @param Line The exact line that contains the log.
- @param Message The user message to log.
-
- @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the packet
- @retval EFI_SUCCESS The log is discard because that it is more verbose
- than the mNetDebugLevelMax. Or, it has been sent
- out.
-
-**/
-EFI_STATUS
-NetDebugOutput (
- UINT32 Level,
- UINT8 *Module,
- UINT8 *File,
- UINT32 Line,
- UINT8 *Message
- )
-{
- UINT8 *Packet;
- UINT32 Len;
- EFI_STATUS Status;
-
- //
- // Check whether the message should be sent out
- //
- if (Message == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- if (Level > mNetDebugLevelMax) {
- Status = EFI_SUCCESS;
- goto ON_EXIT;
- }
-
- //
- // Allocate a maxium of 1024 bytes, the caller should ensure
- // that the message plus the ethernet/ip/udp header is shorter
- // than this
- //
- Packet = AllocatePool (NET_SYSLOG_PACKET_LEN);
-
- if (Packet == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_EXIT;
- }
-
- //
- // Build the message: Ethernet header + IP header + Udp Header + user data
- //
- Len = SyslogBuildPacket (
- Packet,
- NET_SYSLOG_PACKET_LEN,
- Level,
- Module,
- File,
- Line,
- Message
- );
-
- mSyslogPacketSeq++;
- Status = SyslogSendPacket (Packet, Len);
- gBS->FreePool (Packet);
-
-ON_EXIT:
- gBS->FreePool (Message);
- return Status;
-}
diff --git a/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c b/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c index c939124..864da9b 100644 --- a/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c +++ b/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c @@ -87,7 +87,7 @@ UdpIoWrapTx ( UINT32 Count;
IP4_ADDR Ip;
- Token = NetAllocatePool (sizeof (UDP_TX_TOKEN) +
+ Token = AllocatePool (sizeof (UDP_TX_TOKEN) +
sizeof (EFI_UDP4_FRAGMENT_DATA) * (Packet->BlockOpNum - 1));
if (Token == NULL) {
@@ -95,7 +95,7 @@ UdpIoWrapTx ( }
Token->Signature = UDP_IO_TX_SIGNATURE;
- NetListInit (&Token->Link);
+ InitializeListHead (&Token->Link);
Token->UdpIo = UdpIo;
Token->CallBack = CallBack;
@@ -107,14 +107,14 @@ UdpIoWrapTx ( Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
- NET_TPL_EVENT,
+ TPL_NOTIFY,
UdpIoOnDgramSent,
Token,
&UdpToken->Event
);
if (EFI_ERROR (Status)) {
- NetFreePool (Token);
+ gBS->FreePool (Token);
return NULL;
}
@@ -126,10 +126,10 @@ UdpIoWrapTx ( if (EndPoint != NULL) {
Ip = HTONL (EndPoint->LocalAddr);
- NetCopyMem (&Token->UdpSession.SourceAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&Token->UdpSession.SourceAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
Ip = HTONL (EndPoint->RemoteAddr);
- NetCopyMem (&Token->UdpSession.DestinationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&Token->UdpSession.DestinationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
Token->UdpSession.SourcePort = EndPoint->LocalPort;
Token->UdpSession.DestinationPort = EndPoint->RemotePort;
@@ -138,7 +138,7 @@ UdpIoWrapTx ( if (Gateway != 0) {
Ip = HTONL (Gateway);
- NetCopyMem (&Token->Gateway, &Ip, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&Token->Gateway, &Ip, sizeof (EFI_IPv4_ADDRESS));
UdpTxData->GatewayAddress = &Token->Gateway;
}
@@ -166,7 +166,7 @@ UdpIoFreeTxToken ( )
{
gBS->CloseEvent (Token->UdpToken.Event);
- NetFreePool (Token);
+ gBS->FreePool (Token);
}
@@ -192,7 +192,7 @@ UdpIoCreateRxToken ( UDP_RX_TOKEN *Token;
EFI_STATUS Status;
- Token = NetAllocatePool (sizeof (UDP_RX_TOKEN));
+ Token = AllocatePool (sizeof (UDP_RX_TOKEN));
if (Token == NULL) {
return NULL;
@@ -209,14 +209,14 @@ UdpIoCreateRxToken ( Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
- NET_TPL_EVENT,
+ TPL_NOTIFY,
UdpIoOnDgramRcvd,
Token,
&Token->UdpToken.Event
);
if (EFI_ERROR (Status)) {
- NetFreePool (Token);
+ gBS->FreePool (Token);
return NULL;
}
@@ -238,7 +238,7 @@ UdpIoFreeRxToken ( )
{
gBS->CloseEvent (Token->UdpToken.Event);
- NetFreePool (Token);
+ gBS->FreePool (Token);
}
@@ -268,20 +268,20 @@ UdpIoCreatePort ( ASSERT (Configure != NULL);
- UdpIo = NetAllocatePool (sizeof (UDP_IO_PORT));
+ UdpIo = AllocatePool (sizeof (UDP_IO_PORT));
if (UdpIo == NULL) {
return NULL;
}
UdpIo->Signature = UDP_IO_SIGNATURE;
- NetListInit (&UdpIo->Link);
+ InitializeListHead (&UdpIo->Link);
UdpIo->RefCnt = 1;
UdpIo->Controller = Controller;
UdpIo->Image = Image;
- NetListInit (&UdpIo->SentDatagram);
+ InitializeListHead (&UdpIo->SentDatagram);
UdpIo->RecvRequest = NULL;
UdpIo->UdpHandle = NULL;
@@ -336,7 +336,7 @@ FREE_CHILD: );
FREE_MEM:
- NetFreePool (UdpIo);
+ gBS->FreePool (UdpIo);
return NULL;
}
@@ -363,8 +363,8 @@ UdpIoCancelDgrams ( IN VOID *Context
)
{
- NET_LIST_ENTRY *Entry;
- NET_LIST_ENTRY *Next;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
UDP_TX_TOKEN *Token;
NET_LIST_FOR_EACH_SAFE (Entry, Next, &UdpIo->SentDatagram) {
@@ -425,10 +425,10 @@ UdpIoFreePort ( );
if (!IsListEmpty(&UdpIo->Link)) {
- NetListRemoveEntry (&UdpIo->Link);
+ RemoveEntryList (&UdpIo->Link);
}
- NetFreePool (UdpIo);
+ gBS->FreePool (UdpIo);
return EFI_SUCCESS;
}
@@ -485,7 +485,7 @@ UdpIoOnDgramSentDpc ( Token = (UDP_TX_TOKEN *) Context;
ASSERT (Token->Signature == UDP_IO_TX_SIGNATURE);
- NetListRemoveEntry (&Token->Link);
+ RemoveEntryList (&Token->Link);
Token->CallBack (Token->Packet, NULL, Token->UdpToken.Status, Token->Context);
UdpIoFreeTxToken (Token);
@@ -554,10 +554,10 @@ UdpIoSendDatagram ( // Insert the tx token into SendDatagram list before transmitting it. Remove
// it from the list if the returned status is not EFI_SUCCESS.
//
- NetListInsertHead (&UdpIo->SentDatagram, &Token->Link);
+ InsertHeadList (&UdpIo->SentDatagram, &Token->Link);
Status = UdpIo->Udp->Transmit (UdpIo->Udp, &Token->UdpToken);
if (EFI_ERROR (Status)) {
- NetListRemoveEntry (&Token->Link);
+ RemoveEntryList (&Token->Link);
UdpIoFreeTxToken (Token);
return Status;
}
@@ -708,8 +708,8 @@ UdpIoOnDgramRcvdDpc ( Points.LocalPort = UdpSession->DestinationPort;
Points.RemotePort = UdpSession->SourcePort;
- NetCopyMem (&Points.LocalAddr, &UdpSession->DestinationAddress, sizeof (IP4_ADDR));
- NetCopyMem (&Points.RemoteAddr, &UdpSession->SourceAddress, sizeof (IP4_ADDR));
+ CopyMem (&Points.LocalAddr, &UdpSession->DestinationAddress, sizeof (IP4_ADDR));
+ CopyMem (&Points.RemoteAddr, &UdpSession->SourceAddress, sizeof (IP4_ADDR));
Points.LocalAddr = NTOHL (Points.LocalAddr);
Points.RemoteAddr = NTOHL (Points.RemoteAddr);
|