Fix bug with replays and VLANs

This commit is contained in:
Tim Young 2018-10-17 15:23:30 -05:00
parent 811339b176
commit b74f9932bb
3 changed files with 37 additions and 2 deletions

View File

@ -924,6 +924,14 @@ namespace EduNetworkBuilder
} }
} }
public void UpdateAllNicsVLANInfoAfterClone()
{
foreach (NetworkInterface nf in interfaces)
{
nf.UpdateVLANsAfterClone();
}
}
public void LockUsOutOfCard() public void LockUsOutOfCard()
{ {
foreach (NetworkInterface nf in interfaces) foreach (NetworkInterface nf in interfaces)

View File

@ -1535,6 +1535,7 @@ namespace EduNetworkBuilder
NICs.Clear(); NICs.Clear();
foreach(NetworkCard nic in ndCopyFrom.NICs) foreach(NetworkCard nic in ndCopyFrom.NICs)
{ {
nic.UpdateAllNicsVLANInfoAfterClone();
NICs.Add(NetworkCard.Clone(nic)); NICs.Add(NetworkCard.Clone(nic));
} }

View File

@ -69,14 +69,40 @@ namespace EduNetworkBuilder
} }
} }
/// <summary>
/// When we are doing replays and we load in a network interface using reflection,
/// it can create a duplicate VLAN tag (1,untagged). Rebuilding these fixes that.
/// </summary>
public void UpdateVLANsAfterClone()
{
List<VLANInfo> tmpVLANs = new List<VLANInfo>();
tmpVLANs.AddRange(VLANs);
VLANs.Clear();
foreach(VLANInfo VLI in tmpVLANs)
{
bool found = false;
foreach(VLANInfo VLI2 in VLANs)
{
if(VLI2.ID == VLI.ID)
{
VLI2.Tag = VLI.Tag;
found = true;
}
}
if (!found)
VLANs.Add(VLI);
}
}
public VLANInfo GetVLANInfo(int id) public VLANInfo GetVLANInfo(int id)
{ {
VLANInfo status = null;
foreach(VLANInfo one in VLANs) foreach(VLANInfo one in VLANs)
{ {
if (one.ID == id) if (one.ID == id)
return one; status = one;
} }
return null; return status;
} }
public bool Equals(NetworkInterface CompareWith) public bool Equals(NetworkInterface CompareWith)