make it so we can lock ourselves out of a switch

This commit is contained in:
Tim Young 2017-08-27 17:22:26 -05:00
parent d3b6abf1e1
commit e58a75d84e
5 changed files with 34 additions and 1 deletions

View File

@ -1963,6 +1963,7 @@ namespace EduNetworkBuilder
break;
case HowToBreak.LockOutSwitch:
//Lock it out
if (tDevice.DoesForwarding()) tDevice.LockUsOutOfDevice();
break;
case HowToBreak.StaticRouteClear:
//Clear out the static route(s)

View File

@ -2170,7 +2170,7 @@ namespace EduNetworkBuilder
TraversalCollection.Sort((a, b) => b.Count.CompareTo(a.Count));
List<HowToBreak> BreakList = new List<HowToBreak>() { HowToBreak.PowerOff, HowToBreak.EthernetBreak };
List<HowToBreak> BreakList = new List<HowToBreak>() { HowToBreak.PowerOff, HowToBreak.EthernetBreak, HowToBreak.LockOutSwitch };
//foreach (HowToBreak one in Enum.GetValues(typeof(HowToBreak)))
// BreakList.Add(one);
count = 0;

View File

@ -785,6 +785,18 @@ namespace EduNetworkBuilder
}
}
public void LockUsOutOfCard()
{
foreach (NetworkInterface nf in interfaces)
{
if (myNicType != NicType.lo)
{
nf.myIP = new IPAddress(NB.ZeroIPString);
nf.LockOutVLANInterface();
}
}
}
public NetworkInterface InterfaceFromVlanTag(Packet tPacket)
{
int ID = tPacket.VLANID;

View File

@ -1381,6 +1381,15 @@ namespace EduNetworkBuilder
IPConnections.Clear();
}
public void LockUsOutOfDevice()
{
foreach(NetworkCard nic in NICs)
{
if (nic.GetNicType == NicType.lo) continue;
nic.LockUsOutOfCard();
}
}
public ResponseToPacket HowToRespondToPacket(Packet tPacket)
{
bool typesMatch=false;

View File

@ -127,6 +127,17 @@ namespace EduNetworkBuilder
VLANs.Add(new VLANInfo(id, Tag));
}
public void LockOutVLANInterface()
{
Network theNet = NB.GetNetwork();
if (theNet == null)
return;
foreach(VLANName one in theNet.VlanNames)
{
SetVLANTag(one.ID, VLANTagType.Forbidden);
}
}
public void Save(XmlWriter writer)
{
writer.WriteStartElement("interface");