From 06ca7c59f3614247d425efacdf8795b782db8298 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Mon, 7 May 2018 09:43:50 -0500 Subject: [PATCH] Arp and clearArp as doactions --- EduNetworkBuilder/ActionClass.cs | 4 ++++ EduNetworkBuilder/NB.cs | 27 ++++++++++++++++++++++++++- EduNetworkBuilder/NetworkBuilder.cs | 6 ++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/EduNetworkBuilder/ActionClass.cs b/EduNetworkBuilder/ActionClass.cs index f1f69cb..a87cd74 100644 --- a/EduNetworkBuilder/ActionClass.cs +++ b/EduNetworkBuilder/ActionClass.cs @@ -139,6 +139,10 @@ namespace EduNetworkBuilder case NBAction.dhcp: break; case NBAction.arp: + source.AskArpFromHere(Destination); + break; + case NBAction.cleararp: + source.ClearArps(); break; case NBAction.ping: source.PingFromHere(Destination) ; diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index 0d14ad7..c440cb3 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -104,7 +104,9 @@ namespace EduNetworkBuilder public enum HowToBreak { PowerOff, EthernetBreak, EthernetCorrupt, EthernetRemoveLink, LockOutSwitch, WirelessBreakSSID, WirelessBreakKey, DeviceChangeIP, DeviceChangeGW, StaticRouteClear, StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey, BreakDevice } - public enum NBAction { none, newdevice, changelocation, changedevice, deletecomponent, ping, traceroute, arp, dhcp } + public enum NBAction { none, newdevice, changelocation, changedevice, deletecomponent, + + ping, traceroute, arp, cleararp, dhcp } [Serializable] public struct HostNicID //This holds a unique identifier for a network card. Links use this to know what it is connected to @@ -1405,6 +1407,29 @@ namespace EduNetworkBuilder AC.DoAction(); + } + public static void DoActionArpDevice(int HostID, NB_IPAddress Destination) + { + ActionClass AC = new ActionClass(); + AC.Action = NBAction.arp; + AC.SourceID = HostID; + AC.Destination = Destination; + + RegisterAction(AC); + + AC.DoAction(); + + } + public static void DoActionClearArpDevice(int HostID) + { + ActionClass AC = new ActionClass(); + AC.Action = NBAction.cleararp; + AC.SourceID = HostID; + + RegisterAction(AC); + + AC.DoAction(); + } #endregion ActionFunctions diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 0edfe35..56cb2a0 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -1494,7 +1494,8 @@ namespace EduNetworkBuilder todo = destination.Edit(ItemClickedOn, this, NB.Translate("H_ARP_Title2")); if (todo) { - ItemClickedOn.AskArpFromHere(destination); + //ItemClickedOn.AskArpFromHere(destination); + NB.DoActionArpDevice(ItemClickedOn.GetUniqueIdentifier, destination); myNetwork.ProcessPackets(); UpdateMessages(); } @@ -1503,7 +1504,8 @@ namespace EduNetworkBuilder private void pbNetworkView_ArpClear_Click(object sender, EventArgs e) { if (ItemClickedOn == null) return; //we do not have something chosen to arp request from - ItemClickedOn.ClearArps(); + //ItemClickedOn.ClearArps(); + NB.DoActionClearArpDevice(ItemClickedOn.GetUniqueIdentifier); } private void pbNetworkView_MouseUp(object sender, MouseEventArgs e)