31 Prefix1 = *((UINT32 *)((
UINTN *)(Ip1)));
32 Prefix2 = *((UINT32 *)((
UINTN *)(Ip2)));
34 return ((UINT32)(Prefix1 ^ Prefix2) % IP6_ROUTE_CACHE_HASH_SIZE);
53 IN UINT8 PrefixLength,
61 if (RtEntry ==
NULL) {
67 RtEntry->PrefixLength = PrefixLength;
69 if (Destination !=
NULL) {
70 IP6_COPY_ADDRESS (&RtEntry->Destination, Destination);
73 if (GatewayAddress !=
NULL) {
74 IP6_COPY_ADDRESS (&RtEntry->NextHop, GatewayAddress);
91 ASSERT ((RtEntry !=
NULL) && (RtEntry->RefCnt > 0));
93 if (--RtEntry->RefCnt == 0) {
128 ASSERT (Destination !=
NULL || NextHop !=
NULL);
132 for (Index = IP6_PREFIX_MAX; Index >= 0; Index--) {
133 NET_LIST_FOR_EACH (Entry, &RtTable->RouteArea[Index]) {
136 if (Destination !=
NULL) {
137 if (
NetIp6IsNetEqual (Destination, &RtEntry->Destination, RtEntry->PrefixLength)) {
138 NET_GET_REF (RtEntry);
141 }
else if (NextHop !=
NULL) {
143 NET_GET_REF (RtEntry);
178 if (RtCacheEntry ==
NULL) {
182 RtCacheEntry->RefCnt = 1;
183 RtCacheEntry->Tag = Tag;
185 IP6_COPY_ADDRESS (&RtCacheEntry->Destination, Dst);
186 IP6_COPY_ADDRESS (&RtCacheEntry->Source, Src);
187 IP6_COPY_ADDRESS (&RtCacheEntry->NextHop, GateWay);
203 ASSERT (RtCacheEntry->RefCnt > 0);
205 if (--RtCacheEntry->RefCnt == 0) {
233 Index = IP6_ROUTE_CACHE_HASH (Dest, Src);
235 NET_LIST_FOR_EACH (Entry, &RtTable->Cache.CacheBucket[Index]) {
238 if (EFI_IP6_EQUAL (Dest, &RtCacheEntry->Destination) && EFI_IP6_EQUAL (Src, &RtCacheEntry->Source)) {
239 NET_GET_REF (RtCacheEntry);
263 OUT UINT32 *EfiRouteCount,
273 ASSERT (EfiRouteCount !=
NULL);
275 Count = RouteTable->TotalNum;
276 *EfiRouteCount = Count;
278 if ((EfiRouteTable ==
NULL) || (Count == 0)) {
282 if (*EfiRouteTable ==
NULL) {
284 if (*EfiRouteTable ==
NULL) {
285 return EFI_OUT_OF_RESOURCES;
289 EfiTable = *EfiRouteTable;
296 for (Index = IP6_PREFIX_MAX; Index >= 0; Index--) {
297 NET_LIST_FOR_EACH (Entry, &(RouteTable->RouteArea[Index])) {
301 &EfiTable[Count].Destination,
302 &RtEntry->Destination,
303 RtEntry->PrefixLength
306 IP6_COPY_ADDRESS (&EfiTable[Count].Gateway, &RtEntry->NextHop);
313 ASSERT (Count == RouteTable->TotalNum);
334 if (RtTable ==
NULL) {
339 RtTable->TotalNum = 0;
341 for (Index = 0; Index <= IP6_PREFIX_MAX; Index++) {
345 for (Index = 0; Index < IP6_ROUTE_CACHE_HASH_SIZE; Index++) {
347 RtTable->Cache.CacheNum[Index] = 0;
371 ASSERT (RtTable->RefCnt > 0);
373 if (--RtTable->RefCnt > 0) {
380 for (Index = 0; Index <= IP6_PREFIX_MAX; Index++) {
381 NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtTable->RouteArea[Index]) {
388 for (Index = 0; Index < IP6_ROUTE_CACHE_HASH_SIZE; Index++) {
389 NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtTable->Cache.CacheBucket[Index]) {
420 for (Index = 0; Index < IP6_ROUTE_CACHE_HASH_SIZE; Index++) {
421 NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtCache->CacheBucket[Index]) {
424 if (RtCacheEntry->Tag == Tag) {
449 IN UINT8 PrefixLength,
457 ListHead = &RtTable->RouteArea[PrefixLength];
462 NET_LIST_FOR_EACH (Entry, ListHead) {
466 EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop))
468 return EFI_ACCESS_DENIED;
478 return EFI_OUT_OF_RESOURCES;
482 Route->Flag = IP6_DIRECT_ROUTE;
509 IN UINT8 PrefixLength,
519 ListHead = &RtTable->RouteArea[PrefixLength];
520 TotalNum = RtTable->TotalNum;
522 NET_LIST_FOR_EACH_SAFE (Entry, Next, ListHead) {
525 if ((Destination !=
NULL) && !
NetIp6IsNetEqual (Destination, &Route->Destination, PrefixLength)) {
529 if ((GatewayAddress !=
NULL) && !EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop)) {
537 ASSERT (RtTable->TotalNum > 0);
541 return TotalNum == RtTable->TotalNum ? EFI_NOT_FOUND :
EFI_SUCCESS;
570 RtTable = IpSb->RouteTable;
572 ASSERT (RtTable !=
NULL);
577 Index = IP6_ROUTE_CACHE_HASH (Dest, Src);
578 ListHead = &RtTable->Cache.CacheBucket[Index];
585 if (RtCacheEntry !=
NULL) {
595 if (RtEntry ==
NULL) {
605 if ((RtEntry->Flag & IP6_DIRECT_ROUTE) == IP6_DIRECT_ROUTE) {
606 IP6_COPY_ADDRESS (&NextHop, Dest);
608 IP6_COPY_ADDRESS (&NextHop, &RtEntry->NextHop);
618 if (RtCacheEntry ==
NULL) {
623 NET_GET_REF (RtCacheEntry);
624 RtTable->Cache.CacheNum[Index]++;
LIST_ENTRY *EFIAPI InsertHeadList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID Ip6CopyAddressByPrefix(OUT EFI_IPv6_ADDRESS *Dest, IN EFI_IPv6_ADDRESS *Src, IN UINT8 PrefixLength)
EFI_STATUS Ip6BuildEfiRouteTable(IN IP6_ROUTE_TABLE *RouteTable, OUT UINT32 *EfiRouteCount, OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL)
VOID Ip6FreeRouteCacheEntry(IN OUT IP6_ROUTE_CACHE_ENTRY *RtCacheEntry)
VOID Ip6CleanRouteTable(IN OUT IP6_ROUTE_TABLE *RtTable)
IP6_ROUTE_ENTRY * Ip6CreateRouteEntry(IN EFI_IPv6_ADDRESS *Destination OPTIONAL, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL)
IP6_ROUTE_TABLE * Ip6CreateRouteTable(VOID)
IP6_ROUTE_ENTRY * Ip6FindRouteEntry(IN IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Destination OPTIONAL, IN EFI_IPv6_ADDRESS *NextHop OPTIONAL)
EFI_STATUS Ip6AddRoute(IN OUT IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Destination, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *GatewayAddress)
IP6_ROUTE_CACHE_ENTRY * Ip6FindRouteCache(IN IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Dest, IN EFI_IPv6_ADDRESS *Src)
EFI_STATUS Ip6DelRoute(IN OUT IP6_ROUTE_TABLE *RtTable, IN EFI_IPv6_ADDRESS *Destination, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *GatewayAddress)
VOID Ip6PurgeRouteCache(IN IP6_ROUTE_CACHE *RtCache, IN UINTN Tag)
IP6_ROUTE_CACHE_ENTRY * Ip6CreateRouteCacheEntry(IN EFI_IPv6_ADDRESS *Dst, IN EFI_IPv6_ADDRESS *Src, IN EFI_IPv6_ADDRESS *GateWay, IN UINTN Tag)
UINT32 Ip6RouteCacheHash(IN EFI_IPv6_ADDRESS *Ip1, IN EFI_IPv6_ADDRESS *Ip2)
IP6_ROUTE_CACHE_ENTRY * Ip6Route(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *Dest, IN EFI_IPv6_ADDRESS *Src)
VOID Ip6FreeRouteEntry(IN OUT IP6_ROUTE_ENTRY *RtEntry)
BOOLEAN EFIAPI NetIp6IsNetEqual(EFI_IPv6_ADDRESS *Ip1, EFI_IPv6_ADDRESS *Ip2, UINT8 PrefixLength)
BOOLEAN EFIAPI NetIp6IsUnspecifiedAddr(IN EFI_IPv6_ADDRESS *Ip6)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)