TianoCore EDK2 master
Loading...
Searching...
No Matches
Ip6Route.h File Reference

Go to the source code of this file.

Data Structures

struct  IP6_ROUTE_ENTRY
 
struct  IP6_ROUTE_CACHE_ENTRY
 
struct  IP6_ROUTE_CACHE
 
struct  _IP6_ROUTE_TABLE
 

Macros

#define IP6_DIRECT_ROUTE   0x00000001
 
#define IP6_PACKET_TOO_BIG   0x00000010
 
#define IP6_ROUTE_CACHE_HASH_SIZE   31
 
#define IP6_ROUTE_CACHE_MAX   32
 
#define IP6_ROUTE_CACHE_HASH(Ip1, Ip2)   Ip6RouteCacheHash ((Ip1), (Ip2))
 

Typedefs

typedef struct _IP6_ROUTE_TABLE IP6_ROUTE_TABLE
 

Functions

UINT32 Ip6RouteCacheHash (IN EFI_IPv6_ADDRESS *Ip1, IN EFI_IPv6_ADDRESS *Ip2)
 
IP6_ROUTE_CACHE_ENTRYIp6CreateRouteCacheEntry (IN EFI_IPv6_ADDRESS *Dst, IN EFI_IPv6_ADDRESS *Src, IN EFI_IPv6_ADDRESS *GateWay, IN UINTN Tag)
 
VOID Ip6FreeRouteCacheEntry (IN OUT IP6_ROUTE_CACHE_ENTRY *RtCacheEntry)
 
IP6_ROUTE_CACHE_ENTRYIp6FindRouteCache (IN IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Dest, IN EFI_IPv6_ADDRESS *Src)
 
EFI_STATUS Ip6BuildEfiRouteTable (IN IP6_ROUTE_TABLE *RouteTable, OUT UINT32 *EfiRouteCount, OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL)
 
IP6_ROUTE_TABLEIp6CreateRouteTable (VOID)
 
VOID Ip6CleanRouteTable (IN OUT IP6_ROUTE_TABLE *RtTable)
 
IP6_ROUTE_ENTRYIp6CreateRouteEntry (IN EFI_IPv6_ADDRESS *Destination OPTIONAL, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL)
 
IP6_ROUTE_ENTRYIp6FindRouteEntry (IN IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Destination OPTIONAL, IN EFI_IPv6_ADDRESS *NextHop OPTIONAL)
 
VOID Ip6FreeRouteEntry (IN OUT IP6_ROUTE_ENTRY *RtEntry)
 
EFI_STATUS Ip6AddRoute (IN OUT IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Destination, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *GatewayAddress)
 
EFI_STATUS Ip6DelRoute (IN OUT IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Destination, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *GatewayAddress)
 
IP6_ROUTE_CACHE_ENTRYIp6Route (IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *Dest, IN EFI_IPv6_ADDRESS *Src)
 

Detailed Description

EFI IP6 route table and route cache table definitions.

Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Ip6Route.h.

Macro Definition Documentation

◆ IP6_DIRECT_ROUTE

#define IP6_DIRECT_ROUTE   0x00000001

Definition at line 13 of file Ip6Route.h.

◆ IP6_PACKET_TOO_BIG

#define IP6_PACKET_TOO_BIG   0x00000010

Definition at line 14 of file Ip6Route.h.

◆ IP6_ROUTE_CACHE_HASH

#define IP6_ROUTE_CACHE_HASH (   Ip1,
  Ip2 
)    Ip6RouteCacheHash ((Ip1), (Ip2))

Definition at line 22 of file Ip6Route.h.

◆ IP6_ROUTE_CACHE_HASH_SIZE

#define IP6_ROUTE_CACHE_HASH_SIZE   31

Definition at line 16 of file Ip6Route.h.

◆ IP6_ROUTE_CACHE_MAX

#define IP6_ROUTE_CACHE_MAX   32

Max NO. of cache entry per hash bucket

Definition at line 20 of file Ip6Route.h.

Function Documentation

◆ Ip6AddRoute()

EFI_STATUS Ip6AddRoute ( IN OUT IP6_ROUTE_TABLE RtTable,
IN EFI_IPv6_ADDRESS Destination,
IN UINT8  PrefixLength,
IN EFI_IPv6_ADDRESS GatewayAddress 
)

Add a route entry to the route table. It is the help function for EfiIp6Routes.

Parameters
[in,out]RtTableRoute table to add route to.
[in]DestinationThe destination of the network.
[in]PrefixLengthThe PrefixLength of the destination.
[in]GatewayAddressThe 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 was added successfully.

Definition at line 446 of file Ip6Route.c.

◆ Ip6BuildEfiRouteTable()

EFI_STATUS Ip6BuildEfiRouteTable ( IN IP6_ROUTE_TABLE RouteTable,
OUT UINT32 *  EfiRouteCount,
OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable  OPTIONAL 
)

Build a array of EFI_IP6_ROUTE_TABLE to be returned to the caller. The number of EFI_IP6_ROUTE_TABLE is also returned.

Parameters
[in]RouteTableThe pointer of IP6_ROUTE_TABLE internal used.
[out]EfiRouteCountThe number of returned route entries.
[out]EfiRouteTableThe pointer to the array of EFI_IP6_ROUTE_TABLE. If NULL, only the route entry count is returned.
Return values
EFI_SUCCESSThe EFI_IP6_ROUTE_TABLE successfully built.
EFI_OUT_OF_RESOURCESFailed to allocate the memory for the route table.

Build an array of EFI_IP6_ROUTE_TABLE to be returned to the caller. The number of EFI_IP6_ROUTE_TABLE is also returned.

Parameters
[in]RouteTableThe pointer of IP6_ROUTE_TABLE internal used.
[out]EfiRouteCountThe number of returned route entries.
[out]EfiRouteTableThe pointer to the array of EFI_IP6_ROUTE_TABLE. If NULL, only the route entry count is returned.
Return values
EFI_SUCCESSThe EFI_IP6_ROUTE_TABLE successfully built.
EFI_OUT_OF_RESOURCESFailed to allocate the memory for the route table.

Definition at line 261 of file Ip6Route.c.

◆ Ip6CleanRouteTable()

VOID Ip6CleanRouteTable ( IN OUT IP6_ROUTE_TABLE RtTable)

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

Parameters
[in,out]RtTableThe route table to free.

Definition at line 361 of file Ip6Route.c.

◆ Ip6CreateRouteCacheEntry()

IP6_ROUTE_CACHE_ENTRY * Ip6CreateRouteCacheEntry ( IN EFI_IPv6_ADDRESS Dst,
IN EFI_IPv6_ADDRESS Src,
IN EFI_IPv6_ADDRESS GateWay,
IN UINTN  Tag 
)

Allocate and initialize an IP6 route cache entry.

Parameters
[in]DstThe destination address.
[in]SrcThe source address.
[in]GateWayThe next hop address.
[in]TagThe tag from the caller. This marks all the cache entries spawned from one route table entry.
Returns
NULL if it failed to allocate memory for the cache. Otherwise, point to the created route cache entry.

Allocate and initialize a IP6 route cache entry.

Parameters
[in]DstThe destination address.
[in]SrcThe source address.
[in]GateWayThe next hop address.
[in]TagThe tag from the caller. This marks all the cache entries spawned from one route table entry.
Returns
NULL if failed to allocate memory for the cache. Otherwise, point to the created route cache entry.

Definition at line 167 of file Ip6Route.c.

◆ Ip6CreateRouteEntry()

IP6_ROUTE_ENTRY * Ip6CreateRouteEntry ( IN EFI_IPv6_ADDRESS *Destination  OPTIONAL,
IN UINT8  PrefixLength,
IN EFI_IPv6_ADDRESS *GatewayAddress  OPTIONAL 
)

Allocate a route entry then initialize it with the Destination/PrefixLength and Gateway.

Parameters
[in]DestinationThe IPv6 destination address. This is an optional parameter that may be NULL.
[in]PrefixLengthThe destination network's prefix length.
[in]GatewayAddressThe next hop address. This is optional parameter that may be NULL.
Returns
NULL if it failed to allocate memory. Otherwise, the newly created route entry.

Allocate a route entry then initialize it with the Destination/PrefixLength and Gateway.

Parameters
[in]DestinationThe IPv6 destination address. This is an optional parameter that may be NULL.
[in]PrefixLengthThe destination network's prefix length.
[in]GatewayAddressThe next hop address. This is an optional parameter that may be NULL.
Returns
NULL if failed to allocate memory; otherwise, the newly created route entry.

Definition at line 51 of file Ip6Route.c.

◆ Ip6CreateRouteTable()

IP6_ROUTE_TABLE * Ip6CreateRouteTable ( 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.

Create an empty route table. This 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 326 of file Ip6Route.c.

◆ Ip6DelRoute()

EFI_STATUS Ip6DelRoute ( IN OUT IP6_ROUTE_TABLE RtTable,
IN EFI_IPv6_ADDRESS Destination,
IN UINT8  PrefixLength,
IN EFI_IPv6_ADDRESS GatewayAddress 
)

Remove a route entry and all the route caches spawn from it. It is the help function for EfiIp6Routes.

Parameters
[in,out]RtTableThe route table to remove the route from.
[in]DestinationThe destination network.
[in]PrefixLengthThe PrefixLength of the Destination.
[in]GatewayAddressThe next hop address.
Return values
EFI_SUCCESSSuccessfully removed the route entry.
EFI_NOT_FOUNDThere is no route entry in the table with that property.

Remove a route entry and all the route caches spawn from it. It is the help function for EfiIp6Routes.

Parameters
[in,out]RtTableThe route table to remove the route from.
[in]DestinationThe destination network.
[in]PrefixLengthThe PrefixLength of the Destination.
[in]GatewayAddressThe next hop address.
Return values
EFI_SUCCESSThe route entry was successfully removed.
EFI_NOT_FOUNDThere is no route entry in the table with that property.

Definition at line 506 of file Ip6Route.c.

◆ Ip6FindRouteCache()

IP6_ROUTE_CACHE_ENTRY * Ip6FindRouteCache ( IN IP6_ROUTE_TABLE RtTable,
IN EFI_IPv6_ADDRESS Dest,
IN EFI_IPv6_ADDRESS Src 
)

Find a route cache with the destination and source address. This is used by the ICMPv6 redirect message process.

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, point to the correct route cache entry.

Find a route cache with the destination and source address. This is used by the ICMPv6 redirect message process.

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 pointer to the correct route cache entry.

Definition at line 223 of file Ip6Route.c.

◆ Ip6FindRouteEntry()

IP6_ROUTE_ENTRY * Ip6FindRouteEntry ( IN IP6_ROUTE_TABLE RtTable,
IN EFI_IPv6_ADDRESS *Destination  OPTIONAL,
IN EFI_IPv6_ADDRESS *NextHop  OPTIONAL 
)

Search the route table for a most specific match to the Dst. It searches from the longest route area (prefix length == 128) to the shortest route area (default routes). In each route area, it will first search the instance's route table, then the default route table. This is required per the following requirements:

  1. IP search the route table for a most specific match.
  2. The local route entries have precedence over the default route entry.
Parameters
[in]RtTableThe route table to search from.
[in]DestinationThe destination address to search. If NULL, search the route table by NextHop.
[in]NextHopThe next hop address. If NULL, search the route table by Destination.
Returns
NULL if no route matches the Dst. Otherwise the point to the most specific route to the Dst.

Search the route table for a most specific match to the Dst. It searches from the longest route area (prefix length == 128) to the shortest route area (default routes). In each route area, it will first search the instance's route table, then the default route table. This is required per the following requirements:

  1. IP search the route table for a most specific match.
  2. The local route entries have precedence over the default route entry.
Parameters
[in]RtTableThe route table to search from.
[in]DestinationThe destination address to search. If NULL, search the route table by NextHop.
[in]NextHopThe next hop address. If NULL, search the route table by Destination.
Returns
NULL if no route matches the Dst. Otherwise, the point to the
most specific route to the Dst.

Definition at line 118 of file Ip6Route.c.

◆ Ip6FreeRouteCacheEntry()

VOID Ip6FreeRouteCacheEntry ( IN OUT IP6_ROUTE_CACHE_ENTRY RtCacheEntry)

Free the route cache entry. It is reference counted.

Parameters
[in,out]RtCacheEntryThe route cache entry to free.

Definition at line 199 of file Ip6Route.c.

◆ Ip6FreeRouteEntry()

VOID Ip6FreeRouteEntry ( IN OUT IP6_ROUTE_ENTRY RtEntry)

Free the route table entry. It is reference counted.

Parameters
[in,out]RtEntryThe route entry to free.

Definition at line 87 of file Ip6Route.c.

◆ Ip6Route()

IP6_ROUTE_CACHE_ENTRY * Ip6Route ( IN IP6_SERVICE IpSb,
IN EFI_IPv6_ADDRESS Dest,
IN EFI_IPv6_ADDRESS Src 
)

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

Parameters
[in]IpSbThe IP6 service data.
[in]DestThe destination address to search for.
[in]SrcThe source address to search for.
Returns
NULL if failed to route packet. Otherwise, a route cache entry that can be used to route packet.

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

Parameters
[in]IpSbThe IP6 service data.
[in]DestThe destination address to search for.
[in]SrcThe source address to search for.
Returns
NULL if it failed to route the packet. Otherwise, a route cache entry that can be used to route packets.

Definition at line 557 of file Ip6Route.c.

◆ Ip6RouteCacheHash()

UINT32 Ip6RouteCacheHash ( IN EFI_IPv6_ADDRESS Ip1,
IN EFI_IPv6_ADDRESS Ip2 
)

This is the worker function for IP6_ROUTE_CACHE_HASH(). It calculates the value as the index of the route cache bucket according to the prefix of two IPv6 addresses.

Parameters
[in]Ip1The IPv6 address.
[in]Ip2The IPv6 address.
Returns
The hash value of the prefix of two IPv6 addresses.

Definition at line 23 of file Ip6Route.c.