From 6889f92fc71562165e7c0397e47087818a01148b Mon Sep 17 00:00:00 2001 From: Tim Young Date: Tue, 8 Dec 2020 15:38:19 -0700 Subject: [PATCH] Global search and fixing functions to use NB_IPAddress.isZeroIPString --- EduNetworkBuilder/IPAddressEntry.cs | 2 +- EduNetworkBuilder/NetTest.cs | 4 ++-- EduNetworkBuilder/Network.cs | 6 +++--- EduNetworkBuilder/NetworkBuilder.cs | 6 +++--- EduNetworkBuilder/NetworkDevice.cs | 9 +++++---- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/EduNetworkBuilder/IPAddressEntry.cs b/EduNetworkBuilder/IPAddressEntry.cs index 70bf153..4227075 100644 --- a/EduNetworkBuilder/IPAddressEntry.cs +++ b/EduNetworkBuilder/IPAddressEntry.cs @@ -53,7 +53,7 @@ namespace EduNetworkBuilder string hostname = ""; if (ToEdit != null) hostname = ToEdit.hostname; - if (toEdit.GetIP.ToIpString() == NB.ZeroIPString) + if (toEdit.IsZeroString()) { string lIP = lastIP.GetIP.ToIpString(); string lNM = lastIP.GetMask.ToIpString(); diff --git a/EduNetworkBuilder/NetTest.cs b/EduNetworkBuilder/NetTest.cs index fdfd45e..34bf618 100644 --- a/EduNetworkBuilder/NetTest.cs +++ b/EduNetworkBuilder/NetTest.cs @@ -513,7 +513,7 @@ namespace EduNetworkBuilder case NetTestType.NeedsRouteToNet: if (Source == null) return false; //Unable to do it. Do not count it against them. tAddr = theNet.DNSLookup(Source,dHost); - if (tAddr == null || tAddr.GetIPString == NB.ZeroIPString) + if (tAddr == null || tAddr.IsZeroString()) tAddr = new NB_IPAddress(dHost); if (Source.HasRouteMatching(tAddr)) { @@ -531,7 +531,7 @@ namespace EduNetworkBuilder if (Dest.HasIPAddress(tAddr)) return false; //They gave the same address to the source that the dest has. if (!theNet.HasUniqueIP(tAddr, Source)) return false; //Verify we have not given the IP to someone else if (tAddr != null && - tAddr.GetIPString != NB.ZeroIPString) + !tAddr.IsZeroString()) { if(dAddress != null & dAddress.GetMask == tAddr.GetMask) return true; diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index 3f301cb..e9347ec 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -2427,7 +2427,7 @@ namespace EduNetworkBuilder src = GetDeviceFromName(NT.sHost); if (src == null) continue; destination = DNSLookup(src, NT.dHost); - if (destination == null || destination.GetIPString == NB.ZeroIPString) + if (destination == null || destination.IsZeroString()) destination = new NB_IPAddress(NT.dHost); src.PingFromHere(destination); break; @@ -2435,7 +2435,7 @@ namespace EduNetworkBuilder src = GetDeviceFromName(NT.sHost); if (src == null) continue; destination = DNSLookup(src, NT.dHost); - if (destination == null || destination.GetIPString == NB.ZeroIPString) + if (destination == null || destination.IsZeroString()) destination = new NB_IPAddress(NT.dHost); src.AskArpFromHere(destination); break; @@ -2443,7 +2443,7 @@ namespace EduNetworkBuilder src = GetDeviceFromName(NT.sHost); if (src == null) continue; destination = DNSLookup(src, NT.dHost); - if (destination == null || destination.GetIPString == NB.ZeroIPString) + if (destination == null || destination.IsZeroString()) destination = new NB_IPAddress(NT.dHost); src.TracerouteFromHere(destination); break; diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 0967b0d..296163d 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -1624,7 +1624,7 @@ namespace EduNetworkBuilder string dest = (string)Pressed.Tag; NB_IPAddress destination; destination = myNetwork.DNSLookup(ItemClickedOn, dest); - if (destination == null || destination.GetIPString == NB.ZeroIPString) + if (destination == null || destination.IsZeroString()) destination = new NB_IPAddress(dest); //ItemClickedOn.PingFromHere(destination); NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination); @@ -1640,7 +1640,7 @@ namespace EduNetworkBuilder string dest = (string)Pressed.Tag; NB_IPAddress destination; destination = myNetwork.DNSLookup(ItemClickedOn, dest); - if (destination == null || destination.GetIPString == NB.ZeroIPString) + if (destination == null || destination.IsZeroString()) destination = new NB_IPAddress(dest); //ItemClickedOn.TracerouteFromHere(destination); NB.DoActionTracertDevice(ItemClickedOn.GetUniqueIdentifier, destination); @@ -1656,7 +1656,7 @@ namespace EduNetworkBuilder string dest = (string)Pressed.Tag; NB_IPAddress destination; destination = myNetwork.DNSLookup(ItemClickedOn, dest); - if (destination == null || destination.GetIPString == NB.ZeroIPString) + if (destination == null || destination.IsZeroString()) destination = new NB_IPAddress(dest); NB.DoActionArpDevice(ItemClickedOn.GetUniqueIdentifier, destination); //ItemClickedOn.AskArpFromHere(destination); diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index 9cc760d..683a308 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -1672,7 +1672,7 @@ namespace EduNetworkBuilder public bool HasRouteMatching(string destString) { NB_IPAddress dest = new NB_IPAddress(destString); - if (dest.GetIPString == NB.ZeroIPString) return false; + if (dest.IsZeroString()) return false; return HasRouteMatching(dest); } @@ -2119,7 +2119,7 @@ namespace EduNetworkBuilder //It was destined for here, or it is starting from scratch. See if we need to route it. if (tPacket.destIP == null) tPacket.destIP = new NB_IPAddress(NB.ZeroIPString); NB_IPAddress dest = DestinationFromIP(tPacket.destIP); //Get the IP, or GW - if(dest.GetIPString == NB.ZeroIPString && !tPacket.destIP.IsBroadcast()) + if(dest.IsZeroString() && !tPacket.destIP.IsBroadcast()) { //No gateway set and no route... string errString = string.Format(NB.Translate("ND_NoRouteStr"), hostname, tPacket.destIP.GetIPString); @@ -2424,7 +2424,7 @@ namespace EduNetworkBuilder nPacket.sourceIP = new NB_IPAddress(NB.ZeroIPString); nPacket.TsourceIP = new NB_IPAddress(NB.ZeroIPString); } - if (tip.GetIP.ToIpString() != NB.ZeroIPString) + if (!tip.IsZeroString()) nPacket.destIP = tip; if (tPacket.isFresh) { @@ -3419,7 +3419,8 @@ namespace EduNetworkBuilder { ArpTable.Add(AE); } - if(IPFromArp(mac) != ip && ip != NB.ZeroIPString) + NB_IPAddress tAddress = new NB_IPAddress(ip); + if(IPFromArp(mac) != ip && !tAddress.IsZeroString()) { foreach (ArpEntry arp in ArpTable.ToList()) {