\r
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php.\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
**/\r
UINT32\r
Ip6RouteCacheHash (\r
- IN EFI_IPv6_ADDRESS *Ip1,\r
- IN EFI_IPv6_ADDRESS *Ip2\r
+ IN EFI_IPv6_ADDRESS *Ip1,\r
+ IN EFI_IPv6_ADDRESS *Ip2\r
)\r
{\r
- UINT32 Prefix1;\r
- UINT32 Prefix2;\r
+ UINT32 Prefix1;\r
+ UINT32 Prefix2;\r
\r
- Prefix1 = *((UINT32 *) ((UINTN *) (Ip1)));\r
- Prefix2 = *((UINT32 *) ((UINTN *) (Ip2)));\r
+ Prefix1 = *((UINT32 *)((UINTN *)(Ip1)));\r
+ Prefix2 = *((UINT32 *)((UINTN *)(Ip2)));\r
\r
- return ((UINT32) (Prefix1 ^ Prefix2) % IP6_ROUTE_CACHE_HASH_SIZE);\r
+ return ((UINT32)(Prefix1 ^ Prefix2) % IP6_ROUTE_CACHE_HASH_SIZE);\r
}\r
\r
/**\r
@param[in] GatewayAddress The next hop address. This is an optional parameter\r
that may be NULL.\r
\r
- @return NULL if failed to allocate memeory; otherwise, the newly created route entry.\r
+ @return NULL if failed to allocate memory; otherwise, the newly created route entry.\r
\r
**/\r
IP6_ROUTE_ENTRY *\r
Ip6CreateRouteEntry (\r
- IN EFI_IPv6_ADDRESS *Destination OPTIONAL,\r
- IN UINT8 PrefixLength,\r
- IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL\r
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,\r
+ IN UINT8 PrefixLength,\r
+ IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL\r
)\r
{\r
- IP6_ROUTE_ENTRY *RtEntry;\r
+ IP6_ROUTE_ENTRY *RtEntry;\r
\r
RtEntry = AllocateZeroPool (sizeof (IP6_ROUTE_ENTRY));\r
\r
**/\r
VOID\r
Ip6FreeRouteEntry (\r
- IN OUT IP6_ROUTE_ENTRY *RtEntry\r
+ IN OUT IP6_ROUTE_ENTRY *RtEntry\r
)\r
{\r
ASSERT ((RtEntry != NULL) && (RtEntry->RefCnt > 0));\r
2. The local route entries have precedence over the default route entry.\r
\r
@param[in] RtTable The route table to search from.\r
- @param[in] Destination The destionation address to search. If NULL, search\r
+ @param[in] Destination The destination address to search. If NULL, search\r
the route table by NextHop.\r
@param[in] NextHop The next hop address. If NULL, search the route table\r
by Destination.\r
**/\r
IP6_ROUTE_ENTRY *\r
Ip6FindRouteEntry (\r
- IN IP6_ROUTE_TABLE *RtTable,\r
- IN EFI_IPv6_ADDRESS *Destination OPTIONAL,\r
- IN EFI_IPv6_ADDRESS *NextHop OPTIONAL\r
+ IN IP6_ROUTE_TABLE *RtTable,\r
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,\r
+ IN EFI_IPv6_ADDRESS *NextHop OPTIONAL\r
)\r
{\r
- LIST_ENTRY *Entry;\r
- IP6_ROUTE_ENTRY *RtEntry;\r
- INTN Index;\r
+ LIST_ENTRY *Entry;\r
+ IP6_ROUTE_ENTRY *RtEntry;\r
+ INTN Index;\r
\r
ASSERT (Destination != NULL || NextHop != NULL);\r
\r
return RtEntry;\r
}\r
}\r
-\r
}\r
}\r
\r
**/\r
IP6_ROUTE_CACHE_ENTRY *\r
Ip6CreateRouteCacheEntry (\r
- IN EFI_IPv6_ADDRESS *Dst,\r
- IN EFI_IPv6_ADDRESS *Src,\r
- IN EFI_IPv6_ADDRESS *GateWay,\r
- IN UINTN Tag\r
+ IN EFI_IPv6_ADDRESS *Dst,\r
+ IN EFI_IPv6_ADDRESS *Src,\r
+ IN EFI_IPv6_ADDRESS *GateWay,\r
+ IN UINTN Tag\r
)\r
{\r
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
\r
RtCacheEntry = AllocatePool (sizeof (IP6_ROUTE_CACHE_ENTRY));\r
\r
\r
/**\r
Find a route cache with the destination and source address. This is\r
- used by the ICMPv6 redirect messasge process.\r
+ used by the ICMPv6 redirect message process.\r
\r
@param[in] RtTable The route table to search the cache for.\r
@param[in] Dest The destination address.\r
**/\r
IP6_ROUTE_CACHE_ENTRY *\r
Ip6FindRouteCache (\r
- IN IP6_ROUTE_TABLE *RtTable,\r
- IN EFI_IPv6_ADDRESS *Dest,\r
- IN EFI_IPv6_ADDRESS *Src\r
+ IN IP6_ROUTE_TABLE *RtTable,\r
+ IN EFI_IPv6_ADDRESS *Dest,\r
+ IN EFI_IPv6_ADDRESS *Src\r
)\r
{\r
- LIST_ENTRY *Entry;\r
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
- UINT32 Index;\r
+ LIST_ENTRY *Entry;\r
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
+ UINT32 Index;\r
\r
Index = IP6_ROUTE_CACHE_HASH (Dest, Src);\r
\r
NET_LIST_FOR_EACH (Entry, &RtTable->Cache.CacheBucket[Index]) {\r
RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_CACHE_ENTRY, Link);\r
\r
- if (EFI_IP6_EQUAL (Dest, &RtCacheEntry->Destination)&& EFI_IP6_EQUAL (Src, &RtCacheEntry->Source)) {\r
+ if (EFI_IP6_EQUAL (Dest, &RtCacheEntry->Destination) && EFI_IP6_EQUAL (Src, &RtCacheEntry->Source)) {\r
NET_GET_REF (RtCacheEntry);\r
return RtCacheEntry;\r
}\r
**/\r
EFI_STATUS\r
Ip6BuildEfiRouteTable (\r
- IN IP6_ROUTE_TABLE *RouteTable,\r
- OUT UINT32 *EfiRouteCount,\r
- OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL\r
+ IN IP6_ROUTE_TABLE *RouteTable,\r
+ OUT UINT32 *EfiRouteCount,\r
+ OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL\r
)\r
{\r
- LIST_ENTRY *Entry;\r
- IP6_ROUTE_ENTRY *RtEntry;\r
- EFI_IP6_ROUTE_TABLE *EfiTable;\r
- UINT32 Count;\r
- INT32 Index;\r
+ LIST_ENTRY *Entry;\r
+ IP6_ROUTE_ENTRY *RtEntry;\r
+ EFI_IP6_ROUTE_TABLE *EfiTable;\r
+ UINT32 Count;\r
+ INT32 Index;\r
\r
ASSERT (EfiRouteCount != NULL);\r
\r
Count = 0;\r
\r
for (Index = IP6_PREFIX_MAX; Index >= 0; Index--) {\r
-\r
NET_LIST_FOR_EACH (Entry, &(RouteTable->RouteArea[Index])) {\r
RtEntry = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link);\r
\r
VOID\r
)\r
{\r
- IP6_ROUTE_TABLE *RtTable;\r
- UINT32 Index;\r
+ IP6_ROUTE_TABLE *RtTable;\r
+ UINT32 Index;\r
\r
RtTable = AllocatePool (sizeof (IP6_ROUTE_TABLE));\r
if (RtTable == NULL) {\r
**/\r
VOID\r
Ip6CleanRouteTable (\r
- IN OUT IP6_ROUTE_TABLE *RtTable\r
+ IN OUT IP6_ROUTE_TABLE *RtTable\r
)\r
{\r
- LIST_ENTRY *Entry;\r
- LIST_ENTRY *Next;\r
- IP6_ROUTE_ENTRY *RtEntry;\r
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
- UINT32 Index;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+ IP6_ROUTE_ENTRY *RtEntry;\r
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
+ UINT32 Index;\r
\r
ASSERT (RtTable->RefCnt > 0);\r
\r
if (--RtTable->RefCnt > 0) {\r
- return ;\r
+ return;\r
}\r
\r
//\r
**/\r
VOID\r
Ip6PurgeRouteCache (\r
- IN IP6_ROUTE_CACHE *RtCache,\r
- IN UINTN Tag\r
+ IN IP6_ROUTE_CACHE *RtCache,\r
+ IN UINTN Tag\r
)\r
{\r
- LIST_ENTRY *Entry;\r
- LIST_ENTRY *Next;\r
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
- UINT32 Index;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
+ UINT32 Index;\r
\r
for (Index = 0; Index < IP6_ROUTE_CACHE_HASH_SIZE; Index++) {\r
NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtCache->CacheBucket[Index]) {\r
-\r
RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_CACHE_ENTRY, Link);\r
\r
if (RtCacheEntry->Tag == Tag) {\r
**/\r
EFI_STATUS\r
Ip6AddRoute (\r
- IN OUT IP6_ROUTE_TABLE *RtTable,\r
- IN EFI_IPv6_ADDRESS *Destination,\r
- IN UINT8 PrefixLength,\r
- IN EFI_IPv6_ADDRESS *GatewayAddress\r
+ IN OUT IP6_ROUTE_TABLE *RtTable,\r
+ IN EFI_IPv6_ADDRESS *Destination,\r
+ IN UINT8 PrefixLength,\r
+ IN EFI_IPv6_ADDRESS *GatewayAddress\r
)\r
{\r
- LIST_ENTRY *ListHead;\r
- LIST_ENTRY *Entry;\r
- IP6_ROUTE_ENTRY *Route;\r
+ LIST_ENTRY *ListHead;\r
+ LIST_ENTRY *Entry;\r
+ IP6_ROUTE_ENTRY *Route;\r
\r
ListHead = &RtTable->RouteArea[PrefixLength];\r
\r
Route = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link);\r
\r
if (NetIp6IsNetEqual (Destination, &Route->Destination, PrefixLength) &&\r
- EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop)) {\r
+ EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop))\r
+ {\r
return EFI_ACCESS_DENIED;\r
}\r
}\r
**/\r
EFI_STATUS\r
Ip6DelRoute (\r
- IN OUT IP6_ROUTE_TABLE *RtTable,\r
- IN EFI_IPv6_ADDRESS *Destination,\r
- IN UINT8 PrefixLength,\r
- IN EFI_IPv6_ADDRESS *GatewayAddress\r
+ IN OUT IP6_ROUTE_TABLE *RtTable,\r
+ IN EFI_IPv6_ADDRESS *Destination,\r
+ IN UINT8 PrefixLength,\r
+ IN EFI_IPv6_ADDRESS *GatewayAddress\r
)\r
{\r
- LIST_ENTRY *ListHead;\r
- LIST_ENTRY *Entry;\r
- LIST_ENTRY *Next;\r
- IP6_ROUTE_ENTRY *Route;\r
- UINT32 TotalNum;\r
+ LIST_ENTRY *ListHead;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+ IP6_ROUTE_ENTRY *Route;\r
+ UINT32 TotalNum;\r
\r
ListHead = &RtTable->RouteArea[PrefixLength];\r
TotalNum = RtTable->TotalNum;\r
NET_LIST_FOR_EACH_SAFE (Entry, Next, ListHead) {\r
Route = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link);\r
\r
- if (Destination != NULL && !NetIp6IsNetEqual (Destination, &Route->Destination, PrefixLength)) {\r
+ if ((Destination != NULL) && !NetIp6IsNetEqual (Destination, &Route->Destination, PrefixLength)) {\r
continue;\r
}\r
- if (GatewayAddress != NULL && !EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop)) {\r
+\r
+ if ((GatewayAddress != NULL) && !EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop)) {\r
continue;\r
}\r
\r
- Ip6PurgeRouteCache (&RtTable->Cache, (UINTN) Route);\r
+ Ip6PurgeRouteCache (&RtTable->Cache, (UINTN)Route);\r
RemoveEntryList (Entry);\r
Ip6FreeRouteEntry (Route);\r
\r
**/\r
IP6_ROUTE_CACHE_ENTRY *\r
Ip6Route (\r
- IN IP6_SERVICE *IpSb,\r
- IN EFI_IPv6_ADDRESS *Dest,\r
- IN EFI_IPv6_ADDRESS *Src\r
+ IN IP6_SERVICE *IpSb,\r
+ IN EFI_IPv6_ADDRESS *Dest,\r
+ IN EFI_IPv6_ADDRESS *Src\r
)\r
{\r
- IP6_ROUTE_TABLE *RtTable;\r
- LIST_ENTRY *ListHead;\r
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
- IP6_ROUTE_ENTRY *RtEntry;\r
- EFI_IPv6_ADDRESS NextHop;\r
- UINT32 Index;\r
+ IP6_ROUTE_TABLE *RtTable;\r
+ LIST_ENTRY *ListHead;\r
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;\r
+ IP6_ROUTE_ENTRY *RtEntry;\r
+ EFI_IPv6_ADDRESS NextHop;\r
+ UINT32 Index;\r
\r
RtTable = IpSb->RouteTable;\r
\r
//\r
// Create a route cache entry, and tag it as spawned from this route entry\r
//\r
- RtCacheEntry = Ip6CreateRouteCacheEntry (Dest, Src, &NextHop, (UINTN) RtEntry);\r
+ RtCacheEntry = Ip6CreateRouteCacheEntry (Dest, Src, &NextHop, (UINTN)RtEntry);\r
\r
if (RtCacheEntry == NULL) {\r
return NULL;\r
\r
return RtCacheEntry;\r
}\r
-\r