summaryrefslogtreecommitdiff
path: root/edk2/NetworkPkg
diff options
context:
space:
mode:
authorhhuan13 <hhuan13@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-14 11:29:47 +0000
committerhhuan13 <hhuan13@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-14 11:29:47 +0000
commit2baa4dda670a0dc8c7398e46098b2b53e1fe09f8 (patch)
tree5016120e3bf591ebda9f787f4fd44e38f9e9ae14 /edk2/NetworkPkg
parent4b0659ada0dbae02d23557bd27fa9b015c3b7a4a (diff)
1. Update DHCPv6 to use DUID-UUID option
Signed-off-by: hhuan13 Reviewed-by: tye1 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@12018 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'edk2/NetworkPkg')
-rw-r--r--edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c3
-rw-r--r--edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h5
-rw-r--r--edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c127
3 files changed, 91 insertions, 44 deletions
diff --git a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
index 9bd4c9197..54ef2e278 100644
--- a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
+++ b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
@@ -166,7 +166,8 @@ Dhcp6CreateService (
);
//
- // Generate client Duid in the format of Duid-llt.
+ // Generate client Duid: If SMBIOS system UUID is located, generate DUID in DUID-UUID format.
+ // Otherwise, in DUID-LLT format.
//
Dhcp6Srv->ClientId = Dhcp6GenerateClientId (Dhcp6Srv->Snp->Mode);
diff --git a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
index 8fb1dfa38..84d50ad24 100644
--- a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
+++ b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
@@ -1,7 +1,7 @@
/** @file
Dhcp6 internal data structure and definition declaration.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -184,7 +184,8 @@ typedef enum {
typedef enum {
Dhcp6DuidTypeLlt = 1,
Dhcp6DuidTypeEn = 2,
- Dhcp6DuidTypeLl = 3
+ Dhcp6DuidTypeLl = 3,
+ Dhcp6DuidTypeUuid = 4
} DHCP6_DUID_TYPE;
//
diff --git a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
index f4e7649e6..ac0e577f5 100644
--- a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
+++ b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
@@ -34,6 +34,8 @@ Dhcp6GenerateClientId (
EFI_DHCP6_DUID *Duid;
EFI_TIME Time;
UINT32 Stamp;
+ EFI_GUID Uuid;
+
//
// Attempt to get client Id from variable to keep it constant.
@@ -45,17 +47,6 @@ Dhcp6GenerateClientId (
}
//
- // Generate a time stamp of the seconds from 2000/1/1, assume 30day/month.
- //
- gRT->GetTime (&Time, NULL);
- Stamp = (UINT32)
- (
- (((((Time.Year - 2000) * 360 + (Time.Month - 1)) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) *
- 60 +
- Time.Second
- );
-
- //
// The format of client identifier option:
//
// 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
@@ -68,42 +59,96 @@ Dhcp6GenerateClientId (
// . .
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
- //
- // The format of DUID-LLT:
- //
- // 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
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // | Duid type (1) | hardware type (16 bits) |
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // | time (32 bits) |
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // . .
- // . link-layer address (variable length) .
- // . .
- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- //
//
- // sizeof (option-len + Duid-type + hardware-type + time) = 10 bytes
+ // If System UUID is found from SMBIOS Table, use DUID-UUID type.
//
- Duid = AllocateZeroPool (10 + Mode->HwAddressSize);
- if (Duid == NULL) {
- return NULL;
- }
+ if (!EFI_ERROR (NetLibGetSystemGuid (&Uuid))) {
+ //
+ //
+ // The format of DUID-UUID:
+ //
+ // 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
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // | DUID-Type (4) | UUID (128 bits) |
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+ // | |
+ // | |
+ // | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // | |
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
- //
- // sizeof (Duid-type + hardware-type + time) = 8 bytes
- //
- Duid->Length = (UINT16) (Mode->HwAddressSize + 8);
+ //
+ // sizeof (option-len + Duid-type + UUID-size) = 20 bytes
+ //
+ Duid = AllocateZeroPool (2 + 2 + sizeof (EFI_GUID));
+ if (Duid == NULL) {
+ return NULL;
+ }
- //
- // Set the Duid-type, hardware-type, time and copy the hardware address.
- //
- WriteUnaligned16 ((UINT16 *) (Duid->Duid), HTONS (Dhcp6DuidTypeLlt));
- WriteUnaligned16 ((UINT16 *) (Duid->Duid + 2), HTONS (NET_IFTYPE_ETHERNET));
- WriteUnaligned32 ((UINT32 *) (Duid->Duid + 4), HTONL (Stamp));
+ //
+ // sizeof (Duid-type + UUID-size) = 18 bytes
+ //
+ Duid->Length = (UINT16) (18);
+
+ //
+ // Set the Duid-type and copy UUID.
+ //
+ WriteUnaligned16 ((UINT16 *) (Duid->Duid), HTONS (Dhcp6DuidTypeUuid));
+
+ CopyMem (Duid->Duid + 2, &Uuid, sizeof(EFI_GUID));
+
+ } else {
+
+ //
+ //
+ // The format of DUID-LLT:
+ //
+ // 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
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // | Duid type (1) | hardware type (16 bits) |
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // | time (32 bits) |
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // . .
+ // . link-layer address (variable length) .
+ // . .
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ //
- CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);
+ //
+ // Generate a time stamp of the seconds from 2000/1/1, assume 30day/month.
+ //
+ gRT->GetTime (&Time, NULL);
+ Stamp = (UINT32)
+ (
+ (((((Time.Year - 2000) * 360 + (Time.Month - 1)) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) *
+ 60 +
+ Time.Second
+ );
+
+ //
+ // sizeof (option-len + Duid-type + hardware-type + time) = 10 bytes
+ //
+ Duid = AllocateZeroPool (10 + Mode->HwAddressSize);
+ if (Duid == NULL) {
+ return NULL;
+ }
+
+ //
+ // sizeof (Duid-type + hardware-type + time) = 8 bytes
+ //
+ Duid->Length = (UINT16) (Mode->HwAddressSize + 8);
+
+ //
+ // Set the Duid-type, hardware-type, time and copy the hardware address.
+ //
+ WriteUnaligned16 ((UINT16 *) (Duid->Duid), HTONS (Dhcp6DuidTypeLlt));
+ WriteUnaligned16 ((UINT16 *) (Duid->Duid + 2), HTONS (NET_IFTYPE_ETHERNET));
+ WriteUnaligned32 ((UINT32 *) (Duid->Duid + 4), HTONL (Stamp));
+
+ CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);
+ }
Status = gRT->SetVariable (
L"ClientId",