X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Route.c;h=ea0023ddcb2d823d3f8cf50a5ef2720955c1dccd;hb=d0d34cdf1d2752f0d7c3ca41af7e7ed29c221d11;hp=3ab940e184f97b1c4b49538340b96deb18c5326d;hpb=fe1e36e550c6ffcd2561903d434683d3939e1942;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c index 3ab940e184..ea0023ddcb 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c @@ -1,7 +1,7 @@ /** @file -Copyright (c) 2005 - 2006, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2005 - 2009, 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 @@ -9,14 +9,6 @@ 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: - - Ip4Route.c - -Abstract: - - **/ #include "Ip4Impl.h" @@ -26,12 +18,12 @@ Abstract: Allocate a route entry then initialize it with the Dest/Netmaks and Gateway. - @param Dest The destination network - @param Netmask The destination network mask - @param GateWay The nexthop address + @param[in] Dest The destination network + @param[in] Netmask The destination network mask + @param[in] GateWay The nexthop address @return NULL if failed to allocate memeory, otherwise the newly created - @return route entry. + route entry. **/ IP4_ROUTE_ENTRY * @@ -66,8 +58,6 @@ Ip4CreateRouteEntry ( @param RtEntry The route entry to free. - @return NONE - **/ VOID Ip4FreeRouteEntry ( @@ -77,22 +67,22 @@ Ip4FreeRouteEntry ( ASSERT (RtEntry->RefCnt > 0); if (--RtEntry->RefCnt == 0) { - gBS->FreePool (RtEntry); + FreePool (RtEntry); } } /** - Allocate and initialize a IP4 route cache entry. + Allocate and initialize an IP4 route cache entry. - @param Dst The destination address - @param Src The source address - @param GateWay The next hop address - @param Tag The tag from the caller. This marks all the cache - entries spawned from one route table entry. + @param[in] Dst The destination address + @param[in] Src The source address + @param[in] GateWay The next hop address + @param[in] Tag The tag from the caller. This marks all the cache + entries spawned from one route table entry. @return NULL if failed to allocate memory for the cache, other point - @return to the created route cache entry. + to the created route cache entry. **/ IP4_ROUTE_CACHE_ENTRY * @@ -128,8 +118,6 @@ Ip4CreateRouteCacheEntry ( @param RtCacheEntry The route cache entry to free. - @return None - **/ VOID Ip4FreeRouteCacheEntry ( @@ -139,7 +127,7 @@ Ip4FreeRouteCacheEntry ( ASSERT (RtCacheEntry->RefCnt > 0); if (--RtCacheEntry->RefCnt == 0) { - gBS->FreePool (RtCacheEntry); + FreePool (RtCacheEntry); } } @@ -147,19 +135,17 @@ Ip4FreeRouteCacheEntry ( /** Initialize an empty route cache table. - @param RtCache The rotue cache table to initialize. - - @return NONE + @param[in, out] RtCache The rotue cache table to initialize. **/ VOID Ip4InitRouteCache ( - IN IP4_ROUTE_CACHE *RtCache + IN OUT IP4_ROUTE_CACHE *RtCache ) { UINT32 Index; - for (Index = 0; Index < IP4_ROUTE_CACHE_HASH; Index++) { + for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) { InitializeListHead (&(RtCache->CacheBucket[Index])); } } @@ -169,9 +155,7 @@ Ip4InitRouteCache ( Clean up a route cache, that is free all the route cache entries enqueued in the cache. - @param RtCache The route cache table to clean up - - @return None + @param[in] RtCache The route cache table to clean up **/ VOID @@ -184,7 +168,7 @@ Ip4CleanRouteCache ( IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; UINT32 Index; - for (Index = 0; Index < IP4_ROUTE_CACHE_HASH; Index++) { + for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &(RtCache->CacheBucket[Index])) { RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link); @@ -199,10 +183,8 @@ Ip4CleanRouteCache ( /** Create an empty route table, includes its internal route cache - None - @return NULL if failed to allocate memory for the route table, otherwise - @return the point to newly created route table. + the point to newly created route table. **/ IP4_ROUTE_TABLE * @@ -237,9 +219,7 @@ Ip4CreateRouteTable ( Free the route table and its associated route cache. Route table is reference counted. - @param RtTable The route table to free. - - @return None + @param[in] RtTable The route table to free. **/ VOID @@ -272,7 +252,7 @@ Ip4FreeRouteTable ( Ip4CleanRouteCache (&RtTable->Cache); - gBS->FreePool (RtTable); + FreePool (RtTable); } @@ -286,13 +266,11 @@ Ip4FreeRouteTable ( @param RtCache Route cache to remove the entries from @param Tag The Tag of the entries to remove - @return None - **/ VOID Ip4PurgeRouteCache ( - IN IP4_ROUTE_CACHE *RtCache, - IN UINTN Tag + IN OUT IP4_ROUTE_CACHE *RtCache, + IN UINTN Tag ) { LIST_ENTRY *Entry; @@ -300,7 +278,7 @@ Ip4PurgeRouteCache ( IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; UINT32 Index; - for (Index = 0; Index < IP4_ROUTE_CACHE_HASH; Index++) { + for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtCache->CacheBucket[Index]) { RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link); @@ -318,10 +296,10 @@ Ip4PurgeRouteCache ( Add a route entry to the route table. All the IP4_ADDRs are in host byte order. - @param RtTable Route table to add route to - @param Dest The destination of the network - @param Netmask The netmask of the destination - @param Gateway The next hop address + @param[in, out] RtTable Route table to add route to + @param[in] Dest The destination of the network + @param[in] Netmask The netmask of the destination + @param[in] Gateway The next hop address @retval EFI_ACCESS_DENIED The same route already exists @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the entry @@ -330,10 +308,10 @@ Ip4PurgeRouteCache ( **/ EFI_STATUS Ip4AddRoute ( - IN IP4_ROUTE_TABLE *RtTable, - IN IP4_ADDR Dest, - IN IP4_ADDR Netmask, - IN IP4_ADDR Gateway + IN OUT IP4_ROUTE_TABLE *RtTable, + IN IP4_ADDR Dest, + IN IP4_ADDR Netmask, + IN IP4_ADDR Gateway ) { LIST_ENTRY *Head; @@ -380,10 +358,10 @@ Ip4AddRoute ( /** Remove a route entry and all the route caches spawn from it. - @param RtTable The route table to remove the route from - @param Dest The destination network - @param Netmask The netmask of the Dest - @param Gateway The next hop address + @param RtTable The route table to remove the route from + @param Dest The destination network + @param Netmask The netmask of the Dest + @param Gateway The next hop address @retval EFI_SUCCESS The route entry is successfully removed @retval EFI_NOT_FOUND There is no route entry in the table with that @@ -392,10 +370,10 @@ Ip4AddRoute ( **/ EFI_STATUS Ip4DelRoute ( - IN IP4_ROUTE_TABLE *RtTable, - IN IP4_ADDR Dest, - IN IP4_ADDR Netmask, - IN IP4_ADDR Gateway + IN OUT IP4_ROUTE_TABLE *RtTable, + IN IP4_ADDR Dest, + IN IP4_ADDR Netmask, + IN IP4_ADDR Gateway ) { LIST_ENTRY *Head; @@ -428,12 +406,12 @@ Ip4DelRoute ( host redirect according to RFC1122. So, only route cache entries are modified according to the ICMP redirect message. - @param RtTable The route table to search the cache for - @param Dest The destination address - @param Src The source address + @param[in] RtTable The route table to search the cache for + @param[in] Dest The destination address + @param[in] Src The source address @return NULL if no route entry to the (Dest, Src). Otherwise the point - @return to the correct route cache entry. + to the correct route cache entry. **/ IP4_ROUTE_CACHE_ENTRY * @@ -464,18 +442,18 @@ Ip4FindRouteCache ( /** Search the route table for a most specific match to the Dst. It searches - from the longest route area (mask length == 32) to the shortest route area ( - default routes). In each route area, it will first search the instance's + from the longest route area (mask length == 32) to the shortest route area + (default routes). In each route area, it will first search the instance's route table, then the default route table. This is required by the following requirements: 1. IP search the route table for a most specific match 2. The local route entries have precedence over the default route entry. - @param RtTable The route table to search from - @param Dst The destionation address to search + @param[in] RtTable The route table to search from + @param[in] Dst The destionation address to search @return NULL if no route matches the Dst, otherwise the point to the - @return most specific route to the Dst. + most specific route to the Dst. **/ IP4_ROUTE_ENTRY * @@ -510,15 +488,15 @@ Ip4FindRouteEntry ( /** - Search the route table to route the packet. Return/creat a route + Search the route table to route the packet. Return/create a route cache if there is a route to the destination. - @param RtTable The route table to search from - @param Dest The destination address to search for - @param Src The source address to search for + @param[in] RtTable The route table to search from + @param[in] Dest The destination address to search for + @param[in] Src The source address to search for @return NULL if failed to route packet, otherwise a route cache - @return entry that can be used to route packet. + entry that can be used to route packet. **/ IP4_ROUTE_CACHE_ENTRY * @@ -562,11 +540,11 @@ Ip4Route ( // // Found a route to the Dest, if it is a direct route, the packet - // will be send directly to the destination, such as for connected + // will be sent directly to the destination, such as for connected // network. Otherwise, it is an indirect route, the packet will be - // send the next hop router. + // sent to the next hop router. // - if (RtEntry->Flag & IP4_DIRECT_ROUTE) { + if ((RtEntry->Flag & IP4_DIRECT_ROUTE) != 0) { NextHop = Dest; } else { NextHop = RtEntry->NextHop; @@ -612,7 +590,7 @@ Ip4Route ( GetModeData. The EFI_IP4_ROUTE_TABLE is clumsy to use in the internal operation of the IP4 driver. - @param IpInstance The IP4 child that requests the route table. + @param[in] IpInstance The IP4 child that requests the route table. @retval EFI_SUCCESS The route table is successfully build @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the rotue table. @@ -633,7 +611,7 @@ Ip4BuildEfiRouteTable ( RtTable = IpInstance->RouteTable; if (IpInstance->EfiRouteTable != NULL) { - gBS->FreePool (IpInstance->EfiRouteTable); + FreePool (IpInstance->EfiRouteTable); IpInstance->EfiRouteTable = NULL; IpInstance->EfiRouteCount = 0;