Fix duplicate wireless link error

This commit is contained in:
Tim Young 2015-08-28 13:58:27 -07:00
parent cf4538b585
commit 679d2f7010
4 changed files with 24 additions and 9 deletions

View File

@ -752,6 +752,7 @@ namespace EduNetworkBuilder
//We are making a link //We are making a link
LinkEditor myEditor = new LinkEditor(ItemClickedOn, ReleasedOn); LinkEditor myEditor = new LinkEditor(ItemClickedOn, ReleasedOn);
myEditor.ShowDialog(); myEditor.ShowDialog();
UpdateLinks();
pbNetworkView.Invalidate(); //In case any changes have been made pbNetworkView.Invalidate(); //In case any changes have been made
} }
else if (ItemClickedOn == null) else if (ItemClickedOn == null)

View File

@ -394,7 +394,7 @@ namespace EduNetworkBuilder
if (tPacket.MyType == PacketType.arp_request && !nf.isLocal(tPacket.destIP)) if (tPacket.MyType == PacketType.arp_request && !nf.isLocal(tPacket.destIP))
continue; //only send out arp requests on local networks continue; //only send out arp requests on local networks
nPacket = new Packet(tPacket);//Creates a new packet but sets isfresh=false nPacket = new Packet(tPacket);//Creates a new packet but sets isfresh=false
if (nf.isLocal(tPacket.OutboundIP) || tPacket.OutboundIP.GetIPString == NB.BroadcastIPString) if (tPacket.OutboundIP == null || (nf.isLocal(tPacket.OutboundIP) || tPacket.OutboundIP.GetIPString == NB.BroadcastIPString))
{ {
if ((nf != null && nf.myIP.GetIPString != NB.ZeroIPString) || nPacket.MyType == PacketType.dhcp_request) if ((nf != null && nf.myIP.GetIPString != NB.ZeroIPString) || nPacket.MyType == PacketType.dhcp_request)
{ {
@ -442,7 +442,7 @@ namespace EduNetworkBuilder
foreach (NetworkInterface nf in interfaces.ToList()) foreach (NetworkInterface nf in interfaces.ToList())
{ {
nPacket = new Packet(tPacket);//Creates a new packet but sets isfresh=false nPacket = new Packet(tPacket);//Creates a new packet but sets isfresh=false
if (nf.isLocal(tPacket.OutboundIP) || tPacket.OutboundIP.GetIPString == NB.BroadcastIPString) if (tPacket.OutboundIP != null && (nf.isLocal(tPacket.OutboundIP) || tPacket.OutboundIP.GetIPString == NB.BroadcastIPString))
{ {
if ((nf != null && nf.myIP != null && nf.myIP.GetIPString != NB.ZeroIPString) || nPacket.MyType == PacketType.dhcp_request) if ((nf != null && nf.myIP != null && nf.myIP.GetIPString != NB.ZeroIPString) || nPacket.MyType == PacketType.dhcp_request)
{ {
@ -531,7 +531,7 @@ namespace EduNetworkBuilder
//set it to be the ip of management interface //set it to be the ip of management interface
nPacket.sourceIP = WhereFrom.HubManagementIP(); nPacket.sourceIP = WhereFrom.HubManagementIP();
} }
if (nPacket.destMAC == null || nPacket.destMAC == "") if (nPacket.destMAC == null || nPacket.destMAC == "" && tPacket.OutboundIP != null)
{ {
nPacket.destMAC = WhereFrom.LookupArpFromIP(tPacket.OutboundIP.GetIPString); nPacket.destMAC = WhereFrom.LookupArpFromIP(tPacket.OutboundIP.GetIPString);
} }
@ -565,13 +565,13 @@ namespace EduNetworkBuilder
Network mynet; Network mynet;
NetworkDevice nd; NetworkDevice nd;
//We make sure the MAC matches. //We make sure the MAC matches.
if (tPacket == null) return;
tPacket.InboundNic = this; //track which nic we came in on.
if (myNicType == NicType.port || myNicType == NicType.wport)
{
//Try tracking the arp if we can
mynet = NB.GetNetwork(); mynet = NB.GetNetwork();
nd = mynet.GetDeviceFromID(myID); nd = mynet.GetDeviceFromID(myID);
if (tPacket == null) return;
tPacket.InboundNic = this; //track which nic we came in on.
if (myNicType == NicType.port || myNicType == NicType.wport || (nd.IsWirelessForwarder() && myNicType == NicType.wlan))
{
//Try tracking the arp if we can
if (tPacket.TsourceIP == null) tPacket.TsourceIP = tPacket.sourceIP; if (tPacket.TsourceIP == null) tPacket.TsourceIP = tPacket.sourceIP;
nd.StoreArp(tPacket.sourceMAC, tPacket.TsourceIP.GetIP.ToIpString(), myID); nd.StoreArp(tPacket.sourceMAC, tPacket.TsourceIP.GetIP.ToIpString(), myID);
//If it is a return DHCP packet. We should try to update the MAC //If it is a return DHCP packet. We should try to update the MAC

View File

@ -251,6 +251,7 @@ namespace EduNetworkBuilder
if(nl != null) if(nl != null)
{ {
myNet.RemoveComponent(nl); myNet.RemoveComponent(nl);
nl.Destroy();
} }
nic.ConnectedLink = -1; nic.ConnectedLink = -1;
} }
@ -647,8 +648,10 @@ namespace EduNetworkBuilder
NICs[index].Edit(); NICs[index].Edit();
//If the nic was a wireless, make sure we copy the ssid and key to all other of identical type //If the nic was a wireless, make sure we copy the ssid and key to all other of identical type
if (NICs[index].GetNicType == NicType.wport || NICs[index].GetNicType == NicType.wlan) if (NICs[index].GetNicType == NicType.wport || NICs[index].GetNicType == NicType.wlan)
{
duplicateSSIDnKey(NICs[index].SSID, NICs[index].WirelessKey, NICs[index].GetNicType); duplicateSSIDnKey(NICs[index].SSID, NICs[index].WirelessKey, NICs[index].GetNicType);
} }
}
public void DeleteNic(int index) public void DeleteNic(int index)
{ {
if (index < 0) return; if (index < 0) return;
@ -1195,6 +1198,15 @@ namespace EduNetworkBuilder
return null; return null;
} }
public bool IsWirelessForwarder()
{
if (myType == NetworkComponentType.wrepeater) return true;
if (myType == NetworkComponentType.wap) return true;
if (myType == NetworkComponentType.wbridge) return true;
if (myType == NetworkComponentType.wrouter) return true;
return false;
}
public override void ProcessPacket(Packet tPacket) public override void ProcessPacket(Packet tPacket)
{ {
//Psuedo code for processing a packet //Psuedo code for processing a packet
@ -1306,7 +1318,8 @@ namespace EduNetworkBuilder
case NicType.wlan: case NicType.wlan:
//If the packet is a new packet and is not connecting to itself //If the packet is a new packet and is not connecting to itself
//or, if it is routing away. //or, if it is routing away.
if ((tPacket.isFresh && !ExactMatch ) || (NeedsRouting && DoesRouting())) if ((tPacket.isFresh && !ExactMatch ) || (NeedsRouting && DoesRouting()) ||
IsWirelessForwarder())
{ {
//Pass it to the NIC to send out each nic+interface. //Pass it to the NIC to send out each nic+interface.
//The nic checks to see if it works and then processes it //The nic checks to see if it works and then processes it
@ -2160,7 +2173,8 @@ namespace EduNetworkBuilder
if (myType == NetworkComponentType.net_switch) return true; if (myType == NetworkComponentType.net_switch) return true;
if (myType == NetworkComponentType.wap) return true; if (myType == NetworkComponentType.wap) return true;
if (myType == NetworkComponentType.wrouter) return true; if (myType == NetworkComponentType.wrouter) return true;
if (myType == NetworkComponentType.wbridge) return true; if (myType == NetworkComponentType.wrepeater) return true;
if (myType == NetworkComponentType.wrouter) return true;
return false; return false;
} }
/// <summary> /// <summary>

View File

@ -47,7 +47,7 @@ namespace EduNetworkBuilder
Client = sNic; Client = sNic;
IsWireless = true; IsWireless = true;
} }
if(IsWireless && AccessPoint != null && Client != null) if(IsWireless && AccessPoint != null && Client != null && AccessPoint.SSID != null && AccessPoint.SSID != "")
{ {
bool donesomething=false; bool donesomething=false;
if(AccessPoint.SSID != Client.SSID) if(AccessPoint.SSID != Client.SSID)