@param GateWay The nexthop address\r
\r
@return NULL if failed to allocate memeory, otherwise the newly created\r
- @return route entry.\r
+ route entry.\r
\r
**/\r
-STATIC\r
IP4_ROUTE_ENTRY *\r
Ip4CreateRouteEntry (\r
IN IP4_ADDR Dest,\r
{\r
IP4_ROUTE_ENTRY *RtEntry;\r
\r
- RtEntry = NetAllocatePool (sizeof (IP4_ROUTE_ENTRY));\r
+ RtEntry = AllocatePool (sizeof (IP4_ROUTE_ENTRY));\r
\r
if (RtEntry == NULL) {\r
return NULL;\r
}\r
\r
- NetListInit (&RtEntry->Link);\r
+ InitializeListHead (&RtEntry->Link);\r
\r
RtEntry->RefCnt = 1;\r
RtEntry->Dest = Dest;\r
@return NONE\r
\r
**/\r
-STATIC\r
VOID\r
Ip4FreeRouteEntry (\r
IN IP4_ROUTE_ENTRY *RtEntry\r
ASSERT (RtEntry->RefCnt > 0);\r
\r
if (--RtEntry->RefCnt == 0) {\r
- NetFreePool (RtEntry);\r
+ gBS->FreePool (RtEntry);\r
}\r
}\r
\r
\r
/**\r
- Allocate and initialize a IP4 route cache entry.\r
+ Allocate and initialize an IP4 route cache entry.\r
\r
@param Dst The destination address\r
@param Src The source address\r
entries spawned from one route table entry.\r
\r
@return NULL if failed to allocate memory for the cache, other point\r
- @return to the created route cache entry.\r
+ to the created route cache entry.\r
\r
**/\r
-STATIC\r
IP4_ROUTE_CACHE_ENTRY *\r
Ip4CreateRouteCacheEntry (\r
IN IP4_ADDR Dst,\r
{\r
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
\r
- RtCacheEntry = NetAllocatePool (sizeof (IP4_ROUTE_CACHE_ENTRY));\r
+ RtCacheEntry = AllocatePool (sizeof (IP4_ROUTE_CACHE_ENTRY));\r
\r
if (RtCacheEntry == NULL) {\r
return NULL;\r
}\r
\r
- NetListInit (&RtCacheEntry->Link);\r
+ InitializeListHead (&RtCacheEntry->Link);\r
\r
RtCacheEntry->RefCnt = 1;\r
RtCacheEntry->Dest = Dst;\r
ASSERT (RtCacheEntry->RefCnt > 0);\r
\r
if (--RtCacheEntry->RefCnt == 0) {\r
- NetFreePool (RtCacheEntry);\r
+ gBS->FreePool (RtCacheEntry);\r
}\r
}\r
\r
**/\r
VOID\r
Ip4InitRouteCache (\r
- IN IP4_ROUTE_CACHE *RtCache\r
+ IN OUT IP4_ROUTE_CACHE *RtCache\r
)\r
{\r
UINT32 Index;\r
\r
for (Index = 0; Index < IP4_ROUTE_CACHE_HASH; Index++) {\r
- NetListInit (&(RtCache->CacheBucket[Index]));\r
+ InitializeListHead (&(RtCache->CacheBucket[Index]));\r
}\r
}\r
\r
IN IP4_ROUTE_CACHE *RtCache\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Next;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
UINT32 Index;\r
\r
NET_LIST_FOR_EACH_SAFE (Entry, Next, &(RtCache->CacheBucket[Index])) {\r
RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link);\r
\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
Ip4FreeRouteCacheEntry (RtCacheEntry);\r
}\r
}\r
/**\r
Create an empty route table, includes its internal route cache\r
\r
- None\r
-\r
@return NULL if failed to allocate memory for the route table, otherwise\r
- @return the point to newly created route table.\r
+ the point to newly created route table.\r
\r
**/\r
IP4_ROUTE_TABLE *\r
IP4_ROUTE_TABLE *RtTable;\r
UINT32 Index;\r
\r
- RtTable = NetAllocatePool (sizeof (IP4_ROUTE_TABLE));\r
+ RtTable = AllocatePool (sizeof (IP4_ROUTE_TABLE));\r
\r
if (RtTable == NULL) {\r
return NULL;\r
RtTable->TotalNum = 0;\r
\r
for (Index = 0; Index < IP4_MASK_NUM; Index++) {\r
- NetListInit (&(RtTable->RouteArea[Index]));\r
+ InitializeListHead (&(RtTable->RouteArea[Index]));\r
}\r
\r
RtTable->Next = NULL;\r
IN IP4_ROUTE_TABLE *RtTable\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Next;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
IP4_ROUTE_ENTRY *RtEntry;\r
UINT32 Index;\r
\r
NET_LIST_FOR_EACH_SAFE (Entry, Next, &(RtTable->RouteArea[Index])) {\r
RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link);\r
\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
Ip4FreeRouteEntry (RtEntry);\r
}\r
}\r
\r
Ip4CleanRouteCache (&RtTable->Cache);\r
\r
- NetFreePool (RtTable);\r
+ gBS->FreePool (RtTable);\r
}\r
\r
\r
@return None\r
\r
**/\r
-STATIC\r
VOID\r
Ip4PurgeRouteCache (\r
- IN IP4_ROUTE_CACHE *RtCache,\r
- IN UINTN Tag\r
+ IN OUT IP4_ROUTE_CACHE *RtCache,\r
+ IN UINTN Tag\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Next;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
UINT32 Index;\r
\r
RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link);\r
\r
if (RtCacheEntry->Tag == Tag) {\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
Ip4FreeRouteCacheEntry (RtCacheEntry);\r
}\r
}\r
**/\r
EFI_STATUS\r
Ip4AddRoute (\r
- IN IP4_ROUTE_TABLE *RtTable,\r
- IN IP4_ADDR Dest,\r
- IN IP4_ADDR Netmask,\r
- IN IP4_ADDR Gateway\r
+ IN OUT IP4_ROUTE_TABLE *RtTable,\r
+ IN IP4_ADDR Dest,\r
+ IN IP4_ADDR Netmask,\r
+ IN IP4_ADDR Gateway\r
)\r
{\r
- NET_LIST_ENTRY *Head;\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Head;\r
+ LIST_ENTRY *Entry;\r
IP4_ROUTE_ENTRY *RtEntry;\r
\r
//\r
RtEntry->Flag = IP4_DIRECT_ROUTE;\r
}\r
\r
- NetListInsertHead (Head, &RtEntry->Link);\r
+ InsertHeadList (Head, &RtEntry->Link);\r
RtTable->TotalNum++;\r
\r
return EFI_SUCCESS;\r
**/\r
EFI_STATUS\r
Ip4DelRoute (\r
- IN IP4_ROUTE_TABLE *RtTable,\r
- IN IP4_ADDR Dest,\r
- IN IP4_ADDR Netmask,\r
- IN IP4_ADDR Gateway\r
+ IN OUT IP4_ROUTE_TABLE *RtTable,\r
+ IN IP4_ADDR Dest,\r
+ IN IP4_ADDR Netmask,\r
+ IN IP4_ADDR Gateway\r
)\r
{\r
- NET_LIST_ENTRY *Head;\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Next;\r
+ LIST_ENTRY *Head;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
IP4_ROUTE_ENTRY *RtEntry;\r
\r
Head = &(RtTable->RouteArea[NetGetMaskLength (Netmask)]);\r
\r
if (IP4_NET_EQUAL (RtEntry->Dest, Dest, Netmask) && (RtEntry->NextHop == Gateway)) {\r
Ip4PurgeRouteCache (&RtTable->Cache, (UINTN) RtEntry);\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
Ip4FreeRouteEntry (RtEntry);\r
\r
RtTable->TotalNum--;\r
@param Src The source address\r
\r
@return NULL if no route entry to the (Dest, Src). Otherwise the point\r
- @return to the correct route cache entry.\r
+ to the correct route cache entry.\r
\r
**/\r
IP4_ROUTE_CACHE_ENTRY *\r
IN IP4_ADDR Src\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
UINT32 Index;\r
\r
\r
/**\r
Search the route table for a most specific match to the Dst. It searches\r
- from the longest route area (mask length == 32) to the shortest route area (\r
- default routes). In each route area, it will first search the instance's\r
+ from the longest route area (mask length == 32) to the shortest route area\r
+ (default routes). In each route area, it will first search the instance's\r
route table, then the default route table. This is required by the following\r
requirements:\r
1. IP search the route table for a most specific match\r
@return most specific route to the Dst.\r
\r
**/\r
-STATIC\r
IP4_ROUTE_ENTRY *\r
Ip4FindRouteEntry (\r
IN IP4_ROUTE_TABLE *RtTable,\r
IN IP4_ADDR Dst\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
IP4_ROUTE_ENTRY *RtEntry;\r
IP4_ROUTE_TABLE *Table;\r
INTN Index;\r
\r
\r
/**\r
- Search the route table to route the packet. Return/creat a route\r
+ Search the route table to route the packet. Return/create a route\r
cache if there is a route to the destination.\r
\r
@param RtTable The route table to search from\r
@param Src The source address to search for\r
\r
@return NULL if failed to route packet, otherwise a route cache\r
- @return entry that can be used to route packet.\r
+ entry that can be used to route packet.\r
\r
**/\r
IP4_ROUTE_CACHE_ENTRY *\r
IN IP4_ADDR Src\r
)\r
{\r
- NET_LIST_ENTRY *Head;\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Next;\r
+ LIST_ENTRY *Head;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
IP4_ROUTE_CACHE_ENTRY *Cache;\r
IP4_ROUTE_ENTRY *RtEntry;\r
// If found, promote the cache entry to the head of the hash bucket. LRU\r
//\r
if (RtCacheEntry != NULL) {\r
- NetListRemoveEntry (&RtCacheEntry->Link);\r
- NetListInsertHead (Head, &RtCacheEntry->Link);\r
+ RemoveEntryList (&RtCacheEntry->Link);\r
+ InsertHeadList (Head, &RtCacheEntry->Link);\r
return RtCacheEntry;\r
}\r
\r
\r
//\r
// Found a route to the Dest, if it is a direct route, the packet\r
- // will be send directly to the destination, such as for connected\r
+ // will be sent directly to the destination, such as for connected\r
// network. Otherwise, it is an indirect route, the packet will be\r
- // send the next hop router.\r
+ // sent to the next hop router.\r
//\r
- if (RtEntry->Flag & IP4_DIRECT_ROUTE) {\r
+ if ((RtEntry->Flag & IP4_DIRECT_ROUTE) != 0) {\r
NextHop = Dest;\r
} else {\r
NextHop = RtEntry->NextHop;\r
return NULL;\r
}\r
\r
- NetListInsertHead (Head, &RtCacheEntry->Link);\r
+ InsertHeadList (Head, &RtCacheEntry->Link);\r
NET_GET_REF (RtCacheEntry);\r
\r
//\r
\r
Cache = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link);\r
\r
- NetListRemoveEntry (Entry);\r
+ RemoveEntryList (Entry);\r
Ip4FreeRouteCacheEntry (Cache);\r
}\r
\r
IN IP4_PROTOCOL *IpInstance\r
)\r
{\r
- IP4_SERVICE *IpSb;\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
IP4_ROUTE_TABLE *RtTable;\r
IP4_ROUTE_ENTRY *RtEntry;\r
EFI_IP4_ROUTE_TABLE *Table;\r
UINT32 Count;\r
INT32 Index;\r
\r
- IpSb = IpInstance->Service;\r
RtTable = IpInstance->RouteTable;\r
\r
if (IpInstance->EfiRouteTable != NULL) {\r
- NetFreePool (IpInstance->EfiRouteTable);\r
+ gBS->FreePool (IpInstance->EfiRouteTable);\r
\r
IpInstance->EfiRouteTable = NULL;\r
IpInstance->EfiRouteCount = 0;\r
return EFI_SUCCESS;\r
}\r
\r
- Table = NetAllocatePool (sizeof (EFI_IP4_ROUTE_TABLE) * Count);\r
+ Table = AllocatePool (sizeof (EFI_IP4_ROUTE_TABLE) * Count);\r
\r
if (Table == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r