Global search and fixing functions to use NB_IPAddress.isZeroIPString

This commit is contained in:
Tim Young 2020-12-08 15:38:19 -07:00
parent 8a906bad5f
commit 6889f92fc7
5 changed files with 14 additions and 13 deletions

View File

@ -53,7 +53,7 @@ namespace EduNetworkBuilder
string hostname = ""; string hostname = "";
if (ToEdit != null) if (ToEdit != null)
hostname = ToEdit.hostname; hostname = ToEdit.hostname;
if (toEdit.GetIP.ToIpString() == NB.ZeroIPString) if (toEdit.IsZeroString())
{ {
string lIP = lastIP.GetIP.ToIpString(); string lIP = lastIP.GetIP.ToIpString();
string lNM = lastIP.GetMask.ToIpString(); string lNM = lastIP.GetMask.ToIpString();

View File

@ -513,7 +513,7 @@ namespace EduNetworkBuilder
case NetTestType.NeedsRouteToNet: case NetTestType.NeedsRouteToNet:
if (Source == null) return false; //Unable to do it. Do not count it against them. if (Source == null) return false; //Unable to do it. Do not count it against them.
tAddr = theNet.DNSLookup(Source,dHost); tAddr = theNet.DNSLookup(Source,dHost);
if (tAddr == null || tAddr.GetIPString == NB.ZeroIPString) if (tAddr == null || tAddr.IsZeroString())
tAddr = new NB_IPAddress(dHost); tAddr = new NB_IPAddress(dHost);
if (Source.HasRouteMatching(tAddr)) 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 (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 (!theNet.HasUniqueIP(tAddr, Source)) return false; //Verify we have not given the IP to someone else
if (tAddr != null && if (tAddr != null &&
tAddr.GetIPString != NB.ZeroIPString) !tAddr.IsZeroString())
{ {
if(dAddress != null & dAddress.GetMask == tAddr.GetMask) if(dAddress != null & dAddress.GetMask == tAddr.GetMask)
return true; return true;

View File

@ -2427,7 +2427,7 @@ namespace EduNetworkBuilder
src = GetDeviceFromName(NT.sHost); src = GetDeviceFromName(NT.sHost);
if (src == null) continue; if (src == null) continue;
destination = DNSLookup(src, NT.dHost); destination = DNSLookup(src, NT.dHost);
if (destination == null || destination.GetIPString == NB.ZeroIPString) if (destination == null || destination.IsZeroString())
destination = new NB_IPAddress(NT.dHost); destination = new NB_IPAddress(NT.dHost);
src.PingFromHere(destination); src.PingFromHere(destination);
break; break;
@ -2435,7 +2435,7 @@ namespace EduNetworkBuilder
src = GetDeviceFromName(NT.sHost); src = GetDeviceFromName(NT.sHost);
if (src == null) continue; if (src == null) continue;
destination = DNSLookup(src, NT.dHost); destination = DNSLookup(src, NT.dHost);
if (destination == null || destination.GetIPString == NB.ZeroIPString) if (destination == null || destination.IsZeroString())
destination = new NB_IPAddress(NT.dHost); destination = new NB_IPAddress(NT.dHost);
src.AskArpFromHere(destination); src.AskArpFromHere(destination);
break; break;
@ -2443,7 +2443,7 @@ namespace EduNetworkBuilder
src = GetDeviceFromName(NT.sHost); src = GetDeviceFromName(NT.sHost);
if (src == null) continue; if (src == null) continue;
destination = DNSLookup(src, NT.dHost); destination = DNSLookup(src, NT.dHost);
if (destination == null || destination.GetIPString == NB.ZeroIPString) if (destination == null || destination.IsZeroString())
destination = new NB_IPAddress(NT.dHost); destination = new NB_IPAddress(NT.dHost);
src.TracerouteFromHere(destination); src.TracerouteFromHere(destination);
break; break;

View File

@ -1624,7 +1624,7 @@ namespace EduNetworkBuilder
string dest = (string)Pressed.Tag; string dest = (string)Pressed.Tag;
NB_IPAddress destination; NB_IPAddress destination;
destination = myNetwork.DNSLookup(ItemClickedOn, dest); destination = myNetwork.DNSLookup(ItemClickedOn, dest);
if (destination == null || destination.GetIPString == NB.ZeroIPString) if (destination == null || destination.IsZeroString())
destination = new NB_IPAddress(dest); destination = new NB_IPAddress(dest);
//ItemClickedOn.PingFromHere(destination); //ItemClickedOn.PingFromHere(destination);
NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination); NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination);
@ -1640,7 +1640,7 @@ namespace EduNetworkBuilder
string dest = (string)Pressed.Tag; string dest = (string)Pressed.Tag;
NB_IPAddress destination; NB_IPAddress destination;
destination = myNetwork.DNSLookup(ItemClickedOn, dest); destination = myNetwork.DNSLookup(ItemClickedOn, dest);
if (destination == null || destination.GetIPString == NB.ZeroIPString) if (destination == null || destination.IsZeroString())
destination = new NB_IPAddress(dest); destination = new NB_IPAddress(dest);
//ItemClickedOn.TracerouteFromHere(destination); //ItemClickedOn.TracerouteFromHere(destination);
NB.DoActionTracertDevice(ItemClickedOn.GetUniqueIdentifier, destination); NB.DoActionTracertDevice(ItemClickedOn.GetUniqueIdentifier, destination);
@ -1656,7 +1656,7 @@ namespace EduNetworkBuilder
string dest = (string)Pressed.Tag; string dest = (string)Pressed.Tag;
NB_IPAddress destination; NB_IPAddress destination;
destination = myNetwork.DNSLookup(ItemClickedOn, dest); destination = myNetwork.DNSLookup(ItemClickedOn, dest);
if (destination == null || destination.GetIPString == NB.ZeroIPString) if (destination == null || destination.IsZeroString())
destination = new NB_IPAddress(dest); destination = new NB_IPAddress(dest);
NB.DoActionArpDevice(ItemClickedOn.GetUniqueIdentifier, destination); NB.DoActionArpDevice(ItemClickedOn.GetUniqueIdentifier, destination);
//ItemClickedOn.AskArpFromHere(destination); //ItemClickedOn.AskArpFromHere(destination);

View File

@ -1672,7 +1672,7 @@ namespace EduNetworkBuilder
public bool HasRouteMatching(string destString) public bool HasRouteMatching(string destString)
{ {
NB_IPAddress dest = new NB_IPAddress(destString); NB_IPAddress dest = new NB_IPAddress(destString);
if (dest.GetIPString == NB.ZeroIPString) return false; if (dest.IsZeroString()) return false;
return HasRouteMatching(dest); 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. //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); if (tPacket.destIP == null) tPacket.destIP = new NB_IPAddress(NB.ZeroIPString);
NB_IPAddress dest = DestinationFromIP(tPacket.destIP); //Get the IP, or GW 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... //No gateway set and no route...
string errString = string.Format(NB.Translate("ND_NoRouteStr"), hostname, tPacket.destIP.GetIPString); 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.sourceIP = new NB_IPAddress(NB.ZeroIPString);
nPacket.TsourceIP = new NB_IPAddress(NB.ZeroIPString); nPacket.TsourceIP = new NB_IPAddress(NB.ZeroIPString);
} }
if (tip.GetIP.ToIpString() != NB.ZeroIPString) if (!tip.IsZeroString())
nPacket.destIP = tip; nPacket.destIP = tip;
if (tPacket.isFresh) if (tPacket.isFresh)
{ {
@ -3419,7 +3419,8 @@ namespace EduNetworkBuilder
{ {
ArpTable.Add(AE); 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()) foreach (ArpEntry arp in ArpTable.ToList())
{ {