]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Update DHCPv6 to use DUID-UUID option
authorhhuan13 <hhuan13@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Jul 2011 11:29:47 +0000 (11:29 +0000)
committerhhuan13 <hhuan13@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Jul 2011 11:29:47 +0000 (11:29 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12018 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c

index 9bd4c9197a4049a5bc6fcf980821549dc38d3ac6..54ef2e2783d8c6cd630bd16c9405d540b9ce49cc 100644 (file)
@@ -166,7 +166,8 @@ Dhcp6CreateService (
     );\r
 \r
   //\r
-  // Generate client Duid in the format of Duid-llt.\r
+  // Generate client Duid: If SMBIOS system UUID is located, generate DUID in DUID-UUID format.\r
+  // Otherwise, in DUID-LLT format.\r
   //\r
   Dhcp6Srv->ClientId        = Dhcp6GenerateClientId (Dhcp6Srv->Snp->Mode);\r
 \r
index 8fb1dfa382682387717b23af86382925d2138797..84d50ad24424df23a8ac78048a2d0587ebeab5e1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Dhcp6 internal data structure and definition declaration.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, 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
@@ -184,7 +184,8 @@ typedef enum {
 typedef enum {\r
   Dhcp6DuidTypeLlt              = 1,\r
   Dhcp6DuidTypeEn               = 2,\r
-  Dhcp6DuidTypeLl               = 3\r
+  Dhcp6DuidTypeLl               = 3,\r
+  Dhcp6DuidTypeUuid             = 4\r
 } DHCP6_DUID_TYPE;\r
 \r
 //\r
index f4e7649e6cba2b4734db308cb52fd6e1de080835..ac0e577f5e333eaae1661d606c58520cc4dc4e1b 100644 (file)
@@ -34,6 +34,8 @@ Dhcp6GenerateClientId (
   EFI_DHCP6_DUID            *Duid;\r
   EFI_TIME                  Time;\r
   UINT32                    Stamp;\r
+  EFI_GUID                  Uuid;\r
+\r
 \r
   //\r
   // Attempt to get client Id from variable to keep it constant.\r
@@ -44,17 +46,6 @@ Dhcp6GenerateClientId (
     return Duid;\r
   }\r
 \r
-  //\r
-  // Generate a time stamp of the seconds from 2000/1/1, assume 30day/month.\r
-  //\r
-  gRT->GetTime (&Time, NULL);\r
-  Stamp = (UINT32)\r
-    (\r
-      (((((Time.Year - 2000) * 360 + (Time.Month - 1)) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) *\r
-      60 +\r
-      Time.Second\r
-    );\r
-\r
   //\r
   //  The format of client identifier option:\r
   //\r
@@ -68,42 +59,96 @@ Dhcp6GenerateClientId (
   //    .                                                               .\r
   //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
   //\r
-  //\r
-  //  The format of DUID-LLT:\r
-  //\r
-  //     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\r
-  //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
-  //    |          Duid type (1)        |    hardware type (16 bits)    |\r
-  //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
-  //    |                        time (32 bits)                         |\r
-  //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
-  //    .                                                               .\r
-  //    .             link-layer address (variable length)              .\r
-  //    .                                                               .\r
-  //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
-  //\r
 \r
   //\r
-  // sizeof (option-len + Duid-type + hardware-type + time) = 10 bytes\r
+  // If System UUID is found from SMBIOS Table, use DUID-UUID type.\r
   //\r
-  Duid = AllocateZeroPool (10 + Mode->HwAddressSize);\r
-  if (Duid == NULL) {\r
-    return NULL;\r
-  }\r
+  if (!EFI_ERROR (NetLibGetSystemGuid (&Uuid))) {\r
+    //\r
+    //\r
+    //  The format of DUID-UUID:\r
+    //   \r
+    //    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\r
+    //   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+    //   |          DUID-Type (4)        |    UUID (128 bits)            |\r
+    //   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |\r
+    //   |                                                               |\r
+    //   |                                                               |\r
+    //   |                                -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+    //   |                                |\r
+    //   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\r
 \r
-  //\r
-  // sizeof (Duid-type + hardware-type + time) = 8 bytes\r
-  //\r
-  Duid->Length = (UINT16) (Mode->HwAddressSize + 8);\r
+    //\r
+    // sizeof (option-len + Duid-type + UUID-size) = 20 bytes\r
+    //\r
+    Duid = AllocateZeroPool (2 + 2 + sizeof (EFI_GUID));\r
+    if (Duid == NULL) {\r
+      return NULL;\r
+    }\r
 \r
-  //\r
-  // Set the Duid-type, hardware-type, time and copy the hardware address.\r
-  //\r
-  WriteUnaligned16 ((UINT16 *) (Duid->Duid), HTONS (Dhcp6DuidTypeLlt));\r
-  WriteUnaligned16 ((UINT16 *) (Duid->Duid + 2), HTONS (NET_IFTYPE_ETHERNET));\r
-  WriteUnaligned32 ((UINT32 *) (Duid->Duid + 4), HTONL (Stamp));\r
+    //\r
+    // sizeof (Duid-type + UUID-size) = 18 bytes\r
+    //\r
+    Duid->Length = (UINT16) (18);\r
+  \r
+    //\r
+    // Set the Duid-type and copy UUID.\r
+    //\r
+    WriteUnaligned16 ((UINT16 *) (Duid->Duid), HTONS (Dhcp6DuidTypeUuid));\r
+  \r
+    CopyMem (Duid->Duid + 2, &Uuid, sizeof(EFI_GUID));\r
+\r
+  } else {\r
+      \r
+    //\r
+    //\r
+    //  The format of DUID-LLT:\r
+    //\r
+    //     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\r
+    //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+    //    |          Duid type (1)        |    hardware type (16 bits)    |\r
+    //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+    //    |                        time (32 bits)                         |\r
+    //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+    //    .                                                               .\r
+    //    .             link-layer address (variable length)              .\r
+    //    .                                                               .\r
+    //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+    //\r
 \r
-  CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);\r
+    //\r
+    // Generate a time stamp of the seconds from 2000/1/1, assume 30day/month.\r
+    //\r
+    gRT->GetTime (&Time, NULL);\r
+    Stamp = (UINT32)\r
+      (\r
+        (((((Time.Year - 2000) * 360 + (Time.Month - 1)) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) *\r
+        60 +\r
+        Time.Second\r
+      );\r
+\r
+    //\r
+    // sizeof (option-len + Duid-type + hardware-type + time) = 10 bytes\r
+    //\r
+    Duid = AllocateZeroPool (10 + Mode->HwAddressSize);\r
+    if (Duid == NULL) {\r
+      return NULL;\r
+    }\r
+  \r
+    //\r
+    // sizeof (Duid-type + hardware-type + time) = 8 bytes\r
+    //\r
+    Duid->Length = (UINT16) (Mode->HwAddressSize + 8);\r
+  \r
+    //\r
+    // Set the Duid-type, hardware-type, time and copy the hardware address.\r
+    //\r
+    WriteUnaligned16 ((UINT16 *) (Duid->Duid), HTONS (Dhcp6DuidTypeLlt));\r
+    WriteUnaligned16 ((UINT16 *) (Duid->Duid + 2), HTONS (NET_IFTYPE_ETHERNET));\r
+    WriteUnaligned32 ((UINT32 *) (Duid->Duid + 4), HTONL (Stamp));\r
+  \r
+    CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);\r
+  }\r
 \r
   Status = gRT->SetVariable (\r
                   L"ClientId",\r