Ip6Route.h revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
0N/A/** @file
1879N/A EFI IP6 route table and route cache table defintions.
0N/A
0N/A Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
0N/A
0N/A This program and the accompanying materials
0N/A are licensed and made available under the terms and conditions of the BSD License
0N/A which accompanies this distribution. The full text of the license may be found at
0N/A http://opensource.org/licenses/bsd-license.php.
0N/A
0N/A THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
0N/A WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
0N/A
0N/A**/
0N/A
0N/A#ifndef __EFI_IP6_ROUTE_H__
0N/A#define __EFI_IP6_ROUTE_H__
0N/A
1472N/A#define IP6_DIRECT_ROUTE 0x00000001
1472N/A#define IP6_PACKET_TOO_BIG 0x00000010
1472N/A
0N/A#define IP6_ROUTE_CACHE_HASH_SIZE 31
0N/A///
0N/A/// Max NO. of cache entry per hash bucket
1879N/A///
1879N/A#define IP6_ROUTE_CACHE_MAX 32
1879N/A
0N/A#define IP6_ROUTE_CACHE_HASH(Ip1, Ip2) Ip6RouteCacheHash ((Ip1), (Ip2))
0N/A
0N/Atypedef struct {
0N/A LIST_ENTRY Link;
1523N/A INTN RefCnt;
0N/A UINT32 Flag;
0N/A UINT8 PrefixLength;
0N/A EFI_IPv6_ADDRESS Destination;
0N/A EFI_IPv6_ADDRESS NextHop;
0N/A} IP6_ROUTE_ENTRY;
0N/A
0N/Atypedef struct {
0N/A LIST_ENTRY Link;
0N/A INTN RefCnt;
0N/A UINTN Tag;
0N/A EFI_IPv6_ADDRESS Destination;
0N/A EFI_IPv6_ADDRESS Source;
0N/A EFI_IPv6_ADDRESS NextHop;
0N/A} IP6_ROUTE_CACHE_ENTRY;
0N/A
0N/Atypedef struct {
0N/A LIST_ENTRY CacheBucket[IP6_ROUTE_CACHE_HASH_SIZE];
0N/A UINT8 CacheNum[IP6_ROUTE_CACHE_HASH_SIZE];
0N/A} IP6_ROUTE_CACHE;
0N/A
0N/A//
0N/A// Each IP6 instance has its own route table. Each ServiceBinding
0N/A// instance has a default route table and default address.
0N/A//
0N/A// All the route table entries with the same prefix length are linked
0N/A// together in one route area. For example, RouteArea[0] contains
0N/A// the default routes. A route table also contains a route cache.
0N/A//
0N/A
0N/Atypedef struct _IP6_ROUTE_TABLE {
0N/A INTN RefCnt;
0N/A UINT32 TotalNum;
0N/A LIST_ENTRY RouteArea[IP6_PREFIX_NUM];
0N/A IP6_ROUTE_CACHE Cache;
0N/A} IP6_ROUTE_TABLE;
0N/A
0N/A/**
0N/A This is the worker function for IP6_ROUTE_CACHE_HASH(). It calculates the value
0N/A as the index of the route cache bucket according to the prefix of two IPv6 addresses.
0N/A
0N/A @param[in] Ip1 The IPv6 address.
0N/A @param[in] Ip2 The IPv6 address.
0N/A
0N/A @return The hash value of the prefix of two IPv6 addresses.
0N/A
0N/A**/
0N/AUINT32
0N/AIp6RouteCacheHash (
0N/A IN EFI_IPv6_ADDRESS *Ip1,
0N/A IN EFI_IPv6_ADDRESS *Ip2
0N/A );
0N/A
0N/A/**
0N/A Allocate and initialize an IP6 route cache entry.
0N/A
0N/A @param[in] Dst The destination address.
0N/A @param[in] Src The source address.
1523N/A @param[in] GateWay The next hop address.
0N/A @param[in] Tag The tag from the caller. This marks all the cache entries
0N/A spawned from one route table entry.
0N/A
0N/A @return NULL if it failed to allocate memory for the cache. Otherwise, point
0N/A to the created route cache entry.
0N/A
0N/A**/
0N/AIP6_ROUTE_CACHE_ENTRY *
0N/AIp6CreateRouteCacheEntry (
0N/A IN EFI_IPv6_ADDRESS *Dst,
0N/A IN EFI_IPv6_ADDRESS *Src,
0N/A IN EFI_IPv6_ADDRESS *GateWay,
0N/A IN UINTN Tag
0N/A );
0N/A
0N/A/**
0N/A Free the route cache entry. It is reference counted.
0N/A
0N/A @param[in, out] RtCacheEntry The route cache entry to free.
0N/A
0N/A**/
0N/AVOID
0N/AIp6FreeRouteCacheEntry (
0N/A IN OUT IP6_ROUTE_CACHE_ENTRY *RtCacheEntry
0N/A );
0N/A
0N/A/**
0N/A Find a route cache with the destination and source address. This is
0N/A used by the ICMPv6 redirect messasge process.
0N/A
0N/A @param[in] RtTable The route table to search the cache for.
0N/A @param[in] Dest The destination address.
0N/A @param[in] Src The source address.
0N/A
0N/A @return NULL if no route entry to the (Dest, Src). Otherwise, point
0N/A to the correct route cache entry.
0N/A
0N/A**/
0N/AIP6_ROUTE_CACHE_ENTRY *
0N/AIp6FindRouteCache (
0N/A IN IP6_ROUTE_TABLE *RtTable,
0N/A IN EFI_IPv6_ADDRESS *Dest,
0N/A IN EFI_IPv6_ADDRESS *Src
0N/A );
0N/A
1523N/A/**
0N/A Build a array of EFI_IP6_ROUTE_TABLE to be returned to the caller. The number
0N/A of EFI_IP6_ROUTE_TABLE is also returned.
0N/A
0N/A @param[in] RouteTable The pointer of IP6_ROUTE_TABLE internal used.
0N/A @param[out] EfiRouteCount The number of returned route entries.
0N/A @param[out] EfiRouteTable The pointer to the array of EFI_IP6_ROUTE_TABLE.
0N/A If NULL, only the route entry count is returned.
0N/A
0N/A @retval EFI_SUCCESS The EFI_IP6_ROUTE_TABLE successfully built.
0N/A @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the route table.
1523N/A
0N/A**/
0N/AEFI_STATUS
0N/AIp6BuildEfiRouteTable (
0N/A IN IP6_ROUTE_TABLE *RouteTable,
0N/A OUT UINT32 *EfiRouteCount,
0N/A OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL
0N/A );
0N/A
0N/A/**
0N/A Create an empty route table, includes its internal route cache.
0N/A
0N/A @return NULL if failed to allocate memory for the route table. Otherwise,
0N/A the point to newly created route table.
0N/A
0N/A**/
0N/AIP6_ROUTE_TABLE *
0N/AIp6CreateRouteTable (
0N/A VOID
0N/A );
0N/A
0N/A/**
0N/A Free the route table and its associated route cache. Route
0N/A table is reference counted.
0N/A
0N/A @param[in, out] RtTable The route table to free.
0N/A
0N/A**/
0N/AVOID
0N/AIp6CleanRouteTable (
0N/A IN OUT IP6_ROUTE_TABLE *RtTable
0N/A );
0N/A
0N/A/**
0N/A Allocate a route entry then initialize it with the Destination/PrefixLength
0N/A and Gateway.
0N/A
0N/A @param[in] Destination The IPv6 destination address. This is an optional
0N/A parameter that may be NULL.
0N/A @param[in] PrefixLength The destination network's prefix length.
0N/A @param[in] GatewayAddress The next hop address. This is optional parameter
0N/A that may be NULL.
0N/A
0N/A @return NULL if it failed to allocate memeory. Otherwise, the newly created route entry.
0N/A
0N/A**/
0N/AIP6_ROUTE_ENTRY *
0N/AIp6CreateRouteEntry (
0N/A IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
0N/A IN UINT8 PrefixLength,
0N/A IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
0N/A );
0N/A
0N/A/**
0N/A Search the route table for a most specific match to the Dst. It searches
0N/A from the longest route area (prefix length == 128) to the shortest route area
0N/A (default routes). In each route area, it will first search the instance's
0N/A route table, then the default route table. This is required per the following
0N/A requirements:
0N/A 1. IP search the route table for a most specific match.
0N/A 2. The local route entries have precedence over the default route entry.
0N/A
0N/A @param[in] RtTable The route table to search from.
0N/A @param[in] Destination The destionation address to search. If NULL, search
0N/A the route table by NextHop.
0N/A @param[in] NextHop The next hop address. If NULL, search the route table
0N/A by Destination.
0N/A
0N/A @return NULL if no route matches the Dst. Otherwise the point to the
0N/A most specific route to the Dst.
0N/A
0N/A**/
0N/AIP6_ROUTE_ENTRY *
0N/AIp6FindRouteEntry (
0N/A IN IP6_ROUTE_TABLE *RtTable,
0N/A IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
0N/A IN EFI_IPv6_ADDRESS *NextHop OPTIONAL
0N/A );
0N/A
0N/A/**
0N/A Free the route table entry. It is reference counted.
0N/A
0N/A @param[in, out] RtEntry The route entry to free.
0N/A
0N/A**/
0N/AVOID
0N/AIp6FreeRouteEntry (
0N/A IN OUT IP6_ROUTE_ENTRY *RtEntry
0N/A );
0N/A
0N/A/**
0N/A Add a route entry to the route table. It is the help function for EfiIp6Routes.
0N/A
0N/A @param[in, out] RtTable Route table to add route to.
0N/A @param[in] Destination The destination of the network.
0N/A @param[in] PrefixLength The PrefixLength of the destination.
0N/A @param[in] GatewayAddress The next hop address.
0N/A
0N/A @retval EFI_ACCESS_DENIED The same route already exists.
0N/A @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the entry.
0N/A @retval EFI_SUCCESS The route was added successfully.
0N/A
0N/A**/
0N/AEFI_STATUS
0N/AIp6AddRoute (
0N/A IN OUT IP6_ROUTE_TABLE *RtTable,
0N/A IN EFI_IPv6_ADDRESS *Destination,
0N/A IN UINT8 PrefixLength,
0N/A IN EFI_IPv6_ADDRESS *GatewayAddress
0N/A );
0N/A
0N/A/**
0N/A Remove a route entry and all the route caches spawn from it.
0N/A It is the help function for EfiIp6Routes.
0N/A
0N/A @param[in, out] RtTable The route table to remove the route from.
0N/A @param[in] Destination The destination network.
0N/A @param[in] PrefixLength The PrefixLength of the Destination.
0N/A @param[in] GatewayAddress The next hop address.
0N/A
0N/A @retval EFI_SUCCESS Successfully removed the route entry.
0N/A @retval EFI_NOT_FOUND There is no route entry in the table with that
0N/A properity.
0N/A
0N/A**/
0N/AEFI_STATUS
0N/AIp6DelRoute (
0N/A IN OUT IP6_ROUTE_TABLE *RtTable,
0N/A IN EFI_IPv6_ADDRESS *Destination,
0N/A IN UINT8 PrefixLength,
0N/A IN EFI_IPv6_ADDRESS *GatewayAddress
0N/A );
0N/A
0N/A/**
0N/A Search the route table to route the packet. Return/create a route
0N/A cache if there is a route to the destination.
0N/A
0N/A @param[in] IpSb The IP6 service data.
0N/A @param[in] Dest The destination address to search for.
0N/A @param[in] Src The source address to search for.
0N/A
0N/A @return NULL if failed to route packet. Otherwise, a route cache
0N/A entry that can be used to route packet.
0N/A
0N/A**/
0N/AIP6_ROUTE_CACHE_ENTRY *
0N/AIp6Route (
0N/A IN IP6_SERVICE *IpSb,
0N/A IN EFI_IPv6_ADDRESS *Dest,
0N/A IN EFI_IPv6_ADDRESS *Src
0N/A );
0N/A
0N/A#endif
0N/A