X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Route.c;h=5bec33e5987a7658258b3a767d9c066b186d26e3;hp=54d934250f5a66177f5d538c3b27983c7f41875e;hb=96e1079fa412753e42edf293ce28adda88e68a45;hpb=687a2e5f6902fa26c7a1d7a7705e0747c4095125 diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c index 54d934250f..5bec33e598 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c @@ -31,10 +31,9 @@ Abstract: @param GateWay The nexthop address @return NULL if failed to allocate memeory, otherwise the newly created - @return route entry. + route entry. **/ -STATIC IP4_ROUTE_ENTRY * Ip4CreateRouteEntry ( IN IP4_ADDR Dest, @@ -44,13 +43,13 @@ Ip4CreateRouteEntry ( { IP4_ROUTE_ENTRY *RtEntry; - RtEntry = NetAllocatePool (sizeof (IP4_ROUTE_ENTRY)); + RtEntry = AllocatePool (sizeof (IP4_ROUTE_ENTRY)); if (RtEntry == NULL) { return NULL; } - NetListInit (&RtEntry->Link); + InitializeListHead (&RtEntry->Link); RtEntry->RefCnt = 1; RtEntry->Dest = Dest; @@ -70,7 +69,6 @@ Ip4CreateRouteEntry ( @return NONE **/ -STATIC VOID Ip4FreeRouteEntry ( IN IP4_ROUTE_ENTRY *RtEntry @@ -79,13 +77,13 @@ Ip4FreeRouteEntry ( ASSERT (RtEntry->RefCnt > 0); if (--RtEntry->RefCnt == 0) { - NetFreePool (RtEntry); + gBS->FreePool (RtEntry); } } /** - Allocate and initialize a IP4 route cache entry. + Allocate and initialize an IP4 route cache entry. @param Dst The destination address @param Src The source address @@ -94,10 +92,9 @@ Ip4FreeRouteEntry ( entries spawned from one route table entry. @return NULL if failed to allocate memory for the cache, other point - @return to the created route cache entry. + to the created route cache entry. **/ -STATIC IP4_ROUTE_CACHE_ENTRY * Ip4CreateRouteCacheEntry ( IN IP4_ADDR Dst, @@ -108,13 +105,13 @@ Ip4CreateRouteCacheEntry ( { IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; - RtCacheEntry = NetAllocatePool (sizeof (IP4_ROUTE_CACHE_ENTRY)); + RtCacheEntry = AllocatePool (sizeof (IP4_ROUTE_CACHE_ENTRY)); if (RtCacheEntry == NULL) { return NULL; } - NetListInit (&RtCacheEntry->Link); + InitializeListHead (&RtCacheEntry->Link); RtCacheEntry->RefCnt = 1; RtCacheEntry->Dest = Dst; @@ -142,7 +139,7 @@ Ip4FreeRouteCacheEntry ( ASSERT (RtCacheEntry->RefCnt > 0); if (--RtCacheEntry->RefCnt == 0) { - NetFreePool (RtCacheEntry); + gBS->FreePool (RtCacheEntry); } } @@ -157,13 +154,13 @@ Ip4FreeRouteCacheEntry ( **/ VOID Ip4InitRouteCache ( - IN IP4_ROUTE_CACHE *RtCache + IN OUT IP4_ROUTE_CACHE *RtCache ) { UINT32 Index; for (Index = 0; Index < IP4_ROUTE_CACHE_HASH; Index++) { - NetListInit (&(RtCache->CacheBucket[Index])); + InitializeListHead (&(RtCache->CacheBucket[Index])); } } @@ -182,8 +179,8 @@ Ip4CleanRouteCache ( IN IP4_ROUTE_CACHE *RtCache ) { - NET_LIST_ENTRY *Entry; - NET_LIST_ENTRY *Next; + LIST_ENTRY *Entry; + LIST_ENTRY *Next; IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; UINT32 Index; @@ -191,7 +188,7 @@ Ip4CleanRouteCache ( NET_LIST_FOR_EACH_SAFE (Entry, Next, &(RtCache->CacheBucket[Index])) { RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link); - NetListRemoveEntry (Entry); + RemoveEntryList (Entry); Ip4FreeRouteCacheEntry (RtCacheEntry); } } @@ -202,10 +199,8 @@ Ip4CleanRouteCache ( /** Create an empty route table, includes its internal route cache - None - @return NULL if failed to allocate memory for the route table, otherwise - @return the point to newly created route table. + the point to newly created route table. **/ IP4_ROUTE_TABLE * @@ -216,7 +211,7 @@ Ip4CreateRouteTable ( IP4_ROUTE_TABLE *RtTable; UINT32 Index; - RtTable = NetAllocatePool (sizeof (IP4_ROUTE_TABLE)); + RtTable = AllocatePool (sizeof (IP4_ROUTE_TABLE)); if (RtTable == NULL) { return NULL; @@ -226,7 +221,7 @@ Ip4CreateRouteTable ( RtTable->TotalNum = 0; for (Index = 0; Index < IP4_MASK_NUM; Index++) { - NetListInit (&(RtTable->RouteArea[Index])); + InitializeListHead (&(RtTable->RouteArea[Index])); } RtTable->Next = NULL; @@ -250,8 +245,8 @@ Ip4FreeRouteTable ( IN IP4_ROUTE_TABLE *RtTable ) { - NET_LIST_ENTRY *Entry; - NET_LIST_ENTRY *Next; + LIST_ENTRY *Entry; + LIST_ENTRY *Next; IP4_ROUTE_ENTRY *RtEntry; UINT32 Index; @@ -268,14 +263,14 @@ Ip4FreeRouteTable ( NET_LIST_FOR_EACH_SAFE (Entry, Next, &(RtTable->RouteArea[Index])) { RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link); - NetListRemoveEntry (Entry); + RemoveEntryList (Entry); Ip4FreeRouteEntry (RtEntry); } } Ip4CleanRouteCache (&RtTable->Cache); - NetFreePool (RtTable); + gBS->FreePool (RtTable); } @@ -292,15 +287,14 @@ Ip4FreeRouteTable ( @return None **/ -STATIC VOID Ip4PurgeRouteCache ( - IN IP4_ROUTE_CACHE *RtCache, - IN UINTN Tag + IN OUT IP4_ROUTE_CACHE *RtCache, + IN UINTN Tag ) { - NET_LIST_ENTRY *Entry; - NET_LIST_ENTRY *Next; + LIST_ENTRY *Entry; + LIST_ENTRY *Next; IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; UINT32 Index; @@ -310,7 +304,7 @@ Ip4PurgeRouteCache ( RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link); if (RtCacheEntry->Tag == Tag) { - NetListRemoveEntry (Entry); + RemoveEntryList (Entry); Ip4FreeRouteCacheEntry (RtCacheEntry); } } @@ -334,14 +328,14 @@ Ip4PurgeRouteCache ( **/ EFI_STATUS Ip4AddRoute ( - IN IP4_ROUTE_TABLE *RtTable, - IN IP4_ADDR Dest, - IN IP4_ADDR Netmask, - IN IP4_ADDR Gateway + IN OUT IP4_ROUTE_TABLE *RtTable, + IN IP4_ADDR Dest, + IN IP4_ADDR Netmask, + IN IP4_ADDR Gateway ) { - NET_LIST_ENTRY *Head; - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Head; + LIST_ENTRY *Entry; IP4_ROUTE_ENTRY *RtEntry; // @@ -374,7 +368,7 @@ Ip4AddRoute ( RtEntry->Flag = IP4_DIRECT_ROUTE; } - NetListInsertHead (Head, &RtEntry->Link); + InsertHeadList (Head, &RtEntry->Link); RtTable->TotalNum++; return EFI_SUCCESS; @@ -396,15 +390,15 @@ Ip4AddRoute ( **/ EFI_STATUS Ip4DelRoute ( - IN IP4_ROUTE_TABLE *RtTable, - IN IP4_ADDR Dest, - IN IP4_ADDR Netmask, - IN IP4_ADDR Gateway + IN OUT IP4_ROUTE_TABLE *RtTable, + IN IP4_ADDR Dest, + IN IP4_ADDR Netmask, + IN IP4_ADDR Gateway ) { - NET_LIST_ENTRY *Head; - NET_LIST_ENTRY *Entry; - NET_LIST_ENTRY *Next; + LIST_ENTRY *Head; + LIST_ENTRY *Entry; + LIST_ENTRY *Next; IP4_ROUTE_ENTRY *RtEntry; Head = &(RtTable->RouteArea[NetGetMaskLength (Netmask)]); @@ -414,7 +408,7 @@ Ip4DelRoute ( if (IP4_NET_EQUAL (RtEntry->Dest, Dest, Netmask) && (RtEntry->NextHop == Gateway)) { Ip4PurgeRouteCache (&RtTable->Cache, (UINTN) RtEntry); - NetListRemoveEntry (Entry); + RemoveEntryList (Entry); Ip4FreeRouteEntry (RtEntry); RtTable->TotalNum--; @@ -437,7 +431,7 @@ Ip4DelRoute ( @param Src The source address @return NULL if no route entry to the (Dest, Src). Otherwise the point - @return to the correct route cache entry. + to the correct route cache entry. **/ IP4_ROUTE_CACHE_ENTRY * @@ -447,7 +441,7 @@ Ip4FindRouteCache ( IN IP4_ADDR Src ) { - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; UINT32 Index; @@ -468,8 +462,8 @@ Ip4FindRouteCache ( /** 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 + 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 @@ -482,14 +476,13 @@ Ip4FindRouteCache ( @return most specific route to the Dst. **/ -STATIC IP4_ROUTE_ENTRY * Ip4FindRouteEntry ( IN IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dst ) { - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; IP4_ROUTE_ENTRY *RtEntry; IP4_ROUTE_TABLE *Table; INTN Index; @@ -515,7 +508,7 @@ Ip4FindRouteEntry ( /** - Search the route table to route the packet. Return/creat a route + Search the route table to route the packet. Return/create a route cache if there is a route to the destination. @param RtTable The route table to search from @@ -523,7 +516,7 @@ Ip4FindRouteEntry ( @param Src The source address to search for @return NULL if failed to route packet, otherwise a route cache - @return entry that can be used to route packet. + entry that can be used to route packet. **/ IP4_ROUTE_CACHE_ENTRY * @@ -533,9 +526,9 @@ Ip4Route ( IN IP4_ADDR Src ) { - NET_LIST_ENTRY *Head; - NET_LIST_ENTRY *Entry; - NET_LIST_ENTRY *Next; + LIST_ENTRY *Head; + LIST_ENTRY *Entry; + LIST_ENTRY *Next; IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; IP4_ROUTE_CACHE_ENTRY *Cache; IP4_ROUTE_ENTRY *RtEntry; @@ -551,8 +544,8 @@ Ip4Route ( // If found, promote the cache entry to the head of the hash bucket. LRU // if (RtCacheEntry != NULL) { - NetListRemoveEntry (&RtCacheEntry->Link); - NetListInsertHead (Head, &RtCacheEntry->Link); + RemoveEntryList (&RtCacheEntry->Link); + InsertHeadList (Head, &RtCacheEntry->Link); return RtCacheEntry; } @@ -567,11 +560,11 @@ Ip4Route ( // // Found a route to the Dest, if it is a direct route, the packet - // will be send directly to the destination, such as for connected + // will be sent directly to the destination, such as for connected // network. Otherwise, it is an indirect route, the packet will be - // send the next hop router. + // sent to the next hop router. // - if (RtEntry->Flag & IP4_DIRECT_ROUTE) { + if ((RtEntry->Flag & IP4_DIRECT_ROUTE) != 0) { NextHop = Dest; } else { NextHop = RtEntry->NextHop; @@ -588,7 +581,7 @@ Ip4Route ( return NULL; } - NetListInsertHead (Head, &RtCacheEntry->Link); + InsertHeadList (Head, &RtCacheEntry->Link); NET_GET_REF (RtCacheEntry); // @@ -604,7 +597,7 @@ Ip4Route ( Cache = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link); - NetListRemoveEntry (Entry); + RemoveEntryList (Entry); Ip4FreeRouteCacheEntry (Cache); } @@ -628,7 +621,7 @@ Ip4BuildEfiRouteTable ( IN IP4_PROTOCOL *IpInstance ) { - NET_LIST_ENTRY *Entry; + LIST_ENTRY *Entry; IP4_ROUTE_TABLE *RtTable; IP4_ROUTE_ENTRY *RtEntry; EFI_IP4_ROUTE_TABLE *Table; @@ -638,7 +631,7 @@ Ip4BuildEfiRouteTable ( RtTable = IpInstance->RouteTable; if (IpInstance->EfiRouteTable != NULL) { - NetFreePool (IpInstance->EfiRouteTable); + gBS->FreePool (IpInstance->EfiRouteTable); IpInstance->EfiRouteTable = NULL; IpInstance->EfiRouteCount = 0; @@ -654,7 +647,7 @@ Ip4BuildEfiRouteTable ( return EFI_SUCCESS; } - Table = NetAllocatePool (sizeof (EFI_IP4_ROUTE_TABLE) * Count); + Table = AllocatePool (sizeof (EFI_IP4_ROUTE_TABLE) * Count); if (Table == NULL) { return EFI_OUT_OF_RESOURCES;