]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
MdeModulePkg: Fix some typos of "according"
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Impl.c
index 821dfbb450a7b592b7d42ac8b828a68d2f8b36c4..1db4c667d7cce721048ba2f02fb1a395e2e43f98 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This file implement the EFI_DHCP4_PROTOCOL interface.\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, 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
@@ -660,9 +660,7 @@ EfiDhcp4Configure (
     }\r
 \r
     CopyMem (&Ip, &Dhcp4CfgData->ClientAddress, sizeof (IP4_ADDR));\r
-\r
-    if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
-\r
+    if (IP4_IS_LOCAL_BROADCAST(NTOHL (Ip))) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   }\r
@@ -1188,14 +1186,16 @@ Dhcp4InstanceConfigUdpIo (
   )\r
 {\r
   DHCP_PROTOCOL                     *Instance;\r
+  DHCP_SERVICE                      *DhcpSb;\r
   EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN  *Token;\r
   EFI_UDP4_CONFIG_DATA              UdpConfigData;\r
   IP4_ADDR                          ClientAddr;\r
-  IP4_ADDR                          Ip;   \r
+  IP4_ADDR                          Ip; \r
   INTN                              Class; \r
-  IP4_ADDR                          SubnetMask;\r
+  IP4_ADDR                          SubnetMask;  \r
 \r
   Instance = (DHCP_PROTOCOL *) Context;\r
+  DhcpSb   = Instance->Service;\r
   Token    = Instance->Token;\r
 \r
   ZeroMem (&UdpConfigData, sizeof (EFI_UDP4_CONFIG_DATA));\r
@@ -1208,10 +1208,22 @@ Dhcp4InstanceConfigUdpIo (
   ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr);\r
   Ip = HTONL (ClientAddr);\r
   CopyMem (&UdpConfigData.StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
-  \r
-  Class = NetGetIpClass (ClientAddr);\r
-  ASSERT (Class < IP4_ADDR_CLASSE);\r
-  SubnetMask = gIp4AllMasks[Class << 3];\r
+\r
+  if (DhcpSb->Netmask == 0) {\r
+    //\r
+    // The Dhcp4.TransmitReceive() API should be able to used at any time according to\r
+    // UEFI spec, while in classless addressing network, the netmask must be explicitly\r
+    // provided together with the station address.\r
+    // If the DHCP instance haven't be configured with a valid netmask, we could only\r
+    // compute it according to the classful addressing rule.\r
+    //\r
+    Class = NetGetIpClass (ClientAddr);\r
+    ASSERT (Class < IP4_ADDR_CLASSE);\r
+    SubnetMask = gIp4AllMasks[Class << 3];\r
+  } else {\r
+    SubnetMask = DhcpSb->Netmask;\r
+  }\r
+\r
   Ip = HTONL (SubnetMask);\r
   CopyMem (&UdpConfigData.SubnetMask, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
 \r
@@ -1485,8 +1497,6 @@ EfiDhcp4TransmitReceive (
   DHCP_SERVICE   *DhcpSb;\r
   EFI_IP_ADDRESS Gateway;\r
   IP4_ADDR       ClientAddr;\r
-  INTN           Class;\r
-  IP4_ADDR       SubnetMask;\r
 \r
   if ((This == NULL) || (Token == NULL) || (Token->Packet == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1494,7 +1504,6 @@ EfiDhcp4TransmitReceive (
 \r
   Instance = DHCP_INSTANCE_FROM_THIS (This);\r
   DhcpSb   = Instance->Service;\r
-  DhcpSb->ActiveChild = Instance;\r
 \r
   if (Instance->Token != NULL) {\r
     //\r
@@ -1580,11 +1589,8 @@ EfiDhcp4TransmitReceive (
   //\r
   // Get the gateway.\r
   //\r
-  Class = NetGetIpClass (ClientAddr);\r
-  ASSERT (Class < IP4_ADDR_CLASSE);\r
-  SubnetMask = gIp4AllMasks[Class << 3];\r
   ZeroMem (&Gateway, sizeof (Gateway));\r
-  if (!IP4_NET_EQUAL (ClientAddr, EndPoint.RemoteAddr.Addr[0], SubnetMask)) {\r
+  if (!IP4_NET_EQUAL (ClientAddr, EndPoint.RemoteAddr.Addr[0], DhcpSb->Netmask)) {\r
     CopyMem (&Gateway.v4, &Token->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
     Gateway.Addr[0] = NTOHL (Gateway.Addr[0]);\r
   }\r