/* Calculate how many bits are the same between two IPv6 addresses. */
UINT8 Ip6CommonPrefixLen(IN EFI_IPv6_ADDRESS *AddressA, IN EFI_IPv6_ADDRESS *AddressB)
/* Calculate how many bits are the same between two IPv6 addresses. */
UINT8 Ip6CommonPrefixLen(IN EFI_IPv6_ADDRESS *AddressA, IN EFI_IPv6_ADDRESS *AddressB)
{
  UINT8  Count;
  UINT8  Index;
  UINT8  ByteA;
  UINT8  ByteB;
  UINT8  NumBits;
  Count = 0;
  Index = 0;
  while (Index < 16) {
    ByteA = AddressA->Addr[Index];
    ByteB = AddressB->Addr[Index];
    if (ByteA == ByteB) {
      Count += 8;
      Index++;
      continue;
    }
    NumBits = 8;
    ByteA   = (UINT8)(ByteA ^ ByteB);
    while (ByteA != 0) {
      NumBits--;
      ByteA = (UINT8)(ByteA >> 1);
    }
    return (UINT8)(Count + NumBits);
  }
  return Count;
}