]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c
BaseTools:Change the path of the file that Binary Cache
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Output.c
index 370eaa6a9f7a315928e894d23ff18c7258c1ecd2..5eb3814089cbe0f90a1ededd97997d9637aff7b1 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Transmit the IP4 packet.\r
-  \r
-Copyright (c) 2005 - 2013, 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
-http://opensource.org/licenses/bsd-license.php\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -269,16 +263,16 @@ Ip4Output (
     Head->Ver      = 4;\r
     RawData        = FALSE;\r
   }\r
-  \r
+\r
   //\r
   // Call IPsec process.\r
   //\r
   Status = Ip4IpSecProcessPacket (\r
-             IpSb, \r
-             &Head, \r
-             &Packet, \r
-             &Option, \r
-             &OptLen, \r
+             IpSb,\r
+             &Head,\r
+             &Packet,\r
+             &Option,\r
+             &OptLen,\r
              EfiIPsecOutBound,\r
              Context\r
              );\r
@@ -286,7 +280,7 @@ Ip4Output (
   if (EFI_ERROR(Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   Dest = Head->Dst;\r
   if (IP4_IS_BROADCAST (Ip4GetNetCast (Dest, IpIf)) || (Dest == IP4_ALLONE_ADDRESS)) {\r
     //\r
@@ -309,9 +303,16 @@ Ip4Output (
     // Route the packet unless overrided, that is, GateWay isn't zero.\r
     //\r
     if (IpInstance == NULL) {\r
-      CacheEntry = Ip4Route (IpSb->DefaultRouteTable, Head->Dst, Head->Src);\r
+      CacheEntry = Ip4Route (IpSb->DefaultRouteTable, Head->Dst, Head->Src, IpIf->SubnetMask, TRUE);\r
     } else {\r
-      CacheEntry = Ip4Route (IpInstance->RouteTable, Head->Dst, Head->Src);\r
+      CacheEntry = Ip4Route (IpInstance->RouteTable, Head->Dst, Head->Src, IpIf->SubnetMask, FALSE);\r
+      //\r
+      // If failed to route the packet by using the instance's route table,\r
+      // try to use the default route table.\r
+      //\r
+      if (CacheEntry == NULL) {\r
+        CacheEntry = Ip4Route (IpSb->DefaultRouteTable, Head->Dst, Head->Src, IpIf->SubnetMask, TRUE);\r
+      }\r
     }\r
 \r
     if (CacheEntry == NULL) {\r
@@ -326,7 +327,7 @@ Ip4Output (
   // OK, selected the source and route, fragment the packet then send\r
   // them. Tag each fragment other than the first one as spawn from it.\r
   //\r
-  Mtu = IpSb->MaxPacketSize + sizeof (IP4_HEAD);  \r
+  Mtu = IpSb->MaxPacketSize + sizeof (IP4_HEAD);\r
 \r
   if (Packet->TotalSize + HeadLen > Mtu) {\r
     //\r
@@ -335,7 +336,7 @@ Ip4Output (
     if (RawData) {\r
       return EFI_BAD_BUFFER_SIZE;\r
     }\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
@@ -379,7 +380,8 @@ Ip4Output (
                  Fragment,\r
                  GateWay,\r
                  Ip4SysPacketSent,\r
-                 Packet\r
+                 Packet,\r
+                 IpSb\r
                  );\r
 \r
       if (EFI_ERROR (Status)) {\r
@@ -422,7 +424,7 @@ Ip4Output (
   //    upper layer's packets.\r
   //\r
   Ip4PrependHead (Packet, Head, Option, OptLen);\r
-  Status = Ip4SendFrame (IpIf, IpInstance, Packet, GateWay, Callback, Context);\r
+  Status = Ip4SendFrame (IpIf, IpInstance, Packet, GateWay, Callback, Context, IpSb);\r
 \r
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r