X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=NetworkPkg%2FDhcp6Dxe%2FDhcp6Utility.c;h=10a99a00d4b5595c93547501d7f8a2dcbe457400;hp=32247c927b0a63a6b89af29be80c24cb0950bd5e;hb=f75a7f568e6d0944327970b3f3f2dafd9bba76b1;hpb=685e44a546ac3744d04cdce12d27d07f96831e7c
diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
index 32247c927b..10a99a00d4 100644
--- a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
@@ -1,7 +1,8 @@
/** @file
Dhcp6 support functions implementation.
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -63,11 +64,11 @@ Dhcp6GenerateClientId (
//
// If System UUID is found from SMBIOS Table, use DUID-UUID type.
//
- if (!EFI_ERROR (NetLibGetSystemGuid (&Uuid))) {
+ if ((PcdGet8 (PcdDhcp6UidType) == Dhcp6DuidTypeUuid) && !EFI_ERROR (NetLibGetSystemGuid (&Uuid)) && !CompareGuid (&Uuid, &gZeroGuid)) {
//
//
// 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) |
@@ -90,16 +91,16 @@ Dhcp6GenerateClientId (
// 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:
@@ -134,19 +135,19 @@ Dhcp6GenerateClientId (
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));
-
+ WriteUnaligned16 ((UINT16 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid)), HTONS (Dhcp6DuidTypeLlt));
+ WriteUnaligned16 ((UINT16 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 2), HTONS (NET_IFTYPE_ETHERNET));
+ WriteUnaligned32 ((UINT32 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 4), HTONL (Stamp));
+
CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);
}
@@ -157,7 +158,10 @@ Dhcp6GenerateClientId (
Duid->Length + 2,
(VOID *) Duid
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ FreePool (Duid);
+ return NULL;
+ }
return Duid;
}
@@ -383,7 +387,6 @@ Dhcp6CalculateLeaseTime (
IN DHCP6_IA_CB *IaCb
)
{
- EFI_DHCP6_IA_ADDRESS *IaAddr;
UINT32 MinLt;
UINT32 MaxLt;
UINTN Index;
@@ -398,9 +401,8 @@ Dhcp6CalculateLeaseTime (
// valid life time.
//
for (Index = 0; Index < IaCb->Ia->IaAddressCount; Index++) {
- IaAddr = IaCb->Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS);
- MinLt = MIN (MinLt, IaAddr->ValidLifetime);
- MaxLt = MAX (MinLt, IaAddr->ValidLifetime);
+ MinLt = MIN (MinLt, IaCb->Ia->IaAddress[Index].ValidLifetime);
+ MaxLt = MAX (MinLt, IaCb->Ia->IaAddress[Index].ValidLifetime);
}
//
@@ -685,7 +687,7 @@ Dhcp6AppendIaAddrOption (
// . IAaddr-options .
// . .
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
+
//
// Fill the value of Ia Address option type
//
@@ -998,7 +1000,7 @@ Dhcp6SeekIaOption (
}
/**
- Check whether the incoming IPv6 address in IaAddr is one of the maintained
+ Check whether the incoming IPv6 address in IaAddr is one of the maintained
addresses in the IA control blcok.
@param[in] IaAddr The pointer to the IA Address to be checked.
@@ -1017,7 +1019,7 @@ Dhcp6AddrIsInCurrentIa (
UINT32 Index;
ASSERT (IaAddr != NULL && CurrentIa != NULL);
-
+
for (Index = 0; Index < CurrentIa->IaAddressCount; Index++) {
if (EFI_IP6_EQUAL(&IaAddr->IpAddress, &CurrentIa->IaAddress[Index].IpAddress)) {
return TRUE;
@@ -1301,7 +1303,7 @@ EFI_STATUS
Dhcp6GetMappingTimeOut (
IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg,
OUT UINTN *TimeOut
- )
+ )
{
EFI_STATUS Status;
UINTN DataSize;
@@ -1321,8 +1323,8 @@ Dhcp6GetMappingTimeOut (
if (EFI_ERROR (Status)) {
return Status;
}
-
+
*TimeOut = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + DHCP6_DAD_ADDITIONAL_DELAY;
-
+
return EFI_SUCCESS;
}