]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Impl.c
index b5cd7b7d393202364999fe3a3d45340664bc4a63..ec6f0370772b003ec1b79b230655571034f0b747 100644 (file)
@@ -1,13 +1,7 @@
 /** @file\r
 \r
 Copyright (c) 2005 - 2018, 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
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -672,17 +666,21 @@ Ip4ConfigProtocol (
     }\r
 \r
     //\r
-    // Add a route to this connected network in the route table\r
+    // Add a route to this connected network in the instance route table.\r
     //\r
-    Ip4AddRoute (IpInstance->RouteTable, Ip, Netmask, IP4_ALLZERO_ADDRESS);\r
-\r
+    Ip4AddRoute (\r
+      IpInstance->RouteTable,\r
+      Ip & Netmask,\r
+      Netmask,\r
+      IP4_ALLZERO_ADDRESS\r
+      );\r
   } else {\r
     //\r
     // Use the default address. Check the state.\r
     //\r
     if (IpSb->State == IP4_SERVICE_UNSTARTED) {\r
       //\r
-      // Trigger the EFI_IP4_CONFIG2_PROTOCOL to retrieve the \r
+      // Trigger the EFI_IP4_CONFIG2_PROTOCOL to retrieve the\r
       // default IPv4 address if it is not available yet.\r
       //\r
       Policy = IpSb->Ip4Config2Instance.Policy;\r
@@ -1048,8 +1046,8 @@ Ip4Groups (
   // is decreamented each time an address is removed..\r
   //\r
   for (Index = IpInstance->GroupCount; Index > 0 ; Index--) {\r
+    ASSERT (IpInstance->Groups != NULL);\r
     Group = IpInstance->Groups[Index - 1];\r
-\r
     if ((GroupAddress == NULL) || EFI_IP4_EQUAL (&Group, GroupAddress)) {\r
       if (EFI_ERROR (Ip4LeaveGroup (IpInstance, NTOHL (Group)))) {\r
         return EFI_DEVICE_ERROR;\r
@@ -1259,7 +1257,7 @@ EfiIp4Routes (
   // the gateway address must be a unicast on the connected network if not zero.\r
   //\r
   if ((Nexthop != IP4_ALLZERO_ADDRESS) &&\r
-      (!IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask) ||\r
+      ((IpIf->SubnetMask != IP4_ALLONE_ADDRESS && !IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask)) ||\r
         IP4_IS_BROADCAST (Ip4GetNetCast (Nexthop, IpIf)))) {\r
 \r
     Status = EFI_INVALID_PARAMETER;\r
@@ -1660,7 +1658,7 @@ EfiIp4Transmit (
     }\r
 \r
     RawHdrLen = (UINT8) (RawHdrLen << 2);\r
-    \r
+\r
     CopyMem (&Head, FirstFragment, IP4_MIN_HEADLEN);\r
 \r
     Ip4NtohHead (&Head);\r
@@ -2250,8 +2248,8 @@ Ip4SentPacketTicking (
 }\r
 \r
 /**\r
-  This heart beat timer of IP4 service instance times out all of its IP4 children's \r
-  received-but-not-delivered and transmitted-but-not-recycle packets, and provides \r
+  This heart beat timer of IP4 service instance times out all of its IP4 children's\r
+  received-but-not-delivered and transmitted-but-not-recycle packets, and provides\r
   time input for its IGMP protocol.\r
 \r
   @param[in]  Event                  The IP4 service instance's heart beat timer.\r
@@ -2269,17 +2267,17 @@ Ip4TimerTicking (
 \r
   IpSb = (IP4_SERVICE *) Context;\r
   NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);\r
-  \r
+\r
   Ip4PacketTimerTicking (IpSb);\r
   Ip4IgmpTicking (IpSb);\r
 }\r
 \r
 /**\r
-  This dedicated timer is used to poll underlying network media status. In case \r
-  of cable swap or wireless network switch, a new round auto configuration will \r
-  be initiated. The timer will signal the IP4 to run DHCP configuration again. \r
-  IP4 driver will free old IP address related resource, such as route table and \r
-  Interface, then initiate a DHCP process to acquire new IP, eventually create \r
+  This dedicated timer is used to poll underlying network media status. In case\r
+  of cable swap or wireless network switch, a new round auto configuration will\r
+  be initiated. The timer will signal the IP4 to run DHCP configuration again.\r
+  IP4 driver will free old IP address related resource, such as route table and\r
+  Interface, then initiate a DHCP process to acquire new IP, eventually create\r
   route table for new IP address.\r
 \r
   @param[in]  Event                  The IP4 service instance's heart beat timer.\r
@@ -2300,12 +2298,12 @@ Ip4TimerReconfigChecking (
 \r
   IpSb = (IP4_SERVICE *) Context;\r
   NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);\r
-  \r
+\r
   OldMediaPresent = IpSb->MediaPresent;\r
 \r
   //\r
-  // Get fresh mode data from MNP, since underlying media status may change. \r
-  // Here, it needs to mention that the MediaPresent can also be checked even if \r
+  // Get fresh mode data from MNP, since underlying media status may change.\r
+  // Here, it needs to mention that the MediaPresent can also be checked even if\r
   // EFI_NOT_STARTED returned while this MNP child driver instance isn't configured.\r
   //\r
   Status = IpSb->Mnp->GetModeData (IpSb->Mnp, NULL, &SnpModeData);\r
@@ -2320,8 +2318,8 @@ Ip4TimerReconfigChecking (
   if (!OldMediaPresent && IpSb->MediaPresent && (IpSb->Ip4Config2Instance.Policy == Ip4Config2PolicyDhcp)) {\r
     //\r
     // Signal the IP4 to run the dhcp configuration again. IP4 driver will free\r
-    // old IP address related resource, such as route table and Interface, then \r
-    // initiate a DHCP round to acquire new IP, eventually \r
+    // old IP address related resource, such as route table and Interface, then\r
+    // initiate a DHCP round to acquire new IP, eventually\r
     // create route table for new IP address.\r
     //\r
     if (IpSb->ReconfigEvent != NULL) {\r