/* Calculate the lease time by the algorithm defined in rfc. */
VOID Dhcp6CalculateLeaseTime(IN DHCP6_IA_CB *IaCb)
/* Calculate the lease time by the algorithm defined in rfc. */
VOID Dhcp6CalculateLeaseTime(IN DHCP6_IA_CB *IaCb)
{
  UINT32  MinLt;
  UINT32  MaxLt;
  UINTN   Index;
  ASSERT (IaCb->Ia->IaAddressCount > 0);
  MinLt = (UINT32)(-1);
  MaxLt = 0;
  for (Index = 0; Index < IaCb->Ia->IaAddressCount; Index++) {
    MinLt = MIN (MinLt, IaCb->Ia->IaAddress[Index].ValidLifetime);
    MaxLt = MAX (MinLt, IaCb->Ia->IaAddress[Index].ValidLifetime);
  }
  IaCb->T1            = (IaCb->T1 != 0) ? IaCb->T1 : (UINT32)(MinLt * 5 / 10);
  IaCb->T2            = (IaCb->T2 != 0) ? IaCb->T2 : (UINT32)(MinLt * 8 / 10);
  IaCb->AllExpireTime = MaxLt;
  IaCb->LeaseTime     = 0;
}