X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Impl.c;h=05fd96d634cd98c2badf90b214265316fe543c65;hb=1204fe8319e5e6f77df68c375ef403e9ffa9227e;hp=84a39656f6a10e3e92dc4d37edc0e13dec4f8170;hpb=894d038a8d0e99d456042e2b6d1554c4a406ea70;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c index 84a39656f6..05fd96d634 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c @@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Ip4Impl.h" +EFI_IPSEC_PROTOCOL *mIpSec = NULL; + /** Gets the current operational settings for this instance of the EFI IPv4 Protocol driver. @@ -404,6 +406,8 @@ EfiIp4GetModeData ( Ip4ModeData->RouteTable = NULL; Ip4ModeData->RouteCount = 0; + Ip4ModeData->MaxPacketSize = IpSb->MaxPacketSize; + // // return the current station address for this IP child. So, // the user can get the default address through this. Some @@ -557,6 +561,10 @@ Ip4AutoConfigCallBackDpc ( EFI_STATUS Status; UINTN Len; UINT32 Index; + IP4_ADDR StationAddress; + IP4_ADDR SubnetMask; + IP4_ADDR SubnetAddress; + IP4_ADDR GatewayAddress; IpSb = (IP4_SERVICE *) Context; NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE); @@ -642,11 +650,9 @@ Ip4AutoConfigCallBackDpc ( // Set the default interface's address, then add a directed // route for it, that is, the route whose nexthop is zero. // - Status = Ip4SetAddress ( - IpIf, - EFI_NTOHL (Data->StationAddress), - EFI_NTOHL (Data->SubnetMask) - ); + StationAddress = EFI_NTOHL (Data->StationAddress); + SubnetMask = EFI_NTOHL (Data->SubnetMask); + Status = Ip4SetAddress (IpIf, StationAddress, SubnetMask); if (EFI_ERROR (Status)) { goto ON_EXIT; @@ -654,8 +660,8 @@ Ip4AutoConfigCallBackDpc ( Ip4AddRoute ( IpSb->DefaultRouteTable, - EFI_NTOHL (Data->StationAddress), - EFI_NTOHL (Data->SubnetMask), + StationAddress, + SubnetMask, IP4_ALLZERO_ADDRESS ); @@ -665,12 +671,10 @@ Ip4AutoConfigCallBackDpc ( for (Index = 0; Index < Data->RouteTableSize; Index++) { RouteEntry = &Data->RouteTable[Index]; - Ip4AddRoute ( - IpSb->DefaultRouteTable, - EFI_NTOHL (RouteEntry->SubnetAddress), - EFI_NTOHL (RouteEntry->SubnetMask), - EFI_NTOHL (RouteEntry->GatewayAddress) - ); + SubnetAddress = EFI_NTOHL (RouteEntry->SubnetAddress); + SubnetMask = EFI_NTOHL (RouteEntry->SubnetMask); + GatewayAddress = EFI_NTOHL (RouteEntry->GatewayAddress); + Ip4AddRoute (IpSb->DefaultRouteTable, SubnetAddress, SubnetMask, GatewayAddress); } IpSb->State = IP4_SERVICE_CONFIGED; @@ -678,7 +682,7 @@ Ip4AutoConfigCallBackDpc ( Ip4SetVariableData (IpSb); ON_EXIT: - gBS->FreePool (Data); + FreePool (Data); } /** @@ -703,7 +707,7 @@ Ip4AutoConfigCallBack ( // // Request Ip4AutoConfigCallBackDpc as a DPC at TPL_CALLBACK // - NetLibQueueDpc (TPL_CALLBACK, Ip4AutoConfigCallBackDpc, Context); + QueueDpc (TPL_CALLBACK, Ip4AutoConfigCallBackDpc, Context); } @@ -1041,13 +1045,13 @@ Ip4CleanProtocol ( } if (IpInstance->EfiRouteTable != NULL) { - gBS->FreePool (IpInstance->EfiRouteTable); + FreePool (IpInstance->EfiRouteTable); IpInstance->EfiRouteTable = NULL; IpInstance->EfiRouteCount = 0; } if (IpInstance->Groups != NULL) { - gBS->FreePool (IpInstance->Groups); + FreePool (IpInstance->Groups); IpInstance->Groups = NULL; IpInstance->GroupCount = 0; } @@ -1333,12 +1337,12 @@ Ip4Groups ( } if (EFI_ERROR (Ip4JoinGroup (IpInstance, NTOHL (Group)))) { - gBS->FreePool (Members); + FreePool (Members); return EFI_DEVICE_ERROR; } if (IpInstance->Groups != NULL) { - gBS->FreePool (IpInstance->Groups); + FreePool (IpInstance->Groups); } IpInstance->Groups = Members; @@ -1366,7 +1370,7 @@ Ip4Groups ( if (IpInstance->GroupCount == 0) { ASSERT (Index == 1); - gBS->FreePool (IpInstance->Groups); + FreePool (IpInstance->Groups); IpInstance->Groups = NULL; } @@ -1764,6 +1768,13 @@ Ip4FreeTxToken ( Wrap = (IP4_TXTOKEN_WRAP *) Context; + // + // Signal IpSecRecycleEvent to inform IPsec free the memory + // + if (Wrap->IpSecRecycleSignal != NULL) { + gBS->SignalEvent (Wrap->IpSecRecycleSignal); + } + // // Find the token in the instance's map. EfiIp4Transmit put the // token to the map. If that failed, NetMapFindKey will return NULL. @@ -1780,10 +1791,10 @@ Ip4FreeTxToken ( // // Dispatch the DPC queued by the NotifyFunction of Token->Event. // - NetLibDispatchDpc (); + DispatchDpc (); } - gBS->FreePool (Wrap); + FreePool (Wrap); } @@ -1947,12 +1958,12 @@ EfiIp4Transmit ( } Head.Fragment = IP4_HEAD_FRAGMENT_FIELD (DontFragment, FALSE, 0); - HeadLen = sizeof (IP4_HEAD) + ((TxData->OptionsLength + 3) &~0x03); + HeadLen = (TxData->OptionsLength + 3) & (~0x03); // // If don't fragment and fragment needed, return error // - if (DontFragment && (TxData->TotalDataLength + HeadLen > IpSb->SnpMode.MaxPacketSize)) { + if (DontFragment && (TxData->TotalDataLength + HeadLen > IpSb->MaxPacketSize)) { Status = EFI_BAD_BUFFER_SIZE; goto ON_EXIT; } @@ -1962,7 +1973,7 @@ EfiIp4Transmit ( // a IP4_TXTOKEN_WRAP and the data in a netbuf // Status = EFI_OUT_OF_RESOURCES; - Wrap = AllocatePool (sizeof (IP4_TXTOKEN_WRAP)); + Wrap = AllocateZeroPool (sizeof (IP4_TXTOKEN_WRAP)); if (Wrap == NULL) { goto ON_EXIT; } @@ -1981,7 +1992,7 @@ EfiIp4Transmit ( ); if (Wrap->Packet == NULL) { - gBS->FreePool (Wrap); + FreePool (Wrap); goto ON_EXIT; } @@ -2110,7 +2121,7 @@ EfiIp4Receive ( // Dispatch the DPC queued by the NotifyFunction of this instane's receive // event. // - NetLibDispatchDpc (); + DispatchDpc (); ON_EXIT: gBS->RestoreTPL (OldTpl); @@ -2266,7 +2277,7 @@ Ip4Cancel ( // Dispatch the DPCs queued by the NotifyFunction of the canceled rx token's // events. // - NetLibDispatchDpc (); + DispatchDpc (); if (EFI_ERROR (Status)) { if ((Token != NULL) && (Status == EFI_ABORTED)) { return EFI_SUCCESS;