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/DxeNetLib | |
parent | bb8ffffd1c0ff0ee697c26d377fd9767097cc02b (diff) | |
download | edk2-platforms-e48e37fce2611df7a52aff271835ff72ee396d9b.tar.xz |
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/DxeNetLib')
-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 |
4 files changed, 100 insertions, 636 deletions
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index ee8b6797e5..b813db37cc 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 3ce822d831..78fad5b5f3 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 a9de17f7e2..d1dbd0aee5 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 e182b741f5..0000000000 --- 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;
-}
|