Fix duplicate wireless link error
This commit is contained in:
		| @@ -752,6 +752,7 @@ namespace EduNetworkBuilder | ||||
|                     //We are making a link | ||||
|                     LinkEditor myEditor = new LinkEditor(ItemClickedOn, ReleasedOn); | ||||
|                     myEditor.ShowDialog(); | ||||
|                     UpdateLinks(); | ||||
|                     pbNetworkView.Invalidate(); //In case any changes have been made | ||||
|                 } | ||||
|                 else if (ItemClickedOn == null) | ||||
|   | ||||
| @@ -394,7 +394,7 @@ namespace EduNetworkBuilder | ||||
|                         if (tPacket.MyType == PacketType.arp_request && !nf.isLocal(tPacket.destIP)) | ||||
|                             continue;  //only send out arp requests on local networks | ||||
|                         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) | ||||
|                             { | ||||
| @@ -442,7 +442,7 @@ namespace EduNetworkBuilder | ||||
|                     foreach (NetworkInterface nf in interfaces.ToList()) | ||||
|                     { | ||||
|                         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) | ||||
|                             { | ||||
| @@ -531,7 +531,7 @@ namespace EduNetworkBuilder | ||||
|                         //set it to be the ip of management interface | ||||
|                         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); | ||||
|                     } | ||||
| @@ -565,13 +565,13 @@ namespace EduNetworkBuilder | ||||
|             Network mynet; | ||||
|             NetworkDevice nd; | ||||
|             //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(); | ||||
|             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; | ||||
|                 nd.StoreArp(tPacket.sourceMAC, tPacket.TsourceIP.GetIP.ToIpString(), myID); | ||||
|                 //If it is a return DHCP packet.  We should try to update the MAC | ||||
|   | ||||
| @@ -251,6 +251,7 @@ namespace EduNetworkBuilder | ||||
|                         if(nl != null) | ||||
|                         { | ||||
|                             myNet.RemoveComponent(nl); | ||||
|                             nl.Destroy(); | ||||
|                         } | ||||
|                         nic.ConnectedLink = -1; | ||||
|                    } | ||||
| @@ -647,8 +648,10 @@ namespace EduNetworkBuilder | ||||
|             NICs[index].Edit(); | ||||
|             //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) | ||||
|             { | ||||
|                 duplicateSSIDnKey(NICs[index].SSID, NICs[index].WirelessKey, NICs[index].GetNicType); | ||||
|             } | ||||
|         } | ||||
|         public void DeleteNic(int index) | ||||
|         { | ||||
|             if (index < 0) return; | ||||
| @@ -1195,6 +1198,15 @@ namespace EduNetworkBuilder | ||||
|             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) | ||||
|         { | ||||
|             //Psuedo code for processing a packet | ||||
| @@ -1306,7 +1318,8 @@ namespace EduNetworkBuilder | ||||
|                     case NicType.wlan: | ||||
|                         //If the packet is a new packet and is not connecting to itself | ||||
|                         //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. | ||||
|                             //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.wap) 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; | ||||
|         } | ||||
|         /// <summary> | ||||
|   | ||||
| @@ -47,7 +47,7 @@ namespace EduNetworkBuilder | ||||
|                     Client = sNic; | ||||
|                     IsWireless = true; | ||||
|                 } | ||||
|                 if(IsWireless && AccessPoint != null && Client != null) | ||||
|                 if(IsWireless && AccessPoint != null && Client != null && AccessPoint.SSID != null && AccessPoint.SSID != "") | ||||
|                 { | ||||
|                     bool donesomething=false; | ||||
|                     if(AccessPoint.SSID != Client.SSID) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user