/* Retrieve the Prefix address according to the PrefixLength by clear the useless bits. */
VOID Ip6GetPrefix(IN UINT8 PrefixLength, IN OUT EFI_IPv6_ADDRESS *Prefix)
/* Retrieve the Prefix address according to the PrefixLength by clear the useless bits. */
VOID Ip6GetPrefix(IN UINT8 PrefixLength, IN OUT EFI_IPv6_ADDRESS *Prefix)
{
  UINT8  Byte;
  UINT8  Bit;
  UINT8  Mask;
  UINT8  Value;
  ASSERT ((Prefix != NULL) && (PrefixLength < IP6_PREFIX_MAX));
  if (PrefixLength == 0) {
    ZeroMem (Prefix, sizeof (EFI_IPv6_ADDRESS));
    return;
  }
  if (PrefixLength >= IP6_PREFIX_MAX) {
    return;
  }
  Byte  = (UINT8)(PrefixLength / 8);
  Bit   = (UINT8)(PrefixLength % 8);
  Value = Prefix->Addr[Byte];
  if (Byte > 0) {
    ZeroMem (Prefix->Addr + Byte, 16 - Byte);
  }
  if (Bit > 0) {
    Mask               = (UINT8)(0xFF << (8 - Bit));
    Prefix->Addr[Byte] = (UINT8)(Value & Mask);
  }
}