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

Go to the source code of this file.

Functions

IP4_ROUTE_ENTRYIp4CreateRouteEntry (IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR GateWay)
 
VOID Ip4FreeRouteEntry (IN IP4_ROUTE_ENTRY *RtEntry)
 
IP4_ROUTE_CACHE_ENTRYIp4CreateRouteCacheEntry (IN IP4_ADDR Dst, IN IP4_ADDR Src, IN IP4_ADDR GateWay, IN UINTN Tag)
 
VOID Ip4FreeRouteCacheEntry (IN IP4_ROUTE_CACHE_ENTRY *RtCacheEntry)
 
VOID Ip4InitRouteCache (IN OUT IP4_ROUTE_CACHE *RtCache)
 
VOID Ip4CleanRouteCache (IN IP4_ROUTE_CACHE *RtCache)
 
IP4_ROUTE_TABLEIp4CreateRouteTable (VOID)
 
VOID Ip4FreeRouteTable (IN IP4_ROUTE_TABLE *RtTable)
 
VOID Ip4PurgeRouteCache (IN OUT IP4_ROUTE_CACHE *RtCache, IN UINTN Tag)
 
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)
 
IP4_ROUTE_ENTRYIp4FindRouteEntry (IN IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dst)
 
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

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

Definition in file Ip4Route.c.

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.

◆ Ip4CleanRouteCache()

VOID Ip4CleanRouteCache ( IN IP4_ROUTE_CACHE RtCache)

Clean up a route cache, that is free all the route cache entries enqueued in the cache.

Parameters
[in]RtCacheThe route cache table to clean up

Definition at line 150 of file Ip4Route.c.

◆ Ip4CreateRouteCacheEntry()

IP4_ROUTE_CACHE_ENTRY * Ip4CreateRouteCacheEntry ( IN IP4_ADDR  Dst,
IN IP4_ADDR  Src,
IN IP4_ADDR  GateWay,
IN UINTN  Tag 
)

Allocate and initialize an IP4 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, other point to the created route cache entry.

Definition at line 80 of file Ip4Route.c.

◆ Ip4CreateRouteEntry()

IP4_ROUTE_ENTRY * Ip4CreateRouteEntry ( IN IP4_ADDR  Dest,
IN IP4_ADDR  Netmask,
IN IP4_ADDR  GateWay 
)

Allocate a route entry then initialize it with the Dest/Netmask and Gateway.

Parameters
[in]DestThe destination network
[in]NetmaskThe destination network mask
[in]GateWayThe nexthop address
Returns
NULL if failed to allocate memory, otherwise the newly created route entry.

Definition at line 23 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.

◆ Ip4FindRouteEntry()

IP4_ROUTE_ENTRY * Ip4FindRouteEntry ( IN IP4_ROUTE_TABLE RtTable,
IN IP4_ADDR  Dst 
)

Search the route table for a most specific match to the Dst. It searches from the longest route area (mask length == 32) 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 by 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]DstThe destination address to search
Returns
NULL if no route matches the Dst, otherwise the point to the most specific route to the Dst.

Definition at line 438 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.

◆ Ip4FreeRouteEntry()

VOID Ip4FreeRouteEntry ( IN IP4_ROUTE_ENTRY RtEntry)

Free the route table entry. It is reference counted.

Parameters
RtEntryThe route entry to free.

Definition at line 55 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.

◆ Ip4InitRouteCache()

VOID Ip4InitRouteCache ( IN OUT IP4_ROUTE_CACHE RtCache)

Initialize an empty route cache table.

Parameters
[in,out]RtCacheThe route cache table to initialize.

Definition at line 131 of file Ip4Route.c.

◆ Ip4PurgeRouteCache()

VOID Ip4PurgeRouteCache ( IN OUT IP4_ROUTE_CACHE RtCache,
IN UINTN  Tag 
)

Remove all the cache entries bearing the Tag. When a route cache entry is created, it is tagged with the address of route entry from which it is spawned. When a route entry is deleted, the cache entries spawned from it are also deleted.

Parameters
RtCacheRoute cache to remove the entries from
TagThe Tag of the entries to remove

Definition at line 254 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.