]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
Fix default VENDOR_CLASS in DHCP discover.
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcSupport.c
index 30418c3b6a1c2d83483c738c511fbc361d6799fe..88ae7b6a7a145c18097ef3ba9f55a4b8d75eb6bc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support functions implementation for UefiPxeBc Driver.\r
 \r
-  Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -28,7 +28,7 @@
 \r
 **/\r
 EFI_STATUS\r
-PxeBcFlushStaionIp (\r
+PxeBcFlushStationIp (\r
   PXEBC_PRIVATE_DATA       *Private,\r
   EFI_IP_ADDRESS           *StationIp,\r
   EFI_IP_ADDRESS           *SubnetMask     OPTIONAL\r
@@ -59,10 +59,6 @@ PxeBcFlushStaionIp (
     }\r
 \r
     Status = Private->Ip6->Receive (Private->Ip6, &Private->Icmp6Token);\r
-    if (EFI_ERROR (Status)) {\r
-      goto ON_EXIT;\r
-    }\r
-\r
   } else {\r
     ASSERT (SubnetMask != NULL);\r
     CopyMem (&Private->Udp4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS));\r
@@ -82,10 +78,6 @@ PxeBcFlushStaionIp (
     }\r
 \r
     Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpToken);\r
-    if (EFI_ERROR (Status)) {\r
-      goto ON_EXIT;\r
-    }\r
-\r
   }\r
 \r
 ON_EXIT:\r
@@ -1464,3 +1456,56 @@ PxeBcUniHexToUint8 (
 \r
   return EFI_INVALID_PARAMETER;\r
 }\r
+\r
+/**\r
+  Calculate the elapsed time.\r
+\r
+  @param[in]      Private      The pointer to PXE private data\r
+\r
+**/\r
+VOID\r
+CalcElapsedTime (\r
+  IN     PXEBC_PRIVATE_DATA     *Private\r
+  )\r
+{\r
+  EFI_TIME          Time;\r
+  UINT64            CurrentStamp;\r
+  UINT64            ElapsedTimeValue;\r
+\r
+  //\r
+  // Generate a time stamp of the centiseconds from 1900/1/1, assume 30day/month.\r
+  //\r
+  ZeroMem (&Time, sizeof (EFI_TIME));\r
+  gRT->GetTime (&Time, NULL);\r
+  CurrentStamp = (UINT64)\r
+    (\r
+      ((((((Time.Year - 1900) * 360 +\r
+       (Time.Month - 1)) * 30 +\r
+       (Time.Day - 1)) * 24 + Time.Hour) * 60 +\r
+       Time.Minute) * 60 + Time.Second) * 100\r
+       + DivU64x32(Time.Nanosecond, 10000000)\r
+    );\r
+\r
+  //\r
+  // Sentinel value of 0 means that this is the first DHCP packet that we are\r
+  // sending and that we need to initialize the value.  First DHCP Solicit\r
+  // gets 0 elapsed-time.  Otherwise, calculate based on StartTime.\r
+  //\r
+  if (Private->ElapsedTime == 0) {\r
+    Private->ElapsedTime = CurrentStamp;\r
+  } else {\r
+    ElapsedTimeValue = CurrentStamp - Private->ElapsedTime;\r
+\r
+    //\r
+    // If elapsed time cannot fit in two bytes, set it to 0xffff.\r
+    //\r
+    if (ElapsedTimeValue > 0xffff) {\r
+      ElapsedTimeValue = 0xffff;\r
+    }\r
+    //\r
+    // Save the elapsed time\r
+    //\r
+    Private->ElapsedTime = ElapsedTimeValue;\r
+  }\r
+}\r
+\r