/* Calculate the prefix length of the IPv4 subnet mask. */
UINT8 IScsiGetSubnetMaskPrefixLength(IN EFI_IPv4_ADDRESS *SubnetMask)
/* Calculate the prefix length of the IPv4 subnet mask. */
UINT8 IScsiGetSubnetMaskPrefixLength(IN EFI_IPv4_ADDRESS *SubnetMask)
{
  UINT8   Len;
  UINT32  ReverseMask;
  ReverseMask = (SubnetMask->Addr[0] << 24) | (SubnetMask->Addr[1] << 16) | (SubnetMask->Addr[2] << 8) | (SubnetMask->Addr[3]);
  ReverseMask = ~ReverseMask;
  if ((ReverseMask & (ReverseMask + 1)) != 0) {
    return 0;
  }
  Len = 0;
  while (ReverseMask != 0) {
    ReverseMask = ReverseMask >> 1;
    Len++;
  }
  return (UINT8)(32 - Len);
}