mirror of https://github.com/acidanthera/audk.git
1. Update DHCPv6 to use DUID-UUID option
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12018 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
57b301b569
commit
33c09637c6
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
//
|
||||
|
|
|
@ -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.
|
||||
|
@ -44,17 +46,6 @@ Dhcp6GenerateClientId (
|
|||
return Duid;
|
||||
}
|
||||
|
||||
//
|
||||
// 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:
|
||||
//
|
||||
|
@ -68,6 +59,48 @@ Dhcp6GenerateClientId (
|
|||
// . .
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
//
|
||||
|
||||
//
|
||||
// If System UUID is found from SMBIOS Table, use DUID-UUID type.
|
||||
//
|
||||
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 (option-len + Duid-type + UUID-size) = 20 bytes
|
||||
//
|
||||
Duid = AllocateZeroPool (2 + 2 + sizeof (EFI_GUID));
|
||||
if (Duid == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// 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:
|
||||
//
|
||||
|
@ -83,6 +116,17 @@ 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
|
||||
);
|
||||
|
||||
//
|
||||
// sizeof (option-len + Duid-type + hardware-type + time) = 10 bytes
|
||||
//
|
||||
|
@ -104,6 +148,7 @@ Dhcp6GenerateClientId (
|
|||
WriteUnaligned32 ((UINT32 *) (Duid->Duid + 4), HTONL (Stamp));
|
||||
|
||||
CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);
|
||||
}
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
L"ClientId",
|
||||
|
|
Loading…
Reference in New Issue