]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h
added comments for CAPSULE_HOB_INFO in CapsuleVendor.h (MdeModuleModulePkg).
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Route.h
CommitLineData
83cbd279 1/** @file\r
3e8c18da 2 EFI IP4 route table and route cache table defintions.\r
3 \r
4Copyright (c) 2005 - 2006, Intel Corporation.<BR>\r
83cbd279 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
83cbd279 13**/\r
14\r
15#ifndef __EFI_IP4_ROUTE_H__\r
16#define __EFI_IP4_ROUTE_H__\r
17\r
5f778b1f 18#include "Ip4Common.h"\r
83cbd279 19\r
5405e9a6 20typedef enum {\r
83cbd279 21 IP4_DIRECT_ROUTE = 0x00000001,\r
22\r
23 IP4_ROUTE_CACHE_HASH = 31,\r
24 IP4_ROUTE_CACHE_MAX = 64 // Max NO. of cache entry per hash bucket\r
5405e9a6 25} IP4_ROUTE_ENUM_TYPES;\r
83cbd279 26\r
27#define IP4_ROUTE_CACHE_HASH(Dst, Src) (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH)\r
28\r
96e1079f 29///\r
30/// The route entry in the route table. Dest/Netmask is the destion\r
31/// network. The nexthop is the gateway to send the packet to in\r
32/// order to reach the Dest/Netmask. If the Flag has IP4_DIRECT_ROUTE\r
33/// on, the gateway is the destination of the IP packet itself. Route\r
34/// enties of the connected network have the flag on.\r
35///\r
83cbd279 36typedef struct {\r
e48e37fc 37 LIST_ENTRY Link;\r
83cbd279 38 INTN RefCnt;\r
39 IP4_ADDR Dest;\r
40 IP4_ADDR Netmask;\r
41 IP4_ADDR NextHop;\r
42 UINT32 Flag;\r
43} IP4_ROUTE_ENTRY;\r
44\r
96e1079f 45///\r
46/// The route cache entry. The route cache entry is optional.\r
47/// But it is necessary to support the ICMP redirect message.\r
48/// Check Ip4ProcessIcmpRedirect for information.\r
49///\r
50/// The cache entry field Tag is used to tag all the route\r
51/// cache entry spawned from a route table entry. This makes\r
52/// it simple to delete all the route cache entries from a\r
53/// to-be-deleted route entry.\r
54///\r
83cbd279 55typedef struct {\r
e48e37fc 56 LIST_ENTRY Link;\r
83cbd279 57 INTN RefCnt;\r
58 IP4_ADDR Dest;\r
59 IP4_ADDR Src;\r
60 IP4_ADDR NextHop;\r
61 UINTN Tag;\r
62} IP4_ROUTE_CACHE_ENTRY;\r
63\r
96e1079f 64///\r
65/// The route cache table is organized as a hash table. Each\r
66/// IP4 route table has a embedded route cache. For now the\r
67/// route cache and route table are binded togehter. But keep\r
68/// the route cache a seperated structure in case we want to\r
69/// detach them later.\r
70///\r
83cbd279 71typedef struct {\r
e48e37fc 72 LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH];\r
83cbd279 73} IP4_ROUTE_CACHE;\r
74\r
96e1079f 75///\r
76/// Each IP4 instance has its own route table. Each ServiceBinding\r
77/// instance has a default route table and default address.\r
78///\r
79/// All the route table entries with the same mask are linked\r
80/// together in one route area. For example, RouteArea[0] contains\r
81/// the default routes. A route table also contains a route cache.\r
82///\r
83cbd279 83typedef struct _IP4_ROUTE_TABLE IP4_ROUTE_TABLE;\r
84\r
85struct _IP4_ROUTE_TABLE {\r
86 INTN RefCnt;\r
87 UINT32 TotalNum;\r
e48e37fc 88 LIST_ENTRY RouteArea[IP4_MASK_NUM];\r
83cbd279 89 IP4_ROUTE_TABLE *Next;\r
90 IP4_ROUTE_CACHE Cache;\r
91};\r
92\r
2ff29212 93/**\r
94 Create an empty route table, includes its internal route cache\r
95\r
96 @return NULL if failed to allocate memory for the route table, otherwise\r
97 the point to newly created route table.\r
98\r
99**/\r
100IP4_ROUTE_TABLE *\r
83cbd279 101Ip4CreateRouteTable (\r
102 VOID\r
103 );\r
104\r
2ff29212 105/**\r
106 Free the route table and its associated route cache. Route\r
107 table is reference counted.\r
108\r
3e8c18da 109 @param[in] RtTable The route table to free.\r
2ff29212 110\r
111**/\r
83cbd279 112VOID\r
113Ip4FreeRouteTable (\r
2ff29212 114 IN IP4_ROUTE_TABLE *RtTable\r
83cbd279 115 );\r
116\r
2ff29212 117/**\r
118 Add a route entry to the route table. All the IP4_ADDRs are in\r
119 host byte order.\r
120\r
3e8c18da 121 @param[in, out] RtTable Route table to add route to\r
122 @param[in] Dest The destination of the network\r
123 @param[in] Netmask The netmask of the destination\r
124 @param[in] Gateway The next hop address\r
2ff29212 125\r
126 @retval EFI_ACCESS_DENIED The same route already exists\r
127 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the entry\r
128 @retval EFI_SUCCESS The route is added successfully.\r
129\r
130**/\r
83cbd279 131EFI_STATUS\r
132Ip4AddRoute (\r
2ff29212 133 IN OUT IP4_ROUTE_TABLE *RtTable,\r
134 IN IP4_ADDR Dest,\r
135 IN IP4_ADDR Netmask,\r
136 IN IP4_ADDR Gateway\r
83cbd279 137 );\r
138\r
2ff29212 139/**\r
140 Remove a route entry and all the route caches spawn from it.\r
141\r
3e8c18da 142 @param RtTable The route table to remove the route from\r
143 @param Dest The destination network\r
144 @param Netmask The netmask of the Dest\r
145 @param Gateway The next hop address\r
2ff29212 146\r
147 @retval EFI_SUCCESS The route entry is successfully removed\r
148 @retval EFI_NOT_FOUND There is no route entry in the table with that\r
149 properity.\r
150\r
151**/\r
83cbd279 152EFI_STATUS\r
153Ip4DelRoute (\r
2ff29212 154 IN OUT IP4_ROUTE_TABLE *RtTable,\r
155 IN IP4_ADDR Dest,\r
156 IN IP4_ADDR Netmask,\r
157 IN IP4_ADDR Gateway\r
83cbd279 158 );\r
159\r
2ff29212 160/**\r
161 Find a route cache with the dst and src. This is used by ICMP\r
162 redirect messasge process. All kinds of redirect is treated as\r
163 host redirect according to RFC1122. So, only route cache entries\r
164 are modified according to the ICMP redirect message.\r
165\r
3e8c18da 166 @param[in] RtTable The route table to search the cache for\r
167 @param[in] Dest The destination address\r
168 @param[in] Src The source address\r
2ff29212 169\r
170 @return NULL if no route entry to the (Dest, Src). Otherwise the point\r
171 to the correct route cache entry.\r
172\r
173**/\r
83cbd279 174IP4_ROUTE_CACHE_ENTRY *\r
175Ip4FindRouteCache (\r
176 IN IP4_ROUTE_TABLE *RtTable,\r
177 IN IP4_ADDR Dest,\r
178 IN IP4_ADDR Src\r
179 );\r
180\r
2ff29212 181/**\r
182 Free the route cache entry. It is reference counted.\r
183\r
184 @param RtCacheEntry The route cache entry to free.\r
185\r
2ff29212 186**/\r
83cbd279 187VOID\r
188Ip4FreeRouteCacheEntry (\r
189 IN IP4_ROUTE_CACHE_ENTRY *RtCacheEntry\r
190 );\r
191\r
2ff29212 192/**\r
193 Search the route table to route the packet. Return/create a route\r
194 cache if there is a route to the destination.\r
195\r
3e8c18da 196 @param[in] RtTable The route table to search from\r
197 @param[in] Dest The destination address to search for\r
198 @param[in] Src The source address to search for\r
2ff29212 199\r
200 @return NULL if failed to route packet, otherwise a route cache\r
201 entry that can be used to route packet.\r
202\r
203**/\r
83cbd279 204IP4_ROUTE_CACHE_ENTRY *\r
205Ip4Route (\r
206 IN IP4_ROUTE_TABLE *RtTable,\r
207 IN IP4_ADDR Dest,\r
208 IN IP4_ADDR Src\r
209 );\r
210\r
2ff29212 211/**\r
212 Build a EFI_IP4_ROUTE_TABLE to be returned to the caller of\r
213 GetModeData. The EFI_IP4_ROUTE_TABLE is clumsy to use in the\r
214 internal operation of the IP4 driver.\r
215\r
3e8c18da 216 @param[in] IpInstance The IP4 child that requests the route table.\r
2ff29212 217\r
218 @retval EFI_SUCCESS The route table is successfully build\r
219 @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the rotue table.\r
220\r
221**/\r
83cbd279 222EFI_STATUS\r
223Ip4BuildEfiRouteTable (\r
224 IN IP4_PROTOCOL *IpInstance\r
225 );\r
226#endif\r