]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c
1. Add EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName() support.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Output.c
index 85dffe0643584c7b6c2ad7bbf995fffa786c54a9..7ff17b6637936e361e37eea86ddac35d19de5aba 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Transmit the IP4 packet.\r
   \r
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\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
@@ -204,6 +204,10 @@ Ip4SysPacketSent (
   @retval EFI_NO_MAPPING       There is no interface to the destination.\r
   @retval EFI_NOT_FOUND        There is no route to the destination\r
   @retval EFI_SUCCESS          The packet is successfully transmitted.\r
+  @retval EFI_BAD_BUFFER_SIZE  The length of the IPv4 header + option length +\r
+                               total data length is greater than MTU (or greater\r
+                               than the maximum packet size if Token.Packet.TxData.\r
+                               OverrideData.DoNotFragment is TRUE.)\r
   @retval Others               Failed to transmit the packet.\r
 \r
 **/\r
@@ -231,6 +235,7 @@ Ip4Output (
   UINT32                    Offset;\r
   UINT32                    Mtu;\r
   UINT32                    Num;\r
+  BOOLEAN                   RawData;\r
 \r
   //\r
   // Select an interface/source for system packet, application\r
@@ -252,11 +257,18 @@ Ip4Output (
 \r
   //\r
   // Before IPsec process, prepared the IP head.\r
+  // If Ip4Output is transmitting RawData, don't update IPv4 header.\r
   //\r
-  HeadLen        = sizeof (IP4_HEAD) + ((OptLen + 3) & (~0x03));\r
-  Head->HeadLen  = (UINT8) (HeadLen >> 2);\r
-  Head->Id       = mIp4Id++;\r
-  Head->Ver      = 4;\r
+  HeadLen = sizeof (IP4_HEAD) + ((OptLen + 3) & (~0x03));\r
+\r
+  if ((IpInstance != NULL) && IpInstance->ConfigData.RawData) {\r
+    RawData        = TRUE;\r
+  } else {\r
+    Head->HeadLen  = (UINT8) (HeadLen >> 2);\r
+    Head->Id       = mIp4Id++;\r
+    Head->Ver      = 4;\r
+    RawData        = FALSE;\r
+  }\r
   \r
   //\r
   // Call IPsec process.\r
@@ -323,6 +335,13 @@ Ip4Output (
   Mtu = IpSb->MaxPacketSize + sizeof (IP4_HEAD);  \r
 \r
   if (Packet->TotalSize + HeadLen > Mtu) {\r
+    //\r
+    // Fragmentation is diabled for RawData mode.\r
+    //\r
+    if (RawData) {\r
+      return EFI_BAD_BUFFER_SIZE;\r
+    }\r
+    \r
     //\r
     // Packet is fragmented from the tail to the head, that is, the\r
     // first frame sent is the last fragment of the packet. The first\r