From 58ce4f64fabcfc861fef4e41fa7779343158bb36 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Tue, 25 Oct 2016 13:22:33 -0500 Subject: [PATCH] Vlan tests are working --- EduNetworkBuilder/NetTest.cs | 23 +++++++++++++++++++++++ EduNetworkBuilder/NetworkCard.cs | 10 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/EduNetworkBuilder/NetTest.cs b/EduNetworkBuilder/NetTest.cs index 2eb7969..4c42169 100644 --- a/EduNetworkBuilder/NetTest.cs +++ b/EduNetworkBuilder/NetTest.cs @@ -504,6 +504,29 @@ namespace EduNetworkBuilder if (srvr == shouldbe) return true; break; + case NetTestType.NeedsForbiddenVLAN: + case NetTestType.NeedsTaggedVLAN: + case NetTestType.NeedsUntaggedVLAN: + if (Source == null) return false; //Unable to do it. Do not count it against them. + string ifname = GetInterfaceFromVLANInterfaceRequirement(); + if (ifname == "") return false; //unable to do it. + string nicname = Regex.Replace(ifname, @":\w*",""); + int id = GetIDFromVLANInterfaceRequirement(); + //Find the nic + NetworkCard nic = Source.NicFromName(nicname); + if (nic == null) return false; //no matching nic + //find the interface + NetworkInterface nif = nic.InterfaceFromName(ifname); + if (nif == null) return false; //no matchint interface + + //find the entry for the vlan + VLANInfo vi = nif.GetVLANInfo(id); + if (vi == null) return false; //No such vlan or something. + if (TheTest == NetTestType.NeedsForbiddenVLAN && vi.Tag == VLANTagType.Forbidden) return true; + if (TheTest == NetTestType.NeedsUntaggedVLAN && vi.Tag == VLANTagType.Untagged) return true; + if (TheTest == NetTestType.NeedsTaggedVLAN && vi.Tag == VLANTagType.Tagged) return true; + return false; + break; case NetTestType.LockAll: case NetTestType.LockDHCP: case NetTestType.LockIP: diff --git a/EduNetworkBuilder/NetworkCard.cs b/EduNetworkBuilder/NetworkCard.cs index 06e23f0..a2b08e8 100644 --- a/EduNetworkBuilder/NetworkCard.cs +++ b/EduNetworkBuilder/NetworkCard.cs @@ -769,6 +769,16 @@ namespace EduNetworkBuilder return null; } + public NetworkInterface InterfaceFromName(string InterfaceName) + { + foreach (NetworkInterface oneIF in interfaces) + { + if (oneIF.nic_name == InterfaceName) + return oneIF; + } + return null; + } + public IPAddress FirstIP() { List addresses = IPAddressList();