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:
parent
0368d6d0f9
commit
f3df4f525a
@ -11,7 +11,7 @@ using System.Text.RegularExpressions;
|
||||
namespace EduNetworkBuilder
|
||||
{
|
||||
[Serializable]
|
||||
public class IPAddress
|
||||
public class NB_IPAddress
|
||||
{
|
||||
|
||||
private UInt32 _ip;
|
||||
@ -19,14 +19,14 @@ namespace EduNetworkBuilder
|
||||
private UInt32 _gw;
|
||||
private IPAddressType myType;
|
||||
|
||||
public IPAddress(string ip, string mask, IPAddressType WhatType)
|
||||
public NB_IPAddress(string ip, string mask, IPAddressType WhatType)
|
||||
{
|
||||
myType = WhatType;
|
||||
_ip = ip.ParseIp();
|
||||
_mask = mask.ParseIp();
|
||||
}
|
||||
|
||||
public IPAddress(string ip, string mask, string gw)
|
||||
public NB_IPAddress(string ip, string mask, string gw)
|
||||
{
|
||||
myType = IPAddressType.route;
|
||||
_ip = ip.ParseIp();
|
||||
@ -34,7 +34,7 @@ namespace EduNetworkBuilder
|
||||
_gw = gw.ParseIp();
|
||||
}
|
||||
|
||||
public IPAddress(XmlNode theNode)
|
||||
public NB_IPAddress(XmlNode theNode)
|
||||
{
|
||||
foreach (XmlNode Individual in theNode.ChildNodes)
|
||||
{
|
||||
@ -87,7 +87,7 @@ namespace EduNetworkBuilder
|
||||
get { return myType; }
|
||||
}
|
||||
|
||||
public bool IsLocal(IPAddress dest)
|
||||
public bool IsLocal(NB_IPAddress dest)
|
||||
{
|
||||
if (dest == null) return false;
|
||||
UInt32 answer = dest.GetIP & _mask;
|
||||
@ -105,13 +105,13 @@ namespace EduNetworkBuilder
|
||||
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);
|
||||
return IPe.Edit(FromWhat, DHCPif);
|
||||
}
|
||||
|
||||
public IPAddress(string ip)
|
||||
public NB_IPAddress(string ip)
|
||||
{
|
||||
if (ip == null) ip = NB.ZeroIPString;
|
||||
myType = IPAddressType.ip;
|
||||
@ -292,57 +292,57 @@ namespace EduNetworkBuilder
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
public IPAddress BreakIPNetmaskRandom()
|
||||
public NB_IPAddress BreakIPNetmaskRandom()
|
||||
{
|
||||
string randomMask = "";
|
||||
do
|
||||
{
|
||||
randomMask = GenRandomIPOrMask();
|
||||
} while (randomMask == GetMaskString);
|
||||
IPAddress one = new IPAddress(GetIPString, randomMask, myType);
|
||||
NB_IPAddress one = new NB_IPAddress(GetIPString, randomMask, myType);
|
||||
return one;
|
||||
}
|
||||
public IPAddress BreakIPNetmaskMangle()
|
||||
public NB_IPAddress BreakIPNetmaskMangle()
|
||||
{
|
||||
string newmask = randomizeOctects(GetMaskString);
|
||||
IPAddress one = new IPAddress(GetIPString, newmask, myType);
|
||||
NB_IPAddress one = new NB_IPAddress(GetIPString, newmask, myType);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
public IPAddress BreakIPAddressRandom()
|
||||
public NB_IPAddress BreakIPAddressRandom()
|
||||
{
|
||||
string randomIP = "";
|
||||
do
|
||||
{
|
||||
randomIP = GenRandomIPOrMask();
|
||||
} while (randomIP == GetMaskString);
|
||||
IPAddress one = new IPAddress(randomIP, GetMaskString, myType);
|
||||
NB_IPAddress one = new NB_IPAddress(randomIP, GetMaskString, myType);
|
||||
return one;
|
||||
}
|
||||
public IPAddress BreakIPAddressMangle()
|
||||
public NB_IPAddress BreakIPAddressMangle()
|
||||
{
|
||||
string newip = randomizeOctects(GetMaskString);
|
||||
IPAddress one = new IPAddress(newip, GetMaskString, myType);
|
||||
NB_IPAddress one = new NB_IPAddress(newip, GetMaskString, myType);
|
||||
return one;
|
||||
}
|
||||
#endregion
|
||||
|
@ -15,14 +15,14 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
public partial class IPAddressEntry : Form
|
||||
{
|
||||
IPAddress WhatToEdit;
|
||||
IPAddress DHCPInterface=null;
|
||||
NB_IPAddress WhatToEdit;
|
||||
NB_IPAddress DHCPInterface=null;
|
||||
bool WellDone = true;
|
||||
NetworkDevice ParentDevice = null;
|
||||
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();
|
||||
LanguagifyComponents();
|
||||
@ -33,7 +33,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
ParentDevice = ToEdit;
|
||||
Network myNet = NB.GetNetwork();
|
||||
IPAddress lastIP = myNet.RetrieveLastIP();
|
||||
NB_IPAddress lastIP = myNet.RetrieveLastIP();
|
||||
WhatToEdit = toEdit;
|
||||
string hostname = "";
|
||||
if (ToEdit != null)
|
||||
@ -158,7 +158,7 @@ namespace EduNetworkBuilder
|
||||
return WellDone;
|
||||
}
|
||||
|
||||
public bool Edit(NetworkDevice ToEdit, IPAddress DHCPif)
|
||||
public bool Edit(NetworkDevice ToEdit, NB_IPAddress DHCPif)
|
||||
{
|
||||
DHCPInterface = DHCPif;
|
||||
lblIP.Text = NB.Translate("IPAE_EditIf");
|
||||
@ -192,7 +192,7 @@ namespace EduNetworkBuilder
|
||||
Network mynet = NB.GetNetwork();
|
||||
if (ParentDevice != null)
|
||||
{
|
||||
IPAddress tAddress = mynet.DNSLookup(ParentDevice, tbGateway.Text);
|
||||
NB_IPAddress tAddress = mynet.DNSLookup(ParentDevice, tbGateway.Text);
|
||||
}
|
||||
|
||||
UInt32 taddress = tbGateway.Text.ParseIp();
|
||||
@ -201,7 +201,7 @@ namespace EduNetworkBuilder
|
||||
if (DHCPInterface != null)
|
||||
{
|
||||
//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;
|
||||
MessageBox.Show(NB.Translate("IPAE_tbGateValEndIPRange"));
|
||||
@ -221,7 +221,7 @@ namespace EduNetworkBuilder
|
||||
if (DHCPInterface != null)
|
||||
{
|
||||
//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;
|
||||
MessageBox.Show(NB.Translate("IPAE_tbNtmskValEndIPRange"));
|
||||
@ -233,7 +233,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
UInt32 taddress;
|
||||
Network mynet = NB.GetNetwork();
|
||||
IPAddress tIPAddress = null;
|
||||
NB_IPAddress tIPAddress = null;
|
||||
if (ParentDevice != null)
|
||||
{
|
||||
tIPAddress = mynet.DNSLookup(ParentDevice, tbIPAddress.Text);
|
||||
|
@ -487,7 +487,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
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"));
|
||||
myNetDevice.AddRoute(newip);
|
||||
UpdateForm();
|
||||
|
@ -170,18 +170,18 @@ namespace EduNetworkBuilder
|
||||
[Serializable]
|
||||
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 ResponseToPacket Response; //accept, masq
|
||||
public IPAddress internalIP; //Used if we are masquerading
|
||||
public IPConnectionEntry(IPAddress dest, PacketType what, ResponseToPacket response)
|
||||
public NB_IPAddress internalIP; //Used if we are masquerading
|
||||
public IPConnectionEntry(NB_IPAddress dest, PacketType what, ResponseToPacket response)
|
||||
{
|
||||
destIP = dest;
|
||||
What = what;
|
||||
Response = response;
|
||||
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;
|
||||
What = what;
|
||||
|
@ -471,8 +471,8 @@ namespace EduNetworkBuilder
|
||||
if(theNet == null) theNet= NB.GetNetwork();
|
||||
NetworkDevice Source = theNet.GetDeviceFromName(sHost);
|
||||
NetworkDevice Dest = theNet.GetDeviceFromName(dHost);
|
||||
IPAddress gw;
|
||||
IPAddress tAddr;
|
||||
NB_IPAddress gw;
|
||||
NB_IPAddress tAddr;
|
||||
|
||||
switch(TheTest)
|
||||
{
|
||||
@ -496,11 +496,11 @@ namespace EduNetworkBuilder
|
||||
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)
|
||||
tAddr = new IPAddress(dHost);
|
||||
tAddr = new NB_IPAddress(dHost);
|
||||
if (Source.HasRouteMatching(tAddr))
|
||||
{
|
||||
IPAddress route = Source.RouteMatching(tAddr);
|
||||
if (Source.LocalNic(new IPAddress(route.GetGateway.ToIpString())) == null)
|
||||
NB_IPAddress route = Source.RouteMatching(tAddr);
|
||||
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 true;
|
||||
}
|
||||
@ -509,7 +509,7 @@ namespace EduNetworkBuilder
|
||||
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.
|
||||
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 (!theNet.HasUniqueIP(tAddr, Source)) return false; //Verify we have not given the IP to someone else
|
||||
if (tAddr != null &&
|
||||
|
@ -244,7 +244,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
//return all the dhcp ranges
|
||||
sItem = theNet.GetDeviceFromName(ToEdit.sHost);
|
||||
foreach (IPAddress ip in sItem.IPAddressList())
|
||||
foreach (NB_IPAddress ip in sItem.IPAddressList())
|
||||
{
|
||||
cbDest.Items.Add(ip.GetIPString);
|
||||
}
|
||||
@ -253,7 +253,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
//return all the dhcp ranges
|
||||
sItem = theNet.GetDeviceFromName(ToEdit.sHost);
|
||||
foreach (IPAddress ip in sItem.ListRoutes())
|
||||
foreach (NB_IPAddress ip in sItem.ListRoutes())
|
||||
{
|
||||
cbDest.Items.Add(ip.GetIPString);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace EduNetworkBuilder
|
||||
private List<Packet> myPackets = new List<Packet>();
|
||||
private List<PacketMessage> myMessages = new List<PacketMessage>();
|
||||
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 List<NetTest> NetTests = new List<NetTest>();
|
||||
private bool AlreadyDisplayedMessage = false;
|
||||
@ -724,12 +724,12 @@ namespace EduNetworkBuilder
|
||||
_isDirty = true;
|
||||
}
|
||||
|
||||
public void StoreLastIP(IPAddress ip)
|
||||
public void StoreLastIP(NB_IPAddress ip)
|
||||
{
|
||||
lastAddress = ip;
|
||||
}
|
||||
|
||||
public IPAddress RetrieveLastIP()
|
||||
public NB_IPAddress RetrieveLastIP()
|
||||
{
|
||||
return lastAddress;
|
||||
}
|
||||
@ -962,7 +962,7 @@ namespace EduNetworkBuilder
|
||||
/// <param name="ToFind">The IP address to find</param>
|
||||
/// <param name="Source">The device that has it</param>
|
||||
/// <returns></returns>
|
||||
public bool HasUniqueIP(IPAddress ToFind, NetworkDevice Source)
|
||||
public bool HasUniqueIP(NB_IPAddress ToFind, NetworkDevice Source)
|
||||
{
|
||||
NetworkDevice ND;
|
||||
foreach (NetworkComponent nc in NetComponents)
|
||||
@ -1234,7 +1234,7 @@ namespace EduNetworkBuilder
|
||||
/// <param name="packet_type">The type of packet that arrived</param>
|
||||
/// <param name="sHost">The host it originated from</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 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.
|
||||
string sHost = ReverseDNSLookup(source, sIP);
|
||||
@ -1286,15 +1286,15 @@ namespace EduNetworkBuilder
|
||||
public bool NoteActionDone(NetTestType theTest, string sHost, string dHost)
|
||||
{
|
||||
bool OldVal = false;
|
||||
IPAddress sourceIP;
|
||||
NB_IPAddress sourceIP;
|
||||
string sourceIPstring;
|
||||
IPAddress destIP;
|
||||
NB_IPAddress destIP;
|
||||
string destIPstring;
|
||||
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
|
||||
destIP = new IPAddress(dHost);
|
||||
destIP = new NB_IPAddress(dHost);
|
||||
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) &&
|
||||
(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))
|
||||
@ -1747,7 +1747,7 @@ namespace EduNetworkBuilder
|
||||
nd = (NetworkDevice)nc;
|
||||
if(nd.hostname == toFind)
|
||||
{
|
||||
IPAddress found = nd.BestIPForThis(source);
|
||||
NB_IPAddress found = nd.BestIPForThis(source);
|
||||
return found;
|
||||
}
|
||||
}
|
||||
@ -1755,7 +1755,7 @@ namespace EduNetworkBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
public string ReverseDNSLookup(NetworkDevice source, IPAddress toFind)
|
||||
public string ReverseDNSLookup(NetworkDevice source, NB_IPAddress toFind)
|
||||
{
|
||||
if (source != null && source.HasIPAddress(toFind))
|
||||
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;
|
||||
foreach (NetworkComponent nc in NetComponents)
|
||||
@ -2164,7 +2164,7 @@ namespace EduNetworkBuilder
|
||||
|
||||
foreach (NetTest NT in NetTests)
|
||||
{
|
||||
IPAddress destination;
|
||||
NB_IPAddress destination;
|
||||
NetworkDevice src = null;
|
||||
//Here we do any pings or actions
|
||||
switch (NT.TheTest)
|
||||
@ -2177,7 +2177,7 @@ namespace EduNetworkBuilder
|
||||
if (src == null) continue;
|
||||
destination = DNSLookup(src, NT.dHost);
|
||||
if (destination == null || destination.GetIPString == NB.ZeroIPString)
|
||||
destination = new IPAddress(NT.dHost);
|
||||
destination = new NB_IPAddress(NT.dHost);
|
||||
src.PingFromHere(destination);
|
||||
break;
|
||||
case NetTestType.SuccessfullyArps:
|
||||
@ -2185,7 +2185,7 @@ namespace EduNetworkBuilder
|
||||
if (src == null) continue;
|
||||
destination = DNSLookup(src, NT.dHost);
|
||||
if (destination == null || destination.GetIPString == NB.ZeroIPString)
|
||||
destination = new IPAddress(NT.dHost);
|
||||
destination = new NB_IPAddress(NT.dHost);
|
||||
src.AskArpFromHere(destination);
|
||||
break;
|
||||
case NetTestType.SuccessfullyTraceroutes:
|
||||
@ -2193,7 +2193,7 @@ namespace EduNetworkBuilder
|
||||
if (src == null) continue;
|
||||
destination = DNSLookup(src, NT.dHost);
|
||||
if (destination == null || destination.GetIPString == NB.ZeroIPString)
|
||||
destination = new IPAddress(NT.dHost);
|
||||
destination = new NB_IPAddress(NT.dHost);
|
||||
src.TracerouteFromHere(destination);
|
||||
break;
|
||||
}
|
||||
@ -2224,7 +2224,7 @@ namespace EduNetworkBuilder
|
||||
NB.RegisterInvisibleNetwork(this);
|
||||
NetworkDevice src = GetDeviceFromName(source);
|
||||
if (src == null) return null;
|
||||
IPAddress destination = DNSLookup(src, dest);
|
||||
NB_IPAddress destination = DNSLookup(src, dest);
|
||||
src.PingFromHere(destination);
|
||||
NonVisualProcessPacketsOnce();
|
||||
NB.UnregisterInvisibleNetwork();
|
||||
|
@ -1338,7 +1338,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
bool todo = true;
|
||||
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);
|
||||
if(todo)
|
||||
{
|
||||
@ -1352,7 +1352,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
bool todo = true;
|
||||
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);
|
||||
if (todo)
|
||||
{
|
||||
@ -1368,10 +1368,10 @@ namespace EduNetworkBuilder
|
||||
ToolStripMenuItem Pressed = (ToolStripMenuItem)sender;
|
||||
string itemname = Pressed.Text;
|
||||
string dest = (string)Pressed.Tag;
|
||||
IPAddress destination;
|
||||
NB_IPAddress destination;
|
||||
destination = myNetwork.DNSLookup(ItemClickedOn, dest);
|
||||
if(destination == null || destination.GetIPString == NB.ZeroIPString)
|
||||
destination = new IPAddress(dest);
|
||||
destination = new NB_IPAddress(dest);
|
||||
ItemClickedOn.PingFromHere(destination);
|
||||
myNetwork.ProcessPackets();
|
||||
UpdateMessages();
|
||||
@ -1383,10 +1383,10 @@ namespace EduNetworkBuilder
|
||||
ToolStripMenuItem Pressed = (ToolStripMenuItem)sender;
|
||||
string itemname = Pressed.Text;
|
||||
string dest = (string)Pressed.Tag;
|
||||
IPAddress destination;
|
||||
NB_IPAddress destination;
|
||||
destination = myNetwork.DNSLookup(ItemClickedOn, dest);
|
||||
if (destination == null || destination.GetIPString == NB.ZeroIPString)
|
||||
destination = new IPAddress(dest);
|
||||
destination = new NB_IPAddress(dest);
|
||||
ItemClickedOn.TracerouteFromHere(destination);
|
||||
myNetwork.ProcessPackets();
|
||||
UpdateMessages();
|
||||
@ -1398,10 +1398,10 @@ namespace EduNetworkBuilder
|
||||
ToolStripMenuItem Pressed = (ToolStripMenuItem)sender;
|
||||
string itemname = Pressed.Text;
|
||||
string dest = (string)Pressed.Tag;
|
||||
IPAddress destination;
|
||||
NB_IPAddress destination;
|
||||
destination = myNetwork.DNSLookup(ItemClickedOn, dest);
|
||||
if (destination == null || destination.GetIPString == NB.ZeroIPString)
|
||||
destination = new IPAddress(dest);
|
||||
destination = new NB_IPAddress(dest);
|
||||
ItemClickedOn.AskArpFromHere(destination);
|
||||
myNetwork.ProcessPackets();
|
||||
UpdateMessages();
|
||||
@ -1411,7 +1411,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
bool todo = true;
|
||||
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"));
|
||||
if (todo)
|
||||
{
|
||||
@ -2031,7 +2031,7 @@ namespace EduNetworkBuilder
|
||||
private void pingToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
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"));
|
||||
if (todo)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ namespace EduNetworkBuilder
|
||||
public int ConnectedLink=-1; //The link that is connected to this nic.
|
||||
private int UniqueIdentifier = NB.GetUniqueIdentifier();
|
||||
private string _nic_name="";
|
||||
public IPAddress TunnelEndpoint;
|
||||
public NB_IPAddress TunnelEndpoint;
|
||||
public string EncryptionKey;
|
||||
public string SSID;
|
||||
public string WirelessKey
|
||||
@ -83,7 +83,7 @@ namespace EduNetworkBuilder
|
||||
MAC = tmac.ToUpper(); //Make sure it is all uppercase
|
||||
break;
|
||||
case "tunnelendpoint":
|
||||
TunnelEndpoint = new IPAddress(Individual);
|
||||
TunnelEndpoint = new NB_IPAddress(Individual);
|
||||
break;
|
||||
case "encryptionkey":
|
||||
EncryptionKey = Individual.InnerText;
|
||||
@ -210,9 +210,9 @@ namespace EduNetworkBuilder
|
||||
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.none) return theIPs;
|
||||
foreach (NetworkInterface iface in interfaces)
|
||||
@ -222,7 +222,7 @@ namespace EduNetworkBuilder
|
||||
return theIPs;
|
||||
}
|
||||
|
||||
public bool HasIPAddresses(IPAddress dest)
|
||||
public bool HasIPAddresses(NB_IPAddress dest)
|
||||
{
|
||||
if (myNicType == NicType.port) return false;
|
||||
if (myNicType == NicType.none) return false;
|
||||
@ -235,7 +235,7 @@ namespace EduNetworkBuilder
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasBroadcastAddresses(IPAddress dest)
|
||||
public bool HasBroadcastAddresses(NB_IPAddress dest)
|
||||
{
|
||||
if (myNicType == NicType.port) 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)
|
||||
{
|
||||
@ -390,7 +390,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasLocalInterface(IPAddress theIP)
|
||||
public bool HasLocalInterface(NB_IPAddress theIP)
|
||||
{
|
||||
foreach(NetworkInterface nIF in interfaces)
|
||||
{
|
||||
@ -405,7 +405,7 @@ namespace EduNetworkBuilder
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public NetworkInterface LocalInterface(IPAddress theIP, PacketMessage Tracker)
|
||||
public NetworkInterface LocalInterface(NB_IPAddress theIP, PacketMessage Tracker)
|
||||
{
|
||||
if (myNicType == NicType.port)
|
||||
{
|
||||
@ -777,7 +777,7 @@ namespace EduNetworkBuilder
|
||||
|
||||
if (nd.HowToRespondToPacket(tPacket) == ResponseToPacket.masq)
|
||||
{
|
||||
IPAddress oAddress = nd.PacketMasqueradeSource(tPacket);
|
||||
NB_IPAddress oAddress = nd.PacketMasqueradeSource(tPacket);
|
||||
if(oAddress != null)
|
||||
{
|
||||
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)
|
||||
{
|
||||
nf.myIP = new IPAddress(NB.ZeroIPString);
|
||||
nf.myIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
nf.SetVLANTag(1, VLANTagType.Untagged);
|
||||
}
|
||||
}
|
||||
@ -832,7 +832,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
if (myNicType != NicType.lo)
|
||||
{
|
||||
nf.myIP = new IPAddress(NB.ZeroIPString);
|
||||
nf.myIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
nf.LockOutVLANInterface();
|
||||
}
|
||||
}
|
||||
@ -863,13 +863,13 @@ namespace EduNetworkBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
public IPAddress FirstIP()
|
||||
public NB_IPAddress FirstIP()
|
||||
{
|
||||
List<IPAddress> addresses = IPAddressList();
|
||||
List<NB_IPAddress> addresses = IPAddressList();
|
||||
if (addresses.Count > 0)
|
||||
return addresses[0];
|
||||
else
|
||||
return new IPAddress(NB.ZeroIPString);
|
||||
return new NB_IPAddress(NB.ZeroIPString);
|
||||
}
|
||||
|
||||
public static T Clone<T>(T source)
|
||||
|
@ -194,7 +194,7 @@ namespace EduNetworkBuilder
|
||||
NetworkDevice nd = theNet.GetDeviceFromID(MyNicToEdit.myID);
|
||||
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"));
|
||||
SaveDataToNic();
|
||||
|
@ -15,14 +15,14 @@ namespace EduNetworkBuilder
|
||||
public class NetworkDevice : NetworkComponent
|
||||
{
|
||||
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 Point MyLocation;
|
||||
public int Size;
|
||||
protected List<ArpEntry> ArpTable = new List<ArpEntry>();
|
||||
protected NetworkComponentType myType = NetworkComponentType.none;
|
||||
protected List<IPAddress> RouteTable = new List<IPAddress>();
|
||||
protected List<IPAddress> DHCPRanges = new List<IPAddress>();
|
||||
protected List<NB_IPAddress> RouteTable = new List<NB_IPAddress>();
|
||||
protected List<NB_IPAddress> DHCPRanges = new List<NB_IPAddress>();
|
||||
protected List<ArpEntry> DHCPLeases = new List<ArpEntry>();
|
||||
protected List<IPConnectionEntry> IPConnections = new List<IPConnectionEntry>();
|
||||
protected bool isDNSServer = false;
|
||||
@ -301,7 +301,7 @@ namespace EduNetworkBuilder
|
||||
DefaultGW.Edit(this,ParentForm,NB.Translate("ND_EdtGteway"));
|
||||
}
|
||||
|
||||
public IPAddress GetGateway()
|
||||
public NB_IPAddress GetGateway()
|
||||
{
|
||||
if(CanUseDHCP)
|
||||
{
|
||||
@ -310,10 +310,10 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
if(nic.UsesDHCP)
|
||||
{
|
||||
List<IPAddress> tlist = nic.IPAddressList();
|
||||
List<NB_IPAddress> tlist = nic.IPAddressList();
|
||||
if(tlist.Count > 0)
|
||||
{
|
||||
IPAddress newIP = new IPAddress(tlist[0].GetGateway.ToIpString());
|
||||
NB_IPAddress newIP = new NB_IPAddress(tlist[0].GetGateway.ToIpString());
|
||||
return newIP;
|
||||
}
|
||||
}
|
||||
@ -364,7 +364,7 @@ namespace EduNetworkBuilder
|
||||
int.TryParse(Individual.InnerText, out UniqueIdentifier);
|
||||
break;
|
||||
case "gateway":
|
||||
DefaultGW = new IPAddress(Individual);
|
||||
DefaultGW = new NB_IPAddress(Individual);
|
||||
break;
|
||||
case "hostname":
|
||||
hostname = Individual.InnerText;
|
||||
@ -377,7 +377,7 @@ namespace EduNetworkBuilder
|
||||
NICs.Add(newNic);
|
||||
break;
|
||||
case "route":
|
||||
IPAddress ip = new IPAddress(Individual);
|
||||
NB_IPAddress ip = new NB_IPAddress(Individual);
|
||||
RouteTable.Add(ip);
|
||||
break;
|
||||
case "isdns":
|
||||
@ -390,7 +390,7 @@ namespace EduNetworkBuilder
|
||||
bool.TryParse(Individual.InnerText, out isDHCPServer);
|
||||
break;
|
||||
case "dhcprange":
|
||||
IPAddress dhcpip = new IPAddress(Individual);
|
||||
NB_IPAddress dhcpip = new NB_IPAddress(Individual);
|
||||
DHCPRanges.Add(dhcpip);
|
||||
break;
|
||||
case "hasadvfirewall":
|
||||
@ -441,11 +441,11 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
nic.Save(writer);
|
||||
}
|
||||
foreach (IPAddress ip in RouteTable)
|
||||
foreach (NB_IPAddress ip in RouteTable)
|
||||
{
|
||||
ip.Save(writer, "route");
|
||||
}
|
||||
foreach (IPAddress dhcp in DHCPRanges)
|
||||
foreach (NB_IPAddress dhcp in DHCPRanges)
|
||||
{
|
||||
dhcp.Save(writer, "dhcprange");
|
||||
}
|
||||
@ -1290,7 +1290,7 @@ namespace EduNetworkBuilder
|
||||
return tList;
|
||||
}
|
||||
|
||||
public bool HasIPAddress(IPAddress dest)
|
||||
public bool HasIPAddress(NB_IPAddress dest)
|
||||
{
|
||||
foreach(NetworkCard nic in NICs)
|
||||
{
|
||||
@ -1300,10 +1300,10 @@ namespace EduNetworkBuilder
|
||||
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
|
||||
foreach (IPAddress ip in RouteTable)
|
||||
foreach (NB_IPAddress ip in RouteTable)
|
||||
{
|
||||
if (dest.GetMask != 0 && dest.GetMask.ToIpString() != "255.255.255.0")
|
||||
{
|
||||
@ -1319,15 +1319,15 @@ namespace EduNetworkBuilder
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
public bool HasRouteMatching(string destString)
|
||||
{
|
||||
IPAddress dest = new IPAddress(destString);
|
||||
NB_IPAddress dest = new NB_IPAddress(destString);
|
||||
if (dest.GetIPString == NB.ZeroIPString) return false;
|
||||
return HasRouteMatching(dest);
|
||||
}
|
||||
@ -1341,7 +1341,7 @@ namespace EduNetworkBuilder
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
public bool HasBroadcastAddress(IPAddress dest)
|
||||
public bool HasBroadcastAddress(NB_IPAddress dest)
|
||||
{
|
||||
if (dest.BroadcastAddress == dest.GetIP) return true;
|
||||
foreach(NetworkCard nic in NICs)
|
||||
@ -1475,7 +1475,7 @@ namespace EduNetworkBuilder
|
||||
nic.SetIPForDHCP(); //clear the source IP
|
||||
}
|
||||
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();
|
||||
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;
|
||||
//We need to create a packet
|
||||
@ -1512,7 +1512,7 @@ namespace EduNetworkBuilder
|
||||
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 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
|
||||
}
|
||||
|
||||
public void AskArpFromHere(IPAddress Destination, PacketMessage Tracker=null)
|
||||
public void AskArpFromHere(NB_IPAddress Destination, PacketMessage Tracker=null)
|
||||
{
|
||||
//We need to create a packet
|
||||
if (isFrozen() || IsBurned || PowerOff) return;
|
||||
@ -1533,7 +1533,7 @@ namespace EduNetworkBuilder
|
||||
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)
|
||||
{
|
||||
@ -1612,7 +1612,7 @@ namespace EduNetworkBuilder
|
||||
return ResponseToPacket.reject;
|
||||
}
|
||||
|
||||
public IPAddress PacketMasqueradeSource(Packet tPacket)
|
||||
public NB_IPAddress PacketMasqueradeSource(Packet tPacket)
|
||||
{
|
||||
bool typesMatch = false;
|
||||
foreach (IPConnectionEntry ipc in IPConnections)
|
||||
@ -1712,8 +1712,8 @@ namespace EduNetworkBuilder
|
||||
if(MacAddressMatch || tPacket.isFresh)
|
||||
{
|
||||
//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);
|
||||
IPAddress dest = DestinationFromIP(tPacket.destIP); //Get the IP, or GW
|
||||
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.GetIPString != NB.BroadcastIPString)
|
||||
{
|
||||
//No gateway set and no route...
|
||||
@ -2007,7 +2007,7 @@ namespace EduNetworkBuilder
|
||||
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.MyStatus = PacketStatus.finished_ok;
|
||||
IPAddress tip = nPacket.sourceIP;
|
||||
NB_IPAddress tip = nPacket.sourceIP;
|
||||
if (!HasBroadcastAddress(tPacket.destIP))
|
||||
{
|
||||
nPacket.sourceIP = tPacket.destIP;
|
||||
@ -2015,8 +2015,8 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
else
|
||||
{
|
||||
nPacket.sourceIP = new IPAddress(NB.ZeroIPString);
|
||||
nPacket.TsourceIP = new IPAddress(NB.ZeroIPString);
|
||||
nPacket.sourceIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
nPacket.TsourceIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
}
|
||||
if (tip.GetIP.ToIpString() != NB.ZeroIPString)
|
||||
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
|
||||
//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 ||
|
||||
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.
|
||||
//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;
|
||||
|
||||
//Console.WriteLine("Tracert: " + tPacket.OrigTTL + " " + tPacket.sourceIP.GetIPString);
|
||||
@ -2143,7 +2143,7 @@ namespace EduNetworkBuilder
|
||||
if (nPacket.TsourceIP == null) nPacket.TsourceIP = nPacket.sourceIP;
|
||||
StoreArp(nPacket.sourceMAC, nPacket.TsourceIP.GetIP.ToIpString(), theID);
|
||||
//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.TsourceIP = nPacket.destIP;
|
||||
nPacket.destIP = tip;
|
||||
@ -2212,7 +2212,7 @@ namespace EduNetworkBuilder
|
||||
nPacket.Tracking = new PacketMessage();
|
||||
myNet.addPacket(nPacket);
|
||||
//We need to find a dhcp IP for this.
|
||||
IPAddress dst;
|
||||
NB_IPAddress dst;
|
||||
if (tPacket.InboundInterface == null)
|
||||
{
|
||||
dst = RequestDHCPLease(tPacket.sourceMAC, tPacket.OutboundIP);
|
||||
@ -2226,7 +2226,7 @@ namespace EduNetworkBuilder
|
||||
//if the packet came in on a 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)
|
||||
dst = RequestDHCPLease(tPacket.sourceMAC, theIP);
|
||||
}
|
||||
@ -2248,7 +2248,7 @@ namespace EduNetworkBuilder
|
||||
string IP = "";
|
||||
if (nPacket.sourceIP != null) IP = nPacket.sourceIP.GetIPString;
|
||||
if(IP == "" && nPacket.WhereAmI != null) {
|
||||
IPAddress tIP = HubManagementIP();
|
||||
NB_IPAddress tIP = HubManagementIP();
|
||||
if (tIP != null) IP = tIP.GetIPString;
|
||||
}
|
||||
tPacket.Tracking.Status = NB.LeftPad(hostname) + " " + string.Format(NB.Translate("ND_ProssArrDHCPStr"), IP);
|
||||
@ -2268,7 +2268,7 @@ namespace EduNetworkBuilder
|
||||
if (tnic != null)
|
||||
{
|
||||
if (tPacket.payloadIP == null)
|
||||
tPacket.payloadIP = new IPAddress(NB.ZeroIPString);
|
||||
tPacket.payloadIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
tnic.SetIPForDHCP(tPacket.payloadIP);
|
||||
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());
|
||||
@ -2292,11 +2292,11 @@ namespace EduNetworkBuilder
|
||||
tPacket.MyStatus = PacketStatus.finished; //Different things may have different finished things.
|
||||
}
|
||||
|
||||
public IPAddress LocalDeviceIP(NetworkDevice FromWhat)
|
||||
public NB_IPAddress LocalDeviceIP(NetworkDevice FromWhat)
|
||||
{
|
||||
NetworkInterface nif;
|
||||
List<IPAddress> myList = FromWhat.IPAddressList();
|
||||
foreach (IPAddress ip in myList.ToList())
|
||||
List<NB_IPAddress> myList = FromWhat.IPAddressList();
|
||||
foreach (NB_IPAddress ip in myList.ToList())
|
||||
{
|
||||
foreach (NetworkCard tNic in NICs)
|
||||
{
|
||||
@ -2313,9 +2313,9 @@ namespace EduNetworkBuilder
|
||||
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)
|
||||
{
|
||||
if(tNic.GetNicType == NicType.management_interface)
|
||||
@ -2378,9 +2378,9 @@ namespace EduNetworkBuilder
|
||||
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)
|
||||
{
|
||||
thelist.AddRange(nic.IPAddressList());
|
||||
@ -2391,7 +2391,7 @@ namespace EduNetworkBuilder
|
||||
public List<string> SubnetList()
|
||||
{
|
||||
List<string> thelist = new List<string>();
|
||||
foreach(IPAddress taddr in IPAddressList())
|
||||
foreach(NB_IPAddress taddr in IPAddressList())
|
||||
{
|
||||
if(!thelist.Contains(taddr.NetworkAddress.ToIpString()))
|
||||
{
|
||||
@ -2404,7 +2404,7 @@ namespace EduNetworkBuilder
|
||||
public List<string> BroadcastList()
|
||||
{
|
||||
List<string> thelist = new List<string>();
|
||||
foreach (IPAddress taddr in IPAddressList())
|
||||
foreach (NB_IPAddress taddr in IPAddressList())
|
||||
{
|
||||
if (!thelist.Contains(taddr.BroadcastAddress.ToIpString()))
|
||||
{
|
||||
@ -2420,16 +2420,16 @@ namespace EduNetworkBuilder
|
||||
/// </summary>
|
||||
/// <param name="dest">The target IP</param>
|
||||
/// <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;
|
||||
NetworkCard tCard = null;
|
||||
IPAddress DestAddr;
|
||||
NB_IPAddress DestAddr;
|
||||
string DHCPGW = "";
|
||||
foreach( IPAddress ip in RouteTable)
|
||||
foreach( NB_IPAddress ip in RouteTable)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -2447,19 +2447,19 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
if (oNic != null)
|
||||
{
|
||||
List<IPAddress> tlist = oNic.IPAddressList();
|
||||
List<NB_IPAddress> tlist = oNic.IPAddressList();
|
||||
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 != "")
|
||||
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.
|
||||
return DefaultGW;
|
||||
}
|
||||
|
||||
public bool PrepPacketForSending(Packet tPacket, IPAddress dest)
|
||||
public bool PrepPacketForSending(Packet tPacket, NB_IPAddress dest)
|
||||
{
|
||||
if((tPacket.OutboundMAC == null || tPacket.OutboundMAC == "") &&
|
||||
tPacket.MyType == PacketType.dhcp_request &&
|
||||
@ -2474,7 +2474,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
nic.SetIPForDHCP();
|
||||
Packet nPacket = new Packet(tPacket);
|
||||
nPacket.OutboundIP = new IPAddress(NB.ZeroIPString);
|
||||
nPacket.OutboundIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
nPacket.OutboundMAC = nic.MAC;
|
||||
nPacket.OutboundNic = nic;
|
||||
nPacket.OutboundIF = nic.GetInterface(0);
|
||||
@ -2495,11 +2495,11 @@ namespace EduNetworkBuilder
|
||||
Network myNet = NB.GetNetwork();
|
||||
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
|
||||
Packet nPacket = new Packet(tPacket);
|
||||
nPacket.OutboundIP = new IPAddress(NB.ZeroIPString);
|
||||
nPacket.OutboundIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
nPacket.OutboundMAC = nic.MAC;
|
||||
nPacket.destMAC = NB.BroadcastMACString;
|
||||
nPacket.OutboundNic = nic;
|
||||
@ -2595,7 +2595,7 @@ namespace EduNetworkBuilder
|
||||
/// </summary>
|
||||
/// <param name="toFind">The IP Address we are looking for</param>
|
||||
/// <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;
|
||||
foreach (NetworkCard nic in NICs)
|
||||
@ -2643,13 +2643,13 @@ namespace EduNetworkBuilder
|
||||
return answer;
|
||||
}
|
||||
|
||||
private IPAddress IPFromTypeNic(NicType What)
|
||||
private NB_IPAddress IPFromTypeNic(NicType What)
|
||||
{
|
||||
foreach(NetworkCard nic in NB.Randomize(NICs).ToList())
|
||||
{
|
||||
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)
|
||||
return ip;
|
||||
@ -2659,9 +2659,9 @@ namespace EduNetworkBuilder
|
||||
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)
|
||||
{
|
||||
answer = LocalDeviceIP(Source);
|
||||
@ -2689,17 +2689,17 @@ namespace EduNetworkBuilder
|
||||
public List<string> DeviceRouteStrings()
|
||||
{
|
||||
List<string> answer = new List<string>();
|
||||
foreach (IPAddress ip in RouteTable)
|
||||
foreach (NB_IPAddress ip in RouteTable)
|
||||
{
|
||||
answer.Add(ip.IPFormat());
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
public void AddRoute(IPAddress route)
|
||||
public void AddRoute(NB_IPAddress route)
|
||||
{
|
||||
RouteTable.Add(route);
|
||||
}
|
||||
public List<IPAddress> ListRoutes()
|
||||
public List<NB_IPAddress> ListRoutes()
|
||||
{
|
||||
return RouteTable;
|
||||
}
|
||||
@ -2773,7 +2773,7 @@ namespace EduNetworkBuilder
|
||||
NetworkInterface inif = nc.InterfaceFromVlanTag(tPacket);
|
||||
tPacket.InboundInterface = inif;
|
||||
|
||||
List<IPAddress> addresses = nc.IPAddressList();
|
||||
List<NB_IPAddress> addresses = nc.IPAddressList();
|
||||
if (addresses.Count > 0)
|
||||
{
|
||||
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
|
||||
// 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
|
||||
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;
|
||||
|
||||
//We create a new packet
|
||||
@ -2864,8 +2864,8 @@ namespace EduNetworkBuilder
|
||||
//Console.WriteLine(" Tracert bounce: " + tPacket.OrigTTL + " " + hostname + " " + tPacket.payloadData);
|
||||
|
||||
//Finish setting up the new packet - sending it back
|
||||
nPacket.sourceIP = new IPAddress(NB.ZeroIPString);
|
||||
nPacket.TsourceIP = new IPAddress(NB.ZeroIPString);
|
||||
nPacket.sourceIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
nPacket.TsourceIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
myNet.addPacket(nPacket);
|
||||
//Console.WriteLine(" Tracert bounce pkt:" + nPacket.OrigTTL + nPacket.payloadData);
|
||||
return true;
|
||||
@ -2971,7 +2971,7 @@ namespace EduNetworkBuilder
|
||||
return arp;
|
||||
}
|
||||
|
||||
public string ArpFromIP(IPAddress IPAddress)
|
||||
public string ArpFromIP(NB_IPAddress IPAddress)
|
||||
{
|
||||
return ArpFromIP(IPAddress.GetIP.ToIpString());
|
||||
}
|
||||
@ -3018,7 +3018,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
ClearArps();
|
||||
RouteTable.Clear();
|
||||
DefaultGW = new IPAddress(NB.ZeroIPString);
|
||||
DefaultGW = new NB_IPAddress(NB.ZeroIPString);
|
||||
foreach(NetworkCard nic in NICs)
|
||||
{
|
||||
if(nic.GetNicType != NicType.port)
|
||||
@ -3032,11 +3032,11 @@ namespace EduNetworkBuilder
|
||||
public void CheckDHCPRangesAgainstInterfaces()
|
||||
{
|
||||
bool found = false;
|
||||
List<IPAddress> theInterfaces = IPAddressList();
|
||||
foreach(IPAddress dhcpIP in DHCPRanges.ToList())
|
||||
List<NB_IPAddress> theInterfaces = IPAddressList();
|
||||
foreach(NB_IPAddress dhcpIP in DHCPRanges.ToList())
|
||||
{
|
||||
found = false;
|
||||
foreach (IPAddress interfaceIP in theInterfaces)
|
||||
foreach (NB_IPAddress interfaceIP in theInterfaces)
|
||||
{
|
||||
if(interfaceIP.GetIP == dhcpIP.GetIP)
|
||||
{
|
||||
@ -3049,10 +3049,10 @@ namespace EduNetworkBuilder
|
||||
DHCPRanges.Remove(dhcpIP);
|
||||
}
|
||||
}
|
||||
foreach (IPAddress interfaceIP in theInterfaces)
|
||||
foreach (NB_IPAddress interfaceIP in theInterfaces)
|
||||
{
|
||||
found = false;
|
||||
foreach (IPAddress dhcpIP in DHCPRanges)
|
||||
foreach (NB_IPAddress dhcpIP in DHCPRanges)
|
||||
{
|
||||
if (interfaceIP.GetIP == dhcpIP.GetIP)
|
||||
{
|
||||
@ -3062,7 +3062,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
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)
|
||||
{
|
||||
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")
|
||||
{
|
||||
@ -3088,10 +3088,10 @@ namespace EduNetworkBuilder
|
||||
return theStrings;
|
||||
}
|
||||
|
||||
public IPAddress DHCPRangeMatchingInterface(IPAddress InterfaceIP)
|
||||
public NB_IPAddress DHCPRangeMatchingInterface(NB_IPAddress InterfaceIP)
|
||||
{
|
||||
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))
|
||||
return ip;
|
||||
@ -3103,9 +3103,9 @@ namespace EduNetworkBuilder
|
||||
if (index > DHCPRanges.Count) return;
|
||||
if (index < 0) return;
|
||||
bool found = false;
|
||||
IPAddress ifIP = null;
|
||||
List<IPAddress> theInterfaces = IPAddressList();
|
||||
foreach (IPAddress interfaceIP in theInterfaces)
|
||||
NB_IPAddress ifIP = null;
|
||||
List<NB_IPAddress> theInterfaces = IPAddressList();
|
||||
foreach (NB_IPAddress interfaceIP in theInterfaces)
|
||||
{
|
||||
if(interfaceIP.GetIP == DHCPRanges[index].GetIP)
|
||||
{
|
||||
@ -3118,16 +3118,16 @@ namespace EduNetworkBuilder
|
||||
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;
|
||||
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 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)
|
||||
IPAddress tGateway = GetGateway();
|
||||
NB_IPAddress tGateway = GetGateway();
|
||||
NetworkCard lNic = LocalNic(tGateway);
|
||||
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)
|
||||
{
|
||||
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))
|
||||
return addr;
|
||||
}
|
||||
@ -3183,17 +3183,17 @@ namespace EduNetworkBuilder
|
||||
/// <param name="MAC">The mac of the requesting machine</param>
|
||||
/// <param name="NIC_IP">the IP of the server nic</param>
|
||||
/// <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)
|
||||
NIC_IP = HubManagementIP();
|
||||
IPAddress tAddress = LookupDHCPLease(MAC, NIC_IP);
|
||||
NB_IPAddress tAddress = LookupDHCPLease(MAC, NIC_IP);
|
||||
if (tAddress != null && NIC_IP.IsLocal(tAddress))
|
||||
return tAddress;
|
||||
|
||||
//if we are here, we need to find an address to give.
|
||||
bool stillOK = true;
|
||||
IPAddress startaddress = DHCPRangeMatchingInterface(NIC_IP);
|
||||
NB_IPAddress startaddress = DHCPRangeMatchingInterface(NIC_IP);
|
||||
if (startaddress == null) return null;
|
||||
UInt32 sIPNum = startaddress.GetMask;
|
||||
UInt32 eIPNum = startaddress.GetGateway;
|
||||
@ -3201,17 +3201,17 @@ namespace EduNetworkBuilder
|
||||
while(stillOK)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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(!tAddress.IsLocal(gateway))
|
||||
{
|
||||
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++;
|
||||
if(sIPNum > eIPNum)
|
||||
@ -3238,7 +3238,7 @@ namespace EduNetworkBuilder
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasLocalNic(IPAddress dest)
|
||||
public bool HasLocalNic(NB_IPAddress dest)
|
||||
{
|
||||
foreach(NetworkCard nic in NICs)
|
||||
{
|
||||
@ -3328,7 +3328,7 @@ namespace EduNetworkBuilder
|
||||
if (nic == null) return false;
|
||||
NetworkInterface nif = nic.InterfaceFromName(nicname);
|
||||
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();
|
||||
|
||||
switch(rnd.Next(8))
|
||||
@ -3368,7 +3368,7 @@ namespace EduNetworkBuilder
|
||||
|
||||
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();
|
||||
|
||||
switch (rnd.Next(8))
|
||||
|
@ -12,7 +12,7 @@ namespace EduNetworkBuilder
|
||||
[Serializable]
|
||||
public class NetworkInterface
|
||||
{
|
||||
public IPAddress myIP;
|
||||
public NB_IPAddress myIP;
|
||||
public string nic_name; //eth0, eth0:0, etc
|
||||
public HostNicID AttachedToHostNic;
|
||||
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)
|
||||
{
|
||||
nic_name = name;
|
||||
myIP = new IPAddress(IP, Mask,IPAddressType.ip);
|
||||
myIP = new NB_IPAddress(IP, Mask,IPAddressType.ip);
|
||||
AttachedToHostNic = AttachedTo;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ namespace EduNetworkBuilder
|
||||
switch (Individual.Name.ToLower())
|
||||
{
|
||||
case "myip":
|
||||
myIP = new IPAddress(Individual);
|
||||
myIP = new NB_IPAddress(Individual);
|
||||
break;
|
||||
case "nicname":
|
||||
nic_name = Individual.InnerText;
|
||||
@ -186,7 +186,7 @@ namespace EduNetworkBuilder
|
||||
IPAddressEntry ipe = new IPAddressEntry(myIP,ND, ParentForm);
|
||||
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 (!AllowZeroMatch && (myIP == null || myIP.GetIP == 0))
|
||||
|
@ -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 TickTTL = 50;
|
||||
public int health = 100;
|
||||
public IPAddress sourceIP;
|
||||
public IPAddress OriginalDestIP;
|
||||
public IPAddress TsourceIP; //This is the local link source ip. It should go along with the local MAC address
|
||||
public IPAddress destIP;
|
||||
public NB_IPAddress sourceIP;
|
||||
public NB_IPAddress OriginalDestIP;
|
||||
public NB_IPAddress TsourceIP; //This is the local link source ip. It should go along with the local MAC address
|
||||
public NB_IPAddress destIP;
|
||||
public string sourceMAC;
|
||||
public string destMAC;
|
||||
public Packet payloadPacket = null;
|
||||
public string payloadData = ""; //Contains the mac-address, or ip-address string, or something else
|
||||
public string EncryptionString = "";
|
||||
public IPAddress payloadIP = null;
|
||||
public NB_IPAddress payloadIP = null;
|
||||
public PacketMessage Tracking = new PacketMessage();
|
||||
public NetworkComponent WhereAmI = null;
|
||||
public NetworkLink LastNetworkLink = null;
|
||||
@ -62,7 +62,7 @@ namespace EduNetworkBuilder
|
||||
public NetworkCard InboundNic = null;
|
||||
public NetworkInterface InboundInterface = 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 OutboundDestMAC = "";
|
||||
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
|
||||
{
|
||||
sourceIP = new IPAddress(source);
|
||||
TsourceIP = new IPAddress(source);
|
||||
destIP = new IPAddress(dest);
|
||||
sourceIP = new NB_IPAddress(source);
|
||||
TsourceIP = new NB_IPAddress(source);
|
||||
destIP = new NB_IPAddress(dest);
|
||||
if (destIP.BroadcastAddress == destIP.GetIP)
|
||||
{
|
||||
destMAC = NB.BroadcastMACString;
|
||||
@ -160,7 +160,7 @@ namespace EduNetworkBuilder
|
||||
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;
|
||||
payloadData = payload;
|
||||
@ -179,7 +179,7 @@ namespace EduNetworkBuilder
|
||||
|
||||
if (theType != PacketType.arp_answer && theType != PacketType.arp_request)
|
||||
{
|
||||
sourceIP = new IPAddress(NB.ZeroIPString);
|
||||
sourceIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
destIP = dest;
|
||||
if (destIP != null && destIP.BroadcastAddress == destIP.GetIP)
|
||||
destMAC = NB.BroadcastMACString;
|
||||
@ -188,7 +188,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceIP = new IPAddress(NB.ZeroIPString);
|
||||
sourceIP = new NB_IPAddress(NB.ZeroIPString);
|
||||
destMAC = NB.BroadcastMACString;
|
||||
destIP = dest;
|
||||
Tracking.AddMessage(DebugLevel.info, start, NB.Translate("Packet Created"));
|
||||
@ -299,7 +299,7 @@ namespace EduNetworkBuilder
|
||||
if (NB.GetComponentType(WhereAmI) == GeneralComponentType.device)
|
||||
{
|
||||
NetworkDevice ndWhere = (NetworkDevice)WhereAmI;
|
||||
IPAddress dest = ndWhere.DestinationFromIP(destIP);
|
||||
NB_IPAddress dest = ndWhere.DestinationFromIP(destIP);
|
||||
string dMAC = ndWhere.ArpFromIP(dest.GetIP.ToIpString());
|
||||
if (dMAC != "" || destMAC == NB.BroadcastMACString)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user