Change "Ping" to an action

This commit is contained in:
Tim Young 2018-05-04 12:55:05 -05:00
parent 2890c25083
commit b3f4733248
3 changed files with 19 additions and 4 deletions

View File

@ -109,7 +109,7 @@ namespace EduNetworkBuilder
{ {
public NBAction Action = NBAction.none; public NBAction Action = NBAction.none;
public int SourceID = -1; //used for basically everything public int SourceID = -1; //used for basically everything
public int DestID = -1; //used for pinging, arp, traceroute public NB_IPAddress Destination; //used for pinging, arp, traceroute
public HostNicID SourceNIC; //used for links public HostNicID SourceNIC; //used for links
public HostNicID DestNic; //Used for links public HostNicID DestNic; //Used for links
public Point Location; //Used when making a new device or moving an old device public Point Location; //Used when making a new device or moving an old device
@ -120,7 +120,6 @@ namespace EduNetworkBuilder
{ {
Network myNet = NB.GetNetwork(); Network myNet = NB.GetNetwork();
NetworkDevice source = myNet.GetDeviceFromID(SourceID); NetworkDevice source = myNet.GetDeviceFromID(SourceID);
NetworkDevice dest = myNet.GetDeviceFromID(DestID);
switch (Action) switch (Action)
{ {
@ -142,8 +141,10 @@ namespace EduNetworkBuilder
case NBAction.arp: case NBAction.arp:
break; break;
case NBAction.ping: case NBAction.ping:
source.PingFromHere(Destination) ;
break; break;
case NBAction.traceroute: case NBAction.traceroute:
source.TracerouteFromHere(Destination);
break; break;
} }
} }

View File

@ -1380,6 +1380,19 @@ namespace EduNetworkBuilder
AC.DoAction(); AC.DoAction();
} }
public static void DoActionPingDevice(int HostID, NB_IPAddress Destination)
{
ActionClass AC = new ActionClass();
AC.Action = NBAction.ping;
AC.SourceID = HostID;
AC.Destination = Destination;
RegisterAction(AC);
AC.DoAction();
}
#endregion ActionFunctions #endregion ActionFunctions
} }

View File

@ -1449,7 +1449,8 @@ namespace EduNetworkBuilder
destination = myNetwork.DNSLookup(ItemClickedOn, dest); destination = myNetwork.DNSLookup(ItemClickedOn, dest);
if(destination == null || destination.GetIPString == NB.ZeroIPString) if(destination == null || destination.GetIPString == NB.ZeroIPString)
destination = new NB_IPAddress(dest); destination = new NB_IPAddress(dest);
ItemClickedOn.PingFromHere(destination); //ItemClickedOn.PingFromHere(destination);
NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination);
myNetwork.ProcessPackets(); myNetwork.ProcessPackets();
UpdateMessages(); UpdateMessages();
} }