X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Output.c;h=7ff17b6637936e361e37eea86ddac35d19de5aba;hp=7d8745d5a5b2208ef410f4c45c5dd28821a9a2ff;hb=216f79703b8cb8dc65abdd768bedb2bcdbc1a1f8;hpb=619561dc52a036621540b8a51a7379968cba2128 diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c index 7d8745d5a5..7ff17b6637 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c @@ -1,8 +1,8 @@ /** @file Transmit the IP4 packet. -Copyright (c) 2005 - 2009, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -204,6 +204,10 @@ Ip4SysPacketSent ( @retval EFI_NO_MAPPING There is no interface to the destination. @retval EFI_NOT_FOUND There is no route to the destination @retval EFI_SUCCESS The packet is successfully transmitted. + @retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + + total data length is greater than MTU (or greater + than the maximum packet size if Token.Packet.TxData. + OverrideData.DoNotFragment is TRUE.) @retval Others Failed to transmit the packet. **/ @@ -231,6 +235,7 @@ Ip4Output ( UINT32 Offset; UINT32 Mtu; UINT32 Num; + BOOLEAN RawData; // // Select an interface/source for system packet, application @@ -250,6 +255,38 @@ Ip4Output ( Head->Src = IpIf->Ip; } + // + // Before IPsec process, prepared the IP head. + // If Ip4Output is transmitting RawData, don't update IPv4 header. + // + HeadLen = sizeof (IP4_HEAD) + ((OptLen + 3) & (~0x03)); + + if ((IpInstance != NULL) && IpInstance->ConfigData.RawData) { + RawData = TRUE; + } else { + Head->HeadLen = (UINT8) (HeadLen >> 2); + Head->Id = mIp4Id++; + Head->Ver = 4; + RawData = FALSE; + } + + // + // Call IPsec process. + // + Status = Ip4IpSecProcessPacket ( + IpSb, + &Head, + &Packet, + &Option, + &OptLen, + EfiIPsecOutBound, + Context + ); + + if (EFI_ERROR(Status)) { + return Status; + } + // // Route the packet unless overrided, that is, GateWay isn't zero. // @@ -291,32 +328,20 @@ Ip4Output ( } } - // - // TODO: currently Option/OptLen are not included into encryption scope. - // - Status = Ip4IpSecProcessPacket ( - IpSb, - Head, - &Packet, - Option, - OptLen, - EfiIPsecOutBound, - Context - ); - - if (EFI_ERROR(Status)) { - return Status; - } - // // OK, selected the source and route, fragment the packet then send // them. Tag each fragment other than the first one as spawn from it. // - Mtu = IpSb->MaxPacketSize + sizeof (IP4_HEAD); - HeadLen = sizeof (IP4_HEAD) + ((OptLen + 3) & (~0x03)); - Head->Id = mIp4Id++; + Mtu = IpSb->MaxPacketSize + sizeof (IP4_HEAD); if (Packet->TotalSize + HeadLen > Mtu) { + // + // Fragmentation is diabled for RawData mode. + // + if (RawData) { + return EFI_BAD_BUFFER_SIZE; + } + // // Packet is fragmented from the tail to the head, that is, the // first frame sent is the last fragment of the packet. The first