vlan tagging tests

This commit is contained in:
Tim Young 2016-10-24 19:42:41 -05:00
parent 907fdc17dd
commit c45b8ba221
3 changed files with 51 additions and 2 deletions

View File

@ -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, @"(?<interface>[A-z:0-9]+) - (?<id>\d+)");
if (result.Groups["interface"] != null) return result.Groups["interface"].Value;
return "";
}
public int GetIDFromVLANInterfaceRequirement()
{
int answer = -1;
Match result = Regex.Match(dHost, @"(?<interface>[A-z:0-9]+) - (?<id>\d+)");
if (result.Groups["id"] != null) int.TryParse( result.Groups["id"].Value, out answer);
return answer;
}
/// <summary>
/// See if the test has been solved
/// </summary>

View File

@ -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(), @"(?<interface>[A-z:0-9]+) - (?<id>\d+)");
if (result.Groups["interface"] != null && result.Groups["id"] != null)
return true;
return false;
}
else
{
if (ntt == NetTestType.SuccessfullyPings) return true;

View File

@ -906,6 +906,8 @@ namespace EduNetworkBuilder
{
if (Size > 200) Size = 200;
if (Size < 10) Size = 10;
DateTime Test = DateTime.UtcNow + TimeSpan.FromMilliseconds(100);
}