diff --git a/EduNetworkBuilder/NetTest.cs b/EduNetworkBuilder/NetTest.cs index 4a72d9c..2eb7969 100644 --- a/EduNetworkBuilder/NetTest.cs +++ b/EduNetworkBuilder/NetTest.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Drawing; using System.Xml; using System.Windows.Forms; +using System.Text.RegularExpressions; namespace EduNetworkBuilder { @@ -408,6 +409,23 @@ namespace EduNetworkBuilder TaskWasDone = true; } + + public string GetInterfaceFromVLANInterfaceRequirement() + { + Match result = Regex.Match(dHost, @"(?[A-z:0-9]+) - (?\d+)"); + if (result.Groups["interface"] != null) return result.Groups["interface"].Value; + return ""; + } + + public int GetIDFromVLANInterfaceRequirement() + { + int answer = -1; + Match result = Regex.Match(dHost, @"(?[A-z:0-9]+) - (?\d+)"); + if (result.Groups["id"] != null) int.TryParse( result.Groups["id"].Value, out answer); + return answer; + } + + /// /// See if the test has been solved /// diff --git a/EduNetworkBuilder/NetTestEditor.cs b/EduNetworkBuilder/NetTestEditor.cs index 2698a7d..65da075 100644 --- a/EduNetworkBuilder/NetTestEditor.cs +++ b/EduNetworkBuilder/NetTestEditor.cs @@ -197,6 +197,25 @@ namespace EduNetworkBuilder } } } + else if (ToEdit.TheTest == NetTestType.NeedsForbiddenVLAN || + ToEdit.TheTest == NetTestType.NeedsTaggedVLAN || + ToEdit.TheTest == NetTestType.NeedsUntaggedVLAN ) + { + sItem = theNet.GetDeviceFromName(ToEdit.sHost); + foreach (string nname in sItem.NICNames()) + { + NetworkCard nic = sItem.NicFromName(nname); + if (!nic.NicCanDoVLANs()) continue; + for (int i = 0; i < nic.IFCount; i++) + { + NetworkInterface nif = nic.GetInterface(i); + foreach (VLANName vn in theNet.VlanNames) + { + cbDest.Items.Add(nif.nic_name + " - " + vn.ID.ToString()); + } + } + } + } else { //List all the hosts foreach (string host in HostNames) @@ -265,7 +284,7 @@ namespace EduNetworkBuilder if (ntt == NetTestType.LockAll || ntt == NetTestType.LockDHCP || ntt == NetTestType.LockIP || ntt == NetTestType.LockNic || ntt == NetTestType.LockRoute) return true; - if(ntt == NetTestType.NeedsRouteToNet) + if (ntt == NetTestType.NeedsRouteToNet) { //We should have a network, not a host. } @@ -273,11 +292,21 @@ namespace EduNetworkBuilder { //This uses a verbosity } - else if(ntt == NetTestType.LockInterfaceVLAN || ntt == NetTestType.LockNicVLAN || + else if (ntt == NetTestType.LockInterfaceVLAN || ntt == NetTestType.LockNicVLAN || ntt == NetTestType.LockVLANNames || ntt == NetTestType.LockVLANsOnHost) { return true; } + else if (ntt == NetTestType.NeedsUntaggedVLAN || ntt == NetTestType.NeedsTaggedVLAN || + ntt == NetTestType.NeedsForbiddenVLAN) + { + //We have an interface and a network ID. Verify they exist + if (cbDest.SelectedIndex < 0) return false; + Match result = Regex.Match(cbDest.SelectedItem.ToString(), @"(?[A-z:0-9]+) - (?\d+)"); + if (result.Groups["interface"] != null && result.Groups["id"] != null) + return true; + return false; + } else { if (ntt == NetTestType.SuccessfullyPings) return true; diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index f30ac75..027edc6 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -906,6 +906,8 @@ namespace EduNetworkBuilder { if (Size > 200) Size = 200; if (Size < 10) Size = 10; + + DateTime Test = DateTime.UtcNow + TimeSpan.FromMilliseconds(100); }