/* Check VLAN configuration variable and delete the duplicative content if has identical Vlan ID. */
EFI_STATUS MnpCheckVlanVariable(IN MNP_DEVICE_DATA *MnpDeviceData, IN VLAN_TCI *Buffer, IN UINTN NumberOfVlan, OUT UINTN *NewNumberOfVlan)
/* Check VLAN configuration variable and delete the duplicative content if has identical Vlan ID. */
EFI_STATUS MnpCheckVlanVariable(IN MNP_DEVICE_DATA *MnpDeviceData, IN VLAN_TCI *Buffer, IN UINTN NumberOfVlan, OUT UINTN *NewNumberOfVlan)
{
  UINTN       Index;
  UINTN       Index2;
  UINTN       Count;
  BOOLEAN     FoundDuplicateItem;
  EFI_STATUS  Status;
  Count              = 0;
  FoundDuplicateItem = FALSE;
  Status             = EFI_SUCCESS;
  for (Index = 0; Index < NumberOfVlan; Index++) {
    for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) {
      if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) {
        FoundDuplicateItem = TRUE;
        Count++;
        break;
      }
    }
    if (FoundDuplicateItem) {
      for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) {
        CopyMem (Buffer + Index, Buffer + Index2, sizeof (VLAN_TCI));
      }
    }
    FoundDuplicateItem = FALSE;
  }
  *NewNumberOfVlan = NumberOfVlan - Count;
  if (Count != 0) {
    Status = MnpSetVlanVariable (MnpDeviceData, *NewNumberOfVlan, Buffer);
  }
  return Status;
}