Vlan tests are working

This commit is contained in:
Tim Young 2016-10-25 13:22:33 -05:00
parent c45b8ba221
commit 58ce4f64fa
2 changed files with 33 additions and 0 deletions

View File

@ -504,6 +504,29 @@ namespace EduNetworkBuilder
if (srvr == shouldbe) if (srvr == shouldbe)
return true; return true;
break; 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.LockAll:
case NetTestType.LockDHCP: case NetTestType.LockDHCP:
case NetTestType.LockIP: case NetTestType.LockIP:

View File

@ -769,6 +769,16 @@ namespace EduNetworkBuilder
return null; return null;
} }
public NetworkInterface InterfaceFromName(string InterfaceName)
{
foreach (NetworkInterface oneIF in interfaces)
{
if (oneIF.nic_name == InterfaceName)
return oneIF;
}
return null;
}
public IPAddress FirstIP() public IPAddress FirstIP()
{ {
List<IPAddress> addresses = IPAddressList(); List<IPAddress> addresses = IPAddressList();