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