X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Route.h;h=778c97dc8b30904904d4713db7d373738a1c05e8;hp=bc396f94b42bbd9a0a302bd395c974f561fccfbd;hb=4f0f2316ed7699e233b362b83c7fbd63c2adf97e;hpb=96e1079fa412753e42edf293ce28adda88e68a45 diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h index bc396f94b4..778c97dc8b 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h @@ -1,7 +1,8 @@ /** @file - -Copyright (c) 2005 - 2006, Intel Corporation -All rights reserved. This program and the accompanying materials + EFI IP4 route table and route cache table defintions. + +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,16 +10,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.h - -Abstract: - - EFI IP4 route table and route cache table defintions. - - **/ #ifndef __EFI_IP4_ROUTE_H__ @@ -26,14 +17,12 @@ Abstract: #include "Ip4Common.h" -typedef enum { - IP4_DIRECT_ROUTE = 0x00000001, +#define IP4_DIRECT_ROUTE 0x00000001 - IP4_ROUTE_CACHE_HASH = 31, - IP4_ROUTE_CACHE_MAX = 64 // Max NO. of cache entry per hash bucket -} IP4_ROUTE_ENUM_TYPES; +#define IP4_ROUTE_CACHE_HASH_VALUE 31 +#define IP4_ROUTE_CACHE_MAX 64 // Max NO. of cache entry per hash bucket -#define IP4_ROUTE_CACHE_HASH(Dst, Src) (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH) +#define IP4_ROUTE_CACHE_HASH(Dst, Src) (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH_VALUE) /// /// The route entry in the route table. Dest/Netmask is the destion @@ -78,7 +67,7 @@ typedef struct { /// detach them later. /// typedef struct { - LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH]; + LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH_VALUE]; } IP4_ROUTE_CACHE; /// @@ -99,32 +88,87 @@ struct _IP4_ROUTE_TABLE { IP4_ROUTE_CACHE Cache; }; -IP4_ROUTE_TABLE* +/** + Create an empty route table, includes its internal route cache + + @return NULL if failed to allocate memory for the route table, otherwise + the point to newly created route table. + +**/ +IP4_ROUTE_TABLE * Ip4CreateRouteTable ( VOID ); +/** + Free the route table and its associated route cache. Route + table is reference counted. + + @param[in] RtTable The route table to free. + +**/ VOID Ip4FreeRouteTable ( - IN IP4_ROUTE_TABLE *RouteTable + IN IP4_ROUTE_TABLE *RtTable ); +/** + Add a route entry to the route table. All the IP4_ADDRs are in + host byte order. + + @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 + @retval EFI_SUCCESS The route is added successfully. + +**/ 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 ); +/** + 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 + + @retval EFI_SUCCESS The route entry is successfully removed + @retval EFI_NOT_FOUND There is no route entry in the table with that + properity. + +**/ 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 ); +/** + Find a route cache with the dst and src. This is used by ICMP + redirect messasge process. All kinds of redirect is treated as + host redirect according to RFC1122. So, only route cache entries + are modified according to the ICMP redirect message. + + @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 + to the correct route cache entry. + +**/ IP4_ROUTE_CACHE_ENTRY * Ip4FindRouteCache ( IN IP4_ROUTE_TABLE *RtTable, @@ -132,11 +176,29 @@ Ip4FindRouteCache ( IN IP4_ADDR Src ); +/** + Free the route cache entry. It is reference counted. + + @param RtCacheEntry The route cache entry to free. + +**/ VOID Ip4FreeRouteCacheEntry ( IN IP4_ROUTE_CACHE_ENTRY *RtCacheEntry ); +/** + Search the route table to route the packet. Return/create a route + cache if there is a route to the destination. + + @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 + entry that can be used to route packet. + +**/ IP4_ROUTE_CACHE_ENTRY * Ip4Route ( IN IP4_ROUTE_TABLE *RtTable, @@ -144,6 +206,17 @@ Ip4Route ( IN IP4_ADDR Src ); +/** + Build a EFI_IP4_ROUTE_TABLE to be returned to the caller of + GetModeData. The EFI_IP4_ROUTE_TABLE is clumsy to use in the + internal operation of the IP4 driver. + + @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. + +**/ EFI_STATUS Ip4BuildEfiRouteTable ( IN IP4_PROTOCOL *IpInstance