]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h
Use Mde library and definition instead of some native definitions in NetLib, to simpl...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Route.h
CommitLineData
83cbd279 1/** @file\r
2\r
3Copyright (c) 2005 - 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12\r
13Module Name:\r
14\r
15 Ip4Route.h\r
16\r
17Abstract:\r
18\r
19 EFI IP4 route table and route cache table defintions.\r
20\r
21\r
22**/\r
23\r
24#ifndef __EFI_IP4_ROUTE_H__\r
25#define __EFI_IP4_ROUTE_H__\r
26\r
27#include "IP4Common.h"\r
28\r
29enum {\r
30 IP4_DIRECT_ROUTE = 0x00000001,\r
31\r
32 IP4_ROUTE_CACHE_HASH = 31,\r
33 IP4_ROUTE_CACHE_MAX = 64 // Max NO. of cache entry per hash bucket\r
34};\r
35\r
36#define IP4_ROUTE_CACHE_HASH(Dst, Src) (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH)\r
37\r
38//\r
39// The route entry in the route table. Dest/Netmask is the destion\r
40// network. The nexthop is the gateway to send the packet to in\r
41// order to reach the Dest/Netmask. If the Flag has IP4_DIRECT_ROUTE\r
42// on, the gateway is the destination of the IP packet itself. Route\r
43// enties of the connected network have the flag on.\r
44//\r
45typedef struct {\r
e48e37fc 46 LIST_ENTRY Link;\r
83cbd279 47 INTN RefCnt;\r
48 IP4_ADDR Dest;\r
49 IP4_ADDR Netmask;\r
50 IP4_ADDR NextHop;\r
51 UINT32 Flag;\r
52} IP4_ROUTE_ENTRY;\r
53\r
54//\r
55// The route cache entry. The route cache entry is optional.\r
56// But it is necessary to support the ICMP redirect message.\r
57// Check Ip4ProcessIcmpRedirect for information.\r
58//\r
59// The cache entry field Tag is used to tag all the route\r
60// cache entry spawned from a route table entry. This makes\r
61// it simple to delete all the route cache entries from a\r
62// to-be-deleted route entry.\r
63//\r
64typedef struct {\r
e48e37fc 65 LIST_ENTRY Link;\r
83cbd279 66 INTN RefCnt;\r
67 IP4_ADDR Dest;\r
68 IP4_ADDR Src;\r
69 IP4_ADDR NextHop;\r
70 UINTN Tag;\r
71} IP4_ROUTE_CACHE_ENTRY;\r
72\r
73//\r
74// The route cache table is organized as a hash table. Each\r
75// IP4 route table has a embedded route cache. For now the\r
76// route cache and route table are binded togehter. But keep\r
77// the route cache a seperated structure in case we want to\r
78// detach them later.\r
79//\r
80typedef struct {\r
e48e37fc 81 LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH];\r
83cbd279 82} IP4_ROUTE_CACHE;\r
83\r
84//\r
85// Each IP4 instance has its own route table. Each ServiceBinding\r
86// instance has a default route table and default address.\r
87//\r
88// All the route table entries with the same mask are linked\r
89// together in one route area. For example, RouteArea[0] contains\r
90// the default routes. A route table also contains a route cache.\r
91//\r
92typedef struct _IP4_ROUTE_TABLE IP4_ROUTE_TABLE;\r
93\r
94struct _IP4_ROUTE_TABLE {\r
95 INTN RefCnt;\r
96 UINT32 TotalNum;\r
e48e37fc 97 LIST_ENTRY RouteArea[IP4_MASK_NUM];\r
83cbd279 98 IP4_ROUTE_TABLE *Next;\r
99 IP4_ROUTE_CACHE Cache;\r
100};\r
101\r
102IP4_ROUTE_TABLE*\r
103Ip4CreateRouteTable (\r
104 VOID\r
105 );\r
106\r
107VOID\r
108Ip4FreeRouteTable (\r
109 IN IP4_ROUTE_TABLE *RouteTable\r
110 );\r
111\r
112EFI_STATUS\r
113Ip4AddRoute (\r
114 IN IP4_ROUTE_TABLE *RtTable,\r
115 IN IP4_ADDR Dest,\r
116 IN IP4_ADDR Netmask,\r
117 IN IP4_ADDR Gateway\r
118 );\r
119\r
120EFI_STATUS\r
121Ip4DelRoute (\r
122 IN IP4_ROUTE_TABLE *RtTable,\r
123 IN IP4_ADDR Dest,\r
124 IN IP4_ADDR Netmask,\r
125 IN IP4_ADDR Gateway\r
126 );\r
127\r
128IP4_ROUTE_CACHE_ENTRY *\r
129Ip4FindRouteCache (\r
130 IN IP4_ROUTE_TABLE *RtTable,\r
131 IN IP4_ADDR Dest,\r
132 IN IP4_ADDR Src\r
133 );\r
134\r
135VOID\r
136Ip4FreeRouteCacheEntry (\r
137 IN IP4_ROUTE_CACHE_ENTRY *RtCacheEntry\r
138 );\r
139\r
140IP4_ROUTE_CACHE_ENTRY *\r
141Ip4Route (\r
142 IN IP4_ROUTE_TABLE *RtTable,\r
143 IN IP4_ADDR Dest,\r
144 IN IP4_ADDR Src\r
145 );\r
146\r
147EFI_STATUS\r
148Ip4BuildEfiRouteTable (\r
149 IN IP4_PROTOCOL *IpInstance\r
150 );\r
151#endif\r