/* Search the list array to find an IP6 prefix list entry. */
IP6_PREFIX_LIST_ENTRY* Ip6FindPrefixListEntry(IN IP6_SERVICE *IpSb, IN BOOLEAN OnLinkOrAuto, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *Prefix)
/* Search the list array to find an IP6 prefix list entry. */
IP6_PREFIX_LIST_ENTRY* Ip6FindPrefixListEntry(IN IP6_SERVICE *IpSb, IN BOOLEAN OnLinkOrAuto, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *Prefix)
{
  IP6_PREFIX_LIST_ENTRY  *PrefixList;
  LIST_ENTRY             *Entry;
  LIST_ENTRY             *ListHead;
  NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
  ASSERT (Prefix != NULL);
  if (OnLinkOrAuto) {
    ListHead = &IpSb->OnlinkPrefix;
  } else {
    ListHead = &IpSb->AutonomousPrefix;
  }
  NET_LIST_FOR_EACH (Entry, ListHead) {
    PrefixList = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link);
    if (PrefixLength != 255) {
      if ((PrefixList->PrefixLength == PrefixLength) &&
          NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixLength))
      {
        return PrefixList;
      }
    } else {
      if (NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixList->PrefixLength)) {
        return PrefixList;
      }
    }
  }
  return NULL;
}