TianoCore EDK2 master
Loading...
Searching...
No Matches
Ip4Route.h File Reference
#include "Ip4Common.h"

Go to the source code of this file.

Data Structures

struct  IP4_ROUTE_ENTRY
 
struct  IP4_ROUTE_CACHE_ENTRY
 
struct  IP4_ROUTE_CACHE
 
struct  _IP4_ROUTE_TABLE
 

Macros

#define IP4_DIRECT_ROUTE   0x00000001
 
#define IP4_ROUTE_CACHE_HASH_VALUE   31
 
#define IP4_ROUTE_CACHE_MAX   64
 
#define IP4_ROUTE_CACHE_HASH(Dst, Src)   (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH_VALUE)
 

Typedefs

typedef struct _IP4_ROUTE_TABLE IP4_ROUTE_TABLE
 

Functions

IP4_ROUTE_TABLEIp4CreateRouteTable (VOID)
 
VOID Ip4FreeRouteTable (IN IP4_ROUTE_TABLE *RtTable)
 
EFI_STATUS Ip4AddRoute (IN OUT IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR Gateway)
 
EFI_STATUS Ip4DelRoute (IN OUT IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR Gateway)
 
IP4_ROUTE_CACHE_ENTRYIp4FindRouteCache (IN IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Src)
 
VOID Ip4FreeRouteCacheEntry (IN IP4_ROUTE_CACHE_ENTRY *RtCacheEntry)
 
IP4_ROUTE_CACHE_ENTRYIp4Route (IN IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Src, IN IP4_ADDR SubnetMask, IN BOOLEAN AlwaysTryDestAddr)
 
EFI_STATUS Ip4BuildEfiRouteTable (IN IP4_PROTOCOL *IpInstance)
 

Detailed Description

EFI IP4 route table and route cache table definitions.

Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Ip4Route.h.

Macro Definition Documentation

◆ IP4_DIRECT_ROUTE

#define IP4_DIRECT_ROUTE   0x00000001

Definition at line 14 of file Ip4Route.h.

◆ IP4_ROUTE_CACHE_HASH

#define IP4_ROUTE_CACHE_HASH (   Dst,
  Src 
)    (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH_VALUE)

Definition at line 19 of file Ip4Route.h.

◆ IP4_ROUTE_CACHE_HASH_VALUE

#define IP4_ROUTE_CACHE_HASH_VALUE   31

Definition at line 16 of file Ip4Route.h.

◆ IP4_ROUTE_CACHE_MAX

#define IP4_ROUTE_CACHE_MAX   64

Definition at line 17 of file Ip4Route.h.

Typedef Documentation

◆ IP4_ROUTE_TABLE

Each IP4 instance has its own route table. Each ServiceBinding instance has a default route table and default address.

All the route table entries with the same mask are linked together in one route area. For example, RouteArea[0] contains the default routes. A route table also contains a route cache.

Definition at line 75 of file Ip4Route.h.

Function Documentation

◆ Ip4AddRoute()

EFI_STATUS Ip4AddRoute ( IN OUT IP4_ROUTE_TABLE RtTable,
IN IP4_ADDR  Dest,
IN IP4_ADDR  Netmask,
IN IP4_ADDR  Gateway 
)

Add a route entry to the route table. All the IP4_ADDRs are in host byte order.

Parameters
[in,out]RtTableRoute table to add route to
[in]DestThe destination of the network
[in]NetmaskThe netmask of the destination
[in]GatewayThe next hop address
Return values
EFI_ACCESS_DENIEDThe same route already exists
EFI_OUT_OF_RESOURCESFailed to allocate memory for the entry
EFI_SUCCESSThe route is added successfully.

Definition at line 291 of file Ip4Route.c.

◆ Ip4BuildEfiRouteTable()

EFI_STATUS Ip4BuildEfiRouteTable ( IN IP4_PROTOCOL IpInstance)

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.

Parameters
[in]IpInstanceThe IP4 child that requests the route table.
Return values
EFI_SUCCESSThe route table is successfully build
EFI_OUT_OF_RESOURCESFailed to allocate the memory for the route table.

Definition at line 593 of file Ip4Route.c.

◆ Ip4CreateRouteTable()

IP4_ROUTE_TABLE * Ip4CreateRouteTable ( VOID  )

Create an empty route table, includes its internal route cache

Returns
NULL if failed to allocate memory for the route table, otherwise the point to newly created route table.

Definition at line 177 of file Ip4Route.c.

◆ Ip4DelRoute()

EFI_STATUS Ip4DelRoute ( 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.

Parameters
RtTableThe route table to remove the route from
DestThe destination network
NetmaskThe netmask of the Dest
GatewayThe next hop address
Return values
EFI_SUCCESSThe route entry is successfully removed
EFI_NOT_FOUNDThere is no route entry in the table with that property.

Definition at line 352 of file Ip4Route.c.

◆ Ip4FindRouteCache()

IP4_ROUTE_CACHE_ENTRY * Ip4FindRouteCache ( IN IP4_ROUTE_TABLE RtTable,
IN IP4_ADDR  Dest,
IN IP4_ADDR  Src 
)

Find a route cache with the dst and src. This is used by ICMP redirect message 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.

Parameters
[in]RtTableThe route table to search the cache for
[in]DestThe destination address
[in]SrcThe source address
Returns
NULL if no route entry to the (Dest, Src). Otherwise the point to the correct route cache entry.

Definition at line 397 of file Ip4Route.c.

◆ Ip4FreeRouteCacheEntry()

VOID Ip4FreeRouteCacheEntry ( IN IP4_ROUTE_CACHE_ENTRY RtCacheEntry)

Free the route cache entry. It is reference counted.

Parameters
RtCacheEntryThe route cache entry to free.

Definition at line 113 of file Ip4Route.c.

◆ Ip4FreeRouteTable()

VOID Ip4FreeRouteTable ( IN IP4_ROUTE_TABLE RtTable)

Free the route table and its associated route cache. Route table is reference counted.

Parameters
[in]RtTableThe route table to free.

Definition at line 211 of file Ip4Route.c.

◆ Ip4Route()

IP4_ROUTE_CACHE_ENTRY * Ip4Route ( IN IP4_ROUTE_TABLE RtTable,
IN IP4_ADDR  Dest,
IN IP4_ADDR  Src,
IN IP4_ADDR  SubnetMask,
IN BOOLEAN  AlwaysTryDestAddr 
)

Search the route table to route the packet. Return/create a route cache if there is a route to the destination.

Parameters
[in]RtTableThe route table to search from
[in]DestThe destination address to search for
[in]SrcThe source address to search for
[in]SubnetMaskThe subnet mask of the Src address, this field is used to check if the station is using /32 subnet.
[in]AlwaysTryDestAddrAlways try to use the dest address as next hop even though we can't find a matching route entry. This field is only valid when using /32 subnet.
Returns
NULL if failed to route packet, otherwise a route cache entry that can be used to route packet.

Definition at line 484 of file Ip4Route.c.