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

@ -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;