Rename IPAddress class to NB_IPAddress. We will be using the System.Net.IPAddress class and do not want to have a conflict.

This commit is contained in:
Tim Young 2018-03-09 15:47:33 -06:00
parent 0368d6d0f9
commit f3df4f525a
13 changed files with 202 additions and 202 deletions

View File

@ -11,7 +11,7 @@ using System.Text.RegularExpressions;
namespace EduNetworkBuilder namespace EduNetworkBuilder
{ {
[Serializable] [Serializable]
public class IPAddress public class NB_IPAddress
{ {
private UInt32 _ip; private UInt32 _ip;
@ -19,14 +19,14 @@ namespace EduNetworkBuilder
private UInt32 _gw; private UInt32 _gw;
private IPAddressType myType; private IPAddressType myType;
public IPAddress(string ip, string mask, IPAddressType WhatType) public NB_IPAddress(string ip, string mask, IPAddressType WhatType)
{ {
myType = WhatType; myType = WhatType;
_ip = ip.ParseIp(); _ip = ip.ParseIp();
_mask = mask.ParseIp(); _mask = mask.ParseIp();
} }
public IPAddress(string ip, string mask, string gw) public NB_IPAddress(string ip, string mask, string gw)
{ {
myType = IPAddressType.route; myType = IPAddressType.route;
_ip = ip.ParseIp(); _ip = ip.ParseIp();
@ -34,7 +34,7 @@ namespace EduNetworkBuilder
_gw = gw.ParseIp(); _gw = gw.ParseIp();
} }
public IPAddress(XmlNode theNode) public NB_IPAddress(XmlNode theNode)
{ {
foreach (XmlNode Individual in theNode.ChildNodes) foreach (XmlNode Individual in theNode.ChildNodes)
{ {
@ -87,7 +87,7 @@ namespace EduNetworkBuilder
get { return myType; } get { return myType; }
} }
public bool IsLocal(IPAddress dest) public bool IsLocal(NB_IPAddress dest)
{ {
if (dest == null) return false; if (dest == null) return false;
UInt32 answer = dest.GetIP & _mask; UInt32 answer = dest.GetIP & _mask;
@ -105,13 +105,13 @@ namespace EduNetworkBuilder
return IPe.Edit(); return IPe.Edit();
} }
public bool Edit(NetworkDevice FromWhat, IPAddress DHCPif, Form ParentForm, bool JustPinging = false) public bool Edit(NetworkDevice FromWhat, NB_IPAddress DHCPif, Form ParentForm, bool JustPinging = false)
{ {
IPAddressEntry IPe = new IPAddressEntry(this, FromWhat, ParentForm, JustPinging); IPAddressEntry IPe = new IPAddressEntry(this, FromWhat, ParentForm, JustPinging);
return IPe.Edit(FromWhat, DHCPif); return IPe.Edit(FromWhat, DHCPif);
} }
public IPAddress(string ip) public NB_IPAddress(string ip)
{ {
if (ip == null) ip = NB.ZeroIPString; if (ip == null) ip = NB.ZeroIPString;
myType = IPAddressType.ip; myType = IPAddressType.ip;
@ -292,57 +292,57 @@ namespace EduNetworkBuilder
return neworder; return neworder;
} }
public IPAddress BreakIPNetmaskZero() public NB_IPAddress BreakIPNetmaskZero()
{ {
IPAddress one = new IPAddress(GetIPString, "0.0.0.0", myType); NB_IPAddress one = new NB_IPAddress(GetIPString, "0.0.0.0", myType);
return one; return one;
} }
public IPAddress BreakIPNetmask32() public NB_IPAddress BreakIPNetmask32()
{ {
IPAddress one = new IPAddress(GetIPString, "255.255.255.255", myType); NB_IPAddress one = new NB_IPAddress(GetIPString, "255.255.255.255", myType);
return one; return one;
} }
public IPAddress BreakIPNetmaskRandom() public NB_IPAddress BreakIPNetmaskRandom()
{ {
string randomMask = ""; string randomMask = "";
do do
{ {
randomMask = GenRandomIPOrMask(); randomMask = GenRandomIPOrMask();
} while (randomMask == GetMaskString); } while (randomMask == GetMaskString);
IPAddress one = new IPAddress(GetIPString, randomMask, myType); NB_IPAddress one = new NB_IPAddress(GetIPString, randomMask, myType);
return one; return one;
} }
public IPAddress BreakIPNetmaskMangle() public NB_IPAddress BreakIPNetmaskMangle()
{ {
string newmask = randomizeOctects(GetMaskString); string newmask = randomizeOctects(GetMaskString);
IPAddress one = new IPAddress(GetIPString, newmask, myType); NB_IPAddress one = new NB_IPAddress(GetIPString, newmask, myType);
return one; return one;
} }
public IPAddress BreakIPAddressZero() public NB_IPAddress BreakIPAddressZero()
{ {
IPAddress one = new IPAddress("0.0.0.0", GetIPString, myType); NB_IPAddress one = new NB_IPAddress("0.0.0.0", GetIPString, myType);
return one; return one;
} }
public IPAddress BreakIPAddress32() public NB_IPAddress BreakIPAddress32()
{ {
IPAddress one = new IPAddress("255.255.255.255", GetIPString, myType); NB_IPAddress one = new NB_IPAddress("255.255.255.255", GetIPString, myType);
return one; return one;
} }
public IPAddress BreakIPAddressRandom() public NB_IPAddress BreakIPAddressRandom()
{ {
string randomIP = ""; string randomIP = "";
do do
{ {
randomIP = GenRandomIPOrMask(); randomIP = GenRandomIPOrMask();
} while (randomIP == GetMaskString); } while (randomIP == GetMaskString);
IPAddress one = new IPAddress(randomIP, GetMaskString, myType); NB_IPAddress one = new NB_IPAddress(randomIP, GetMaskString, myType);
return one; return one;
} }
public IPAddress BreakIPAddressMangle() public NB_IPAddress BreakIPAddressMangle()
{ {
string newip = randomizeOctects(GetMaskString); string newip = randomizeOctects(GetMaskString);
IPAddress one = new IPAddress(newip, GetMaskString, myType); NB_IPAddress one = new NB_IPAddress(newip, GetMaskString, myType);
return one; return one;
} }
#endregion #endregion

View File

@ -15,14 +15,14 @@ namespace EduNetworkBuilder
{ {
public partial class IPAddressEntry : Form public partial class IPAddressEntry : Form
{ {
IPAddress WhatToEdit; NB_IPAddress WhatToEdit;
IPAddress DHCPInterface=null; NB_IPAddress DHCPInterface=null;
bool WellDone = true; bool WellDone = true;
NetworkDevice ParentDevice = null; NetworkDevice ParentDevice = null;
Point StartLocation = new Point (50,50); Point StartLocation = new Point (50,50);
public IPAddressEntry(IPAddress toEdit, NetworkDevice ToEdit, Form ParentForm, bool JustPinging=false) public IPAddressEntry(NB_IPAddress toEdit, NetworkDevice ToEdit, Form ParentForm, bool JustPinging=false)
{ {
InitializeComponent(); InitializeComponent();
LanguagifyComponents(); LanguagifyComponents();
@ -33,7 +33,7 @@ namespace EduNetworkBuilder
} }
ParentDevice = ToEdit; ParentDevice = ToEdit;
Network myNet = NB.GetNetwork(); Network myNet = NB.GetNetwork();
IPAddress lastIP = myNet.RetrieveLastIP(); NB_IPAddress lastIP = myNet.RetrieveLastIP();
WhatToEdit = toEdit; WhatToEdit = toEdit;
string hostname = ""; string hostname = "";
if (ToEdit != null) if (ToEdit != null)
@ -158,7 +158,7 @@ namespace EduNetworkBuilder
return WellDone; return WellDone;
} }
public bool Edit(NetworkDevice ToEdit, IPAddress DHCPif) public bool Edit(NetworkDevice ToEdit, NB_IPAddress DHCPif)
{ {
DHCPInterface = DHCPif; DHCPInterface = DHCPif;
lblIP.Text = NB.Translate("IPAE_EditIf"); lblIP.Text = NB.Translate("IPAE_EditIf");
@ -192,7 +192,7 @@ namespace EduNetworkBuilder
Network mynet = NB.GetNetwork(); Network mynet = NB.GetNetwork();
if (ParentDevice != null) if (ParentDevice != null)
{ {
IPAddress tAddress = mynet.DNSLookup(ParentDevice, tbGateway.Text); NB_IPAddress tAddress = mynet.DNSLookup(ParentDevice, tbGateway.Text);
} }
UInt32 taddress = tbGateway.Text.ParseIp(); UInt32 taddress = tbGateway.Text.ParseIp();
@ -201,7 +201,7 @@ namespace EduNetworkBuilder
if (DHCPInterface != null) if (DHCPInterface != null)
{ {
//We also check to verify that the address is in the correct range //We also check to verify that the address is in the correct range
if (!DHCPInterface.IsLocal(new IPAddress(tbGateway.Text))) if (!DHCPInterface.IsLocal(new NB_IPAddress(tbGateway.Text)))
{ {
e.Cancel = true; e.Cancel = true;
MessageBox.Show(NB.Translate("IPAE_tbGateValEndIPRange")); MessageBox.Show(NB.Translate("IPAE_tbGateValEndIPRange"));
@ -221,7 +221,7 @@ namespace EduNetworkBuilder
if (DHCPInterface != null) if (DHCPInterface != null)
{ {
//We also check to verify that the address is in the correct range //We also check to verify that the address is in the correct range
if (!DHCPInterface.IsLocal(new IPAddress(tbNetmask.Text))) if (!DHCPInterface.IsLocal(new NB_IPAddress(tbNetmask.Text)))
{ {
e.Cancel = true; e.Cancel = true;
MessageBox.Show(NB.Translate("IPAE_tbNtmskValEndIPRange")); MessageBox.Show(NB.Translate("IPAE_tbNtmskValEndIPRange"));
@ -233,7 +233,7 @@ namespace EduNetworkBuilder
{ {
UInt32 taddress; UInt32 taddress;
Network mynet = NB.GetNetwork(); Network mynet = NB.GetNetwork();
IPAddress tIPAddress = null; NB_IPAddress tIPAddress = null;
if (ParentDevice != null) if (ParentDevice != null)
{ {
tIPAddress = mynet.DNSLookup(ParentDevice, tbIPAddress.Text); tIPAddress = mynet.DNSLookup(ParentDevice, tbIPAddress.Text);

View File

@ -487,7 +487,7 @@ namespace EduNetworkBuilder
} }
private void AddRoute() private void AddRoute()
{ {
IPAddress newip = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, NB.ZeroIPString); NB_IPAddress newip = new NB_IPAddress(NB.ZeroIPString, NB.ZeroIPString, NB.ZeroIPString);
newip.Edit(myNetDevice, this, NB.Translate("LBW_AddRouteCreate")); newip.Edit(myNetDevice, this, NB.Translate("LBW_AddRouteCreate"));
myNetDevice.AddRoute(newip); myNetDevice.AddRoute(newip);
UpdateForm(); UpdateForm();

View File

@ -170,18 +170,18 @@ namespace EduNetworkBuilder
[Serializable] [Serializable]
public struct IPConnectionEntry public struct IPConnectionEntry
{ {
public IPAddress destIP; //where we are sending the packet to. We expect a response to come from here public NB_IPAddress destIP; //where we are sending the packet to. We expect a response to come from here
public PacketType What; //ping, dhcp, etc public PacketType What; //ping, dhcp, etc
public ResponseToPacket Response; //accept, masq public ResponseToPacket Response; //accept, masq
public IPAddress internalIP; //Used if we are masquerading public NB_IPAddress internalIP; //Used if we are masquerading
public IPConnectionEntry(IPAddress dest, PacketType what, ResponseToPacket response) public IPConnectionEntry(NB_IPAddress dest, PacketType what, ResponseToPacket response)
{ {
destIP = dest; destIP = dest;
What = what; What = what;
Response = response; Response = response;
internalIP = null; internalIP = null;
} }
public IPConnectionEntry(IPAddress dest, PacketType what, ResponseToPacket response, IPAddress internal_ip) public IPConnectionEntry(NB_IPAddress dest, PacketType what, ResponseToPacket response, NB_IPAddress internal_ip)
{ {
destIP = dest; destIP = dest;
What = what; What = what;

View File

@ -471,8 +471,8 @@ namespace EduNetworkBuilder
if(theNet == null) theNet= NB.GetNetwork(); if(theNet == null) theNet= NB.GetNetwork();
NetworkDevice Source = theNet.GetDeviceFromName(sHost); NetworkDevice Source = theNet.GetDeviceFromName(sHost);
NetworkDevice Dest = theNet.GetDeviceFromName(dHost); NetworkDevice Dest = theNet.GetDeviceFromName(dHost);
IPAddress gw; NB_IPAddress gw;
IPAddress tAddr; NB_IPAddress tAddr;
switch(TheTest) switch(TheTest)
{ {
@ -496,11 +496,11 @@ namespace EduNetworkBuilder
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.GetIPString == NB.ZeroIPString)
tAddr = new IPAddress(dHost); tAddr = new NB_IPAddress(dHost);
if (Source.HasRouteMatching(tAddr)) if (Source.HasRouteMatching(tAddr))
{ {
IPAddress route = Source.RouteMatching(tAddr); NB_IPAddress route = Source.RouteMatching(tAddr);
if (Source.LocalNic(new IPAddress(route.GetGateway.ToIpString())) == null) if (Source.LocalNic(new NB_IPAddress(route.GetGateway.ToIpString())) == null)
return false; //The gateway specified is not local to the device. We cannot get to it return false; //The gateway specified is not local to the device. We cannot get to it
return true; return true;
} }
@ -509,7 +509,7 @@ namespace EduNetworkBuilder
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.
if (Dest == null) return false; //Unable to do it. Do not count it against them. if (Dest == null) return false; //Unable to do it. Do not count it against them.
tAddr = Source.LocalDeviceIP(Dest); tAddr = Source.LocalDeviceIP(Dest);
IPAddress dAddress = Dest.LocalDeviceIP(Source); NB_IPAddress dAddress = Dest.LocalDeviceIP(Source);
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 &&

View File

@ -244,7 +244,7 @@ namespace EduNetworkBuilder
{ {
//return all the dhcp ranges //return all the dhcp ranges
sItem = theNet.GetDeviceFromName(ToEdit.sHost); sItem = theNet.GetDeviceFromName(ToEdit.sHost);
foreach (IPAddress ip in sItem.IPAddressList()) foreach (NB_IPAddress ip in sItem.IPAddressList())
{ {
cbDest.Items.Add(ip.GetIPString); cbDest.Items.Add(ip.GetIPString);
} }
@ -253,7 +253,7 @@ namespace EduNetworkBuilder
{ {
//return all the dhcp ranges //return all the dhcp ranges
sItem = theNet.GetDeviceFromName(ToEdit.sHost); sItem = theNet.GetDeviceFromName(ToEdit.sHost);
foreach (IPAddress ip in sItem.ListRoutes()) foreach (NB_IPAddress ip in sItem.ListRoutes())
{ {
cbDest.Items.Add(ip.GetIPString); cbDest.Items.Add(ip.GetIPString);
} }

View File

@ -46,7 +46,7 @@ namespace EduNetworkBuilder
private List<Packet> myPackets = new List<Packet>(); private List<Packet> myPackets = new List<Packet>();
private List<PacketMessage> myMessages = new List<PacketMessage>(); private List<PacketMessage> myMessages = new List<PacketMessage>();
private bool _isDirty = false; private bool _isDirty = false;
private IPAddress lastAddress = new IPAddress("0.0.0.0/24"); private NB_IPAddress lastAddress = new NB_IPAddress("0.0.0.0/24");
public string NetworkFilename = ""; public string NetworkFilename = "";
public List<NetTest> NetTests = new List<NetTest>(); public List<NetTest> NetTests = new List<NetTest>();
private bool AlreadyDisplayedMessage = false; private bool AlreadyDisplayedMessage = false;
@ -724,12 +724,12 @@ namespace EduNetworkBuilder
_isDirty = true; _isDirty = true;
} }
public void StoreLastIP(IPAddress ip) public void StoreLastIP(NB_IPAddress ip)
{ {
lastAddress = ip; lastAddress = ip;
} }
public IPAddress RetrieveLastIP() public NB_IPAddress RetrieveLastIP()
{ {
return lastAddress; return lastAddress;
} }
@ -962,7 +962,7 @@ namespace EduNetworkBuilder
/// <param name="ToFind">The IP address to find</param> /// <param name="ToFind">The IP address to find</param>
/// <param name="Source">The device that has it</param> /// <param name="Source">The device that has it</param>
/// <returns></returns> /// <returns></returns>
public bool HasUniqueIP(IPAddress ToFind, NetworkDevice Source) public bool HasUniqueIP(NB_IPAddress ToFind, NetworkDevice Source)
{ {
NetworkDevice ND; NetworkDevice ND;
foreach (NetworkComponent nc in NetComponents) foreach (NetworkComponent nc in NetComponents)
@ -1234,7 +1234,7 @@ namespace EduNetworkBuilder
/// <param name="packet_type">The type of packet that arrived</param> /// <param name="packet_type">The type of packet that arrived</param>
/// <param name="sHost">The host it originated from</param> /// <param name="sHost">The host it originated from</param>
/// <param name="dHost">The machine it went to</param> /// <param name="dHost">The machine it went to</param>
public void NotePacketArrived(PacketType packet_type, NetworkDevice source, IPAddress sIP, IPAddress dIP, int PacketID) public void NotePacketArrived(PacketType packet_type, NetworkDevice source, NB_IPAddress sIP, NB_IPAddress dIP, int PacketID)
{ {
string sHost = ReverseDNSLookup(source, sIP); string sHost = ReverseDNSLookup(source, sIP);
string dHost = ReverseDNSLookup(source, dIP); string dHost = ReverseDNSLookup(source, dIP);
@ -1267,7 +1267,7 @@ namespace EduNetworkBuilder
} }
} }
public bool HasCompletedPingTest(PacketType packet_type, NetworkDevice source, IPAddress sIP, IPAddress dIP, int PacketID) public bool HasCompletedPingTest(PacketType packet_type, NetworkDevice source, NB_IPAddress sIP, NB_IPAddress dIP, int PacketID)
{ {
if (packet_type != PacketType.ping_answer) return false; //This only works with pings. if (packet_type != PacketType.ping_answer) return false; //This only works with pings.
string sHost = ReverseDNSLookup(source, sIP); string sHost = ReverseDNSLookup(source, sIP);
@ -1286,15 +1286,15 @@ namespace EduNetworkBuilder
public bool NoteActionDone(NetTestType theTest, string sHost, string dHost) public bool NoteActionDone(NetTestType theTest, string sHost, string dHost)
{ {
bool OldVal = false; bool OldVal = false;
IPAddress sourceIP; NB_IPAddress sourceIP;
string sourceIPstring; string sourceIPstring;
IPAddress destIP; NB_IPAddress destIP;
string destIPstring; string destIPstring;
foreach (NetTest nt in NetTests) foreach (NetTest nt in NetTests)
{ {
sourceIP = new IPAddress(sHost); sourceIP = new NB_IPAddress(sHost);
sourceIPstring = ReverseDNSLookup(null, sourceIP); //this will either be an ip address or the host name sourceIPstring = ReverseDNSLookup(null, sourceIP); //this will either be an ip address or the host name
destIP = new IPAddress(dHost); destIP = new NB_IPAddress(dHost);
destIPstring = ReverseDNSLookup(null, destIP); //this will either be an ip address or the host name destIPstring = ReverseDNSLookup(null, destIP); //this will either be an ip address or the host name
if ((nt.TheTest == NetTestType.HelpRequest || nt.TheTest == NetTestType.FailedPing || nt.TheTest == NetTestType.ReadContextHelp) && if ((nt.TheTest == NetTestType.HelpRequest || nt.TheTest == NetTestType.FailedPing || nt.TheTest == NetTestType.ReadContextHelp) &&
(sHost == nt.sHost || sourceIPstring == nt.sHost) && (sHost == nt.sHost || sourceIPstring == nt.sHost) &&
@ -1736,7 +1736,7 @@ namespace EduNetworkBuilder
} }
} }
public IPAddress DNSLookup(NetworkDevice source, string toFind) public NB_IPAddress DNSLookup(NetworkDevice source, string toFind)
{ {
foreach(NetworkComponent nc in NB.Randomize(NetComponents)) foreach(NetworkComponent nc in NB.Randomize(NetComponents))
@ -1747,7 +1747,7 @@ namespace EduNetworkBuilder
nd = (NetworkDevice)nc; nd = (NetworkDevice)nc;
if(nd.hostname == toFind) if(nd.hostname == toFind)
{ {
IPAddress found = nd.BestIPForThis(source); NB_IPAddress found = nd.BestIPForThis(source);
return found; return found;
} }
} }
@ -1755,7 +1755,7 @@ namespace EduNetworkBuilder
return null; return null;
} }
public string ReverseDNSLookup(NetworkDevice source, IPAddress toFind) public string ReverseDNSLookup(NetworkDevice source, NB_IPAddress toFind)
{ {
if (source != null && source.HasIPAddress(toFind)) if (source != null && source.HasIPAddress(toFind))
return source.hostname; //if the host is 127.0.0.1 or something. return source.hostname; //if the host is 127.0.0.1 or something.
@ -2041,7 +2041,7 @@ namespace EduNetworkBuilder
} }
} }
} }
public void DoAllPing(IPAddress destination) public void DoAllPing(NB_IPAddress destination)
{ {
NetworkDevice nd; NetworkDevice nd;
foreach (NetworkComponent nc in NetComponents) foreach (NetworkComponent nc in NetComponents)
@ -2164,7 +2164,7 @@ namespace EduNetworkBuilder
foreach (NetTest NT in NetTests) foreach (NetTest NT in NetTests)
{ {
IPAddress destination; NB_IPAddress destination;
NetworkDevice src = null; NetworkDevice src = null;
//Here we do any pings or actions //Here we do any pings or actions
switch (NT.TheTest) switch (NT.TheTest)
@ -2177,7 +2177,7 @@ namespace EduNetworkBuilder
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.GetIPString == NB.ZeroIPString)
destination = new IPAddress(NT.dHost); destination = new NB_IPAddress(NT.dHost);
src.PingFromHere(destination); src.PingFromHere(destination);
break; break;
case NetTestType.SuccessfullyArps: case NetTestType.SuccessfullyArps:
@ -2185,7 +2185,7 @@ namespace EduNetworkBuilder
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.GetIPString == NB.ZeroIPString)
destination = new IPAddress(NT.dHost); destination = new NB_IPAddress(NT.dHost);
src.AskArpFromHere(destination); src.AskArpFromHere(destination);
break; break;
case NetTestType.SuccessfullyTraceroutes: case NetTestType.SuccessfullyTraceroutes:
@ -2193,7 +2193,7 @@ namespace EduNetworkBuilder
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.GetIPString == NB.ZeroIPString)
destination = new IPAddress(NT.dHost); destination = new NB_IPAddress(NT.dHost);
src.TracerouteFromHere(destination); src.TracerouteFromHere(destination);
break; break;
} }
@ -2224,7 +2224,7 @@ namespace EduNetworkBuilder
NB.RegisterInvisibleNetwork(this); NB.RegisterInvisibleNetwork(this);
NetworkDevice src = GetDeviceFromName(source); NetworkDevice src = GetDeviceFromName(source);
if (src == null) return null; if (src == null) return null;
IPAddress destination = DNSLookup(src, dest); NB_IPAddress destination = DNSLookup(src, dest);
src.PingFromHere(destination); src.PingFromHere(destination);
NonVisualProcessPacketsOnce(); NonVisualProcessPacketsOnce();
NB.UnregisterInvisibleNetwork(); NB.UnregisterInvisibleNetwork();

View File

@ -1338,7 +1338,7 @@ namespace EduNetworkBuilder
{ {
bool todo = true; bool todo = true;
if (ItemClickedOn == null) return; //we do not have something chosen to ping from if (ItemClickedOn == null) return; //we do not have something chosen to ping from
IPAddress destination = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only); NB_IPAddress destination = new NB_IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only);
todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Ping"),true); todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Ping"),true);
if(todo) if(todo)
{ {
@ -1352,7 +1352,7 @@ namespace EduNetworkBuilder
{ {
bool todo = true; bool todo = true;
if (ItemClickedOn == null) return; //we do not have something chosen to traceroute from if (ItemClickedOn == null) return; //we do not have something chosen to traceroute from
IPAddress destination = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only); NB_IPAddress destination = new NB_IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only);
todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Traceroute"), true); todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Traceroute"), true);
if (todo) if (todo)
{ {
@ -1368,10 +1368,10 @@ namespace EduNetworkBuilder
ToolStripMenuItem Pressed = (ToolStripMenuItem)sender; ToolStripMenuItem Pressed = (ToolStripMenuItem)sender;
string itemname = Pressed.Text; string itemname = Pressed.Text;
string dest = (string)Pressed.Tag; string dest = (string)Pressed.Tag;
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.GetIPString == NB.ZeroIPString)
destination = new IPAddress(dest); destination = new NB_IPAddress(dest);
ItemClickedOn.PingFromHere(destination); ItemClickedOn.PingFromHere(destination);
myNetwork.ProcessPackets(); myNetwork.ProcessPackets();
UpdateMessages(); UpdateMessages();
@ -1383,10 +1383,10 @@ namespace EduNetworkBuilder
ToolStripMenuItem Pressed = (ToolStripMenuItem)sender; ToolStripMenuItem Pressed = (ToolStripMenuItem)sender;
string itemname = Pressed.Text; string itemname = Pressed.Text;
string dest = (string)Pressed.Tag; string dest = (string)Pressed.Tag;
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.GetIPString == NB.ZeroIPString)
destination = new IPAddress(dest); destination = new NB_IPAddress(dest);
ItemClickedOn.TracerouteFromHere(destination); ItemClickedOn.TracerouteFromHere(destination);
myNetwork.ProcessPackets(); myNetwork.ProcessPackets();
UpdateMessages(); UpdateMessages();
@ -1398,10 +1398,10 @@ namespace EduNetworkBuilder
ToolStripMenuItem Pressed = (ToolStripMenuItem)sender; ToolStripMenuItem Pressed = (ToolStripMenuItem)sender;
string itemname = Pressed.Text; string itemname = Pressed.Text;
string dest = (string)Pressed.Tag; string dest = (string)Pressed.Tag;
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.GetIPString == NB.ZeroIPString)
destination = new IPAddress(dest); destination = new NB_IPAddress(dest);
ItemClickedOn.AskArpFromHere(destination); ItemClickedOn.AskArpFromHere(destination);
myNetwork.ProcessPackets(); myNetwork.ProcessPackets();
UpdateMessages(); UpdateMessages();
@ -1411,7 +1411,7 @@ namespace EduNetworkBuilder
{ {
bool todo = true; bool todo = true;
if (ItemClickedOn == null) return; //we do not have something chosen to arp request from if (ItemClickedOn == null) return; //we do not have something chosen to arp request from
IPAddress destination = new IPAddress(NB.ZeroIPString, "255.255.255.255", IPAddressType.ip_only); NB_IPAddress destination = new NB_IPAddress(NB.ZeroIPString, "255.255.255.255", IPAddressType.ip_only);
todo = destination.Edit(ItemClickedOn, this, NB.Translate("H_ARP_Title2")); todo = destination.Edit(ItemClickedOn, this, NB.Translate("H_ARP_Title2"));
if (todo) if (todo)
{ {
@ -2031,7 +2031,7 @@ namespace EduNetworkBuilder
private void pingToolStripMenuItem_Click(object sender, EventArgs e) private void pingToolStripMenuItem_Click(object sender, EventArgs e)
{ {
bool todo = true; bool todo = true;
IPAddress destination = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only); NB_IPAddress destination = new NB_IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only);
todo = destination.Edit(null, this, NB.Translate("NB_NetViewPng")); todo = destination.Edit(null, this, NB.Translate("NB_NetViewPng"));
if (todo) if (todo)
{ {

View File

@ -25,7 +25,7 @@ namespace EduNetworkBuilder
public int ConnectedLink=-1; //The link that is connected to this nic. public int ConnectedLink=-1; //The link that is connected to this nic.
private int UniqueIdentifier = NB.GetUniqueIdentifier(); private int UniqueIdentifier = NB.GetUniqueIdentifier();
private string _nic_name=""; private string _nic_name="";
public IPAddress TunnelEndpoint; public NB_IPAddress TunnelEndpoint;
public string EncryptionKey; public string EncryptionKey;
public string SSID; public string SSID;
public string WirelessKey public string WirelessKey
@ -83,7 +83,7 @@ namespace EduNetworkBuilder
MAC = tmac.ToUpper(); //Make sure it is all uppercase MAC = tmac.ToUpper(); //Make sure it is all uppercase
break; break;
case "tunnelendpoint": case "tunnelendpoint":
TunnelEndpoint = new IPAddress(Individual); TunnelEndpoint = new NB_IPAddress(Individual);
break; break;
case "encryptionkey": case "encryptionkey":
EncryptionKey = Individual.InnerText; EncryptionKey = Individual.InnerText;
@ -210,9 +210,9 @@ namespace EduNetworkBuilder
return theIPs; return theIPs;
} }
public List<IPAddress> IPAddressList() public List<NB_IPAddress> IPAddressList()
{ {
List<IPAddress> theIPs = new List<IPAddress>(); List<NB_IPAddress> theIPs = new List<NB_IPAddress>();
if (myNicType == NicType.port) return theIPs; if (myNicType == NicType.port) return theIPs;
if (myNicType == NicType.none) return theIPs; if (myNicType == NicType.none) return theIPs;
foreach (NetworkInterface iface in interfaces) foreach (NetworkInterface iface in interfaces)
@ -222,7 +222,7 @@ namespace EduNetworkBuilder
return theIPs; return theIPs;
} }
public bool HasIPAddresses(IPAddress dest) public bool HasIPAddresses(NB_IPAddress dest)
{ {
if (myNicType == NicType.port) return false; if (myNicType == NicType.port) return false;
if (myNicType == NicType.none) return false; if (myNicType == NicType.none) return false;
@ -235,7 +235,7 @@ namespace EduNetworkBuilder
return false; return false;
} }
public bool HasBroadcastAddresses(IPAddress dest) public bool HasBroadcastAddresses(NB_IPAddress dest)
{ {
if (myNicType == NicType.port) return false; if (myNicType == NicType.port) return false;
if (myNicType == NicType.none) return false; if (myNicType == NicType.none) return false;
@ -363,7 +363,7 @@ namespace EduNetworkBuilder
} }
} }
} }
public void SetIPForDHCP(IPAddress newIP) public void SetIPForDHCP(NB_IPAddress newIP)
{ {
if (UsesDHCP && CanUseDHCP) if (UsesDHCP && CanUseDHCP)
{ {
@ -390,7 +390,7 @@ namespace EduNetworkBuilder
} }
} }
public bool HasLocalInterface(IPAddress theIP) public bool HasLocalInterface(NB_IPAddress theIP)
{ {
foreach(NetworkInterface nIF in interfaces) foreach(NetworkInterface nIF in interfaces)
{ {
@ -405,7 +405,7 @@ namespace EduNetworkBuilder
/// </summary> /// </summary>
/// <param name="theIP">An IP address we are trying to send out</param> /// <param name="theIP">An IP address we are trying to send out</param>
/// <returns>null if no interface is local. Otherwise, it returns the one that matches the packet</returns> /// <returns>null if no interface is local. Otherwise, it returns the one that matches the packet</returns>
public NetworkInterface LocalInterface(IPAddress theIP, PacketMessage Tracker) public NetworkInterface LocalInterface(NB_IPAddress theIP, PacketMessage Tracker)
{ {
if (myNicType == NicType.port) if (myNicType == NicType.port)
{ {
@ -777,7 +777,7 @@ namespace EduNetworkBuilder
if (nd.HowToRespondToPacket(tPacket) == ResponseToPacket.masq) if (nd.HowToRespondToPacket(tPacket) == ResponseToPacket.masq)
{ {
IPAddress oAddress = nd.PacketMasqueradeSource(tPacket); NB_IPAddress oAddress = nd.PacketMasqueradeSource(tPacket);
if(oAddress != null) if(oAddress != null)
{ {
tPacket.Tracking.AddMessage(DebugLevel.natting, nd.hostname, string.Format(NB.Translate("NC_ChangeIPBackStr"), oAddress.GetIPString)); tPacket.Tracking.AddMessage(DebugLevel.natting, nd.hostname, string.Format(NB.Translate("NC_ChangeIPBackStr"), oAddress.GetIPString));
@ -820,7 +820,7 @@ namespace EduNetworkBuilder
{ {
if (myNicType != NicType.lo) if (myNicType != NicType.lo)
{ {
nf.myIP = new IPAddress(NB.ZeroIPString); nf.myIP = new NB_IPAddress(NB.ZeroIPString);
nf.SetVLANTag(1, VLANTagType.Untagged); nf.SetVLANTag(1, VLANTagType.Untagged);
} }
} }
@ -832,7 +832,7 @@ namespace EduNetworkBuilder
{ {
if (myNicType != NicType.lo) if (myNicType != NicType.lo)
{ {
nf.myIP = new IPAddress(NB.ZeroIPString); nf.myIP = new NB_IPAddress(NB.ZeroIPString);
nf.LockOutVLANInterface(); nf.LockOutVLANInterface();
} }
} }
@ -863,13 +863,13 @@ namespace EduNetworkBuilder
return null; return null;
} }
public IPAddress FirstIP() public NB_IPAddress FirstIP()
{ {
List<IPAddress> addresses = IPAddressList(); List<NB_IPAddress> addresses = IPAddressList();
if (addresses.Count > 0) if (addresses.Count > 0)
return addresses[0]; return addresses[0];
else else
return new IPAddress(NB.ZeroIPString); return new NB_IPAddress(NB.ZeroIPString);
} }
public static T Clone<T>(T source) public static T Clone<T>(T source)

View File

@ -194,7 +194,7 @@ namespace EduNetworkBuilder
NetworkDevice nd = theNet.GetDeviceFromID(MyNicToEdit.myID); NetworkDevice nd = theNet.GetDeviceFromID(MyNicToEdit.myID);
if(MyNicToEdit.TunnelEndpoint == null) if(MyNicToEdit.TunnelEndpoint == null)
{ {
MyNicToEdit.TunnelEndpoint = new IPAddress(NB.ZeroIPString, "255.255.255.0", IPAddressType.ip_only); MyNicToEdit.TunnelEndpoint = new NB_IPAddress(NB.ZeroIPString, "255.255.255.0", IPAddressType.ip_only);
} }
MyNicToEdit.TunnelEndpoint.Edit(nd, this, NB.Translate("_Endpt")); MyNicToEdit.TunnelEndpoint.Edit(nd, this, NB.Translate("_Endpt"));
SaveDataToNic(); SaveDataToNic();

View File

@ -15,14 +15,14 @@ namespace EduNetworkBuilder
public class NetworkDevice : NetworkComponent public class NetworkDevice : NetworkComponent
{ {
protected List<NetworkCard> NICs = new List<NetworkCard>(); protected List<NetworkCard> NICs = new List<NetworkCard>();
protected IPAddress DefaultGW = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.gw); protected NB_IPAddress DefaultGW = new NB_IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.gw);
protected Image MyImage = null; protected Image MyImage = null;
protected Point MyLocation; protected Point MyLocation;
public int Size; public int Size;
protected List<ArpEntry> ArpTable = new List<ArpEntry>(); protected List<ArpEntry> ArpTable = new List<ArpEntry>();
protected NetworkComponentType myType = NetworkComponentType.none; protected NetworkComponentType myType = NetworkComponentType.none;
protected List<IPAddress> RouteTable = new List<IPAddress>(); protected List<NB_IPAddress> RouteTable = new List<NB_IPAddress>();
protected List<IPAddress> DHCPRanges = new List<IPAddress>(); protected List<NB_IPAddress> DHCPRanges = new List<NB_IPAddress>();
protected List<ArpEntry> DHCPLeases = new List<ArpEntry>(); protected List<ArpEntry> DHCPLeases = new List<ArpEntry>();
protected List<IPConnectionEntry> IPConnections = new List<IPConnectionEntry>(); protected List<IPConnectionEntry> IPConnections = new List<IPConnectionEntry>();
protected bool isDNSServer = false; protected bool isDNSServer = false;
@ -301,7 +301,7 @@ namespace EduNetworkBuilder
DefaultGW.Edit(this,ParentForm,NB.Translate("ND_EdtGteway")); DefaultGW.Edit(this,ParentForm,NB.Translate("ND_EdtGteway"));
} }
public IPAddress GetGateway() public NB_IPAddress GetGateway()
{ {
if(CanUseDHCP) if(CanUseDHCP)
{ {
@ -310,10 +310,10 @@ namespace EduNetworkBuilder
{ {
if(nic.UsesDHCP) if(nic.UsesDHCP)
{ {
List<IPAddress> tlist = nic.IPAddressList(); List<NB_IPAddress> tlist = nic.IPAddressList();
if(tlist.Count > 0) if(tlist.Count > 0)
{ {
IPAddress newIP = new IPAddress(tlist[0].GetGateway.ToIpString()); NB_IPAddress newIP = new NB_IPAddress(tlist[0].GetGateway.ToIpString());
return newIP; return newIP;
} }
} }
@ -364,7 +364,7 @@ namespace EduNetworkBuilder
int.TryParse(Individual.InnerText, out UniqueIdentifier); int.TryParse(Individual.InnerText, out UniqueIdentifier);
break; break;
case "gateway": case "gateway":
DefaultGW = new IPAddress(Individual); DefaultGW = new NB_IPAddress(Individual);
break; break;
case "hostname": case "hostname":
hostname = Individual.InnerText; hostname = Individual.InnerText;
@ -377,7 +377,7 @@ namespace EduNetworkBuilder
NICs.Add(newNic); NICs.Add(newNic);
break; break;
case "route": case "route":
IPAddress ip = new IPAddress(Individual); NB_IPAddress ip = new NB_IPAddress(Individual);
RouteTable.Add(ip); RouteTable.Add(ip);
break; break;
case "isdns": case "isdns":
@ -390,7 +390,7 @@ namespace EduNetworkBuilder
bool.TryParse(Individual.InnerText, out isDHCPServer); bool.TryParse(Individual.InnerText, out isDHCPServer);
break; break;
case "dhcprange": case "dhcprange":
IPAddress dhcpip = new IPAddress(Individual); NB_IPAddress dhcpip = new NB_IPAddress(Individual);
DHCPRanges.Add(dhcpip); DHCPRanges.Add(dhcpip);
break; break;
case "hasadvfirewall": case "hasadvfirewall":
@ -441,11 +441,11 @@ namespace EduNetworkBuilder
{ {
nic.Save(writer); nic.Save(writer);
} }
foreach (IPAddress ip in RouteTable) foreach (NB_IPAddress ip in RouteTable)
{ {
ip.Save(writer, "route"); ip.Save(writer, "route");
} }
foreach (IPAddress dhcp in DHCPRanges) foreach (NB_IPAddress dhcp in DHCPRanges)
{ {
dhcp.Save(writer, "dhcprange"); dhcp.Save(writer, "dhcprange");
} }
@ -1290,7 +1290,7 @@ namespace EduNetworkBuilder
return tList; return tList;
} }
public bool HasIPAddress(IPAddress dest) public bool HasIPAddress(NB_IPAddress dest)
{ {
foreach(NetworkCard nic in NICs) foreach(NetworkCard nic in NICs)
{ {
@ -1300,10 +1300,10 @@ namespace EduNetworkBuilder
return false; return false;
} }
public IPAddress RouteMatching(IPAddress dest) public NB_IPAddress RouteMatching(NB_IPAddress dest)
{ {
//If we are comparing a route that has a 'special' netmask, make sure it is the right netmask //If we are comparing a route that has a 'special' netmask, make sure it is the right netmask
foreach (IPAddress ip in RouteTable) foreach (NB_IPAddress ip in RouteTable)
{ {
if (dest.GetMask != 0 && dest.GetMask.ToIpString() != "255.255.255.0") if (dest.GetMask != 0 && dest.GetMask.ToIpString() != "255.255.255.0")
{ {
@ -1319,15 +1319,15 @@ namespace EduNetworkBuilder
return null; return null;
} }
public bool HasRouteMatching(IPAddress dest) public bool HasRouteMatching(NB_IPAddress dest)
{ {
IPAddress matched = RouteMatching(dest); NB_IPAddress matched = RouteMatching(dest);
if (matched != null) return true; if (matched != null) return true;
return false; return false;
} }
public bool HasRouteMatching(string destString) public bool HasRouteMatching(string destString)
{ {
IPAddress dest = new IPAddress(destString); NB_IPAddress dest = new NB_IPAddress(destString);
if (dest.GetIPString == NB.ZeroIPString) return false; if (dest.GetIPString == NB.ZeroIPString) return false;
return HasRouteMatching(dest); return HasRouteMatching(dest);
} }
@ -1341,7 +1341,7 @@ namespace EduNetworkBuilder
// } // }
// return false; // return false;
//} //}
public bool HasBroadcastAddress(IPAddress dest) public bool HasBroadcastAddress(NB_IPAddress dest)
{ {
if (dest.BroadcastAddress == dest.GetIP) return true; if (dest.BroadcastAddress == dest.GetIP) return true;
foreach(NetworkCard nic in NICs) foreach(NetworkCard nic in NICs)
@ -1475,7 +1475,7 @@ namespace EduNetworkBuilder
nic.SetIPForDHCP(); //clear the source IP nic.SetIPForDHCP(); //clear the source IP
} }
Packet DHCPPacket = new Packet(this, "", NB.BroadcastMACString, NB.Translate("NB_NetViewDHCP"), PacketType.dhcp_request); Packet DHCPPacket = new Packet(this, "", NB.BroadcastMACString, NB.Translate("NB_NetViewDHCP"), PacketType.dhcp_request);
DHCPPacket.destIP = new IPAddress(NB.BroadcastIPString); DHCPPacket.destIP = new NB_IPAddress(NB.BroadcastIPString);
Network myNet = NB.GetNetwork(); Network myNet = NB.GetNetwork();
myNet.addPacket(DHCPPacket); myNet.addPacket(DHCPPacket);
} }
@ -1501,7 +1501,7 @@ namespace EduNetworkBuilder
} }
} }
public void PingFromHere(IPAddress Destination) public void PingFromHere(NB_IPAddress Destination)
{ {
if (isFrozen() || IsBurned || PowerOff) return; if (isFrozen() || IsBurned || PowerOff) return;
//We need to create a packet //We need to create a packet
@ -1512,7 +1512,7 @@ namespace EduNetworkBuilder
myNet.addPacket(PingPacket); myNet.addPacket(PingPacket);
} }
public void TracerouteFromHere(IPAddress Destination) public void TracerouteFromHere(NB_IPAddress Destination)
{ {
//We need to create a traceroute packet - start with 1 TTL //We need to create a traceroute packet - start with 1 TTL
//We pass it the destination as the payload string, so we have that for all traceroutes. //We pass it the destination as the payload string, so we have that for all traceroutes.
@ -1522,7 +1522,7 @@ namespace EduNetworkBuilder
tracertmessages.Clear(); //Start with a fresh bunch of messages tracertmessages.Clear(); //Start with a fresh bunch of messages
} }
public void AskArpFromHere(IPAddress Destination, PacketMessage Tracker=null) public void AskArpFromHere(NB_IPAddress Destination, PacketMessage Tracker=null)
{ {
//We need to create a packet //We need to create a packet
if (isFrozen() || IsBurned || PowerOff) return; if (isFrozen() || IsBurned || PowerOff) return;
@ -1533,7 +1533,7 @@ namespace EduNetworkBuilder
myNet.addPacket(ArpPacket); myNet.addPacket(ArpPacket);
} }
public void TunnelPacketFromHere(IPAddress Destination, Packet Payload, string Encryption = "") public void TunnelPacketFromHere(NB_IPAddress Destination, Packet Payload, string Encryption = "")
{ {
if(Destination == null) if(Destination == null)
{ {
@ -1612,7 +1612,7 @@ namespace EduNetworkBuilder
return ResponseToPacket.reject; return ResponseToPacket.reject;
} }
public IPAddress PacketMasqueradeSource(Packet tPacket) public NB_IPAddress PacketMasqueradeSource(Packet tPacket)
{ {
bool typesMatch = false; bool typesMatch = false;
foreach (IPConnectionEntry ipc in IPConnections) foreach (IPConnectionEntry ipc in IPConnections)
@ -1712,8 +1712,8 @@ namespace EduNetworkBuilder
if(MacAddressMatch || tPacket.isFresh) if(MacAddressMatch || tPacket.isFresh)
{ {
//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 IPAddress(NB.ZeroIPString); if (tPacket.destIP == null) tPacket.destIP = new NB_IPAddress(NB.ZeroIPString);
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.GetIPString != NB.BroadcastIPString) if(dest.GetIPString == NB.ZeroIPString && tPacket.destIP.GetIPString != NB.BroadcastIPString)
{ {
//No gateway set and no route... //No gateway set and no route...
@ -2007,7 +2007,7 @@ namespace EduNetworkBuilder
tPacket.AddMessage(DebugLevel.info, NB.Translate("ND_ProcessArrival_PingReached1")); tPacket.AddMessage(DebugLevel.info, NB.Translate("ND_ProcessArrival_PingReached1"));
tPacket.Tracking.Status = NB.LeftPad(hostname) + " Ping " + NB.Translate("ND_ProcessArrival_PingReached1") + tPacket.sourceIP.GetIP.ToIpString() + "-> " + tPacket.destIP.GetIP.ToIpString(); tPacket.Tracking.Status = NB.LeftPad(hostname) + " Ping " + NB.Translate("ND_ProcessArrival_PingReached1") + tPacket.sourceIP.GetIP.ToIpString() + "-> " + tPacket.destIP.GetIP.ToIpString();
tPacket.MyStatus = PacketStatus.finished_ok; tPacket.MyStatus = PacketStatus.finished_ok;
IPAddress tip = nPacket.sourceIP; NB_IPAddress tip = nPacket.sourceIP;
if (!HasBroadcastAddress(tPacket.destIP)) if (!HasBroadcastAddress(tPacket.destIP))
{ {
nPacket.sourceIP = tPacket.destIP; nPacket.sourceIP = tPacket.destIP;
@ -2015,8 +2015,8 @@ namespace EduNetworkBuilder
} }
else else
{ {
nPacket.sourceIP = new IPAddress(NB.ZeroIPString); nPacket.sourceIP = new NB_IPAddress(NB.ZeroIPString);
nPacket.TsourceIP = new IPAddress(NB.ZeroIPString); nPacket.TsourceIP = new NB_IPAddress(NB.ZeroIPString);
} }
if (tip.GetIP.ToIpString() != NB.ZeroIPString) if (tip.GetIP.ToIpString() != NB.ZeroIPString)
nPacket.destIP = tip; nPacket.destIP = tip;
@ -2025,7 +2025,7 @@ namespace EduNetworkBuilder
//The packet reached itself. At this moment, the packet does not yet have the source information set //The packet reached itself. At this moment, the packet does not yet have the source information set
//We just need to set the dest //We just need to set the dest
// //
nPacket.destIP = new IPAddress(NB.LoopbackIPString); nPacket.destIP = new NB_IPAddress(NB.LoopbackIPString);
} }
if (myType == NetworkComponentType.net_hub || myType == NetworkComponentType.net_switch || if (myType == NetworkComponentType.net_hub || myType == NetworkComponentType.net_switch ||
myType == NetworkComponentType.wrouter) myType == NetworkComponentType.wrouter)
@ -2096,7 +2096,7 @@ namespace EduNetworkBuilder
if (response == ResponseToPacket.none || response == ResponseToPacket.masq) return; //We do not do anything with it here. if (response == ResponseToPacket.none || response == ResponseToPacket.masq) return; //We do not do anything with it here.
//The reply got here. This packet is done //The reply got here. This packet is done
IPAddress origStart = new IPAddress(tPacket.payloadData); NB_IPAddress origStart = new NB_IPAddress(tPacket.payloadData);
int ttl = tPacket.OrigTTL + 1; int ttl = tPacket.OrigTTL + 1;
//Console.WriteLine("Tracert: " + tPacket.OrigTTL + " " + tPacket.sourceIP.GetIPString); //Console.WriteLine("Tracert: " + tPacket.OrigTTL + " " + tPacket.sourceIP.GetIPString);
@ -2143,7 +2143,7 @@ namespace EduNetworkBuilder
if (nPacket.TsourceIP == null) nPacket.TsourceIP = nPacket.sourceIP; if (nPacket.TsourceIP == null) nPacket.TsourceIP = nPacket.sourceIP;
StoreArp(nPacket.sourceMAC, nPacket.TsourceIP.GetIP.ToIpString(), theID); StoreArp(nPacket.sourceMAC, nPacket.TsourceIP.GetIP.ToIpString(), theID);
//This is the IP we are looking for, send response back //This is the IP we are looking for, send response back
IPAddress tip = nPacket.sourceIP; NB_IPAddress tip = nPacket.sourceIP;
nPacket.sourceIP = nPacket.destIP; nPacket.sourceIP = nPacket.destIP;
nPacket.TsourceIP = nPacket.destIP; nPacket.TsourceIP = nPacket.destIP;
nPacket.destIP = tip; nPacket.destIP = tip;
@ -2212,7 +2212,7 @@ namespace EduNetworkBuilder
nPacket.Tracking = new PacketMessage(); nPacket.Tracking = new PacketMessage();
myNet.addPacket(nPacket); myNet.addPacket(nPacket);
//We need to find a dhcp IP for this. //We need to find a dhcp IP for this.
IPAddress dst; NB_IPAddress dst;
if (tPacket.InboundInterface == null) if (tPacket.InboundInterface == null)
{ {
dst = RequestDHCPLease(tPacket.sourceMAC, tPacket.OutboundIP); dst = RequestDHCPLease(tPacket.sourceMAC, tPacket.OutboundIP);
@ -2226,7 +2226,7 @@ namespace EduNetworkBuilder
//if the packet came in on a port... //if the packet came in on a port...
if (tPacket.InboundNic != null && (tPacket.InboundNic.GetNicType == NicType.wport || tPacket.InboundNic.GetNicType == NicType.port)) if (tPacket.InboundNic != null && (tPacket.InboundNic.GetNicType == NicType.wport || tPacket.InboundNic.GetNicType == NicType.port))
{ {
IPAddress theIP = HubManagementIP(); NB_IPAddress theIP = HubManagementIP();
if (theIP != null) if (theIP != null)
dst = RequestDHCPLease(tPacket.sourceMAC, theIP); dst = RequestDHCPLease(tPacket.sourceMAC, theIP);
} }
@ -2248,7 +2248,7 @@ namespace EduNetworkBuilder
string IP = ""; string IP = "";
if (nPacket.sourceIP != null) IP = nPacket.sourceIP.GetIPString; if (nPacket.sourceIP != null) IP = nPacket.sourceIP.GetIPString;
if(IP == "" && nPacket.WhereAmI != null) { if(IP == "" && nPacket.WhereAmI != null) {
IPAddress tIP = HubManagementIP(); NB_IPAddress tIP = HubManagementIP();
if (tIP != null) IP = tIP.GetIPString; if (tIP != null) IP = tIP.GetIPString;
} }
tPacket.Tracking.Status = NB.LeftPad(hostname) + " " + string.Format(NB.Translate("ND_ProssArrDHCPStr"), IP); tPacket.Tracking.Status = NB.LeftPad(hostname) + " " + string.Format(NB.Translate("ND_ProssArrDHCPStr"), IP);
@ -2268,7 +2268,7 @@ namespace EduNetworkBuilder
if (tnic != null) if (tnic != null)
{ {
if (tPacket.payloadIP == null) if (tPacket.payloadIP == null)
tPacket.payloadIP = new IPAddress(NB.ZeroIPString); tPacket.payloadIP = new NB_IPAddress(NB.ZeroIPString);
tnic.SetIPForDHCP(tPacket.payloadIP); tnic.SetIPForDHCP(tPacket.payloadIP);
IsDirty = true; //If we need to redraw the device IP IsDirty = true; //If we need to redraw the device IP
tPacket.Tracking.Status = NB.LeftPad(hostname) + " " + string.Format(NB.Translate("ND_ProssArrDHCPAnsStr"), tPacket.payloadIP.GetIP.ToIpString()); tPacket.Tracking.Status = NB.LeftPad(hostname) + " " + string.Format(NB.Translate("ND_ProssArrDHCPAnsStr"), tPacket.payloadIP.GetIP.ToIpString());
@ -2292,11 +2292,11 @@ namespace EduNetworkBuilder
tPacket.MyStatus = PacketStatus.finished; //Different things may have different finished things. tPacket.MyStatus = PacketStatus.finished; //Different things may have different finished things.
} }
public IPAddress LocalDeviceIP(NetworkDevice FromWhat) public NB_IPAddress LocalDeviceIP(NetworkDevice FromWhat)
{ {
NetworkInterface nif; NetworkInterface nif;
List<IPAddress> myList = FromWhat.IPAddressList(); List<NB_IPAddress> myList = FromWhat.IPAddressList();
foreach (IPAddress ip in myList.ToList()) foreach (NB_IPAddress ip in myList.ToList())
{ {
foreach (NetworkCard tNic in NICs) foreach (NetworkCard tNic in NICs)
{ {
@ -2313,9 +2313,9 @@ namespace EduNetworkBuilder
return null; return null;
} }
public IPAddress HubManagementIP() public NB_IPAddress HubManagementIP()
{ {
List<IPAddress> IPAddresses = new List<IPAddress>(); List<NB_IPAddress> IPAddresses = new List<NB_IPAddress>();
foreach (NetworkCard tNic in NICs) foreach (NetworkCard tNic in NICs)
{ {
if(tNic.GetNicType == NicType.management_interface) if(tNic.GetNicType == NicType.management_interface)
@ -2378,9 +2378,9 @@ namespace EduNetworkBuilder
return lockedOUT; return lockedOUT;
} }
public List<IPAddress> IPAddressList() public List<NB_IPAddress> IPAddressList()
{ {
List<IPAddress> thelist = new List<IPAddress>(); List<NB_IPAddress> thelist = new List<NB_IPAddress>();
foreach(NetworkCard nic in NICs) foreach(NetworkCard nic in NICs)
{ {
thelist.AddRange(nic.IPAddressList()); thelist.AddRange(nic.IPAddressList());
@ -2391,7 +2391,7 @@ namespace EduNetworkBuilder
public List<string> SubnetList() public List<string> SubnetList()
{ {
List<string> thelist = new List<string>(); List<string> thelist = new List<string>();
foreach(IPAddress taddr in IPAddressList()) foreach(NB_IPAddress taddr in IPAddressList())
{ {
if(!thelist.Contains(taddr.NetworkAddress.ToIpString())) if(!thelist.Contains(taddr.NetworkAddress.ToIpString()))
{ {
@ -2404,7 +2404,7 @@ namespace EduNetworkBuilder
public List<string> BroadcastList() public List<string> BroadcastList()
{ {
List<string> thelist = new List<string>(); List<string> thelist = new List<string>();
foreach (IPAddress taddr in IPAddressList()) foreach (NB_IPAddress taddr in IPAddressList())
{ {
if (!thelist.Contains(taddr.BroadcastAddress.ToIpString())) if (!thelist.Contains(taddr.BroadcastAddress.ToIpString()))
{ {
@ -2420,16 +2420,16 @@ namespace EduNetworkBuilder
/// </summary> /// </summary>
/// <param name="dest">The target IP</param> /// <param name="dest">The target IP</param>
/// <returns>The IP the packet should be going to</returns> /// <returns>The IP the packet should be going to</returns>
public IPAddress DestinationFromIP(IPAddress dest, NetworkCard oNic = null) public NB_IPAddress DestinationFromIP(NB_IPAddress dest, NetworkCard oNic = null)
{ {
NetworkInterface nIF = null; NetworkInterface nIF = null;
NetworkCard tCard = null; NetworkCard tCard = null;
IPAddress DestAddr; NB_IPAddress DestAddr;
string DHCPGW = ""; string DHCPGW = "";
foreach( IPAddress ip in RouteTable) foreach( NB_IPAddress ip in RouteTable)
{ {
if (ip.IsLocal(dest)) if (ip.IsLocal(dest))
return new IPAddress(ip.GetGateway.ToIpString());//We return the gateway return new NB_IPAddress(ip.GetGateway.ToIpString());//We return the gateway
} }
foreach (NetworkCard nic in NICs) foreach (NetworkCard nic in NICs)
{ {
@ -2447,19 +2447,19 @@ namespace EduNetworkBuilder
} }
if (oNic != null) if (oNic != null)
{ {
List<IPAddress> tlist = oNic.IPAddressList(); List<NB_IPAddress> tlist = oNic.IPAddressList();
if(tlist.Count > 0 && tlist[0].GetGateway.ToIpString() != NB.ZeroIPString) if(tlist.Count > 0 && tlist[0].GetGateway.ToIpString() != NB.ZeroIPString)
{ {
return new IPAddress(tlist[0].GetGateway.ToIpString()); return new NB_IPAddress(tlist[0].GetGateway.ToIpString());
} }
} }
if (DHCPGW != "") if (DHCPGW != "")
return new IPAddress(DHCPGW); return new NB_IPAddress(DHCPGW);
//if we get here, we do not know where to send it. Use the default gw. //if we get here, we do not know where to send it. Use the default gw.
return DefaultGW; return DefaultGW;
} }
public bool PrepPacketForSending(Packet tPacket, IPAddress dest) public bool PrepPacketForSending(Packet tPacket, NB_IPAddress dest)
{ {
if((tPacket.OutboundMAC == null || tPacket.OutboundMAC == "") && if((tPacket.OutboundMAC == null || tPacket.OutboundMAC == "") &&
tPacket.MyType == PacketType.dhcp_request && tPacket.MyType == PacketType.dhcp_request &&
@ -2474,7 +2474,7 @@ namespace EduNetworkBuilder
{ {
nic.SetIPForDHCP(); nic.SetIPForDHCP();
Packet nPacket = new Packet(tPacket); Packet nPacket = new Packet(tPacket);
nPacket.OutboundIP = new IPAddress(NB.ZeroIPString); nPacket.OutboundIP = new NB_IPAddress(NB.ZeroIPString);
nPacket.OutboundMAC = nic.MAC; nPacket.OutboundMAC = nic.MAC;
nPacket.OutboundNic = nic; nPacket.OutboundNic = nic;
nPacket.OutboundIF = nic.GetInterface(0); nPacket.OutboundIF = nic.GetInterface(0);
@ -2495,11 +2495,11 @@ namespace EduNetworkBuilder
Network myNet = NB.GetNetwork(); Network myNet = NB.GetNetwork();
foreach (NetworkCard nic in NICs) foreach (NetworkCard nic in NICs)
{ {
if (!nic.HasIP(new IPAddress("127.0.0.1").GetIP)) //don't bother pinging on the loopback if (!nic.HasIP(new NB_IPAddress("127.0.0.1").GetIP)) //don't bother pinging on the loopback
{ {
//Make one Broadcast ping for every nic that has an IP //Make one Broadcast ping for every nic that has an IP
Packet nPacket = new Packet(tPacket); Packet nPacket = new Packet(tPacket);
nPacket.OutboundIP = new IPAddress(NB.ZeroIPString); nPacket.OutboundIP = new NB_IPAddress(NB.ZeroIPString);
nPacket.OutboundMAC = nic.MAC; nPacket.OutboundMAC = nic.MAC;
nPacket.destMAC = NB.BroadcastMACString; nPacket.destMAC = NB.BroadcastMACString;
nPacket.OutboundNic = nic; nPacket.OutboundNic = nic;
@ -2595,7 +2595,7 @@ namespace EduNetworkBuilder
/// </summary> /// </summary>
/// <param name="toFind">The IP Address we are looking for</param> /// <param name="toFind">The IP Address we are looking for</param>
/// <returns>a network card, or null if nothing matches</returns> /// <returns>a network card, or null if nothing matches</returns>
public NetworkCard LocalNic(IPAddress toFind, bool skipZero= false) public NetworkCard LocalNic(NB_IPAddress toFind, bool skipZero= false)
{ {
NetworkInterface nIF; NetworkInterface nIF;
foreach (NetworkCard nic in NICs) foreach (NetworkCard nic in NICs)
@ -2643,13 +2643,13 @@ namespace EduNetworkBuilder
return answer; return answer;
} }
private IPAddress IPFromTypeNic(NicType What) private NB_IPAddress IPFromTypeNic(NicType What)
{ {
foreach(NetworkCard nic in NB.Randomize(NICs).ToList()) foreach(NetworkCard nic in NB.Randomize(NICs).ToList())
{ {
if(nic.GetNicType == What) if(nic.GetNicType == What)
{ {
foreach(IPAddress ip in nic.IPAddressList()) foreach(NB_IPAddress ip in nic.IPAddressList())
{ {
if (ip.GetIPString != NB.ZeroIPString && ip.GetIPString != NB.LoopbackIPString) if (ip.GetIPString != NB.ZeroIPString && ip.GetIPString != NB.LoopbackIPString)
return ip; return ip;
@ -2659,9 +2659,9 @@ namespace EduNetworkBuilder
return null; return null;
} }
public IPAddress BestIPForThis(NetworkDevice Source=null) public NB_IPAddress BestIPForThis(NetworkDevice Source=null)
{ {
IPAddress answer=null; NB_IPAddress answer=null;
if(Source != null) if(Source != null)
{ {
answer = LocalDeviceIP(Source); answer = LocalDeviceIP(Source);
@ -2689,17 +2689,17 @@ namespace EduNetworkBuilder
public List<string> DeviceRouteStrings() public List<string> DeviceRouteStrings()
{ {
List<string> answer = new List<string>(); List<string> answer = new List<string>();
foreach (IPAddress ip in RouteTable) foreach (NB_IPAddress ip in RouteTable)
{ {
answer.Add(ip.IPFormat()); answer.Add(ip.IPFormat());
} }
return answer; return answer;
} }
public void AddRoute(IPAddress route) public void AddRoute(NB_IPAddress route)
{ {
RouteTable.Add(route); RouteTable.Add(route);
} }
public List<IPAddress> ListRoutes() public List<NB_IPAddress> ListRoutes()
{ {
return RouteTable; return RouteTable;
} }
@ -2773,7 +2773,7 @@ namespace EduNetworkBuilder
NetworkInterface inif = nc.InterfaceFromVlanTag(tPacket); NetworkInterface inif = nc.InterfaceFromVlanTag(tPacket);
tPacket.InboundInterface = inif; tPacket.InboundInterface = inif;
List<IPAddress> addresses = nc.IPAddressList(); List<NB_IPAddress> addresses = nc.IPAddressList();
if (addresses.Count > 0) if (addresses.Count > 0)
{ {
if (tPacket.TsourceIP == null) tPacket.TsourceIP = tPacket.sourceIP; if (tPacket.TsourceIP == null) tPacket.TsourceIP = tPacket.sourceIP;
@ -2847,7 +2847,7 @@ namespace EduNetworkBuilder
//There is a fringe case. Do not bounce back if the target device is on the same LAN that this packet came in on //There is a fringe case. Do not bounce back if the target device is on the same LAN that this packet came in on
// Otherwise, the traceroute gets an odd reply. // Otherwise, the traceroute gets an odd reply.
// Do not do a tracert reply if the src and dest are local to each-other, and if this is not the device that is the endpoint // Do not do a tracert reply if the src and dest are local to each-other, and if this is not the device that is the endpoint
bool LocalToEachOther = tPacket.sourceIP.IsLocal(new IPAddress(tPacket.payloadData)); bool LocalToEachOther = tPacket.sourceIP.IsLocal(new NB_IPAddress(tPacket.payloadData));
if (LocalToEachOther && RoutesPackets() && !HasMac(tPacket.destMAC)) return false; if (LocalToEachOther && RoutesPackets() && !HasMac(tPacket.destMAC)) return false;
//We create a new packet //We create a new packet
@ -2864,8 +2864,8 @@ namespace EduNetworkBuilder
//Console.WriteLine(" Tracert bounce: " + tPacket.OrigTTL + " " + hostname + " " + tPacket.payloadData); //Console.WriteLine(" Tracert bounce: " + tPacket.OrigTTL + " " + hostname + " " + tPacket.payloadData);
//Finish setting up the new packet - sending it back //Finish setting up the new packet - sending it back
nPacket.sourceIP = new IPAddress(NB.ZeroIPString); nPacket.sourceIP = new NB_IPAddress(NB.ZeroIPString);
nPacket.TsourceIP = new IPAddress(NB.ZeroIPString); nPacket.TsourceIP = new NB_IPAddress(NB.ZeroIPString);
myNet.addPacket(nPacket); myNet.addPacket(nPacket);
//Console.WriteLine(" Tracert bounce pkt:" + nPacket.OrigTTL + nPacket.payloadData); //Console.WriteLine(" Tracert bounce pkt:" + nPacket.OrigTTL + nPacket.payloadData);
return true; return true;
@ -2971,7 +2971,7 @@ namespace EduNetworkBuilder
return arp; return arp;
} }
public string ArpFromIP(IPAddress IPAddress) public string ArpFromIP(NB_IPAddress IPAddress)
{ {
return ArpFromIP(IPAddress.GetIP.ToIpString()); return ArpFromIP(IPAddress.GetIP.ToIpString());
} }
@ -3018,7 +3018,7 @@ namespace EduNetworkBuilder
{ {
ClearArps(); ClearArps();
RouteTable.Clear(); RouteTable.Clear();
DefaultGW = new IPAddress(NB.ZeroIPString); DefaultGW = new NB_IPAddress(NB.ZeroIPString);
foreach(NetworkCard nic in NICs) foreach(NetworkCard nic in NICs)
{ {
if(nic.GetNicType != NicType.port) if(nic.GetNicType != NicType.port)
@ -3032,11 +3032,11 @@ namespace EduNetworkBuilder
public void CheckDHCPRangesAgainstInterfaces() public void CheckDHCPRangesAgainstInterfaces()
{ {
bool found = false; bool found = false;
List<IPAddress> theInterfaces = IPAddressList(); List<NB_IPAddress> theInterfaces = IPAddressList();
foreach(IPAddress dhcpIP in DHCPRanges.ToList()) foreach(NB_IPAddress dhcpIP in DHCPRanges.ToList())
{ {
found = false; found = false;
foreach (IPAddress interfaceIP in theInterfaces) foreach (NB_IPAddress interfaceIP in theInterfaces)
{ {
if(interfaceIP.GetIP == dhcpIP.GetIP) if(interfaceIP.GetIP == dhcpIP.GetIP)
{ {
@ -3049,10 +3049,10 @@ namespace EduNetworkBuilder
DHCPRanges.Remove(dhcpIP); DHCPRanges.Remove(dhcpIP);
} }
} }
foreach (IPAddress interfaceIP in theInterfaces) foreach (NB_IPAddress interfaceIP in theInterfaces)
{ {
found = false; found = false;
foreach (IPAddress dhcpIP in DHCPRanges) foreach (NB_IPAddress dhcpIP in DHCPRanges)
{ {
if (interfaceIP.GetIP == dhcpIP.GetIP) if (interfaceIP.GetIP == dhcpIP.GetIP)
{ {
@ -3062,7 +3062,7 @@ namespace EduNetworkBuilder
} }
if (!found) if (!found)
{ {
DHCPRanges.Add(new IPAddress(interfaceIP.GetIP.ToIpString(),NB.ZeroIPString,NB.ZeroIPString)); DHCPRanges.Add(new NB_IPAddress(interfaceIP.GetIP.ToIpString(),NB.ZeroIPString,NB.ZeroIPString));
} }
} }
} }
@ -3070,7 +3070,7 @@ namespace EduNetworkBuilder
public List<string> DHCPStrings(bool WithAdditionalInfo=true) public List<string> DHCPStrings(bool WithAdditionalInfo=true)
{ {
List<string> theStrings = new List<string>(); List<string> theStrings = new List<string>();
foreach(IPAddress ip in DHCPRanges) foreach(NB_IPAddress ip in DHCPRanges)
{ {
if (ip.GetIP.ToIpString() != "127.0.0.1") if (ip.GetIP.ToIpString() != "127.0.0.1")
{ {
@ -3088,10 +3088,10 @@ namespace EduNetworkBuilder
return theStrings; return theStrings;
} }
public IPAddress DHCPRangeMatchingInterface(IPAddress InterfaceIP) public NB_IPAddress DHCPRangeMatchingInterface(NB_IPAddress InterfaceIP)
{ {
if (InterfaceIP == null) return null; if (InterfaceIP == null) return null;
foreach (IPAddress ip in DHCPRanges) foreach (NB_IPAddress ip in DHCPRanges)
{ {
if (ip.GetIP.ToIpString() != "127.0.0.1" && InterfaceIP.IsLocal(ip)) if (ip.GetIP.ToIpString() != "127.0.0.1" && InterfaceIP.IsLocal(ip))
return ip; return ip;
@ -3103,9 +3103,9 @@ namespace EduNetworkBuilder
if (index > DHCPRanges.Count) return; if (index > DHCPRanges.Count) return;
if (index < 0) return; if (index < 0) return;
bool found = false; bool found = false;
IPAddress ifIP = null; NB_IPAddress ifIP = null;
List<IPAddress> theInterfaces = IPAddressList(); List<NB_IPAddress> theInterfaces = IPAddressList();
foreach (IPAddress interfaceIP in theInterfaces) foreach (NB_IPAddress interfaceIP in theInterfaces)
{ {
if(interfaceIP.GetIP == DHCPRanges[index].GetIP) if(interfaceIP.GetIP == DHCPRanges[index].GetIP)
{ {
@ -3118,16 +3118,16 @@ namespace EduNetworkBuilder
DHCPLeases.Clear(); DHCPLeases.Clear();
} }
public IPAddress LookupDHCPLease(string MAC, IPAddress NIC_IP) public NB_IPAddress LookupDHCPLease(string MAC, NB_IPAddress NIC_IP)
{ {
IPAddress gateway; NB_IPAddress gateway;
NetworkComponentType NCT = myType; NetworkComponentType NCT = myType;
if(myType == NetworkComponentType.wrouter) if(myType == NetworkComponentType.wrouter)
{ {
//If we are a wireless router, we could be set up as an access point, or as a router/firewall //If we are a wireless router, we could be set up as an access point, or as a router/firewall
//If the default gateway is on the LAN, we use the gateway. If the default gateway is on the WAN, //If the default gateway is on the LAN, we use the gateway. If the default gateway is on the WAN,
//We use the IP of the firewall IP. (NIC_IP) //We use the IP of the firewall IP. (NIC_IP)
IPAddress tGateway = GetGateway(); NB_IPAddress tGateway = GetGateway();
NetworkCard lNic = LocalNic(tGateway); NetworkCard lNic = LocalNic(tGateway);
if(lNic != null && lNic.GetNicType == NicType.wan) if(lNic != null && lNic.GetNicType == NicType.wan)
{ {
@ -3153,7 +3153,7 @@ namespace EduNetworkBuilder
if (dhcp.MACAddress == MAC && dhcp.IPAddr != NB.ZeroIPString && NIC_IP != null && gateway != null) if (dhcp.MACAddress == MAC && dhcp.IPAddr != NB.ZeroIPString && NIC_IP != null && gateway != null)
{ {
IPAddress addr = new IPAddress(dhcp.IPAddr, NIC_IP.GetMask.ToIpString(), gateway.GetIP.ToIpString()); NB_IPAddress addr = new NB_IPAddress(dhcp.IPAddr, NIC_IP.GetMask.ToIpString(), gateway.GetIP.ToIpString());
if (addr.IsLocal(NIC_IP)) if (addr.IsLocal(NIC_IP))
return addr; return addr;
} }
@ -3183,17 +3183,17 @@ namespace EduNetworkBuilder
/// <param name="MAC">The mac of the requesting machine</param> /// <param name="MAC">The mac of the requesting machine</param>
/// <param name="NIC_IP">the IP of the server nic</param> /// <param name="NIC_IP">the IP of the server nic</param>
/// <returns>an IPAddress IP/Mask/GW</returns> /// <returns>an IPAddress IP/Mask/GW</returns>
public IPAddress RequestDHCPLease(string MAC, IPAddress NIC_IP) public NB_IPAddress RequestDHCPLease(string MAC, NB_IPAddress NIC_IP)
{ {
if (NIC_IP == null) if (NIC_IP == null)
NIC_IP = HubManagementIP(); NIC_IP = HubManagementIP();
IPAddress tAddress = LookupDHCPLease(MAC, NIC_IP); NB_IPAddress tAddress = LookupDHCPLease(MAC, NIC_IP);
if (tAddress != null && NIC_IP.IsLocal(tAddress)) if (tAddress != null && NIC_IP.IsLocal(tAddress))
return tAddress; return tAddress;
//if we are here, we need to find an address to give. //if we are here, we need to find an address to give.
bool stillOK = true; bool stillOK = true;
IPAddress startaddress = DHCPRangeMatchingInterface(NIC_IP); NB_IPAddress startaddress = DHCPRangeMatchingInterface(NIC_IP);
if (startaddress == null) return null; if (startaddress == null) return null;
UInt32 sIPNum = startaddress.GetMask; UInt32 sIPNum = startaddress.GetMask;
UInt32 eIPNum = startaddress.GetGateway; UInt32 eIPNum = startaddress.GetGateway;
@ -3201,17 +3201,17 @@ namespace EduNetworkBuilder
while(stillOK) while(stillOK)
{ {
ipstring = sIPNum.ToIpString(); ipstring = sIPNum.ToIpString();
tAddress = new IPAddress(ipstring, NIC_IP.GetMask.ToIpString(),NB.ZeroIPString); tAddress = new NB_IPAddress(ipstring, NIC_IP.GetMask.ToIpString(),NB.ZeroIPString);
if (!IPAlreadyUsed(ipstring)) if (!IPAlreadyUsed(ipstring))
{ {
MakeDHCPLease(ipstring, MAC); MakeDHCPLease(ipstring, MAC);
IPAddress gateway = GetGateway(); NB_IPAddress gateway = GetGateway();
//If the gateway is not local to the IP address we are giving out, give the IP of this device //If the gateway is not local to the IP address we are giving out, give the IP of this device
if(!tAddress.IsLocal(gateway)) if(!tAddress.IsLocal(gateway))
{ {
gateway = NIC_IP; //Return the firewall IP that it came in on gateway = NIC_IP; //Return the firewall IP that it came in on
} }
return new IPAddress(ipstring,NIC_IP.GetMask.ToIpString(),gateway.GetIP.ToIpString()); return new NB_IPAddress(ipstring,NIC_IP.GetMask.ToIpString(),gateway.GetIP.ToIpString());
} }
sIPNum++; sIPNum++;
if(sIPNum > eIPNum) if(sIPNum > eIPNum)
@ -3238,7 +3238,7 @@ namespace EduNetworkBuilder
return false; return false;
} }
public bool HasLocalNic(IPAddress dest) public bool HasLocalNic(NB_IPAddress dest)
{ {
foreach(NetworkCard nic in NICs) foreach(NetworkCard nic in NICs)
{ {
@ -3328,7 +3328,7 @@ namespace EduNetworkBuilder
if (nic == null) return false; if (nic == null) return false;
NetworkInterface nif = nic.InterfaceFromName(nicname); NetworkInterface nif = nic.InterfaceFromName(nicname);
if (nif == null) return false; if (nif == null) return false;
IPAddress newaddress = new IPAddress("0.0.0.0"); NB_IPAddress newaddress = new NB_IPAddress("0.0.0.0");
Random rnd = NB.GetRandom(); Random rnd = NB.GetRandom();
switch(rnd.Next(8)) switch(rnd.Next(8))
@ -3368,7 +3368,7 @@ namespace EduNetworkBuilder
public bool BreakGateway() public bool BreakGateway()
{ {
IPAddress newaddress = new IPAddress("0.0.0.0"); NB_IPAddress newaddress = new NB_IPAddress("0.0.0.0");
Random rnd = NB.GetRandom(); Random rnd = NB.GetRandom();
switch (rnd.Next(8)) switch (rnd.Next(8))

View File

@ -12,7 +12,7 @@ namespace EduNetworkBuilder
[Serializable] [Serializable]
public class NetworkInterface public class NetworkInterface
{ {
public IPAddress myIP; public NB_IPAddress myIP;
public string nic_name; //eth0, eth0:0, etc public string nic_name; //eth0, eth0:0, etc
public HostNicID AttachedToHostNic; public HostNicID AttachedToHostNic;
public List<VLANInfo> VLANs = new List<VLANInfo>() { new VLANInfo(1, VLANTagType.Untagged ) }; public List<VLANInfo> VLANs = new List<VLANInfo>() { new VLANInfo(1, VLANTagType.Untagged ) };
@ -20,7 +20,7 @@ namespace EduNetworkBuilder
public NetworkInterface(string name, string IP, string Mask, HostNicID AttachedTo) public NetworkInterface(string name, string IP, string Mask, HostNicID AttachedTo)
{ {
nic_name = name; nic_name = name;
myIP = new IPAddress(IP, Mask,IPAddressType.ip); myIP = new NB_IPAddress(IP, Mask,IPAddressType.ip);
AttachedToHostNic = AttachedTo; AttachedToHostNic = AttachedTo;
} }
@ -35,7 +35,7 @@ namespace EduNetworkBuilder
switch (Individual.Name.ToLower()) switch (Individual.Name.ToLower())
{ {
case "myip": case "myip":
myIP = new IPAddress(Individual); myIP = new NB_IPAddress(Individual);
break; break;
case "nicname": case "nicname":
nic_name = Individual.InnerText; nic_name = Individual.InnerText;
@ -186,7 +186,7 @@ namespace EduNetworkBuilder
IPAddressEntry ipe = new IPAddressEntry(myIP,ND, ParentForm); IPAddressEntry ipe = new IPAddressEntry(myIP,ND, ParentForm);
ipe.ShowDialog(); ipe.ShowDialog();
} }
public bool isLocal(IPAddress tIp, bool AllowZeroMatch = true) public bool isLocal(NB_IPAddress tIp, bool AllowZeroMatch = true)
{ {
if (tIp == null) return false; if (tIp == null) return false;
if (!AllowZeroMatch && (myIP == null || myIP.GetIP == 0)) if (!AllowZeroMatch && (myIP == null || myIP.GetIP == 0))

View File

@ -41,16 +41,16 @@ namespace EduNetworkBuilder
public int OrigTTL = 20; //The original TTL. We need to know what we started with so we can pass it back on a traceroute public int OrigTTL = 20; //The original TTL. We need to know what we started with so we can pass it back on a traceroute
public int TickTTL = 50; public int TickTTL = 50;
public int health = 100; public int health = 100;
public IPAddress sourceIP; public NB_IPAddress sourceIP;
public IPAddress OriginalDestIP; public NB_IPAddress OriginalDestIP;
public IPAddress TsourceIP; //This is the local link source ip. It should go along with the local MAC address public NB_IPAddress TsourceIP; //This is the local link source ip. It should go along with the local MAC address
public IPAddress destIP; public NB_IPAddress destIP;
public string sourceMAC; public string sourceMAC;
public string destMAC; public string destMAC;
public Packet payloadPacket = null; public Packet payloadPacket = null;
public string payloadData = ""; //Contains the mac-address, or ip-address string, or something else public string payloadData = ""; //Contains the mac-address, or ip-address string, or something else
public string EncryptionString = ""; public string EncryptionString = "";
public IPAddress payloadIP = null; public NB_IPAddress payloadIP = null;
public PacketMessage Tracking = new PacketMessage(); public PacketMessage Tracking = new PacketMessage();
public NetworkComponent WhereAmI = null; public NetworkComponent WhereAmI = null;
public NetworkLink LastNetworkLink = null; public NetworkLink LastNetworkLink = null;
@ -62,7 +62,7 @@ namespace EduNetworkBuilder
public NetworkCard InboundNic = null; public NetworkCard InboundNic = null;
public NetworkInterface InboundInterface = null; public NetworkInterface InboundInterface = null;
public NetworkInterface OutboundIF = null; public NetworkInterface OutboundIF = null;
public IPAddress OutboundIP = new IPAddress(NB.ZeroIPString); public NB_IPAddress OutboundIP = new NB_IPAddress(NB.ZeroIPString);
public string OutboundMAC = ""; public string OutboundMAC = "";
public string OutboundDestMAC = ""; public string OutboundDestMAC = "";
public bool isFresh = false; //Set to be true if the packet is new. Set false as soon as it is processed public bool isFresh = false; //Set to be true if the packet is new. Set false as soon as it is processed
@ -145,9 +145,9 @@ namespace EduNetworkBuilder
} }
else else
{ {
sourceIP = new IPAddress(source); sourceIP = new NB_IPAddress(source);
TsourceIP = new IPAddress(source); TsourceIP = new NB_IPAddress(source);
destIP = new IPAddress(dest); destIP = new NB_IPAddress(dest);
if (destIP.BroadcastAddress == destIP.GetIP) if (destIP.BroadcastAddress == destIP.GetIP)
{ {
destMAC = NB.BroadcastMACString; destMAC = NB.BroadcastMACString;
@ -160,7 +160,7 @@ namespace EduNetworkBuilder
isFresh = true; isFresh = true;
} }
public Packet(NetworkComponent start, IPAddress dest, string payload, PacketType theType, int NewPacketID = -1, int startTTL =-1) public Packet(NetworkComponent start, NB_IPAddress dest, string payload, PacketType theType, int NewPacketID = -1, int startTTL =-1)
{ {
WhereAmI = start; WhereAmI = start;
payloadData = payload; payloadData = payload;
@ -179,7 +179,7 @@ namespace EduNetworkBuilder
if (theType != PacketType.arp_answer && theType != PacketType.arp_request) if (theType != PacketType.arp_answer && theType != PacketType.arp_request)
{ {
sourceIP = new IPAddress(NB.ZeroIPString); sourceIP = new NB_IPAddress(NB.ZeroIPString);
destIP = dest; destIP = dest;
if (destIP != null && destIP.BroadcastAddress == destIP.GetIP) if (destIP != null && destIP.BroadcastAddress == destIP.GetIP)
destMAC = NB.BroadcastMACString; destMAC = NB.BroadcastMACString;
@ -188,7 +188,7 @@ namespace EduNetworkBuilder
} }
else else
{ {
sourceIP = new IPAddress(NB.ZeroIPString); sourceIP = new NB_IPAddress(NB.ZeroIPString);
destMAC = NB.BroadcastMACString; destMAC = NB.BroadcastMACString;
destIP = dest; destIP = dest;
Tracking.AddMessage(DebugLevel.info, start, NB.Translate("Packet Created")); Tracking.AddMessage(DebugLevel.info, start, NB.Translate("Packet Created"));
@ -299,7 +299,7 @@ namespace EduNetworkBuilder
if (NB.GetComponentType(WhereAmI) == GeneralComponentType.device) if (NB.GetComponentType(WhereAmI) == GeneralComponentType.device)
{ {
NetworkDevice ndWhere = (NetworkDevice)WhereAmI; NetworkDevice ndWhere = (NetworkDevice)WhereAmI;
IPAddress dest = ndWhere.DestinationFromIP(destIP); NB_IPAddress dest = ndWhere.DestinationFromIP(destIP);
string dMAC = ndWhere.ArpFromIP(dest.GetIP.ToIpString()); string dMAC = ndWhere.ArpFromIP(dest.GetIP.ToIpString());
if (dMAC != "" || destMAC == NB.BroadcastMACString) if (dMAC != "" || destMAC == NB.BroadcastMACString)
{ {