]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c
Scrubbed more.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Route.c
index 2cf1d0f29cab3a5031752a9aff65610e958a543f..5bec33e5987a7658258b3a767d9c066b186d26e3 100644 (file)
@@ -31,10 +31,9 @@ Abstract:
   @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
@@ -44,13 +43,13 @@ Ip4CreateRouteEntry (
 {\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
@@ -70,7 +69,6 @@ Ip4CreateRouteEntry (
   @return NONE\r
 \r
 **/\r
-STATIC\r
 VOID\r
 Ip4FreeRouteEntry (\r
   IN IP4_ROUTE_ENTRY    *RtEntry\r
@@ -79,13 +77,13 @@ Ip4FreeRouteEntry (
   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
@@ -94,10 +92,9 @@ Ip4FreeRouteEntry (
                                 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
@@ -108,13 +105,13 @@ Ip4CreateRouteCacheEntry (
 {\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
@@ -142,7 +139,7 @@ Ip4FreeRouteCacheEntry (
   ASSERT (RtCacheEntry->RefCnt > 0);\r
 \r
   if (--RtCacheEntry->RefCnt == 0) {\r
-    NetFreePool (RtCacheEntry);\r
+    gBS->FreePool (RtCacheEntry);\r
   }\r
 }\r
 \r
@@ -157,13 +154,13 @@ Ip4FreeRouteCacheEntry (
 **/\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
@@ -182,8 +179,8 @@ Ip4CleanRouteCache (
   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
@@ -191,7 +188,7 @@ Ip4CleanRouteCache (
     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
@@ -202,10 +199,8 @@ Ip4CleanRouteCache (
 /**\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
@@ -216,7 +211,7 @@ Ip4CreateRouteTable (
   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
@@ -226,7 +221,7 @@ Ip4CreateRouteTable (
   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
@@ -250,8 +245,8 @@ Ip4FreeRouteTable (
   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
@@ -268,14 +263,14 @@ Ip4FreeRouteTable (
     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
@@ -292,15 +287,14 @@ Ip4FreeRouteTable (
   @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
@@ -310,7 +304,7 @@ Ip4PurgeRouteCache (
       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
@@ -334,14 +328,14 @@ Ip4PurgeRouteCache (
 **/\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
@@ -374,7 +368,7 @@ Ip4AddRoute (
     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
@@ -396,15 +390,15 @@ Ip4AddRoute (
 **/\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
@@ -414,7 +408,7 @@ Ip4DelRoute (
 \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
@@ -437,7 +431,7 @@ Ip4DelRoute (
   @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
@@ -447,7 +441,7 @@ Ip4FindRouteCache (
   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
@@ -468,8 +462,8 @@ Ip4FindRouteCache (
 \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
@@ -482,14 +476,13 @@ Ip4FindRouteCache (
   @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
@@ -515,7 +508,7 @@ Ip4FindRouteEntry (
 \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
@@ -523,7 +516,7 @@ Ip4FindRouteEntry (
   @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
@@ -533,9 +526,9 @@ Ip4Route (
   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
@@ -551,8 +544,8 @@ Ip4Route (
   // 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
@@ -567,11 +560,11 @@ Ip4Route (
 \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
@@ -588,7 +581,7 @@ Ip4Route (
     return NULL;\r
   }\r
 \r
-  NetListInsertHead (Head, &RtCacheEntry->Link);\r
+  InsertHeadList (Head, &RtCacheEntry->Link);\r
   NET_GET_REF (RtCacheEntry);\r
 \r
   //\r
@@ -604,7 +597,7 @@ Ip4Route (
 \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
@@ -628,19 +621,17 @@ Ip4BuildEfiRouteTable (
   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
@@ -656,7 +647,7 @@ Ip4BuildEfiRouteTable (
     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