/** @file\r
\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2007, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
\r
/**\r
- Create a empty assemble entry for the packet identified by\r
+ Create an empty assemble entry for the packet identified by\r
(Dst, Src, Id, Protocol). The default life for the packet is\r
120 seconds.\r
\r
@return the point to just created reassemble entry.\r
\r
**/\r
-STATIC\r
IP4_ASSEMBLE_ENTRY *\r
Ip4CreateAssembleEntry (\r
IN IP4_ADDR Dst,\r
\r
IP4_ASSEMBLE_ENTRY *Assemble;\r
\r
- Assemble = NetAllocatePool (sizeof (IP4_ASSEMBLE_ENTRY));\r
+ Assemble = AllocatePool (sizeof (IP4_ASSEMBLE_ENTRY));\r
\r
if (Assemble == NULL) {\r
return NULL;\r
}\r
\r
- NetListInit (&Assemble->Link);\r
- NetListInit (&Assemble->Fragments);\r
+ InitializeListHead (&Assemble->Link);\r
+ InitializeListHead (&Assemble->Fragments);\r
\r
Assemble->Dst = Dst;\r
Assemble->Src = Src;\r
\r
\r
/**\r
- Release all the fragments of a packet, then free the assemble entry\r
+ Release all the fragments of a packet, then free the assemble entry.\r
\r
@param Assemble The assemble entry to free\r
\r
@return None\r
\r
**/\r
-STATIC\r
VOID\r
Ip4FreeAssembleEntry (\r
IN IP4_ASSEMBLE_ENTRY *Assemble\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Next;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
NET_BUF *Fragment;\r
\r
NET_LIST_FOR_EACH_SAFE (Entry, Next, &Assemble->Fragments) {\r
Fragment = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);\r
\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
NetbufFree (Fragment);\r
}\r
\r
- NetFreePool (Assemble);\r
+ gBS->FreePool (Assemble);\r
}\r
\r
\r
**/\r
VOID\r
Ip4InitAssembleTable (\r
- IN IP4_ASSEMBLE_TABLE *Table\r
+ IN OUT IP4_ASSEMBLE_TABLE *Table\r
)\r
{\r
UINT32 Index;\r
\r
for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {\r
- NetListInit (&Table->Bucket[Index]);\r
+ InitializeListHead (&Table->Bucket[Index]);\r
}\r
}\r
\r
IN IP4_ASSEMBLE_TABLE *Table\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Next;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
IP4_ASSEMBLE_ENTRY *Assemble;\r
UINT32 Index;\r
\r
NET_LIST_FOR_EACH_SAFE (Entry, Next, &Table->Bucket[Index]) {\r
Assemble = NET_LIST_USER_STRUCT (Entry, IP4_ASSEMBLE_ENTRY, Link);\r
\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
Ip4FreeAssembleEntry (Assemble);\r
}\r
}\r
@return None\r
\r
**/\r
-STATIC\r
VOID\r
Ip4TrimPacket (\r
- IN NET_BUF *Packet,\r
- IN INTN Start,\r
- IN INTN End\r
+ IN OUT NET_BUF *Packet,\r
+ IN INTN Start,\r
+ IN INTN End\r
)\r
{\r
IP4_CLIP_INFO *Info;\r
@return None\r
\r
**/\r
-STATIC\r
VOID\r
Ip4OnFreeFragments (\r
IN VOID *Arg\r
return it to caller. If the packet can't be assembled, NULL is\r
return.\r
\r
- @param Table The assemble table used.\r
- @param Packet The fragment to assemble\r
+ @param Table The assemble table used. New assemble entry will be created\r
+ if the Packet is from a new chain of fragments.\r
+ @param Packet The fragment to assemble. It might be freed if the fragment\r
+ can't be re-assembled.\r
\r
@return NULL if the packet can't be reassemble. The point to just assembled\r
- @return packet if all the fragments of the packet have arrived.\r
+ packet if all the fragments of the packet have arrived.\r
\r
**/\r
-STATIC\r
NET_BUF *\r
Ip4Reassemble (\r
- IN IP4_ASSEMBLE_TABLE *Table,\r
- IN NET_BUF *Packet\r
+ IN OUT IP4_ASSEMBLE_TABLE *Table,\r
+ IN OUT NET_BUF *Packet\r
)\r
{\r
IP4_HEAD *IpHead;\r
IP4_CLIP_INFO *This;\r
IP4_CLIP_INFO *Node;\r
IP4_ASSEMBLE_ENTRY *Assemble;\r
- NET_LIST_ENTRY *Head;\r
- NET_LIST_ENTRY *Prev;\r
- NET_LIST_ENTRY *Cur;\r
+ LIST_ENTRY *Head;\r
+ LIST_ENTRY *Prev;\r
+ LIST_ENTRY *Cur;\r
NET_BUF *Fragment;\r
NET_BUF *NewPacket;\r
INTN Index;\r
goto DROP;\r
}\r
\r
- NetListInsertHead (&Table->Bucket[Index], &Assemble->Link);\r
+ InsertHeadList (&Table->Bucket[Index], &Assemble->Link);\r
}\r
\r
//\r
if (Node->End <= This->End) {\r
Cur = Cur->ForwardLink;\r
\r
- NetListRemoveEntry (&Fragment->List);\r
+ RemoveEntryList (&Fragment->List);\r
Assemble->CurLen -= Node->Length;\r
\r
NetbufFree (Fragment);\r
//\r
if (Node->Start < This->End) {\r
if (This->Start == Node->Start) {\r
- NetListRemoveEntry (&Packet->List);\r
+ RemoveEntryList (&Packet->List);\r
goto DROP;\r
}\r
\r
//\r
// Deliver the whole packet if all the fragments received.\r
// All fragments received if:\r
- // 1. received the last one, so, the totoal length is know\r
+ // 1. received the last one, so, the total length is know\r
// 2. received all the data. If the last fragment on the\r
// queue ends at the total length, all data is received.\r
//\r
if ((Assemble->TotalLen != 0) && (Assemble->CurLen >= Assemble->TotalLen)) {\r
\r
- NetListRemoveEntry (&Assemble->Link);\r
+ RemoveEntryList (&Assemble->Link);\r
\r
//\r
// If the packet is properly formated, the last fragment's End\r
return NULL;\r
}\r
\r
- NewPacket->Ip = Assemble->Head;\r
- CopyMem (IP4_GET_CLIP_INFO (NewPacket), Assemble->Info, sizeof (IP4_CLIP_INFO));\r
+ NewPacket->Ip = Assemble->Head;\r
+ CopyMem (IP4_GET_CLIP_INFO (NewPacket), Assemble->Info, sizeof (*IP4_GET_CLIP_INFO (NewPacket)));\r
return NewPacket;\r
}\r
\r
}\r
\r
//\r
- // Check that the IP4 header is correctly formated\r
+ // Check that the IP4 header is correctly formatted\r
//\r
if (Packet->TotalSize < IP4_MIN_HEADLEN) {\r
goto RESTART;\r
//\r
// Some OS may send IP packets without checksum.\r
//\r
- Checksum = ~NetblockChecksum ((UINT8 *) Head, HeadLen);\r
+ Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Head, HeadLen));\r
\r
if ((Head->Checksum != 0) && (Checksum != 0)) {\r
goto RESTART;\r
\r
Packet = NULL;\r
\r
+ //\r
+ // Dispatch the DPCs queued by the NotifyFunction of the rx token's events\r
+ // which are signaled with received data.\r
+ //\r
+ NetLibDispatchDpc ();\r
+\r
RESTART:\r
Ip4ReceiveFrame (IpSb->DefaultInterface, NULL, Ip4AccpetFrame, IpSb);\r
\r
@param Head The IP header of the packet\r
@param Packet The data of the packet\r
\r
- @return TRUE if the child wants to receive the packet, otherwise return FALSE.\r
+ @retval TRUE If the child wants to receive the packet.\r
+ @retval FALSE Otherwise.\r
\r
**/\r
BOOLEAN\r
//\r
// Dirty trick for the Tiano UEFI network stack implmentation. If\r
// ReceiveTimeout == -1, the receive of the packet for this instance\r
- // is disabled. The UEFI spec don't have such captibility. We add\r
+ // is disabled. The UEFI spec don't have such capability. We add\r
// this to improve the performance because IP will make a copy of\r
// the received packet for each accepting instance. Some IP instances\r
// used by UDP/TCP only send packets, they don't wants to receive.\r
Info = IP4_GET_CLIP_INFO (Clone);\r
Info->Life = IP4_US_TO_SEC (IpInstance->ConfigData.ReceiveTimeout);\r
\r
- NetListInsertTail (&IpInstance->Received, &Clone->List);\r
+ InsertTailList (&IpInstance->Received, &Clone->List);\r
return EFI_SUCCESS;\r
}\r
\r
@return None\r
\r
**/\r
-STATIC\r
VOID\r
EFIAPI\r
Ip4OnRecyclePacket (\r
\r
Wrap = (IP4_RXDATA_WRAP *) Context;\r
\r
- NET_TRYLOCK (&Wrap->IpInstance->RecycleLock);\r
- NetListRemoveEntry (&Wrap->Link);\r
- NET_UNLOCK (&Wrap->IpInstance->RecycleLock);\r
+ EfiAcquireLockOrFail (&Wrap->IpInstance->RecycleLock);\r
+ RemoveEntryList (&Wrap->Link);\r
+ EfiReleaseLock (&Wrap->IpInstance->RecycleLock);\r
\r
ASSERT (!NET_BUF_SHARED (Wrap->Packet));\r
NetbufFree (Wrap->Packet);\r
\r
gBS->CloseEvent (Wrap->RxData.RecycleSignal);\r
- NetFreePool (Wrap);\r
+ gBS->FreePool (Wrap);\r
}\r
\r
\r
EFI_IP4_RECEIVE_DATA *RxData;\r
EFI_STATUS Status;\r
\r
- Wrap = NetAllocatePool (IP4_RXDATA_WRAP_SIZE (Packet->BlockOpNum));\r
+ Wrap = AllocatePool (IP4_RXDATA_WRAP_SIZE (Packet->BlockOpNum));\r
\r
if (Wrap == NULL) {\r
return NULL;\r
}\r
\r
- NetListInit (&Wrap->Link);\r
+ InitializeListHead (&Wrap->Link);\r
\r
Wrap->IpInstance = IpInstance;\r
Wrap->Packet = Packet;\r
RxData = &Wrap->RxData;\r
\r
- NetZeroMem (&RxData->TimeStamp, sizeof (EFI_TIME));\r
+ ZeroMem (&RxData->TimeStamp, sizeof (EFI_TIME));\r
\r
Status = gBS->CreateEvent (\r
EVT_NOTIFY_SIGNAL,\r
- NET_TPL_RECYCLE,\r
+ TPL_NOTIFY,\r
Ip4OnRecyclePacket,\r
Wrap,\r
&RxData->RecycleSignal\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- NetFreePool (Wrap);\r
+ gBS->FreePool (Wrap);\r
return NULL;\r
}\r
\r
//\r
// Deliver a packet if there are both a packet and a receive token.\r
//\r
- while (!NetListIsEmpty (&IpInstance->Received) &&\r
+ while (!IsListEmpty (&IpInstance->Received) &&\r
!NetMapIsEmpty (&IpInstance->RxTokens)) {\r
\r
Packet = NET_LIST_HEAD (&IpInstance->Received, NET_BUF, List);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- NetListRemoveEntry (&Packet->List);\r
+ RemoveEntryList (&Packet->List);\r
\r
} else {\r
//\r
Head = NetbufAllocSpace (Dup, IP4_MAX_HEADLEN, NET_BUF_HEAD);\r
Dup->Ip = (IP4_HEAD *) Head;\r
\r
- NetCopyMem (Head, Packet->Ip, Packet->Ip->HeadLen << 2);\r
+ CopyMem (Head, Packet->Ip, Packet->Ip->HeadLen << 2);\r
NetbufTrim (Dup, IP4_MAX_HEADLEN, TRUE);\r
\r
Wrap = Ip4WrapRxData (IpInstance, Dup);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- NetListRemoveEntry (&Packet->List);\r
+ RemoveEntryList (&Packet->List);\r
NetbufFree (Packet);\r
\r
Packet = Dup;\r
// Insert it into the delivered packet, then get a user's\r
// receive token, pass the wrapped packet up.\r
//\r
- NET_TRYLOCK (&IpInstance->RecycleLock);\r
- NetListInsertHead (&IpInstance->Delivered, &Wrap->Link);\r
- NET_UNLOCK (&IpInstance->RecycleLock);\r
+ EfiAcquireLockOrFail (&IpInstance->RecycleLock);\r
+ InsertHeadList (&IpInstance->Delivered, &Wrap->Link);\r
+ EfiReleaseLock (&IpInstance->RecycleLock);\r
\r
Token = NetMapRemoveHead (&IpInstance->RxTokens, NULL);\r
Token->Status = IP4_GET_CLIP_INFO (Packet)->Status;\r
{\r
IP4_PROTOCOL *IpInstance;\r
IP4_CLIP_INFO *Info;\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
INTN Enqueued;\r
INTN LocalType;\r
INTN SavedType;\r
)\r
{\r
IP4_PROTOCOL *Ip4Instance;\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
\r
NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {\r
Ip4Instance = NET_LIST_USER_STRUCT (Entry, IP4_PROTOCOL, AddrLink);\r
to each IP4 child that accepts the packet. The second pass will\r
deliver a non-shared copy of the packet to each IP4 child that\r
has pending receive requests. Data is copied if more than one\r
- child wants to consume the packet bacause each IP child need\r
+ child wants to consume the packet because each IP child needs\r
its own copy of the packet to make changes.\r
\r
@param IpSb The IP4 service instance that received the packet\r
IN NET_BUF *Packet\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
IP4_INTERFACE *IpIf;\r
INTN Enqueued;\r
\r
IN IP4_SERVICE *IpSb\r
)\r
{\r
- NET_LIST_ENTRY *InstanceEntry;\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Next;\r
+ LIST_ENTRY *InstanceEntry;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
IP4_PROTOCOL *IpInstance;\r
IP4_ASSEMBLE_ENTRY *Assemble;\r
NET_BUF *Packet;\r
Assemble = NET_LIST_USER_STRUCT (Entry, IP4_ASSEMBLE_ENTRY, Link);\r
\r
if ((Assemble->Life > 0) && (--Assemble->Life == 0)) {\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
Ip4FreeAssembleEntry (Assemble);\r
}\r
}\r
Info = IP4_GET_CLIP_INFO (Packet);\r
\r
if ((Info->Life > 0) && (--Info->Life == 0)) {\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
NetbufFree (Packet);\r
}\r
}\r